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.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=/devel/openejb-4.5.1
    -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/ .
  6. Add all JARs from these folders:
    business/src/main/lib-compile/
    business/src/main/lib-runtime/ (actually, lib-runtime is empty)
    business/src/test/lib-test/
    business/src/test/lib-test-hibernate/
  7. Add user library apache-openejb-4.5.1-lib.
  8. Move the two folders to the top. It avoids conflicts.

 

©2008, 2012 Geoff Callender, Sydney, Australia