|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- <?xml version="1.0"?>
-
- <project name="java-test" basedir="." default="foo">
- <fail unless="tests-classpath.value"
- message="the property tests-classpath.value is required by this test" />
- <!-- this property gets overridden programmatically-->
- <property name="timeToWait" value="4"/>
- <!-- this property gets overridden programmatically-->
- <property name="logFile" value="spawn.log"/>
- <property name="tmp" value="${java.io.tmpdir}"/>
- <property name="app"
- value="org.apache.tools.ant.taskdefs.JavaTest$$EntryPoint" />
-
- <property name="app2"
- value="org.apache.tools.ant.taskdefs.JavaTest$$ExceptingEntryPoint" />
-
- <property name="spawnapp"
- value="org.apache.tools.ant.taskdefs.JavaTest$$SpawnEntryPoint" />
-
- <property name="pipeapp"
- value="org.apache.tools.ant.taskdefs.JavaTest$$PipeEntryPoint" />
-
- <!--taskdef name="gc" classname="org.apache.tools.ant.taskdefs.optional.Gc" /-->
-
- <target name="testNoJarNoClassname">
- <java/>
- </target>
-
- <target name="testJarNoFork">
- <java jar="test.jar" fork="false"/>
- </target>
-
-
- <target name="testJarAndClassName">
- <java jar="test.jar" classname="${app}" />
- </target>
-
- <target name="testClassnameAndJar">
- <java classname="${app}" jar="test.jar" />
- </target>
-
- <target name="testRun">
- <fail unless="tests-classpath.value" />
- <java classname="${app}"
- classpath="${tests-classpath.value}"/>
- </target>
-
- <target name="testRunFail">
- <java classname="${app}"
- classpath="${tests-classpath.value}"
- >
- <arg value="2"/>
- </java>
- </target>
-
- <target name="testRunFailFoe">
- <java classname="${app}"
- classpath="${tests-classpath.value}"
- failonerror="true">
- <arg value="2"/>
- </java>
- </target>
-
- <target name="testRunFailFoeFork">
- <java classname="${app}"
- classpath="${tests-classpath.value}"
- failonerror="true"
- fork="true">
- <arg value="2"/>
- </java>
- </target>
-
- <target name="testExcepting">
- <java classname="${app2}"
- classpath="${tests-classpath.value}"
- >
- </java>
- </target>
-
- <target name="testExceptingFork">
- <java classname="${app2}"
- classpath="${tests-classpath.value}"
- fork="true">
- </java>
- </target>
-
- <target name="testExceptingFoe">
- <java classname="${app2}"
- classpath="${tests-classpath.value}"
- failonerror="true">
- </java>
- </target>
-
- <target name="testExceptingFoeFork">
- <java classname="${app2}"
- classpath="${tests-classpath.value}"
- failonerror="true"
- fork="true">
- </java>
- </target>
-
- <target name="testResultPropertyZero">
- <java classname="${app}"
- classpath="${tests-classpath.value}"
- resultproperty="exitcode"
- fork="true"
- >
- </java>
- <echo message="exitcode = ${exitcode}"/>
- </target>
-
- <target name="testResultPropertyNonZero">
- <java classname="${app}"
- classpath="${tests-classpath.value}"
- resultproperty="exitcode"
- failonerror="false"
- fork="true"
- >
- <arg value="2"/>
- </java>
- <echo message="exitcode = ${exitcode}"/>
- </target>
-
- <target name="testResultPropertyZeroNoFork">
- <java classname="${app}"
- classpath="${tests-classpath.value}"
- resultproperty="exitcode"
- fork="false"
- >
- <permissions/>
- </java>
- <echo message="exitcode = ${exitcode}"/>
- </target>
-
- <target name="testResultPropertyNonZeroNoFork">
- <java classname="${app}"
- classpath="${tests-classpath.value}"
- resultproperty="exitcode"
- failonerror="false"
- fork="false">
- <arg value="-1"/>
- <permissions/>
- </java>
- <echo message="exitcode = ${exitcode}"/>
- </target>
-
- <target name="testRunFailWithFailOnError">
- <java classname="${app}"
- classpath="${tests-classpath.value}"
- failonerror="true"
- >
- <arg value="2"/>
- </java>
- </target>
-
- <target name="testRunSuccessWithFailOnError">
- <java classname="${app}"
- classpath="${tests-classpath.value}"
- failonerror="true"
- >
- <arg value="0"/>
- </java>
- </target>
-
- <target name="testSpawn">
- <java classname="${spawnapp}" fork="true" spawn="true" classpath="${tests-classpath.value}">
- <arg value="${timeToWait}"/>
- <arg value="${logFile}" />
- </java>
- </target>
-
- <!--redirection testcases don't want to run under junit unless forked-->
- <target name="redirect1">
- <java classname="${pipeapp}"
- classpath="${tests-classpath.value}"
- inputstring="foo"
- fork="true"
- output="${tmp}/redirect.out"
- errorproperty="redirect.err">
- <arg value="out" />
- </java>
- <!-- let dumb Windows catch up -->
- <sleep seconds="2" />
- <loadfile property="redirect.out.contents" srcfile="${tmp}/redirect.out" />
- <condition property="r1pass">
- <and>
- <equals arg1="${redirect.out.contents}" arg2="foo" />
- <equals arg1="${redirect.err}" arg2="" />
- </and>
- </condition>
- <fail unless="r1pass" />
- </target>
-
- <target name="redirect2" depends="redirect1">
- <java classname="${pipeapp}"
- classpath="${tests-classpath.value}"
- inputstring="bar"
- append="true"
- fork="true"
- output="${tmp}/redirect.out"
- errorproperty="redirect.err">
- <arg value="both" />
- </java>
- <!-- let dumb Windows catch up -->
- <sleep seconds="2" />
- <loadfile property="redirect.out.contents2" srcfile="${tmp}/redirect.out" />
- <condition property="r2pass">
- <and>
- <equals arg1="${redirect.out.contents2}" arg2="foobar" />
- <!-- property should not be reset -->
- <equals arg1="${redirect.err}" arg2="" />
- </and>
- </condition>
- <fail unless="r2pass" />
- </target>
-
- <target name="redirect3">
- <java classname="${pipeapp}"
- classpath="${tests-classpath.value}"
- inputstring="foo"
- fork="true"
- output="${tmp}/redirect.out"
- error="${tmp}/redirect.err">
- <arg value="both" />
- </java>
- <!-- let dumb Windows catch up -->
- <sleep seconds="2" />
- <loadfile property="redirect.out.contents"
- srcfile="${tmp}/redirect.out" />
- <condition property="r3pass">
- <and>
- <equals arg1="${redirect.out.contents}" arg2="foo" />
- <filesmatch file1="${tmp}/redirect.out"
- file2="${tmp}/redirect.err" />
- </and>
- </condition>
- <fail unless="r3pass" />
- </target>
-
- <target name="redirector1">
- <java taskname="foo" classname="${pipeapp}" fork="true"
- classpath="${tests-classpath.value}">
- <redirector inputstring="foo"
- output="${tmp}/redirector.out"
- error="${tmp}/redirector.err"
- createemptyfiles="false" />
- <arg value="out" />
- </java>
- <!-- let dumb Windows catch up -->
- <sleep seconds="2" />
- <loadfile property="redirector.out.contents"
- srcfile="${tmp}/redirector.out" />
- <condition property="ror1pass">
- <and>
- <equals arg1="${redirector.out.contents}" arg2="foo" />
- <not>
- <available file="${tmp}/redirector.err" />
- </not>
- </and>
- </condition>
- <fail unless="ror1pass" />
- </target>
-
- <target name="redirector2" depends="redirector1">
- <!-- fork here, some VMs can be ill-behaved with files,
- such as W!nd0ws -->
- <java taskname="foo" classname="${pipeapp}" fork="true"
- classpath="${tests-classpath.value}">
- <redirector inputstring="foo"
- append="true"
- output="${tmp}/redirector.out"
- error="${tmp}/redirector.err"
- createemptyfiles="false">
- <errorfilterchain>
- <replacestring from="foo" to="bar" />
- </errorfilterchain>
- </redirector>
- <arg value="both" />
- </java>
- <!-- let dumb Windows catch up -->
- <sleep seconds="2" />
- <loadfile property="redirector.out.contents2"
- srcfile="${tmp}/redirector.out" />
- <loadfile property="redirector.err.contents"
- srcfile="${tmp}/redirector.err" />
- <condition property="ror2pass">
- <and>
- <equals arg1="${redirector.out.contents2}" arg2="foofoo" />
- <equals arg1="${redirector.err.contents}" arg2="bar" />
- </and>
- </condition>
- <fail unless="ror2pass" />
- </target>
-
- <target name="cleanup">
- <delete>
- <fileset file="${logFile}" />
- <fileset dir="${tmp}" includes="redirect*" />
- <fileset dir="${tmp}" includes="redirector*" />
- </delete>
- </target>
-
- <target name="foo" />
- </project>
|