aboutsummaryrefslogtreecommitdiff
path: root/jacoco-maven-plugin.test
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2013-01-04 17:28:27 +0100
committerEvgeny Mandrikov <mandrikov@gmail.com>2013-01-04 17:32:35 +0100
commit81c46ae849df51f3d581897582605d2198503767 (patch)
tree00d18e96d036438cb75388a4181d5dfbd1943d42 /jacoco-maven-plugin.test
parent37115f4ba4f6126b8c3352ac890c653e428a7dd8 (diff)
downloadjacoco-81c46ae849df51f3d581897582605d2198503767.tar.gz
Add Maven Mojo to perform offline instrumentation
Diffstat (limited to 'jacoco-maven-plugin.test')
-rw-r--r--jacoco-maven-plugin.test/it/it-offline-instrumentation/pom.xml80
-rw-r--r--jacoco-maven-plugin.test/it/it-offline-instrumentation/src/main/java/DoNotInstrument.java18
-rw-r--r--jacoco-maven-plugin.test/it/it-offline-instrumentation/src/main/java/Example.java18
-rw-r--r--jacoco-maven-plugin.test/it/it-offline-instrumentation/src/test/java/ExampleTest.java21
-rw-r--r--jacoco-maven-plugin.test/it/it-offline-instrumentation/verify.bsh22
5 files changed, 159 insertions, 0 deletions
diff --git a/jacoco-maven-plugin.test/it/it-offline-instrumentation/pom.xml b/jacoco-maven-plugin.test/it/it-offline-instrumentation/pom.xml
new file mode 100644
index 00000000..31005ceb
--- /dev/null
+++ b/jacoco-maven-plugin.test/it/it-offline-instrumentation/pom.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2009, 2013 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:
+ Evgeny Mandrikov - initial API and implementation
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>jacoco</groupId>
+ <artifactId>setup-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>it-offline-instrumentation</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>org.jacoco.agent</artifactId>
+ <classifier>runtime</classifier>
+ <version>@project.version@</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>instrument-classes</id>
+ <goals>
+ <goal>instrument</goal>
+ </goals>
+ <configuration>
+ <excludes>
+ <exclude>**/DoNotInstrument.class</exclude>
+ </excludes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>restore-instrumented-classes</id>
+ <goals>
+ <goal>restore</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>report</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <dataFile>${project.build.directory}/coverage.exec</dataFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <jacoco-agent.destfile>${project.build.directory}/coverage.exec</jacoco-agent.destfile>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/jacoco-maven-plugin.test/it/it-offline-instrumentation/src/main/java/DoNotInstrument.java b/jacoco-maven-plugin.test/it/it-offline-instrumentation/src/main/java/DoNotInstrument.java
new file mode 100644
index 00000000..d51ac9eb
--- /dev/null
+++ b/jacoco-maven-plugin.test/it/it-offline-instrumentation/src/main/java/DoNotInstrument.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 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:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+public class DoNotInstrument {
+
+ public void sayHello() {
+ System.out.println("Hello world");
+ }
+
+}
diff --git a/jacoco-maven-plugin.test/it/it-offline-instrumentation/src/main/java/Example.java b/jacoco-maven-plugin.test/it/it-offline-instrumentation/src/main/java/Example.java
new file mode 100644
index 00000000..630a62f2
--- /dev/null
+++ b/jacoco-maven-plugin.test/it/it-offline-instrumentation/src/main/java/Example.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 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:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+public class Example {
+
+ public void sayHello() {
+ System.out.println("Hello world");
+ }
+
+}
diff --git a/jacoco-maven-plugin.test/it/it-offline-instrumentation/src/test/java/ExampleTest.java b/jacoco-maven-plugin.test/it/it-offline-instrumentation/src/test/java/ExampleTest.java
new file mode 100644
index 00000000..d9b78ab9
--- /dev/null
+++ b/jacoco-maven-plugin.test/it/it-offline-instrumentation/src/test/java/ExampleTest.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 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:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+import org.junit.Test;
+
+public class ExampleTest {
+
+ @Test
+ public void test() {
+ new Example().sayHello();
+ }
+
+}
diff --git a/jacoco-maven-plugin.test/it/it-offline-instrumentation/verify.bsh b/jacoco-maven-plugin.test/it/it-offline-instrumentation/verify.bsh
new file mode 100644
index 00000000..d38fcca6
--- /dev/null
+++ b/jacoco-maven-plugin.test/it/it-offline-instrumentation/verify.bsh
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 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:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+
+File file = new File( basedir, "target/generated-classes/jacoco/Example.class" );
+if ( !file.isFile() ) {
+ throw new RuntimeException( "Could not find backup of instrumented class: " + file );
+}
+
+file = new File( basedir, "target/coverage.exec" );
+if ( !file.isFile() )
+{
+ throw new FileNotFoundException( "Could not find generated dump: " + file );
+}