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.:
    -Djumpstart.ejb-provider=OPENEJB_7_LOCAL
    -Dlog4j.configurationFile=log4j.properties
    -Dopenejb.configuration=business/src/test/conf/openejb-in-memory.xml
    -Dopenejb.home=/devel/apache-openejb-7.0.4
    -Dhibernate.hbm2ddl.auto=update
  • The openejb-in-memory.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 these 2 folders (Advanced... > Add folders):
    business/src/test/conf/
    collapsed/jumpstart.war/WEB-INF/classes/
  5. 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/
  6. Add 1 user library (Advanced... > Add Library > User Library):
    apache-openejb-7.0.4-lib
  7. Ensure the two folders are at the top. It avoids conflicts.

 

©2017, 2018 Geoff Callender, Sydney, Australia