Skip to end of metadata
Go to start of metadata

To use a datasource from a unit test, you need to set up the datasource from the unit test itself.

The nuxeo-runtime-datasource bundle provides some framework for you to register datasource in JNDI through Nuxeo contributions instead of relying on a container like Tomcat to do it for you.

The steps to follow are:

Depend on nuxeo-runtime-datasource

In your pom.xml, add the dependency:

In some circumstances, if your test dependencies aren't followed correctly, you may have to add as well:

Contribute a datasource definition

You first need to define your datasource. For instance in the file OSGI-INF/datasource-contrib.xml add:

Deploy the datasource from the unit test setup

As our example datasource contains a variable for the storage path itself, we initialize this variable from the test code before reading the contribution. Of course you could hardcode things if you prefer.

Using the old SQLDirectoryTestCase

Using JUnit4 and the Nuxeo FeaturesRunner

You may want to use a Feature that looks like:

Use the datasource in the test

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.