Subversion Repositories DevTools

Rev

Rev 1864 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1864 gzemunik 1
<project name="ant-junitee">
2
 
3
	<description>
4
	Example usage:
5
	<!--
6
		<run-junitee-tests jar="${basedir}/build/jar/myejb.jar" appxml="${basedir}/src/etc/application.xml">
7
			<junitee-war>
8
				<classes dir="${basedir}/build/classes/test">
9
					<include name="**/*Test.class"/>
10
				</classes>
11
				<testcases dir="${basedir}/build/classes/test">
12
					<include name="**/*Test.class"/>
13
				</testcases>
14
			</junitee-war>
15
		</run-junitee-tests>
16
	-->
17
 
18
	</description>
19
 
20
	<!-- Note: The following are from jakarta-cactus 13.1.7.cots. This section needs to 
21
				be kept up to date with the associated version of jakarta-cactus -->
22
	<taskdef resource="cactus.tasks">
23
		<classpath>
24
			<pathelement location="${using.jakarta-cactus.basedir}/jar/cactus-1.7.jar"/>
25
			<pathelement location="${using.jakarta-cactus.basedir}/jar/cactus-ant-1.7.jar"/>
26
			<pathelement location="${using.jakarta-cactus.basedir}/jar/commons-httpclient-2.0.2.jar"/>
27
			<pathelement location="${using.jakarta-cactus.basedir}/jar/commons-logging-1.0.4.jar"/>
28
			<pathelement location="${using.jakarta-cactus.basedir}/jar/aspectjrt-1.2.1.jar"/>
29
			<pathelement location="${using.junit.basedir}/jar/junit.jar"/>
30
			<pathelement location="${using.ant-junit.basedir}/jar/ant-junit.jar"/>
31
		</classpath>
32
	</taskdef>
33
 
34
	<taskdef name="junitee" classname="org.junitee.anttask.JUnitEETask">
35
		<classpath>
36
			<pathelement location="${using.junitee.basedir}/jar/junitee-anttask.jar"/>
37
		</classpath>
38
	</taskdef>
39
 
40
	<taskdef name="juniteewar" classname="org.junitee.anttask.JUnitEEWarTask">
41
			<classpath>
42
				<pathelement location="${using.junitee.basedir}/jar/junitee-anttask.jar"/>
43
			</classpath>
44
	</taskdef>
45
 
46
	<macrodef name="run-junitee-tests">
47
 
1866 egunawan 48
		<attribute name="jar"       	default="${ant.project.name}.jar"/>
49
		<attribute name="war"		default="unit-test.war"/>
50
		<attribute name="appxml"    	default="${basedir}/src/etc/application.xml"/>
1864 gzemunik 51
		<element   name="junitee-war"/>
1866 egunawan 52
		<element   name="dependencies" optional="true"/>
1864 gzemunik 53
 
54
		<sequential>
55
 
56
			<mkdir dir="${basedir}/build/jar"/>
57
 
1866 egunawan 58
			<juniteewar destFile="${basedir}/build/jar/@{war}">
1864 gzemunik 59
				<lib dir="${using.junitee.basedir}/jar"     includes="junitee.jar"/>
60
				<lib dir="${using.junit.basedir}/jar"       includes="junit.jar"/>
61
				<junitee-war/>
62
			</juniteewar>
63
 
64
			<ear destfile="${basedir}/build/jar/${ant.project.name}-junitee.ear" appxml="@{appxml}">
65
				<fileset dir="${basedir}/build/pkg/jar">
66
					<include name="@{jar}" />
67
				</fileset>
68
				<fileset dir="${basedir}/build/jar">
1866 egunawan 69
					<include name="@{war}" />
1864 gzemunik 70
				</fileset>
71
				<dependencies/>
72
			</ear>
73
 
74
			<!-- 	This is the trick bit. If you just use antcall to -runservertests, it will complain that -junitee-deploy does not exist in the project. 
75
			  -    	If you explicitly import this file from the main build file after using, then it will work, but just relying on the import done in the
76
			  -	using ant-junitee call will not. Go figure?
77
			  -->
78
			<ant antfile     = "${using.ant-junitee.basedir}/ant-junitee.xml" 
79
			     dir         = "${basedir}" 
80
				 target      = "-runservertests" 
81
				 inheritAll  = "false" 
82
				 inheritRefs = "false">
83
 
84
				<reference refid = "using.junitee.path"/>
85
				<reference refid = "using.jakarta-cactus.path"/>
86
				<property  name  = "using.junitee.basedir" value="${using.junitee.basedir}"/>
87
				<property  name  = "test.project.name" value="${ant.project.name}"/>
88
				<property  name  = "env"                   environment="env" value="env"/>
89
 
90
			</ant>
91
 
92
		</sequential>
93
	</macrodef>
94
 
95
	<target name="-runservertests">
96
		<runservertests testURL="http://${env.COMPUTERNAME}:8080/unit-test/TestServlet"
97
		                    startTarget = "-junitee-deploy"
98
							stopTarget  = "-junitee-undeploy"
99
							testTarget  = "-junitee-run" />
100
	</target>
101
 
102
	<!--
103
	  -  Start unit test deployment
104
	  -->
105
	<target name="-junitee-deploy">
106
		<echo message="DEPLOYING: ${deployment.filename}"/>
107
		<echo message="DEPLOYING TO: ${deployment.location}"/>
108
		<copy file="${basedir}/build/jar/${test.project.name}-junitee.ear" 
109
		      todir="${env.JBOSS_HOME}/server/${test.project.name}/deploy"/>
110
 
111
		<java jar="${env.JBOSS_HOME}/bin/run.jar" fork="true" taskname="jboss">
112
			<arg value="-c" />
113
			<arg value="${test.project.name}" />
114
		</java>
115
	</target>
116
 
117
	<!--
118
	  -  Stop unit test deployment
119
	  -->
120
	<target name="-junitee-undeploy">
121
 
122
		<echo message="Undeploying ${env.JBOSS_HOME}/server/${test.project.name}/deploy/${test.project.name}-junitee.ear"/>
123
		<delete file="${env.JBOSS_HOME}/server/${test.project.name}/deploy/${test.project.name}-junitee.ear"/>
124
 
125
		<!-- This doesn't quite work yet...
126
		 <java jar="${env.JBOSS_HOME}/bin/shutdown.jar" fork="true">
127
			<arg value="-s localhost"/>
128
			<classpath>
129
				<pathelement location="${env.JBOSS_HOME}/client/jnet.jar"/>
130
			</classpath>
131
		</java-->
132
	</target>
133
 
134
	<!--
135
	  -  Run server-side unit tests
136
	  -->
137
	<target name="-junitee-run">
138
 
139
		<delete dir="${basedir}/build/junit"/>
140
 
141
		<mkdir dir="${basedir}/build/junit"/>
142
 
143
		<echo message="Running Unit tests.... Please wait....."/>
144
		<junitee url="http://${env.COMPUTERNAME}:8080/unit-test/TestServlet" printsummary="true">
145
			<formatter type="xml"/>
146
			<test runall="true" todir="${basedir}/build/junit"/>
147
		</junitee>
148
	</target>
149
 
150
</project>