DataNucleus uses JUnit (3.x) for unit testing. The traditional style of "unit" test are included with the project that they are testing. For example "core" has some "unit" tests, and these are run when you build the project.
End-to-End tests also use JUnit, and are available under the tests/accessplatform/trunk part of Subversion. In these tests we persist objects in a datastore, and test the result. There are several scenarios for this type of test, because JDO/JPA have many aspects. By this we mean that we separate our tests into what they test. When developing anything, the tests should be the guiding light as to whether you should be checking anything in to SVN. If your change breaks things, you shouldn't check things in. Each test "scenario" has its own project in SVN with names like "test.jdo.general", "test.jpa.general", etc.
The first thing you require is to obtain and build this project. It is the top level for all "test" projects.
mvn clean install
This builds the jar under "target" and installs it into your Maven2 repository.
The first thing you require is to build this project. It provides a framework for all test scenarios and is available in SVN under test/accessplatform/trunk/test.framework. To build the "test.framework" using Maven, you simply type (from the test.framework project)
mvn clean install
This builds the jar under "target" and installs it into your Maven2 repository.
The next thing you require is to build this project. It provides sample model classes for use in the majority of test scenarios and is available in SVN under test/accessplatform/trunk/test.samples). These are the classes to be persisted, but do not include the information about how they will be persisted (that is specified in the individual test suite). To build the "test.samples" using Maven, you simply type (from the test.samples project)
mvn clean install
This builds the jar under "target" and installs it into your Maven2 repository.
So we have now built the test.framework and test.samples projects and are ready to run any of the "scenarios". There are many scenarios including
To run a test scenario, go into the scenario project and type
mvn clean test
This then runs the tests for that scenario. There are also occasionally additional tests under org.datanucleus.tests.knownbugs and org.datanucleus.tests.newfeatures intended for incorporation into the test scenario at some later point; these are not run by default.
To run the tests on a different datastore (default=H2) type
mvn clean test -Pmysql
or replace "mysql" with "postgresql", "oracle", "mongodb", "hbase" etc
Long term strategy is to just have the overall test scenarios that apply just to JDO or JPA and drop the datastore-specific scenarios except where providing some feature specific to that datastore. Reality is that we don't have resource to do this yet, so typically run such as test.jdo.mongodb for testing MongoDB, which obviously only tests a small subset of what ought to be tested. Offering your time to make all store plugins more feature complete is the only way this task will be performed.
The DataNucleus JCA connector test scenarios are the following projects. To run these tests you must create the data source, deploy the DataNucleus JCA connector and deploy the EJB application.
Where you feel that our unit tests do not adequately cover functionality, you should add a test. Please follow the following process
Each test project is run against a datastore (as defined above). The configuration of the datastores is stored under test.framework/src/conf. Some tests require two database instances, which is why for every database there exist two files, e.g. "maven.datanucleus.datastore=hsql" refers to both
The default database configured in the test projects is H2.
Following are notes about running the DataNucleus unit tests with particular databases.
If you face the issue ORA-12519, TNS:no appropriate service handler, try increasing the parameters sessions and processes to 300 and open_cursors to 1000. To change these values in Oracle, issue the following statements.
alter system set open_cursors = 1000 scope=spfile alter system set sessions = 300 scope=spfile alter system set processes = 300 scope=spfile
*.processes=300 *.sessions=300 *.open_cursors=1000
If you face the issue ORA-01000: maximum open cursors exceeded, try increasing the parameter open_cursors to 1000 in the file initXE.ora or init.ora.
*.open_cursors=1000
If you face OutOfMemory errors, increase the Xms and Xmx JVM args for running the junit tests.