Subversion Repositories DevTools

Rev

Rev 1866 | Go to most recent revision | Details | 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
 
48
		<attribute name="jar"       default="${ant.project.name}.jar"/>
49
		<attribute name="appxml"    default="${basedir}/src/etc/application.xml"/>
50
		<element   name="junitee-war"/>
51
		<element   name="dependencies"/>
52
 
53
		<sequential>
54
 
55
			<mkdir dir="${basedir}/build/jar"/>
56
 
57
			<juniteewar destFile="${basedir}/build/jar/${ant.project.name}-junitee.war">
58
				<lib dir="${using.junitee.basedir}/jar"     includes="junitee.jar"/>
59
				<lib dir="${using.junit.basedir}/jar"       includes="junit.jar"/>
60
				<junitee-war/>
61
			</juniteewar>
62
 
63
			<ear destfile="${basedir}/build/jar/${ant.project.name}-junitee.ear" appxml="@{appxml}">
64
				<fileset dir="${basedir}/build/pkg/jar">
65
					<include name="@{jar}" />
66
				</fileset>
67
				<fileset dir="${basedir}/build/jar">
68
					<include name="${ant.project.name}-junitee.war" />
69
				</fileset>
70
				<dependencies/>
71
			</ear>
72
 
73
			<!-- 	This is the trick bit. If you just use antcall to -runservertests, it will complain that -junitee-deploy does not exist in the project. 
74
			  -    	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
75
			  -	using ant-junitee call will not. Go figure?
76
			  -->
77
			<ant antfile     = "${using.ant-junitee.basedir}/ant-junitee.xml" 
78
			     dir         = "${basedir}" 
79
				 target      = "-runservertests" 
80
				 inheritAll  = "false" 
81
				 inheritRefs = "false">
82
 
83
				<reference refid = "using.junitee.path"/>
84
				<reference refid = "using.jakarta-cactus.path"/>
85
				<property  name  = "using.junitee.basedir" value="${using.junitee.basedir}"/>
86
				<property  name  = "test.project.name" value="${ant.project.name}"/>
87
				<property  name  = "env"                   environment="env" value="env"/>
88
 
89
			</ant>
90
 
91
		</sequential>
92
	</macrodef>
93
 
94
	<target name="-runservertests">
95
		<runservertests testURL="http://${env.COMPUTERNAME}:8080/unit-test/TestServlet"
96
		                    startTarget = "-junitee-deploy"
97
							stopTarget  = "-junitee-undeploy"
98
							testTarget  = "-junitee-run" />
99
	</target>
100
 
101
	<!--
102
	  -  Start unit test deployment
103
	  -->
104
	<target name="-junitee-deploy">
105
		<echo message="DEPLOYING: ${deployment.filename}"/>
106
		<echo message="DEPLOYING TO: ${deployment.location}"/>
107
		<copy file="${basedir}/build/jar/${test.project.name}-junitee.ear" 
108
		      todir="${env.JBOSS_HOME}/server/${test.project.name}/deploy"/>
109
 
110
		<java jar="${env.JBOSS_HOME}/bin/run.jar" fork="true" taskname="jboss">
111
			<arg value="-c" />
112
			<arg value="${test.project.name}" />
113
		</java>
114
	</target>
115
 
116
	<!--
117
	  -  Stop unit test deployment
118
	  -->
119
	<target name="-junitee-undeploy">
120
 
121
		<echo message="Undeploying ${env.JBOSS_HOME}/server/${test.project.name}/deploy/${test.project.name}-junitee.ear"/>
122
		<delete file="${env.JBOSS_HOME}/server/${test.project.name}/deploy/${test.project.name}-junitee.ear"/>
123
 
124
		<!-- This doesn't quite work yet...
125
		 <java jar="${env.JBOSS_HOME}/bin/shutdown.jar" fork="true">
126
			<arg value="-s localhost"/>
127
			<classpath>
128
				<pathelement location="${env.JBOSS_HOME}/client/jnet.jar"/>
129
			</classpath>
130
		</java-->
131
	</target>
132
 
133
	<!--
134
	  -  Run server-side unit tests
135
	  -->
136
	<target name="-junitee-run">
137
 
138
		<delete dir="${basedir}/build/junit"/>
139
 
140
		<mkdir dir="${basedir}/build/junit"/>
141
 
142
		<echo message="Running Unit tests.... Please wait....."/>
143
		<junitee url="http://${env.COMPUTERNAME}:8080/unit-test/TestServlet" printsummary="true">
144
			<formatter type="xml"/>
145
			<test runall="true" todir="${basedir}/build/junit"/>
146
		</junitee>
147
	</target>
148
 
149
</project>