brekke 02/03/25 20:48:53
Modified: . project.xml
src/java/org/apache/maven ProjectProperties.java
src/java/org/apache/maven/project Build.java
src/templates/build Control.vm build.xml default.properties
src/templates/project project.xml
xdocs build-file.xml project-descriptor.xml
Added: src/templates/build build-iutest.xml
Log:
First cut at support for integration unit testing ( was runtime-testing ).
This is the runtime test functionality renamed using terminology from the
cactus website. It is really a simple cactus harness which runs the test
cases inside a container. Tomcat in this case.
All areas that were referred to as runtimeTestXXX are now
integrationUnitTestXXX. Added a pattern set for the jars that are project
dependencies. This is used to build up a war for the test container. The
new delegator target is 'maven:iutest' and I took a shot at adding some
short documentation explaining the target. It is modelled after the rttest
stuff in the old builds of t2/t3.
Revision Changes Path
1.39 +3 -3 jakarta-turbine-maven/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/project.xml,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- project.xml 26 Mar 2002 04:39:07 -0000 1.38
+++ project.xml 26 Mar 2002 04:48:53 -0000 1.39
@@ -259,9 +259,9 @@
<unitTestClassEntry>exclude =
**/WorkspaceMapperTest.class</unitTestClassEntry>
</unitTestClassEntries>
- <!-- Runtime unit test classes -->
- <runtimeTestClassEntries>
- </runtimeTestClassEntries>
+ <!-- Integration unit test classes -->
+ <integrationUnitTestClassEntries>
+ </integrationUnitTestClassEntries>
<!-- J A R R E S O U R C E S -->
<!-- Resources that are packaged up inside the JAR file -->
1.15 +30 -14
jakarta-turbine-maven/src/java/org/apache/maven/ProjectProperties.java
Index: ProjectProperties.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/ProjectProperties.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ProjectProperties.java 26 Mar 2002 04:39:07 -0000 1.14
+++ ProjectProperties.java 26 Mar 2002 04:48:53 -0000 1.15
@@ -54,24 +54,25 @@
* <http://www.apache.org/>.
*/
-import java.io.File;
-import java.util.Iterator;
-import java.util.List;
-import org.apache.tools.ant.types.PatternSet;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
-import org.apache.commons.lang.Strings;
+
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+import org.apache.commons.lang.Strings;
import org.apache.maven.executor.ProjectExecutor;
import org.apache.maven.project.Dependency;
import org.apache.maven.project.Project;
-
import org.apache.stratum.xo.Mapper;
-
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.PatternSet;
import org.apache.velocity.context.Context;
/**
@@ -80,7 +81,7 @@
* the project.
*
* @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: ProjectProperties.java,v 1.14 2002/03/26 04:39:07 jvanzyl Exp $
+ * @version $Id: ProjectProperties.java,v 1.15 2002/03/26 04:48:53 brekke Exp $
*/
public class ProjectProperties
extends ProjectExecutor
@@ -96,6 +97,9 @@
log("Creating classpath reference ...");
createClasspathReference();
+ log("Creating dependency.set ...");
+ createDependencySet();
+
log("Creating source set reference ...");
createPathReference("src.set",
mavenProject.getBuild().getSourceDirectories());
@@ -108,9 +112,9 @@
createPatternSetReference("unit.test.set",
mavenProject.getBuild().getUnitTestClassEntries());
- log("Creating run-time test class entries reference ...");
- createPatternSetReference("runtime.test.set",
- mavenProject.getBuild().getRuntimeTestClassEntries());
+ log("Creating integration unit test class entries reference ...");
+ createPatternSetReference("integration.unit.test.set",
+ mavenProject.getBuild().getIntegrationUnitTestClassEntries());
createJarResourcesProperty();
@@ -181,6 +185,18 @@
getProject().addReference("classpath", classpath);
}
+ // Create a set of the dependencies
+ private void createDependencySet()
+ {
+ List depNames = new Vector(mavenProject.getDependencies().size());
+ for (Iterator i = mavenProject.getDependencies().iterator(); i.hasNext();)
+ {
+ Dependency dep = (Dependency)i.next();
+ depNames.add(dep.getJar());
+ } // end of for (Iterator = .iterator(); .hasNext();)
+ createPatternSetReference("dependency.set", depNames);
+ }
+
// Create the source directories reference
private void createPathReference(String reference, List directories)
{
1.4 +10 -10
jakarta-turbine-maven/src/java/org/apache/maven/project/Build.java
Index: Build.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/Build.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Build.java 24 Feb 2002 17:28:16 -0000 1.3
+++ Build.java 26 Mar 2002 04:48:53 -0000 1.4
@@ -59,7 +59,7 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Build.java,v 1.3 2002/02/24 17:28:16 jvanzyl Exp $
+ * @version $Id: Build.java,v 1.4 2002/03/26 04:48:53 brekke Exp $
*/
public class Build
extends BaseObject
@@ -79,9 +79,9 @@
/**
* Pattern set entries used to control which classes
- * participate in runtime testing.
+ * participate in integration unit testing.
*/
- private List runtimeTestClassEntries;
+ private List integrationUnitTestClassEntries;
/**
* Path entries that control which source directories are used
@@ -113,7 +113,7 @@
{
jarResources = new ArrayList();
unitTestClassEntries = new ArrayList();
- runtimeTestClassEntries = new ArrayList();
+ integrationUnitTestClassEntries = new ArrayList();
sourceDirectories = new ArrayList();
testSourceDirectories = new ArrayList();
aspectSourceDirectories = new ArrayList();
@@ -153,19 +153,19 @@
}
/**
- * Adds a feature to the RuntimeTestClassEntry attribute of the Build object
+ * Adds a feature to the integrationUnitTestClassEntry attribute of the Build
object
*/
- public void addRuntimeTestClassEntry(String runtimeTestClassEntry)
+ public void addIntegrationUnitTestClassEntry(String
integrationUnitTestClassEntry)
{
- runtimeTestClassEntries.add(runtimeTestClassEntry);
+ integrationUnitTestClassEntries.add(integrationUnitTestClassEntry);
}
/**
- * Gets the runtimeTestClassEntries attribute of the Build object
+ * Gets the integrationUnitTestClassEntries attribute of the Build object
*/
- public List getRuntimeTestClassEntries()
+ public List getIntegrationUnitTestClassEntries()
{
- return runtimeTestClassEntries;
+ return integrationUnitTestClassEntries;
}
/**
1.12 +7 -0 jakarta-turbine-maven/src/templates/build/Control.vm
Index: Control.vm
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/Control.vm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Control.vm 14 Mar 2002 22:23:35 -0000 1.11
+++ Control.vm 26 Mar 2002 04:48:53 -0000 1.12
@@ -5,6 +5,7 @@
$buildElements.add("build-metrics.xml")
$buildElements.add("build-docs.xml")
$buildElements.add("build-test.xml")
+$buildElements.add("build-iutest.xml")
$buildElements.add("build-maven.xml")
$buildElements.add("default.properties")
@@ -26,6 +27,12 @@
## -------------------------------------------------------
$delegators.put("test","build-test.xml")
+
+## -------------------------------------------------------
+## Make our list of build-iutest.xml delegators
+## -------------------------------------------------------
+
+$delegators.put("iutest","build-iutest.xml")
## -------------------------------------------------------
## Make our list of build-metrics.xml delegators
1.24 +5 -0 jakarta-turbine-maven/src/templates/build/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/build.xml,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- build.xml 15 Mar 2002 04:03:02 -0000 1.23
+++ build.xml 26 Mar 2002 04:48:53 -0000 1.24
@@ -49,6 +49,11 @@
</target>
<target
+ name="maven:iutest">
+ <ant antfile="$mavenDirectory/build-iutest.xml" target="test"/>
+ </target>
+
+ <target
name="maven:singletest">
<ant antfile="$mavenDirectory/build-test.xml" target="run-singletest"/>
</target>
1.10 +13 -1 jakarta-turbine-maven/src/templates/build/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/default.properties,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- default.properties 17 Mar 2002 00:42:39 -0000 1.9
+++ default.properties 26 Mar 2002 04:48:53 -0000 1.10
@@ -17,9 +17,21 @@
docs.dest = ${basedir}/docs
gen.docs = ${build.dir}/generated-xdocs
+##
+# Properties that are used for the integration unit tests
+# Defined here so they can easily be overridden by project
+# specific properties if necessary.
+##
+iutest.dir = ${src.dir}/iutest
+webapp.dir = ${iutest.dir}/testapp
+conf.test.dir = ${iutest.dir}/cactus
+tomcat.home = ${tdk.home}
+test.port = 8192
+
+##
# These names will actually be based on the versioning document
# that morgan checked into jakarta-site2 the other day.
-
+##
final.name = ${id}-${currentVersion}
final.dir = ${basedir}/${final.name}
1.1 jakarta-turbine-maven/src/templates/build/build-iutest.xml
Index: build-iutest.xml
===================================================================
<?xml version="1.0"?>
<project name="$project.id" default="test" basedir="$antBasedir">
#parse("build.init.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">
<property name="out.test.dir" value="target/iutest"/>
<property name="build.dest" value="target/classes"/>
<property name="test.reportsDirectory" value="test-reports"/>
<echo>
iutest.dir -----> ${iutest.dir}
webapp.dir -----> ${webapp.dir}
conf.test.dir --> ${conf.test.dir}
tomcat.home ----> ${tomcat.home}
test.port ------> ${test.port}
</echo>
</target>
<!-- ================================================================== -->
<!-- C O M P I L E T E S T S -->
<!-- ================================================================== -->
<target
name="compile">
<ant antfile="$mavenDirectory/build-test.xml" target="compile"/>
</target>
<!-- ================================================================== -->
<!-- S E R V E R T E S T S -->
<!-- ================================================================== -->
<target
name="test"
depends="compile,prepare-tests-tomcat-40"
description="==> runs in-container tests via jakarta-cactus">
<taskdef
name="RunServerTests"
className="org.apache.cactus.ant.RunServerTestsTask">
<classpath refid="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:${test.port}/test"
startTarget="start-tomcat-40"
stopTarget="stop-tomcat-40"
testTarget="run-iutests"/>
</target>
<target
name="run-iutests"
depends="iutest-init">
<mkdir dir="${test.reportsDirectory}"/>
<junit
printsummary="yes"
haltonfailure="yes"
haltonerror="yes">
<classpath>
<path refid="classpath"/>
<pathelement location="${build.dest}"/>
</classpath>
<sysproperty key="basedir" value="${basedir}"/>
<formatter type="xml"/>
<formatter type="plain"/>
<batchtest todir="${test.reportsDirectory}">
<fileset dir="${build.dest}">
<patternset refid="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=${tomcat.home}"/>
<arg value="-config"/>
<arg value="${out.tomcat40.full.dir}/conf/server.xml"/>
<arg value="start"/>
<classpath>
<pathelement location="${java.home}/../lib/tools.jar"/>
<fileset dir="${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=${tomcat.home}"/>
<arg value="stop"/>
<classpath>
<fileset dir="${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="tomcat.home">
<echo>
*********************************************************
WARNING : The '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="${out.test.dir}"/>
<mkdir dir="${out.test.dir}"/>
<!-- Create the WEB-INF/lib directory that will be used
with the testapp -->
<war
warfile="${out.test.dir}/test.war"
webxml="${conf.test.dir}/web.xml">
<lib dir="${lib.repo}">
<patternset refid="dependency.set"/>
<exclude name="servlet*.jar"/>
</lib>
<!-- We want to test Turbine core classes -->
<classes dir="${build.dest}"/>
<fileset dir="${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="tomcat.home">
<echo message="tomcat.home = ${tomcat.home}"/>
<property name="out.tomcat40.dir" value="${out.test.dir}/tomcat40"/>
<property name="conf.tomcat40.dir" value="${conf.test.dir}/tomcat40"/>
<property name="out.tomcat40.full.dir" value="${basedir}/${out.tomcat40.dir}"/>
<filter token="out.tomcat40.full.dir" value="${out.tomcat40.full.dir}"/>
<filter token="test.port" value="${test.port}"/>
<!-- Create work and conf directories and copy configuration files -->
<mkdir dir="${out.tomcat40.dir}/conf"/>
<mkdir dir="${out.tomcat40.dir}/work"/>
<mkdir dir="${out.tomcat40.dir}/webapps"/>
<!-- Delete some config file so that they will be copied every time -->
<delete file="${out.tomcat40.dir}/conf/server.xml"/>
<!-- Remove the auto deployed webapp so that it is redeployed every -->
<!-- time. -->
<delete dir="${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="${tomcat.home}/conf/web.xml"
tofile="${out.tomcat40.dir}/conf/web.xml"
filtering="on"/>
<copy
file="${conf.tomcat40.dir}/server.xml"
tofile="${out.tomcat40.dir}/conf/server.xml"
filtering="on"/>
<!-- Copy the war file -->
<copy
file="${out.test.dir}/test.war"
tofile="${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="${build.dest}"
file="${conf.test.dir}/cactus.properties"
filtering="on"/>
</target>
</project>
1.2 +5 -5 jakarta-turbine-maven/src/templates/project/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/templates/project/project.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- project.xml 25 Feb 2002 22:08:43 -0000 1.1
+++ project.xml 26 Mar 2002 04:48:53 -0000 1.2
@@ -100,12 +100,12 @@
#end
</unitTestClassEntries>
- <!-- Runtime unit test classes -->
- <runtimeTestClassEntries>
- #foreach ($runtimeTestClassEntry in $runtimeTestClassEntries)
- <runtimeTestClassEntry>$runtimeTestClassEntry</runtimeTestClassEntry>
+ <!-- Integration Unit test classes -->
+ <integrationUnitTestClassEntries>
+ #foreach ($integrationUnitTestClassEntry in $integrationUnitTestClassEntries)
+
<integrationUnitTestClassEntry>$integrationUnitTestClassEntry</integrationUnitTestClassEntry>
#end
- </runtimeTestClassEntries>
+ </integrationUnitTestClassEntries>
<!-- J A R R E S O U R C E S -->
<!-- Resources that are packaged up inside the JAR file -->
1.19 +61 -5 jakarta-turbine-maven/xdocs/build-file.xml
Index: build-file.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/xdocs/build-file.xml,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- build-file.xml 26 Mar 2002 01:04:29 -0000 1.18
+++ build-file.xml 26 Mar 2002 04:48:53 -0000 1.19
@@ -77,6 +77,10 @@
<ant antfile="${maven.home}/build-test.xml" target="test"/>
</target>
+<target name="maven:iutest">
+ <ant antfile="${maven.home}/build-iutest.xml" target="test"/>
+</target>
+
<target name="maven:singletest">
<ant antfile="${maven.home}/build-test.xml" target="run-singletest"/>
</target>
@@ -156,8 +160,15 @@
<tr>
<td><a href="#build-test.xml">build-test.xml</a></td>
<td>
- Contains targets to run all of the unit tests and run-time
- tests.
+ Contains targets to run all of the unit tests.
+ </td>
+ </tr>
+ <tr>
+ <td><a href="#build-iutest.xml">build-iutest.xml</a></td>
+ <td>
+ Contains targets to run all of the integration unit tests.
+ Currently using the <a
href="http://jakarta.apache.org/cactus">Cactus</a>
+ framework for in-container testing using tomcat.
</td>
</tr>
</table>
@@ -533,7 +544,7 @@
<tr><th>Target</th><th>Description</th></tr>
<tr>
<td><a href="#maven:test">maven:test</a></td>
- <td>Execute all the unit tests and run-time tests.</td>
+ <td>Execute all the unit tests.</td>
</tr>
<tr>
<td><a href="#maven:run-singletest">maven:run-singletest</a></td>
@@ -544,14 +555,14 @@
<subsection name="maven:test">
<p>
The <code>maven:test</code> target executes all of the unit tests
- (JUnit) and run-time tests of the project. First, the source
+ (JUnit) of the project. First, the source
for all of the tests is compiled. The location of the test
source code is determined from the
<a
href="project-descriptor.html#testSourceDirectories"><code>testSourceDirectories</code></a>
element of the Maven project descriptor. In addition, the
<a
href="project-descriptor.html#unitTestClassEntries"><code>unitTestClassEntries</code></a>
and
- <a
href="project-descriptor.html#runtimeTestClassEntries"><code>runtimeTestClassEntries</code></a>
+ <a
href="project-descriptor.html#integrationUnitTestClassEntries"><code>integrationUnitTestClassEntries</code></a>
specify the actual test classes to invoke.
</p>
<p>
@@ -580,6 +591,51 @@
directory of the project. If this directory does not exist,
it is created. In addition, an HTML report is generated when
the <code>docs</code> target is invoked.
+ </p>
+ </subsection>
+ </section>
+ <section name="build-iutest.xml">
+ <p>
+ The following is an overview of the most common targets in this
+ build file:
+ </p>
+ <table>
+ <tr><th>Target</th><th>Description</th></tr>
+ <tr>
+ <td><a href="#maven:iutest">maven:iutest</a></td>
+ <td>Execute all the integration unit tests.</td>
+ </tr>
+ </table>
+ <p/>
+ <subsection name="maven:iutest">
+ <p>
+ The <code>maven:iutest</code> target executes all of the integration unit
tests
+ of the project. These type of unit tests are based on the
+ <a href="http://jakarta.apache.org/cactus">Cactus</a> framework and
execute
+ test cases inside a running servlet container. This harness is setup to
use tomcat
+ for the container. The default properties are listed below.
+ </p>
+
+ <source><![CDATA[# Properties that are used for the integration unit tests
+# Defined here so they can easily be overridden by project
+# specific properties if necessary.
+iutest.dir = ${src.dir}/iutest
+webapp.dir = ${iutest.dir}/testapp
+conf.test.dir = ${iutest.dir}/cactus
+tomcat.home = ${tdk.home}
+test.port = 8192]]></source>
+
+ <p>
+ Each property may be overridden with project specific values using the
<code>project.properties</code>
+ file. More information about setting up in-container tests with cactus
may be found at the
+ <a href="http://jakarta.apache.org/cactus">Cactus</a> site.
+ </p>
+ <p>
+ The results of the tests are placed in the
+ <code>test-reports</code> directory relative to the base
+ directory of the project. If this directory does not exist,
+ it is created. These reports will be included when the HTML report is
+ generated with the <code>maven:docs</code> target.
</p>
</subsection>
</section>
1.9 +5 -5 jakarta-turbine-maven/xdocs/project-descriptor.xml
Index: project-descriptor.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/xdocs/project-descriptor.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- project-descriptor.xml 26 Mar 2002 01:04:29 -0000 1.8
+++ project-descriptor.xml 26 Mar 2002 04:48:53 -0000 1.9
@@ -273,8 +273,8 @@
</unitTestClassEntry>
</unitTestClassEntries>
- <runtimeTestClassEntries>
- </runtimeTestClassEntries>
+ <integrationUnitTestClassEntries>
+ </integrationUnitTestClassEntries>
<jarResources>
</jarResources>
@@ -569,15 +569,15 @@
</tr>
</table>
</subsection>
- <subsection name="runtimeTestClassEntries">
+ <subsection name="integrationUnitTestClassEntries">
<p>
This element specifies the classes which consist of the
- project's run-time tests.
+ project's integration unit tests.
</p>
<table>
<tr><th>Element</th><th>Description</th></tr>
<tr>
- <td>runtimeTestClassEntry</td>
+ <td>integrationUnitTestClassEntry</td>
<td>
The pattern specifying a set of classes. This value can
be either: <code>include = AntPattern</code>,
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>