VisualAge for Java Integration

Last update : September 25 2001

About
  • What is Cactus ?
  • Features/Status
  • Goals
  • News/Changes
  • Roadmap/Todo
  • Contributors
  • Contributing
  • License
  • Feedback


  • Downloads
  • Downloads


  • Documentation
  • How it works ?
  • Getting Started
  • Mock vs Container
  • API Reference


  • Howto Guides
  • Config Howto
  • TestCase Howto
  • Ant Howto
  • HttpUnit Howto
  • Sample Howto
  • EJB Howto
  • IDE Howto


  • Support
  • Bug database
  • Mailing list
  • FAQ


  • Misc.
  • Why the name ?
  • Resources


  • Developers
  • CVS
  • Coding Conventions


  • Forewords and Requirements

    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 3 projects : one for JUnit, one for Cactus ( let's call it "Cactus") 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.

    Note 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.

    Note 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>
           <document-root>$approot$/web</document-root>
           <classpath>$approot$/servlets</classpath>
           <root-uri>/test</root-uri>
           <auto-reload enabled="true" polling-interval="3000"/>
           <shared-context>false</shared-context>
        </websphere-webgroup>
    

    Note 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}/host/default_app/servlets and put the following content :

    <?xml version="1.0"?>
    <webapp>
       <name>test</name>
       <description>Cactus testing web application</description>
       <error-page>/ErrorReporter</error-page>
    
       <servlet>
          <name>ServletRedirector</name>
          <description>Cactus Testing ServletRedirector</description>
          <code>org.apache.cactus.server.ServletTestRedirector</code>
          <servlet-path>/ServletRedirector</servlet-path>
          <autostart>false</autostart>
          <init-parameter>
            <name>param1</name>
            <value>value1 used for testing</value>
        </init-parameter>
       </servlet>
    
       <!-- 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 -->
    
       <servlet>
          <name>ErrorReporter</name>
          <description>Default error reporter servlet</description>
          <code>com.ibm.servlet.engine.webapp.DefaultErrorReporter</code>
          <servlet-path>/ErrorReporter</servlet-path>
          <autostart>true</autostart>
       </servlet>
    
       <servlet>
          <name>jsp</name>
          <description>JSP support servlet</description>
    
          <!--
            WARNING:
    
            If you use the JSP 1.0 compiler, use the following
              <code>com.ibm.ivj.jsp.runtime.JspDebugServlet</code>
    
            If you use the JSP 1.1 compiler (VAJava 3.5.3 only), use the following
              <code>com.ibm.ivj.jsp.jasper.runtime.JspDebugServlet</code>
          -->
          <code>com.ibm.ivj.jsp.jasper.runtime.JspDebugServlet</code>
    
          <init-parameter>
             <name>workingDir</name>
             <value>$server_root$/temp/default_app</value>
          </init-parameter>
          <init-parameter>
             <name>jspemEnabled</name>
             <value>true</value>
          </init-parameter>
          <init-parameter>
             <name>scratchdir</name>
             <value>$server_root$/temp/JSP1_1/default_app</value>
          </init-parameter>
          <init-parameter>
             <name>keepgenerated</name>
             <value>true</value>
          </init-parameter>
          <autostart>true</autostart>
          <servlet-path>*.jsp</servlet-path>
       </servlet>
    
       <servlet>
          <name>file</name>
          <description>File serving servlet</description>
          <code>com.ibm.servlet.engine.webapp.SimpleFileServlet</code>
          <servlet-path>/</servlet-path>
          <init-parameter>
             <name></name>
             <value></value>
          </init-parameter>
          <autostart>true</autostart>
       </servlet>
    </webapp>
    

    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\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, Log4j, and the project that contained the tests to the classpath.


    Final note

    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.




    Copyright © 2000-2001 The Apache Software Foundation. All Rights Reserved.