INTEGRATION TEST WITH EMBEDDED OPENEJB
The embedded OpenEJB server will use an in-memory HSQLDB database. The significance of in-memory is that it will start empty and be discarded afterwards.
We specify the database in business/src/test/conf-openejb-local/openejb.xml, and we will set system property openejb.configuration to that file.
- Choose Run > Open Run Dialog.... The Run window will appear.
- Right-click on JUnit and choose New.
|
- Set Test Runner to JUnit 4.
- Set the other variables to values similar to those shown in the screen shot on the left.
|
- Click on the Arguments tab.
|
- Set the VM arguments to the following, replacing the value of openejb.home with yours, eg.:
-Dopenejb.home=../openejb-3.1 -Dopenejb.configuration=business/src/test/conf-openejb-local/openejb.xml -Dhibernate.hbm2ddl.auto=update
The openejb.xml file configures openejb to use a different database: an in-memory database.
These properties are explained here:
openejb,
hibernate.
|
- Click on the Classpath tab.
|
- Remove the (default classpath) entry.
It will be the project name followed by (default classpath). Remove it.
- Click on User Entries.
- Add conf-openejb-local from business tests.
Choose Advanced... > Add Folders, then from your project choose business/src/test/conf-openejb-local/.
- Add jumpstart.jar from exploded.
Choose Advanced... > Add Folders, then from your project choose exploded/jumpstart.ear/jumpstart.jar/.
- Add JARs from business libs.
Choose Add JARs..., open your project, then choose these JARs:
- Add OpenEJB from user libraries.
Choose Advanced... > Add Library > User Library, then select your openejb-3.1-lib library.
- Move conf and jumpstart.jar to the top. Otherwise there will be problems
(eg. log4j.properties is in conf and bsf.jar).
|
- Click Run.
- Watch the results in the JUnit View panel. In the Console View you might see lots of exceptions but that's normal.
The JUnit View will tell you quickly whether the tests succeeded or not.
Problems? Eclipse might not be ready for junit - see
Could not create task or type of type: junit.