diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit')
5 files changed, 751 insertions, 0 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/junit-formatter-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/junit-formatter-test.xml new file mode 100644 index 00000000..b9a63c94 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/junit-formatter-test.xml @@ -0,0 +1,93 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit"> + <import file="../../../antunit-base.xml" /> + + <path id="junit"> + <fileset dir="../../../../../../lib/optional" includes="junit*"/> + </path> + + <target name="setUp"> + <mkdir dir="${input}"/> + <mkdir dir="${output}"/> + <echo file="${input}/ATest.java"><![CDATA[ +package test; +import junit.framework.TestCase; + +public class ATest extends TestCase { + public void testEmpty() {} +} +]]></echo> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit"/> + </javac> + <macrodef name="j"> + <sequential> + <junit fork="true" forkMode="perBatch"> + <classpath refid="junit"/> + <classpath location="${output}"/> + <batchtest todir="${output}"> + <fileset dir="${output}"> + <include name="**/*Test.class" /> + </fileset> + </batchtest> + <formatter type="plain" if="${if}" extension=".dollar_if"/> + <formatter type="plain" if="if" extension=".if"/> + <formatter type="plain" unless="${if}" extension=".dollar_unless"/> + <formatter type="plain" unless="if" extension=".unless"/> + </junit> + </sequential> + </macrodef> + </target> + + <target name="testPropertyNotSet" depends="setUp"> + <j/> + <au:assertFileDoesntExist file="${output}/TEST-test.ATest.dollar_if"/> + <au:assertFileDoesntExist file="${output}/TEST-test.ATest.if"/> + <au:assertFileExists file="${output}/TEST-test.ATest.dollar_unless"/> + <au:assertFileExists file="${output}/TEST-test.ATest.unless"/> + </target> + + <target name="testPropertySet" depends="setUp"> + <property name="if" value="whatever"/> + <j/> + <au:assertFileDoesntExist file="${output}/TEST-test.ATest.dollar_if"/> + <au:assertFileExists file="${output}/TEST-test.ATest.if"/> + <au:assertFileExists file="${output}/TEST-test.ATest.dollar_unless"/> + <au:assertFileDoesntExist file="${output}/TEST-test.ATest.unless"/> + </target> + + <target name="testPropertyTrue" depends="setUp"> + <property name="if" value="true"/> + <j/> + <au:assertFileExists file="${output}/TEST-test.ATest.dollar_if"/> + <au:assertFileExists file="${output}/TEST-test.ATest.if"/> + <au:assertFileDoesntExist file="${output}/TEST-test.ATest.dollar_unless"/> + <au:assertFileDoesntExist file="${output}/TEST-test.ATest.unless"/> + </target> + + <target name="testPropertyFalse" depends="setUp"> + <property name="if" value="false"/> + <j/> + <au:assertFileDoesntExist file="${output}/TEST-test.ATest.dollar_if"/> + <au:assertFileExists file="${output}/TEST-test.ATest.if"/> + <au:assertFileExists file="${output}/TEST-test.ATest.dollar_unless"/> + <au:assertFileDoesntExist file="${output}/TEST-test.ATest.unless"/> + </target> + +</project> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/junit-outputtoformatters-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/junit-outputtoformatters-test.xml new file mode 100644 index 00000000..29068e48 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/junit-outputtoformatters-test.xml @@ -0,0 +1,137 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project default="all" xmlns:au="antlib:org.apache.ant.antunit"> + <import file="../../../antunit-base.xml" /> + <property name="ant-build" location="../../../../../../build"/> + <property name="build-junit-dir" location="${ant-build}/ant-unit/junit-dir"/> + <property name="reports.dir" location="${build-junit-dir}/report"/> + + <macrodef name="assert-file-not-contains" backtrace="no"> + <sequential> + <au:assertFalse> + <isfileselected file="${reports.dir}/TEST-ExampleTest.txt"> + <contains text="Hello From Test"/> + </isfileselected> + </au:assertFalse> + </sequential> + </macrodef> + + <macrodef name="assert-file-contains" backtrace="no"> + <sequential> + <au:assertTrue> + <isfileselected file="${reports.dir}/TEST-ExampleTest.txt"> + <contains text="Hello From Test"/> + </isfileselected> + </au:assertTrue> + </sequential> + </macrodef> + + <macrodef name="assert-log-not-contains" backtrace="no"> + <sequential> + <au:assertLogDoesntContain text="Hello From Test" /> + </sequential> + </macrodef> + + <macrodef name="assert-log-contains" backtrace="no"> + <sequential> + <au:assertLogContains text="Hello From Test"/> + </sequential> + </macrodef> + + <macrodef name="run-junit"> + <attribute name="fork"/> + <attribute name="showoutput"/> + <attribute name="outputtoformatters"/> + <sequential> + <junit fork="@{fork}" haltonfailure="no" showoutput="@{showoutput}" + outputtoformatters="@{outputtoformatters}"> + <test name="ExampleTest" todir="${reports.dir}"/> + <classpath path="${resources}"/> + <formatter type="plain" usefile="yes"/> + </junit> + </sequential> + </macrodef> + + <target name="init"> + <delete quiet="yes" dir="${build-junit-dir}"/> + <mkdir dir="${resources}"/> + <mkdir dir="${reports.dir}"/> + </target> + + <target name="compile" depends="init"> + <javac srcdir="src" destdir="${resources}" debug="yes"/> + </target> + + <target name="test-show-yes-formatters-yes" depends="compile"> + <run-junit fork="yes" showoutput="yes" + outputtoformatters="yes"/> + <assert-log-contains/> + <assert-file-contains/> + </target> + + <target name="test-show-yes-formatters-no" depends="compile"> + <run-junit fork="yes" showoutput="yes" + outputtoformatters="no"/> + <assert-log-contains/> + <assert-file-not-contains/> + </target> + + <target name="test-show-yes-formatters-no-forkno" depends="compile"> + <run-junit fork="no" showoutput="yes" + outputtoformatters="no"/> + <assert-log-contains/> + <assert-file-not-contains/> + </target> + + <target name="test-show-no-formatters-no" depends="compile"> + <run-junit fork="yes" showoutput="no" + outputtoformatters="no"/> + <assert-log-not-contains/> + <assert-file-not-contains/> + </target> + + <target name="test-show-no-formatters-no-fork-no" depends="compile"> + <run-junit fork="no" showoutput="no" + outputtoformatters="no"/> + <assert-log-not-contains/> + <assert-file-not-contains/> + </target> + + <target name="test-show-no-formatters-yes" depends="compile"> + <run-junit fork="yes" showoutput="no" + outputtoformatters="yes"/> + <assert-log-not-contains/> + <assert-file-contains/> + </target> + + <target name="test-show-no-formatters-yes-fork-no" depends="compile"> + <run-junit fork="no" showoutput="no" + outputtoformatters="yes"/> + <assert-log-not-contains/> + <assert-file-contains/> + </target> + + <target name="all"> + <au:antunit> + <fileset file="${ant.file}"/> + <au:plainlistener/> + </au:antunit> + </target> + +</project> + diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/junit-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/junit-test.xml new file mode 100644 index 00000000..e6aa794c --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/junit-test.xml @@ -0,0 +1,372 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit"> + <import file="../../../antunit-base.xml" /> + + <path id="junit"> + <fileset dir="../../../../../../lib/optional" includes="junit*" /> + <fileset dir="../../../../../../lib/optional" includes="hamcrest-core*" /> + </path> + + <macrodef name="empty-test"> + <attribute name="classname" /> + <attribute name="package" default="test" /> + <sequential> + <echo file="${input}/@{classname}.java"> + <![CDATA[ +package @{package}; +import junit.framework.TestCase; + +public class @{classname} extends TestCase { + public void testEmpty() {} +} +]]> + </echo> + </sequential> + </macrodef> + + <target name="setUp"> + <mkdir dir="${input}" /> + <mkdir dir="${output}" /> + </target> + + <target name="testTimeoutLogOfBatchTests"> + <mkdir dir="${input}" /> + <mkdir dir="${output}" /> + <empty-test classname="ATest" package="org.apache.ant.test" /> + <echo file="${input}/BTest.java"> + <![CDATA[ +package org.apache.ant.test; +import junit.framework.TestCase; + +public class BTest extends TestCase { + public void testEmpty() throws Exception { + Thread.sleep(20 * 1000); + } +} +]]> + </echo> + <empty-test classname="CTest" package="org.apache.ant.test" /> + <empty-test classname="DTest" package="org.apache.ant.test" /> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit" /> + </javac> + <junit fork="true" forkMode="perBatch" timeout="5000" printsummary="yes"> + <classpath refid="junit" /> + <classpath location="${output}" /> + <batchtest> + <fileset dir="${output}"> + <include name="**/*Test.class" /> + </fileset> + </batchtest> + </junit> + <au:assertLogContains text="ATest" /> + <au:assertLogContains text="BTest" /> + <au:assertLogContains text="org.apache.ant.test.Batch-With-Multiple-Tests" /> + <au:assertLogDoesntContain text="CTest" /> + <au:assertLogDoesntContain text="DTest" /> + </target> + + <target name="testFailurePropertyOnTestCase"> + <mkdir dir="${input}" /> + <mkdir dir="${output}" /> + <echo file="${input}/ATest.java"> + <![CDATA[ +package test; +import junit.framework.TestCase; + +public class ATest extends TestCase { + public void testFail() { + assertTrue(false); + } +} +]]> + </echo> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit" /> + </javac> + <junit failureProperty="testcase.failed" haltonfailure="false"> + <classpath refid="junit" /> + <classpath location="${output}" /> + <batchtest> + <fileset dir="${output}"> + <include name="**/*Test.class" /> + </fileset> + </batchtest> + </junit> + <au:assertPropertySet name="testcase.failed" /> + </target> + + <target name="testFailurePropertyOnTestSuite"> + <mkdir dir="${input}" /> + <mkdir dir="${output}" /> + <echo file="${input}/ATest.java"> + <![CDATA[ +package test; +import junit.framework.Assert; +import junit.framework.TestSuite; + +public class ATest extends TestSuite { + public ATest() { + super(test.ATest.class); + } + public void testFail() { + Assert.assertTrue(false); + } +} +]]> + </echo> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit" /> + </javac> + <junit failureProperty="testsuite.failed" haltonfailure="false"> + <classpath refid="junit" /> + <classpath location="${output}" /> + <batchtest> + <fileset dir="${output}"> + <include name="**/*Test.class" /> + </fileset> + </batchtest> + </junit> + <au:assertPropertySet name="testsuite.failed" /> + </target> + + <target name="testTimeoutAndFormattersForkPerTest"> + <antcall target="runTimeoutAndFormattersTest"> + <param name="forkMode" value="perTest" /> + </antcall> + <au:assertFileExists file="${output}/TEST-test.CTest.txt" /> + <au:assertFileExists file="${output}/TEST-test.CTest.xml" /> + <au:assertFileExists file="${output}/TEST-test.DTest.txt" /> + <au:assertFileExists file="${output}/TEST-test.DTest.xml" /> + </target> + + <target name="testTimeoutAndFormattersForkOnce"> + <antcall target="runTimeoutAndFormattersTest"> + <param name="forkMode" value="once" /> + </antcall> + <au:assertFileDoesntExist file="${output}/TEST-test.CTest.txt" /> + <au:assertFileDoesntExist file="${output}/TEST-test.CTest.xml" /> + <au:assertFileDoesntExist file="${output}/TEST-test.DTest.txt" /> + <au:assertFileDoesntExist file="${output}/TEST-test.DTest.xml" /> + </target> + + <target name="runTimeoutAndFormattersTest" description="https://issues.apache.org/bugzilla/show_bug.cgi?id=35634"> + <mkdir dir="${input}" /> + <mkdir dir="${output}" /> + <empty-test classname="ATest" /> + <echo file="${input}/BTest.java"> + <![CDATA[ +package test; +import junit.framework.TestCase; + +public class BTest extends TestCase { + public void testEmpty() throws Exception { + Thread.sleep(20 * 1000); + } +} +]]> + </echo> + <empty-test classname="CTest" /> + <empty-test classname="DTest" /> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit" /> + </javac> + <junit fork="true" timeout="5000" forkmode="${forkMode}"> + <classpath refid="junit" /> + <classpath location="${output}" /> + <batchtest todir="${output}"> + <fileset dir="${output}"> + <include name="**/*Test.class" /> + </fileset> + </batchtest> + <formatter type="brief" /> + <formatter type="xml" /> + </junit> + <au:assertFileExists file="${output}/TEST-test.ATest.txt" /> + <au:assertFileExists file="${output}/TEST-test.ATest.xml" /> + <!-- + <au:assertFileExists file="${output}/TEST-test.BTest.txt" /> + <au:assertFileExists file="${output}/TEST-test.BTest.xml" /> + + These files should only exist if something was written to the log by te runner. + The test previously passed even though the files were empty, which isn't a meaningful result. + TODO we should probably improve the testing around reporting of tests that have timed-out + --> + </target> + + <target name="-ifUnlessSetup" depends="setUp"> + <empty-test classname="ATest" /> + <empty-test classname="BTest" /> + <empty-test classname="CTest" /> + <empty-test classname="DTest" /> + <empty-test classname="ETest" /> + <empty-test classname="FTest" /> + <empty-test classname="GTest" /> + <empty-test classname="HTest" /> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit" /> + </javac> + <macrodef name="j"> + <sequential> + <junit fork="true" forkMode="perBatch" printsummary="yes"> + <classpath refid="junit" /> + <classpath location="${output}" /> + <test name="test.ATest" if="${if}" /> + <test name="test.BTest" if="if" /> + <test name="test.CTest" unless="${if}" /> + <test name="test.DTest" unless="if" /> + <batchtest if="${if}"> + <fileset dir="${output}"> + <include name="**/ETest.class" /> + </fileset> + </batchtest> + <batchtest if="if"> + <fileset dir="${output}"> + <include name="**/FTest.class" /> + </fileset> + </batchtest> + <batchtest unless="${if}"> + <fileset dir="${output}"> + <include name="**/GTest.class" /> + </fileset> + </batchtest> + <batchtest unless="if"> + <fileset dir="${output}"> + <include name="**/HTest.class" /> + </fileset> + </batchtest> + </junit> + </sequential> + </macrodef> + </target> + + <target name="testPropertiesNotSet" depends="-ifUnlessSetup"> + <j /> + <au:assertLogDoesntContain text="Running test.ATest" /> + <au:assertLogDoesntContain text="Running test.BTest" /> + <au:assertLogContains text="Running test.CTest" /> + <au:assertLogContains text="Running test.DTest" /> + <au:assertLogDoesntContain text="Running test.ETest" /> + <au:assertLogDoesntContain text="Running test.FTest" /> + <au:assertLogContains text="Running test.GTest" /> + <au:assertLogContains text="Running test.HTest" /> + </target> + + <target name="testPropertiesSet" depends="-ifUnlessSetup"> + <property name="if" value="whatever" /> + <j /> + <au:assertLogDoesntContain text="Running test.ATest" /> + <au:assertLogContains text="Running test.BTest" /> + <au:assertLogContains text="Running test.CTest" /> + <au:assertLogDoesntContain text="Running test.DTest" /> + <au:assertLogDoesntContain text="Running test.ETest" /> + <au:assertLogContains text="Running test.FTest" /> + <au:assertLogContains text="Running test.GTest" /> + <au:assertLogDoesntContain text="Running test.HTest" /> + </target> + + <target name="testPropertiesTrue" depends="-ifUnlessSetup"> + <property name="if" value="true" /> + <j /> + <au:assertLogContains text="Running test.ATest" /> + <au:assertLogContains text="Running test.BTest" /> + <au:assertLogDoesntContain text="Running test.CTest" /> + <au:assertLogDoesntContain text="Running test.DTest" /> + <au:assertLogContains text="Running test.ETest" /> + <au:assertLogContains text="Running test.FTest" /> + <au:assertLogDoesntContain text="Running test.GTest" /> + <au:assertLogDoesntContain text="Running test.HTest" /> + </target> + + <target name="testPropertiesFalse" depends="-ifUnlessSetup"> + <property name="if" value="false" /> + <j /> + <au:assertLogDoesntContain text="Running test.ATest" /> + <au:assertLogContains text="Running test.BTest" /> + <au:assertLogContains text="Running test.CTest" /> + <au:assertLogDoesntContain text="Running test.DTest" /> + <au:assertLogDoesntContain text="Running test.ETest" /> + <au:assertLogContains text="Running test.FTest" /> + <au:assertLogContains text="Running test.GTest" /> + <au:assertLogDoesntContain text="Running test.HTest" /> + </target> + + <target name="testMissingTestName"> + <property name="test.name" value="null" /> + <au:expectfailure message="test name must be specified"> + <junit fork="false"> + <test name="${test.name}" /> + </junit> + </au:expectfailure> + </target> + + <target name="testTestMethods"> + <condition property="source" value="6"> + <isset property="jdk1.6+"/> + </condition> + <property name="source" value="5"/> + <echo file="${input}/T1.java">public class T1 extends + junit.framework.TestCase { + public void testOK() {} + public void testBad() {throw new RuntimeException("failed");} + }</echo> + <echo file="${input}/T2.java"> + import org.junit.Test; + public class T2 { + @Test + public void ok() {} + @Test + public void bad() { + throw new RuntimeException("failed");} + }</echo> + <javac srcdir="${input}" destdir="${output}" includes="T1.java,T2.java" source="${source}" includeantruntime="false"> + <classpath> + <path refid="junit" /> + </classpath> + </javac> + <junit fork="true" printsummary="true" haltonerror="true"> + <classpath> + <pathelement location="${output}" /> + <path refid="junit" /> + </classpath> + <test name="T1" methods="testOK" /> + <test name="T2" methods="ok" /> + </junit> + </target> + + <target name="testClasspathBuildingSurvivesNonZips" depends="setUp" + description="https://issues.apache.org/bugzilla/show_bug.cgi?id=53964"> + <empty-test classname="ATest" package="org.apache.ant.test" /> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit" /> + </javac> + <junit fork="true" printsummary="true" haltonerror="true"> + <classpath> + <pathelement location="${output}" /> + <pathelement location="${ant.file}" /> + <path refid="junit" /> + </classpath> + <batchtest> + <fileset dir="${output}"> + <include name="**/*Test.class" /> + </fileset> + </batchtest> + </junit> + </target> +</project> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/src/ExampleTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/src/ExampleTest.java new file mode 100644 index 00000000..f1e5ca2b --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/src/ExampleTest.java @@ -0,0 +1,23 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import junit.framework.TestCase; + +public class ExampleTest extends TestCase { + public void testHello() { + System.out.println("Hello From Test"); + } +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/xmlformatter-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/xmlformatter-test.xml new file mode 100644 index 00000000..4aa6e4da --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/junit/xmlformatter-test.xml @@ -0,0 +1,126 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit"> + <import file="../../../antunit-base.xml"/> + + <path id="junit"> + <fileset dir="../../../../../../lib/optional" includes="junit*"/> + </path> + + <target name="test0Character"> + <mkdir dir="${input}/org/example"/> + <echo file="${input}/org/example/A.java"><![CDATA[ +package org.example; +import junit.framework.TestCase; +public class A extends TestCase { + public void testX() { + System.err.println("Here comes the zero: \u0000"); + } +} +]]></echo> + <mkdir dir="${output}"/> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit"/> + </javac> + <junit fork="true"> + <classpath refid="junit"/> + <classpath location="${output}"/> + <batchtest todir="${output}"> + <fileset dir="${output}"> + <include name="**/A.class" /> + </fileset> + </batchtest> + <formatter type="xml"/> + </junit> + <xmlvalidate file="${output}/TEST-org.example.A.xml" + lenient="true"/> + </target> + + <target name="testEntities" + description="https://issues.apache.org/bugzilla/show_bug.cgi?id=49404"> + <mkdir dir="${input}/org/example"/> + <echo file="${input}/org/example/A.java"><![CDATA[ +package org.example; +import junit.framework.TestCase; +public class A extends TestCase { + public void testX() { + assertTrue("&&", false); + } +} +]]></echo> + <mkdir dir="${output}"/> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit"/> + </javac> + <junit fork="true"> + <classpath refid="junit"/> + <classpath location="${output}"/> + <batchtest todir="${output}"> + <fileset dir="${output}"> + <include name="**/A.class" /> + </fileset> + </batchtest> + <formatter type="xml"/> + </junit> + <xmlvalidate file="${output}/TEST-org.example.A.xml" + lenient="true"/> + <au:assertResourceContains + resource="${output}/TEST-org.example.A.xml" + value="message="&amp;amp;&amp;"/> + <au:assertResourceContains + resource="${output}/TEST-org.example.A.xml" + value="AssertionFailedError: &amp;amp;&"/> + </target> + + <target name="testMessageWithTheWordMore"> + <mkdir dir="${input}/org/example"/> + <echo file="${input}/org/example/A.java"><![CDATA[ +package org.example; +import junit.framework.TestCase; +public class A extends TestCase { + public void testX() { + assertTrue("Expected more than one result", 0 > 1); + } + public void testY() { + assertTrue("Expected less than one result", 2 < 1); + } +} +]]></echo> + <mkdir dir="${output}"/> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit"/> + </javac> + <junit fork="true"> + <classpath refid="junit"/> + <classpath location="${output}"/> + <batchtest todir="${output}"> + <fileset dir="${output}"> + <include name="**/A.class" /> + </fileset> + </batchtest> + <formatter type="xml"/> + </junit> + <au:assertResourceContains + resource="${output}/TEST-org.example.A.xml" + value="junit.framework.AssertionFailedError: Expected less than one result"/> + <au:assertResourceContains + resource="${output}/TEST-org.example.A.xml" + value="junit.framework.AssertionFailedError: Expected more than one result"/> + </target> + +</project> |