From 55eb875f2459870f5a20a2ca16ffa56129b872cb Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Sun, 10 Nov 2013 14:08:17 +0100 Subject: Tests for dump goal. --- jacoco-maven-plugin.test/it/it-dump/pom.xml | 66 +++++++++++--------- .../it/it-dump/src/main/java/Example.java | 25 -------- .../it/it-dump/src/main/java/Launch.java | 70 ---------------------- .../it/it-dump/src/main/java/Server.java | 36 +++++++++++ 4 files changed, 75 insertions(+), 122 deletions(-) delete mode 100644 jacoco-maven-plugin.test/it/it-dump/src/main/java/Example.java delete mode 100644 jacoco-maven-plugin.test/it/it-dump/src/main/java/Launch.java create mode 100644 jacoco-maven-plugin.test/it/it-dump/src/main/java/Server.java (limited to 'jacoco-maven-plugin.test/it') 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 @@ prepare-agent prepare-agent - dump tcpserver + + dump + integration-test + + dump + + check - post-integration-test check @@ -48,17 +53,11 @@ BUNDLE - - INSTRUCTION - COVEREDRATIO - 0.1 - CLASS - MISSEDCOUNT - 2 - 2 - + COVEREDCOUNT + 1 + @@ -67,27 +66,40 @@ - org.codehaus.mojo - exec-maven-plugin - 1.2.1 + org.apache.maven.plugins + maven-antrun-plugin + 1.6 - test + launch-server + pre-integration-test - exec + run - + + + + + + + + + + + + stop-server + post-integration-test + + run + + + + + + + - - java - - -classpath - - Launch - ${argLine} - - - + 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"); + } + +} -- cgit v1.2.3