jvanzyl 2002/06/27 20:22:53
Added: src/plugins/cactus build.xml
Log:
iutest which can grow into a cactus test.
Revision Changes Path
1.1 jakarta-turbine-maven/src/plugins/cactus/build.xml
Index: build.xml
===================================================================
<?xml version="1.0"?>
<project name="maven-iutest" default="test" basedir="..">
<!-- ================================================================== -->
<!-- I N I T -->
<!-- ================================================================== -->
<target name="init" unless="maven.init">
<taskdef
name="create-classpath"
classname="org.apache.maven.ant.CreateClasspath">
<classpath>
<pathelement location="${lib.repo}/maven.jar"/>
</classpath>
</taskdef>
<create-classpath
listFile="${maven.home}/plugins/core/jars.list"
reference="pre-maven-classpath"
baseDir="${lib.repo}"
/>
<path id="maven-classpath">
<path refid="pre-maven-classpath"/>
<pathelement location="${lib.repo}/maven.jar"/>
</path>
<!-- define maven taskdefs, as taskdefs are not yet inheritable? -->
<taskdef resource="maven-taskdefs.properties">
<classpath refid="maven-classpath" />
</taskdef>
<property name="maven.init" value="true" />
<!-- call common build file initialization to verify project, update jars
load project and default properties etc -->
<maven-ant antfile="${maven.home}/plugins/core/build-init.xml"
target="verify-project"
inheritAll="true"
inheritRefs="true"
exportAll="true"
exportRefs="true"/>
</target>
<!-- ================================================================== -->
<!-- I U T E S T I N I T -->
<!-- ================================================================== -->
<!-- Create the default properties if they are not defined alread from -->
<!-- one of the loaded proeprty files. -->
<!-- ================================================================== -->
<target
name="iutest-init"
depends="init">
<echo>
iutest.dir -----> ${maven.iutest.dir}
out.test.dir ---> ${maven.out.test.dir}
webapp.dir -----> ${maven.webapp.dir}
conf.test.dir --> ${maven.conf.test.dir}
tomcat.home ----> ${maven.tomcat.home}
test.port ------> ${maven.test.port}
</echo>
<!-- iutest -->
<condition property="maven.iutest.callback.pre-iutest.ok">
<and>
<available file="${maven.iutest.callback.pre-iutest.buildFile}"/>
<not>
<equals arg1="${maven.iutest.callback.pre-iutest.buildTarget}"
arg2="$${maven.iutest.callback.pre-iutest.buildTarget}" />
</not>
</and>
</condition>
<condition property="maven.iutest.callback.post-iutest.ok">
<and>
<available file="${maven.iutest.callback.post-iutest.buildFile}"/>
<not>
<equals arg1="${maven.iutest.callback.post-iutest.buildTarget}"
arg2="$${maven.iutest.callback.post-iutest.buildTarget}" />
</not>
</and>
</condition>
</target>
<!-- ================================================================== -->
<!-- C O M P I L E T E S T S -->
<!-- ================================================================== -->
<target
name="compile"
depends="iutest-init">
<!-- Make sure the core code is compiled -->
<maven-ant antfile="${maven.home}/plugins/core/build.xml" target="compile"/>
<mkdir dir="${maven.iutest.dest}"/>
<javac
destdir="${maven.iutest.dest}"
excludes="**/package.html"
debug="${maven.compile.debug}"
deprecation="${maven.compile.deprecation}"
optimize="${maven.compile.optimize}">
<classpath>
<path refid="maven.dependency.classpath"/>
<pathelement path="${maven.build.dest}"/>
</classpath>
<src>
<path location="${maven.iutest.dir}"/>
</src>
</javac>
</target>
<!-- ================================================================== -->
<!-- S E R V E R T E S T S -->
<!-- ================================================================== -->
<target
name="iutest"
depends="iutest-init,pre-iutest-callback,do-iutest,post-iutest-callback"
description="==> runs in-container tests via jakarta-cactus"/>
<target name="pre-iutest-callback" if="maven.iutest.callback.pre-iutest.ok">
<maven-ant antfile="${maven.iutest.callback.pre-iutest.buildFile}"
target="${maven.iutest.callback.pre-iutest.buildTarget}"
inheritRefs="true" exportAll="false" exportRefs="false"/>
</target>
<target
name="do-iutest"
depends="start-test"
if="maven.integrationUnitTestSourceDirectory">
</target>
<target name="post-iutest-callback" if="maven.iutest.callback.post-iutest.ok">
<maven-ant antfile="${maven.iutest.callback.post-iutest.buildFile}"
target="${maven.iutest.callback.post-iutest.buildTarget}"
inheritRefs="true" exportAll="false" exportRefs="false"/>
</target>
<target
name="start-test"
if="maven.integrationUnitTestSourceDirectory"
depends="compile,prepare-tests-tomcat-40">
<taskdef
name="RunServerTests"
className="org.apache.cactus.ant.RunServerTestsTask">
<classpath refid="maven.dependency.classpath"/>
</taskdef>
<!--
Start the servlet engine, wait for it to be started, run the
unit tests, stop the servlet engine, wait for it to be stopped.
The servlet engine is stopped if the tests fail for any reason
-->
<RunServerTests
testURL="http://localhost:${maven.test.port}/test"
startTarget="start-tomcat-40"
stopTarget="stop-tomcat-40"
testTarget="run-iutests"/>
</target>
<target
name="run-iutests"
depends="iutest-init">
<mkdir dir="${maven.test.reportsDirectory}"/>
<junit
printsummary="yes"
haltonfailure="yes"
haltonerror="yes">
<classpath>
<path refid="maven.dependency.classpath"/>
<pathelement location="${maven.build.dest}"/>
<pathelement location="${maven.iutest.dest}"/>
</classpath>
<sysproperty key="basedir" value="${basedir}"/>
<formatter type="xml"/>
<formatter type="plain" usefile="${maven.junit.usefile}"/>
<batchtest todir="${maven.test.reportsDirectory}">
<fileset dir="${maven.iutest.dir}">
<patternset refid="maven.integration.unit.test.set"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- =================================================================== -->
<!-- S T A R T T O M C A T 4 . 0 -->
<!-- =================================================================== -->
<target
name="start-tomcat-40">
<java
classname="org.apache.catalina.startup.Bootstrap"
fork="yes">
<jvmarg value="-Dcatalina.home=${maven.tomcat.home}"/>
<arg value="-config"/>
<arg value="${maven.out.tomcat40.full.dir}/conf/server.xml"/>
<arg value="start"/>
<classpath>
<pathelement location="${java.home}/../lib/tools.jar"/>
<fileset dir="${maven.tomcat.home}">
<include name="bin/bootstrap.jar"/>
</fileset>
</classpath>
</java>
</target>
<!-- =================================================================== -->
<!-- S T O P T O M C A T 4 . 0 -->
<!-- =================================================================== -->
<target
name="stop-tomcat-40">
<java
classname="org.apache.catalina.startup.Bootstrap"
fork="yes">
<jvmarg value="-Dcatalina.home=${maven.tomcat.home}"/>
<arg value="stop"/>
<classpath>
<fileset dir="${maven.tomcat.home}">
<include name="bin/bootstrap.jar"/>
<include name="server/catalina.jar"/>
</fileset>
</classpath>
</java>
</target>
<!-- =================================================================== -->
<!-- Display a warning message if the needed servlet engine home -->
<!-- property is not set -->
<!-- =================================================================== -->
<target
name="check-tests-tomcat-40"
depends="testwar"
unless="maven.tomcat.home">
<echo>
*********************************************************
WARNING : The 'maven.tomcat.home' property has not been set.
No test will be run on that servlet engine.
*********************************************************
</echo>
</target>
<!-- =================================================================== -->
<!-- C R E A T E T E S T W A R F I L E -->
<!-- =================================================================== -->
<target
name="testwar"
depends="iutest-init,compile">
<!-- Make sure the directory for the war exist -->
<delete dir="${maven.out.test.dir}"/>
<mkdir dir="${maven.out.test.dir}"/>
<!-- Create the WEB-INF/lib directory that will be used
with the testapp -->
<war
warfile="${maven.out.test.dir}/test.war"
webxml="${maven.conf.test.dir}/web.xml">
<lib dir="${lib.repo}">
<patternset refid="maven.dependency.set"/>
<exclude name="servlet*.jar"/>
</lib>
<!-- We want to test Turbine core classes -->
<classes dir="${maven.build.dest}"/>
<classes dir="${maven.iutest.dest}"/>
<fileset dir="${maven.webapp.dir}">
<exclude name="**/CVS/*"/>
<exclude name="**/WEB-INF/web.xml"/>
</fileset>
</war>
</target>
<!-- =================================================================== -->
<!-- Prepare directories and variables for running the tests -->
<!-- =================================================================== -->
<target
name="prepare-tests-tomcat-40"
depends="check-tests-tomcat-40"
if="maven.tomcat.home">
<echo message="maven.tomcat.home = ${maven.tomcat.home}"/>
<property name="maven.out.tomcat40.dir" value="${maven.out.test.dir}/tomcat40"/>
<property name="maven.conf.tomcat40.dir"
value="${maven.conf.test.dir}/tomcat40"/>
<property name="maven.out.tomcat40.full.dir" value="${maven.out.tomcat40.dir}"/>
<filter token="maven.out.tomcat40.full.dir"
value="${maven.out.tomcat40.full.dir}"/>
<filter token="maven.test.port" value="${maven.test.port}"/>
<!-- Create work and conf directories and copy configuration files -->
<mkdir dir="${maven.out.tomcat40.dir}/conf"/>
<mkdir dir="${maven.out.tomcat40.dir}/work"/>
<mkdir dir="${maven.out.tomcat40.dir}/webapps"/>
<!-- Delete some config file so that they will be copied every time -->
<delete file="${maven.out.tomcat40.dir}/conf/server.xml"/>
<!-- Remove the auto deployed webapp so that it is redeployed every -->
<!-- time. -->
<delete dir="${maven.out.tomcat40.dir}/webapps/test"/>
<!-- Copy the default tomcat web.xml to our test conf/ directory. -->
<!-- This is needed otherwise tomcat does not start. -->
<copy
file="${maven.tomcat.home}/conf/web.xml"
tofile="${maven.out.tomcat40.dir}/conf/web.xml"
filtering="on"/>
<copy
file="${maven.conf.tomcat40.dir}/server.xml"
tofile="${maven.out.tomcat40.dir}/conf/server.xml"
filtering="on"/>
<!-- Copy the war file -->
<copy
file="${maven.out.test.dir}/test.war"
tofile="${maven.out.tomcat40.dir}/webapps/test.war"/>
<!-- As this classes directory will be used to run the client side
of Cactus, we need to copy the cactus.properties -->
<copy
todir="${maven.build.dest}"
file="${maven.conf.test.dir}/cactus.properties"
filtering="on"/>
</target>
</project>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>