![]() | ![]() |
![]() |
| Project | Ver 1.1 | Ver 1.2 | JDO | JPA | Guides | Tools |
| 1.1 | Preparation | O/R Mapping | Runtime | Extensions | Developer |
JPOX uses JUnit for unit testing. JPOX uses 2 types of unit tests. The first type are traditional component tests (for individual classes). The second type are more like end-to-end tests where we are persisting objects to a datastore and performing real JDO operations. For this second type, and because JDO has many aspects, we use a "scenario" testing strategy. By this we mean that we separate our unit tests into what they test. When developing anything, the unit tests should be the guiding light as to whether you should be checking anything in to CVS. If your change breaks things, you shouldn't check things in.
There are currently 3 scenarios
Because the last 2 scenarios are very similar in nature, we often use the same classes for testing, but specify different MetaData, meaning that the class is persisted in different ways. The way this is done is by providing jdoa (application id) and jdod (datastore id) MetaData files. These are standard MetaData files, but with a different suffix to define which applies where. This is then interpreted by the testing process and copied across to the testing area with suffix jdo. Some things to bear in mind :-
The "persistence" unit tests are run via a Maven jpoxtest plugin. You need to install the "jpoxtest" Maven plugin before running the tests. Go to the "Plugins/JPOXTest" project and build/install the plugin. Read the README.tests file in the JPOX/Core directory for other dependences and troubleshooting in general for using Maven for JPOX. When preparing to run you need to familiarise yourself with the contents of project.properties (which specifies the RDBMS to run, and the JDBC jar to use), and the "TestFramework" project which has RDBMS config files under "src/conf". To run the "persistence" unit tests with Maven you use the following goals, each representing a test scenario respectively
maven jpoxtest-general
maven jpoxtest-datastore
maven jpoxtest-application
The results of the tests are stored under target/test-reports-{scenario name}. The testing process with Maven operates in 2 ways. The first is for the component based unit tests that are run via the "test" plugin. The persistence unit tests are run via the "jpoxtest" plugin. This provides the functionality necessary for a persistence scenario to be tested. It operates as follows
The Ant process operates similarly to Maven, using Ant scripts. To run Ant, you need to use the following Ant targets : test.general, test.datastore, test.application, test.Enhancer to run the different test scenarios. The results of the tests are stored under tests/results/. ant test.general ant test.datastore ant
test.application ant test.schema ant test.Enhancer In addition, you can run the Ant target test to run all test scenarios : general, schema, datastore, application and Enhancer. ant test If you want run independent tests cases with Ant, use the following command :
ant test.case -Dtest.suite.case=Test -Dtest.suite.case.identity=scenario
ant test.case -Dtest.suite.case=**/RelationshipTest.class -Dtest.suite.case.identity=datastore
ant test.case -Dtest.suite.case=**/RelationshipTest.class -Dtest.suite.case.identity=application
Where you feel that our unit tests do not adequately cover functionality, you should add a test. Please follow the following process
The SCO collection unit tests sit in their own area (org.jpox.sco) and are all related, in the same way as all java Collections are related. Each collection type has its own subdirectory containing helper classes and elements to be persisted. In addition there is one test class for each SCO collection class. The test class tests Normal and Inverse operation of the collection class.
Debugging JPOX unit tests might be very boring, but there is a way of reducing the pain in Eclipse using the JPOX Eclipse Plugin. Follow the next steps to make this easier:
To debug the JPOX enhancement, follow the next steps:
This section has notes about running the JPOX unit tests with certain 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 in the file initXE.ora or init.ora. *.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. |