You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

java.xml 9.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <?xml version="1.0"?>
  2. <project name="java-test" basedir="." default="foo">
  3. <fail unless="tests-classpath.value"
  4. message="the property tests-classpath.value is required by this test" />
  5. <!-- this property gets overridden programmatically-->
  6. <property name="timeToWait" value="4"/>
  7. <!-- this property gets overridden programmatically-->
  8. <property name="logFile" value="spawn.log"/>
  9. <property name="tmp" value="${java.io.tmpdir}"/>
  10. <property name="app"
  11. value="org.apache.tools.ant.taskdefs.JavaTest$$EntryPoint" />
  12. <property name="app2"
  13. value="org.apache.tools.ant.taskdefs.JavaTest$$ExceptingEntryPoint" />
  14. <property name="spawnapp"
  15. value="org.apache.tools.ant.taskdefs.JavaTest$$SpawnEntryPoint" />
  16. <property name="pipeapp"
  17. value="org.apache.tools.ant.taskdefs.JavaTest$$PipeEntryPoint" />
  18. <!--taskdef name="gc" classname="org.apache.tools.ant.taskdefs.optional.Gc" /-->
  19. <target name="testNoJarNoClassname">
  20. <java/>
  21. </target>
  22. <target name="testJarNoFork">
  23. <java jar="test.jar" fork="false"/>
  24. </target>
  25. <target name="testJarAndClassName">
  26. <java jar="test.jar" classname="${app}" />
  27. </target>
  28. <target name="testClassnameAndJar">
  29. <java classname="${app}" jar="test.jar" />
  30. </target>
  31. <target name="testRun">
  32. <fail unless="tests-classpath.value" />
  33. <java classname="${app}"
  34. classpath="${tests-classpath.value}"/>
  35. </target>
  36. <target name="testRunFail">
  37. <java classname="${app}"
  38. classpath="${tests-classpath.value}"
  39. >
  40. <arg value="2"/>
  41. </java>
  42. </target>
  43. <target name="testRunFailFoe">
  44. <java classname="${app}"
  45. classpath="${tests-classpath.value}"
  46. failonerror="true">
  47. <arg value="2"/>
  48. </java>
  49. </target>
  50. <target name="testRunFailFoeFork">
  51. <java classname="${app}"
  52. classpath="${tests-classpath.value}"
  53. failonerror="true"
  54. fork="true">
  55. <arg value="2"/>
  56. </java>
  57. </target>
  58. <target name="testExcepting">
  59. <java classname="${app2}"
  60. classpath="${tests-classpath.value}"
  61. >
  62. </java>
  63. </target>
  64. <target name="testExceptingFork">
  65. <java classname="${app2}"
  66. classpath="${tests-classpath.value}"
  67. fork="true">
  68. </java>
  69. </target>
  70. <target name="testExceptingFoe">
  71. <java classname="${app2}"
  72. classpath="${tests-classpath.value}"
  73. failonerror="true">
  74. </java>
  75. </target>
  76. <target name="testExceptingFoeFork">
  77. <java classname="${app2}"
  78. classpath="${tests-classpath.value}"
  79. failonerror="true"
  80. fork="true">
  81. </java>
  82. </target>
  83. <target name="testResultPropertyZero">
  84. <java classname="${app}"
  85. classpath="${tests-classpath.value}"
  86. resultproperty="exitcode"
  87. fork="true"
  88. >
  89. </java>
  90. <echo message="exitcode = ${exitcode}"/>
  91. </target>
  92. <target name="testResultPropertyNonZero">
  93. <java classname="${app}"
  94. classpath="${tests-classpath.value}"
  95. resultproperty="exitcode"
  96. failonerror="false"
  97. fork="true"
  98. >
  99. <arg value="2"/>
  100. </java>
  101. <echo message="exitcode = ${exitcode}"/>
  102. </target>
  103. <target name="testResultPropertyZeroNoFork">
  104. <java classname="${app}"
  105. classpath="${tests-classpath.value}"
  106. resultproperty="exitcode"
  107. fork="false"
  108. >
  109. <permissions/>
  110. </java>
  111. <echo message="exitcode = ${exitcode}"/>
  112. </target>
  113. <target name="testResultPropertyNonZeroNoFork">
  114. <java classname="${app}"
  115. classpath="${tests-classpath.value}"
  116. resultproperty="exitcode"
  117. failonerror="false"
  118. fork="false">
  119. <arg value="-1"/>
  120. <permissions/>
  121. </java>
  122. <echo message="exitcode = ${exitcode}"/>
  123. </target>
  124. <target name="testRunFailWithFailOnError">
  125. <java classname="${app}"
  126. classpath="${tests-classpath.value}"
  127. failonerror="true"
  128. >
  129. <arg value="2"/>
  130. </java>
  131. </target>
  132. <target name="testRunSuccessWithFailOnError">
  133. <java classname="${app}"
  134. classpath="${tests-classpath.value}"
  135. failonerror="true"
  136. >
  137. <arg value="0"/>
  138. </java>
  139. </target>
  140. <target name="testSpawn">
  141. <java classname="${spawnapp}" fork="true" spawn="true" classpath="${tests-classpath.value}">
  142. <arg value="${timeToWait}"/>
  143. <arg value="${logFile}" />
  144. </java>
  145. </target>
  146. <!--redirection testcases don't want to run under junit unless forked-->
  147. <target name="redirect1">
  148. <java classname="${pipeapp}"
  149. classpath="${tests-classpath.value}"
  150. inputstring="foo"
  151. fork="true"
  152. output="${tmp}/redirect.out"
  153. errorproperty="redirect.err">
  154. <arg value="out" />
  155. </java>
  156. <!-- let dumb Windows catch up -->
  157. <sleep seconds="2" />
  158. <loadfile property="redirect.out.contents" srcfile="${tmp}/redirect.out" />
  159. <condition property="r1pass">
  160. <and>
  161. <equals arg1="${redirect.out.contents}" arg2="foo" />
  162. <equals arg1="${redirect.err}" arg2="" />
  163. </and>
  164. </condition>
  165. <fail unless="r1pass" />
  166. </target>
  167. <target name="redirect2" depends="redirect1">
  168. <java classname="${pipeapp}"
  169. classpath="${tests-classpath.value}"
  170. inputstring="bar"
  171. append="true"
  172. fork="true"
  173. output="${tmp}/redirect.out"
  174. errorproperty="redirect.err">
  175. <arg value="both" />
  176. </java>
  177. <!-- let dumb Windows catch up -->
  178. <sleep seconds="2" />
  179. <loadfile property="redirect.out.contents2" srcfile="${tmp}/redirect.out" />
  180. <condition property="r2pass">
  181. <and>
  182. <equals arg1="${redirect.out.contents2}" arg2="foobar" />
  183. <!-- property should not be reset -->
  184. <equals arg1="${redirect.err}" arg2="" />
  185. </and>
  186. </condition>
  187. <fail unless="r2pass" />
  188. </target>
  189. <target name="redirect3">
  190. <java classname="${pipeapp}"
  191. classpath="${tests-classpath.value}"
  192. inputstring="foo"
  193. fork="true"
  194. output="${tmp}/redirect.out"
  195. error="${tmp}/redirect.err">
  196. <arg value="both" />
  197. </java>
  198. <!-- let dumb Windows catch up -->
  199. <sleep seconds="2" />
  200. <loadfile property="redirect.out.contents"
  201. srcfile="${tmp}/redirect.out" />
  202. <condition property="r3pass">
  203. <and>
  204. <equals arg1="${redirect.out.contents}" arg2="foo" />
  205. <filesmatch file1="${tmp}/redirect.out"
  206. file2="${tmp}/redirect.err" />
  207. </and>
  208. </condition>
  209. <fail unless="r3pass" />
  210. </target>
  211. <target name="redirector1">
  212. <java taskname="foo" classname="${pipeapp}" fork="true"
  213. classpath="${tests-classpath.value}">
  214. <redirector inputstring="foo"
  215. output="${tmp}/redirector.out"
  216. error="${tmp}/redirector.err"
  217. createemptyfiles="false" />
  218. <arg value="out" />
  219. </java>
  220. <!-- let dumb Windows catch up -->
  221. <sleep seconds="2" />
  222. <loadfile property="redirector.out.contents"
  223. srcfile="${tmp}/redirector.out" />
  224. <condition property="ror1pass">
  225. <and>
  226. <equals arg1="${redirector.out.contents}" arg2="foo" />
  227. <not>
  228. <available file="${tmp}/redirector.err" />
  229. </not>
  230. </and>
  231. </condition>
  232. <fail unless="ror1pass" />
  233. </target>
  234. <target name="redirector2" depends="redirector1">
  235. <!-- fork here, some VMs can be ill-behaved with files,
  236. such as W!nd0ws -->
  237. <java taskname="foo" classname="${pipeapp}" fork="true"
  238. classpath="${tests-classpath.value}">
  239. <redirector inputstring="foo"
  240. append="true"
  241. output="${tmp}/redirector.out"
  242. error="${tmp}/redirector.err"
  243. createemptyfiles="false">
  244. <errorfilterchain>
  245. <replacestring from="foo" to="bar" />
  246. </errorfilterchain>
  247. </redirector>
  248. <arg value="both" />
  249. </java>
  250. <!-- let dumb Windows catch up -->
  251. <sleep seconds="2" />
  252. <loadfile property="redirector.out.contents2"
  253. srcfile="${tmp}/redirector.out" />
  254. <loadfile property="redirector.err.contents"
  255. srcfile="${tmp}/redirector.err" />
  256. <condition property="ror2pass">
  257. <and>
  258. <equals arg1="${redirector.out.contents2}" arg2="foofoo" />
  259. <equals arg1="${redirector.err.contents}" arg2="bar" />
  260. </and>
  261. </condition>
  262. <fail unless="ror2pass" />
  263. </target>
  264. <target name="cleanup">
  265. <delete>
  266. <fileset file="${logFile}" />
  267. <fileset dir="${tmp}" includes="redirect*" />
  268. <fileset dir="${tmp}" includes="redirector*" />
  269. </delete>
  270. </target>
  271. <target name="foo" />
  272. </project>