INTEGRATION TEST WITH REMOTE TOMCAT

Tomcat is simply a servlet container which lacks Enterprise Java capabilities like JPA (persistence) and JTA (transactions), so we will install the OpenEJB for Tomcat plug-in. Rather than package JumpStart into an EAR we will package it in a WAR in Collapsed EAR format.

Prepare Tomcat 5.5.x or 6.0.x for JumpStart

The DataSource is set in ${catalina.base}/conf/openejb.xml. By default it uses the HSQLDB whose files are in ${catalina.base}/data/hsqldb/.

Prepare the build

Either build and run the tests from Ant...

Ant will compile, package and deploy jumpstart.war to the server, wait for it to load, then run the integration test suite which will test through the session beans running in the server.

...or build with Ant and run/debug the tests from Eclipse

First, use Ant to compile, package and deploy jumpstart.war to the server and wait for it to load:

Second, create a User Library over Tomcat:

Run the integration test suite from Eclipse:

  • Set Test Runner to JUnit 4.
  • Set the other variables as shown in the diagram on the left.
  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-tomcat-remote from business tests. Choose Advanced... > Add Folders, then from your project choose business/src/test/conf-tomcat-remote/.
  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 Tomcat client from user libraries. Choose Advanced... > Add Library > User Library, then select your tomcat-client-lib library.
  7. Move conf and jumpstart.jar to the top to avoid any conflicts.
Of course, since JumpStart is now running in your server, you can visit it with your web browser at http://yourserver:8080/jumpstart.

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

 

©2008 Geoff Callender, Sydney, Australia