|
DataNucleus uses JUnit for unit testing. DataNucleus uses 2 types of unit tests.
-
Component tests
- the traditional "unit" test and these are stored in SVN
with the project they are testing.
-
End-to-End tests
- where we persist objects in a datastore, and test the
result. These are stored in their own separate projects in SVN
For this second type, and because JDO/JPA have 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 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 base dependents of all test scenarios are the following projects
-
test.framework
- providing the base test classes for creating PMF/EMF
for the datastore, and convenience methods.
-
test.samples
- providing a series of model classes that can be used in
the test scenario for persistence.
The first thing to do is to build these projects, by typing the following in
each of these 2 projects.
So now you have the infrastructure built to run the end-to-end tests. We run these as
particular test scenarios. There are many scenarios including
-
test.jdo.general
- General tests for JDO
-
test.jdo.datastore
- Datastore identity specific tests for JDO
-
test.jdo.application
- Application identity specific tests for JDO
-
test.jdo.jta
- Tests for using JDO with JTA (but not JCA)
-
test.jdo.spatial
- Spatial tests for JDO
-
test.jdo.db4o
- Tests specific to DB4O, using JDO
-
test.jdo.rdbms
- Tests specific to RDBMS, using JDO
-
test.jdo.orm.datastore
- Tests specific to ORM with datastore id, using JDO
-
test.jdo.orm.application
- Tests specific to ORM with app id, using JDO
-
test.jdo.ldap
- Tests specific to LDAP, using JDO
-
test.jdo.excel
- Tests specific to Excel, using JDO
-
test.jpa.general
- General tests for JPA
-
test.jpa.rdbms
- Tests specific to RDBMS, using JPA
To run a test scenario, go into the scenario project and type
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 scneario at some later point.
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.
-
test.jca.jdo
- EJB application with tests for JDO
Where you feel that our unit tests do not adequately cover functionality,
you should add a test. Please follow the following process
-
Decide which scenario your test fits into (e.g test.jdo.general, test.jpa.general)
-
Look at the available model samples (test.samples) and choose one.
-
Write your unit test, extending one of the common base classes,
for example
JDOPersistenceTestCase
, or
JPAPersistenceTestCase
-
Run your test.
-
Raise a JIRA and attach your testcase to the issue
Each test project contains a "project.properties" file that determines which database will be
used for running the tests of that particular project, e.g. test.jdo.general/project.properties.
The value of the property
maven.datanucleus.datastore
refers to database configuration files 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
-
test.framework/src/conf/datanucleus-hsql.
1
.properties, and
-
test.framework/src/conf/datanucleus-hsql.
2
.properties
The default database configured in the test projects is hsqldb.
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
Refer also to the Oracle spfile (see also
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
.
If you face OutOfMemory errors, increase the
Xms
and
Xmx
JVM args for running
the junit tests.
|
|