aboutsummaryrefslogtreecommitdiffstats
path: root/jacoco-maven-plugin.test/it
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2013-11-10 14:08:17 +0100
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2013-11-10 14:08:17 +0100
commit55eb875f2459870f5a20a2ca16ffa56129b872cb (patch)
tree1a8bd1ec09dab9218c3ba723b15ebae9b886768e /jacoco-maven-plugin.test/it
parenta3a1f5a94a71f26473586f14f3fb2afaca61de72 (diff)
downloadplatform_external_jacoco-55eb875f2459870f5a20a2ca16ffa56129b872cb.tar.gz
platform_external_jacoco-55eb875f2459870f5a20a2ca16ffa56129b872cb.tar.bz2
platform_external_jacoco-55eb875f2459870f5a20a2ca16ffa56129b872cb.zip
Tests for dump goal.
Diffstat (limited to 'jacoco-maven-plugin.test/it')
-rw-r--r--jacoco-maven-plugin.test/it/it-dump/pom.xml66
-rw-r--r--jacoco-maven-plugin.test/it/it-dump/src/main/java/Example.java25
-rw-r--r--jacoco-maven-plugin.test/it/it-dump/src/main/java/Launch.java70
-rw-r--r--jacoco-maven-plugin.test/it/it-dump/src/main/java/Server.java36
4 files changed, 75 insertions, 122 deletions
diff --git a/jacoco-maven-plugin.test/it/it-dump/pom.xml b/jacoco-maven-plugin.test/it/it-dump/pom.xml
index ccbbb42c..628b4a31 100644
--- a/jacoco-maven-plugin.test/it/it-dump/pom.xml
+++ b/jacoco-maven-plugin.test/it/it-dump/pom.xml
@@ -31,15 +31,20 @@
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
- <goal>dump</goal>
</goals>
<configuration>
<output>tcpserver</output>
</configuration>
</execution>
<execution>
+ <id>dump</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>dump</goal>
+ </goals>
+ </execution>
+ <execution>
<id>check</id>
- <phase>post-integration-test</phase>
<goals>
<goal>check</goal>
</goals>
@@ -49,16 +54,10 @@
<element>BUNDLE</element>
<limits>
<limit>
- <counter>INSTRUCTION</counter>
- <value>COVEREDRATIO</value>
- <maximum>0.1</maximum>
- </limit>
- <limit>
<counter>CLASS</counter>
- <value>MISSEDCOUNT</value>
- <maximum>2</maximum>
- <minimum>2</minimum>
- </limit>
+ <value>COVEREDCOUNT</value>
+ <minimum>1</minimum>
+ </limit>
</limits>
</rule>
</rules>
@@ -67,27 +66,40 @@
</executions>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2.1</version>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.6</version>
<executions>
<execution>
- <phase>test</phase>
+ <id>launch-server</id>
+ <phase>pre-integration-test</phase>
<goals>
- <goal>exec</goal>
+ <goal>run</goal>
</goals>
- </execution>
+ <configuration>
+ <target>
+ <java classname="Server" spawn="true" fork="true">
+ <classpath refid="maven.runtime.classpath"/>
+ <jvmarg value="${argLine}"/>
+ <arg value="${project.build.directory}/term.txt"/>
+ </java>
+ </target>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-server</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+ <touch file="${project.build.directory}/term.txt" />
+ </target>
+ </configuration>
+ </execution>
</executions>
- <configuration>
- <executable>java</executable>
- <arguments>
- <argument>-classpath</argument>
- <classpath/>
- <argument>Launch</argument>
- <argument>${argLine}</argument>
- </arguments>
- </configuration>
- </plugin>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/jacoco-maven-plugin.test/it/it-dump/src/main/java/Example.java b/jacoco-maven-plugin.test/it/it-dump/src/main/java/Example.java
deleted file mode 100644
index 4173b972..00000000
--- a/jacoco-maven-plugin.test/it/it-dump/src/main/java/Example.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * 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:
- * Chas Honton - initial implementation
- *
- *******************************************************************************/
-public class Example {
-
- private static final long TEN_MINUTES = 10 * 1000 * 60;
-
- public static void main(final String[] args) {
- System.out.println(System.currentTimeMillis()+": Hello ...");
- try {
- Thread.sleep(TEN_MINUTES);
- } catch (final InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println(System.currentTimeMillis()+": ... world");
- }
-}
diff --git a/jacoco-maven-plugin.test/it/it-dump/src/main/java/Launch.java b/jacoco-maven-plugin.test/it/it-dump/src/main/java/Launch.java
deleted file mode 100644
index cd561f3b..00000000
--- a/jacoco-maven-plugin.test/it/it-dump/src/main/java/Launch.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * 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:
- * Chas Honton - initial implementation
- *
- *******************************************************************************/
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-/**
- * Class to launch a java process
- */
-public class Launch {
-
- /**
- * Launch Example in another process. Do not wait for Process to exit
- *
- * @param arguments
- * A single argument - the vm javaagent argument
- * @throws Exception
- */
- public static void main(final String[] arguments) throws Exception {
- final File javaHome = new File(System.getProperty("java.home"));
- final File javaBin = new File(new File(javaHome, "bin"), "java");
-
- final String javaPath = javaBin.getCanonicalPath();
- final String javaAgent = arguments[0];
- final String classpath = System.getProperty("java.class.path");
-
- System.err.println("launching: " + javaPath + ' ' + javaAgent + ' '
- + "-cp" + ' ' + classpath + ' ' + "Example");
- final ProcessBuilder builder = new ProcessBuilder(javaPath, javaAgent,
- "-cp", classpath, "Example");
-
- builder.redirectErrorStream(true);
- final Process process = builder.start();
- process.getOutputStream().close();
- final InputStream is = process.getInputStream();
- final Thread streamPump = new Thread() {
- @Override
- public void run() {
- copy(is, System.out);
- }
- };
- streamPump.setDaemon(true);
- streamPump.start();
- }
-
- private static void copy(final InputStream is, final PrintStream out) {
- try {
- for (;;) {
- final int c = is.read();
- if (c < 0) {
- break;
- }
- out.append((char) c);
- }
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/jacoco-maven-plugin.test/it/it-dump/src/main/java/Server.java b/jacoco-maven-plugin.test/it/it-dump/src/main/java/Server.java
new file mode 100644
index 00000000..307fb1e0
--- /dev/null
+++ b/jacoco-maven-plugin.test/it/it-dump/src/main/java/Server.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+
+import java.io.File;
+
+/**
+ * Simple server which runs as long a termination file is created.
+ */
+public class Server {
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Test server started");
+
+ // Wait for termination file to turn up
+ // This option puts the target in a pseudo 'server' mode
+ if (args.length == 1) {
+ final File termFile = new File(args[0]);
+
+ while (!termFile.exists()) {
+ Thread.sleep(100);
+ }
+ }
+
+ System.out.println("Test server stopped");
+ }
+
+}