You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2019/12/27 03:35:26 UTC
[maven-surefire] branch cli updated (6f4ee88 -> a677f0b)
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a change to branch cli
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.
discard 6f4ee88 added unit tests
discard 84027d9 process should be closed at the end
discard dbb4be7 CountdownCloaseable
discard 6bd85e5 close must be called in shutdown hook
discard d5b75e9 uncommented required block in CountdownCloseable
discard 05a0150 close must be called in shutdown hook
discard a2a8774 try to close std/in in self thread
discard 93618c1 [SUREFIRE-1740] Prerequisite implementation for SUREFIRE-1658
new a677f0b [SUREFIRE-1740] Prerequisite implementation for SUREFIRE-1658
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (6f4ee88)
\
N -- N -- N refs/heads/cli (a677f0b)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
[maven-surefire] 01/01: [SUREFIRE-1740] Prerequisite implementation
for SUREFIRE-1658
Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch cli
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit a677f0bda001ae705d42f7c2e72ce148f371b6f4
Author: tibordigana <ti...@apache.org>
AuthorDate: Thu Nov 21 02:07:16 2019 +0100
[SUREFIRE-1740] Prerequisite implementation for SUREFIRE-1658
---
maven-failsafe-plugin/pom.xml | 48 +---
.../apache/maven/plugin/failsafe/VerifyMojo.java | 2 +-
.../failsafe/util/FailsafeSummaryXmlUtils.java | 6 +-
maven-surefire-common/pom.xml | 40 +--
.../plugin/surefire/AbstractSurefireMojo.java | 16 +-
.../surefire/StartupReportConfiguration.java | 2 +-
.../maven/plugin/surefire/SurefireHelper.java | 2 +-
.../maven/plugin/surefire/TestClassPath.java | 2 +-
.../booterclient/ClasspathForkConfiguration.java | 2 +-
.../plugin/surefire/booterclient/ForkStarter.java | 98 +++++---
.../booterclient/JarManifestForkConfiguration.java | 6 +-
.../ModularClasspathForkConfiguration.java | 2 +-
.../OutputStreamFlushableCommandline.java | 6 +-
.../surefire/booterclient/output/ForkClient.java | 2 +-
.../output/NativeStdErrStreamConsumer.java | 2 +-
.../output/ThreadedStreamConsumer.java | 11 +-
.../plugin/surefire/report/ConsoleReporter.java | 4 +-
.../surefire/report/DefaultReporterFactory.java | 4 +-
.../plugin/surefire/report/FileReporterUtils.java | 2 +-
.../surefire/report/StatelessXmlReporter.java | 4 +-
.../maven/plugin/surefire/report/TestSetStats.java | 4 +-
.../Utf8RecodingDeferredFileOutputStream.java | 2 +-
.../maven/plugin/surefire/util/ScannerUtil.java | 2 +-
.../plugin/surefire/util/SpecificFileFilter.java | 2 +-
.../plugin/surefire/AbstractSurefireMojoTest.java | 2 +-
.../maven/plugin/surefire/SurefireHelperTest.java | 2 +-
...ooterDeserializerProviderConfigurationTest.java | 2 +-
...BooterDeserializerStartupConfigurationTest.java | 2 +-
.../booterclient/ForkConfigurationTest.java | 8 +-
.../surefire/booterclient/ForkStarterTest.java | 272 +++++++++++++++++++++
.../plugin/surefire/booterclient/MainClass.java} | 46 ++--
.../ModularClasspathForkConfigurationTest.java | 2 +-
.../OutputStreamFlushableCommandlineTest.java | 4 +-
.../report/DefaultReporterFactoryTest.java | 4 +-
.../surefire/report/StatelessXmlReporterTest.java | 6 +-
.../plugin/surefire/report/TestSetStatsTest.java | 2 +-
.../runorder/RunEntryStatisticsMapTest.java | 2 +-
.../org/apache/maven/surefire/JUnit4SuiteTest.java | 2 +
.../StatelessTestsetInfoReporterTest.java | 2 +-
.../report/ConsoleOutputFileReporterTest.java | 2 +-
surefire-api/pom.xml | 39 +--
.../maven/surefire/SpecificTestClassFilter.java | 2 +-
.../surefire/booter/ForkedChannelEncoder.java | 2 +-
.../maven/surefire/cli/CommandLineOption.java | 10 -
.../maven/surefire/testset/ResolvedTest.java | 14 +-
.../maven/surefire/testset/TestListResolver.java | 10 +-
.../surefire/util/DefaultDirectoryScanner.java | 4 +-
.../surefire/booter/ForkedChannelEncoderTest.java | 2 +-
.../surefire/booter/NewClassLoaderRunner.java | 2 +-
surefire-booter/pom.xml | 54 ----
.../apache/maven/surefire/booter/PpidChecker.java | 12 +-
.../apache/maven/surefire/booter/SystemUtils.java | 12 +-
.../maven/surefire/booter/ForkedBooterTest.java | 4 +-
.../maven/surefire/booter/PpidCheckerTest.java | 4 +-
.../maven/surefire/booter/SystemUtilsTest.java | 12 +-
surefire-extensions-api/pom.xml | 18 ++
.../extensions/util/CommandlineExecutor.java | 128 ++++++++++
.../extensions/util/CommandlineStreams.java | 82 +++++++
.../extensions/util/CountdownCloseable.java | 70 ++++++
.../util/FlushableWritableByteChannel.java | 68 ++++++
.../extensions/util/LineConsumerThread.java | 101 ++++++++
.../surefire/extensions/util/StreamFeeder.java | 89 +++++++
.../extensions/util/CommandlineExecutorTest.java | 109 +++++++++
.../surefire/extensions/util/JUnit4SuiteTest.java | 34 +--
...fire735ForkFailWithRedirectConsoleOutputIT.java | 5 +-
surefire-providers/common-java5/pom.xml | 30 +--
.../surefire/report/SmartStackTraceParser.java | 6 +-
surefire-report-parser/pom.xml | 30 +--
.../plugins/surefire/report/ReportTestCase.java | 2 +-
.../surefire/report/SurefireReportParser.java | 4 +-
.../surefire/report/TestSuiteXmlParser.java | 2 +-
71 files changed, 1167 insertions(+), 425 deletions(-)
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index ab583ff..915d47e 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -70,16 +70,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-shared-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-shared-utils</artifactId>
+ <version>3.0.0-M4</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
@@ -216,41 +209,6 @@
<siteDirectory>${project.build.directory}/source-site</siteDirectory>
</configuration>
</plugin>
- <plugin>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <minimizeJar>true</minimizeJar>
- <artifactSet>
- <includes>
- <include>org.apache.maven.shared:maven-shared-utils</include>
- <include>commons-io:commons-io</include>
- <include>org.apache.commons:commons-lang3</include>
- </includes>
- </artifactSet>
- <relocations>
- <relocation>
- <pattern>org.apache.maven.shared.utils</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.failsafe.org.apache.maven.shared.utils</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.commons.io</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.failsafe.org.apache.commons.io</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.commons.lang3</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.failsafe.org.apache.commons.lang3</shadedPattern>
- </relocation>
- </relocations>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
index dbb6b7e..2fa31e1 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
@@ -39,7 +39,7 @@ import java.io.File;
import java.util.Collection;
import static org.apache.maven.plugin.surefire.SurefireHelper.reportExecution;
-import static org.apache.maven.shared.utils.StringUtils.capitalizeFirstLetter;
+import static org.apache.maven.surefire.shared.utils.StringUtils.capitalizeFirstLetter;
import static org.apache.maven.surefire.suite.RunResult.noTestsRun;
/**
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java
index 6035308..f7c9cef 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugin.failsafe.util;
* under the License.
*/
-import org.apache.commons.io.IOUtils;
+import org.apache.maven.surefire.shared.io.IOUtils;
import org.apache.maven.surefire.suite.RunResult;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
@@ -37,8 +37,8 @@ import static java.lang.Boolean.parseBoolean;
import static java.lang.Integer.parseInt;
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.commons.lang3.StringEscapeUtils.escapeXml10;
-import static org.apache.commons.lang3.StringEscapeUtils.unescapeXml;
+import static org.apache.maven.surefire.shared.lang3.StringEscapeUtils.escapeXml10;
+import static org.apache.maven.surefire.shared.lang3.StringEscapeUtils.unescapeXml;
import static org.apache.maven.surefire.util.internal.StringUtils.isBlank;
/**
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index 10c1982..fefe831 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -80,20 +80,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-shared-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-compress</artifactId>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-shared-utils</artifactId>
+ <version>3.0.0-M4</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
@@ -187,7 +176,6 @@
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
- <phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
@@ -195,31 +183,9 @@
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
- <include>org.apache.maven.shared:maven-shared-utils</include>
<include>org.apache.maven.shared:maven-common-artifact-filters</include>
- <include>commons-io:commons-io</include>
- <include>org.apache.commons:commons-lang3</include>
- <include>org.apache.commons:commons-compress</include>
</includes>
</artifactSet>
- <relocations>
- <relocation>
- <pattern>org.apache.maven.shared.utils</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.common.org.apache.maven.shared.utils</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.commons.io</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.common.org.apache.commons.io</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.commons.lang3</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.common.org.apache.commons.lang3</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.commons.compress</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.common.org.apache.commons.compress</shadedPattern>
- </relocation>
- </relocations>
</configuration>
</execution>
</executions>
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 75f6241..7604c03 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -58,7 +58,7 @@ import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter;
import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
-import org.apache.maven.shared.utils.io.FileUtils;
+import org.apache.maven.surefire.shared.utils.io.FileUtils;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
import org.apache.maven.surefire.booter.Classpath;
import org.apache.maven.surefire.booter.ClasspathConfiguration;
@@ -120,17 +120,17 @@ import static java.util.Arrays.asList;
import static java.util.Collections.addAll;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
-import static org.apache.commons.lang3.StringUtils.substringBeforeLast;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import static org.apache.maven.surefire.shared.lang3.StringUtils.substringBeforeLast;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.apache.maven.artifact.ArtifactUtils.artifactMapByVersionlessId;
import static org.apache.maven.plugin.surefire.SurefireDependencyResolver.isWithinVersionSpec;
import static org.apache.maven.plugin.surefire.util.DependencyScanner.filter;
import static org.apache.maven.plugin.surefire.SurefireHelper.replaceThreadNumberPlaceholders;
-import static org.apache.maven.shared.utils.StringUtils.capitalizeFirstLetter;
-import static org.apache.maven.shared.utils.StringUtils.isEmpty;
-import static org.apache.maven.shared.utils.StringUtils.isNotBlank;
-import static org.apache.maven.shared.utils.StringUtils.isNotEmpty;
-import static org.apache.maven.shared.utils.StringUtils.split;
+import static org.apache.maven.surefire.shared.utils.StringUtils.capitalizeFirstLetter;
+import static org.apache.maven.surefire.shared.utils.StringUtils.isEmpty;
+import static org.apache.maven.surefire.shared.utils.StringUtils.isNotBlank;
+import static org.apache.maven.surefire.shared.utils.StringUtils.isNotEmpty;
+import static org.apache.maven.surefire.shared.utils.StringUtils.split;
import static org.apache.maven.surefire.booter.SystemUtils.JAVA_SPECIFICATION_VERSION;
import static org.apache.maven.surefire.booter.SystemUtils.endsWithJavaPath;
import static org.apache.maven.surefire.booter.SystemUtils.isBuiltInJava9AtLeast;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
index 02ec44b..a15f802 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
@@ -41,7 +41,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.commons.lang3.StringUtils.trimToNull;
+import static org.apache.maven.surefire.shared.lang3.StringUtils.trimToNull;
import static org.apache.maven.plugin.surefire.SurefireHelper.replaceForkThreadsInPath;
import static org.apache.maven.plugin.surefire.report.ConsoleReporter.BRIEF;
import static org.apache.maven.plugin.surefire.report.ConsoleReporter.PLAIN;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
index 9f6e2d7..bb40574 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
@@ -38,7 +38,7 @@ import java.util.LinkedList;
import java.util.List;
import static java.util.Collections.unmodifiableList;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.apache.maven.surefire.booter.DumpErrorSingleton.DUMPSTREAM_FILE_EXT;
import static org.apache.maven.surefire.booter.DumpErrorSingleton.DUMP_FILE_EXT;
import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
index 3a37816..ba73361 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
@@ -29,7 +29,7 @@ import java.util.List;
import java.util.Map;
import static java.util.Collections.addAll;
-import static org.apache.maven.shared.utils.StringUtils.split;
+import static org.apache.maven.surefire.shared.utils.StringUtils.split;
final class TestClassPath
{
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ClasspathForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ClasspathForkConfiguration.java
index 72aab98..1ca3932 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ClasspathForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ClasspathForkConfiguration.java
@@ -31,7 +31,7 @@ import java.io.File;
import java.util.Map;
import java.util.Properties;
-import static org.apache.maven.shared.utils.StringUtils.join;
+import static org.apache.maven.surefire.shared.utils.StringUtils.join;
/**
* @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
index 2570977..f2734ee 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
@@ -33,10 +33,13 @@ import org.apache.maven.plugin.surefire.booterclient.output.NativeStdErrStreamCo
import org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
-import org.apache.maven.shared.utils.cli.CommandLineCallable;
-import org.apache.maven.shared.utils.cli.CommandLineException;
+import org.apache.maven.surefire.extensions.util.CommandlineExecutor;
+import org.apache.maven.surefire.extensions.util.CommandlineStreams;
+import org.apache.maven.surefire.extensions.util.CountdownCloseable;
+import org.apache.maven.surefire.extensions.util.LineConsumerThread;
+import org.apache.maven.surefire.extensions.util.StreamFeeder;
+import org.apache.maven.surefire.shared.utils.cli.CommandLineException;
import org.apache.maven.surefire.booter.AbstractPathConfiguration;
-import org.apache.maven.surefire.booter.KeyValueSource;
import org.apache.maven.surefire.booter.PropertiesWrapper;
import org.apache.maven.surefire.booter.ProviderConfiguration;
import org.apache.maven.surefire.booter.ProviderFactory;
@@ -75,7 +78,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import static java.lang.StrictMath.min;
import static java.lang.System.currentTimeMillis;
import static java.lang.Thread.currentThread;
-import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.util.Collections.addAll;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.Executors.newScheduledThreadPool;
@@ -88,9 +90,8 @@ import static org.apache.maven.plugin.surefire.booterclient.ForkNumberBucket.dra
import static org.apache.maven.plugin.surefire.booterclient.ForkNumberBucket.returnNumber;
import static org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream
.TestLessInputStreamBuilder;
-import static org.apache.maven.shared.utils.cli.CommandLineUtils.executeCommandLineAsCallable;
-import static org.apache.maven.shared.utils.cli.ShutdownHookUtils.addShutDownHook;
-import static org.apache.maven.shared.utils.cli.ShutdownHookUtils.removeShutdownHook;
+import static org.apache.maven.surefire.shared.utils.cli.ShutdownHookUtils.addShutDownHook;
+import static org.apache.maven.surefire.shared.utils.cli.ShutdownHookUtils.removeShutdownHook;
import static org.apache.maven.surefire.booter.SystemPropertyManager.writePropertiesFile;
import static org.apache.maven.surefire.cli.CommandLineOption.SHOW_ERRORS;
import static org.apache.maven.surefire.suite.RunResult.SUCCESS;
@@ -212,11 +213,17 @@ public class ForkStarter
public void close()
{
run();
+ testProvidingInputStream.clear();
if ( inputStreamCloserHook != null )
{
removeShutdownHook( inputStreamCloserHook );
}
}
+
+ void addCloseable( Closeable closeable )
+ {
+ testProvidingInputStream.add( closeable );
+ }
}
public ForkStarter( ProviderConfiguration providerConfiguration, StartupConfiguration startupConfiguration,
@@ -540,9 +547,9 @@ public class ForkStarter
}
}
- private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkClient forkClient,
+ private RunResult fork( Object testSet, PropertiesWrapper providerProperties, ForkClient forkClient,
SurefireProperties effectiveSystemProperties, int forkNumber,
- AbstractForkInputStream testProvidingInputStream, boolean readTestsFromInStream )
+ AbstractForkInputStream commandInputStream, boolean readTestsFromInStream )
throws SurefireBooterForkException
{
final String tempDir;
@@ -581,9 +588,9 @@ public class ForkStarter
OutputStreamFlushableCommandline cli =
forkConfiguration.createCommandLine( startupConfiguration, forkNumber, dumpLogDir );
- if ( testProvidingInputStream != null )
+ if ( commandInputStream != null )
{
- testProvidingInputStream.setFlushReceiverProvider( cli );
+ commandInputStream.setFlushReceiverProvider( cli );
}
cli.createArg().setValue( tempDir );
@@ -594,41 +601,60 @@ public class ForkStarter
cli.createArg().setValue( systPropsFile.getName() );
}
- final ThreadedStreamConsumer threadedStreamConsumer = new ThreadedStreamConsumer( forkClient );
- final CloseableCloser closer = new CloseableCloser( forkNumber, threadedStreamConsumer,
- requireNonNull( testProvidingInputStream, "null param" ) );
+ ThreadedStreamConsumer eventConsumer = new ThreadedStreamConsumer( forkClient );
+ CloseableCloser closer = new CloseableCloser( forkNumber, eventConsumer, requireNonNull( commandInputStream ) );
log.debug( "Forking command line: " + cli );
Integer result = null;
RunResult runResult = null;
SurefireBooterForkException booterForkException = null;
- try
- {
- NativeStdErrStreamConsumer stdErrConsumer =
- new NativeStdErrStreamConsumer( forkClient.getDefaultReporterFactory() );
-
- CommandLineCallable future =
- executeCommandLineAsCallable( cli, testProvidingInputStream, threadedStreamConsumer,
- stdErrConsumer, 0, closer, ISO_8859_1 );
-
- currentForkClients.add( forkClient );
-
- result = future.call();
+ StreamFeeder in = null;
+ LineConsumerThread out = null;
+ LineConsumerThread err = null;
+ DefaultReporterFactory reporter = forkClient.getDefaultReporterFactory();
+ currentForkClients.add( forkClient );
+ CountdownCloseable countdownCloseable = new CountdownCloseable( eventConsumer, 2 );
+ try ( CommandlineExecutor exec = new CommandlineExecutor( cli, countdownCloseable ) )
+ {
+ // default impl of the extension - solves everything including the encoder/decoder, Process starter,
+ // adaptation of the streams to pipes and sockets
+ // non-default impl may use another classes and not the LineConsumerThread, StreamFeeder - freedom
+ // BEGIN: beginning of the call of the extension
+ CommandlineStreams streams = exec.execute();
+ closer.addCloseable( streams );
+ in = new StreamFeeder( "std-in-fork-" + forkNumber, streams.getStdInChannel(), commandInputStream );
+ in.start();
+ out = new LineConsumerThread( "std-out-fork-" + forkNumber, streams.getStdOutChannel(),
+ eventConsumer, countdownCloseable );
+ out.start();
+ NativeStdErrStreamConsumer stdErrConsumer = new NativeStdErrStreamConsumer( reporter );
+ err = new LineConsumerThread( "std-err-fork-" + forkNumber, streams.getStdErrChannel(),
+ stdErrConsumer, countdownCloseable );
+ err.start();
+ result = exec.awaitExit();
+ // END: end of the call of the extension
if ( forkClient.hadTimeout() )
{
- runResult = timeout( forkClient.getDefaultReporterFactory().getGlobalRunStatistics().getRunResult() );
+ runResult = timeout( reporter.getGlobalRunStatistics().getRunResult() );
}
- else if ( result == null || result != SUCCESS )
+ else if ( result != SUCCESS )
{
booterForkException =
new SurefireBooterForkException( "Error occurred in starting fork, check output in log" );
}
}
+ catch ( InterruptedException e )
+ {
+ // maybe implement it in the Future.cancel() of the extension or similar
+ in.disable();
+ out.disable();
+ err.disable();
+ }
catch ( CommandLineException e )
{
- runResult = failure( forkClient.getDefaultReporterFactory().getGlobalRunStatistics().getRunResult(), e );
+ runResult = failure( reporter.getGlobalRunStatistics().getRunResult(), e );
String cliErr = e.getLocalizedMessage();
Throwable cause = e.getCause();
booterForkException =
@@ -637,10 +663,20 @@ public class ForkStarter
finally
{
currentForkClients.remove( forkClient );
- closer.close();
+ try
+ {
+ Closeable c = forkClient.isSaidGoodBye() ? closer : commandInputStream;
+ c.close();
+ }
+ catch ( IOException e )
+ {
+ InPluginProcessDumpSingleton.getSingleton()
+ .dumpException( e, e.getLocalizedMessage(), dumpLogDir, forkNumber );
+ }
+
if ( runResult == null )
{
- runResult = forkClient.getDefaultReporterFactory().getGlobalRunStatistics().getRunResult();
+ runResult = reporter.getGlobalRunStatistics().getRunResult();
}
forkClient.close( runResult.isTimeout() );
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
index 78e915a..02c275c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
@@ -19,9 +19,9 @@ package org.apache.maven.plugin.surefire.booterclient;
* under the License.
*/
-import org.apache.commons.compress.archivers.zip.Zip64Mode;
-import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
-import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
+import org.apache.maven.surefire.shared.compress.archivers.zip.Zip64Mode;
+import org.apache.maven.surefire.shared.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.maven.surefire.shared.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
import org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
index af38bc5..8f5030b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
@@ -44,7 +44,7 @@ import java.util.Properties;
import static java.io.File.createTempFile;
import static java.io.File.pathSeparatorChar;
import static org.apache.maven.plugin.surefire.SurefireHelper.escapeToPlatformPath;
-import static org.apache.maven.shared.utils.StringUtils.replace;
+import static org.apache.maven.surefire.shared.utils.StringUtils.replace;
import static org.apache.maven.surefire.util.internal.StringUtils.NL;
/**
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
index e22b8df..7f14c54 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandline.java
@@ -24,9 +24,9 @@ import java.util.Collections;
import java.util.Properties;
import java.util.concurrent.ConcurrentLinkedDeque;
-import org.apache.maven.shared.utils.cli.CommandLineException;
-import org.apache.maven.shared.utils.cli.CommandLineUtils;
-import org.apache.maven.shared.utils.cli.Commandline;
+import org.apache.maven.surefire.shared.utils.cli.CommandLineException;
+import org.apache.maven.surefire.shared.utils.cli.CommandLineUtils;
+import org.apache.maven.surefire.shared.utils.cli.Commandline;
/**
* A {@link Commandline} implementation that provides the output stream of
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
index f2a934f..86ad955 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
@@ -22,7 +22,7 @@ package org.apache.maven.plugin.surefire.booterclient.output;
import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.NotifiableTestStream;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
-import org.apache.maven.shared.utils.cli.StreamConsumer;
+import org.apache.maven.surefire.shared.utils.cli.StreamConsumer;
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.RunListener;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NativeStdErrStreamConsumer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NativeStdErrStreamConsumer.java
index ace4f8a..b17bfe4 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NativeStdErrStreamConsumer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NativeStdErrStreamConsumer.java
@@ -20,7 +20,7 @@ package org.apache.maven.plugin.surefire.booterclient.output;
*/
import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
-import org.apache.maven.shared.utils.cli.StreamConsumer;
+import org.apache.maven.surefire.shared.utils.cli.StreamConsumer;
/**
* Used by forked JMV, see {@link org.apache.maven.plugin.surefire.booterclient.ForkStarter}.
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
index 388f16d..853d35c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugin.surefire.booterclient.output;
* under the License.
*/
-import org.apache.maven.shared.utils.cli.StreamConsumer;
+import org.apache.maven.surefire.shared.utils.cli.StreamConsumer;
import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
import java.io.Closeable;
@@ -76,7 +76,7 @@ public final class ThreadedStreamConsumer
@Override
public void run()
{
- while ( !ThreadedStreamConsumer.this.stop.get() )
+ while ( !ThreadedStreamConsumer.this.stop.get() || !ThreadedStreamConsumer.this.items.isEmpty() )
{
try
{
@@ -115,7 +115,11 @@ public final class ThreadedStreamConsumer
@Override
public void consumeLine( String s )
{
- if ( stop.get() && !thread.isAlive() )
+ if ( stop.get() )
+ {
+ return;
+ }
+ else if ( !thread.isAlive() )
{
items.clear();
return;
@@ -138,7 +142,6 @@ public final class ThreadedStreamConsumer
{
if ( stop.compareAndSet( false, true ) )
{
- items.clear();
try
{
items.put( END_ITEM );
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java
index 0bee687..e51c9db 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java
@@ -22,14 +22,14 @@ package org.apache.maven.plugin.surefire.report;
import java.util.List;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
-import org.apache.maven.shared.utils.logging.MessageBuilder;
+import org.apache.maven.surefire.shared.utils.logging.MessageBuilder;
import org.apache.maven.plugin.surefire.log.api.Level;
import org.apache.maven.surefire.extensions.StatelessTestsetInfoConsoleReportEventListener;
import org.apache.maven.surefire.report.TestSetReportEntry;
import static org.apache.maven.plugin.surefire.log.api.Level.resolveLevel;
import static org.apache.maven.plugin.surefire.report.TestSetStats.concatenateWithTestGroup;
-import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
+import static org.apache.maven.surefire.shared.utils.logging.MessageUtils.buffer;
/**
* Base class for console reporters.
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
index ed93a65..7007695 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
@@ -23,7 +23,7 @@ import org.apache.maven.plugin.surefire.StartupReportConfiguration;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.Level;
import org.apache.maven.plugin.surefire.runorder.StatisticsReporter;
-import org.apache.maven.shared.utils.logging.MessageBuilder;
+import org.apache.maven.surefire.shared.utils.logging.MessageBuilder;
import org.apache.maven.surefire.extensions.ConsoleOutputReportEventListener;
import org.apache.maven.surefire.extensions.StatelessReportEventListener;
import org.apache.maven.surefire.extensions.StatelessTestsetInfoConsoleReportEventListener;
@@ -54,7 +54,7 @@ import static org.apache.maven.plugin.surefire.report.DefaultReporterFactory.Tes
import static org.apache.maven.plugin.surefire.report.ReportEntryType.ERROR;
import static org.apache.maven.plugin.surefire.report.ReportEntryType.FAILURE;
import static org.apache.maven.plugin.surefire.report.ReportEntryType.SUCCESS;
-import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
+import static org.apache.maven.surefire.shared.utils.logging.MessageUtils.buffer;
import static org.apache.maven.surefire.util.internal.ObjectUtils.useNonNull;
/**
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java
index fd33d8e..31d1904 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugin.surefire.report;
* under the License.
*/
-import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
/**
* Utils class for file-based reporters
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index fcb066e..d537d2c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -20,8 +20,8 @@ package org.apache.maven.plugin.surefire.report;
*/
import org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
-import org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter;
-import org.apache.maven.shared.utils.xml.XMLWriter;
+import org.apache.maven.surefire.shared.utils.xml.PrettyPrintXMLWriter;
+import org.apache.maven.surefire.shared.utils.xml.XMLWriter;
import org.apache.maven.surefire.extensions.StatelessReportEventListener;
import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.SafeThrowable;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java
index 3e360c1..b34a25f 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugin.surefire.report;
* under the License.
*/
-import org.apache.maven.shared.utils.logging.MessageBuilder;
+import org.apache.maven.surefire.shared.utils.logging.MessageBuilder;
import org.apache.maven.surefire.report.ReportEntry;
import java.util.ArrayList;
@@ -28,7 +28,7 @@ import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
-import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
+import static org.apache.maven.surefire.shared.utils.logging.MessageUtils.buffer;
import static org.apache.maven.surefire.report.CategorizedReportEntry.GROUP_PREFIX;
/**
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/Utf8RecodingDeferredFileOutputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/Utf8RecodingDeferredFileOutputStream.java
index c3eda01..948f131 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/Utf8RecodingDeferredFileOutputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/Utf8RecodingDeferredFileOutputStream.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugin.surefire.report;
* under the License.
*/
-import org.apache.commons.io.output.DeferredFileOutputStream;
+import org.apache.maven.surefire.shared.io.output.DeferredFileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ScannerUtil.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ScannerUtil.java
index 8073907..afd9cf2 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ScannerUtil.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ScannerUtil.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugin.surefire.util;
* under the License.
*/
-import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.surefire.shared.lang3.StringUtils;
import javax.annotation.Nonnull;
final class ScannerUtil
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/SpecificFileFilter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/SpecificFileFilter.java
index 6b97b2f..00ea599 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/SpecificFileFilter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/SpecificFileFilter.java
@@ -24,7 +24,7 @@ import java.util.Set;
import javax.annotation.Nullable;
-import org.apache.maven.shared.utils.io.SelectorUtils;
+import org.apache.maven.surefire.shared.utils.io.SelectorUtils;
import static org.apache.maven.plugin.surefire.util.ScannerUtil.convertSlashToSystemFileSeparator;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
index dacadc0..559a0f1 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
@@ -75,7 +75,7 @@ import static java.util.Arrays.asList;
import static java.util.Collections.emptySet;
import static java.util.Collections.singleton;
import static java.util.Collections.singletonMap;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.apache.maven.artifact.versioning.VersionRange.createFromVersion;
import static org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec;
import static org.fest.assertions.Assertions.assertThat;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java
index 5b15054..4e1ff70 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java
@@ -30,7 +30,7 @@ import java.util.List;
import static java.util.Collections.addAll;
import static java.util.Collections.singleton;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.apache.maven.plugin.surefire.SurefireHelper.escapeToPlatformPath;
import static org.apache.maven.plugin.surefire.SurefireHelper.reportExecution;
import static org.fest.assertions.Assertions.assertThat;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
index 616534d..ca42c44 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
@@ -21,7 +21,7 @@ package org.apache.maven.plugin.surefire.booterclient;
import junit.framework.Assert;
import junit.framework.TestCase;
-import org.apache.commons.io.FileUtils;
+import org.apache.maven.surefire.shared.io.FileUtils;
import org.apache.maven.surefire.booter.BooterDeserializer;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
import org.apache.maven.surefire.booter.ClasspathConfiguration;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
index ec844d3..4e9bbc9 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
@@ -20,7 +20,7 @@ package org.apache.maven.plugin.surefire.booterclient;
*/
import junit.framework.TestCase;
-import org.apache.commons.io.FileUtils;
+import org.apache.maven.surefire.shared.io.FileUtils;
import org.apache.maven.surefire.booter.AbstractPathConfiguration;
import org.apache.maven.surefire.booter.BooterDeserializer;
import org.apache.maven.surefire.booter.Classpath;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
index f38f997..72e5372 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
@@ -19,12 +19,12 @@ package org.apache.maven.plugin.surefire.booterclient;
* under the License.
*/
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.SystemUtils;
+import org.apache.maven.surefire.shared.io.FileUtils;
+import org.apache.maven.surefire.shared.lang3.SystemUtils;
import org.apache.maven.plugin.surefire.JdkAttributes;
import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
-import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.cli.Commandline;
+import org.apache.maven.surefire.shared.utils.StringUtils;
+import org.apache.maven.surefire.shared.utils.cli.Commandline;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
import org.apache.maven.surefire.booter.Classpath;
import org.apache.maven.surefire.booter.ClasspathConfiguration;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkStarterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkStarterTest.java
new file mode 100644
index 0000000..e0874f0
--- /dev/null
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkStarterTest.java
@@ -0,0 +1,272 @@
+package org.apache.maven.plugin.surefire.booterclient;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.plugin.surefire.StartupReportConfiguration;
+import org.apache.maven.plugin.surefire.SurefireProperties;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.AbstractForkInputStream;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream.TestLessInputStreamBuilder;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStream;
+import org.apache.maven.plugin.surefire.booterclient.output.ForkClient;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
+import org.apache.maven.surefire.booter.AbstractPathConfiguration;
+import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
+import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.PropertiesWrapper;
+import org.apache.maven.surefire.booter.ProviderConfiguration;
+import org.apache.maven.surefire.booter.Shutdown;
+import org.apache.maven.surefire.booter.StartupConfiguration;
+import org.apache.maven.surefire.booter.SurefireBooterForkException;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.shared.compress.archivers.zip.Zip64Mode;
+import org.apache.maven.surefire.shared.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.maven.surefire.shared.compress.archivers.zip.ZipArchiveOutputStream;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayDeque;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.jar.Manifest;
+import java.util.zip.Deflater;
+
+import static org.fest.util.Files.delete;
+import static org.hamcrest.Matchers.containsString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.powermock.reflect.Whitebox.invokeMethod;
+
+/**
+ *
+ */
+public class ForkStarterTest
+{
+ private static String baseDir = System.getProperty( "user.dir" );
+ private static File tmp;
+
+ @Rule
+ public final ExpectedException e = ExpectedException.none();
+
+ @BeforeClass
+ public static void prepareFiles() throws IOException
+ {
+ File target = new File( baseDir, "target" );
+ tmp = new File( target, "tmp" );
+ tmp.mkdirs();
+ File booter = new File( tmp, "surefirebooter.jar" );
+ booter.createNewFile();
+
+ try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream( new FileOutputStream( booter ) ) )
+ {
+ zos.setUseZip64( Zip64Mode.Never );
+ zos.setLevel( Deflater.NO_COMPRESSION );
+
+ ZipArchiveEntry ze = new ZipArchiveEntry( "META-INF/MANIFEST.MF" );
+ zos.putArchiveEntry( ze );
+
+ Manifest man = new Manifest();
+
+ man.getMainAttributes().putValue( "Manifest-Version", "1.0" );
+ man.getMainAttributes().putValue( "Main-Class", MainClass.class.getName() );
+
+ man.write( zos );
+
+ zos.closeArchiveEntry();
+
+ ze = new ZipArchiveEntry( "org/apache/maven/plugin/surefire/booterclient/MainClass.class" );
+ zos.putArchiveEntry( ze );
+ String classesDir = Paths.get( target.getPath(), "test-classes" ).toString();
+ Path cls = Paths.get( classesDir, "org", "apache", "maven", "plugin", "surefire", "booterclient",
+ "MainClass.class" );
+ zos.write( Files.readAllBytes( cls ) );
+ zos.closeArchiveEntry();
+ }
+ }
+
+ @AfterClass
+ public static void deleteTmp()
+ {
+ delete( tmp );
+ }
+
+ @Test
+ public void processShouldExitWithoutSayingGoodBye() throws Exception
+ {
+ ReporterConfiguration reporterConfiguration = new ReporterConfiguration( tmp, true );
+
+ ProviderConfiguration providerConfiguration = mock( ProviderConfiguration.class );
+ when( providerConfiguration.getReporterConfiguration() )
+ .thenReturn( reporterConfiguration );
+ when( providerConfiguration.getShutdown() )
+ .thenReturn( Shutdown.EXIT );
+
+ StartupConfiguration startupConfiguration = mock( StartupConfiguration.class );
+ when( startupConfiguration.getClasspathConfiguration() )
+ .thenReturn( new ClasspathConfig() );
+ when( startupConfiguration.getClassLoaderConfiguration() )
+ .thenReturn( new ClassLoaderConfiguration( false, false ) );
+ when( startupConfiguration.getProviderClassName() )
+ .thenReturn( MainClass.class.getName() );
+
+ ForkConfiguration forkConfiguration = mock( ForkConfiguration.class );
+ when( forkConfiguration.getWorkingDirectory() )
+ .thenReturn( tmp );
+ when( forkConfiguration.getTempDirectory() )
+ .thenReturn( tmp );
+ when( forkConfiguration.getPluginPlatform() )
+ .thenReturn( new Platform() );
+ OutputStreamFlushableCommandline cli = new OutputStreamFlushableCommandline();
+ cli.setWorkingDirectory( tmp );
+ cli.setExecutable( System.getProperty( "java.home" ) + "/bin/java" );
+ cli.createArg().setLine( "-jar" );
+ cli.createArg().setLine( "surefirebooter.jar" );
+ cli.createArg().setLine( "fail" );
+ when( forkConfiguration.createCommandLine( eq( startupConfiguration ), eq( 1 ), eq( tmp ) ) )
+ .thenReturn( cli );
+
+ StartupReportConfiguration startupReportConfiguration = new StartupReportConfiguration( true, true, null,
+ false, tmp, true, "", null, false, 0, null, null, true, null, null, null );
+
+ ConsoleLogger logger = mock( ConsoleLogger.class );
+
+ ForkStarter forkStarter = new ForkStarter( providerConfiguration, startupConfiguration, forkConfiguration,
+ 0, startupReportConfiguration, logger );
+
+ DefaultReporterFactory reporterFactory = new DefaultReporterFactory( startupReportConfiguration, logger, 1 );
+
+ e.expect( SurefireBooterForkException.class );
+ e.expectMessage( containsString( "Process Exit Code: 1" ) );
+ e.expectMessage( containsString( "The forked VM terminated without properly saying goodbye." ) );
+ e.expectMessage( containsString( "VM crash or System.exit called?" ) );
+
+ Class<?>[] types = {Object.class, PropertiesWrapper.class, ForkClient.class, SurefireProperties.class,
+ int.class, AbstractForkInputStream.class, boolean.class};
+ TestProvidingInputStream testProvidingInputStream = new TestProvidingInputStream( new ArrayDeque<String>() );
+ invokeMethod( forkStarter, "fork", types, null,
+ new PropertiesWrapper( Collections.<String, String>emptyMap() ),
+ new ForkClient( reporterFactory, null, logger, new AtomicBoolean(), 1 ),
+ new SurefireProperties(), 1, testProvidingInputStream, true );
+ testProvidingInputStream.close();
+ }
+
+ @Test
+ public void processShouldWaitForAck() throws Exception
+ {
+ ReporterConfiguration reporterConfiguration = new ReporterConfiguration( tmp, true );
+
+ ProviderConfiguration providerConfiguration = mock( ProviderConfiguration.class );
+ when( providerConfiguration.getReporterConfiguration() )
+ .thenReturn( reporterConfiguration );
+ when( providerConfiguration.getShutdown() )
+ .thenReturn( Shutdown.EXIT );
+
+ StartupConfiguration startupConfiguration = mock( StartupConfiguration.class );
+ when( startupConfiguration.getClasspathConfiguration() )
+ .thenReturn( new ClasspathConfig() );
+ when( startupConfiguration.getClassLoaderConfiguration() )
+ .thenReturn( new ClassLoaderConfiguration( false, false ) );
+ when( startupConfiguration.getProviderClassName() )
+ .thenReturn( MainClass.class.getName() );
+
+ ForkConfiguration forkConfiguration = mock( ForkConfiguration.class );
+ when( forkConfiguration.getWorkingDirectory() )
+ .thenReturn( tmp );
+ when( forkConfiguration.getTempDirectory() )
+ .thenReturn( tmp );
+ when( forkConfiguration.getPluginPlatform() )
+ .thenReturn( new Platform() );
+ OutputStreamFlushableCommandline cli = new OutputStreamFlushableCommandline();
+ cli.setWorkingDirectory( tmp );
+ cli.setExecutable( System.getProperty( "java.home" ) + "/bin/java" );
+ cli.createArg().setLine( "-jar" );
+ cli.createArg().setLine( "surefirebooter.jar" );
+ when( forkConfiguration.createCommandLine( eq( startupConfiguration ), eq( 1 ), eq( tmp ) ) )
+ .thenReturn( cli );
+
+ StartupReportConfiguration startupReportConfiguration = new StartupReportConfiguration( true, true, null,
+ false, tmp, true, "", null, false, 0, null, null, true, null, null, null );
+
+ ConsoleLogger logger = mock( ConsoleLogger.class );
+
+ ForkStarter forkStarter = new ForkStarter( providerConfiguration, startupConfiguration, forkConfiguration,
+ 0, startupReportConfiguration, logger );
+
+ DefaultReporterFactory reporterFactory = new DefaultReporterFactory( startupReportConfiguration, logger, 1 );
+
+ Class<?>[] types = {Object.class, PropertiesWrapper.class, ForkClient.class, SurefireProperties.class,
+ int.class, AbstractForkInputStream.class, boolean.class};
+ TestLessInputStream testLessInputStream = new TestLessInputStreamBuilder().build();
+ invokeMethod( forkStarter, "fork", types, null,
+ new PropertiesWrapper( Collections.<String, String>emptyMap() ),
+ new ForkClient( reporterFactory, testLessInputStream, logger, new AtomicBoolean(), 1 ),
+ new SurefireProperties(), 1, testLessInputStream, true );
+ testLessInputStream.close();
+ }
+
+ private static class ClasspathConfig extends AbstractPathConfiguration
+ {
+ ClasspathConfig()
+ {
+ this( Classpath.emptyClasspath(), false, false );
+ }
+
+ private ClasspathConfig( Classpath surefireClasspathUrls, boolean enableAssertions, boolean childDelegation )
+ {
+ super( surefireClasspathUrls, enableAssertions, childDelegation );
+ }
+
+ @Override
+ public Classpath getTestClasspath()
+ {
+ return Classpath.emptyClasspath();
+ }
+
+ @Override
+ public boolean isModularPathConfig()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isClassPathConfig()
+ {
+ return true;
+ }
+
+ @Override
+ protected Classpath getInprocClasspath()
+ {
+ return Classpath.emptyClasspath();
+ }
+ }
+}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MainClass.java
similarity index 52%
copy from maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java
copy to maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MainClass.java
index fd33d8e..d90a128 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MainClass.java
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.surefire.report;
+package org.apache.maven.plugin.surefire.booterclient;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,34 +19,34 @@ package org.apache.maven.plugin.surefire.report;
* under the License.
*/
-import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import java.io.IOException;
/**
- * Utils class for file-based reporters
- *
- * @author Andreas Gudian
+ * For testing purposes.
*/
-public final class FileReporterUtils
+public class MainClass
{
- private FileReporterUtils()
+ public static void main( String... args ) throws IOException
{
- throw new IllegalStateException( "non instantiable constructor" );
- }
-
- public static String stripIllegalFilenameChars( String original )
- {
- String result = original;
- String illegalChars = getOSSpecificIllegalChars();
- for ( int i = 0; i < illegalChars.length(); i++ )
+ if ( "fail".equals( args[0] ) )
{
- result = result.replace( illegalChars.charAt( i ), '_' );
+ System.exit( 1 );
+ }
+ else
+ {
+ System.out.println( ":maven:surefire:std:out:bye" );
+ if ( System.in.read() == 0
+ && System.in.read() == 0
+ && System.in.read() == 0
+ && System.in.read() == 5
+ && System.in.read() == 0
+ && System.in.read() == 0
+ && System.in.read() == 0
+ && System.in.read() == 0 )
+ {
+ System.exit( 0 );
+ }
+ System.exit( 1 );
}
-
- return result;
- }
-
- private static String getOSSpecificIllegalChars()
- {
- return IS_OS_WINDOWS ? "\\/:*?\"<>|\0" : "/\0";
}
}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java
index a9077fe..492c5c0 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java
@@ -43,7 +43,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.readAllLines;
import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
-import static org.apache.maven.shared.utils.StringUtils.replace;
+import static org.apache.maven.surefire.shared.utils.StringUtils.replace;
import static org.apache.maven.surefire.booter.Classpath.emptyClasspath;
import static org.fest.assertions.Assertions.assertThat;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandlineTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandlineTest.java
index 3cd0fb8..3b35cda 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandlineTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/OutputStreamFlushableCommandlineTest.java
@@ -19,14 +19,14 @@ package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
* under the License.
*/
-import org.apache.maven.shared.utils.cli.CommandLineException;
+import org.apache.maven.surefire.shared.utils.cli.CommandLineException;
import org.fest.assertions.Condition;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
index 0dfe1b8..abf25ee 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
@@ -33,7 +33,7 @@ import org.apache.maven.plugin.surefire.extensions.SurefireConsoleOutputReporter
import org.apache.maven.plugin.surefire.extensions.SurefireStatelessReporter;
import org.apache.maven.plugin.surefire.extensions.SurefireStatelessTestsetInfoReporter;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
-import org.apache.maven.shared.utils.logging.MessageUtils;
+import org.apache.maven.surefire.shared.utils.logging.MessageUtils;
import org.apache.maven.surefire.report.RunStatistics;
import org.apache.maven.surefire.report.SafeThrowable;
import org.apache.maven.surefire.report.StackTraceWriter;
@@ -427,4 +427,4 @@ public class DefaultReporterFactoryTest
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java
index 0914051..e6eec81 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java
@@ -21,9 +21,9 @@ package org.apache.maven.plugin.surefire.report;
import junit.framework.TestCase;
import org.apache.maven.plugin.surefire.booterclient.output.DeserializedStacktraceWriter;
-import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.xml.Xpp3Dom;
-import org.apache.maven.shared.utils.xml.Xpp3DomBuilder;
+import org.apache.maven.surefire.shared.utils.StringUtils;
+import org.apache.maven.surefire.shared.utils.xml.Xpp3Dom;
+import org.apache.maven.surefire.shared.utils.xml.Xpp3DomBuilder;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.SimpleReportEntry;
import org.apache.maven.surefire.report.StackTraceWriter;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/TestSetStatsTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/TestSetStatsTest.java
index 7aac381..63e1ac3 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/TestSetStatsTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/TestSetStatsTest.java
@@ -26,7 +26,7 @@ import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
-import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
+import static org.apache.maven.surefire.shared.utils.logging.MessageUtils.buffer;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMapTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMapTest.java
index 1a15fbe..b4ffd1a 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMapTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMapTest.java
@@ -33,7 +33,7 @@ import org.apache.maven.surefire.report.SimpleReportEntry;
import junit.framework.TestCase;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.commons.io.IOUtils.readLines;
+import static org.apache.maven.surefire.shared.io.IOUtils.readLines;
import static org.apache.maven.surefire.util.internal.StringUtils.NL;
import static org.fest.assertions.Assertions.assertThat;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
index d28a89c..b1e3b22 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
@@ -34,6 +34,7 @@ import org.apache.maven.plugin.surefire.booterclient.BooterDeserializerProviderC
import org.apache.maven.plugin.surefire.booterclient.BooterDeserializerStartupConfigurationTest;
import org.apache.maven.plugin.surefire.booterclient.DefaultForkConfigurationTest;
import org.apache.maven.plugin.surefire.booterclient.ForkConfigurationTest;
+import org.apache.maven.plugin.surefire.booterclient.ForkStarterTest;
import org.apache.maven.plugin.surefire.booterclient.ForkingRunListenerTest;
import org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfigurationTest;
import org.apache.maven.plugin.surefire.booterclient.ModularClasspathForkConfigurationTest;
@@ -104,6 +105,7 @@ public class JUnit4SuiteTest extends TestCase
suite.addTest( new JUnit4TestAdapter( TestSetStatsTest.class ) );
suite.addTest( new JUnit4TestAdapter( StatelessTestsetInfoReporterTest.class ) );
suite.addTest( new JUnit4TestAdapter( CommonReflectorTest.class ) );
+ suite.addTest( new JUnit4TestAdapter( ForkStarterTest.class ) );
return suite;
}
}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java
index aa10111..a626180 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java
@@ -26,7 +26,7 @@ import org.apache.maven.plugin.surefire.report.ConsoleReporter;
import org.apache.maven.plugin.surefire.report.FileReporter;
import org.apache.maven.plugin.surefire.report.TestSetStats;
import org.apache.maven.plugin.surefire.report.WrappedReportEntry;
-import org.apache.maven.shared.utils.logging.MessageUtils;
+import org.apache.maven.surefire.shared.utils.logging.MessageUtils;
import org.apache.maven.surefire.report.TestSetReportEntry;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java
index e8922cf..1408583 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java
@@ -29,7 +29,7 @@ import java.util.concurrent.Executors;
import org.apache.maven.plugin.surefire.report.ConsoleOutputFileReporter;
import junit.framework.TestCase;
-import org.apache.maven.shared.utils.io.FileUtils;
+import org.apache.maven.surefire.shared.utils.io.FileUtils;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static org.fest.assertions.Assertions.assertThat;
diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml
index 30efd4b..7a91275 100644
--- a/surefire-api/pom.xml
+++ b/surefire-api/pom.xml
@@ -38,12 +38,9 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-shared-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-shared-utils</artifactId>
+ <version>3.0.0-M4</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
@@ -90,36 +87,6 @@
</dependency>
</dependencies>
</plugin>
- <plugin>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <minimizeJar>true</minimizeJar>
- <artifactSet>
- <includes>
- <include>org.apache.maven.shared:maven-shared-utils</include>
- <include>commons-codec:commons-codec</include>
- </includes>
- </artifactSet>
- <relocations>
- <relocation>
- <pattern>org.apache.maven.shared.utils</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.api.org.apache.maven.shared.utils</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.commons.codec</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.api.org.apache.commons.codec</shadedPattern>
- </relocation>
- </relocations>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
</project>
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/SpecificTestClassFilter.java b/surefire-api/src/main/java/org/apache/maven/surefire/SpecificTestClassFilter.java
index 6f6b751..c26ca94 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/SpecificTestClassFilter.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/SpecificTestClassFilter.java
@@ -22,7 +22,7 @@ package org.apache.maven.surefire;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-import org.apache.maven.shared.utils.io.SelectorUtils;
+import org.apache.maven.surefire.shared.utils.io.SelectorUtils;
import org.apache.maven.surefire.util.ScannerFilter;
/**
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkedChannelEncoder.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkedChannelEncoder.java
index f66e137..94f620a 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkedChannelEncoder.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkedChannelEncoder.java
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.booter;
* under the License.
*/
-import org.apache.commons.codec.binary.Base64;
+import org.apache.maven.surefire.shared.codec.binary.Base64;
import org.apache.maven.plugin.surefire.log.api.ConsoleLoggerUtils;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.RunMode;
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java b/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java
index 195828a..668df52 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java
@@ -45,14 +45,4 @@ public enum CommandLineOption
}
return options;
}
-
- public static List<String> toStrings( Collection<CommandLineOption> options )
- {
- List<String> elements = new ArrayList<>( options.size() );
- for ( CommandLineOption option : options )
- {
- elements.add( option.name() );
- }
- return elements;
- }
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/testset/ResolvedTest.java b/surefire-api/src/main/java/org/apache/maven/surefire/testset/ResolvedTest.java
index 56bc279..9b2637b 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/testset/ResolvedTest.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/testset/ResolvedTest.java
@@ -19,18 +19,18 @@ package org.apache.maven.surefire.testset;
* under the License.
*/
-import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.io.MatchPatterns;
+import org.apache.maven.surefire.shared.utils.StringUtils;
+import org.apache.maven.surefire.shared.utils.io.MatchPatterns;
import java.util.regex.Pattern;
import static java.io.File.separatorChar;
import static java.util.regex.Pattern.compile;
-import static org.apache.maven.shared.utils.StringUtils.isBlank;
-import static org.apache.maven.shared.utils.io.MatchPatterns.from;
-import static org.apache.maven.shared.utils.io.SelectorUtils.PATTERN_HANDLER_SUFFIX;
-import static org.apache.maven.shared.utils.io.SelectorUtils.REGEX_HANDLER_PREFIX;
-import static org.apache.maven.shared.utils.io.SelectorUtils.matchPath;
+import static org.apache.maven.surefire.shared.utils.StringUtils.isBlank;
+import static org.apache.maven.surefire.shared.utils.io.MatchPatterns.from;
+import static org.apache.maven.surefire.shared.utils.io.SelectorUtils.PATTERN_HANDLER_SUFFIX;
+import static org.apache.maven.surefire.shared.utils.io.SelectorUtils.REGEX_HANDLER_PREFIX;
+import static org.apache.maven.surefire.shared.utils.io.SelectorUtils.matchPath;
/**
* Single pattern test filter resolved from multi pattern filter -Dtest=MyTest#test,AnotherTest#otherTest.
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestListResolver.java b/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestListResolver.java
index 266d06a..c7c123a 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestListResolver.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestListResolver.java
@@ -26,11 +26,11 @@ import java.util.LinkedHashSet;
import java.util.Set;
import static java.util.Collections.unmodifiableSet;
-import static org.apache.maven.shared.utils.StringUtils.isBlank;
-import static org.apache.maven.shared.utils.StringUtils.isNotBlank;
-import static org.apache.maven.shared.utils.StringUtils.split;
-import static org.apache.maven.shared.utils.io.SelectorUtils.PATTERN_HANDLER_SUFFIX;
-import static org.apache.maven.shared.utils.io.SelectorUtils.REGEX_HANDLER_PREFIX;
+import static org.apache.maven.surefire.shared.utils.StringUtils.isBlank;
+import static org.apache.maven.surefire.shared.utils.StringUtils.isNotBlank;
+import static org.apache.maven.surefire.shared.utils.StringUtils.split;
+import static org.apache.maven.surefire.shared.utils.io.SelectorUtils.PATTERN_HANDLER_SUFFIX;
+import static org.apache.maven.surefire.shared.utils.io.SelectorUtils.REGEX_HANDLER_PREFIX;
import static java.util.Collections.singleton;
import static org.apache.maven.surefire.testset.ResolvedTest.Type.CLASS;
import static org.apache.maven.surefire.testset.ResolvedTest.Type.METHOD;
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
index fdb60f7..12fd968 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
@@ -109,8 +109,8 @@ public class DefaultDirectoryScanner
String[] tests = EMPTY_STRING_ARRAY;
if ( basedir.exists() )
{
- org.apache.maven.shared.utils.io.DirectoryScanner scanner =
- new org.apache.maven.shared.utils.io.DirectoryScanner();
+ org.apache.maven.surefire.shared.utils.io.DirectoryScanner scanner =
+ new org.apache.maven.surefire.shared.utils.io.DirectoryScanner();
scanner.setBasedir( basedir );
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/booter/ForkedChannelEncoderTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/booter/ForkedChannelEncoderTest.java
index efa89e0..1dcf4d9 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/booter/ForkedChannelEncoderTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/booter/ForkedChannelEncoderTest.java
@@ -36,7 +36,7 @@ import java.util.Map;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Arrays.copyOfRange;
-import static org.apache.commons.codec.binary.Base64.encodeBase64String;
+import static org.apache.maven.surefire.shared.codec.binary.Base64.encodeBase64String;
import static org.apache.maven.surefire.booter.ForkedChannelEncoder.encode;
import static org.apache.maven.surefire.booter.ForkedChannelEncoder.encodeHeader;
import static org.apache.maven.surefire.booter.ForkedChannelEncoder.encodeMessage;
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java b/surefire-api/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java
index 780f2f0..8fd653b 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.booter;
* under the License.
*/
-import org.apache.maven.shared.utils.io.FileUtils;
+import org.apache.maven.surefire.shared.utils.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml
index 63279bd..1fa5045 100644
--- a/surefire-booter/pom.xml
+++ b/surefire-booter/pom.xml
@@ -36,25 +36,6 @@
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-api</artifactId>
<version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-shared-utils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-shared-utils</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
@@ -62,11 +43,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
@@ -133,36 +109,6 @@
</systemPropertyVariables>
</configuration>
</plugin>
- <plugin>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <minimizeJar>true</minimizeJar>
- <artifactSet>
- <includes>
- <include>org.apache.commons:commons-lang3</include>
- <include>commons-io:commons-io</include>
- </includes>
- </artifactSet>
- <relocations>
- <relocation>
- <pattern>org.apache.commons.lang3</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.booter.org.apache.commons.lang3</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.commons.io</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.booter.org.apache.commons.io</shadedPattern>
- </relocation>
- </relocations>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
</project>
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
index 4360b02..d935dd4 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
@@ -37,12 +37,12 @@ import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.regex.Pattern.compile;
-import static org.apache.commons.io.IOUtils.closeQuietly;
-import static org.apache.commons.lang3.StringUtils.isNotBlank;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_HP_UX;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_UNIX;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import static org.apache.maven.surefire.shared.io.IOUtils.closeQuietly;
+import static org.apache.maven.surefire.shared.lang3.StringUtils.isNotBlank;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_HP_UX;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_LINUX;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_UNIX;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.apache.maven.surefire.booter.ProcessInfo.unixProcessInfo;
import static org.apache.maven.surefire.booter.ProcessInfo.windowsProcessInfo;
import static org.apache.maven.surefire.booter.ProcessInfo.ERR_PROCESS_INFO;
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java
index e8223d7..ef76374 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java
@@ -36,11 +36,11 @@ import java.util.StringTokenizer;
import static java.lang.Character.isDigit;
import static java.lang.Thread.currentThread;
import static java.util.Objects.requireNonNull;
-import static org.apache.commons.lang3.StringUtils.isNumeric;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_FREE_BSD;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_NET_BSD;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_OPEN_BSD;
+import static org.apache.maven.surefire.shared.lang3.StringUtils.isNumeric;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_FREE_BSD;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_LINUX;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_NET_BSD;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_OPEN_BSD;
import static org.apache.maven.surefire.util.ReflectionUtils.invokeMethodChain;
import static org.apache.maven.surefire.util.ReflectionUtils.tryLoadClass;
@@ -178,7 +178,7 @@ public final class SystemUtils
private static BigDecimal getJavaSpecificationVersion()
{
StringBuilder fractionalVersion = new StringBuilder( "0" );
- for ( char c : org.apache.commons.lang3.SystemUtils.JAVA_SPECIFICATION_VERSION.toCharArray() )
+ for ( char c : org.apache.maven.surefire.shared.lang3.SystemUtils.JAVA_SPECIFICATION_VERSION.toCharArray() )
{
if ( isDigit( c ) )
{
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkedBooterTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkedBooterTest.java
index 434ca80..3f6d148 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkedBooterTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkedBooterTest.java
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.booter;
* under the License.
*/
-import org.apache.commons.io.FileUtils;
+import org.apache.maven.surefire.shared.io.FileUtils;
import org.junit.Test;
import java.io.File;
@@ -211,4 +211,4 @@ public class ForkedBooterTest
.contains( "\"main\"" )
.contains( "java.lang.Thread.State: RUNNABLE" );
}
-}
\ No newline at end of file
+}
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
index 424eb5f..e67d0b3 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
@@ -28,8 +28,8 @@ import java.lang.management.ManagementFactory;
import java.util.regex.Matcher;
import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_UNIX;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_UNIX;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.apache.maven.surefire.booter.ProcessInfo.unixProcessInfo;
import static org.apache.maven.surefire.booter.ProcessInfo.windowsProcessInfo;
import static org.fest.assertions.Assertions.assertThat;
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java
index 34faff0..c504e04 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java
@@ -32,12 +32,12 @@ import java.lang.management.ManagementFactory;
import java.math.BigDecimal;
import static java.io.File.separator;
-import static org.apache.commons.lang3.JavaVersion.JAVA_9;
-import static org.apache.commons.lang3.JavaVersion.JAVA_RECENT;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_FREE_BSD;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_NET_BSD;
-import static org.apache.commons.lang3.SystemUtils.IS_OS_OPEN_BSD;
+import static org.apache.maven.surefire.shared.lang3.JavaVersion.JAVA_9;
+import static org.apache.maven.surefire.shared.lang3.JavaVersion.JAVA_RECENT;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_FREE_BSD;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_LINUX;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_NET_BSD;
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_OPEN_BSD;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
import static org.mockito.Matchers.any;
diff --git a/surefire-extensions-api/pom.xml b/surefire-extensions-api/pom.xml
index 785411a..1e88403 100644
--- a/surefire-extensions-api/pom.xml
+++ b/surefire-extensions-api/pom.xml
@@ -43,6 +43,21 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-shared-utils</artifactId>
+ <version>3.0.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
@@ -84,6 +99,9 @@
</dependencies>
<configuration>
<argLine>${jvm.args.tests}</argLine>
+ <includes>
+ <include>**/JUnit4SuiteTest.java</include>
+ </includes>
<systemPropertyVariables>
<jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineExecutor.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineExecutor.java
new file mode 100644
index 0000000..14a055d
--- /dev/null
+++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineExecutor.java
@@ -0,0 +1,128 @@
+package org.apache.maven.surefire.extensions.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.shared.utils.cli.CommandLineException;
+import org.apache.maven.surefire.shared.utils.cli.Commandline;
+
+import java.io.Closeable;
+
+import static org.apache.maven.surefire.shared.utils.cli.ShutdownHookUtils.addShutDownHook;
+import static org.apache.maven.surefire.shared.utils.cli.ShutdownHookUtils.removeShutdownHook;
+
+/**
+ * Programming model with this class:
+ * <pre> {@code
+ * try ( CommandlineExecutor exec = new CommandlineExecutor( cli, endOfStreamsCountdown );
+ * CommandlineStreams streams = exec.execute() )
+ * {
+ * // register exec in the shutdown hook to destroy pending process
+ *
+ * // register streams in the shutdown hook to close all three streams
+ *
+ * ReadableByteChannel stdOut = streams.getStdOutChannel();
+ * ReadableByteChannel stdErr = streams.getStdErrChannel();
+ * WritableByteChannel stdIn = streams.getStdInChannel();
+ * // lineConsumerThread = new LineConsumerThread( ..., stdErr, ..., endOfStreamsCountdown );
+ * // lineConsumerThread.start();
+ *
+ * // stdIn.write( ... );
+ *
+ * int exitCode = exec.awaitExit();
+ * // process exitCode
+ * }
+ * catch ( InterruptedException e )
+ * {
+ * lineConsumerThread.disable();
+ * }
+ * catch ( CommandLineException e )
+ * {
+ * // handle the exceptions
+ * }
+ * } </pre>
+ */
+public class CommandlineExecutor implements Closeable
+{
+ private final Commandline cli;
+ private final CountdownCloseable endOfStreamsCountdown;
+ private Process process;
+ private Thread shutdownHook;
+
+ public CommandlineExecutor( Commandline cli, CountdownCloseable endOfStreamsCountdown )
+ {
+ // now the surefire-extension-api is dependent on CLI without casting generic type T to unrelated object
+ // and the user would not use maven-surefire-common nothing but the only surefire-extension-api
+ // because maven-surefire-common is used for MOJO plugin and not the user's extensions. The user does not need
+ // to see all MOJO impl. Only the surefire-api, surefire-logger-api and surefire-extension-api.
+ this.cli = cli;
+ this.endOfStreamsCountdown = endOfStreamsCountdown;
+ }
+
+ public CommandlineStreams execute() throws CommandLineException
+ {
+ process = cli.execute();
+ shutdownHook = new ProcessHook( process );
+ addShutDownHook( shutdownHook );
+ return new CommandlineStreams( process );
+ }
+
+ public int awaitExit() throws InterruptedException
+ {
+ try
+ {
+ return process.waitFor();
+ }
+ finally
+ {
+ endOfStreamsCountdown.awaitClosed();
+ }
+ }
+
+ @Override
+ public void close()
+ {
+ if ( shutdownHook != null )
+ {
+ shutdownHook.run();
+ removeShutdownHook( shutdownHook );
+ shutdownHook = null;
+ }
+ }
+
+ private static class ProcessHook extends Thread
+ {
+ private final Process process;
+
+ private ProcessHook( Process process )
+ {
+ super( "cli-shutdown-hook" );
+ this.process = process;
+ setContextClassLoader( null );
+ setDaemon( true );
+ }
+
+ /** {@inheritDoc} */
+ public void run()
+ {
+ process.destroy();
+ }
+ }
+
+}
diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineStreams.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineStreams.java
new file mode 100644
index 0000000..43ec328
--- /dev/null
+++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CommandlineStreams.java
@@ -0,0 +1,82 @@
+package org.apache.maven.surefire.extensions.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.channels.Channel;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.WritableByteChannel;
+
+import static java.nio.channels.Channels.newChannel;
+import static org.apache.maven.surefire.extensions.util.FlushableWritableByteChannel.newFlushableChannel;
+
+/**
+ *
+ */
+public final class CommandlineStreams implements Closeable
+{
+ private final ReadableByteChannel stdOutChannel;
+ private final ReadableByteChannel stdErrChannel;
+ private final WritableByteChannel stdInChannel;
+ private volatile boolean closed;
+
+ public CommandlineStreams( @Nonnull Process process )
+ {
+ InputStream stdOutStream = process.getInputStream();
+ stdOutChannel = newChannel( stdOutStream );
+ InputStream stdErrStream = process.getErrorStream();
+ stdErrChannel = newChannel( stdErrStream );
+ stdInChannel = newFlushableChannel( process.getOutputStream() );
+ }
+
+ public ReadableByteChannel getStdOutChannel()
+ {
+ return stdOutChannel;
+ }
+
+ public ReadableByteChannel getStdErrChannel()
+ {
+ return stdErrChannel;
+ }
+
+ public WritableByteChannel getStdInChannel()
+ {
+ return stdInChannel;
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ if ( closed )
+ {
+ return;
+ }
+
+ try ( Channel c1 = stdOutChannel;
+ Channel c2 = stdErrChannel;
+ Channel c3 = stdInChannel )
+ {
+ closed = true;
+ }
+ }
+}
diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CountdownCloseable.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CountdownCloseable.java
new file mode 100644
index 0000000..9818ec9
--- /dev/null
+++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/CountdownCloseable.java
@@ -0,0 +1,70 @@
+package org.apache.maven.surefire.extensions.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * Decrements {@code countdown} and calls {@code closeable} if reached zero.
+ */
+public final class CountdownCloseable
+ implements Closeable
+{
+ private final Closeable closeable;
+ private volatile int countdown;
+
+ public CountdownCloseable( @Nonnull Closeable closeable, @Nonnegative int countdown )
+ {
+ this.closeable = closeable;
+ this.countdown = countdown;
+ }
+
+ @Override
+ public synchronized void close() throws IOException
+ {
+ if ( --countdown == 0 )
+ {
+ try
+ {
+ closeable.close();
+ }
+ finally
+ {
+ notifyAll();
+ }
+ }
+ }
+
+ /**
+ * Waiting for one Thread in {@link CommandlineExecutor#awaitExit()}.
+ *
+ * @throws InterruptedException see {@link Object#wait()}
+ */
+ public synchronized void awaitClosed() throws InterruptedException
+ {
+ if ( countdown > 0 )
+ {
+ wait();
+ }
+ }
+}
diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/FlushableWritableByteChannel.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/FlushableWritableByteChannel.java
new file mode 100644
index 0000000..e4112f2
--- /dev/null
+++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/FlushableWritableByteChannel.java
@@ -0,0 +1,68 @@
+package org.apache.maven.surefire.extensions.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.annotation.Nonnull;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.WritableByteChannel;
+
+import static java.nio.channels.Channels.newChannel;
+
+/**
+ *
+ */
+final class FlushableWritableByteChannel implements WritableByteChannel
+{
+ private final OutputStream os;
+ private final WritableByteChannel channel;
+
+ private FlushableWritableByteChannel( @Nonnull OutputStream os )
+ {
+ this.os = os;
+ this.channel = newChannel( os );
+ }
+
+ static synchronized WritableByteChannel newFlushableChannel( OutputStream os )
+ {
+ return new FlushableWritableByteChannel( os );
+ }
+
+ @Override
+ public int write( ByteBuffer src ) throws IOException
+ {
+ int countWrittenBytes = channel.write( src );
+ os.flush();
+ return countWrittenBytes;
+ }
+
+ @Override
+ public boolean isOpen()
+ {
+ return channel.isOpen();
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ channel.close();
+ }
+}
diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/LineConsumerThread.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/LineConsumerThread.java
new file mode 100644
index 0000000..109e541
--- /dev/null
+++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/LineConsumerThread.java
@@ -0,0 +1,101 @@
+package org.apache.maven.surefire.extensions.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.shared.utils.cli.StreamConsumer;
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.IOException;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.Charset;
+import java.util.Scanner;
+
+/**
+ *
+ */
+public final class LineConsumerThread extends Thread implements Closeable
+{
+ private final Charset encoding;
+ private final ReadableByteChannel channel;
+ private final StreamConsumer consumer;
+ private final CountdownCloseable countdownCloseable;
+ private volatile boolean disabled;
+
+ public LineConsumerThread( @Nonnull String threadName,
+ @Nonnull ReadableByteChannel channel, @Nonnull StreamConsumer consumer,
+ @Nonnull CountdownCloseable countdownCloseable )
+ {
+ this( threadName, channel, consumer, countdownCloseable, Charset.defaultCharset() );
+ }
+
+ public LineConsumerThread( @Nonnull String threadName,
+ @Nonnull ReadableByteChannel channel, @Nonnull StreamConsumer consumer,
+ @Nonnull CountdownCloseable countdownCloseable, @Nonnull Charset encoding )
+ {
+ setName( threadName );
+ setDaemon( true );
+ this.channel = channel;
+ this.consumer = consumer;
+ this.countdownCloseable = countdownCloseable;
+ this.encoding = encoding;
+ }
+
+ @Override
+ public void run()
+ {
+ try ( Scanner stream = new Scanner( channel, encoding.name() );
+ CountdownCloseable c = countdownCloseable; )
+ {
+ boolean isError = false;
+ while ( stream.hasNextLine() )
+ {
+ try
+ {
+ String line = stream.nextLine();
+ isError |= stream.ioException() != null;
+ if ( !isError && !disabled )
+ {
+ consumer.consumeLine( line );
+ }
+ }
+ catch ( IllegalStateException e )
+ {
+ isError = true;
+ }
+ }
+ }
+ catch ( IllegalStateException | IOException e )
+ {
+ // not needed
+ }
+ }
+
+ public void disable()
+ {
+ disabled = true;
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ channel.close();
+ }
+}
diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/StreamFeeder.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/StreamFeeder.java
new file mode 100644
index 0000000..ca8eb8e
--- /dev/null
+++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/util/StreamFeeder.java
@@ -0,0 +1,89 @@
+package org.apache.maven.surefire.extensions.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.NonWritableChannelException;
+import java.nio.channels.WritableByteChannel;
+
+/**
+ *
+ */
+public class StreamFeeder extends Thread implements Closeable
+{
+ private final WritableByteChannel channel;
+ private final InputStream is;
+
+ private volatile boolean disabled;
+ private volatile Throwable exception;
+
+ public StreamFeeder( @Nonnull String threadName, @Nonnull WritableByteChannel channel, @Nonnull InputStream is )
+ {
+ setName( threadName );
+ setDaemon( true );
+ this.channel = channel;
+ this.is = is;
+ }
+
+ @Override
+ public void run()
+ {
+ try ( WritableByteChannel c = channel )
+ {
+ for ( int data = is.read(); data != -1; data = is.read() )
+ {
+ if ( !disabled )
+ {
+ // todo use CommandReader interface instead of InputStream. Then we would write ByteBuffer.
+ c.write( ByteBuffer.wrap( new byte[] {(byte) data} ) );
+ }
+ }
+ }
+ catch ( ClosedChannelException e )
+ {
+ // closed externally
+ }
+ catch ( IOException | NonWritableChannelException e )
+ {
+ exception = e.getCause() == null ? e : e.getCause();
+ }
+ }
+
+ public void disable()
+ {
+ disabled = true;
+ }
+
+ public Throwable getException()
+ {
+ return exception;
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ channel.close();
+ }
+}
diff --git a/surefire-extensions-api/src/test/java/org/apache/maven/surefire/extensions/util/CommandlineExecutorTest.java b/surefire-extensions-api/src/test/java/org/apache/maven/surefire/extensions/util/CommandlineExecutorTest.java
new file mode 100644
index 0000000..fd99059
--- /dev/null
+++ b/surefire-extensions-api/src/test/java/org/apache/maven/surefire/extensions/util/CommandlineExecutorTest.java
@@ -0,0 +1,109 @@
+package org.apache.maven.surefire.extensions.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.shared.utils.cli.Commandline;
+import org.apache.maven.surefire.shared.utils.cli.StreamConsumer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.Closeable;
+import java.io.InputStream;
+import java.nio.file.Paths;
+
+import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.util.Files.delete;
+import static org.mockito.ArgumentMatchers.contains;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+/**
+ *
+ */
+public class CommandlineExecutorTest
+{
+ private CommandlineExecutor exec;
+ private CommandlineStreams streams;
+ private String baseDir;
+ LineConsumerThread out;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ baseDir = System.getProperty( "user.dir" );
+
+ delete( Paths.get( baseDir, "target", "CommandlineExecutorTest" ).toFile() );
+
+ boolean createdDir = Paths.get( baseDir, "target", "CommandlineExecutorTest" )
+ .toFile()
+ .mkdirs();
+
+ assertThat( createdDir )
+ .isTrue();
+
+ boolean createdFile = Paths.get( baseDir, "target", "CommandlineExecutorTest", "a.txt" )
+ .toFile()
+ .createNewFile();
+
+ assertThat( createdFile )
+ .isTrue();
+ }
+
+ @After
+ public void tearDown() throws Exception
+ {
+ if ( out != null )
+ {
+ out.close();
+ }
+ exec.close();
+ streams.close();
+ delete( Paths.get( baseDir, "target", "CommandlineExecutorTest" ).toFile() );
+ }
+
+ @Test
+ public void shouldExecuteNativeCommand() throws Exception
+ {
+ Closeable closer = mock( Closeable.class );
+ Commandline cli = new Commandline( IS_OS_WINDOWS ? "dir" : "ls -la" );
+ cli.setWorkingDirectory( Paths.get( baseDir, "target", "CommandlineExecutorTest" ).toFile() );
+ CountdownCloseable countdownCloseable = new CountdownCloseable( closer, 1 );
+ exec = new CommandlineExecutor( cli, countdownCloseable );
+ streams = exec.execute();
+ StreamConsumer consumer = mock( StreamConsumer.class );
+ InputStream is = new InputStream()
+ {
+ @Override
+ public int read()
+ {
+ return -1;
+ }
+ };
+ StreamFeeder in = new StreamFeeder( "std-in-fork-1", streams.getStdInChannel(), is );
+ in.start();
+ out = new LineConsumerThread( "std-out-fork-1", streams.getStdOutChannel(), consumer, countdownCloseable );
+ out.start();
+ exec.awaitExit();
+ verify( consumer )
+ .consumeLine( contains( "a.txt" ) );
+ }
+}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java b/surefire-extensions-api/src/test/java/org/apache/maven/surefire/extensions/util/JUnit4SuiteTest.java
similarity index 51%
copy from maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java
copy to surefire-extensions-api/src/test/java/org/apache/maven/surefire/extensions/util/JUnit4SuiteTest.java
index fd33d8e..df9cca1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java
+++ b/surefire-extensions-api/src/test/java/org/apache/maven/surefire/extensions/util/JUnit4SuiteTest.java
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.surefire.report;
+package org.apache.maven.surefire.extensions.util;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,34 +19,20 @@ package org.apache.maven.plugin.surefire.report;
* under the License.
*/
-import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
/**
- * Utils class for file-based reporters
*
- * @author Andreas Gudian
*/
-public final class FileReporterUtils
+public class JUnit4SuiteTest extends TestCase
{
- private FileReporterUtils()
+ public static Test suite()
{
- throw new IllegalStateException( "non instantiable constructor" );
- }
-
- public static String stripIllegalFilenameChars( String original )
- {
- String result = original;
- String illegalChars = getOSSpecificIllegalChars();
- for ( int i = 0; i < illegalChars.length(); i++ )
- {
- result = result.replace( illegalChars.charAt( i ), '_' );
- }
-
- return result;
- }
-
- private static String getOSSpecificIllegalChars()
- {
- return IS_OS_WINDOWS ? "\\/:*?\"<>|\0" : "/\0";
+ TestSuite suite = new TestSuite();
+ suite.addTest( new JUnit4TestAdapter( CommandlineExecutorTest.class ) );
+ return suite;
}
}
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java
index 34504c1..ff5d14a 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java
@@ -38,7 +38,6 @@ public class Surefire735ForkFailWithRedirectConsoleOutputIT
@Test
public void vmStartFail()
- throws Exception
{
OutputValidator outputValidator = unpack().failNever().executeTest();
assertJvmCrashed( outputValidator );
@@ -46,7 +45,6 @@ public class Surefire735ForkFailWithRedirectConsoleOutputIT
@Test
public void vmStartFailShouldFailBuildk()
- throws Exception
{
OutputValidator outputValidator = unpack().maven().withFailure().executeTest();
assertJvmCrashed( outputValidator );
@@ -69,12 +67,13 @@ public class Surefire735ForkFailWithRedirectConsoleOutputIT
}
}
);
+
assertThat( dumpFiles ).isNotEmpty();
+
for ( String dump : dumpFiles )
{
outputValidator.getSurefireReportsFile( dump )
.assertContainsText( "Invalid maximum heap size: -Xmxxxx712743m" );
}
}
-
}
diff --git a/surefire-providers/common-java5/pom.xml b/surefire-providers/common-java5/pom.xml
index 8e30ca3..9245b97 100644
--- a/surefire-providers/common-java5/pom.xml
+++ b/surefire-providers/common-java5/pom.xml
@@ -33,8 +33,9 @@
<dependencies>
<dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-shared-utils</artifactId>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-shared-utils</artifactId>
+ <version>3.0.0-M4</version>
</dependency>
</dependencies>
@@ -56,31 +57,6 @@
</configuration>
</plugin>
<plugin>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <minimizeJar>true</minimizeJar>
- <artifactSet>
- <includes>
- <include>org.apache.maven.shared:maven-shared-utils</include>
- </includes>
- </artifactSet>
- <relocations>
- <relocation>
- <pattern>org.apache.maven.shared.utils</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.java5.org.apache.maven.shared.utils</shadedPattern>
- </relocation>
- </relocations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${jvm.args.tests} ${jacoco.agent}</argLine>
diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
index 134d292..2fd0f83 100644
--- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
+++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
@@ -25,8 +25,8 @@ import java.util.List;
import static java.lang.Math.min;
import static java.util.Arrays.asList;
import static java.util.Collections.reverse;
-import static org.apache.maven.shared.utils.StringUtils.chompLast;
-import static org.apache.maven.shared.utils.StringUtils.isNotEmpty;
+import static org.apache.maven.surefire.shared.utils.StringUtils.chompLast;
+import static org.apache.maven.surefire.shared.utils.StringUtils.isNotEmpty;
/**
* @author Kristian Rosenvold
@@ -171,7 +171,7 @@ public class SmartStackTraceParser
if ( i >= 0 && msg != null )
{
truncatedMessage.append( ' ' )
- .append( msg.substring( 0, min( i, msg.length() ) ) );
+ .append( msg, 0, min( i, msg.length() ) );
if ( i < msg.length() )
{
diff --git a/surefire-report-parser/pom.xml b/surefire-report-parser/pom.xml
index 5b6e771..b9866c3 100644
--- a/surefire-report-parser/pom.xml
+++ b/surefire-report-parser/pom.xml
@@ -39,8 +39,9 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-shared-utils</artifactId>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-shared-utils</artifactId>
+ <version>3.0.0-M4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
@@ -80,31 +81,6 @@
</includes>
</configuration>
</plugin>
- <plugin>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <minimizeJar>true</minimizeJar>
- <artifactSet>
- <includes>
- <include>org.apache.maven.shared:maven-shared-utils</include>
- </includes>
- </artifactSet>
- <relocations>
- <relocation>
- <pattern>org.apache.maven.shared.utils</pattern>
- <shadedPattern>org.apache.maven.surefire.shade.report.org.apache.maven.shared.utils</shadedPattern>
- </relocation>
- </relocations>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
</project>
diff --git a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestCase.java b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestCase.java
index bd1429b..cea9247 100644
--- a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestCase.java
+++ b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestCase.java
@@ -19,7 +19,7 @@ package org.apache.maven.plugins.surefire.report;
* under the License.
*/
-import static org.apache.maven.shared.utils.StringUtils.isNotBlank;
+import static org.apache.maven.surefire.shared.utils.StringUtils.isNotBlank;
/**
*
diff --git a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportParser.java b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportParser.java
index f6e644f..9e0979f 100644
--- a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportParser.java
+++ b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportParser.java
@@ -33,10 +33,10 @@ import javax.xml.parsers.ParserConfigurationException;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.reporting.MavenReportException;
-import org.apache.maven.shared.utils.io.DirectoryScanner;
+import org.apache.maven.surefire.shared.utils.io.DirectoryScanner;
import org.xml.sax.SAXException;
-import static org.apache.maven.shared.utils.StringUtils.split;
+import static org.apache.maven.surefire.shared.utils.StringUtils.split;
/**
*
diff --git a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java
index 943bcdd..d190298 100644
--- a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java
+++ b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java
@@ -35,7 +35,7 @@ import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
-import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.surefire.shared.utils.StringUtils;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;