INTEGRATION TEST IN ECLIPSE 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 > Run Configurations.... The Run Configurations 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 in the screen shot on the right.
  • 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.2
    -Dopenejb.configuration=business/src/test/conf/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. Click on the Classpath tab.
  2. Remove the (default classpath) entry.
  3. Click on User Entries.
  4. Add folder business/src/test/conf/ .
  5. Add folder collapsed/jumpstart.war/WEB-INF/classes/ or,
    if you're using an exploded EAR,
    then add folder exploded/jumpstart.ear/jumpstart.jar/ .
  6. Add all JARs from these folders:
    business/src/main/lib-compile/
    business/src/main/lib-provided/
    business/src/main/lib-runtime/
    business/src/test/lib-test/
    business/src/test/lib-test-openejb-local/
  7. Add user library openejb-3.1.2-lib.
  8. Move the two folders to the top. It avoids conflicts.

 

©2008 Geoff Callender, Sydney, Australia