1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--
4   Copyright (c) 2009, 2015 Mountainminds GmbH & Co. KG and Contributors
5   All rights reserved. This program and the accompanying materials
6   are made available under the terms of the Eclipse Public License v1.0
7   which accompanies this distribution, and is available at
8   http://www.eclipse.org/legal/epl-v10.html
9
10   Contributors:
11      Brock Janiczak - initial API and implementation
12
13   $Id: $
14-->
15
16<project name="JaCoCo Agent Task Tests" xmlns:au="antlib:org.apache.ant.antunit" xmlns:jacoco="antlib:org.jacoco.ant">
17
18	<target name="testCoverageAgent">
19		<jacoco:agent property="jacocoagent" append="false" destfile="test.exec"
20			exclClassLoader="EvilClassLoader" includes="org.example.*"
21		    excludes="*Test" sessionid="testid" dumponexit="false"
22			output="file" address="remotehost" port="1234"
23			classdumpdir="target/dump"/>
24		<au:assertPropertySet name="jacocoagent"/>
25		<au:assertPropertyContains name="jacocoagent" value="-javaagent:"/>
26		<au:assertPropertyContains name="jacocoagent" value="append=false"/>
27		<property name="exec.file" location="test.exec"/>
28		<au:assertPropertyContains name="jacocoagent" value="destfile=${exec.file}"/>
29		<au:assertPropertyContains name="jacocoagent" value="exclclassloader=EvilClassLoader"/>
30		<au:assertPropertyContains name="jacocoagent" value="includes=org.example.*"/>
31		<au:assertPropertyContains name="jacocoagent" value="excludes=*Test"/>
32		<au:assertPropertyContains name="jacocoagent" value="sessionid=testid"/>
33		<au:assertPropertyContains name="jacocoagent" value="dumponexit=false"/>
34		<au:assertPropertyContains name="jacocoagent" value="output=file"/>
35		<au:assertPropertyContains name="jacocoagent" value="address=remotehost"/>
36		<au:assertPropertyContains name="jacocoagent" value="port=1234"/>
37		<property name="dump.dir" location="target/dump"/>
38		<au:assertPropertyContains name="jacocoagent" value="classdumpdir=${dump.dir}"/>
39	</target>
40
41	<target name="testCoverageAgentDisabled">
42		<jacoco:agent enabled="false" property="jacocoagent" append="false" destfile="${basedir}/test.exec" exclClassLoader="sun.reflect.DelegatingClassLoader"/>
43		<au:assertPropertyEquals name="jacocoagent" value=""/>
44	</target>
45
46	<target name="testCoverageAgentWithNoProperty">
47		<au:expectfailure expectedMessage="Property is mandatory">
48			<jacoco:agent/>
49		</au:expectfailure>
50	</target>
51
52	<target name="testCoverageAgentWithEmptyProperty">
53		<au:expectfailure expectedMessage="Property is mandatory">
54			<jacoco:agent property=""/>
55		</au:expectfailure>
56	</target>
57
58	<target name="testCoverageAgentReuseAgentJar">
59		<jacoco:agent property="agent1"/>
60		<jacoco:agent property="agent2"/>
61		<au:assertEquals expected="${agent1}" actual="${agent2}"/>
62	</target>
63
64</project>