-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-test.xml
163 lines (141 loc) · 6.16 KB
/
build-test.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?xml version="1.0" encoding="UTF-8"?>
<project name="cesecore-test" basedir=".">
<condition property="p11exclude" value="" else="**/*PKCS11*Test.class">
<isset property="test.includep11"/>
</condition>
<condition property="exclude-transactiontimeout-test" value="**/TransactionTimeoutTest.class">
<or>
<matches pattern="glassfish" string="${appserver.type}" />
<matches pattern="weblogic" string="${appserver.type}" />
</or>
</condition>
<!-- Dont run tests if -Dskip.test=true -->
<target name="test:unit" description="Run all JUnit tests. Test can be skipped using -Dskip.test=true (ant -Dskip.test=true harddeploy), add -Dtest.includep11=true to include PKCS11 HSM tests." depends="with.clover, clean, compile" unless="skip.test">
<mkdir dir="${test-classes.dir}" />
<javac srcdir="src/test" destdir="${test-classes.dir}" debug="on" includeantruntime="no" encoding="iso8859-1" target="${java.target.version}">
<classpath refid="test.classpath" />
<classpath refid="lib.jee.classpath" />
</javac>
<antcall target="showtime" />
<echo message="pkcs11-exclude=${p11exclude}"/>
<delete dir="${reports.dir}" />
<mkdir dir="${reports.dir}" />
<mkdir dir="${reports.dir}/html" />
<junit printsummary="true" haltonfailure="no">
<classpath>
<path refid="test.classpath" />
<path refid="lib.jee.classpath" />
<pathelement path="${test-classes.dir}" />
<pathelement path="${clover.jar}" />
<pathelement location="src/test/resources/" />
<pathelement location="src/main/resources/" />
<pathelement location="src/main/resources/conf/" />
</classpath>
<batchtest fork="yes" todir="${reports.dir}">
<fileset dir="${test-classes.dir}">
<include name="**/*Test.class" />
<exclude name="${p11exclude}" />
</fileset>
</batchtest>
<formatter type="xml" />
</junit>
<antcall target="createreport" />
<antcall target="showtime" />
</target>
<target name="test:func" description="Runs the functional test suite, add -Dtest.includep11=true to include PKCS11 HSM tests (ant -Dtest.includep11=true test:func)." depends="with.clover">
<antcall target="showtime" />
<echo message="pkcs11-exclude=${p11exclude}"/>
<!-- The below is only valid for JBoss
<fail message="${archive.name}.ear has not been deployed.">
<condition>
<not>
<available file="${deploy.dir}/${archive.name}.ear" />
</not>
</condition>
</fail>
<echo>Running functional test suite against ${deploy.dir}/${archive.name}.war</echo>
-->
<echo>Running functional test suite against appserver ${appserver.home}</echo>
<!-- Compile functional test classes -->
<property name="functest-classes.dir" value="${build.dir}/classes/func" />
<property name="jndi.properties.file" value="src/functionaltests/resources/jndi.properties" />
<property name="log4j.test.file" value="src/test/resources/log4j.xml" />
<mkdir dir="${functest-classes.dir}" />
<javac srcdir="src/functionaltests/test" destdir="${functest-classes.dir}" debug="on" includeantruntime="no" encoding="iso8859-1" target="${java.target.version}">
<classpath>
<pathelement location="${test-utils.dir}" />
<path refid="test.client.classpath" />
<path refid="lib.jee.classpath" />
</classpath>
</javac>
<copy file="${log4j.test.file}" tofile="${test-classes.dir}/log4j.xml" failonerror="true" />
<copy file="${jndi.properties.file}" todir="${test-classes.dir}" failonerror="false" />
<!-- TODO: This target requires a test that the application server is up and running. -->
<!-- Run tests -->
<mkdir dir="${reports.dir}/html" />
<junit printsummary="true" haltonfailure="no">
<classpath>
<path refid="test.client.classpath" />
<path refid="lib.jee.classpath" />
<pathelement location="${functest-classes.dir}" />
<pathelement location="${test-utils.dir}" />
<pathelement location="src/main/resources/" />
<pathelement location="src/main/resources/conf/" />
<pathelement location="src/test/resources/" />
<pathelement location="src/functionaltests/resources/" />
<pathelement location="src/functionaltests/resources/conf/" />
<pathelement path="${clover.jar}" />
</classpath>
<batchtest fork="yes" todir="${reports.dir}">
<fileset dir="${functest-classes.dir}">
<include name="**/*Test.class" />
<!-- Transaction timeout test only works on JBoss, since configuring timeouts on Glassfish is not as easy -->
<exclude name="${exclude-transactiontimeout-test}" />
<exclude name="${p11exclude}" />
</fileset>
</batchtest>
<formatter type="xml" />
</junit>
<antcall target="createreport" />
<antcall target="showtime" />
</target>
<target name="createreport">
<fail message="'reports.dir' is not set." unless="reports.dir" />
<junitreport todir="${reports.dir}">
<fileset dir="${reports.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${reports.dir}/html" />
</junitreport>
<echo message="" />
<echo message="Results are available in file://${reports.dir}/html/index.html" />
</target>
<target name="-check.glassfish">
<available property="glassfish.installed" file="${env.GLASSFISH_HOME}/lib/appserv-rt.jar" />
</target>
<target name="with.glassfish" depends="-check.glassfish" if="clover.installed">
<clover-setup />
</target>
<target name="test:verify" description="Runs Glassfish's EJB verifier" depends="with.glassfish">
<echo>"--verbose --destdir bin/verifier ${build.dir}/${archive.name}.ear"</echo>
<fail message="GLASSFISH_HOME environment variable is not set to a valid Glassfish (v2) directory.${line.separator}${env.GLASSFISH_HOME}/bin/verifier can not be found.">
<condition>
<not>
<available file="${env.GLASSFISH_HOME}/bin/verifier" />
</not>
</condition>
</fail>
<fail message="${archive.name}.ear has not been created">
<condition>
<not>
<available file="${build.dir}/${archive.name}.ear" />
</not>
</condition>
</fail>
<!-- make sure reports dir exists -->
<mkdir dir="${reports.dir}" />
<exec executable="${env.GLASSFISH_HOME}/bin/verifier" failonerror="true" vmlauncher="false">
<arg line="-d bin/reports ${build.dir}/${archive.name}.ear" />
</exec>
</target>
</project>