2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

Forewords and Requirements

This tutorial is written for Cactus 1.2 only. It will need to adapted if you're using Cactus 1.3

This tutorial explains how to run Cactus tests within VisualAge for Java WebSphere Test Environment.

We have received reports that the following tutorial works with VAJava 3.5.2 and 3.5.3. Please tell us if you find that it works with other versions.

Step 1: Import the correct packages in VAJava

Let's assume the following conventions: {Cactus dir} is the directory where you have unzipped the Cactus distribution or sources and {VAJava dir} is the directory where VAJava is installed. Let's also define {WTE dir} to be the WebSphere Test Environment directories, i.e. {VAJava dir}/ide/project_resources/IBM WebSphere Test Environment.

You need to create 4 projects: one for JUnit, one for Cactus ( let's call it "Cactus"), one for HttpClient and optionally one for Log4j. Note that the Log4j one is useful only if wish to get some Cactus runtime logs. If you don't import the Log4j classes, some Cactus classes will appear with a red cross in VAJava but you can safely ignore them as they won't be executed.

You can either import the source files or the compiled classes as you wish. If you import the source file, you should import the following directories: {Cactus dir}/src/framework/servlet22 and {Cactus dir}/src/framework/share. You also need to copy the following files into {VAJava dir}/ide/project_resources/Cactus: log_client.properties and log_server.properties which are located in {Cactus dir}/sample/conf/test. If you have imported from the Cactus jar file, and you have selected to import resources files then they have been automatically imported for you.

Step 2: Set up the cactus.properties file

Copy your cactus.properties file (see the Configuration Howto tutorial for details on cactus.properties) to {VAJava dir}/ide/project_resources/Cactus.

As WebSphere does not support the jsp-file tag in web.xml, we cannot map the redirector JSP to a name, so instead of writing "cactus.jspRedirectorURL = http://localhost:8080/test/JspRedirector" in cactus.properties, you should simply put the JSP file name, as in "cactus.jspRedirectorURL = http://localhost:8080/test/jspRedirector.jsp". This is only needed if you have test cases that extend JspTestCase.

Step 3: Modify WebSphere Test Environment

Edit default.servlet_engine

Edit {WTE dir}/properties/default.servlet_engine and add the following under the default_app webgroup:

    <websphere-webgroup name="test">
       <description>Cactus Testing Web Application</description>
       <auto-reload enabled="true" polling-interval="3000"/>
The init-parameter is only needed if you wish to run sample application provided in the Cactus distribution. Also, in order to run this sample application you'll need to copy the {Cactus dir}/sample/web/test/test.jsp file to {WTE dir}/hosts/default_host/test/web/test as it is used by a test case.

Create a test directory

Create a directory called test under {WTE dir}/hosts/default_host. Under test create another 2 subdirectories: servlets and web.

Create a test.webapp file

Create a test.webapp file in {WTE dir}/hosts/default_host/test/servlets and put the following content:

<?xml version="1.0"?>
   <description>Cactus testing web application</description>

      <description>Cactus Testing ServletRedirector</description>
        <value>value1 used for testing</value>

   <!-- Note: We don't provide a mapping for the JSP Redirector because
        WebSphere does not support the jsp-file tag of the Servlet 2.2
        specification -->

      <description>Default error reporter servlet</description>

      <description>JSP support servlet</description>


        If you use the JSP 1.0 compiler, use the following

        If you use the JSP 1.1 compiler (VAJava 3.5.3 only), use the following


      <description>File serving servlet</description>

Copy the Cactus JSP Redirector file

Copy the {Cactus dir}/sample/web/test/jspRedirector.jsp file to {WTE dir}/hosts/default_host/test/web.

Step 4: Edit VAJava workspace classpath

Add the following to the VAJava workspace classpath (select menu "Window... | Resources" under VAJava):

{VAJava dir}\ide\project_resources\JUnit\;
{VAJava dir}\ide\project_resources\Cactus\;
{VAJava dir}\ide\project_resources\HttpClient\;
{VAJava dir}\ide\project_resources\Log4j\;
{VAJava dir}\ide\project_resources\Servlet API Classes\;

Step 5: Edit VAJava workspace classpath

In the WebSphere Test Environment under Servlet Engine, add Cactus, JUnit, HttpClient, Log4j, and the project that contained the tests to the classpath.

Final note

With this configuration, you'll find cactus_client.log under {VAJava dir}/ide/project_resources/{project being tested} and cactus_server.log under {VAJava dir}/ide/tools/com-ibm-ivj-ui-webcontrolcenter when you run your tests. If you get a "Failed to invoke suite(): java.lang.NoClassDefFoundError" error message, you msy get around that problem by explicitly adding the test cases to the TestSuite that's returned in suite(), for your test case.