Author: bdelacretaz
Date: Thu Apr 7 00:47:13 2005
New Revision: 160376
URL: http://svn.apache.org/viewcvs?view=rev&rev=160376
Log:
patch 34294 applied: new HtmlUnit based tests, thanks to Alfred Nathaniel
Modified:
cocoon/branches/BRANCH_2_1_X/build.properties
cocoon/branches/BRANCH_2_1_X/status.xml
cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl
cocoon/branches/BRANCH_2_1_X/tools/targets/compile-build.xml
cocoon/branches/BRANCH_2_1_X/tools/targets/init-build.xml
cocoon/branches/BRANCH_2_1_X/tools/targets/test-build.xml
Modified: cocoon/branches/BRANCH_2_1_X/build.properties
URL:
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/build.properties?view=diff&r1=160375&r2=160376
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/build.properties (original)
+++ cocoon/branches/BRANCH_2_1_X/build.properties Thu Apr 7 00:47:13 2005
@@ -68,6 +68,13 @@
# disable some long-running tests by default
# anteater.test.bug26186InternalRequestMemoryLeak.enabled = true
+# ---- htmlUnit
----------------------------------------------------------------
+
+htmlunit.home = /default-from-build.properties/htmlunit-1.5
+htmlunit.test.baseurl=http://localhost:8888/
+# for serious leak testing increase iteration count to 10000
+htmlunit.test.Bug26186InternalRequestMemoryLeak.iterations=1
+
# ---- JUnit
-------------------------------------------------------------------
junit.test.debugport=8000
@@ -88,6 +95,9 @@
build.test=${build}/test
build.test.output=${build.test}/output
build.test.report=${build.test}/report
+build.test.htmlunit=${build.test}/htmlunit
+build.test.htmlunit.output=${build.test.htmlunit}/output
+build.test.htmlunit.report=${build.test.htmlunit}/report
build.docs=${build}/docs
build.docs.printer=${build}/printer-docs
build.site=${build}/site
Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL:
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?view=diff&r1=160375&r2=160376
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Thu Apr 7 00:47:13 2005
@@ -196,6 +196,9 @@
<changes>
<release version="@version@" date="@date@">
+ <action dev="BD" type="add" fixes-bug="34294" due-to="Alfred Nathaniel"
due-to-email="[EMAIL PROTECTED]">
+ New set of automated tests based on HtmlUnit
+ </action>
<action dev="VG" type="update">
Add support for namespaced XML elements to the JXPath based input
modules (includes JXPathMetaModule, XMLFileModule, and others).
Modified: cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl
URL:
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl?view=diff&r1=160375&r2=160376
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl (original)
+++ cocoon/branches/BRANCH_2_1_X/tools/src/blocks-build.xsl Thu Apr 7 00:47:13
2005
@@ -49,6 +49,18 @@
</fileset>
</path>
+ <path id="htmlunit.classpath">
+ <fileset dir="${{htmlunit.home}}/lib">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${{tools.lib}}">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${{lib}}">
+ <include name="core/avalon-framework-*.jar"/>
+ </fileset>
+ </path>
+
<!-- Files, which should no compiled or otherwise processed -->
<patternset id="unprocessed.sources">
<exclude name="**/*.java"/>
@@ -355,7 +367,7 @@
<sequential>
<!-- Test if this block has tests -->
<if>
- <available file="@{{dir}}/test"/>
+ <available file="@{{dir}}/test/org/apache"/>
<then>
<mkdir dir="${{build.blocks}}/@{{name}}/test"/>
@@ -370,7 +382,7 @@
target="${{target.vm}}"
nowarn="${{compiler.nowarn}}"
compiler="${{compiler}}">
- <src path="@{{dir}}/test"/>
+ <src path="@{{dir}}/test/org/apache"/>
<classpath>
<path refid="@{{name}}.classpath"/>
<path refid="test.classpath"/>
@@ -396,6 +408,64 @@
<exclude name="**/AllTest.class"/>
<exclude name="**/*$$*Test.class"/>
<exclude name="**/Abstract*.class"/>
+ <exclude name="htmlunit/**"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </then>
+ </if>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="block-prepare-htmlunit-tests">
+ <attribute name="name"/>
+ <attribute name="dir"/>
+ <sequential>
+ <!-- Test if this block has tests -->
+ <if>
+ <and>
+ <available file="@{{dir}}/test/htmlunit"/>
+ <available file="${{htmlunit.home}}"/>
+ </and>
+ <then>
+ <mkdir dir="${{build.blocks}}/@{{name}}/test/htmlunit"/>
+
+ <copy todir="${{build.blocks}}/@{{name}}/test/htmlunit"
filtering="on">
+ <fileset dir="@{{dir}}/test/htmlunit" excludes="**/*.java"/>
+ </copy>
+
+ <javac destdir="${{build.blocks}}/@{{name}}/test/htmlunit"
+ debug="${{compiler.debug}}"
+ optimize="${{compiler.optimize}}"
+ deprecation="${{compiler.deprecation}}"
+ target="${{target.vm}}"
+ nowarn="${{compiler.nowarn}}"
+ compiler="${{compiler}}">
+ <src path="@{{dir}}/test/htmlunit"/>
+ <classpath>
+ <path refid="htmlunit.classpath"/>
+ <pathelement location="${{build.test.htmlunit}}"/>
+ </classpath>
+ </javac>
+
+ <junit printsummary="yes" fork="yes"
failureproperty="junit.test.failed">
+ <jvmarg value="-Djava.endorsed.dirs=lib/endorsed"/>
+ <jvmarg
value="-Djunit.test.loglevel=${{junit.test.loglevel}}"/>
+ <jvmarg
value="-Dhtmlunit.test.baseurl=${{htmlunit.test.baseurl}}"/>
+ <classpath>
+ <path refid="htmlunit.classpath"/>
+ <pathelement location="${{build.test.htmlunit}}"/>
+ <pathelement
location="${{build.blocks}}/@{{name}}/test/htmlunit"/>
+ </classpath>
+ <formatter type="plain" usefile="no"/>
+ <formatter type="xml"/>
+ <batchtest todir="${{build.test.htmlunit.output}}">
+ <fileset dir="${{build.blocks}}/@{{name}}/test/htmlunit">
+ <include name="**/*TestCase.class"/>
+ <include name="**/*Test.class"/>
+ <exclude name="**/AllTest.class"/>
+ <exclude name="**/*$$*Test.class"/>
+ <exclude name="**/Abstract*.class"/>
</fileset>
</batchtest>
</junit>
@@ -553,6 +623,16 @@
</xsl:attribute>
</target>
+ <target name="prepare-htmlunit-tests">
+ <xsl:attribute name="depends">
+ <xsl:text>init</xsl:text>
+ <xsl:for-each select="$cocoon-blocks">
+ <xsl:text>,</xsl:text>
+ <xsl:value-of select="concat(@name, '-prepare-htmlunit-tests')"/>
+ </xsl:for-each>
+ </xsl:attribute>
+ </target>
+
<target name="prepare-anteater-tests">
<xsl:attribute name="depends">
<xsl:text>init</xsl:text>
@@ -818,6 +898,10 @@
</xsl:if>
</xsl:attribute>
<block-tests name="{$block-name}" dir="[EMAIL PROTECTED]"/>
+ </target>
+
+ <target name="[EMAIL PROTECTED]"
unless="internal.exclude.block.{$block-name}">
+ <block-prepare-htmlunit-tests name="{$block-name}" dir="[EMAIL
PROTECTED]"/>
</target>
<target name="[EMAIL PROTECTED]"
unless="internal.exclude.block.{$block-name}">
Modified: cocoon/branches/BRANCH_2_1_X/tools/targets/compile-build.xml
URL:
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/tools/targets/compile-build.xml?view=diff&r1=160375&r2=160376
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/tools/targets/compile-build.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/tools/targets/compile-build.xml Thu Apr 7
00:47:13 2005
@@ -83,6 +83,9 @@
<!-- compiles tests classes -->
<target name="compile-tests"
+ depends="compile-junit-tests, compile-htmlunit-tests"/>
+
+ <target name="compile-tests-prepare"
depends="compile-core, compile-deprecated, clover.off">
<mkdir dir="${build.test}"/>
@@ -90,6 +93,11 @@
<copy todir="${build.test}" filtering="on">
<fileset dir="${test}" excludes="**/*.java"/>
</copy>
+ </target>
+
+ <target name="compile-junit-tests" depends="compile-tests-prepare">
+
+ <!-- Compile JUnit tests, using Cocoon libraries -->
<path id="test.classpath">
<path refid="classpath"/>
@@ -102,8 +110,7 @@
</fileset>
</path>
- <!-- Compile tests -->
- <javac srcdir="${test}"
+ <javac srcdir="${test}/org/apache"
destdir="${build.test}"
debug="${compiler.debug}"
optimize="${compiler.optimize}"
@@ -112,6 +119,35 @@
source="${source.vm}"
compiler="${compiler}"
classpathref="test.classpath"/>
+ </target>
+
+ <target name="compile-htmlunit-tests" if="htmlunit.present"
+ depends="compile-tests-prepare">
+
+ <!-- Compile JUnit tests using htmlUnit (requires running server) -->
+
+ <path id="htmlunit.classpath">
+ <pathelement location="${build.test.htmlunit}" />
+ <fileset dir="${htmlunit.home}/lib">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${tools.lib}">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${lib}">
+ <include name="core/avalon-framework-*.jar"/>
+ </fileset>
+ </path>
+
+ <javac srcdir="${test}/htmlunit/org/apache"
+ destdir="${build.test.htmlunit}"
+ debug="${compiler.debug}"
+ optimize="${compiler.optimize}"
+ deprecation="${compiler.deprecation}"
+ target="${target.vm}"
+ source="${source.vm}"
+ compiler="${compiler}"
+ classpathref="htmlunit.classpath"/>
</target>
<!-- === Package Targets ================================================= -->
Modified: cocoon/branches/BRANCH_2_1_X/tools/targets/init-build.xml
URL:
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/tools/targets/init-build.xml?view=diff&r1=160375&r2=160376
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/tools/targets/init-build.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/tools/targets/init-build.xml Thu Apr 7
00:47:13 2005
@@ -51,6 +51,9 @@
<!-- Get the build properties from an external file -->
<property file="build.properties"/>
+ <!-- Check whether HtmlUnit is installed and available -->
+ <available file="${htmlunit.home}" property="htmlunit.present"/>
+
<!-- Allow users a chance to override without editing the main file -->
<property file="${user.home}/cocoon.blocks.properties"/>
<property file="local.blocks.properties"/>
Modified: cocoon/branches/BRANCH_2_1_X/tools/targets/test-build.xml
URL:
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/tools/targets/test-build.xml?view=diff&r1=160375&r2=160376
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/tools/targets/test-build.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/tools/targets/test-build.xml Thu Apr 7
00:47:13 2005
@@ -21,24 +21,48 @@
<!--+
| Runs all tests
+-->
- <target name="test" depends="junit-tests, anteater-tests"
+ <target name="test" depends="junit-tests, htmlunit-tests, anteater-tests"
description="Runs all tests"/>
<!--+
| Runs JUnit tests
+-->
- <target name="junit-tests" depends="core-junit-tests, block-junit-tests,
junit-tests-report"
+ <target name="junit-tests"
+ depends="core-junit-tests, block-junit-tests, junit-tests-report"
description="Runs JUnit tests"/>
+ <target name="htmlunit-tests"
+ depends="core-htmlunit-tests, block-htmlunit-tests,
htmlunit-tests-report, check-htmlunit-present"
+ description="Runs HtmlUnit tests"/>
+
+ <target name="check-htmlunit-present" unless="htmlunit.present">
+ <echo>To use htmlunit, please install it (see
http://htmlunit.sourceforge.net/) and set htmlunit.home (currently
${htmlunit.home}) in your local.build.properties</echo>
+ <echo>----------------------</echo>
+ <echo>*** Htmlunit notes ***</echo>
+ <echo>a) To run these tests, an instance of Cocoon must be</echo>
+ <echo> running at ${htmlunit.test.baseurl}</echo>
+ <echo>b) JDK 1.4.x is required to run these tests, but running them</echo>
+ <echo> under 1.4.x to test Cocoon running under 1.3.x should be
ok.</echo>
+ <echo>c) htmlunit options can be set in local.build.properties, and
some</echo>
+ <echo> tests only run if enabled there.</echo>
+ </target>
+
<target name="junit-tests-prepare">
<delete dir="${build.test.output}"/>
<delete dir="${build.test.report}"/>
<mkdir dir="${build.test.output}"/>
</target>
+ <target name="htmlunit-tests-prepare" if="htmlunit.present">
+ <delete dir="${build.test.htmlunit.output}"/>
+ <delete dir="${build.test.htmlunit.report}"/>
+ <mkdir dir="${build.test.htmlunit.output}"/>
+ </target>
+
<!-- Runs JUnit tests -->
- <target name="core-junit-tests" depends="compile-tests, junit-tests-prepare">
+ <target name="core-junit-tests"
+ depends="compile-junit-tests, junit-tests-prepare">
<junit printsummary="yes" fork="yes" failureproperty="junit.test.failed">
<jvmarg value="-Djava.endorsed.dirs=lib/endorsed"/>
<jvmarg value="-Djunit.test.loglevel=${junit.test.loglevel}"/>
@@ -57,13 +81,46 @@
<exclude name="**/Abstract*.class" />
<exclude name="**/SitemapComponentTestCase*"/>
<exclude name="**/ContainerTestCase*"/>
+ <exclude name="htmlunit/**"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <!-- Runs HtmlUnit tests -->
+ <target name="core-htmlunit-tests" if="htmlunit.present"
+ depends="compile-htmlunit-tests, htmlunit-tests-prepare">
+
+ <!-- fail if the URL under test is not available -->
+ <echo>Tests tests require another instance of Cocoon to run at
${htmlunit.test.baseurl}</echo>
+ <get src="${htmlunit.test.baseurl}"
+ dest="${build.temp}/htmlunit-tests-checkaccess.html"
+ verbose="false"
+ usetimestamp="false"/>
+
+ <junit printsummary="yes" fork="yes"
failureproperty="htmlunit.test.failed">
+ <jvmarg value="-Djava.endorsed.dirs=lib/endorsed"/>
+ <jvmarg value="-Djunit.test.loglevel=${junit.test.loglevel}"/>
+ <jvmarg value="-Dhtmlunit.test.baseurl=${htmlunit.test.baseurl}"/>
+ <jvmarg value="-Dhtmlunit.test.source-dir=${webapp}"/>
+ <jvmarg value="-Dhtmlunit.test.deploy-dir=${build.webapp}"/>
+ <jvmarg
value="-Dhtmlunit.test.Bug26186InternalRequestMemoryLeak.iterations=${htmlunit.test.Bug26186InternalRequestMemoryLeak.iterations}"/>
+ <classpath>
+ <path refid="htmlunit.classpath"/>
+ </classpath>
+ <formatter type="plain" usefile="no"/>
+ <formatter type="xml"/>
+ <batchtest todir="${build.test.htmlunit.output}">
+ <fileset dir="${build.test.htmlunit}">
+ <include name="**/*TestCase.class"/>
+ <exclude name="**/HtmlUnitTestCase.class"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- Runs JUnit tests in debug mode -->
- <target name="junit-test-debug" depends="compile-tests, junit-tests-prepare">
+ <target name="junit-test-debug" depends="compile-junit-tests,
junit-tests-prepare">
<fail unless="junit.testcase"
message="Please set the property $${junit.testcase} to a JUnit
testcase (package.Classname, e.g. org.test.MyTestCase)."/>
@@ -80,13 +137,22 @@
</target>
<!-- Block tests -->
- <target name="block-junit-tests" depends="compile-tests, prepare-blocks">
+ <target name="block-junit-tests"
+ depends="compile-junit-tests, prepare-blocks">
<ant antfile="${build.temp}/blocks-build.xml"
inheritAll="true"
inheritRefs="false"
target="tests"/>
</target>
+ <target name="block-htmlunit-tests" if="htmlunit.present"
+ depends="compile-htmlunit-tests, prepare-blocks">
+ <ant antfile="${build.temp}/blocks-build.xml"
+ inheritAll="true"
+ inheritRefs="false"
+ target="prepare-htmlunit-tests"/>
+ </target>
+
<target name="junit-tests-report" depends="init">
<mkdir dir="${build.test.report}"/>
<junitreport todir="${build.test.output}">
@@ -100,6 +166,19 @@
message="One or more JUnit tests failed or caused errors. Please
have a look into the report for details."/>
</target>
+ <target name="htmlunit-tests-report" if="htmlunit.present" depends="init">
+ <mkdir dir="${build.test.htmlunit.report}"/>
+ <junitreport todir="${build.test.htmlunit.output}">
+ <fileset dir="${build.test.htmlunit.output}">
+ <include name="TEST-*.xml"/>
+ </fileset>
+ <report format="frames" todir="${build.test.htmlunit.report}"/>
+ </junitreport>
+ <echo message="Unit report is at
${build.test.htmlunit.report}/index.html"/>
+ <fail if="htmlunit.test.failed"
+ message="One or more HtmlUnit tests failed or caused errors. Please
have a look into the report for details."/>
+ </target>
+
<!--+
| Anteater tests
@@ -150,13 +229,13 @@
</target>
<!-- Anteater tests -->
- <target name="core-anteater-tests" depends="compile-tests,
anteater-tests-prepare"
+ <target name="core-anteater-tests" depends="anteater-tests-prepare"
description="Runs anteater tests">
<call-anteater script="run-tests.xml" target="all" targetfile=""/>
</target>
<!-- Run a SINGLE Anteater tests -->
- <target name="anteater-test" depends="compile-tests, anteater-tests-prepare,
block-anteater-tests"
+ <target name="anteater-test" depends="anteater-tests-prepare,
block-anteater-tests"
description="Runs a single Anteater test">
<echo>d) to run the tests in 'calc.xml' call 'build anteater-test
-Dtarget=calc'</echo>
<call-anteater script="run-tests.xml" target="single"
targetfile="${target}"/>