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 Pedro Nevado <pn...@javato.com> on 2004/09/07 12:25:46 UTC

Problem with runservertests task _and solution.

I will answer myself my yesterday post, in case someone suffer from the same
naivety I do in respect of the internals of Tomcat. So, please, expert
readers allow me some obviousness.

The ant script to run Cactus tests with Servlet 2.4 especification is:

<target name="run_testCactus" depends="new_contextCactus">
        <runservertests
            testurl="${cactus.contextURL}"
            starttarget="start.tomcat5"
            stoptarget="stop.tomcat5"
            testtarget="testCactus"/>
    </target>

    <target name="testCactus" depends="clean_testCactus">
        <mkdir dir="${testCactus.reports.dir}"/>
        <junit printsummary="false" haltonerror="false"
haltonfailure="false"
               fork="${junit.fork}"
               errorproperty="testCactus.failed"
               failureproperty="testCactus.failed"
            >
            <formatter type="plain" usefile="false" />
            <formatter type="xml" />
            <classpath>
                <pathelement path="${testCactus.path}"/>
                <pathelement location="${log4j.jar}" />
            </classpath>
            <assertions>
                <enable package="com.espivo.vivoen"/>
            </assertions>
            <batchtest todir="${testCactus.reports.dir}" unless="testClass"
>
               <fileset dir="${testCactus.build.class.dir}"
includes="**/*Test.class" />
            </batchtest>
        </junit>
        <junitreport todir="${testCactus.reports.dir}">
            <fileset dir="${testCactus.reports.dir}" includes="TEST-*.xml"/>
            <report todir="${testCactus.reports.dir}/html" format="frames"/>
        </junitreport>
        <fail if="testCactus.failed">At least one test failed after making
report!</fail>
    </target>

    <target name="start.tomcat5">
        <java classname="org.apache.catalina.startup.Bootstrap"
            failonerror="yes" fork="true">
            <jvmarg value="-Dcatalina.home=${env.CATALINA_HOME}"/>
            <jvmarg value="-Dcatalina.base=${env.CATALINA_HOME}"/>
            <arg value="-config"/>
            <arg value="${env.CATALINA_HOME}/conf/server.xml"/>
            <arg value="start"/>
            <classpath>
              <pathelement path="${java_comp.path}"/>
              <fileset dir="${env.CATALINA_HOME}"
includes="bin/bootstrap.jar"/>
            </classpath>
        </java>
    </target>
    <target name="stop.tomcat5">
        <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
            <jvmarg value="-Dcatalina.home=${env.CATALINA_HOME}"/>
            <jvmarg value="-Dcatalina.base=${env.CATALINA_HOME}"/>
            <arg value="-config"/>
            <arg value="${env.CATALINA_HOME}/conf/server.xml"/>
            <arg value="stop"/>
            <classpath>
              <pathelement path="${java_comp.path}"/>
              <fileset dir="${env.CATALINA_HOME}">
                  <include name="bin/bootstrap.jar"/>
              </fileset>
            </classpath>
        </java>
    </target>

With this script you elude the parsing of the cactus and warcactification
tasks, which treat 2.4 web.xml as is they were 2.2.
It is compatible with unpacked applications referenced in context.xml
archives in your catalina_home/conf/catalina/localhost, so no need for a
previous .war or a customised server.xml.
Thanks to the people who wrote the build-tests.xml file in the Struts 1.2.2
distribution.

Regards,
Pedro Nevado



RE: Problem with runservertests task _and solution.

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

I highly recommend that you use the Cargo Ant task to start/stop/configure
your container (see http://cargo.codehaus.org).

Thanks for posting back and explaining the solution!

Cheers,
-Vincent

> -----Original Message-----
> From: Pedro Nevado [mailto:pnevado@javato.com]
> Sent: mardi 7 septembre 2004 12:26
> To: cactus-user@jakarta.apache.org
> Subject: Problem with runservertests task _and solution.
> 
> I will answer myself my yesterday post, in case someone suffer from the
> same
> naivety I do in respect of the internals of Tomcat. So, please, expert
> readers allow me some obviousness.
> 
> The ant script to run Cactus tests with Servlet 2.4 especification is:
> 
> <target name="run_testCactus" depends="new_contextCactus">
>         <runservertests
>             testurl="${cactus.contextURL}"
>             starttarget="start.tomcat5"
>             stoptarget="stop.tomcat5"
>             testtarget="testCactus"/>
>     </target>
> 
>     <target name="testCactus" depends="clean_testCactus">
>         <mkdir dir="${testCactus.reports.dir}"/>
>         <junit printsummary="false" haltonerror="false"
> haltonfailure="false"
>                fork="${junit.fork}"
>                errorproperty="testCactus.failed"
>                failureproperty="testCactus.failed"
>             >
>             <formatter type="plain" usefile="false" />
>             <formatter type="xml" />
>             <classpath>
>                 <pathelement path="${testCactus.path}"/>
>                 <pathelement location="${log4j.jar}" />
>             </classpath>
>             <assertions>
>                 <enable package="com.espivo.vivoen"/>
>             </assertions>
>             <batchtest todir="${testCactus.reports.dir}"
> unless="testClass"
> >
>                <fileset dir="${testCactus.build.class.dir}"
> includes="**/*Test.class" />
>             </batchtest>
>         </junit>
>         <junitreport todir="${testCactus.reports.dir}">
>             <fileset dir="${testCactus.reports.dir}" includes="TEST-
> *.xml"/>
>             <report todir="${testCactus.reports.dir}/html"
> format="frames"/>
>         </junitreport>
>         <fail if="testCactus.failed">At least one test failed after making
> report!</fail>
>     </target>
> 
>     <target name="start.tomcat5">
>         <java classname="org.apache.catalina.startup.Bootstrap"
>             failonerror="yes" fork="true">
>             <jvmarg value="-Dcatalina.home=${env.CATALINA_HOME}"/>
>             <jvmarg value="-Dcatalina.base=${env.CATALINA_HOME}"/>
>             <arg value="-config"/>
>             <arg value="${env.CATALINA_HOME}/conf/server.xml"/>
>             <arg value="start"/>
>             <classpath>
>               <pathelement path="${java_comp.path}"/>
>               <fileset dir="${env.CATALINA_HOME}"
> includes="bin/bootstrap.jar"/>
>             </classpath>
>         </java>
>     </target>
>     <target name="stop.tomcat5">
>         <java classname="org.apache.catalina.startup.Bootstrap"
> fork="yes">
>             <jvmarg value="-Dcatalina.home=${env.CATALINA_HOME}"/>
>             <jvmarg value="-Dcatalina.base=${env.CATALINA_HOME}"/>
>             <arg value="-config"/>
>             <arg value="${env.CATALINA_HOME}/conf/server.xml"/>
>             <arg value="stop"/>
>             <classpath>
>               <pathelement path="${java_comp.path}"/>
>               <fileset dir="${env.CATALINA_HOME}">
>                   <include name="bin/bootstrap.jar"/>
>               </fileset>
>             </classpath>
>         </java>
>     </target>
> 
> With this script you elude the parsing of the cactus and warcactification
> tasks, which treat 2.4 web.xml as is they were 2.2.
> It is compatible with unpacked applications referenced in context.xml
> archives in your catalina_home/conf/catalina/localhost, so no need for a
> previous .war or a customised server.xml.
> Thanks to the people who wrote the build-tests.xml file in the Struts
> 1.2.2
> distribution.
> 
> Regards,
> Pedro Nevado
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org