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.

  • Set Test Runner to JUnit 4.
  • Set the other variables to values similar to those shown in the screen shot on the left.
  • 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.
  1. Remove the (default classpath) entry. It will be the project name followed by (default classpath). Remove it.
  2. Click on User Entries.
  3. Add conf-openejb-local from business tests. Choose Advanced... > Add Folders, then from your project choose business/src/test/conf-openejb-local/.
  4. Add jumpstart.jar from exploded. Choose Advanced... > Add Folders, then from your project choose exploded/jumpstart.ear/jumpstart.jar/.
  5. Add JARs from business libs. Choose Add JARs..., open your project, then choose these JARs:
  6. Add OpenEJB from user libraries. Choose Advanced... > Add Library > User Library, then select your openejb-3.1-lib library.
  7. Move conf and jumpstart.jar to the top. Otherwise there will be problems (eg. log4j.properties is in conf and bsf.jar).

Problems? Eclipse might not be ready for junit - see Could not create task or type of type: junit.

 

©2008 Geoff Callender, Sydney, Australia