diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional')
15 files changed, 1794 insertions, 0 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/depend/depend-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/depend/depend-test.xml new file mode 100644 index 00000000..48f94aa3 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/depend/depend-test.xml @@ -0,0 +1,131 @@ +<?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" /> + + <property name="src1" location="${input}/src1"/> + <property name="src2" location="${input}/src2"/> + + <target name="setUp"> + <mkdir dir="${src1}"/> + <mkdir dir="${output}"/> + <mkdir dir="${src1}/a"/> + <echo file="${src1}/a/B.java"><![CDATA[ +package a; +public class B { + public static String hello() { + return "Hello"; + } +} +]]></echo> + <mkdir dir="${src2}/b"/> + </target> + + <target name="testBug45916" depends="setUp"> + <echo file="${src2}/b/Main.java"><![CDATA[ +package b; + +import a.B; + +public class Main { + + public static void main(String[] args) { + new Runnable() { + public void run() { + System.err.println(B.hello()); + } + }.run(); + } + +} +]]></echo> + <javac srcdir="${src1}:${src2}" + destdir="${output}"/> + + <!--to ensure that the classfiles generated in the previous step + will be outdated--> + <sleep seconds="3" /> + <touch file="${src1}/a/B.java" /> + <javac srcdir="${src1}" destdir="${output}"/> + <jar destfile="${output}/A.jar" basedir="${output}" includes="a/**"/> + <delete dir="${output}/a"/> + + <depend srcDir="${src1}" + destDir="${output}" cache="${output}" + classpath="${output}/A.jar"/> + <au:assertFileExists file="${output}/b/Main$1.class"/> + </target> + + <target name="classpathTestSetUp" depends="setUp"> + <echo file="${src2}/b/Main.java"><![CDATA[ +package b; + +import a.B; + +public class Main { + + public static void main(String[] args) { + System.err.println(B.hello()); + } + +} +]]></echo> + + <property name="dest2" location="${output}/dest2"/> + + <mkdir dir="${resources}"/> + <mkdir dir="${dest2}"/> + + <javac srcdir="${src1}" destdir="${resources}"/> + <javac srcdir="${src2}" destdir="${dest2}" classpath="${resources}"/> + <sleep seconds="3" /> + <touch file="${src1}/a/B.java" /> + <javac srcdir="${src1}" destdir="${resources}"/> + <au:assertFileExists file="${dest2}/b/Main.class"/> + </target> + + <target name="testClasspathJar" depends="classpathTestSetUp"> + + <jar destfile="${test.jar}" basedir="${resources}"/> + <delete dir="${resources}"/> + <path id="resources-id"> + <pathelement location="${test.jar}"/> + </path> + + <depend srcDir="${src2}" + destDir="${dest2}" cache="${output}" + classpathref="resources-id" + /> + <au:assertFileDoesntExist file="${dest2}/b/Main.class"/> + + </target> + + <target name="testClasspathDir" depends="classpathTestSetUp"> + + <path id="resources-id"> + <pathelement location="${resources}"/> + </path> + + <depend srcDir="${src2}" + destDir="${dest2}" cache="${output}" + classpathref="resources-id" + /> + <au:assertFileDoesntExist file="${dest2}/b/Main.class"/> + + </target> +</project> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/funtest-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/funtest-test.xml new file mode 100644 index 00000000..6baa4f7e --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/funtest-test.xml @@ -0,0 +1,128 @@ +<?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"/> + + <!-- three presets for state--> + <presetdef name="p1"> + <property name="p1" value="true"/> + </presetdef> + <presetdef name="p2"> + <property name="p2" value="true"/> + </presetdef> + <presetdef name="p3"> + <property name="p3" value="true"/> + </presetdef> + <presetdef name="p4"> + <property name="p4" value="true"/> + </presetdef> + <presetdef name="p5"> + <property name="p5" value="true"/> + </presetdef> + + <presetdef name="assertP1"> + <au:assertPropertySet name="p1"/> + </presetdef> + <presetdef name="assertP2"> + <au:assertPropertySet name="p2"/> + </presetdef> + <presetdef name="assertP3"> + <au:assertPropertySet name="p3"/> + </presetdef> + <presetdef name="assertP4"> + <au:assertPropertySet name="p4"/> + </presetdef> + <presetdef name="assertP5"> + <au:assertPropertySet name="p5"/> + </presetdef> + + <target name="setUp"> + <taskdef name="funtest" + classname="org.apache.tools.ant.taskdefs.optional.testing.Funtest"/> + </target> + + <target name="testPresets" + description="test the presets behave"> + <p1/> + <assertP1/> + <p2/> + <assertP2/> + <p3/> + <assertP3/> + <p4/> + <assertP4/> + <p5/> + <assertP5/> + </target> + + <target name="testToSuccess"> + <funtest> + <setup> + <p1/> + </setup> + <application> + <assertP1/> + <p2/> + </application> + <block> + <isset property="p2"/> + </block> + <tests> + <assertP1/> + <assertP2/> + <p3/> + </tests> + <reporting> + <assertP3/> + <p4/> + </reporting> + <teardown> + <assertP4/> + <p5/> + </teardown> + </funtest> + <assertP5/> + </target> + + <target name="testCondition"> + <funtest > + <condition> + <isset property="unset"/> + </condition> + <setup> + <fail>should not be reached</fail> + </setup> + </funtest> + </target> + + <target name="testSetupFailureSkipsTeardown"> + <au:expectfailure message="setup failed"> + <funtest> + <setup> + <p1/> + <fail>setup failed</fail> + </setup> + <teardown> + <p5/> + </teardown> + </funtest> + </au:expectfailure> + <assertP1/> + </target> + +</project> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/javah-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/javah-test.xml new file mode 100644 index 00000000..e85293e2 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/javah-test.xml @@ -0,0 +1,65 @@ +<?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" /> + + <target name="-create-javah-adapter"> + <mkdir dir="${input}/org/example" /> + <echo file="${input}/org/example/Adapter.java"> + <![CDATA[ +package org.example; +import org.apache.tools.ant.taskdefs.optional.javah.JavahAdapter; +import org.apache.tools.ant.taskdefs.optional.Javah; + +public class Adapter implements JavahAdapter { + public boolean compile(Javah javah) { + System.err.println("adapter called"); + return true; + } +}]]> + </echo> + <mkdir dir="${resources}" /> + <javac srcdir="${input}" destdir="${resources}" /> + </target> + + <target name="testAdapterNotFound" depends="-create-javah-adapter"> + <au:expectfailure> + <javah class="org.example.Adapter" destdir="${output}" implementation="org.example.Adapter" /> + </au:expectfailure> + <au:assertLogDoesntContain text="adapter called" /> + </target> + + <target name="testImplementationClasspath" depends="-create-javah-adapter" description="https://issues.apache.org/bugzilla/show_bug.cgi?id=11143"> + <mkdir dir="${output}" /> + <javah class="org.example.Adapter" destdir="${output}" implementation="org.example.Adapter"> + <implementationclasspath location="${resources}" /> + </javah> + <au:assertLogContains text="adapter called" /> + </target> + + <target name="testImplementationAsNestedElement" depends="-create-javah-adapter"> + <componentdef classname="org.example.Adapter" name="myjavac"> + <classpath location="${resources}" /> + </componentdef> + <mkdir dir="${output}" /> + <javah class="org.example.Adapter" destdir="${output}"> + <myjavac /> + </javah> + <au:assertLogContains text="adapter called" /> + </target> +</project> 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> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/native2ascii-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/native2ascii-test.xml new file mode 100644 index 00000000..7a30df79 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/native2ascii-test.xml @@ -0,0 +1,68 @@ +<?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" /> + + <target name="-create-native2ascii-adapter"> + <mkdir dir="${input}/org/example"/> + <echo file="${input}/org/example/Adapter.java"><![CDATA[ +package org.example; +import java.io.File; +import org.apache.tools.ant.taskdefs.optional.native2ascii.Native2AsciiAdapter; +import org.apache.tools.ant.taskdefs.optional.Native2Ascii; + +public class Adapter implements Native2AsciiAdapter { + public boolean convert(Native2Ascii native2ascii, File f1, File f2) { + System.err.println("adapter called"); + return true; + } +}]]></echo> + <mkdir dir="${resources}"/> + <javac srcdir="${input}" destdir="${resources}"/> + </target> + + <target name="testAdapterNotFound" depends="-create-native2ascii-adapter" unless="build.sysclasspath.only"> + <!-- under gump the failure will not happen because the ${resources} directory is systematically on the classpath + what would be cool would be a task which removes a path element from the classpath. Do we have that ? --> + <au:expectfailure> + <native2ascii src="${input}" dest="${output}" includes="**/*.java" + implementation="org.example.Adapter"/> + </au:expectfailure> + <au:assertLogDoesntContain text="adapter called"/> + </target> + + <target name="testImplementationClasspath" depends="-create-native2ascii-adapter" + description="https://issues.apache.org/bugzilla/show_bug.cgi?id=11143"> + <native2ascii src="${input}" dest="${output}" includes="**/*.java" + implementation="org.example.Adapter"> + <implementationclasspath location="${resources}"/> + </native2ascii> + <au:assertLogContains text="adapter called"/> + </target> + + <target name="testImplementationAsNestedElement" + depends="-create-native2ascii-adapter"> + <componentdef classname="org.example.Adapter" name="myjavac"> + <classpath location="${resources}"/> + </componentdef> + <native2ascii src="${input}" dest="${output}" includes="**/*.java"> + <myjavac/> + </native2ascii> + <au:assertLogContains text="adapter called"/> + </target> +</project> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/propertyfile-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/propertyfile-test.xml new file mode 100644 index 00000000..0ea70513 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/propertyfile-test.xml @@ -0,0 +1,44 @@ +<?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" /> + + <target name="setUp"> + <mkdir dir="${output}"/> + </target> + + <target name="testReadWithPrefix" depends="setUp" + description="https://issues.apache.org/bugzilla/show_bug.cgi?id=48768"> + <property name="test.txt" location="${output}/test.txt"/> + <echo file="${test.txt}"><![CDATA[ +bbb=val2 +aaa=val1 +]]></echo> + + <property file="${test.txt}"/> + <au:assertPropertyEquals name="aaa" value="val1"/> + <au:assertPropertyEquals name="bbb" value="val2"/> + <propertyfile file="${test.txt}"> + <entry key="bbb" value="dummy"/> + </propertyfile> + + <property file="${test.txt}" prefix="xxx"/> + <au:assertPropertyEquals name="xxx.aaa" value="val1"/> + <au:assertPropertyEquals name="xxx.bbb" value="dummy"/> + </target> +</project> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/propertyfilelayout-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/propertyfilelayout-test.xml new file mode 100644 index 00000000..f1b367f9 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/propertyfilelayout-test.xml @@ -0,0 +1,289 @@ +<?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" /> + + <target name="setUp"> + <mkdir dir="${input}"/> + <mkdir dir="${output}"/> + <echo file="${input}/initial.properties"><![CDATA[#my comment +foo=bar +#second comment +x=1 +]]></echo> + <fixcrlf file="${input}/initial.properties"/> + <presetdef name="pf"> + <propertyfile file="${output}/created.properties"> + <entry key="foo" value="bar"/> + <entry key="x" value="1" type="int"/> + </propertyfile> + </presetdef> + </target> + + <target name="testCreateWithoutComment" depends="setUp"> + <pf/> + <local name="head.in"/> + <local name="head.out"/> + <local name="tail.in"/> + <local name="tail.out"/> + <!-- skip comment --> + <loadfile srcfile="${input}/initial.properties" property="head.in"> + <filterchain> + <headfilter lines="1" skip="1"/> + </filterchain> + </loadfile> + <loadfile srcfile="${input}/initial.properties" property="tail.in"> + <filterchain> + <tailfilter lines="1"/> + </filterchain> + </loadfile> + <!-- skip date and blank line --> + <loadfile srcfile="${output}/created.properties" property="head.out"> + <filterchain> + <headfilter lines="1" skip="2"/> + </filterchain> + </loadfile> + <loadfile srcfile="${output}/created.properties" property="tail.out"> + <filterchain> + <tailfilter lines="1"/> + </filterchain> + </loadfile> + <au:assertPropertyEquals name="head.out" value="${head.in}"/> + <au:assertPropertyEquals name="tail.out" value="${tail.in}"/> + </target> + + <target name="testCreateWithComment" depends="setUp"> + <pf comment="my comment"/> + <local name="head.in"/> + <local name="head.out"/> + <local name="middle.in"/> + <local name="middle.out"/> + <local name="tail.in"/> + <local name="tail.out"/> + <!-- just comment --> + <loadfile srcfile="${input}/initial.properties" property="head.in"> + <filterchain> + <headfilter lines="1"/> + </filterchain> + </loadfile> + <!-- skip comment --> + <loadfile srcfile="${input}/initial.properties" property="middle.in"> + <filterchain> + <headfilter lines="1" skip="1"/> + </filterchain> + </loadfile> + <loadfile srcfile="${input}/initial.properties" property="tail.in"> + <filterchain> + <tailfilter lines="1"/> + </filterchain> + </loadfile> + <!-- just comment --> + <loadfile srcfile="${output}/created.properties" property="head.out"> + <filterchain> + <headfilter lines="1"/> + </filterchain> + </loadfile> + <!-- skip comment, date and blank line --> + <loadfile srcfile="${output}/created.properties" property="middle.out"> + <filterchain> + <headfilter lines="1" skip="3"/> + </filterchain> + </loadfile> + <loadfile srcfile="${output}/created.properties" property="tail.out"> + <filterchain> + <tailfilter lines="1"/> + </filterchain> + </loadfile> + <au:assertPropertyEquals name="head.out" value="${head.in}"/> + <au:assertPropertyEquals name="middle.out" value="${middle.in}"/> + <au:assertPropertyEquals name="tail.out" value="${tail.in}"/> + </target> + + <target name="-updateSetUp" depends="setUp"> + <copy file="${input}/initial.properties" + tofile="${output}/created.properties"/> + </target> + + <target name="testUpdateWithoutComment" depends="-updateSetUp"> + <pf/> + <local name="head.in"/> + <local name="head.out"/> + <loadfile srcfile="${input}/initial.properties" property="head.in"/> + <!-- skip date --> + <loadfile srcfile="${output}/created.properties" property="head.out"> + <filterchain> + <headfilter skip="1"/> + </filterchain> + </loadfile> + <au:assertPropertyEquals name="head.out" value="${head.in}"/> + </target> + + <target name="testUpdateWithNewComment" depends="-updateSetUp"> + <pf comment="new comment"/> + <local name="head.in"/> + <local name="head.out"/> + <local name="tail.in"/> + <local name="tail.out"/> + <property name="head.in" value="#new comment${line.separator}"/> + <!-- just comment --> + <loadfile srcfile="${output}/created.properties" property="head.out"> + <filterchain> + <headfilter lines="1"/> + </filterchain> + </loadfile> + <loadfile srcfile="${input}/initial.properties" property="tail.in"/> + <!-- skip new comment and date --> + <loadfile srcfile="${output}/created.properties" property="tail.out"> + <filterchain> + <headfilter skip="2"/> + </filterchain> + </loadfile> + <au:assertPropertyEquals name="head.out" value="${head.in}"/> + <au:assertPropertyEquals name="tail.out" value="${tail.in}"/> + </target> + + <target name="testUpdateWithSameComment" depends="-updateSetUp"> + <pf comment="my comment"/> + <local name="head.in"/> + <local name="head.out"/> + <local name="tail.in"/> + <local name="tail.out"/> + <!-- just comment --> + <loadfile srcfile="${input}/initial.properties" property="head.in"> + <filterchain> + <headfilter lines="1"/> + </filterchain> + </loadfile> + <!-- just comment --> + <loadfile srcfile="${output}/created.properties" property="head.out"> + <filterchain> + <headfilter lines="1"/> + </filterchain> + </loadfile> + <!-- skip comment --> + <loadfile srcfile="${input}/initial.properties" property="tail.in"> + <filterchain> + <headfilter skip="1"/> + </filterchain> + </loadfile> + <!-- skip comment and date --> + <loadfile srcfile="${output}/created.properties" property="tail.out"> + <filterchain> + <headfilter skip="2"/> + </filterchain> + </loadfile> + <au:assertPropertyEquals name="head.out" value="${head.in}"/> + <au:assertPropertyEquals name="tail.out" value="${tail.in}"/> + </target> + + <target name="testRepeatedUpdateWithoutComment" depends="-updateSetUp"> + <pf/> + <pf/> + <local name="head.in"/> + <local name="head.out"/> + <loadfile srcfile="${input}/initial.properties" property="head.in"/> + <!-- skip date --> + <loadfile srcfile="${output}/created.properties" property="head.out"> + <filterchain> + <headfilter skip="1"/> + </filterchain> + </loadfile> + <au:assertPropertyEquals name="head.out" value="${head.in}"/> + </target> + + <target name="testRepeatedUpdateWithSameComment" depends="-updateSetUp"> + <pf comment="my comment"/> + <pf comment="my comment"/> + <local name="head.in"/> + <local name="head.out"/> + <local name="tail.in"/> + <local name="tail.out"/> + <!-- just comment --> + <loadfile srcfile="${input}/initial.properties" property="head.in"> + <filterchain> + <headfilter lines="1"/> + </filterchain> + </loadfile> + <!-- just comment --> + <loadfile srcfile="${output}/created.properties" property="head.out"> + <filterchain> + <headfilter lines="1"/> + </filterchain> + </loadfile> + <!-- skip comment --> + <loadfile srcfile="${input}/initial.properties" property="tail.in"> + <filterchain> + <headfilter skip="1"/> + </filterchain> + </loadfile> + <!-- skip comment and date --> + <loadfile srcfile="${output}/created.properties" property="tail.out"> + <filterchain> + <headfilter skip="2"/> + </filterchain> + </loadfile> + <au:assertPropertyEquals name="head.out" value="${head.in}"/> + <au:assertPropertyEquals name="tail.out" value="${tail.in}"/> + </target> + + + <target name="testPreservesDosLineEnds" depends="setUp" + description="https://issues.apache.org/bugzilla/show_bug.cgi?id=50049"> + <property name="test.txt" location="${output}/test.txt"/> + <echo file="${test.txt}"><![CDATA[ +bbb=val2 +aaa=val1 +]]></echo> + <fixcrlf eol="dos" file="${test.txt}"/> + <propertyfile file="${test.txt}" comment="${header}"/> + <copy file="${test.txt}" tofile="${test.txt}.expected"/> + <fixcrlf eol="dos" file="${test.txt}.expected"/> + <au:assertFilesMatch expected="${test.txt}.expected" + actual="${test.txt}"/> + </target> + + <target name="testPreservesUnixLineEnds" depends="setUp" + description="https://issues.apache.org/bugzilla/show_bug.cgi?id=50049"> + <property name="test.txt" location="${output}/test.txt"/> + <echo file="${test.txt}"><![CDATA[ +bbb=val2 +aaa=val1 +]]></echo> + <fixcrlf eol="unix" file="${test.txt}"/> + <propertyfile file="${test.txt}" comment="${header}"/> + <copy file="${test.txt}" tofile="${test.txt}.expected"/> + <fixcrlf eol="unix" file="${test.txt}.expected"/> + <au:assertFilesMatch expected="${test.txt}.expected" + actual="${test.txt}"/> + </target> + + <target name="testPreservesMacLineEnds" depends="setUp" + description="https://issues.apache.org/bugzilla/show_bug.cgi?id=50049"> + <property name="test.txt" location="${output}/test.txt"/> + <echo file="${test.txt}"><![CDATA[ +bbb=val2 +aaa=val1 +]]></echo> + <fixcrlf eol="mac" file="${test.txt}"/> + <propertyfile file="${test.txt}" comment="${header}"/> + <copy file="${test.txt}" tofile="${test.txt}.expected"/> + <fixcrlf eol="mac" file="${test.txt}.expected"/> + <au:assertFilesMatch expected="${test.txt}.expected" + actual="${test.txt}"/> + </target> +</project> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/replaceregexp-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/replaceregexp-test.xml new file mode 100644 index 00000000..2d64ce7a --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/replaceregexp-test.xml @@ -0,0 +1,32 @@ +<?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" /> + + <target name="testRCSupport"> + <mkdir dir="${output}"/> + <echo file="${output}/text.txt"><![CDATA[ +Hello, world! +]]></echo> + <replaceregexp match="world" replace="Ant"> + <file file="${output}/text.txt"/> + </replaceregexp> + <au:assertResourceContains + resource="${output}/text.txt" value="Hello, Ant!"/> + </target> +</project> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/script/scriptdef-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/script/scriptdef-test.xml new file mode 100644 index 00000000..da78e427 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/script/scriptdef-test.xml @@ -0,0 +1,131 @@ +<?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" /> + + <description> + In which we test interesting aspects of scripting. + The targeted language is javascript; this lets us run without + additions on Java6+. + </description> + + <condition property="prereqs-ok"> + <or> + <and> + <available classname="org.apache.bsf.BSFManager" /> + <available classname="org.apache.bsf.engines.javascript.JavaScriptEngine" /> + </and> + <available classname="javax.script.ScriptEngineManager" /> + </or> + </condition> + + <!-- auto doesn't verify the language is supported and selects BSF + even if the JavaScriptEngine is not there --> + <condition property="script.manager" value="javax"> + <and> + <not> + <available classname="org.apache.bsf.engines.javascript.JavaScriptEngine" /> + </not> + <isset property="prereqs-ok"/> + </and> + </condition> + <property name="script.manager" value="auto" /> + + <string id="script.code"> + self.log("Ant version =${ant.version}"); + project.setNewProperty("property","live"); + </string> + + <presetdef name="js"> + <scriptdef language="javascript" name="scripttest" manager="${script.manager}"> + <!-- optional property attribute--> + <attribute name="property" /> + </scriptdef> + </presetdef> + + <property name="prop" value='self.log("Ant version =${ant.version}");project.setNewProperty("property","live");' /> + + <presetdef name="assertPropSet"> + <au:assertPropertyEquals name="property" value="live" /> + </presetdef> + + + <!--purely to test that everything works --> + <target name="testInline" if="prereqs-ok"> + <js>self.log("Hello");</js> + <scripttest /> + </target> + + <target name="testStringResource" if="prereqs-ok"> + <js> + <string value='self.log("Ant version =${ant.version}");' /> + </js> + <scripttest /> + </target> + + <target name="testStringResourceRef" if="prereqs-ok"> + <js> + <string refid="script.code" /> + </js> + <scripttest /> + <assertPropSet /> + </target> + + <target name="testStringResourceInline" if="prereqs-ok"> + <js> + <string> + self.log("Ant version =${ant.version}"); + project.setNewProperty("property","live"); + </string> + </js> + <scripttest /> + <assertPropSet /> + </target> + + <target name="testPropertyResource" if="prereqs-ok"> + <js> + <propertyresource name="prop" /> + </js> + <scripttest /> + <assertPropSet /> + </target> + + <target name="testMixedResources" if="prereqs-ok"> + <js> + <string refid="script.code" /> + <propertyresource name="prop" /> + <string> + project.setNewProperty("property2","live"); + </string> + </js> + <scripttest /> + <assertPropSet name="property2" /> + </target> + + <target name="testExceptionNesting" description="https://issues.apache.org/bugzilla/show_bug.cgi?id=47509" if="prereqs-ok"> + <scriptdef name="quickfail" language="javascript"> + <![CDATA[ + self.fail("I failed!"); + ]]> + </scriptdef> + <au:expectfailure message="I failed!"> + <quickfail /> + </au:expectfailure> + </target> +</project> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/unix/symlink-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/unix/symlink-test.xml new file mode 100644 index 00000000..90c57f43 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/unix/symlink-test.xml @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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 name="symlink-test" + default="antunit" xmlns:au="antlib:org.apache.ant.antunit"> + <import file="../../../antunit-base.xml"/> + + <target name="setUp"> + <condition property="isUnix"> + <os family="unix" /> + </condition> + </target> + + <target name="tearDown" depends="antunit-base.tearDown" + if="chmod.tmp"> + <chmod dir="${chmod.tmp}" perm="755"/> + <delete dir="${chmod.tmp}"/> + </target> + + <target name="os"> + + <mkdir dir="${output}" /> + <condition property="unix"> + <os family="unix" /> + </condition> + <property name="file_ref" + location="${output}/file"/> + <property name="hanging_ref" + location="${output}/hanging_ref"/> + </target> + + <target name="init" depends="os" if="unix"> + <touch file="${file_ref}" /> + </target> + + <target name="testCreateDouble" depends="init" if="unix"> + <symlink overwrite="true" link="${output}/link" + resource="${file_ref}"/> + <symlink overwrite="true" link="${output}/link" + resource="${file_ref}"/> + </target> + + + <target name="testCreateDoubleHanging" depends="init" if="unix"> + <symlink overwrite="true" link="${output}/link2" + resource="${hanging_ref}"/> + <symlink overwrite="true" link="${output}/link2" + resource="${hanging_ref}"/> + </target> + + <target name="testCreateOverFile" depends="init" if="unix"> + <touch file="${output}/link3" /> + <symlink overwrite="true" link="${output}/link3" + resource="${file_ref}"/> + </target> + + <target name="testDeleteOfBrokenLink" depends="init" if="unix"> + <symlink link="${output}/link" resource="${file_ref}"/> + <delete file="${file_ref}"/> + <symlink link="${output}/link" action="delete"/> + <au:assertFileDoesntExist file="${output}/link"/> + </target> + + <target name="testDeleteLinkToParent" depends="init" if="unix"> + <symlink link="${output}/link" resource="${output}"/> + <symlink link="${output}/link" action="delete"/> + <au:assertFileDoesntExist file="${output}/link"/> + </target> + + <target name="testDeleteWithNoPermissionToRenameTarget" + depends="init" if="unix"> + <!-- must be outside of ${output} or "base" tearDown will fail --> + <property name="chmod.tmp" location="${output}/../ant-symlink-test"/> + <mkdir dir="${chmod.tmp}/A"/> + <chmod perm="555" dir="${chmod.tmp}"/> + <symlink link="${output}/link" resource="${chmod.tmp}/A"/> + <symlink link="${output}/link" action="delete"/> + <au:assertFileDoesntExist file="${output}/link"/> + </target> + + <target name="testDeleteLinkInSameDirAsBuildFile" depends="setUp" if="isUnix" + description="https://issues.apache.org/bugzilla/show_bug.cgi?id=49137"> + <mkdir dir="${output}/Templates"/> + <mkdir dir="${output}/project1"/> + <symlink action="single" link="${output}/project1/Templates" + resource="../Templates"/> + <echo file="${output}/project1/build.xml"><![CDATA[ +<project name="project1" default="build" basedir="."> + <target name="build"> + <symlink action="delete" link="Templates"/> + </target> +</project>]]></echo> + <ant antfile="${output}/project1/build.xml"/> + </target> +</project> diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/windows/attrib-test.xml b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/windows/attrib-test.xml new file mode 100644 index 00000000..d5cea2b5 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/optional/windows/attrib-test.xml @@ -0,0 +1,46 @@ +<?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" /> + + <target name="setUp"> + <condition property="windows?"> + <os family="windows"/> + </condition> + <mkdir dir="${input}"/> + </target> + + <target name="testPerformance" depends="setUp" if="windows?" + description="https://issues.apache.org/bugzilla/show_bug.cgi?id=48734"> + <touch file="${input}/0.tld"/> + <touch file="${input}/1.tld"/> + <touch file="${input}/2.tld"/> + <touch file="${input}/3.tld"/> + <touch file="${input}/4.tld"/> + <touch file="${input}/5.tld"/> + <touch file="${input}/6.tld"/> + <touch file="${input}/7.tld"/> + <touch file="${input}/8.tld"/> + <touch file="${input}/9.tld"/> + <attrib readonly="false"> + <fileset dir="${input}"> + <include name="*.tld" /> + </fileset> + </attrib> + </target> +</project> |