Trac #77: Refactor Ant task tests.
diff --git a/org.jacoco.ant.test/.classpath b/org.jacoco.ant.test/.classpath
index 2d1a430..5e28ab4 100644
--- a/org.jacoco.ant.test/.classpath
+++ b/org.jacoco.ant.test/.classpath
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>

 <classpath>

+	<classpathentry exported="true" kind="lib" path="lib/ant-antunit-1.2alpha.jar"/>

 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>

 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>

 	<classpathentry kind="src" path="src"/>

diff --git a/org.jacoco.ant.test/META-INF/MANIFEST.MF b/org.jacoco.ant.test/META-INF/MANIFEST.MF
index 59f41fa..06780dc 100644
--- a/org.jacoco.ant.test/META-INF/MANIFEST.MF
+++ b/org.jacoco.ant.test/META-INF/MANIFEST.MF
@@ -5,5 +5,8 @@
 Bundle-Version: 0.3.2.qualifier
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-Vendor: Mountainminds GmbH & Co. KG and Contributors
-Fragment-Host: org.jacoco.core
-Require-Bundle: org.junit4;bundle-version="[4.0.0,5.0.0)"
+Fragment-Host: org.jacoco.ant
+Require-Bundle: org.junit4;bundle-version="[4.5.0,5.0.0)",
+ org.apache.ant;bundle-version="[1.7.1,2.0.0)"
+Bundle-ClassPath: .,
+ lib/ant-antunit-1.2alpha.jar
diff --git a/org.jacoco.ant.test/ant/lib/ant-antunit-1.1.jar b/org.jacoco.ant.test/ant/lib/ant-antunit-1.1.jar
deleted file mode 100644
index 8dd4b3d..0000000
--- a/org.jacoco.ant.test/ant/lib/ant-antunit-1.1.jar
+++ /dev/null
Binary files differ
diff --git a/org.jacoco.ant.test/ant/runtest.xml b/org.jacoco.ant.test/ant/runtest.xml
deleted file mode 100644
index 09474c8..0000000
--- a/org.jacoco.ant.test/ant/runtest.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>

-

-<!-- 

-   Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors

-   All rights reserved. This program and the accompanying materials

-   are made available under the terms of the Eclipse Public License v1.0

-   which accompanies this distribution, and is available at

-   http://www.eclipse.org/legal/epl-v10.html

-  

-   Contributors:

-      Brock Janiczak - initial API and implementation

-      

-   $Id: $

--->

-

-<project name="Run Ant Unit Tests" xmlns:au="antlib:org.apache.ant.antunit" basedir="." default="test">

-

-	<taskdef uri="antlib:org.apache.ant.antunit" resource="org/apache/ant/antunit/antlib.xml">

-		<classpath>

-			<fileset dir="lib" includes="*.jar"/>

-		</classpath>

-	</taskdef>

-	

-	<target name="test">

-		<au:antunit failonerror="true">

-			<propertyset>

-				<propertyref name="result.dist.lib.dir"/>

-				<propertyref name="result.tmp.bundle.testdata.dir"/>

-				<propertyref name="result.tmp.bundle.classes.dir"/>

-				<propertyref name="bundle-org.junit4.path"/>

-			</propertyset>

-	    	

-			<fileset dir="test" includes="*.xml"/>

-			<!-- The XML Listener is broken in a few ways:

-	    	     Attempts to create package names for the tests, but only works if tests are under the base dir

-	    	     XML result is not parseable by the eclipse junit framework

-			-->

-			<!--

-			<au:xmllistener todir="${result.tmp.bundle.test.dir}" loglevel="info"/>

-			-->

-			<au:plainlistener sendLogTo="ant" logLevel="info"/>

-		</au:antunit>

-	</target>

-

-</project>
\ No newline at end of file
diff --git a/org.jacoco.ant.test/ant/test/org.jacoco.ant.CoverageTaskTest.xml b/org.jacoco.ant.test/ant/test/org.jacoco.ant.CoverageTaskTest.xml
deleted file mode 100644
index 16f760e..0000000
--- a/org.jacoco.ant.test/ant/test/org.jacoco.ant.CoverageTaskTest.xml
+++ /dev/null
@@ -1,160 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>

-

-<!-- 

-   Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors

-   All rights reserved. This program and the accompanying materials

-   are made available under the terms of the Eclipse Public License v1.0

-   which accompanies this distribution, and is available at

-   http://www.eclipse.org/legal/epl-v10.html

-  

-   Contributors:

-      Brock Janiczak - initial API and implementation

-      

-   $Id: $

--->

-

-<project name="JaCoCo Coverage Task Tests" xmlns:au="antlib:org.apache.ant.antunit" xmlns:jacoco="antlib:org.jacoco.ant">

-	

-	<path id="ant-test-classes">

-		<path path="${result.tmp.bundle.classes.dir}"/>

-	</path>

-	

-	<path id="bundle-org.junit4" path="${bundle-org.junit4.path}"/>

-			

-	<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">

-		<classpath>

-			<file file="${result.dist.lib.dir}/jacocoant.jar"/>

-		</classpath>

-	</taskdef>

-	

-	<target name="setUp">

-		<delete dir="${result.tmp.bundle.testdata.dir}" quiet="false" failonerror="true"/>

-		<mkdir dir="${result.tmp.bundle.testdata.dir}"/>

-	</target>

-

-	<target name="testNoSubTasks">

-		<au:expectfailure expectedMessage="A child task must be supplied for the coverage task">

-			<jacoco:coverage/>

-		</au:expectfailure>

-	</target>

-

-	<target name="testMultipleSubTasks">

-		<au:expectfailure expectedMessage="Only one child task can be supplied to the coverge task">

-			<jacoco:coverage>

-				<java fork="true" classname="org.jacoco.ant.test.EmptyMain">

-					<classpath>

-						<path refid="ant-test-classes"/>

-					</classpath>

-				</java>

-				<java fork="true" classname="org.jacoco.ant.test.EmptyMain">

-					<classpath>

-						<path refid="ant-test-classes"/>

-					</classpath>

-				</java>

-			</jacoco:coverage>

-		</au:expectfailure>

-	</target>

-	

-	<target name="testInvalidSubTask">

-		<au:expectfailure expectedMessage="jar is not a valid child of the coverage task">

-			<jacoco:coverage>

-				<jar destfile="test.jar"/>

-			</jacoco:coverage>

-		</au:expectfailure>

-	</target>

-

-	<target name="testCoverageOfForkedJava">

-		<property name="testCoverageOfForkedJava.exec.file" location="${result.tmp.bundle.testdata.dir}/testCoverageOfForkedJava.exec"/>

-		<jacoco:coverage destfile="${testCoverageOfForkedJava.exec.file}">

-			<java classname="org.jacoco.ant.test.EmptyMain" fork="true">

-				<classpath>

-					<path refid="ant-test-classes"/>

-				</classpath>

-			</java>

-		</jacoco:coverage>

-		<au:assertLogContains text="Enhancing java with coverage"/>

-		<au:assertFileExists file="${testCoverageOfForkedJava.exec.file}"/>

-	</target>

-	

-	<target name="testCoverageOfForkedJavaDisabled">

-		<property name="testCoverageOfForkedJava.exec.file" location="${result.tmp.bundle.testdata.dir}/testCoverageOfForkedJavaDisabled.exec"/>

-		<jacoco:coverage enabled="false" destfile="${testCoverageOfForkedJava.exec.file}">

-			<java classname="org.jacoco.ant.test.EmptyMain" fork="true">

-				<classpath>

-					<path refid="ant-test-classes"/>

-				</classpath>

-			</java>

-		</jacoco:coverage>

-		<au:assertLogDoesntContain text="Enhancing java with coverage"/>

-		<au:assertFileDoesntExist file="${testCoverageOfForkedJava.exec.file}"/>

-	</target>

-

-	<target name="testCoverageOfNonForkedJava">

-		<au:expectfailure expectedMessage="Coverage can only be applied on a forked VM">

-			<jacoco:coverage>

-				<java classname="org.jacoco.ant.test.EmptyMain" fork="false">

-					<classpath>

-						<path refid="ant-test-classes"/>

-					</classpath>

-				</java>

-			</jacoco:coverage>

-		</au:expectfailure>

-	</target>

-

-	<target name="testCoverageOfForkedJUnit">

-		<property name="testCoverageOfForkedJUnit.exec.file" location="${result.tmp.bundle.testdata.dir}/testCoverageOfForkedJUnit.exec"/>

-		<jacoco:coverage destfile="${testCoverageOfForkedJUnit.exec.file}">

-			<junit fork="true" >

-				<classpath>

-					<path refid="bundle-org.junit4"/>

-					<path refid="ant-test-classes"/>

-				</classpath>

-			    <batchtest todir="${result.tmp.bundle.test.dir}" >

-					<fileset dir="${result.tmp.bundle.classes.dir}">

-						<include name="org/jacoco/ant/test/EmptyTest.class"/>

-					</fileset>

-			    </batchtest>

-			</junit>

-		</jacoco:coverage>

-		<au:assertLogContains text="Enhancing junit with coverage"/>

-		<au:assertFileExists file="${testCoverageOfForkedJUnit.exec.file}"/>

-	</target>

-	

-	<target name="testCoverageOfForkedJUnitDisabled">

-		<property name="testCoverageOfForkedJUnit.exec.file" location="${result.tmp.bundle.testdata.dir}/testCoverageOfForkedJUnitDisabled.exec"/>

-		<jacoco:coverage enabled="false" destfile="${testCoverageOfForkedJUnit.exec.file}">

-			<junit fork="true" >

-				<classpath>

-					<path refid="bundle-org.junit4"/>

-					<path refid="ant-test-classes"/>

-				</classpath>

-			    <batchtest todir="${result.tmp.bundle.test.dir}" >

-					<fileset dir="${result.tmp.bundle.classes.dir}">

-						<include name="org/jacoco/ant/test/EmptyTest.class"/>

-					</fileset>

-			    </batchtest>

-			</junit>

-		</jacoco:coverage>

-		<au:assertLogDoesntContain text="Enhancing junit with coverage"/>

-		<au:assertFileDoesntExist file="${testCoverageOfForkedJUnit.exec.file}"/>

-	</target>

-

-	<target name="testCoverageOfNonForkedJUnit">

-		<au:expectfailure expectedMessage="Coverage can only be applied on a forked VM">

-			<jacoco:coverage>

-				<junit fork="false">

-					<classpath>

-						<path refid="bundle-org.junit4"/>

-						<path refid="ant-test-classes"/>

-					</classpath>

-				    <batchtest todir="${result.tmp.bundle.test.dir}" >

-						<fileset dir="${result.tmp.bundle.classes.dir}">

-							<include name="org/jacoco/ant/test/EmptyTest.class"/>

-						</fileset>

-				    </batchtest>

-				</junit>

-			</jacoco:coverage>

-		</au:expectfailure>

-	</target>

-	

-</project>
\ No newline at end of file
diff --git a/org.jacoco.ant.test/ant/test/org.jacoco.ant.MergeTaskTest.xml b/org.jacoco.ant.test/ant/test/org.jacoco.ant.MergeTaskTest.xml
deleted file mode 100644
index 637f279..0000000
--- a/org.jacoco.ant.test/ant/test/org.jacoco.ant.MergeTaskTest.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>

-

-<!-- 

-   Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors

-   All rights reserved. This program and the accompanying materials

-   are made available under the terms of the Eclipse Public License v1.0

-   which accompanies this distribution, and is available at

-   http://www.eclipse.org/legal/epl-v10.html

-  

-   Contributors:

-      Brock Janiczak - initial API and implementation

-      

-   $Id: $

--->

-

-<project name="JaCoCo Merge Task Tests" xmlns:au="antlib:org.apache.ant.antunit" xmlns:jacoco="antlib:org.jacoco.ant">

-			

-	<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">

-		<classpath>

-			<file file="${result.dist.lib.dir}/jacocoant.jar"/>

-		</classpath>

-	</taskdef>

-	

-	<target name="setUp">

-		<delete dir="${result.tmp.bundle.testdata.dir}" quiet="false" failonerror="true"/>

-		<mkdir dir="${result.tmp.bundle.testdata.dir}"/>

-	</target>

-	

-	<target name="testMergeNoDestination">

-		<au:expectfailure expectedMessage="Destination file must be supplied">

-			<jacoco:merge/>

-		</au:expectfailure>

-	</target>

-	

-	<target name="testMergeToDirectory">

-		<au:expectfailure expectedMessage="Unable to write to destination file">

-			<jacoco:merge destfile="${basedir}"/>

-		</au:expectfailure>

-	</target>

-	

-	<target name="testMergeEmptySet">

-		<property name="testMergeEmptySet.exec.file" location="${result.tmp.bundle.testdata.dir}/empty.exec"/>

-		<jacoco:merge destfile="${testMergeEmptySet.exec.file}"/>

-		

-		<au:assertLogContains text="0 files merged"/>

-		<au:assertFileExists file="${testMergeEmptySet.exec.file}"/>

-	</target>

-	

-	<target name="testMergeMultipleFiles">

-		<property name="testMergeMultipleFiles.exec.file" location="${result.tmp.bundle.testdata.dir}/merged.exec"/>

-		<jacoco:merge destfile="${testMergeMultipleFiles.exec.file}">

-			<fileset dir="executionData" includes="*.exec"/>

-		</jacoco:merge>

-		

-		<au:assertLogContains text="2 files merged"/>

-		<au:assertFileExists file="${testMergeMultipleFiles.exec.file}"/>

-	</target>

-

-</project>
\ No newline at end of file
diff --git a/org.jacoco.ant.test/build.properties b/org.jacoco.ant.test/build.properties
index a657887..2d2aa2a 100644
--- a/org.jacoco.ant.test/build.properties
+++ b/org.jacoco.ant.test/build.properties
@@ -2,4 +2,5 @@
 output.. = bin/

 bin.includes = META-INF/,\

                .,\

-               about.html

+               about.html,\

+               lib/ant-antunit-1.2alpha.jar

diff --git a/org.jacoco.ant.test/buildhook.xml b/org.jacoco.ant.test/buildhook.xml
index 81619d7..ef80cc2 100644
--- a/org.jacoco.ant.test/buildhook.xml
+++ b/org.jacoco.ant.test/buildhook.xml
@@ -16,38 +16,18 @@
 <project name="org.jacoco.ant.tests.buildhook" xmlns:au="antlib:org.apache.ant.antunit" xmlns:jacoco="antlib:org.jacoco.ant" basedir=".">

 	

 	<path id="dependencies">

+		<path refid="bundle-org.jacoco.core"/>

+		<path refid="bundle-org.jacoco.agent"/>

+		<path refid="bundle-org.jacoco.report"/>

+		<path refid="bundle-org.jacoco.ant"/>

+		<path refid="bundle-org.objectweb.asm"/>

 		<path refid="bundle-org.junit4"/>

+		<file file="${source.bundle.dir}/lib/ant-antunit-1.2alpha.jar"/>

 	</path>

 	

 	<property name="do.compile" value="true"/>

-	<property name="do.customverify" value="true"/>

+	<property name="do.verify" value="true"/>

 	

 	<property name="testscope" value="org.jacoco.ant.*"/>

-		

-	<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">

-		<classpath>

-			<file file="${result.dist.lib.dir}/jacocoant.jar"/>

-		</classpath>

-	</taskdef>

-	

-	<target name="customverify">

-		<property name="result.dist.bundle.jar.file" location="${result.dist.lib.dir}/${manifest.Bundle-SymbolicName}_${qualified.bundle.version}.jar"/>

-		<property name="result.tmp.bundle.test.dir" location="${result.tmp.bundle.dir}/test"/>

-		<property name="result.tmp.bundle.testdata.dir" location="${result.tmp.bundle.dir}/testdata"/>

-		

-		<jacoco:coverage

-				append="true"

-				includes="${testscope}"

-				destfile="${result.tmp.coverage.file}">

-			<java fork="true" jar="${ant.library.dir}/ant-launcher.jar" failonerror="true">

-				<arg value="-f"/>

-				<arg value="${source.bundle.dir}/ant/runtest.xml"/>

-				<arg value="-Dresult.dist.lib.dir=${result.dist.lib.dir}"/>

-				<arg value="-Dresult.tmp.bundle.testdata.dir=${result.tmp.bundle.testdata.dir}"/>

-				<arg value="-Dresult.tmp.bundle.classes.dir=${result.tmp.bundle.classes.dir}"/>

-				<arg value="-Dbundle-org.junit4.path=${toString:bundle-org.junit4}"/>

-			</java>

-		</jacoco:coverage>

 

-	</target>

 </project>
\ No newline at end of file
diff --git a/org.jacoco.ant.test/lib/ant-antunit-1.2alpha.jar b/org.jacoco.ant.test/lib/ant-antunit-1.2alpha.jar
new file mode 100644
index 0000000..9e1f518
--- /dev/null
+++ b/org.jacoco.ant.test/lib/ant-antunit-1.2alpha.jar
Binary files differ
diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/AgentTaskTest.java b/org.jacoco.ant.test/src/org/jacoco/ant/AgentTaskTest.java
new file mode 100644
index 0000000..7f94bb4
--- /dev/null
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/AgentTaskTest.java
@@ -0,0 +1,31 @@
+/*******************************************************************************

+ * Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *    Brock Janiczak - initial API and implementation

+ *    

+ * $Id: $

+ *******************************************************************************/

+package org.jacoco.ant;

+

+import java.io.File;

+

+import junit.framework.TestSuite;

+

+import org.apache.ant.antunit.junit3.AntUnitSuite;

+import org.apache.ant.antunit.junit4.AntUnitSuiteRunner;

+import org.junit.runner.RunWith;

+

+@RunWith(AntUnitSuiteRunner.class)

+public class AgentTaskTest {

+

+	public static TestSuite suite() {

+		final File file = new File("src/org/jacoco/ant/AgentTaskTest.xml");

+		return new AntUnitSuite(file, AgentTaskTest.class);

+	}

+

+}

diff --git a/org.jacoco.ant.test/ant/test/org.jacoco.ant.AgentTaskTest.xml b/org.jacoco.ant.test/src/org/jacoco/ant/AgentTaskTest.xml
similarity index 82%
rename from org.jacoco.ant.test/ant/test/org.jacoco.ant.AgentTaskTest.xml
rename to org.jacoco.ant.test/src/org/jacoco/ant/AgentTaskTest.xml
index 621443a..699d5a8 100644
--- a/org.jacoco.ant.test/ant/test/org.jacoco.ant.AgentTaskTest.xml
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/AgentTaskTest.xml
@@ -15,14 +15,8 @@
 

 <project name="JaCoCo Agent Task Tests" xmlns:au="antlib:org.apache.ant.antunit" xmlns:jacoco="antlib:org.jacoco.ant">

 			

-	<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">

-		<classpath>

-			<file file="${result.dist.lib.dir}/jacocoant.jar"/>

-		</classpath>

-	</taskdef>

-	

 	<target name="testCoverageAgent">

-		<jacoco:agent property="jacocoagent" append="false" destfile="${basedir}/test.exec" exclClassLoader="sun.reflect.DelegatingClassLoader"/>

+		<jacoco:agent property="jacocoagent" append="false" destfile="test.exec" exclClassLoader="sun.reflect.DelegatingClassLoader"/>

 		<au:assertPropertySet name="jacocoagent"/>

 	</target>

 	

diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.java b/org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.java
new file mode 100644
index 0000000..5d9c238
--- /dev/null
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.java
@@ -0,0 +1,31 @@
+/*******************************************************************************

+ * Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *    Brock Janiczak - initial API and implementation

+ *    

+ * $Id: $

+ *******************************************************************************/

+package org.jacoco.ant;

+

+import java.io.File;

+

+import junit.framework.TestSuite;

+

+import org.apache.ant.antunit.junit3.AntUnitSuite;

+import org.apache.ant.antunit.junit4.AntUnitSuiteRunner;

+import org.junit.runner.RunWith;

+

+@RunWith(AntUnitSuiteRunner.class)

+public class CoverageTaskTest {

+

+	public static TestSuite suite() {

+		final File file = new File("src/org/jacoco/ant/CoverageTaskTest.xml");

+		return new AntUnitSuite(file, CoverageTaskTest.class);

+	}

+

+}

diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.xml b/org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.xml
new file mode 100644
index 0000000..0f4903b
--- /dev/null
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>

+

+<!-- 

+   Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors

+   All rights reserved. This program and the accompanying materials

+   are made available under the terms of the Eclipse Public License v1.0

+   which accompanies this distribution, and is available at

+   http://www.eclipse.org/legal/epl-v10.html

+  

+   Contributors:

+      Brock Janiczak - initial API and implementation

+      

+   $Id: $

+-->

+

+<project name="JaCoCo Coverage Task Tests" xmlns:au="antlib:org.apache.ant.antunit" xmlns:jacoco="antlib:org.jacoco.ant">

+	

+	<target name="setUp">

+		<tempfile property="temp.dir" prefix="jacocoTest" destdir="${java.io.tmpdir}" />

+		<mkdir dir="${temp.dir}"/>

+		<property name="exec.file" location="${temp.dir}/exec.file" />

+	</target>

+

+	<target name="tearDown">

+		<delete dir="${temp.dir}" quiet="false" failonerror="true"/>

+	</target>

+			

+	<target name="testNoSubTasks">

+		<au:expectfailure expectedMessage="A child task must be supplied for the coverage task">

+			<jacoco:coverage/>

+		</au:expectfailure>

+	</target>

+

+	<target name="testMultipleSubTasks">

+		<au:expectfailure expectedMessage="Only one child task can be supplied to the coverge task">

+			<jacoco:coverage>

+				<java fork="true" classname="Foo" />

+				<java fork="true" classname="Foo" />

+			</jacoco:coverage>

+		</au:expectfailure>

+	</target>

+	

+	<target name="testInvalidSubTask">

+		<au:expectfailure expectedMessage="jar is not a valid child of the coverage task">

+			<jacoco:coverage>

+				<jar destfile="test.jar"/>

+			</jacoco:coverage>

+		</au:expectfailure>

+	</target>

+

+	<target name="testCoverageOfForkedJava">

+		<jacoco:coverage destfile="${exec.file}">

+			<java classname="org.jacoco.ant.test.EmptyMain" fork="true" />

+		</jacoco:coverage>

+		<au:assertLogContains text="Enhancing java with coverage"/>

+		<au:assertFileExists file="${exec.file}"/>

+	</target>

+	

+	<target name="testCoverageOfForkedJavaDisabled">

+		<jacoco:coverage enabled="false" destfile="${exec.file}">

+			<java classname="org.jacoco.ant.test.EmptyMain" fork="true" />

+		</jacoco:coverage>

+		<au:assertLogDoesntContain text="Enhancing java with coverage"/>

+		<au:assertFileDoesntExist file="${exec.file}"/>

+	</target>

+

+	<target name="testCoverageOfNonForkedJava">

+		<au:expectfailure expectedMessage="Coverage can only be applied on a forked VM">

+			<jacoco:coverage>

+				<java classname="Foo" fork="false" />

+			</jacoco:coverage>

+		</au:expectfailure>

+	</target>

+

+	<target name="testCoverageOfForkedJUnit">

+		<jacoco:coverage destfile="${exec.file}">

+			<junit fork="true" >

+			    <batchtest todir="${temp.dir}" >

+					<fileset dir=".">

+						<include name="**/EmptyTestTarget.java"/>

+					</fileset>

+			    </batchtest>

+			</junit>

+		</jacoco:coverage>

+		<au:assertLogContains text="Enhancing junit with coverage"/>

+		<au:assertFileExists file="${exec.file}"/>

+	</target>

+	

+	<target name="testCoverageOfForkedJUnitDisabled">

+		<jacoco:coverage enabled="false" destfile="${exec.file}">

+			<junit fork="true" >

+			    <batchtest todir="${temp.dir}" >

+					<fileset dir=".">

+						<include name="**/EmptyTestTarget.java"/>

+					</fileset>

+			    </batchtest>

+			</junit>

+		</jacoco:coverage>

+		<au:assertLogDoesntContain text="Enhancing junit with coverage"/>

+		<au:assertFileDoesntExist file="${exec.file}"/>

+	</target>

+

+	<target name="testCoverageOfNonForkedJUnit">

+		<au:expectfailure expectedMessage="Coverage can only be applied on a forked VM">

+			<jacoco:coverage>

+				<junit fork="false" />

+			</jacoco:coverage>

+		</au:expectfailure>

+	</target>

+	

+</project>
\ No newline at end of file
diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/MergeTaskTest.java b/org.jacoco.ant.test/src/org/jacoco/ant/MergeTaskTest.java
new file mode 100644
index 0000000..701bf90
--- /dev/null
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/MergeTaskTest.java
@@ -0,0 +1,31 @@
+/*******************************************************************************

+ * Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *    Brock Janiczak - initial API and implementation

+ *    

+ * $Id: $

+ *******************************************************************************/

+package org.jacoco.ant;

+

+import java.io.File;

+

+import junit.framework.TestSuite;

+

+import org.apache.ant.antunit.junit3.AntUnitSuite;

+import org.apache.ant.antunit.junit4.AntUnitSuiteRunner;

+import org.junit.runner.RunWith;

+

+@RunWith(AntUnitSuiteRunner.class)

+public class MergeTaskTest {

+

+	public static TestSuite suite() {

+		final File file = new File("src/org/jacoco/ant/MergeTaskTest.xml");

+		return new AntUnitSuite(file, MergeTaskTest.class);

+	}

+

+}

diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/MergeTaskTest.xml b/org.jacoco.ant.test/src/org/jacoco/ant/MergeTaskTest.xml
new file mode 100644
index 0000000..24a5091
--- /dev/null
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/MergeTaskTest.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>

+

+<!-- 

+   Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors

+   All rights reserved. This program and the accompanying materials

+   are made available under the terms of the Eclipse Public License v1.0

+   which accompanies this distribution, and is available at

+   http://www.eclipse.org/legal/epl-v10.html

+  

+   Contributors:

+      Brock Janiczak - initial API and implementation

+      

+   $Id: $

+-->

+

+<project name="JaCoCo Merge Task Tests" xmlns:au="antlib:org.apache.ant.antunit" xmlns:jacoco="antlib:org.jacoco.ant">

+

+	<target name="setUp">

+		<tempfile property="temp.dir" prefix="jacocoTest" destdir="${java.io.tmpdir}" />

+		<mkdir dir="${temp.dir}"/>

+		<property name="exec.file" location="${temp.dir}/exec.file" />

+	</target>

+

+	<target name="tearDown">

+		<delete dir="${temp.dir}" quiet="false" failonerror="true"/>

+	</target>

+	

+	<target name="testMergeNoDestination">

+		<au:expectfailure expectedMessage="Destination file must be supplied">

+			<jacoco:merge/>

+		</au:expectfailure>

+	</target>

+	

+	<target name="testMergeToDirectory">

+		<au:expectfailure expectedMessage="Unable to write to destination file">

+			<jacoco:merge destfile="${temp.dir}"/>

+		</au:expectfailure>

+	</target>

+	

+	<target name="testMergeEmptySet">

+		<jacoco:merge destfile="${exec.file}"/>

+		

+		<au:assertLogContains text="0 files merged"/>

+		<au:assertFileExists file="${exec.file}"/>

+	</target>

+	

+	<target name="testMergeMultipleFiles">

+		<jacoco:merge destfile="${exec.file}">

+			<fileset dir="data" includes="*.exec"/>

+		</jacoco:merge>

+		

+		<au:assertLogContains text="2 files merged"/>

+		<au:assertFileExists file="${exec.file}"/>

+	</target>

+

+</project>
\ No newline at end of file
diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.java b/org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.java
new file mode 100644
index 0000000..a529097
--- /dev/null
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************

+ * Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *    Brock Janiczak - initial API and implementation

+ *    

+ * $Id: $

+ *******************************************************************************/

+package org.jacoco.ant;

+

+import java.io.File;

+

+import junit.framework.TestSuite;

+

+import org.apache.ant.antunit.junit3.AntUnitSuite;

+import org.apache.ant.antunit.junit4.AntUnitSuiteRunner;

+import org.junit.runner.RunWith;

+

+@RunWith(AntUnitSuiteRunner.class)

+public class ReportTaskTest {

+

+	public static TestSuite suite() {

+		System.setProperty("org.jacoco.ant.reportTaskTest.classes.dir",

+				getClassFileLocation());

+		final File file = new File("src/org/jacoco/ant/ReportTaskTest.xml");

+		return new AntUnitSuite(file, ReportTaskTest.class);

+	}

+

+	/**

+	 * @return class path entry where this class is located

+	 */

+	private static String getClassFileLocation() {

+		String name = ReportTaskTest.class.getName();

+		final String res = "/" + name.replace('.', '/') + ".class";

+		final String loc = ReportTaskTest.class.getResource(res).getFile();

+		return loc.substring(0, loc.length() - res.length());

+	}

+

+}

diff --git a/org.jacoco.ant.test/ant/test/org.jacoco.ant.ReportTaskTest.xml b/org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.xml
similarity index 72%
rename from org.jacoco.ant.test/ant/test/org.jacoco.ant.ReportTaskTest.xml
rename to org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.xml
index e77fbe0..000aec7 100644
--- a/org.jacoco.ant.test/ant/test/org.jacoco.ant.ReportTaskTest.xml
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.xml
@@ -15,15 +15,13 @@
 

 <project name="JaCoCo Report Task Tests" xmlns:au="antlib:org.apache.ant.antunit" xmlns:jacoco="antlib:org.jacoco.ant">

 			

-	<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">

-		<classpath>

-			<file file="${result.dist.lib.dir}/jacocoant.jar"/>

-		</classpath>

-	</taskdef>

-	

 	<target name="setUp">

-		<delete dir="${result.tmp.bundle.testdata.dir}" quiet="false" failonerror="true"/>

-		<mkdir dir="${result.tmp.bundle.testdata.dir}"/>

+		<tempfile property="temp.dir" prefix="jacocoTest" destdir="${java.io.tmpdir}" />

+		<mkdir dir="${temp.dir}"/>

+	</target>

+

+	<target name="tearDown">

+		<delete dir="${temp.dir}" quiet="false" failonerror="true" />

 	</target>

 	

 	

@@ -77,7 +75,7 @@
 		<au:expectfailure expectedMessage="Either destination directory or file must be supplied, not both">

 			<jacoco:report>

 				<structure name="root"/>

-				<html destdir="${result.tmp.bundle.testdata.dir}" destfile="${result.tmp.bundle.testdata.dir}/report.zip"/>

+				<html destdir="${temp.dir}" destfile="${temp.dir}/report.zip"/>

 			</jacoco:report>

 		</au:expectfailure>

 	</target>

@@ -87,14 +85,14 @@
 			<structure name="Test">

 				<group name="Group">

 					<classfiles>

-						<fileset dir="${result.tmp.bundle.classes.dir}" includes="**/*.class"/>

+						<fileset dir="${org.jacoco.ant.reportTaskTest.classes.dir}" includes="**/*.class"/>

 					</classfiles>

 				</group>

 			</structure>

-			<html destdir="${result.tmp.bundle.testdata.dir}"/>

+			<html destdir="${temp.dir}"/>

 		</jacoco:report>

 		

-		<au:assertFileExists file="${result.tmp.bundle.testdata.dir}/Group/org.jacoco.ant.test/EmptyTest.html"/>

+		<au:assertFileExists file="${temp.dir}/Group/org.jacoco.ant/ReportTaskTest.html"/>

 	</target>

 	

 	<target name="testReportHtmlWithPath">

@@ -102,20 +100,20 @@
 			<structure name="Test">

 				<group name="Group">

 					<classfiles>

-						<path location="${result.tmp.bundle.classes.dir}"/>

+						<path location="${org.jacoco.ant.reportTaskTest.classes.dir}"/>

 					</classfiles>

 				</group>

 			</structure>

-			<html destdir="${result.tmp.bundle.testdata.dir}"/>

+			<html destdir="${temp.dir}"/>

 		</jacoco:report>

 		

-		<au:assertFileExists file="${result.tmp.bundle.testdata.dir}/Group/org.jacoco.ant.test/EmptyTest.html"/>

+		<au:assertFileExists file="${temp.dir}/Group/org.jacoco.ant/ReportTaskTest.html"/>

 	</target>

 	

 	<target name="testReportHtmlWithJAR">

-		<property name="testReportHtmlWithJAR.jarfile" location="${result.tmp.bundle.testdata.dir}/testclasses.jar"/>

+		<property name="testReportHtmlWithJAR.jarfile" location="${temp.dir}/testclasses.jar"/>

 		<jar destfile="${testReportHtmlWithJAR.jarfile}">

-			<fileset dir="${result.tmp.bundle.classes.dir}" includes="**/*.class"/>

+			<fileset dir="${org.jacoco.ant.reportTaskTest.classes.dir}" includes="**/*.class"/>

 		</jar>

 		<jacoco:report>

 			<structure name="Test">

@@ -125,19 +123,19 @@
 					</classfiles>

 				</group>

 			</structure>

-			<html destdir="${result.tmp.bundle.testdata.dir}"/>

+			<html destdir="${temp.dir}"/>

 		</jacoco:report>

 		

-		<au:assertFileExists file="${result.tmp.bundle.testdata.dir}/Group/org.jacoco.ant.test/EmptyTest.html"/>

+		<au:assertFileExists file="${temp.dir}/Group/org.jacoco.ant/ReportTaskTest.html"/>

 	</target>

 	

 	<target name="testReportHtmlFooter">

 		<jacoco:report>

 			<structure name="Test"/>

-			<html footer="ExampleFooter" destdir="${result.tmp.bundle.testdata.dir}"/>

+			<html footer="ExampleFooter" destdir="${temp.dir}"/>

 		</jacoco:report>

 		

-		<loadfile property="testReportHtmlFooter.content" srcfile="${result.tmp.bundle.testdata.dir}/index.html" encoding="UTF-8"/>

+		<loadfile property="testReportHtmlFooter.content" srcfile="${temp.dir}/index.html" encoding="UTF-8"/>

 		<au:assertTrue message="Footer not included in ${testReportHtmlFooter.content}">

 			<contains string="${testReportHtmlFooter.content}" substring="ExampleFooter"/>

 		</au:assertTrue>

@@ -146,10 +144,10 @@
 	<target name="testReportHtmlEncoding">

 		<jacoco:report>

 			<structure name="Test"/>

-			<html encoding="UTF-16" destdir="${result.tmp.bundle.testdata.dir}"/>

+			<html encoding="UTF-16" destdir="${temp.dir}"/>

 		</jacoco:report>

 		

-		<loadfile property="testReportHtmlEncoding.content" srcfile="${result.tmp.bundle.testdata.dir}/index.html" encoding="UTF-16"/>

+		<loadfile property="testReportHtmlEncoding.content" srcfile="${temp.dir}/index.html" encoding="UTF-16"/>

 		<au:assertTrue message="Encoding not set in ${testReportHtmlEncoding.content}">

 			<contains string="${testReportHtmlEncoding.content}" substring="encoding=&quot;UTF-16&quot;"/>

 		</au:assertTrue>

@@ -159,13 +157,13 @@
 		<jacoco:report>

 			<structure name="Test">

 				<classfiles>

-					<fileset dir="${result.tmp.bundle.classes.dir}" includes="**/*.class"/>

+					<fileset dir="${org.jacoco.ant.reportTaskTest.classes.dir}" includes="**/*.class"/>

 				</classfiles>

 			</structure>

-			<html destfile="${result.tmp.bundle.testdata.dir}/report.zip"/>

+			<html destfile="${temp.dir}/report.zip"/>

 		</jacoco:report>

 		

-		<au:assertFileExists file="${result.tmp.bundle.testdata.dir}/report.zip"/>

+		<au:assertFileExists file="${temp.dir}/report.zip"/>

 	</target>

 	

 	

@@ -181,7 +179,7 @@
 	</target>

 	

 	<target name="testReportCsvEncoding">

-		<property name="testReportCsvEncoding.destfile" location="${result.tmp.bundle.testdata.dir}/report.csv"/>

+		<property name="testReportCsvEncoding.destfile" location="${temp.dir}/report.csv"/>

 		<jacoco:report>

 			<structure name="Test"/>

 			<csv encoding="UTF-16" destfile="${testReportCsvEncoding.destfile}"/>

@@ -207,7 +205,7 @@
 	</target>

 

 	<target name="testReportXmlEncoding">

-		<property name="testReportXmlEncoding.destfile" location="${result.tmp.bundle.testdata.dir}/report.xml"/>

+		<property name="testReportXmlEncoding.destfile" location="${temp.dir}/report.xml"/>

 		<jacoco:report>

 			<structure name="Test"/>

 			<xml encoding="UTF-16" destfile="${testReportXmlEncoding.destfile}"/>

diff --git a/org.jacoco.ant.test/ant/test/executionData/sample1.exec b/org.jacoco.ant.test/src/org/jacoco/ant/data/sample1.exec
similarity index 100%
rename from org.jacoco.ant.test/ant/test/executionData/sample1.exec
rename to org.jacoco.ant.test/src/org/jacoco/ant/data/sample1.exec
Binary files differ
diff --git a/org.jacoco.ant.test/ant/test/executionData/sample2.exec b/org.jacoco.ant.test/src/org/jacoco/ant/data/sample2.exec
similarity index 100%
rename from org.jacoco.ant.test/ant/test/executionData/sample2.exec
rename to org.jacoco.ant.test/src/org/jacoco/ant/data/sample2.exec
Binary files differ
diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/test/EmptyMain.java b/org.jacoco.ant.test/src/org/jacoco/ant/targets/EmptyMain.java
similarity index 88%
rename from org.jacoco.ant.test/src/org/jacoco/ant/test/EmptyMain.java
rename to org.jacoco.ant.test/src/org/jacoco/ant/targets/EmptyMain.java
index a522d9f..cd1fca4 100644
--- a/org.jacoco.ant.test/src/org/jacoco/ant/test/EmptyMain.java
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/targets/EmptyMain.java
@@ -10,15 +10,17 @@
  *    

  * $Id: $

  *******************************************************************************/

-package org.jacoco.ant.test;

+package org.jacoco.ant.targets;

 

 /**

- * Simple test application that performs no processing

+ * Simple test application that performs no processing.

  * 

  * @author Brock Janiczak

  * @version $Revision: $

  */

 public class EmptyMain {

+

 	public static void main(String[] args) {

 	}

+

 }

diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/test/EmptyMain.java b/org.jacoco.ant.test/src/org/jacoco/ant/targets/EmptyTestTarget.java
similarity index 78%
copy from org.jacoco.ant.test/src/org/jacoco/ant/test/EmptyMain.java
copy to org.jacoco.ant.test/src/org/jacoco/ant/targets/EmptyTestTarget.java
index a522d9f..a04fa25 100644
--- a/org.jacoco.ant.test/src/org/jacoco/ant/test/EmptyMain.java
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/targets/EmptyTestTarget.java
@@ -10,15 +10,19 @@
  *    

  * $Id: $

  *******************************************************************************/

-package org.jacoco.ant.test;

+package org.jacoco.ant.targets;

+

+import org.junit.Test;

 

 /**

- * Simple test application that performs no processing

+ * Simple test target that performs no processing.

  * 

  * @author Brock Janiczak

  * @version $Revision: $

  */

-public class EmptyMain {

-	public static void main(String[] args) {

+public class EmptyTestTarget {

+

+	@Test

+	public void testNothing() {

 	}

 }

diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/test/EmptyTest.java b/org.jacoco.ant.test/src/org/jacoco/ant/test/EmptyTest.java
deleted file mode 100644
index 72e15e8..0000000
--- a/org.jacoco.ant.test/src/org/jacoco/ant/test/EmptyTest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************

- * Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * which accompanies this distribution, and is available at

- * http://www.eclipse.org/legal/epl-v10.html

- *

- * Contributors:

- *    Brock Janiczak - initial API and implementation

- *    

- * $Id: $

- *******************************************************************************/

-package org.jacoco.ant.test;

-

-import org.junit.Test;

-

-public class EmptyTest {

-

-	@Test

-	public void testNothing() {

-	}

-}