build.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <?xml version="1.0"?>
  2. <!--
  3. Build file for running container integration tests.
  4. $Id$
  5. -->
  6. <project name="acegi-security-integration-tests" default="usage" basedir=".">
  7. <property file="build.properties"/>
  8. <property file="project.properties"/>
  9. <path id="qa-portalpath">
  10. <fileset dir="${dist.lib.dir}">
  11. <include name="acegi-security-spring.jar"/>
  12. </fileset>
  13. <fileset dir="${lib.dir}">
  14. <include name="**/*.jar"/>
  15. </fileset>
  16. <fileset dir="${httpunit.lib.dir}">
  17. <include name="**/*.jar"/>
  18. </fileset>
  19. </path>
  20. <path id="jalopy-classpath">
  21. <fileset dir="${lib.dir}/jalopy">
  22. <include name="**/*.jar"/>
  23. </fileset>
  24. </path>
  25. <target name="usage">
  26. <echo level="info">
  27. ${name} build file
  28. ------------------------------------------------------
  29. Among the available targets are:
  30. clean --> deletes output directories
  31. unzip --> unzips each container into file system
  32. tests --> unzips each container and runs all tests
  33. tests-jetty --> runs the integration tests with Jetty
  34. tests-jboss --> runs the integration tests with JBoss
  35. tests-catalina --> runs the integration tests with Catalina
  36. (both 4.1 and 5.0)
  37. tests-catalina-4.1--> runs the integration tests with Catalina 4.1
  38. tests-catalina-5 --> runs the integration tests with Catalina 5.0
  39. Each tests-xxxx target assumes the container is unzipped
  40. BE SURE TO CHECK REPORTS DIRECTORY FOR RESULTS OF TESTS!
  41. *** The script does NOT halt if a test errors or fails ***
  42. </echo>
  43. </target>
  44. <target name="clean" description="Clean all output dirs">
  45. <delete dir="${build.dir}"/>
  46. <delete dir="${tmp.dir}"/>
  47. <delete dir="${reports.dir}"/>
  48. </target>
  49. <target name="buildtests" depends="" description="Compile test source tree Java files into class files">
  50. <mkdir dir="${build.dir}"/>
  51. <javac destdir="${build.dir}" target="1.3" debug="${debug}"
  52. deprecation="false" optimize="false" failonerror="true">
  53. <src path="${src.dir}"/>
  54. <classpath refid="qa-portalpath"/>
  55. </javac>
  56. </target>
  57. <target name="format" description="Formats all project source code">
  58. <taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
  59. <classpath refid="jalopy-classpath"/>
  60. </taskdef>
  61. <jalopy fileformat="unix"
  62. convention="${jalopy.xml}"
  63. history="file"
  64. historymethod="adler32"
  65. loglevel="error"
  66. threads="2"
  67. classpathref="qa-portalpath">
  68. <fileset dir="${src.dir}">
  69. <include name="**/*.java"/>
  70. </fileset>
  71. </jalopy>
  72. </target>
  73. <target name="tests" depends="clean,unzip,tests-jetty,tests-catalina,tests-jboss"
  74. description="Run all integration tests">
  75. <property name="jboss-${jboss.version}.errored" value="1"/>
  76. <property name="jakarta-tomcat-${tomcat-4.1.version}.failed" value="1"/>
  77. <condition property="anyerrors" value="true">
  78. <or>
  79. <isset property="jetty-${jetty.version}.errored"/>
  80. <isset property="jboss-${jboss.version}.errored"/>
  81. <isset property="jakarta-tomcat-${tomcat-4.1.version}.errored"/>
  82. <isset property="jakarta-tomcat-${tomcat-5.version}.errored"/>
  83. </or>
  84. </condition>
  85. <condition property="anyfailures" value="true">
  86. <or>
  87. <isset property="jetty-${jetty.version}.failed"/>
  88. <isset property="jboss-${jboss.version}.failed"/>
  89. <isset property="jakarta-tomcat-${tomcat-4.1.version}.failed"/>
  90. <isset property="jakarta-tomcat-${tomcat-5.version}.failed"/>
  91. </or>
  92. </condition>
  93. <fileset id="availablereports" dir="${reports.dir}"
  94. includes="**/html/index.html"/>
  95. <condition property="is.windows">
  96. <os family="windows"/>
  97. </condition>
  98. <antcall target="-prepare.availablereports.unix"/>
  99. <antcall target="-prepare.availablereports.windows"/>
  100. <condition property="jetty.errored" value="YES !">
  101. <isset property="jetty-${jetty.version}.errored"/>
  102. </condition>
  103. <condition property="jboss.errored" value="YES !">
  104. <isset property="jboss-${jboss.version}.errored"/>
  105. </condition>
  106. <condition property="jakarta-tomcat-4.1.errored" value="YES !">
  107. <isset property="jakarta-tomcat-${tomcat-4.1.version}.errored"/>
  108. </condition>
  109. <condition property="jakarta-tomcat-5.errored" value="YES !">
  110. <isset property="jakarta-tomcat-${tomcat-5.version}.errored"/>
  111. </condition>
  112. <condition property="jetty.failed" value="YES !">
  113. <isset property="jetty-${jetty.version}.failed"/>
  114. </condition>
  115. <condition property="jboss.failed" value="YES !">
  116. <isset property="jboss-${jboss.version}.failed"/>
  117. </condition>
  118. <condition property="jakarta-tomcat-4.1.failed" value="YES !">
  119. <isset property="jakarta-tomcat-${tomcat-4.1.version}.failed"/>
  120. </condition>
  121. <condition property="jakarta-tomcat-5.failed" value="YES !">
  122. <isset property="jakarta-tomcat-${tomcat-5.version}.failed"/>
  123. </condition>
  124. <property name="jetty.errored" value="no "/>
  125. <property name="jboss.errored" value="no "/>
  126. <property name="jakarta-tomcat-4.1.errored" value="no "/>
  127. <property name="jakarta-tomcat-5.errored" value="no "/>
  128. <property name="jetty.failed" value="no "/>
  129. <property name="jboss.failed" value="no "/>
  130. <property name="jakarta-tomcat-4.1.failed" value="no "/>
  131. <property name="jakarta-tomcat-5.failed" value="no "/>
  132. <property name="jetty.run" value="no"/>
  133. <property name="jboss.run" value="no"/>
  134. <property name="jakarta-tomcat-4.1.run" value="no"/>
  135. <property name="jakarta-tomcat-5.run" value="no"/>
  136. <echo level="info">
  137. Jetty ${jetty.version}:&#9;Run: ${jetty.run}&#9;&#9;Errored: ${jetty.errored}&#9;Failed: ${jetty.failed}
  138. JBoss ${jboss.version}:&#9;Run: ${jboss.run}&#9;&#9;Errored: ${jboss.errored}&#9;Failed: ${jboss.failed}
  139. Tomcat ${tomcat-4.1.version}:&#9;Run: ${jakarta-tomcat-4.1.run}&#9;&#9;Errored: ${jakarta-tomcat-4.1.errored}&#9;Failed: ${jakarta-tomcat-4.1.failed}
  140. Tomcat ${tomcat-5.version}:&#9;Run: ${jakarta-tomcat-5.run}&#9;&#9;Errored: ${jakarta-tomcat-5.errored}&#9;Failed: ${jakarta-tomcat-5.failed}
  141. </echo>
  142. <fail if="anyerrors">ERRORS OCCURED DURING TESTING</fail>
  143. <fail if="anyfailures">Failures occured during testing</fail>
  144. </target>
  145. <target name="-prepare.availablereports.windows" if="is.windows">
  146. <pathconvert dirsep="\" pathsep="&#13;&#10;"
  147. property="availablereports.paths"
  148. refid="availablereports"/>
  149. <echo>${availablereports.paths}</echo>
  150. </target>
  151. <target name="-prepare.availablereports.unix" unless="is.windows">
  152. <echo>not is.windows: ${is.windows}</echo>
  153. <pathconvert dirsep="/" pathsep="&#10;"
  154. property="availablereports.paths"
  155. refid="availablereports"/>
  156. <echo>${availablereports.paths}</echo>
  157. </target>
  158. <target name="tests-jetty" depends="buildtests" description="Runs Jetty integration tests">
  159. <copy file="${config.dir}/jetty-${jetty.version}/jetty.xml" todir="${tmp.dir}/jetty-${jetty.version}/etc" overwrite="true"/>
  160. <copy file="${acegisecurity.xml}" todir="${tmp.dir}/jetty-${jetty.version}/etc" overwrite="true"/>
  161. <copy file="${dist.lib.dir}/acegi-security-jetty-ext.jar" todir="${tmp.dir}/jetty-${jetty.version}/ext" overwrite="true"/>
  162. <copy file="${lib.dir}/aop-alliance/aopalliance.jar" todir="${tmp.dir}/jetty-${jetty.version}/ext" overwrite="true"/>
  163. <copy file="${lib.dir}/jakarta-commons/commons-logging.jar" todir="${tmp.dir}/jetty-${jetty.version}/ext" overwrite="true"/>
  164. <copy file="${lib.dir}/spring/spring.jar" todir="${tmp.dir}/jetty-${jetty.version}/ext" overwrite="true"/>
  165. <copy file="${contacts.war}" todir="${tmp.dir}/jetty-${jetty.version}/webapps" overwrite="true"/>
  166. <parallel>
  167. <java fork="true" dir="${tmp.dir}/jetty-${jetty.version}/" classpath="${tmp.dir}/jetty-${jetty.version}/start.jar" classname="org.mortbay.start.Main">
  168. </java>
  169. <sequential>
  170. <waitfor maxwait="240" maxwaitunit="second" checkevery="500" checkeveryunit="millisecond">
  171. <http url="http://localhost:8080/contacts" />
  172. </waitfor>
  173. <antcall target="-runtests">
  174. <param name="product" value="jetty-${jetty.version}"/>
  175. </antcall>
  176. <java fork="true" dir="${tmp.dir}/jetty-${jetty.version}/" classpath="${tmp.dir}/jetty-${jetty.version}/stop.jar" classname="org.mortbay.stop.Main"/>
  177. </sequential>
  178. </parallel>
  179. <antcall target="-report">
  180. <param name="product" value="jetty-${jetty.version}"/>
  181. </antcall>
  182. <property name="jetty.run" value="yes"/>
  183. </target>
  184. <target name="tests-catalina" description="Runs Catalina integration tests">
  185. <antcall target="-tests-catalina">
  186. <param name="tomcat.version" value="${tomcat-4.1.version}"/>
  187. </antcall>
  188. <antcall target="-tests-catalina">
  189. <param name="tomcat.version" value="${tomcat-5.version}"/>
  190. </antcall>
  191. </target>
  192. <target name="tests-catalina-4.1" description="Runs Catalina 4.1 integration tests">
  193. <antcall target="-tests-catalina">
  194. <param name="tomcat.version" value="${tomcat-4.1.version}"/>
  195. </antcall>
  196. </target>
  197. <target name="tests-catalina-5" description="Runs Catalina 5 integration tests">
  198. <antcall target="-tests-catalina">
  199. <param name="tomcat.version" value="${tomcat-5.version}"/>
  200. </antcall>
  201. </target>
  202. <target name="-tests-catalina" depends="buildtests" description="Runs Catalina integration tests">
  203. <delete dir="${tmp.dir}/jakarta-tomcat-${tomcat.version}/webapps/contacts"/>
  204. <copy file="${config.dir}/catalina-${tomcat.version}/server.xml" todir="${tmp.dir}/jakarta-tomcat-${tomcat.version}/conf" overwrite="true"/>
  205. <copy file="${acegisecurity.xml}" todir="${tmp.dir}/jakarta-tomcat-${tomcat.version}/conf" overwrite="true"/>
  206. <copy file="${dist.lib.dir}/acegi-security-catalina-server.jar" todir="${tmp.dir}/jakarta-tomcat-${tomcat.version}/server/lib" overwrite="true"/>
  207. <copy file="${dist.lib.dir}/acegi-security-catalina-common.jar" todir="${tmp.dir}/jakarta-tomcat-${tomcat.version}/common/lib" overwrite="true"/>
  208. <copy file="${lib.dir}/aop-alliance/aopalliance.jar" todir="${tmp.dir}/jakarta-tomcat-${tomcat.version}/common/lib" overwrite="true"/>
  209. <copy file="${lib.dir}/spring/spring.jar" todir="${tmp.dir}/jakarta-tomcat-${tomcat.version}/common/lib" overwrite="true"/>
  210. <copy file="${contacts.war}" todir="${tmp.dir}/jakarta-tomcat-${tomcat.version}/webapps" overwrite="true"/>
  211. <property name="tomcat.home" value="${tmp.dir}/jakarta-tomcat-${tomcat.version}"/>
  212. <parallel>
  213. <java fork="true" classname="org.apache.catalina.startup.Bootstrap" dir="${tomcat.home}">
  214. <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
  215. <arg value="start"/>
  216. <classpath>
  217. <pathelement path="${java.home}/../lib/tools.jar"/>
  218. <fileset dir="${tomcat.home}">
  219. <include name="bin/bootstrap.jar"/>
  220. </fileset>
  221. </classpath>
  222. </java>
  223. <sequential>
  224. <waitfor maxwait="240" maxwaitunit="second" checkevery="500" checkeveryunit="millisecond">
  225. <http url="http://localhost:8080/contacts" />
  226. </waitfor>
  227. <antcall target="-runtests">
  228. <param name="product" value="jakarta-tomcat-${tomcat.version}"/>
  229. </antcall>
  230. <java fork="true" classname="org.apache.catalina.startup.Bootstrap" dir="${tomcat.home}">
  231. <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
  232. <arg value="stop"/>
  233. <classpath>
  234. <pathelement path="${java.home}/../lib/tools.jar"/>
  235. <fileset dir="${tomcat.home}">
  236. <include name="bin/bootstrap.jar"/>
  237. </fileset>
  238. </classpath>
  239. </java>
  240. </sequential>
  241. </parallel>
  242. <antcall target="-report">
  243. <param name="product" value="jakarta-tomcat-${tomcat.version}"/>
  244. </antcall>
  245. <property name="jakarta-tomcat-${tomcat.version}.run" value="yes"/>
  246. </target>
  247. <target name="tests-jboss" depends="buildtests" description="Runs JBoss integration tests">
  248. <copy file="${config.dir}/jboss-${jboss.version}/login-config.xml" todir="${tmp.dir}/jboss-${jboss.version}/server/default/conf" overwrite="true"/>
  249. <copy file="${acegisecurity.xml}" todir="${tmp.dir}/jboss-${jboss.version}/server/default/conf" overwrite="true"/>
  250. <copy file="${dist.lib.dir}/acegi-security-jboss-lib.jar" todir="${tmp.dir}/jboss-${jboss.version}/server/default/lib" overwrite="true"/>
  251. <copy file="${lib.dir}/aop-alliance/aopalliance.jar" todir="${tmp.dir}/jboss-${jboss.version}/server/default/lib" overwrite="true"/>
  252. <copy file="${lib.dir}/spring/spring.jar" todir="${tmp.dir}/jboss-${jboss.version}/server/default/lib" overwrite="true"/>
  253. <copy file="${contacts.war}" todir="${tmp.dir}/jboss-${jboss.version}/server/default/deploy" overwrite="true"/>
  254. <parallel>
  255. <java fork="yes" classname="org.jboss.Main" dir="${tmp.dir}/jboss-${jboss.version}">
  256. <classpath>
  257. <pathelement path="${java.home}/../lib/tools.jar"/>
  258. <pathelement path="${tmp.dir}/jboss-${jboss.version}/bin/run.jar"/>
  259. </classpath>
  260. </java>
  261. <sequential>
  262. <waitfor maxwait="240" maxwaitunit="second" checkevery="500" checkeveryunit="millisecond">
  263. <http url="http://localhost:8080/contacts" />
  264. </waitfor>
  265. <antcall target="-runtests">
  266. <param name="product" value="jboss-${jboss.version}"/>
  267. </antcall>
  268. <java fork="yes" classname="org.jboss.Shutdown" dir="${tmp.dir}/jboss-${jboss.version}">
  269. <arg value="--shutdown"/>
  270. <classpath>
  271. <pathelement path="${tmp.dir}/jboss-${jboss.version}/bin/shutdown.jar"/>
  272. </classpath>
  273. </java>
  274. </sequential>
  275. </parallel>
  276. <antcall target="-report">
  277. <param name="product" value="jboss-${jboss.version}"/>
  278. </antcall>
  279. <property name="jboss.run" value="yes"/>
  280. </target>
  281. <target name="unzip" depends="unzip-jetty,unzip-catalina,unzip-jboss" description="Unzip all containers"/>
  282. <target name="unzip-jetty" depends="" description="Unzip Jetty container">
  283. <delete dir="${tmp.dir}/Jetty-${jetty.version}"/>
  284. <mkdir dir="${tmp.dir}/Jetty-${jetty.version}"/>
  285. <unzip src="${containers.dir}/Jetty-${jetty.version}-all.zip" dest="${tmp.dir}"/>
  286. </target>
  287. <target name="unzip-catalina" depends="" description="Unzip Catalina container">
  288. <antcall target="-unzip-catalina">
  289. <param name="tomcat.version" value="${tomcat-4.1.version}"/>
  290. </antcall>
  291. <antcall target="-unzip-catalina">
  292. <param name="tomcat.version" value="${tomcat-5.version}"/>
  293. </antcall>
  294. </target>
  295. <target name="unzip-catalina-4.1" depends="" description="Unzip Catalina 4.1 container">
  296. <antcall target="-unzip-catalina">
  297. <param name="tomcat.version" value="${tomcat-4.1.version}"/>
  298. </antcall>
  299. </target>
  300. <target name="unzip-catalina-5" depends="" description="Unzip Catalina 5 container">
  301. <antcall target="-unzip-catalina">
  302. <param name="tomcat.version" value="${tomcat-4.1.version}"/>
  303. </antcall>
  304. </target>
  305. <target name="-unzip-catalina" depends="" description="Unzip Catalina container">
  306. <delete dir="${tmp.dir}/jakarta-tomcat-${tomcat.version}"/>
  307. <mkdir dir="${tmp.dir}/jakarta-tomcat-${tomcat.version}"/>
  308. <unzip src="${containers.dir}/jakarta-tomcat-${tomcat.version}.zip" dest="${tmp.dir}"/>
  309. </target>
  310. <target name="unzip-jboss" depends="" description="Unzip JBoss container">
  311. <delete dir="${tmp.dir}/jboss-${jboss.version}"/>
  312. <mkdir dir="${tmp.dir}/jboss-${jboss.version}"/>
  313. <unzip src="${containers.dir}/jboss-${jboss.version}.zip" dest="${tmp.dir}"/>
  314. </target>
  315. <target name="-report" description="Generates a browsable HTML report of the test run">
  316. <mkdir dir="${reports.dir}/${product}/html"/>
  317. <junitreport todir="${reports.dir}/${product}">
  318. <fileset dir="${reports.dir}/${product}" includes="**/TEST-*.xml"/>
  319. <report format="frames" todir="${reports.dir}/${product}/html"/>
  320. </junitreport>
  321. </target>
  322. <target name="-runtests" description="Runs the unit tests">
  323. <delete dir="${reports.dir}/${product}"/>
  324. <mkdir dir="${reports.dir}/${product}"/>
  325. <junit printsummary="yes" haltonfailure="no" haltonerror="no"
  326. failureproperty="${product}.failed"
  327. errorproperty="${product}.errored">
  328. <classpath location="${build.dir}"/>
  329. <classpath refid="qa-portalpath"/>
  330. <formatter type="xml"/>
  331. <batchtest fork="yes" todir="${reports.dir}/${product}">
  332. <fileset dir="${build.dir}" includes="${test.includes}" excludes="${test.excludes}"/>
  333. </batchtest>
  334. </junit>
  335. </target>
  336. </project>