You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by "Mitchell, Glen (Corporate Channel Development)" <Gl...@rbs.co.uk> on 2003/08/26 17:59:00 UTC

Cactus + Ant + WebSphere

Hello,

I am new to using the WebSphere app server and have been trying to get
Cactus tests to run against the app server using Ant tasks.

Is it possible to run cactus tests on Websphere using ANT. I know it is
possible to do this within the Websphere development environment but is it
possible to do this using an ANT script outside of WSAD, where I deploy the
EAR file to a server, start the server and then run the tests, using the
WebSphere and tasks .i.e wsdeployejb, wsStartServer, wsStopServer

Within the <cactus> ANT task there is no support for the WebSphere container
but I used the generic container to try and get the WebSphere container
running. Unfortunately the container failed to start and everything timed
out after 180000ms. 

Thus is it possible to do what what I am attempting.

I have attached my build.xml file (its a bit of a hack of the cactus servlet
sample) to this email. The target "test" gives hopefully an idea of what I
have outlined above 

Thanks
Glen Mitchell


<?xml version="1.0"?>

<!--
 
============================================================================
=
    Build file for the Cactus Servlet Sample subproject. It shows how to use
    Cactus for unit testing the Servlet API (Servlets, Filters and Taglibs).

    The following Ant tasks need to be available in your ant installation
(i.e.
    the Ant task themselves and their dependent jars need to be put in
    ANT_HOME/lib):

        junit                  [REQUIRED] JUnit Ant task

    Check the build.properties file to find out what properties need to be
set
    in order to successfully run this script.

    This script should be started with the following command line:

        ant <target>

    Run "ant -projecthelp" to get a list of available targets.
 
============================================================================
=
-->
<project name="Cactus Servlet Sample" default="dist" basedir=".">

    <!-- Give user a chance to override without editing this file
       (and without typing -D each time it compiles it) -->
  <property file="build.properties" />
  <property file="${user.home}/build.properties" />

  <!-- Global project properties -->
  <property name="project.name.text" value="Cactus Servlet Sample"/>
  <property name="project.name.file" value="sample-servlet"/>
  <property name="project.version" value="1.5-beta1"/>

  <!-- Prefix to add to all distributable files -->
  <property name="project.prefix" value="jakarta-"/>

  <!-- Generic properties -->
  <property name="year" value="2000-2003"/>
  <property name="debug" value="on"/>
  <property name="optimize" value="off"/>
  <property name="deprecation" value="off"/>

  <!-- Properties for the Cactus tests -->
  <property name="cactus.port" value="8080"/>

  <!--
 
========================================================================
       Set the properties related to the source tree.
 
========================================================================
  -->
  <property name="src.dir" location="src"/>
  <property name="src.java.dir" location="${src.dir}/java"/>
  <property name="src.conf.dir" location="${src.dir}/conf"/>
  <property name="src.cactus.dir" location="${src.dir}/test-cactus"/>
  <property name="src.webapp.dir" location="${src.dir}/webapp"/>

  <!--
 
========================================================================
       Set the properties related to the target area
 
========================================================================
  -->
  <!-- Destination locations for the build -->
  <property name="target.dir" location="target"/>
  <property name="target.classes.dir" location="${target.dir}/classes"/>
  <property name="target.classes.java.dir"
      location="${target.classes.dir}/java"/>
  <property name="target.classes.cactus.dir"
      location="${target.classes.dir}/cactus"/>
  <property name="target.testreports.dir"
      location="${target.dir}/test-reports"/>

  <!-- Distribution directory, i.e. where the expanded distibutable files
       are located -->
  <property name="dist.dir" location="dist"/>

  <!--
 
========================================================================
       Set the properties related to the required libraries
 
========================================================================
  -->

  <!-- Libraries required for the sample project -->
  <property name="servlet.jar"
      location="../../lib/servletapi-2.3.jar"/>
  <property name="jstl.jar"
      location="lib/jstl-1.0.2.jar"/>
  <property name="standard.jar"
      location="lib/standard-1.0.2.jar"/>
  <path id="project.classpath">
    <pathelement location="${servlet.jar}"/>
    <pathelement location="${jstl.jar}"/>
    <pathelement location="${standard.jar}"/>
  </path>

  <!-- Libraries required for the Cactus tests -->
  <property name="aspectjrt.jar"
      location="../../lib/aspectjrt-1.0.6.jar"/>
  <property name="cactus.jar"
      location="../../lib/cactus-1.5-beta1.jar"/>
  <property name="cactus.ant.jar"
      location="../../lib/cactus-ant-1.5-beta1.jar"/>
  <property name="commons.httpclient.jar"
      location="../../lib/commons-httpclient-2.0-beta2.jar"/>
  <property name="commons.logging.jar"
      location="../../lib/commons-logging-1.0.3.jar"/>
  <property name="httpunit.jar"
      location="../../lib/httpunit-1.5.3.jar"/>
  <property name="junit.jar"
      location="../../lib/junit-3.8.1.jar"/>
  <property name="nekohtml.jar"
      location="../../lib/nekohtml-0.7.4.jar"/>
  <path id="cactus.classpath">
    <path refid="project.classpath"/>
    <pathelement location="${aspectjrt.jar}"/>
    <pathelement location="${cactus.jar}"/>
    <pathelement location="${cactus.ant.jar}"/>
    <pathelement location="${commons.httpclient.jar}"/>
    <pathelement location="${commons.logging.jar}"/>
    <pathelement location="${junit.jar}"/>
  </path>

<property name="ear.dir" location="ear"/>

  <!-- load properties file -->
  <property file="test.properties"/> 


  <!-- Libraries required for the WSAD ANT tests -->
  <path id="wsad.ant.classpath">
    <pathelement location="${wsad.ant.jar}"/>
  </path> 



  <!--
 
========================================================================
       Initialize the build. Must be called by all targets
 
========================================================================
  -->
  <target name="init">

    <condition property="properties.ok">
      <and>
        <available file="${servlet.jar}"/>
        <available file="${jstl.jar}"/>
        <available file="${standard.jar}"/>
      </and>
    </condition>
    <fail unless="properties.ok">Missing property or property pointing to an
invalid file
(check your build.properties file)</fail>

    <taskdef resource="cactus.tasks" classpathref="cactus.classpath"/>

    <taskdef file="wsad.tasks" classpathref="wsad.ant.classpath"/>

    <tstamp/>

  </target>

  <!--
 
========================================================================
       Compiles the sources
 
========================================================================
  -->
  <!-- Compiles the java sources -->
  <target name="compile.java" depends="init">

    <mkdir dir="${target.classes.java.dir}"/>
    <javac destdir="${target.classes.java.dir}"
        deprecation="${deprecation}" optimize="${optimize}">
      <src path="${src.java.dir}"/>
      <classpath>
        <path refid="project.classpath"/>
      </classpath>
    </javac>

  </target>

  <!-- Compiles the Cactus test sources -->
  <target name="compile.cactus" depends="compile.java">

    <mkdir dir="${target.classes.cactus.dir}"/>
    <javac destdir="${target.classes.cactus.dir}"
        deprecation="${deprecation}" optimize="${optimize}">
      <src path="${src.cactus.dir}"/>
      <classpath>
        <path refid="cactus.classpath"/>
        <pathelement location="${httpunit.jar}"/>
        <pathelement location="${nekohtml.jar}"/>
        <pathelement location="${target.classes.java.dir}"/>
      </classpath>
    </javac>

  </target>

  <target name="compile" depends="compile.java, compile.cactus"
      description="Compile the sources"/>

  <!--
 
========================================================================
       Create the runtime war file
 
========================================================================
  -->
  <target name="war" depends="compile.java"
      description="Generate the runtime war">

    <war warfile="${target.dir}/${project.name.file}.war"
         webxml="${src.webapp.dir}/WEB-INF/web.xml">
      <fileset dir="${src.webapp.dir}">
        <exclude name="cactus-report.xsl"/>
        <exclude name="WEB-INF/cactus-web.xml"/>
        <exclude name="WEB-INF/web.xml"/>
      </fileset>
      <classes dir="${target.classes.java.dir}"/>
      <lib file="${jstl.jar}"/>
      <lib file="${standard.jar}"/>
    </war>

  </target>

  <!--
 
========================================================================
       Generate the distributable files
 
========================================================================
  -->
  <target name="dist" depends="clean, war, test"
      description="Generate the distributable files">

    <copy todir="${dist.dir}"
        file="${target.dir}/${project.name.file}.war"/>

  </target>

  <!--
 
========================================================================
       Clean generated files (including distributables)
 
========================================================================
  -->
  <target name="clean" depends="init" description="Clean all generated
files">

    <delete dir="${target.dir}"/>
    <delete dir="${dist.dir}"/>

  </target>

  <!--
 
========================================================================
       Run the tests on the containers for which the Ant property
       "cactus.home.[container name]" has been defined.
 
========================================================================
  -->
  <target name="test.prepare" depends="war, compile.cactus">
  
    <!-- Cactify the web-app archive -->
    

    
    <!-- Prepare the directories for the JUnit reports -->
    <mkdir dir="${target.testreports.dir}"/>
    <mkdir dir="${target.testreports.dir}/jboss3x"/>
    <mkdir dir="${target.testreports.dir}/orion1x"/>
    <mkdir dir="${target.testreports.dir}/orion2x"/>
    <mkdir dir="${target.testreports.dir}/resin2x"/>
    <!-- mkdir dir="${target.testreports.dir}/tomcat3x"/ -->
    <mkdir dir="${target.testreports.dir}/tomcat4x"/>
    <mkdir dir="${target.testreports.dir}/tomcat5x"/>
    <mkdir dir="${target.testreports.dir}/weblogic7x"/>

  </target>

  <target name="test" depends="test.prepare"
      description="Run the tests on the defined containers">

    <!-- Run the tests -->
    <cactus earfile="${ear.dir}/TestCactusEAR.ear" fork="yes"
        failureproperty="tests.failed">
      <classpath>
        <path refid="project.classpath"/>
        <pathelement location="${clover.jar}"/>
        <pathelement location="${httpunit.jar}"/>
        <pathelement location="${nekohtml.jar}"/>
        <pathelement location="${target.classes.java.dir}"/>
        <pathelement location="${target.classes.cactus.dir}"/>
      </classpath>
      <containerset>
  	<generic name="CactusTest" port="9080" startuptarget="start.server"
shutdowntarget="stop.server"/>
      </containerset>
      <formatter type="brief" usefile="false"/>
      <formatter type="xml"/>
      <batchtest>
        <fileset dir="${src.cactus.dir}">
          <!-- Due to some Cactus synchronization bug, the 'unit' tests need
               to run before the 'sample' tests -->
          <include name="**/unit/Test*.java"/>
          <exclude name="**/unit/Test*All.java"/>
        </fileset>
      </batchtest>
      <batchtest>
        <fileset dir="${src.cactus.dir}">
          <include name="**/sample/Test*.java"/>
          <exclude name="**/sample/Test*All.java"/>
        </fileset>
      </batchtest>
    </cactus>

    <!-- Generate the JUnit reports -->
    <junitreport todir="${target.testreports.dir}/jboss3x">
      <fileset dir="${target.testreports.dir}/jboss3x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/jboss3x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/orion1x">
      <fileset dir="${target.testreports.dir}/orion1x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/orion1x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/orion2x">
      <fileset dir="${target.testreports.dir}/orion2x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/orion2x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/resin2x">
      <fileset dir="${target.testreports.dir}/resin2x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/resin2x"
          format="frames"/>
    </junitreport>
    <!-- junitreport todir="${target.testreports.dir}/tomcat3x">
      <fileset dir="${target.testreports.dir}/tomcat3x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/tomcat3x"
          format="frames"/>
    </junitreport -->
    <junitreport todir="${target.testreports.dir}/tomcat4x">
      <fileset dir="${target.testreports.dir}/tomcat4x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/tomcat4x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/tomcat5x">
      <fileset dir="${target.testreports.dir}/tomcat5x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/tomcat5x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/weblogic7x">
      <fileset dir="${target.testreports.dir}/weblogic7x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/weblogic7x"
          format="frames"/>
    </junitreport>

    <fail if="tests.failed">At least one test failed!</fail>

  </target>


  <target name="deploy" depends="init">
    <wsejbdeploy inputJar="${ear.dir}/TestCactusEAR.ear"
outputJar="${ear.dir}/TestCactus1EAR.ear" wasHome="${wsad.home}"/>
  </target>

  <target name="start.server" depends="deploy">
    <wsStartServer server="server1" wasHome="${wsad.home}"/>
  </target>
  
  <target name="stop.server" depends="init">
    <wsStopServer server="server1" wasHome="${wsad.home}"/>  
  </target>

</project>



The Royal Bank of Scotland plc ('the Bank') is regulated by the Financial 
Services Authority and is a member of The Royal Bank of Scotland Marketing
Group.  The only packaged products (life policies, unit trusts and other
collective investment schemes and stakeholder and other pensions) the Bank
advises on and sells are those of the Marketing Group, whose other members
are Royal Scottish Assurance plc and Royal Bank of Scotland Unit Trust
Management Limited, both regulated by the Financial Services Authority.

The Royal Bank of Scotland plc. Registered in Scotland No 90312.  Registered
Office: 36 St Andrew Square, Edinburgh EH2 2YB. 

Agency agreements exist between members of The Royal Bank of Scotland Group.

This e-mail message is confidential and for use by the addressee only. If
the message is received by anyone other than the addressee, please return
the message to the sender by replying to it and then delete the message from
your computer. Internet e-mails are not necessarily secure. The Royal Bank
of Scotland plc does not accept responsibility for changes made to this
message after it was sent. 

Whilst all reasonable care has been taken to avoid the transmission of
viruses, it is the responsibility of the recipient to ensure that the onward
transmission, opening or use of this message and any attachments will not
adversely affect its systems or data. No responsibility is accepted by The
Royal Bank of Scotland plc in this regard and the recipient should carry out
such virus and other checks as it considers appropriate.


RE: Cactus + Ant + WebSphere

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Glen,

There is no limitation in Cactus as to what application server you use
(provided it supports the Servlet spec). Now the cactus Ant task that we
provide does not include a websphere container (simply because we're not
using websphere and nobody has contributed code for it).

The approach you've taken is the correct one (i.e. using the generic
container). If your start and stop targets are working then it should
work fine.

If you could provide the output you get maybe we could help.

Thanks
-Vincent

> -----Original Message-----
> From: Mitchell, Glen (Corporate Channel Development)
> [mailto:Glen.Mitchell@rbs.co.uk]
> Sent: 26 August 2003 17:59
> To: 'cactus-user@jakarta.apache.org'
> Subject: Cactus + Ant + WebSphere
> 
> Hello,
> 
> I am new to using the WebSphere app server and have been trying to get
> Cactus tests to run against the app server using Ant tasks.
> 
> Is it possible to run cactus tests on Websphere using ANT. I know it
is
> possible to do this within the Websphere development environment but
is it
> possible to do this using an ANT script outside of WSAD, where I
deploy
> the
> EAR file to a server, start the server and then run the tests, using
the
> WebSphere and tasks .i.e wsdeployejb, wsStartServer, wsStopServer
> 
> Within the <cactus> ANT task there is no support for the WebSphere
> container
> but I used the generic container to try and get the WebSphere
container
> running. Unfortunately the container failed to start and everything
timed
> out after 180000ms.
> 
> Thus is it possible to do what what I am attempting.
> 
> I have attached my build.xml file (its a bit of a hack of the cactus
> servlet
> sample) to this email. The target "test" gives hopefully an idea of
what I
> have outlined above
> 
> Thanks
> Glen Mitchell

[snip]