From 89dc9f97c851bed1d8af0ae75143eb692efb75dd Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 29 Oct 2016 23:06:12 +0200
Subject: [PATCH 001/194] [SUREFIRE-1296] The project build directory should
not be determined as (directory of surefire-reports).getParentFile(). It is a
problem if report directory is customized.
---
.../plugin/surefire/AbstractSurefireMojo.java | 20 ++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
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 a3ab13eec5..7e1c2a7716 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
@@ -649,6 +649,13 @@ public abstract class AbstractSurefireMojo
@Parameter( defaultValue = "${session.parallel}", readonly = true )
private Boolean parallelMavenExecution;
+ /**
+ * Read-only parameter with value of Maven property project.build.directory.
+ * @since 2.19.2
+ */
+ @Parameter( defaultValue = "${project.build.directory}", readonly = true )
+ private File projectBuildDirectory;
+
/**
* List of dependencies to scan for test classes to include in the test run.
* The child elements of this element must be <dependency> elements, and the
@@ -2025,7 +2032,7 @@ private Artifact getSurefireBooterArtifact()
*/
private File getSurefireTempDir()
{
- return new File( getReportsDirectory().getParentFile(), "surefire" );
+ return new File( getProjectBuildDirectory(), "surefire" );
}
/**
@@ -2046,6 +2053,7 @@ private String getConfigChecksum()
checksum.add( getClasspathDependencyScopeExclude() );
checksum.add( getAdditionalClasspathElements() );
checksum.add( getReportsDirectory() );
+ checksum.add( getProjectBuildDirectory() );
checksum.add( getTestSourceDirectory() );
checksum.add( getTest() );
checksum.add( getIncludes() );
@@ -3279,6 +3287,16 @@ public void setClasspathDependencyScopeExclude( String classpathDependencyScopeE
this.classpathDependencyScopeExclude = classpathDependencyScopeExclude;
}
+ public File getProjectBuildDirectory()
+ {
+ return projectBuildDirectory;
+ }
+
+ public void setProjectBuildDirectory( File projectBuildDirectory )
+ {
+ this.projectBuildDirectory = projectBuildDirectory;
+ }
+
protected void logDebugOrCliShowErrors( String s )
{
SurefireHelper.logDebugOrCliShowErrors( s, getConsoleLogger(), cli );
From fb9b699e27dae905393a5bc4d5c6ae39606c3172 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 30 Oct 2016 10:51:26 +0100
Subject: [PATCH 002/194] [SUREFIRE-1297] Specify surefire temp directory for
run in multiple processes
---
.../plugin/surefire/AbstractSurefireMojo.java | 76 +++++++++++++------
1 file changed, 52 insertions(+), 24 deletions(-)
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 7e1c2a7716..127ec82747 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
@@ -20,23 +20,6 @@
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -62,13 +45,13 @@
import org.apache.maven.plugin.surefire.booterclient.ForkStarter;
import org.apache.maven.plugin.surefire.booterclient.ProviderDetector;
import org.apache.maven.plugin.surefire.log.PluginConsoleLogger;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.util.DependencyScanner;
import org.apache.maven.plugin.surefire.util.DirectoryScanner;
import org.apache.maven.plugins.annotations.Component;
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.utils.StringUtils;
import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
import org.apache.maven.surefire.booter.Classpath;
@@ -82,7 +65,6 @@
import org.apache.maven.surefire.booter.SurefireExecutionException;
import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.providerapi.SurefireProvider;
-import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.suite.RunResult;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
@@ -97,10 +79,28 @@
import org.apache.maven.toolchain.ToolchainManager;
import javax.annotation.Nonnull;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import static java.lang.Thread.currentThread;
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.split;
/**
* Abstract base class for running tests using Surefire.
@@ -329,6 +329,15 @@ public abstract class AbstractSurefireMojo
@Parameter( property = "forkMode", defaultValue = "once" )
private String forkMode;
+ /**
+ * Relative path to project.build.directory containing internal Surefire temporary files.
+ * It is deleted after the test set has completed.
+ *
+ * @since 2.19.2
+ */
+ @Parameter( property = "tempDir", defaultValue = "surefire" )
+ private String tempDir;
+
/**
* Option to specify the jvm (or path to the java executable) to use with the forking options. For the default, the
* jvm will be a new instance of the same VM as the one used to run Maven. JVM settings are not inherited from
@@ -874,6 +883,7 @@ boolean verifyParameters()
warnIfRerunClashes();
warnIfWrongShutdownValue();
warnIfNotApplicableSkipAfterFailureCount();
+ warnIfIllegalTempDir();
}
return true;
}
@@ -881,7 +891,6 @@ boolean verifyParameters()
private void executeAfterPreconditionsChecked( DefaultScanResult scanResult )
throws MojoExecutionException, MojoFailureException
{
-
List providers = createProviders();
RunResult current = RunResult.noTestsRun();
@@ -1735,7 +1744,7 @@ private List getIncludeList()
if ( isSpecificTestSpecified() )
{
includes = new ArrayList();
- Collections.addAll( includes, StringUtils.split( getTest(), "," ) );
+ Collections.addAll( includes, split( getTest(), "," ) );
}
else
{
@@ -2002,7 +2011,7 @@ private String getEffectiveJvm()
jvmToUse = toolchain.findTool( "java" ); //NOI18N
}
- if ( StringUtils.isEmpty( jvmToUse ) )
+ if ( isEmpty( jvmToUse ) )
{
// use the same JVM as the one used to run Maven (the "java.home" one)
jvmToUse = System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java";
@@ -2032,7 +2041,7 @@ private Artifact getSurefireBooterArtifact()
*/
private File getSurefireTempDir()
{
- return new File( getProjectBuildDirectory(), "surefire" );
+ return new File( getProjectBuildDirectory(), getTempDir() );
}
/**
@@ -2107,6 +2116,7 @@ private String getConfigChecksum()
checksum.add( getDependenciesToScan() );
checksum.add( getForkedProcessExitTimeoutInSeconds() );
checksum.add( getRerunFailingTestsCount() );
+ checksum.add( getTempDir() );
addPluginSpecificChecksumItems( checksum );
return checksum.getSha1();
}
@@ -2193,7 +2203,7 @@ private Classpath generateTestClasspath()
{
if ( classpathElement != null )
{
- Collections.addAll( classpath, StringUtils.split( classpathElement, "," ) );
+ Collections.addAll( classpath, split( classpathElement, "," ) );
}
}
}
@@ -2512,6 +2522,14 @@ else if ( skipAfterFailureCount > 0 )
}
}
+ private void warnIfIllegalTempDir() throws MojoFailureException
+ {
+ if ( isEmpty( getTempDir() ) )
+ {
+ throw new MojoFailureException( "Parameter 'tempDir' should not be blank string." );
+ }
+ }
+
final class TestNgProviderInfo
implements ProviderInfo
{
@@ -3301,4 +3319,14 @@ protected void logDebugOrCliShowErrors( String s )
{
SurefireHelper.logDebugOrCliShowErrors( s, getConsoleLogger(), cli );
}
+
+ public String getTempDir()
+ {
+ return tempDir;
+ }
+
+ public void setTempDir( String tempDir )
+ {
+ this.tempDir = tempDir;
+ }
}
From 059bd029ccfc56a0d9370f9862d4feed5fc07448 Mon Sep 17 00:00:00 2001
From: Richard Raumberger
Date: Sat, 12 Nov 2016 22:06:23 +0100
Subject: [PATCH 003/194] [SUREFIRE-1301] add note for changing baseDir
property
---
.../apt/examples/fork-options-and-parallel-execution.apt.vm | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm b/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
index 2f9429cd54..805d1e1c93 100644
--- a/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
@@ -291,6 +291,12 @@ Fork Options and Parallel Test Execution
<<<-T>>>, the only limitation is that you can not use it together with
<<>>.
+ When running parallel maven builds without forks, all system properties
+ are shared among the builder threads and ${thisPlugin.toLowerCase()} executions,
+ therefore the threads will encounter race conditions when setting
+ properties, e.g. <<>>, which may lead to changing system properties
+ and unexpected runtime behaviour.
+
* Migrating the Deprecated forkMode Parameter to forkCount and reuseForks
${thisPlugin.toLowerCase()} versions prior 2.14 used the parameter <<>>
From 364b0c9e8ae56916f0b9aead2a26f07ed57befca Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 28 Nov 2016 23:16:20 +0100
Subject: [PATCH 004/194] [SUREFIRE-1295] Attribute JVM crashes to tests
---
.../surefire/booterclient/ForkStarter.java | 39 ++++++++-
.../booterclient/output/ForkClient.java | 81 ++++++++++++++-----
2 files changed, 94 insertions(+), 26 deletions(-)
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 d512f24753..3981c792d0 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
@@ -114,6 +114,8 @@
*/
public class ForkStarter
{
+ private static final String EXECUTION_EXCEPTION = "ExecutionException";
+
private static final long PING_IN_SECONDS = 10;
private static final int TIMEOUT_CHECK_PERIOD_MILLIS = 100;
@@ -436,6 +438,7 @@ private static RunResult awaitResultsDone( Collection> results
throws SurefireBooterForkException
{
RunResult globalResult = new RunResult( 0, 0, 0, 0 );
+ SurefireBooterForkException exception = null;
for ( Future result : results )
{
try
@@ -459,10 +462,31 @@ private static RunResult awaitResultsDone( Collection> results
catch ( ExecutionException e )
{
Throwable realException = e.getCause();
- String error = realException == null ? "" : realException.getLocalizedMessage();
- throw new SurefireBooterForkException( "ExecutionException " + error, realException );
+ if ( realException == null )
+ {
+ if ( exception == null )
+ {
+ exception = new SurefireBooterForkException( EXECUTION_EXCEPTION );
+ }
+ }
+ else
+ {
+ String previousError = "";
+ if ( exception != null && !EXECUTION_EXCEPTION.equals( exception.getLocalizedMessage().trim() ) )
+ {
+ previousError = exception.getLocalizedMessage() + "\n";
+ }
+ String error = previousError + EXECUTION_EXCEPTION + " " + realException.getLocalizedMessage();
+ exception = new SurefireBooterForkException( error, realException );
+ }
}
}
+
+ if ( exception != null )
+ {
+ throw exception;
+ }
+
return globalResult;
}
@@ -566,6 +590,7 @@ private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkC
log.debug( "Forking command line: " + cli );
+ Integer result = null;
RunResult runResult = null;
SurefireBooterForkException booterForkException = null;
try
@@ -577,7 +602,7 @@ private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkC
currentForkClients.add( forkClient );
- int result = future.call();
+ result = future.call();
if ( forkClient.hadTimeout() )
{
@@ -622,10 +647,16 @@ else if ( result != SUCCESS )
}
if ( !forkClient.isSaidGoodBye() )
{
+ String errorCode = result == null ? "" : "\nProcess Exit Code: " + result;
+ String testsInProgress = forkClient.hasTestsInProgress() ? "\nCrashed tests:" : "";
+ for ( String test : forkClient.testsInProgress() )
+ {
+ testsInProgress += "\n" + test;
+ }
// noinspection ThrowFromFinallyBlock
throw new RuntimeException(
"The forked VM terminated without properly saying goodbye. VM crash or System.exit called?"
- + "\nCommand was " + cli.toString() + detail, cause );
+ + "\nCommand was " + cli.toString() + detail + errorCode + testsInProgress, cause );
}
}
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 e6e5a6eebb..46d1115ba6 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
@@ -19,27 +19,31 @@
* under the License.
*/
+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.report.ConsoleOutputReceiver;
+import org.apache.maven.surefire.report.ReportEntry;
+import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.report.RunListener;
+import org.apache.maven.surefire.report.StackTraceWriter;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.nio.ByteBuffer;
import java.util.NoSuchElementException;
import java.util.Properties;
+import java.util.Queue;
+import java.util.Set;
import java.util.StringTokenizer;
+import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.NotifiableTestStream;
-import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
-import org.apache.maven.shared.utils.cli.StreamConsumer;
-import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
-import org.apache.maven.surefire.report.ConsoleOutputReceiver;
-import org.apache.maven.surefire.report.ReportEntry;
-import org.apache.maven.surefire.report.ReporterException;
-import org.apache.maven.surefire.report.RunListener;
-import org.apache.maven.surefire.report.StackTraceWriter;
-
import static java.lang.Integer.decode;
import static java.lang.Integer.parseInt;
import static java.lang.System.currentTimeMillis;
@@ -52,14 +56,14 @@
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_STDOUT;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_STOP_ON_NEXT_TEST;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_SYSPROPS;
+import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TESTSET_COMPLETED;
+import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TESTSET_STARTING;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_ASSUMPTIONFAILURE;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_ERROR;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_FAILED;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_SKIPPED;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_STARTING;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_SUCCEEDED;
-import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TESTSET_COMPLETED;
-import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TESTSET_STARTING;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_WARNING;
import static org.apache.maven.surefire.booter.Shutdown.KILL;
import static org.apache.maven.surefire.report.CategorizedReportEntry.reportEntry;
@@ -73,7 +77,7 @@
* @author Kristian Rosenvold
*/
public class ForkClient
- implements StreamConsumer
+ implements StreamConsumer
{
private static final long START_TIME_ZERO = 0L;
private static final long START_TIME_NEGATIVE_TIMEOUT = -1L;
@@ -86,6 +90,8 @@ public class ForkClient
private final NotifiableTestStream notifiableTestStream;
+ private final Queue testsInProgress = new ConcurrentLinkedQueue();
+
/**
* testSetStartedAt is set to non-zero after received
* {@link org.apache.maven.surefire.booter.ForkingRunListener#BOOTERCODE_TESTSET_STARTING test-set}.
@@ -185,35 +191,56 @@ private void processLine( String s )
case BOOTERCODE_TESTSET_STARTING:
getOrCreateReporter( channelNumber )
.testSetStarting( createReportEntry( remaining ) );
+
setCurrentStartTime();
break;
case BOOTERCODE_TESTSET_COMPLETED:
+ testsInProgress.clear();
+
getOrCreateReporter( channelNumber )
.testSetCompleted( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_STARTING:
+ ReportEntry reportEntry = createReportEntry( remaining );
+ testsInProgress.offer( reportEntry.getSourceName() );
+
getOrCreateReporter( channelNumber )
.testStarting( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_SUCCEEDED:
+ reportEntry = createReportEntry( remaining );
+ testsInProgress.remove( reportEntry.getSourceName() );
+
getOrCreateReporter( channelNumber )
- .testSucceeded( createReportEntry( remaining ) );
+ .testSucceeded( reportEntry );
break;
case BOOTERCODE_TEST_FAILED:
+ reportEntry = createReportEntry( remaining );
+ testsInProgress.remove( reportEntry.getSourceName() );
+
getOrCreateReporter( channelNumber )
- .testFailed( createReportEntry( remaining ) );
+ .testFailed( reportEntry );
break;
case BOOTERCODE_TEST_SKIPPED:
+ reportEntry = createReportEntry( remaining );
+ testsInProgress.remove( reportEntry.getSourceName() );
+
getOrCreateReporter( channelNumber )
- .testSkipped( createReportEntry( remaining ) );
+ .testSkipped( reportEntry );
break;
case BOOTERCODE_TEST_ERROR:
+ reportEntry = createReportEntry( remaining );
+ testsInProgress.remove( reportEntry.getSourceName() );
+
getOrCreateReporter( channelNumber )
- .testError( createReportEntry( remaining ) );
+ .testError( reportEntry );
break;
case BOOTERCODE_TEST_ASSUMPTIONFAILURE:
+ reportEntry = createReportEntry( remaining );
+ testsInProgress.remove( reportEntry.getSourceName() );
+
getOrCreateReporter( channelNumber )
- .testAssumptionFailure( createReportEntry( remaining ) );
+ .testAssumptionFailure( reportEntry );
break;
case BOOTERCODE_SYSPROPS:
int keyEnd = remaining.indexOf( "," );
@@ -287,19 +314,19 @@ private void writeTestOutput( final int channelNumber, final String remaining, f
{
byte[] convertedBytes = unescaped.array();
getOrCreateConsoleOutputReceiver( channelNumber )
- .writeTestOutput( convertedBytes, unescaped.position(), unescaped.remaining(), isStdout );
+ .writeTestOutput( convertedBytes, unescaped.position(), unescaped.remaining(), isStdout );
}
else
{
byte[] convertedBytes = new byte[unescaped.remaining()];
unescaped.get( convertedBytes, 0, unescaped.remaining() );
getOrCreateConsoleOutputReceiver( channelNumber )
- .writeTestOutput( convertedBytes, 0, convertedBytes.length, isStdout );
+ .writeTestOutput( convertedBytes, 0, convertedBytes.length, isStdout );
}
}
public final void consumeMultiLineContent( String s )
- throws IOException
+ throws IOException
{
BufferedReader stringReader = new BufferedReader( new StringReader( s ) );
for ( String s1 = stringReader.readLine(); s1 != null; s1 = stringReader.readLine() )
@@ -325,7 +352,7 @@ private ReportEntry createReportEntry( String untokenized )
String elapsedStr = tokens.nextToken();
Integer elapsed = "null".equals( elapsedStr ) ? null : decode( elapsedStr );
final StackTraceWriter stackTraceWriter =
- tokens.hasMoreTokens() ? deserializeStackTraceWriter( tokens ) : null;
+ tokens.hasMoreTokens() ? deserializeStackTraceWriter( tokens ) : null;
return reportEntry( source, name, group, stackTraceWriter, elapsed, message );
}
@@ -411,4 +438,14 @@ public final boolean isErrorInFork()
{
return errorInFork != null;
}
+
+ public Set testsInProgress()
+ {
+ return new TreeSet( testsInProgress );
+ }
+
+ public boolean hasTestsInProgress()
+ {
+ return !testsInProgress.isEmpty();
+ }
}
From db251b3915d01539903b684f12d6d69e29b978bb Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Wed, 30 Nov 2016 20:08:36 +0100
Subject: [PATCH 005/194] [SUREFIRE] refactoring - removed unnecessary Java
class-field
---
.../apache/maven/surefire/booter/ProviderConfiguration.java | 5 -----
1 file changed, 5 deletions(-)
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
index b0825a8994..79cbd4258b 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
@@ -41,11 +41,6 @@
*/
public class ProviderConfiguration
{
- /**
- * @noinspection UnusedDeclaration
- */
- public static final int TESTS_SUCCEEDED_EXIT_CODE = 0;
-
private final DirectoryScannerParameters dirScannerParams;
private final ReporterConfiguration reporterConfiguration;
From a1ecfc022de22ac891cfaa95b752869554544122 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Wed, 30 Nov 2016 20:11:48 +0100
Subject: [PATCH 006/194] [SUREFIRE-1310] ForkClient should handle only one
channel-id
---
.../booterclient/output/ForkClient.java | 100 +++++++-----------
.../booterclient/ForkingRunListenerTest.java | 59 ++++++-----
2 files changed, 68 insertions(+), 91 deletions(-)
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 e6e5a6eebb..475b9ffafb 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
@@ -19,29 +19,26 @@
* under the License.
*/
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.nio.ByteBuffer;
-import java.util.NoSuchElementException;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicLong;
-
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.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.RunListener;
import org.apache.maven.surefire.report.StackTraceWriter;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.nio.ByteBuffer;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.concurrent.atomic.AtomicLong;
+
import static java.lang.Integer.decode;
-import static java.lang.Integer.parseInt;
import static java.lang.System.currentTimeMillis;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_BYE;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_CONSOLE;
@@ -52,14 +49,14 @@
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_STDOUT;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_STOP_ON_NEXT_TEST;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_SYSPROPS;
+import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TESTSET_COMPLETED;
+import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TESTSET_STARTING;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_ASSUMPTIONFAILURE;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_ERROR;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_FAILED;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_SKIPPED;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_STARTING;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TEST_SUCCEEDED;
-import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TESTSET_COMPLETED;
-import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_TESTSET_STARTING;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_WARNING;
import static org.apache.maven.surefire.booter.Shutdown.KILL;
import static org.apache.maven.surefire.report.CategorizedReportEntry.reportEntry;
@@ -78,7 +75,7 @@ public class ForkClient
private static final long START_TIME_ZERO = 0L;
private static final long START_TIME_NEGATIVE_TIMEOUT = -1L;
- private final ConcurrentMap testSetReporters;
+ private final RunListener testSetReporter;
private final DefaultReporterFactory defaultReporterFactory;
@@ -101,7 +98,7 @@ public class ForkClient
public ForkClient( DefaultReporterFactory defaultReporterFactory, Properties testVmSystemProperties,
NotifiableTestStream notifiableTestStream, ConsoleLogger log )
{
- testSetReporters = new ConcurrentHashMap();
+ testSetReporter = defaultReporterFactory.createReporter();
this.defaultReporterFactory = defaultReporterFactory;
this.testVmSystemProperties = testVmSystemProperties;
this.notifiableTestStream = notifiableTestStream;
@@ -176,44 +173,35 @@ private void processLine( String s )
log.warning( s );
return;
}
- final int channelNumber = parseInt( s.substring( 2, comma ), 16 );
int rest = s.indexOf( ",", comma );
final String remaining = s.substring( rest + 1 );
switch ( operationId )
{
case BOOTERCODE_TESTSET_STARTING:
- getOrCreateReporter( channelNumber )
- .testSetStarting( createReportEntry( remaining ) );
+ testSetReporter.testSetStarting( createReportEntry( remaining ) );
setCurrentStartTime();
break;
case BOOTERCODE_TESTSET_COMPLETED:
- getOrCreateReporter( channelNumber )
- .testSetCompleted( createReportEntry( remaining ) );
+ testSetReporter.testSetCompleted( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_STARTING:
- getOrCreateReporter( channelNumber )
- .testStarting( createReportEntry( remaining ) );
+ testSetReporter.testStarting( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_SUCCEEDED:
- getOrCreateReporter( channelNumber )
- .testSucceeded( createReportEntry( remaining ) );
+ testSetReporter.testSucceeded( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_FAILED:
- getOrCreateReporter( channelNumber )
- .testFailed( createReportEntry( remaining ) );
+ testSetReporter.testFailed( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_SKIPPED:
- getOrCreateReporter( channelNumber )
- .testSkipped( createReportEntry( remaining ) );
+ testSetReporter.testSkipped( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_ERROR:
- getOrCreateReporter( channelNumber )
- .testError( createReportEntry( remaining ) );
+ testSetReporter.testError( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_ASSUMPTIONFAILURE:
- getOrCreateReporter( channelNumber )
- .testAssumptionFailure( createReportEntry( remaining ) );
+ testSetReporter.testAssumptionFailure( createReportEntry( remaining ) );
break;
case BOOTERCODE_SYSPROPS:
int keyEnd = remaining.indexOf( "," );
@@ -227,13 +215,13 @@ private void processLine( String s )
}
break;
case BOOTERCODE_STDOUT:
- writeTestOutput( channelNumber, remaining, true );
+ writeTestOutput( remaining, true );
break;
case BOOTERCODE_STDERR:
- writeTestOutput( channelNumber, remaining, false );
+ writeTestOutput( remaining, false );
break;
case BOOTERCODE_CONSOLE:
- getOrCreateConsoleLogger( channelNumber )
+ getOrCreateConsoleLogger()
.info( createConsoleMessage( remaining ) );
break;
case BOOTERCODE_NEXT_TEST:
@@ -249,11 +237,11 @@ private void processLine( String s )
stopOnNextTest();
break;
case BOOTERCODE_DEBUG:
- getOrCreateConsoleLogger( channelNumber )
+ getOrCreateConsoleLogger()
.debug( createConsoleMessage( remaining ) );
break;
case BOOTERCODE_WARNING:
- getOrCreateConsoleLogger( channelNumber )
+ getOrCreateConsoleLogger()
.warning( createConsoleMessage( remaining ) );
break;
default:
@@ -276,7 +264,7 @@ private void processLine( String s )
}
}
- private void writeTestOutput( final int channelNumber, final String remaining, final boolean isStdout )
+ private void writeTestOutput( String remaining, boolean isStdout )
{
int csNameEnd = remaining.indexOf( ',' );
String charsetName = remaining.substring( 0, csNameEnd );
@@ -286,14 +274,14 @@ private void writeTestOutput( final int channelNumber, final String remaining, f
if ( unescaped.hasArray() )
{
byte[] convertedBytes = unescaped.array();
- getOrCreateConsoleOutputReceiver( channelNumber )
+ getOrCreateConsoleOutputReceiver()
.writeTestOutput( convertedBytes, unescaped.position(), unescaped.remaining(), isStdout );
}
else
{
byte[] convertedBytes = new byte[unescaped.remaining()];
unescaped.get( convertedBytes, 0, unescaped.remaining() );
- getOrCreateConsoleOutputReceiver( channelNumber )
+ getOrCreateConsoleOutputReceiver()
.writeTestOutput( convertedBytes, 0, convertedBytes.length, isStdout );
}
}
@@ -359,37 +347,21 @@ private String unescape( String source )
/**
* Used when getting reporters on the plugin side of a fork.
*
- * @param channelNumber The logical channel number
* @return A mock provider reporter
*/
- public final RunListener getReporter( int channelNumber )
+ public final RunListener getReporter()
{
- return testSetReporters.get( channelNumber );
- }
-
- private RunListener getOrCreateReporter( int channelNumber )
- {
- RunListener reporter = testSetReporters.get( channelNumber );
- if ( reporter == null )
- {
- reporter = defaultReporterFactory.createReporter();
- RunListener old = testSetReporters.putIfAbsent( channelNumber, reporter );
- if ( old != null )
- {
- reporter = old;
- }
- }
- return reporter;
+ return testSetReporter;
}
- private ConsoleOutputReceiver getOrCreateConsoleOutputReceiver( int channelNumber )
+ private ConsoleOutputReceiver getOrCreateConsoleOutputReceiver()
{
- return (ConsoleOutputReceiver) getOrCreateReporter( channelNumber );
+ return (ConsoleOutputReceiver) testSetReporter;
}
- private ConsoleLogger getOrCreateConsoleLogger( int channelNumber )
+ private ConsoleLogger getOrCreateConsoleLogger()
{
- return (ConsoleLogger) getOrCreateReporter( channelNumber );
+ return (ConsoleLogger) testSetReporter;
}
public void close( boolean hadTimeout )
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java
index 5b8867b54a..19356f59e4 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java
@@ -19,19 +19,14 @@
* under the License.
*/
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.nio.charset.Charset;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.NotifiableTestStream;
import org.apache.maven.plugin.surefire.booterclient.output.ForkClient;
-import org.apache.maven.surefire.booter.ForkingRunListener;
-import org.apache.maven.surefire.report.CategorizedReportEntry;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
+import org.apache.maven.surefire.booter.ForkingRunListener;
+import org.apache.maven.surefire.report.CategorizedReportEntry;
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
import org.apache.maven.surefire.report.LegacyPojoStackTraceWriter;
import org.apache.maven.surefire.report.ReportEntry;
@@ -40,12 +35,17 @@
import org.apache.maven.surefire.report.SimpleReportEntry;
import org.apache.maven.surefire.report.StackTraceWriter;
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author Kristian Rosenvold
@@ -53,10 +53,9 @@
public class ForkingRunListenerTest
extends TestCase
{
+ private final ByteArrayOutputStream content, anotherContent;
- private final ByteArrayOutputStream content;
-
- private final PrintStream printStream;
+ private final PrintStream printStream, anotherPrintStream;
final int defaultChannel = 17;
@@ -64,8 +63,11 @@ public class ForkingRunListenerTest
public ForkingRunListenerTest()
{
- this.content = new ByteArrayOutputStream();
+ content = new ByteArrayOutputStream();
printStream = new PrintStream( content );
+
+ anotherContent = new ByteArrayOutputStream();
+ anotherPrintStream = new PrintStream( anotherContent );
}
private void reset()
@@ -74,7 +76,6 @@ private void reset()
content.reset();
}
-
public void testHeaderCreation()
{
final byte[] header = ForkingRunListener.createHeader( (byte) 'F', 0xCAFE );
@@ -253,7 +254,7 @@ public void testMultipleEntries()
forkStreamClient.consumeMultiLineContent( content.toString( "utf-8" ) );
- final MockReporter reporter = (MockReporter) forkStreamClient.getReporter( defaultChannel );
+ final MockReporter reporter = (MockReporter) forkStreamClient.getReporter();
final List events = reporter.getEvents();
assertEquals( MockReporter.SET_STARTING, events.get( 0 ) );
assertEquals( MockReporter.TEST_STARTING, events.get( 1 ) );
@@ -271,21 +272,25 @@ public void test2DifferentChannels()
new ForkingRunListener( printStream, defaultChannel, false )
.testStarting( expected );
- new ForkingRunListener( printStream, anotherChannel, false )
+ new ForkingRunListener( anotherPrintStream, anotherChannel, false )
.testSkipped( secondExpected );
TestSetMockReporterFactory providerReporterFactory = new TestSetMockReporterFactory();
+ Properties vmProps = new Properties();
+ NotifiableTestStream notifiableTestStream = new MockNotifiableTestStream();
NullConsoleLogger log = new NullConsoleLogger();
- final ForkClient forkStreamClient = new ForkClient( providerReporterFactory, new Properties(),
- new MockNotifiableTestStream(), log );
+
+ ForkClient forkStreamClient = new ForkClient( providerReporterFactory, vmProps, notifiableTestStream, log );
forkStreamClient.consumeMultiLineContent( content.toString( "utf-8" ) );
- MockReporter reporter = (MockReporter) forkStreamClient.getReporter( defaultChannel );
+ MockReporter reporter = (MockReporter) forkStreamClient.getReporter();
Assert.assertEquals( MockReporter.TEST_STARTING, reporter.getFirstEvent() );
Assert.assertEquals( expected, reporter.getFirstData() );
Assert.assertEquals( 1, reporter.getEvents().size() );
- MockReporter reporter2 = (MockReporter) forkStreamClient.getReporter( anotherChannel );
+ forkStreamClient = new ForkClient( providerReporterFactory, vmProps, notifiableTestStream, log );
+ forkStreamClient.consumeMultiLineContent( anotherContent.toString( "utf-8" ) );
+ MockReporter reporter2 = (MockReporter) forkStreamClient.getReporter();
Assert.assertEquals( MockReporter.TEST_SKIPPED, reporter2.getFirstEvent() );
Assert.assertEquals( secondExpected, reporter2.getFirstData() );
Assert.assertEquals( 1, reporter2.getEvents().size() );
@@ -331,9 +336,9 @@ private SimpleReportEntry createReportEntryWithSpecialMessage( String message )
}
}
- private RunListener createForkingRunListener( Integer testSetCHannel )
+ private RunListener createForkingRunListener( Integer testSetChannel )
{
- return new ForkingRunListener( printStream, testSetCHannel, false );
+ return new ForkingRunListener( printStream, testSetChannel, false );
}
private class StandardTestRun
@@ -355,7 +360,7 @@ public void clientReceiveContent()
final ForkClient forkStreamClient = new ForkClient( providerReporterFactory, new Properties(),
new MockNotifiableTestStream(), log );
forkStreamClient.consumeMultiLineContent( content.toString( ) );
- reporter = (MockReporter) forkStreamClient.getReporter( defaultChannel );
+ reporter = (MockReporter) forkStreamClient.getReporter();
}
public String getFirstEvent()
From 648c967171bb94c262c15fc5393ba813c313cdfb Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Wed, 30 Nov 2016 23:13:07 +0100
Subject: [PATCH 007/194] Merge branch 'master' of
https://github.com/apache/maven-surefire into SUREFIRE-1295
Conflicts:
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
---
.../booterclient/output/ForkClient.java | 4 +
.../src/site/apt/examples/shutdown.apt.vm | 8 +-
maven-surefire-plugin/src/site/fml/faq.fml | 10 ++
...efire1295AttributeJvmCrashesToTestsIT.java | 117 ++++++++++++++++++
.../test/resources/crash-during-test/pom.xml | 65 ++++++++++
.../java/junit44/environment/BasicTest.java | 52 ++++++++
.../junit44/environment/SomeOtherTest.java | 28 +++++
7 files changed, 283 insertions(+), 1 deletion(-)
create mode 100644 surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
create mode 100644 surefire-integration-tests/src/test/resources/crash-during-test/pom.xml
create mode 100644 surefire-integration-tests/src/test/resources/crash-during-test/src/test/java/junit44/environment/BasicTest.java
create mode 100644 surefire-integration-tests/src/test/resources/crash-during-test/src/test/java/junit44/environment/SomeOtherTest.java
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 1472aa467f..898a165e02 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
@@ -35,7 +35,11 @@
import java.nio.ByteBuffer;
import java.util.NoSuchElementException;
import java.util.Properties;
+import java.util.Queue;
+import java.util.Set;
import java.util.StringTokenizer;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicLong;
import static java.lang.Integer.decode;
diff --git a/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm b/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm
index 7e943a5aeb..9257c42b89 100644
--- a/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm
@@ -85,4 +85,10 @@ Shutdown of Forked JVM
amount of time and the whole plugin fails with the error message:
<<>>
-
+
+
+* Crashed forked JVM caused listing the crashed test(s)
+
+ After the JVM exited abruptly, the console lists the message <<>> if the entire
+ test-set has not been yet completed. This happens if a test exited, killed JVM or segmentation fault crashed JVM.
+
diff --git a/maven-surefire-plugin/src/site/fml/faq.fml b/maven-surefire-plugin/src/site/fml/faq.fml
index 6be79138d8..de736dd778 100644
--- a/maven-surefire-plugin/src/site/fml/faq.fml
+++ b/maven-surefire-plugin/src/site/fml/faq.fml
@@ -67,6 +67,16 @@ under the License.
+
+ Crashed Surefire or Failsafe plugin must indicate crashed tests
+
+
+ After a forked JVM has crashed the console of forked JVM prints Crashed tests: and lists the last test
+ which has crashed. In the console log you can find the message
+ The forked VM terminated without properly saying goodbye.
+
+
+ How can I run GWT tests?
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
new file mode 100644
index 0000000000..94532b9c28
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
@@ -0,0 +1,117 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.it.VerificationException;
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.SurefireLauncher;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Iterator;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeFalse;
+
+/**
+ * https://issues.apache.org/jira/browse/SUREFIRE-1295
+ * https://github.com/apache/maven-surefire/pull/136
+ *
+ * @author michaeltandy
+ * @since 2.19.2
+ */
+public class Surefire1295AttributeJvmCrashesToTestsIT
+ extends SurefireJUnit4IntegrationTestCase
+{
+ @Before
+ public void skipWindows()
+ {
+ assumeFalse( System.getProperty( "os.name" ).startsWith( "Windows" ) );
+ }
+
+ @Test
+ public void crashInFork() throws VerificationException
+ {
+ SurefireLauncher launcher = unpack( "crash-during-test" );
+
+ checkCrashTypes( launcher );
+ }
+
+ @Test
+ public void crashInSingleUseFork() throws VerificationException
+ {
+ SurefireLauncher launcher = unpack( "crash-during-test" )
+ .forkCount( 1 )
+ .reuseForks( false );
+
+ checkCrashTypes( launcher );
+ }
+
+ @Test
+ public void crashInReusableFork() throws VerificationException
+ {
+ SurefireLauncher launcher = unpack( "crash-during-test" )
+ .forkOncePerThread()
+ .threadCount( 1 );
+
+ checkCrashTypes( launcher );
+ }
+
+ private static void checkCrashTypes( SurefireLauncher launcher )
+ throws VerificationException
+ {
+ checkCrash( launcher.addGoal( "-DcrashType=exit" ) );
+ checkCrash( launcher.addGoal( "-DcrashType=abort" ) );
+ checkCrash( launcher.addGoal( "-DcrashType=segfault" ) );
+ }
+
+ private static void checkCrash( SurefireLauncher launcher ) throws VerificationException
+ {
+ OutputValidator validator = launcher.maven()
+ .withFailure()
+ .executeTest()
+ .verifyTextInLog( "The forked VM terminated without properly saying "
+ + "goodbye. VM crash or System.exit called?"
+ )
+ .verifyTextInLog( "Crashed tests:" );
+
+ for ( Iterator it = validator.loadLogLines().iterator(); it.hasNext(); )
+ {
+ String line = it.next();
+ if ( line.contains( "Crashed tests:" ) )
+ {
+ line = it.next();
+ if ( it.hasNext() )
+ {
+ assertThat( line ).contains( "junit44.environment.BasicTest" );
+ }
+ else
+ {
+ fail( "Could not find any line after 'Crashed tests:'." );
+ }
+ }
+ }
+
+ }
+
+
+}
diff --git a/surefire-integration-tests/src/test/resources/crash-during-test/pom.xml b/surefire-integration-tests/src/test/resources/crash-during-test/pom.xml
new file mode 100644
index 0000000000..38134bdcb7
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/crash-during-test/pom.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+ org.apache.maven.surefire
+ it-parent
+ 1.0
+ ../pom.xml
+
+
+ 4.0.0
+ org.apache.maven.plugins.surefire
+ crash-during-test
+ 1.0-SNAPSHOT
+ Tests vm crash while a test is in progress
+
+
+
+ junit
+ junit
+ 4.4
+ test
+
+
+ uk.me.mjt
+ crashjvm
+ 1.0
+ test
+ jar
+
+
+
+
+
+
+ maven-surefire-plugin
+ ${surefire.version}
+
+ once
+
+
+
+
+
+
diff --git a/surefire-integration-tests/src/test/resources/crash-during-test/src/test/java/junit44/environment/BasicTest.java b/surefire-integration-tests/src/test/resources/crash-during-test/src/test/java/junit44/environment/BasicTest.java
new file mode 100644
index 0000000000..57d57bb59c
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/crash-during-test/src/test/java/junit44/environment/BasicTest.java
@@ -0,0 +1,52 @@
+package junit44.environment;
+
+/*
+ * 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 static org.junit.Assert.*;
+import org.junit.Test;
+import uk.me.mjt.CrashJvm;
+
+public class BasicTest
+{
+ @Test
+ public void testCrashJvm()
+ {
+ assertTrue(CrashJvm.loadedOk());
+
+ String crashType = System.getProperty("crashType");
+ assertNotNull(crashType);
+ if ( crashType.equals( "exit" ) )
+ {
+ CrashJvm.exit();
+ }
+ else if ( crashType.equals( "abort" ) )
+ {
+ CrashJvm.abort();
+ }
+ else if (crashType.equals( "segfault" ))
+ {
+ CrashJvm.segfault();
+ }
+ else
+ {
+ fail("Don't recognise crashType " + crashType);
+ }
+ }
+}
diff --git a/surefire-integration-tests/src/test/resources/crash-during-test/src/test/java/junit44/environment/SomeOtherTest.java b/surefire-integration-tests/src/test/resources/crash-during-test/src/test/java/junit44/environment/SomeOtherTest.java
new file mode 100644
index 0000000000..e10f6aa33a
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/crash-during-test/src/test/java/junit44/environment/SomeOtherTest.java
@@ -0,0 +1,28 @@
+
+package junit44.environment;
+
+/*
+ * 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.junit.Test;
+
+public class SomeOtherTest {
+ @Test
+ public void nonCrashingTest() {}
+}
From 392f8b2f5d4d966d4868ccca4e40195a5154ac58 Mon Sep 17 00:00:00 2001
From: Benedikt Ritter
Date: Tue, 22 Nov 2016 22:19:35 +0100
Subject: [PATCH 008/194] [SUREFIRE-1308] Move Surefire1179IT to jiras package
---
.../apache/maven/surefire/its/{ => jiras}/Surefire1179IT.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/{ => jiras}/Surefire1179IT.java (96%)
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire1179IT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java
similarity index 96%
rename from surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire1179IT.java
rename to surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java
index d29ccf9336..e4e8e31bb0 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire1179IT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.its;
+package org.apache.maven.surefire.its.jiras;
/*
* Licensed to the Apache Software Foundation (ASF) under one
From 15b953000afc26ca3844af7d18fd7b3c9ad26cd5 Mon Sep 17 00:00:00 2001
From: Benedikt Ritter
Date: Tue, 22 Nov 2016 21:05:13 +0100
Subject: [PATCH 009/194] SUREFIRE-1306: JUnit4RerunFailingTestsIT does not
execute with the JUnit version configured in the test
Drop the junitVersion property from pom.xml and let the test execute
with the latest JUnit 4.12 currently available.
---
.../its/JUnit4RerunFailingTestsIT.java | 40 +++++++++----------
.../junit4-rerun-failing-tests/pom.xml | 7 +---
2 files changed, 21 insertions(+), 26 deletions(-)
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java
index 47fb71a057..c6c6b8f38e 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java
@@ -42,22 +42,22 @@ public void testRerunFailingErrorTestsWithOneRetry()
throws Exception
{
OutputValidator outputValidator =
- unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0,
0 );
verifyFailuresOneRetryAllClasses( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal(
"-DforkCount=2" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 );
verifyFailuresOneRetryAllClasses( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-Dparallel=methods" ).addGoal(
"-DuseUnlimitedThreads=true" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 );
verifyFailuresOneRetryAllClasses( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-Dparallel=classes" ).addGoal(
"-DuseUnlimitedThreads=true" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 );
verifyFailuresOneRetryAllClasses( outputValidator );
@@ -69,24 +69,24 @@ public void testRerunFailingErrorTestsTwoRetry()
{
// Four flakes, both tests have been re-run twice
OutputValidator outputValidator =
- unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=2" ).executeTest().assertTestSuiteResults( 5, 0, 0, 0, 4 );
verifyFailuresTwoRetryAllClasses( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=2" ).addGoal( "-DforkCount=3" ).executeTest()
.assertTestSuiteResults( 5, 0, 0, 0, 4 );
verifyFailuresTwoRetryAllClasses( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=2" ).addGoal( "-Dparallel=methods" ).addGoal(
"-DuseUnlimitedThreads=true" ).executeTest().assertTestSuiteResults( 5, 0, 0, 0, 4 );
verifyFailuresTwoRetryAllClasses( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=2" ).addGoal( "-Dparallel=classes" ).addGoal(
"-DuseUnlimitedThreads=true" ).executeTest().assertTestSuiteResults( 5, 0, 0, 0, 4 );
@@ -98,22 +98,22 @@ public void testRerunFailingErrorTestsFalse()
throws Exception
{
OutputValidator outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion(
- "4.7" ).maven().withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 );
+ "4.12" ).maven().withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 );
verifyFailuresNoRetryAllClasses( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-DforkCount=3" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 );
verifyFailuresNoRetryAllClasses( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dparallel=methods" ).addGoal(
"-DuseUnlimitedThreads=true" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 );
verifyFailuresNoRetryAllClasses( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dparallel=classes" ).addGoal(
"-DuseUnlimitedThreads=true" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 );
@@ -125,26 +125,26 @@ public void testRerunOneTestClass()
throws Exception
{
OutputValidator outputValidator =
- unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal(
"-Dtest=FlakyFirstTimeTest" ).withFailure().executeTest().assertTestSuiteResults( 3, 1, 1, 0, 0 );
verifyFailuresOneRetryOneClass( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-DforkCount=3" ).addGoal(
"-Dtest=FlakyFirstTimeTest" ).withFailure().executeTest().assertTestSuiteResults( 3, 1, 1, 0, 0 );
verifyFailuresOneRetryOneClass( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-Dparallel=methods" ).addGoal(
"-DuseUnlimitedThreads=true" ).addGoal(
"-Dtest=FlakyFirstTimeTest" ).withFailure().executeTest().assertTestSuiteResults( 3, 1, 1, 0, 0 );
verifyFailuresOneRetryOneClass( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-Dparallel=classes" ).addGoal(
"-DuseUnlimitedThreads=true" ).addGoal(
"-Dtest=FlakyFirstTimeTest" ).withFailure().executeTest().assertTestSuiteResults( 3, 1, 1, 0, 0 );
@@ -157,21 +157,21 @@ public void testRerunOneTestMethod()
throws Exception
{
OutputValidator outputValidator =
- unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal(
"-Dtest=FlakyFirstTimeTest#testFailing*" ).withFailure().executeTest().assertTestSuiteResults( 1, 0, 1,
0, 0 );
verifyFailuresOneRetryOneMethod( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-DforkCount=3" ).addGoal(
"-Dtest=FlakyFirstTimeTest#testFailing*" ).withFailure().executeTest().assertTestSuiteResults( 1, 0, 1, 0,
0 );
verifyFailuresOneRetryOneMethod( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-Dparallel=methods" ).addGoal(
"-DuseUnlimitedThreads=true" ).addGoal(
"-Dtest=FlakyFirstTimeTest#testFailing*" ).withFailure().executeTest().assertTestSuiteResults( 1, 0, 1, 0,
@@ -179,7 +179,7 @@ public void testRerunOneTestMethod()
verifyFailuresOneRetryOneMethod( outputValidator );
- outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.7" ).maven().addGoal(
+ outputValidator = unpack().addGoal( "-Dprovider=surefire-junit4" ).setJUnitVersion( "4.12" ).maven().addGoal(
"-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-Dparallel=classes" ).addGoal(
"-DuseUnlimitedThreads=true" ).addGoal(
"-Dtest=FlakyFirstTimeTest#testFailing*" ).withFailure().executeTest().assertTestSuiteResults( 1, 0, 1, 0,
diff --git a/surefire-integration-tests/src/test/resources/junit4-rerun-failing-tests/pom.xml b/surefire-integration-tests/src/test/resources/junit4-rerun-failing-tests/pom.xml
index 7482811350..5652336780 100644
--- a/surefire-integration-tests/src/test/resources/junit4-rerun-failing-tests/pom.xml
+++ b/surefire-integration-tests/src/test/resources/junit4-rerun-failing-tests/pom.xml
@@ -28,16 +28,11 @@
1.0-SNAPSHOTTest for rerun failing tests in JUnit 4
-
-
- 4.4
-
-
junitjunit
- ${junitVersion}
+ ${junit.version}test
From 195e4833ca7abb0278d34bff94cd7669d5331e45 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Thu, 1 Dec 2016 00:35:01 +0100
Subject: [PATCH 010/194] [SUREFIRE-1306] JUnit4RerunFailingTestsIT does not
execute with the JUnit version configured in the test
---
.../surefire/common/junit4/JUnitTestFailureListener.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java
index e6fe2dee32..2585f50038 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java
@@ -39,7 +39,10 @@ public class JUnitTestFailureListener
public void testFailure( Failure failure )
throws Exception
{
- allFailures.add( failure );
+ if ( failure != null )
+ {
+ allFailures.add( failure );
+ }
}
public List getAllFailures()
From c2a7d4b7f28b0fb5456b9871fd87cbac5c70cbd3 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Fri, 2 Dec 2016 02:51:07 +0100
Subject: [PATCH 011/194] [SUREFIRE-1305] surefire fails on parallel tests when
newline character is in test description
---
.../surefire/common/junit4/JUnit4RunListener.java | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
index d3aa9a4e07..85e2acd94a 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
@@ -44,11 +44,7 @@
public class JUnit4RunListener
extends org.junit.runner.notification.RunListener
{
- private static final Pattern PARENS = Pattern.compile( "^" + ".+" //any character
- + "\\(("
- // then an open-paren (start matching a group)
- + "[^\\\\(\\\\)]+" //non-parens
- + ")\\)" + "$" );
+ private static final Pattern METHOD_CLASS_PATTERN = Pattern.compile( "([\\s\\S]*)\\((.*)\\)" );
protected final RunListener reporter;
@@ -188,8 +184,8 @@ protected SimpleReportEntry createReportEntry( Description description )
public static String extractClassName( Description description )
{
String displayName = description.getDisplayName();
- Matcher m = PARENS.matcher( displayName );
- return m.find() ? m.group( 1 ) : displayName;
+ Matcher m = METHOD_CLASS_PATTERN.matcher( displayName );
+ return m.matches() ? m.group( 2 ) : displayName;
}
public static String extractMethodName( Description description )
From d9b577cdc991d09116282d89ca69b5d2768acb0e Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Fri, 2 Dec 2016 04:36:13 +0100
Subject: [PATCH 012/194] [SUREFIRE-1311] JUnit47 provider should not
internally parse JUnit Description
---
.../common/junit4/JUnit4RunListener.java | 18 ++++++++++---
.../common/junit4/JUnit4StackTraceWriter.java | 14 +++++-----
surefire-providers/common-junit48/pom.xml | 6 +++++
.../junit48/JUnit46StackTraceWriter.java | 9 ++++---
.../junitcore/JUnitCoreRunListener.java | 18 ++++++++++---
.../junitcore/NonConcurrentRunListener.java | 26 ++++++++++++++-----
6 files changed, 68 insertions(+), 23 deletions(-)
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
index 85e2acd94a..dd004fa706 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
@@ -120,7 +120,7 @@ public void testFailure( Failure failure )
failureFlag.set( true );
}
- @SuppressWarnings( { "UnusedDeclaration" } )
+ @SuppressWarnings( "UnusedDeclaration" )
public void testAssumptionFailure( Failure failure )
{
Description desc = failure.getDescription();
@@ -152,16 +152,16 @@ public void testExecutionSkippedByUser()
reporter.testExecutionSkippedByUser();
}
- private static String getClassName( Description description )
+ private String getClassName( Description description )
{
- String name = extractClassName( description );
+ String name = extractDescriptionClassName( description );
if ( name == null || isInsaneJunitNullString( name ) )
{
// This can happen upon early failures (class instantiation error etc)
Description subDescription = description.getChildren().get( 0 );
if ( subDescription != null )
{
- name = extractClassName( subDescription );
+ name = extractDescriptionClassName( subDescription );
}
if ( name == null )
{
@@ -181,6 +181,16 @@ protected SimpleReportEntry createReportEntry( Description description )
return new SimpleReportEntry( getClassName( description ), description.getDisplayName() );
}
+ protected String extractDescriptionClassName( Description description )
+ {
+ return extractClassName( description );
+ }
+
+ protected String extractDescriptionMethodName( Description description )
+ {
+ return extractMethodName( description );
+ }
+
public static String extractClassName( Description description )
{
String displayName = description.getDisplayName();
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
index 8292d4b8c2..a4690ca79d 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
@@ -22,9 +22,12 @@
import org.apache.maven.surefire.report.SafeThrowable;
import org.apache.maven.surefire.report.SmartStackTraceParser;
import org.apache.maven.surefire.report.StackTraceWriter;
-
import org.junit.runner.notification.Failure;
+import static org.apache.maven.surefire.common.junit4.JUnit4RunListener.extractClassName;
+import static org.apache.maven.surefire.common.junit4.JUnit4RunListener.extractMethodName;
+import static org.apache.maven.surefire.report.SmartStackTraceParser.stackTraceWithFocusOnClassAsString;
+
/**
* Writes out a specific {@link org.junit.runner.notification.Failure} for
* surefire as a stacktrace.
@@ -74,15 +77,14 @@ public String writeTraceToString()
return "";
}
-
protected String getTestClassName()
{
- return JUnit4RunListener.extractClassName( junitFailure.getDescription() );
+ return extractClassName( junitFailure.getDescription() );
}
protected String getTestMethodName()
{
- return JUnit4RunListener.extractMethodName( junitFailure.getDescription() );
+ return extractMethodName( junitFailure.getDescription() );
}
@SuppressWarnings( "ThrowableResultOfMethodCallIgnored" )
@@ -105,11 +107,11 @@ public String writeTrimmedTraceToString()
try
{
Throwable e = junitFailure.getException();
- return SmartStackTraceParser.stackTraceWithFocusOnClassAsString( e, testClass );
+ return stackTraceWithFocusOnClassAsString( e, testClass );
}
catch ( Throwable t )
{
- return SmartStackTraceParser.stackTraceWithFocusOnClassAsString( t, testClass );
+ return stackTraceWithFocusOnClassAsString( t, testClass );
}
}
diff --git a/surefire-providers/common-junit48/pom.xml b/surefire-providers/common-junit48/pom.xml
index 5cd10fab28..e6e697619d 100644
--- a/surefire-providers/common-junit48/pom.xml
+++ b/surefire-providers/common-junit48/pom.xml
@@ -42,6 +42,12 @@
org.apache.maven.surefirecommon-junit4${project.version}
+
+
+ junit
+ junit
+
+ org.apache.maven.surefire
diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
index 72f0b007c8..c7f2bd7f6e 100644
--- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
+++ b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
@@ -19,9 +19,7 @@
* under the License.
*/
-import org.apache.maven.surefire.common.junit4.JUnit4RunListener;
import org.apache.maven.surefire.common.junit4.JUnit4StackTraceWriter;
-
import org.junit.runner.notification.Failure;
/**
@@ -50,6 +48,11 @@ public JUnit46StackTraceWriter( Failure junitFailure )
protected final String getTestClassName()
{
- return JUnit4RunListener.extractClassName( junitFailure.getDescription() );
+ return junitFailure.getDescription().getClassName();
+ }
+
+ protected String getTestMethodName()
+ {
+ return junitFailure.getDescription().getMethodName();
}
}
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
index 5d76c39b2c..81e4f80885 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
@@ -87,17 +87,17 @@ private void fillTestCountMap( Description description )
}
else
{
- if ( item.getMethodName() != null )
+ if ( extractDescriptionMethodName( item ) != null )
{
testSet.incrementTestMethodCount();
if ( itemTestClassName == null )
{
- itemTestClassName = item.getClassName();
+ itemTestClassName = extractDescriptionClassName( item );
}
}
else
{
- classMethodCounts.put( item.getClassName(), new TestSet( item ) );
+ classMethodCounts.put( extractDescriptionClassName( item ), new TestSet( item ) );
}
}
}
@@ -112,4 +112,16 @@ protected StackTraceWriter createStackTraceWriter( Failure failure )
{
return new JUnit46StackTraceWriter( failure );
}
+
+ @Override
+ protected String extractDescriptionClassName( Description description )
+ {
+ return description.getClassName();
+ }
+
+ @Override
+ protected String extractDescriptionMethodName( Description description )
+ {
+ return description.getMethodName();
+ }
}
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
index 9d4e9c15e7..539fd73484 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
@@ -37,7 +37,6 @@ public class NonConcurrentRunListener
extends JUnit4RunListener
implements ConsoleOutputReceiver
{
-
private Description currentTestSetDescription;
private Description lastFinishedDescription;
@@ -56,12 +55,25 @@ public synchronized void writeTestOutput( byte[] buf, int off, int len, boolean
protected SimpleReportEntry createReportEntry( Description description )
{
- return new SimpleReportEntry( description.getClassName(), description.getDisplayName() );
+ return new SimpleReportEntry( extractDescriptionClassName( description ), description.getDisplayName() );
}
protected SimpleReportEntry createReportEntryForTestSet( Description description )
{
- return new SimpleReportEntry( description.getClassName(), description.getClassName() );
+ String testClassName = extractDescriptionClassName( description );
+ return new SimpleReportEntry( testClassName, testClassName );
+ }
+
+ @Override
+ protected String extractDescriptionClassName( Description description )
+ {
+ return description.getClassName();
+ }
+
+ @Override
+ protected String extractDescriptionMethodName( Description description )
+ {
+ return description.getMethodName();
}
@Override
@@ -110,7 +122,7 @@ public void testFinished( Description description )
throws Exception
{
super.testFinished( description );
- this.lastFinishedDescription = description;
+ lastFinishedDescription = description;
}
@Override
@@ -120,7 +132,7 @@ public void testIgnored( Description description )
finishLastTestSetIfNecessary( description );
super.testIgnored( description );
- this.lastFinishedDescription = description;
+ lastFinishedDescription = description;
}
@Override
@@ -130,14 +142,14 @@ public void testFailure( Failure failure )
finishLastTestSetIfNecessary( failure.getDescription() );
super.testFailure( failure );
- this.lastFinishedDescription = failure.getDescription();
+ lastFinishedDescription = failure.getDescription();
}
@Override
public void testAssumptionFailure( Failure failure )
{
super.testAssumptionFailure( failure );
- this.lastFinishedDescription = failure.getDescription();
+ lastFinishedDescription = failure.getDescription();
}
@Override
From 569e75452b1180251190c34713714bb4ac515d0e Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 3 Dec 2016 20:57:21 +0100
Subject: [PATCH 013/194] [SUREFIRE] moved UrlUtils to internal package
---
.../plugin/surefire/booterclient/ForkConfiguration.java | 5 +++--
.../maven/surefire/util/{ => internal}/UrlUtils.java | 7 ++++---
.../java/org/apache/maven/surefire/util/UrlUtilsTest.java | 6 ++++--
.../java/org/apache/maven/surefire/booter/Classpath.java | 5 ++---
4 files changed, 13 insertions(+), 10 deletions(-)
rename surefire-api/src/main/java/org/apache/maven/surefire/util/{ => internal}/UrlUtils.java (93%)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 036ec561bd..6d43bd291e 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -27,7 +27,6 @@
import org.apache.maven.surefire.booter.ForkedBooter;
import org.apache.maven.surefire.booter.StartupConfiguration;
import org.apache.maven.surefire.booter.SurefireBooterForkException;
-import org.apache.maven.surefire.util.UrlUtils;
import java.io.File;
import java.io.FileOutputStream;
@@ -40,6 +39,8 @@
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
+import static org.apache.maven.surefire.util.internal.UrlUtils.toURL;
+
/**
* Configuration for forking tests.
*
@@ -287,7 +288,7 @@ private File createJar( List classPath, String startClassName )
for ( String el : classPath )
{
// NOTE: if File points to a directory, this entry MUST end in '/'.
- cp.append( UrlUtils.getURL( new File( el ) ).toExternalForm() )
+ cp.append( toURL( new File( el ) ).toExternalForm() )
.append( " " );
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java
similarity index 93%
rename from surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
rename to surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java
index 34dfe3d963..3a33b7f82a 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.util;
+package org.apache.maven.surefire.util.internal;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -28,7 +28,7 @@
/**
* Utility for dealing with URLs in pre-JDK 1.4.
*/
-public class UrlUtils
+public final class UrlUtils
{
private static final BitSet UNRESERVED = new BitSet( Byte.MAX_VALUE - Byte.MIN_VALUE + 1 );
@@ -38,6 +38,7 @@ public class UrlUtils
private UrlUtils()
{
+ throw new IllegalStateException( "no instantiable constructor" );
}
private static final String ENCODING = "UTF-8";
@@ -59,7 +60,7 @@ private UrlUtils()
}
}
- public static URL getURL( File file )
+ public static URL toURL( File file )
throws MalformedURLException
{
// with JDK 1.4+, code would be: return new URL( file.toURI().toASCIIString() );
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
index a9d7df0602..3d9a07fa0c 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
@@ -19,12 +19,14 @@
* under the License.
*/
+import junit.framework.TestCase;
+
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URL;
-import junit.framework.TestCase;
+import static org.apache.maven.surefire.util.internal.UrlUtils.toURL;
/**
* Test the URL utilities.
@@ -55,7 +57,7 @@ private void verifyFileName( String fileName, String expectedFileName )
throws Exception
{
File f = new File( homeDir, fileName );
- URL u = UrlUtils.getURL( f );
+ URL u = toURL( f );
String url = u.toString();
assertStartsWith( url, "file:" );
assertEndsWith( url, expectedFileName );
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
index d03fed1a2f..13388c5e4c 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
@@ -19,8 +19,6 @@
* under the License.
*/
-import org.apache.maven.surefire.util.UrlUtils;
-
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
@@ -32,6 +30,7 @@
import java.util.List;
import static java.io.File.pathSeparatorChar;
+import static org.apache.maven.surefire.util.internal.UrlUtils.toURL;
/**
* An ordered list of classpath elements with set behaviour
@@ -124,7 +123,7 @@ public List getAsUrlList()
for ( String url : unmodifiableElements )
{
File f = new File( url );
- urls.add( UrlUtils.getURL( f ) );
+ urls.add( toURL( f ) );
}
return urls;
}
From d7bf6ce49043a3301494fdd26c538afad4e1938d Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 3 Dec 2016 22:26:42 +0100
Subject: [PATCH 014/194] [SUREFIRE-1305] surefire fails on parallel tests when
newline character is in test description
---
.../internal/TestClassMethodNameUtils.java | 1 +
.../common/junit4/JUnit4RunListener.java | 25 +++----------------
.../common/junit4/JUnit4StackTraceWriter.java | 8 +++---
3 files changed, 9 insertions(+), 25 deletions(-)
create mode 100644 surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TestClassMethodNameUtils.java
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TestClassMethodNameUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TestClassMethodNameUtils.java
new file mode 100644
index 0000000000..29b4f51871
--- /dev/null
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TestClassMethodNameUtils.java
@@ -0,0 +1 @@
+package org.apache.maven.surefire.util.internal;
/*
* 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 java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* JUnit Description parser.
* Used by JUnit Version lower than 4.7.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class TestClassMethodNameUtils
{
private static final Pattern METHOD_CLASS_PATTERN = Pattern.compile( "([\\s\\S]*)\\((.*)\\)" );
private TestClassMethodNameUtils()
{
throw new IllegalStateException( "no instantiable constructor" );
}
public static String extractClassName( String displayName )
{
Matcher m = METHOD_CLASS_PATTERN.matcher( displayName );
return m.matches() ? m.group( 2 ) : displayName;
}
public static String extractMethodName( String displayName )
{
int i = displayName.indexOf( "(" );
return i >= 0 ? displayName.substring( 0, i ) : displayName;
}
}
\ No newline at end of file
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
index dd004fa706..1d365cfc09 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
@@ -28,14 +28,13 @@
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.isFailureInsideJUnitItself;
import static org.apache.maven.surefire.common.junit4.JUnit4Reflector.getAnnotatedIgnoreValue;
import static org.apache.maven.surefire.report.SimpleReportEntry.assumption;
import static org.apache.maven.surefire.report.SimpleReportEntry.ignored;
import static org.apache.maven.surefire.report.SimpleReportEntry.withException;
+import static org.apache.maven.surefire.util.internal.TestClassMethodNameUtils.extractClassName;
+import static org.apache.maven.surefire.util.internal.TestClassMethodNameUtils.extractMethodName;
/**
* RunListener for JUnit4, delegates to our own RunListener
@@ -44,8 +43,6 @@
public class JUnit4RunListener
extends org.junit.runner.notification.RunListener
{
- private static final Pattern METHOD_CLASS_PATTERN = Pattern.compile( "([\\s\\S]*)\\((.*)\\)" );
-
protected final RunListener reporter;
/**
@@ -183,26 +180,12 @@ protected SimpleReportEntry createReportEntry( Description description )
protected String extractDescriptionClassName( Description description )
{
- return extractClassName( description );
+ return extractClassName( description.getDisplayName() );
}
protected String extractDescriptionMethodName( Description description )
{
- return extractMethodName( description );
- }
-
- public static String extractClassName( Description description )
- {
- String displayName = description.getDisplayName();
- Matcher m = METHOD_CLASS_PATTERN.matcher( displayName );
- return m.matches() ? m.group( 2 ) : displayName;
- }
-
- public static String extractMethodName( Description description )
- {
- String displayName = description.getDisplayName();
- int i = displayName.indexOf( "(" );
- return i >= 0 ? displayName.substring( 0, i ) : displayName;
+ return extractMethodName( description.getDisplayName() );
}
public static void rethrowAnyTestMechanismFailures( Result run )
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
index a4690ca79d..33f499e343 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
@@ -24,8 +24,8 @@
import org.apache.maven.surefire.report.StackTraceWriter;
import org.junit.runner.notification.Failure;
-import static org.apache.maven.surefire.common.junit4.JUnit4RunListener.extractClassName;
-import static org.apache.maven.surefire.common.junit4.JUnit4RunListener.extractMethodName;
+import static org.apache.maven.surefire.util.internal.TestClassMethodNameUtils.extractClassName;
+import static org.apache.maven.surefire.util.internal.TestClassMethodNameUtils.extractMethodName;
import static org.apache.maven.surefire.report.SmartStackTraceParser.stackTraceWithFocusOnClassAsString;
/**
@@ -79,12 +79,12 @@ public String writeTraceToString()
protected String getTestClassName()
{
- return extractClassName( junitFailure.getDescription() );
+ return extractClassName( junitFailure.getDescription().getDisplayName() );
}
protected String getTestMethodName()
{
- return extractMethodName( junitFailure.getDescription() );
+ return extractMethodName( junitFailure.getDescription().getDisplayName() );
}
@SuppressWarnings( "ThrowableResultOfMethodCallIgnored" )
From 68246e2f93daeee0cbcbaf342fa4a4a485c72899 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 11 Dec 2016 09:51:41 +0100
Subject: [PATCH 015/194] [SUREFIRE] refactoring
---
.../plugin/surefire/AbstractSurefireMojo.java | 8 +++---
.../maven/surefire/util/UrlUtilsTest.java | 25 ++++---------------
2 files changed, 10 insertions(+), 23 deletions(-)
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 127ec82747..3606be23e0 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
@@ -101,6 +101,8 @@
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.split;
+import static org.apache.maven.surefire.suite.RunResult.failure;
+import static org.apache.maven.surefire.suite.RunResult.noTestsRun;
/**
* Abstract base class for running tests using Surefire.
@@ -774,7 +776,7 @@ public void execute()
throw new MojoFailureException(
"No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" );
}
- handleSummary( RunResult.noTestsRun(), null );
+ handleSummary( noTestsRun(), null );
return;
}
logReportsDirectory();
@@ -893,7 +895,7 @@ private void executeAfterPreconditionsChecked( DefaultScanResult scanResult )
{
List providers = createProviders();
- RunResult current = RunResult.noTestsRun();
+ RunResult current = noTestsRun();
Exception firstForkException = null;
for ( ProviderInfo provider : providers )
@@ -927,7 +929,7 @@ private void executeAfterPreconditionsChecked( DefaultScanResult scanResult )
if ( firstForkException != null )
{
- current = RunResult.failure( current, firstForkException );
+ current = failure( current, firstForkException );
}
handleSummary( current, firstForkException );
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
index 3d9a07fa0c..964fa1087c 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
@@ -22,8 +22,7 @@
import junit.framework.TestCase;
import java.io.File;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
+import java.net.URI;
import java.net.URL;
import static org.apache.maven.surefire.util.internal.UrlUtils.toURL;
@@ -58,27 +57,13 @@ private void verifyFileName( String fileName, String expectedFileName )
{
File f = new File( homeDir, fileName );
URL u = toURL( f );
+ URI uri = u.toURI();
+ File urlFile = new File( uri );
String url = u.toString();
+
assertStartsWith( url, "file:" );
assertEndsWith( url, expectedFileName );
-
- try
- {
- // use reflection to do "URI uri = u.toURI()" if JDK 1.5+
- Method toURI = URL.class.getMethod( "toURI", null );
- Object uri = toURI.invoke( u, null );
-
- // use reflection to do "File urlFile = new File( uri )" if JDK 1.4+
- Constructor newFile = File.class.getConstructor( new Class[]{ uri.getClass() } );
- File urlFile = (File) newFile.newInstance( uri );
-
- assertEquals( f, urlFile );
- }
- catch ( NoSuchMethodException e )
- {
- // URL.toURI() method in JDK 1.5+, not available currently
- // we won't be able to check for file equality...
- }
+ assertEquals( f, urlFile );
}
private void assertStartsWith( String string, String substring )
From fd293d8971c0c869fca6ee9cd9d17145b9a76bd1 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 11 Dec 2016 13:28:37 +0100
Subject: [PATCH 016/194] [SUREFIRE] refactoring
---
.../apache/maven/surefire/booter/ClasspathConfiguration.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
index d582f3c7eb..3389a375b0 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
@@ -82,7 +82,7 @@ public ClassLoader createMergedClassLoader()
throws SurefireExecutionException
{
return Classpath.join( inprocClasspath, classpathUrls )
- .createClassLoader( null, this.childDelegation, enableAssertions, "test" );
+ .createClassLoader( null, childDelegation, enableAssertions, "test" );
}
public Classpath getProviderClasspath()
@@ -90,8 +90,7 @@ public Classpath getProviderClasspath()
return surefireClasspathUrls;
}
-
- public Classpath getTestClasspath()
+ public Classpath getTestClasspath()
{
return classpathUrls;
}
From 9478990e1e6f5ccb1c25cd3ba92e97a8b57c8228 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 11 Dec 2016 13:32:27 +0100
Subject: [PATCH 017/194] [SUREFIRE-1312] Classpath containing url special
characters with Reflections not working
---
.../plugin/surefire/booterclient/ForkConfiguration.java | 8 ++++----
.../java/org/apache/maven/surefire/booter/Classpath.java | 5 ++---
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 6d43bd291e..988af8f5c1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -39,8 +39,6 @@
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
-import static org.apache.maven.surefire.util.internal.UrlUtils.toURL;
-
/**
* Configuration for forking tests.
*
@@ -287,8 +285,10 @@ private File createJar( List classPath, String startClassName )
StringBuilder cp = new StringBuilder();
for ( String el : classPath )
{
- // NOTE: if File points to a directory, this entry MUST end in '/'.
- cp.append( toURL( new File( el ) ).toExternalForm() )
+ File file1 = new File( el );
+ String pathEnd = file1.isDirectory() ? "/" : "";
+ cp.append( file1.toURI().toASCIIString() )
+ .append( pathEnd )
.append( " " );
}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
index 13388c5e4c..e7d97c86e1 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
@@ -162,9 +162,9 @@ public ClassLoader createClassLoader( ClassLoader parent, boolean childDelegatio
try
{
IsolatedClassLoader classLoader = new IsolatedClassLoader( parent, childDelegation, roleName );
- for ( URL url : getAsUrlList() )
+ for ( String classPathElement : unmodifiableElements )
{
- classLoader.addURL( url );
+ classLoader.addURL( new File( classPathElement ).toURL() );
}
if ( parent != null )
{
@@ -179,7 +179,6 @@ public ClassLoader createClassLoader( ClassLoader parent, boolean childDelegatio
}
}
-
public int hashCode()
{
return unmodifiableElements.hashCode();
From f841a16e4f85ffc28a39baa3f01454c08092f79d Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 11 Dec 2016 13:38:42 +0100
Subject: [PATCH 018/194] [SUREFIRE-1313] Unify console report result in
SurefirePlugin and VerifyMojo
---
.../maven/plugin/failsafe/VerifyMojo.java | 2 +-
.../maven/plugin/surefire/SurefireHelper.java | 94 ++++++++++++-------
.../maven/plugin/surefire/SurefirePlugin.java | 13 +--
.../maven/surefire/suite/RunResult.java | 3 +-
4 files changed, 65 insertions(+), 47 deletions(-)
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 37199a3b3c..5d0b035306 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
@@ -209,7 +209,7 @@ public void execute()
throw new MojoExecutionException( e.getMessage(), e );
}
- reportExecution( this, summary, getConsoleLogger() );
+ reportExecution( this, summary, getConsoleLogger(), null );
}
}
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 3f87c3cb5b..e4b340a70f 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
@@ -26,6 +26,7 @@
import org.apache.maven.plugin.surefire.log.PluginConsoleLogger;
import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.testset.TestSetFailedException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -34,10 +35,10 @@
import java.util.List;
import static java.util.Collections.unmodifiableList;
+import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_ERROR;
-import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_WARN;
import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_INFO;
-import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
+import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_WARN;
import static org.apache.maven.surefire.cli.CommandLineOption.SHOW_ERRORS;
/**
@@ -55,48 +56,26 @@ private SurefireHelper()
}
public static void reportExecution( SurefireReportParameters reportParameters, RunResult result,
- PluginConsoleLogger log )
+ PluginConsoleLogger log, Exception firstForkException )
throws MojoFailureException, MojoExecutionException
{
- boolean timeoutOrOtherFailure = result.isFailureOrTimeout();
-
- if ( !timeoutOrOtherFailure )
+ if ( firstForkException == null && !result.isTimeout() && result.isErrorFree() )
{
- if ( result.getCompletedCount() == 0 )
+ if ( result.getCompletedCount() == 0 && failIfNoTests( reportParameters ) )
{
- if ( reportParameters.getFailIfNoTests() == null || !reportParameters.getFailIfNoTests() )
- {
- return;
- }
- throw new MojoFailureException(
- "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" );
- }
-
- if ( result.isErrorFree() )
- {
- return;
+ throw new MojoFailureException( "No tests were executed! "
+ + "(Set -DfailIfNoTests=false to ignore this error.)" );
}
+ return;
}
- String msg = timeoutOrOtherFailure
- ? "There was a timeout or other error in the fork"
- : "There are test failures.\n\nPlease refer to " + reportParameters.getReportsDirectory()
- + " for the individual test results.";
-
if ( reportParameters.isTestFailureIgnore() )
{
- log.error( msg );
+ log.error( createErrorMessage( reportParameters, result, firstForkException ) );
}
else
{
- if ( result.isFailure() )
- {
- throw new MojoExecutionException( msg );
- }
- else
- {
- throw new MojoFailureException( msg );
- }
+ throwException( reportParameters, result, firstForkException );
}
}
@@ -181,4 +160,55 @@ private static String getFailureBehavior( MavenExecutionRequest request )
}
}
+ private static boolean failIfNoTests( SurefireReportParameters reportParameters )
+ {
+ return reportParameters.getFailIfNoTests() != null && reportParameters.getFailIfNoTests();
+ }
+
+ private static boolean isNotFatal( Exception firstForkException )
+ {
+ return firstForkException == null || firstForkException instanceof TestSetFailedException;
+ }
+
+ private static void throwException( SurefireReportParameters reportParameters, RunResult result,
+ Exception firstForkException )
+ throws MojoFailureException, MojoExecutionException
+ {
+ if ( isNotFatal( firstForkException ) )
+ {
+ throw new MojoFailureException( createErrorMessage( reportParameters, result, firstForkException ),
+ firstForkException );
+ }
+ else
+ {
+ throw new MojoExecutionException( createErrorMessage( reportParameters, result, firstForkException ),
+ firstForkException );
+ }
+ }
+
+ private static String createErrorMessage( SurefireReportParameters reportParameters, RunResult result,
+ Exception firstForkException )
+ {
+ StringBuilder msg = new StringBuilder( 128 );
+
+ if ( result.isTimeout() )
+ {
+ msg.append( "There was a timeout or other error in the fork" );
+ }
+ else
+ {
+ msg.append( "There are test failures.\n\nPlease refer to " )
+ .append( reportParameters.getReportsDirectory() )
+ .append( " for the individual test results." );
+ }
+
+ if ( firstForkException != null && firstForkException.getLocalizedMessage() != null )
+ {
+ msg.append( '\n' )
+ .append( firstForkException.getLocalizedMessage() );
+ }
+
+ return msg.toString();
+ }
+
}
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index 97f1a7944b..943ed69ff3 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -331,18 +331,7 @@ protected int getRerunFailingTestsCount()
protected void handleSummary( RunResult summary, Exception firstForkException )
throws MojoExecutionException, MojoFailureException
{
- assertNoException( firstForkException );
-
- reportExecution( this, summary, getConsoleLogger() );
- }
-
- private void assertNoException( Exception firstForkException )
- throws MojoFailureException
- {
- if ( firstForkException != null )
- {
- throw new MojoFailureException( firstForkException.getMessage(), firstForkException );
- }
+ reportExecution( this, summary, getConsoleLogger(), firstForkException );
}
protected boolean isSkipExecution()
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
index 50102e0f21..a8466b28fe 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
@@ -177,7 +177,7 @@ public boolean isErrorFree()
/* Indicates test timeout or technical failure */
public boolean isFailureOrTimeout()
{
- return this.timeout || isFailure();
+ return isTimeout() || isFailure();
}
public boolean isFailure()
@@ -195,7 +195,6 @@ public boolean isTimeout()
return timeout;
}
-
public RunResult aggregate( RunResult other )
{
String failureMessage = getFailure() != null ? getFailure() : other.getFailure();
From 304f454ed20b492d8d7f739a268a09d8b3c81763 Mon Sep 17 00:00:00 2001
From: Michael Osipov
Date: Thu, 22 Dec 2016 23:02:27 +0100
Subject: [PATCH 019/194] Fix typos in Javadocs
---
.../surefire/its/jiras/Surefire1028UnableToRunSingleIT.java | 4 ++--
.../surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java | 2 +-
.../surefire/junitcore/MavenSurefireJUnit47RunnerTest.java | 2 +-
.../surefire/junitcore/MavenSurefireJUnit48RunnerTest.java | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java
index 74cb281935..6e4d76c6f6 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java
@@ -28,13 +28,13 @@
*
* With Surefire 2.15
* {@code $ mvn test -Dtest=MyTest#testFoo}
- * Results :
+ * Results:
* Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
*
* With Surefire 2.16
* {@code $ mvn test -Dtest=MyTest#testFoo}
*
- * Results :
+ * Results:
* Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
*
* @author Tibor Digana (tibor17)
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java
index 16e27cfc22..74a4e469b1 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java
@@ -37,7 +37,7 @@
* Running pkg.RunningTest
* Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec - in pkg.RunningTest
*
- * Results :
+ * Results:
*
* Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
*/
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java
index cc877078d0..b883d09399 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java
@@ -32,7 +32,7 @@
* T E S T S
* -------------------------------------------------------
*
- * Results :
+ * Results:
*
* Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
*
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit48RunnerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit48RunnerTest.java
index f9d4fc46ad..08e16958e7 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit48RunnerTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit48RunnerTest.java
@@ -32,7 +32,7 @@
* T E S T S
* -------------------------------------------------------
*
- * Results :
+ * Results:
*
* Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
*
From dcd3b64acf129e630c6aaec9b2e1f48476855bad Mon Sep 17 00:00:00 2001
From: Michael Osipov
Date: Fri, 23 Dec 2016 00:11:25 +0100
Subject: [PATCH 020/194] [SUREFIRE-1315] Fix stylistic errors in
DefaultReporterFactory
* Update labels for proper English style
* Use proper title case
---
.../plugin/surefire/report/DefaultReporterFactory.java | 6 +++---
.../surefire/report/DefaultReporterFactoryTest.java | 4 ++--
.../src/site/markdown/newerrorsummary.md | 4 ++--
.../maven/surefire/its/JUnit4RerunFailingTestsIT.java | 10 +++++-----
.../jiras/Surefire1146RerunFailedAndParameterized.java | 2 +-
5 files changed, 13 insertions(+), 13 deletions(-)
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 2332856aa6..24f5b3b23d 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
@@ -421,9 +421,9 @@ boolean printTestFailures( TestResultType type )
enum TestResultType
{
- error( "Tests in error: " ),
- failure( "Failed tests: " ),
- flake( "Flaked tests: " ),
+ error( "Erroneous Tests: " ),
+ failure( "Failed Tests: " ),
+ flake( "Flaky Tests: " ),
success( "Success: " ),
skipped( "Skipped: " ),
unknown( "Unknown: " );
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 e51c993aa1..98f97bd81b 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
@@ -120,7 +120,7 @@ public void testMergeTestHistoryResult()
// Now test the result will be printed out correctly
factory.printTestFailures( flake );
String[] expectedFlakeOutput =
- { "Flaked tests: ", TEST_FOUR, " Run 1: " + ASSERTION_FAIL, " Run 2: PASS", "", TEST_ONE,
+ { "Flaky Tests: ", TEST_FOUR, " Run 1: " + ASSERTION_FAIL, " Run 2: PASS", "", TEST_ONE,
" Run 1: " + ERROR, " Run 2: " + ASSERTION_FAIL, " Run 3: PASS", "", TEST_TWO, " Run 1: " + ERROR,
" Run 2: PASS", "" };
assertEquals( asList( expectedFlakeOutput ), reporter.getMessages() );
@@ -128,7 +128,7 @@ public void testMergeTestHistoryResult()
reporter.reset();
factory.printTestFailures( error );
String[] expectedFailureOutput =
- { "Tests in error: ", TEST_THREE, " Run 1: " + ASSERTION_FAIL, " Run 2: " + ERROR, " Run 3: " + ERROR, ""
+ { "Erroneous Tests: ", TEST_THREE, " Run 1: " + ASSERTION_FAIL, " Run 2: " + ERROR, " Run 3: " + ERROR, ""
};
assertEquals( asList( expectedFailureOutput ), reporter.getMessages() );
diff --git a/maven-surefire-plugin/src/site/markdown/newerrorsummary.md b/maven-surefire-plugin/src/site/markdown/newerrorsummary.md
index 7467aa9303..09537e3e26 100644
--- a/maven-surefire-plugin/src/site/markdown/newerrorsummary.md
+++ b/maven-surefire-plugin/src/site/markdown/newerrorsummary.md
@@ -26,11 +26,11 @@ report of the run or the files on disk.
### Example output:
- Failed tests:
+ Failed Tests:
Test1.assertion1:59 Bending maths expected:<[123]> but was:<[312]>
Test1.assertion2:64 True is false
- Tests in error:
+ Erroneous Tests:
Test1.nullPointerInLibrary:38 » NullPointer
Test1.failInMethod:43->innerFailure:68 NullPointer Fail here
Test1.failInLibInMethod:48 » NullPointer
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java
index c6c6b8f38e..f216e08e0c 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java
@@ -216,11 +216,11 @@ private void verifyFailuresOneRetryOneMethod( OutputValidator outputValidator )
private void verifyFailuresOneRetry( OutputValidator outputValidator, int run, int failures, int errors,
int flakes )
{
- outputValidator.verifyTextInLog( "Failed tests" );
+ outputValidator.verifyTextInLog( "Failed Tests:" );
outputValidator.verifyTextInLog( "Run 1: FlakyFirstTimeTest.testFailingTestOne" );
outputValidator.verifyTextInLog( "Run 2: FlakyFirstTimeTest.testFailingTestOne" );
- outputValidator.verifyTextInLog( "Tests in error" );
+ outputValidator.verifyTextInLog( "Erroneous Tests:" );
outputValidator.verifyTextInLog( "Run 1: FlakyFirstTimeTest.testErrorTestOne" );
outputValidator.verifyTextInLog( "Run 2: FlakyFirstTimeTest.testErrorTestOne" );
@@ -230,7 +230,7 @@ private void verifyFailuresOneRetry( OutputValidator outputValidator, int run, i
private void verifyOnlyFailuresOneRetry( OutputValidator outputValidator, int run, int failures, int errors,
int flakes )
{
- outputValidator.verifyTextInLog( "Failed tests" );
+ outputValidator.verifyTextInLog( "Failed Tests:" );
outputValidator.verifyTextInLog( "Run 1: FlakyFirstTimeTest.testFailingTestOne" );
outputValidator.verifyTextInLog( "Run 2: FlakyFirstTimeTest.testFailingTestOne" );
@@ -240,7 +240,7 @@ private void verifyOnlyFailuresOneRetry( OutputValidator outputValidator, int ru
private void verifyFailuresTwoRetry( OutputValidator outputValidator, int run, int failures, int errors,
int flakes )
{
- outputValidator.verifyTextInLog( "Flaked tests" );
+ outputValidator.verifyTextInLog( "Flaky Tests:" );
outputValidator.verifyTextInLog( "Run 1: FlakyFirstTimeTest.testFailingTestOne" );
outputValidator.verifyTextInLog( "Run 2: FlakyFirstTimeTest.testFailingTestOne" );
outputValidator.verifyTextInLog( "Run 3: PASS" );
@@ -253,7 +253,7 @@ private void verifyFailuresTwoRetry( OutputValidator outputValidator, int run, i
private void verifyFailuresNoRetry( OutputValidator outputValidator, int run, int failures, int errors, int flakes )
{
- outputValidator.verifyTextInLog( "Failed tests" );
+ outputValidator.verifyTextInLog( "Failed Tests:" );
outputValidator.verifyTextInLog( "testFailingTestOne(junit4.FlakyFirstTimeTest)" );
outputValidator.verifyTextInLog( "ERROR" );
outputValidator.verifyTextInLog( "testErrorTestOne(junit4.FlakyFirstTimeTest)" );
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java
index 24d39bc307..8ebc6ecc02 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java
@@ -39,7 +39,7 @@ public void testsAreRerun()
private void verify( OutputValidator outputValidator, int run, int failures, int errors, int skipped, int flakes )
{
- outputValidator.verifyTextInLog( "Flaked tests:" );
+ outputValidator.verifyTextInLog( "Flaky Tests:" );
outputValidator.verifyTextInLog( "jiras.surefire1146.CustomDescriptionParameterizedTest.flakyTest[0: (Test11); Test12; Test13;](jiras.surefire1146.CustomDescriptionParameterizedTest)" );
outputValidator.verifyTextInLog( "Run 1: CustomDescriptionParameterizedTest.flakyTest:" );
outputValidator.verifyTextInLog( "Run 2: CustomDescriptionParameterizedTest.flakyTest:" );
From 137029531f22e65cb9bb841aa62ca859441b0b14 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 26 Dec 2016 15:18:08 +0100
Subject: [PATCH 021/194] [SUREFIRE-1316] MVN 3.1.0 minimum in build time
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 77c0385829..fc80f9daf5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -366,7 +366,7 @@
- [3.0.5,)
+ [3.1.0,)
From 0d90d9755c3308aaa328a948ce7e14011f426453 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 26 Dec 2016 15:27:27 +0100
Subject: [PATCH 022/194] [SUREFIRE-1317] Refactoring
---
.../apache/maven/plugin/surefire/AbstractSurefireMojo.java | 2 +-
.../maven/plugin/surefire/booterclient/BooterSerializer.java | 4 ++--
.../maven/plugin/surefire/report/TestSetRunListener.java | 1 -
.../org/apache/maven/surefire/util/internal/StringUtils.java | 5 ++---
.../apache/maven/surefire/booter/SystemPropertyManager.java | 1 -
5 files changed, 5 insertions(+), 8 deletions(-)
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 3606be23e0..4f7744fc1e 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
@@ -2047,7 +2047,7 @@ private File getSurefireTempDir()
}
/**
- * Operates on raw plugin paramenters, not the "effective" values.
+ * Operates on raw plugin parameters, not the "effective" values.
*
* @return The checksum
*/
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
index 2aac04be83..114150d748 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
@@ -61,7 +61,7 @@ class BooterSerializer
{
private final ForkConfiguration forkConfiguration;
- public BooterSerializer( ForkConfiguration forkConfiguration )
+ BooterSerializer( ForkConfiguration forkConfiguration )
{
this.forkConfiguration = forkConfiguration;
}
@@ -69,7 +69,7 @@ public BooterSerializer( ForkConfiguration forkConfiguration )
/**
* Does not modify sourceProperties
*/
- public File serialize( KeyValueSource sourceProperties, ProviderConfiguration booterConfiguration,
+ File serialize( KeyValueSource sourceProperties, ProviderConfiguration booterConfiguration,
StartupConfiguration providerConfiguration, Object testSet, boolean readTestsFromInStream )
throws IOException
{
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
index dbc802c086..ca12c9031b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
@@ -166,7 +166,6 @@ public void testSetCompleted( ReportEntry report )
addTestMethodStats();
detailsForThis.reset();
-
}
// ----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index a95518386a..830cace5e8 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -59,9 +59,8 @@ public final class StringUtils
{
public static final String NL = System.getProperty( "line.separator" );
- private static final byte[] HEX_CHARS = new byte[] {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'A', 'B', 'C', 'D', 'E', 'F' };
+ private static final byte[] HEX_CHARS = {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
private static final Charset DEFAULT_CHARSET = Charset.defaultCharset();
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
index 17db48925d..713d4fed89 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
@@ -68,7 +68,6 @@ private static PropertiesWrapper loadProperties( File file )
return loadProperties( new FileInputStream( file ) );
}
-
public static void setSystemProperties( File file )
throws IOException
{
From 738976c4d7546d91b624435f806d6820e4025f0b Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 26 Dec 2016 15:32:51 +0100
Subject: [PATCH 023/194] [SUREFIRE-1318] Upgrade JaCoCo Version to 0.7.8
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index fc80f9daf5..034b6040d1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -328,7 +328,7 @@
org.jacocojacoco-maven-plugin
- 0.7.7.201606060606
+ 0.7.8**/failsafe/*
From 614f12c62c803d85f4cc48ad850d9055547d12fa Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 26 Dec 2016 15:36:40 +0100
Subject: [PATCH 024/194] [SUREFIRE-1319] Upgrade RAT Plugin Version to 0.12
---
pom.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/pom.xml b/pom.xml
index 034b6040d1..7a8b813d18 100644
--- a/pom.xml
+++ b/pom.xml
@@ -380,6 +380,7 @@
org.apache.ratapache-rat-plugin
+ 0.12rat-check
From 37d99af1c19f2bdd56f10f73155c4947a09b8764 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 26 Dec 2016 15:39:18 +0100
Subject: [PATCH 025/194] [SUREFIRE-1320] Upgrade Sniffer Plugin Version to
1.15
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 7a8b813d18..979f7a76b7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -277,7 +277,7 @@
org.codehaus.mojoanimal-sniffer-maven-plugin
- 1.11
+ 1.15signature-check
From 99978af43be70e29f2f74c39b888c2ef9b98cd20 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 26 Dec 2016 15:43:58 +0100
Subject: [PATCH 026/194] [SUREFIRE-1321] Integration tests should be cleaned
up before running. Add goal=clean in maven-invoker-plugin.
---
maven-failsafe-plugin/pom.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index 91c7677986..a5d41ff5a1 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -282,6 +282,7 @@
src/it${project.build.directory}/it
+ cleanverify
From 9964119f3a238223e50b0bd6e813ea8dc03f910d Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 26 Dec 2016 16:16:30 +0100
Subject: [PATCH 027/194] [SUREFIRE-1323] Java 1.6 for improved XML parser
needed in SUREFIRE-1322
---
pom.xml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 979f7a76b7..3b8ab650cd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,6 +86,8 @@
+ 1.6
+ 1.62.2.13.3
@@ -289,8 +291,8 @@
org.codehaus.mojo.signature
- java15
- 1.0
+ java16
+ 1.1
From 303cc8acdaf677bee9751da94de16e07083febb7 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 26 Dec 2016 16:26:18 +0100
Subject: [PATCH 028/194] [SUREFIRE-1322] Surefire and Failsafe should dump
critical errors in dump file and console
---
.../plugin/failsafe/IntegrationTestMojo.java | 47 +++++---
.../maven/plugin/failsafe/VerifyMojo.java | 71 +++---------
.../plugin/failsafe/xmlsummary/ErrorType.java | 1 +
.../failsafe/xmlsummary/FailsafeSummary.java | 1 +
.../xmlsummary/FailsafeSummaryXmlUtils.java | 1 +
.../plugin/failsafe/xmlsummary/JAXB.java | 1 +
.../failsafe/xmlsummary/ObjectFactory.java | 1 +
.../failsafe/MarshallerUnmarshallerTest.java | 1 +
.../maven/plugin/failsafe/RunResultTest.java | 1 +
.../plugin/failsafe/failsafe-summary.xml | 1 +
.../maven/plugin/surefire/SurefireHelper.java | 25 +++--
.../surefire/booterclient/ForkStarter.java | 30 ++++--
.../booterclient/output/ForkClient.java | 6 +-
.../output/LostCommandsDumpSingleton.java | 1 +
.../report/DefaultReporterFactory.java | 6 ++
.../src/site/apt/developing.apt.vm | 4 +-
.../src/site/apt/examples/shutdown.apt.vm | 5 +-
.../src/site/apt/index.apt.vm | 9 +-
maven-surefire-plugin/src/site/fml/faq.fml | 25 ++++-
.../src/site/resources/xsd/bindings.xml | 1 +
.../site/resources/xsd/failsafe-summary.xsd | 1 +
.../maven/surefire/booter/CommandReader.java | 18 +++-
.../maven/surefire/suite/RunResult.java | 101 ++----------------
.../surefire/util/internal/DumpFileUtils.java | 1 +
.../maven/surefire/suite/RunResultTest.java | 83 +-------------
.../maven/surefire/booter/ForkedBooter.java | 74 +++++++++----
.../its/CheckTestNgExecuteErrorIT.java | 28 ++++-
.../surefire/its/fixture/OutputValidator.java | 9 +-
.../Surefire141PluggableProvidersIT.java | 35 ++++--
29 files changed, 281 insertions(+), 307 deletions(-)
create mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ErrorType.java
create mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummary.java
create mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java
create mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java
create mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ObjectFactory.java
create mode 100644 maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/MarshallerUnmarshallerTest.java
create mode 100644 maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java
create mode 100644 maven-failsafe-plugin/src/test/resources/org/apache/maven/plugin/failsafe/failsafe-summary.xml
create mode 100644 maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
create mode 100644 maven-surefire-plugin/src/site/resources/xsd/bindings.xml
create mode 100644 maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd
create mode 100644 surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
index c0048d535d..2d781094d1 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
@@ -19,12 +19,6 @@
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
@@ -36,6 +30,16 @@
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.surefire.suite.RunResult;
+import javax.xml.bind.JAXBException;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+
+import static org.apache.maven.plugin.failsafe.xmlsummary.FailsafeSummaryXmlUtils.writeSummary;
import static org.apache.maven.shared.utils.ReaderFactory.FILE_ENCODING;
/**
@@ -46,9 +50,9 @@
* @noinspection JavaDoc,
*/
@Mojo( name = "integration-test", requiresProject = true, requiresDependencyResolution = ResolutionScope.TEST,
- defaultPhase = LifecyclePhase.INTEGRATION_TEST, threadSafe = true )
+ defaultPhase = LifecyclePhase.INTEGRATION_TEST, threadSafe = true )
public class IntegrationTestMojo
- extends AbstractSurefireMojo
+ extends AbstractSurefireMojo
{
private static final String FAILSAFE_IN_PROGRESS_CONTEXT_KEY = "failsafe-in-progress";
@@ -235,7 +239,7 @@ public class IntegrationTestMojo
* By default, Surefire forks your tests using a manifest-only JAR; set this parameter to "false" to force it to
* launch your tests with a plain old Java classpath. (See the
*
- * http://maven.apache.org/plugins/maven-failsafe-plugin/examples/class-loading.html
+ * http://maven.apache.org/plugins/maven-failsafe-plugin/examples/class-loading.html
* for a more detailed explanation of manifest-only JARs and their benefits.)
*
* Beware, setting this to "false" may cause your tests to fail on Windows if your classpath is too long.
@@ -326,7 +330,7 @@ public class IntegrationTestMojo
* Defaults to "0".
* See the prerequisites and limitations in documentation:
*
- * http://maven.apache.org/plugins/maven-failsafe-plugin/examples/skip-after-failure.html
+ * http://maven.apache.org/plugins/maven-failsafe-plugin/examples/skip-after-failure.html
*
* @since 2.19
*/
@@ -353,7 +357,7 @@ protected int getRerunFailingTestsCount()
@SuppressWarnings( "unchecked" )
protected void handleSummary( RunResult summary, Exception firstForkException )
- throws MojoExecutionException, MojoFailureException
+ throws MojoExecutionException, MojoFailureException
{
File summaryFile = getSummaryFile();
if ( !summaryFile.getParentFile().isDirectory() )
@@ -365,12 +369,16 @@ protected void handleSummary( RunResult summary, Exception firstForkException )
try
{
Object token = getPluginContext().get( FAILSAFE_IN_PROGRESS_CONTEXT_KEY );
- summary.writeSummary( summaryFile, token != null, getEncodingOrDefault() );
+ writeSummary( summary, summaryFile, token != null, toCharset( getEncodingOrDefault() ) );
}
catch ( IOException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
+ catch ( JAXBException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
getPluginContext().put( FAILSAFE_IN_PROGRESS_CONTEXT_KEY, FAILSAFE_IN_PROGRESS_CONTEXT_KEY );
}
@@ -379,10 +387,12 @@ private String getEncodingOrDefault()
{
if ( StringUtils.isEmpty( encoding ) )
{
- getConsoleLogger().warning( "File encoding has not been set, using platform encoding "
- + FILE_ENCODING
- + ", i.e. build is platform dependent! The file encoding for reports output files "
- + "should be provided by the POM property ${project.reporting.outputEncoding}." );
+ getConsoleLogger()
+ .warning( "File encoding has not been set, using platform encoding "
+ + FILE_ENCODING
+ + ", i.e. build is platform dependent! The file encoding for reports output files"
+ + " should be provided by the POM property ${project.reporting.outputEncoding}."
+ );
return FILE_ENCODING;
}
else
@@ -741,4 +751,9 @@ protected final boolean hasSuiteXmlFiles()
{
return suiteXmlFiles != null && suiteXmlFiles.length != 0;
}
+
+ static Charset toCharset( String encoding )
+ {
+ return Charset.forName( Charset.isSupported( encoding ) ? encoding : encoding.toUpperCase( Locale.ROOT ) );
+ }
}
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 5d0b035306..a56d5215e7 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
@@ -19,18 +19,11 @@
* under the License.
*/
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.Collection;
-
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.failsafe.xmlsummary.FailsafeSummaryXmlUtils;
import org.apache.maven.plugin.surefire.SurefireHelper;
import org.apache.maven.plugin.surefire.SurefireReportParameters;
import org.apache.maven.plugin.surefire.log.PluginConsoleLogger;
@@ -41,11 +34,12 @@
import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.suite.RunResult;
+import javax.xml.bind.JAXBException;
+import java.io.File;
+import java.util.Collection;
+
import static org.apache.maven.plugin.surefire.SurefireHelper.reportExecution;
-import static org.apache.maven.shared.utils.ReaderFactory.FILE_ENCODING;
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.io.IOUtil.close;
import static org.apache.maven.surefire.suite.RunResult.noTestsRun;
/**
@@ -54,10 +48,11 @@
* @author Stephen Connolly
* @author Jason van Zyl
*/
+@SuppressWarnings( "unused" )
@Mojo( name = "verify", defaultPhase = LifecyclePhase.VERIFY, requiresProject = true, threadSafe = true )
public class VerifyMojo
- extends AbstractMojo
- implements SurefireReportParameters
+ extends AbstractMojo
+ implements SurefireReportParameters
{
/**
@@ -167,44 +162,28 @@ public class VerifyMojo
private volatile PluginConsoleLogger consoleLogger;
public void execute()
- throws MojoExecutionException, MojoFailureException
+ throws MojoExecutionException, MojoFailureException
{
cli = commandLineOptions();
if ( verifyParameters() )
{
- logDebugOrCliShowErrors(
- capitalizeFirstLetter( getPluginName() ) + " report directory: " + getReportsDirectory() );
+ logDebugOrCliShowErrors( capitalizeFirstLetter( getPluginName() )
+ + " report directory: " + getReportsDirectory() );
RunResult summary;
try
{
- final String encoding;
- if ( isEmpty( this.encoding ) )
- {
- getConsoleLogger()
- .warning( "File encoding has not been set, using platform encoding "
- + FILE_ENCODING
- + ", i.e. build is platform dependent! The file encoding for "
- + "reports output files should be provided by the POM property "
- + "${project.reporting.outputEncoding}." );
- encoding = FILE_ENCODING;
- }
- else
- {
- encoding = this.encoding;
- }
-
- summary = existsSummaryFile() ? readSummary( encoding, summaryFile ) : noTestsRun();
+ summary = existsSummaryFile() ? readSummary( summaryFile ) : noTestsRun();
if ( existsSummaryFiles() )
{
for ( final File summaryFile : summaryFiles )
{
- summary = summary.aggregate( readSummary( encoding, summaryFile ) );
+ summary = summary.aggregate( readSummary( summaryFile ) );
}
}
}
- catch ( IOException e )
+ catch ( JAXBException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
@@ -228,29 +207,13 @@ private PluginConsoleLogger getConsoleLogger()
return consoleLogger;
}
- private RunResult readSummary( String encoding, File summaryFile )
- throws IOException
+ private RunResult readSummary( File summaryFile ) throws JAXBException
{
- FileInputStream fileInputStream = null;
- BufferedInputStream bufferedInputStream = null;
- Reader reader = null;
- try
- {
- fileInputStream = new FileInputStream( summaryFile );
- bufferedInputStream = new BufferedInputStream( fileInputStream );
- reader = new InputStreamReader( bufferedInputStream, encoding );
- return RunResult.fromInputStream( bufferedInputStream, encoding );
- }
- finally
- {
- close( reader );
- close( bufferedInputStream );
- close( fileInputStream );
- }
+ return FailsafeSummaryXmlUtils.toRunResult( summaryFile );
}
protected boolean verifyParameters()
- throws MojoFailureException
+ throws MojoFailureException
{
if ( isSkip() || isSkipTests() || isSkipITs() || isSkipExec() )
{
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ErrorType.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ErrorType.java
new file mode 100644
index 0000000000..f301527dcf
--- /dev/null
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ErrorType.java
@@ -0,0 +1 @@
+package org.apache.maven.plugin.failsafe.xmlsummary;
/*
* 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.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;
/**
*
Java class for errorType.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*/
@XmlType( name = "errorType" )
@XmlEnum( Integer.class )
public enum ErrorType
{
@XmlEnumValue( "255" )
FAILURE( 255 ),
@XmlEnumValue( "254" )
NO_TESTS( 254 );
private final int value;
ErrorType( int v )
{
value = v;
}
public static ErrorType fromValue( Integer v )
{
if ( v == null )
{
return null;
}
for ( ErrorType c : ErrorType.values() )
{
if ( c.value == v )
{
return c;
}
}
throw new IllegalArgumentException( "" + v );
}
public int value()
{
return value;
}
}
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummary.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummary.java
new file mode 100644
index 0000000000..d20fd4f897
--- /dev/null
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummary.java
@@ -0,0 +1 @@
+package org.apache.maven.plugin.failsafe.xmlsummary;
/*
* 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.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import static java.util.Collections.emptyList;
import static org.apache.maven.plugin.failsafe.xmlsummary.ErrorType.FAILURE;
import static org.apache.maven.plugin.failsafe.xmlsummary.ErrorType.NO_TESTS;
/**
*
Java class for anonymous complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*/
@XmlAccessorType( XmlAccessType.FIELD )
@XmlType( name = "", propOrder = {
"completed",
"errors",
"failures",
"skipped",
"failureMessage"
} )
@XmlRootElement( name = "failsafe-summary" )
public class FailsafeSummary
{
private static final String ERROR_MSG_PREFIX = "org.apache.maven.surefire.booter.SurefireBooterForkException: ";
private static final Pattern STACK_TRACE_ELEMENT1 = Pattern.compile( "^\\tat.*\\(.*\\.java\\:[\\d]+\\)$" );
private static final Pattern STACK_TRACE_ELEMENT2 = Pattern.compile( "^\\tat.*\\(Native Method\\)$" );
private static final Pattern STACK_TRACE_ELEMENT3 = Pattern.compile( "^Caused by\\: .*" );
private int completed;
private int errors;
private int failures;
private int skipped;
@XmlElement( required = true, nillable = true )
private String failureMessage;
@XmlAttribute( name = "result" )
private ErrorType result;
@XmlAttribute( name = "timeout", required = true )
private boolean timeout;
/**
* Gets the value of the completed property.
*/
public int getCompleted()
{
return completed;
}
/**
* Sets the value of the completed property.
*/
public void setCompleted( int value )
{
this.completed = value;
}
/**
* Gets the value of the errors property.
*/
public int getErrors()
{
return errors;
}
/**
* Sets the value of the errors property.
*/
public void setErrors( int value )
{
this.errors = value;
}
/**
* Gets the value of the failures property.
*/
public int getFailures()
{
return failures;
}
/**
* Sets the value of the failures property.
*/
public void setFailures( int value )
{
this.failures = value;
}
/**
* Gets the value of the skipped property.
*/
public int getSkipped()
{
return skipped;
}
/**
* Sets the value of the skipped property.
*/
public void setSkipped( int value )
{
this.skipped = value;
}
/**
* Gets the value of the failureMessage property.
*
* @return possible object is
* {@link String }
*/
public String getFailureMessage()
{
return failureMessage;
}
/**
* Sets the value of the failureMessage property.
*
* @param value allowed object is
* {@link String }
*/
public void setFailureMessage( String value )
{
this.failureMessage = value;
}
/**
* Gets the value of the result property.
*
* @return possible object is
* {@link ErrorType }
*/
public ErrorType getResult()
{
return result;
}
/**
* Sets the value of the result property.
*
* @param value allowed object is
* {@link ErrorType }
*/
public void setResult( ErrorType value )
{
this.result = value;
}
/**
* Gets the value of the timeout property.
*/
public boolean isTimeout()
{
return timeout;
}
/**
* Sets the value of the timeout property.
*/
public void setTimeout( boolean value )
{
this.timeout = value;
}
public boolean hasNoTests()
{
return getResult() == NO_TESTS;
}
public boolean isFailure()
{
return getResult() == FAILURE;
}
public List extractExceptionMessageLines() throws IOException
{
if ( getFailureMessage() == null )
{
return emptyList();
}
List msg = new ArrayList();
LineNumberReader reader = new LineNumberReader( new StringReader( getFailureMessage() ) );
for ( @SuppressWarnings( "checkstyle:innerassignment" ) String line; ( line = reader.readLine() ) != null; )
{
if ( !STACK_TRACE_ELEMENT1.matcher( line ).matches()
&& !STACK_TRACE_ELEMENT2.matcher( line ).matches()
&& !STACK_TRACE_ELEMENT3.matcher( line ).matches() )
{
line = line.trim();
msg.add( line.startsWith( ERROR_MSG_PREFIX ) ? line.substring( ERROR_MSG_PREFIX.length() ) : line );
}
else
{
break;
}
}
return msg;
}
@Override
public boolean equals( Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
FailsafeSummary summary = (FailsafeSummary) o;
return getCompleted() == summary.getCompleted()
&& getErrors() == summary.getErrors()
&& getFailures() == summary.getFailures()
&& getSkipped() == summary.getSkipped()
&& isTimeout() == summary.isTimeout()
&& equal( getFailureMessage(), summary.getFailureMessage() )
&& getResult() == summary.getResult();
}
@Override
public int hashCode()
{
int result1 = getCompleted();
result1 = 31 * result1 + getErrors();
result1 = 31 * result1 + getFailures();
result1 = 31 * result1 + getSkipped();
result1 = 31 * result1 + ( getFailureMessage() != null ? getFailureMessage().hashCode() : 0 );
result1 = 31 * result1 + ( getResult() != null ? getResult().hashCode() : 0 );
result1 = 31 * result1 + ( isTimeout() ? 1 : 0 );
return result1;
}
private boolean equal( String s1, String s2 )
{
return s1 == null ? s2 == null : s1.equals( s2 );
}
}
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java
new file mode 100644
index 0000000000..6bfa945c5e
--- /dev/null
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java
@@ -0,0 +1 @@
+package org.apache.maven.plugin.failsafe.xmlsummary;
/*
* 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.suite.RunResult;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
/**
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class FailsafeSummaryXmlUtils
{
public static final Charset UTF8 = Charset.forName( "UTF-8" );
private FailsafeSummaryXmlUtils()
{
throw new IllegalStateException( "No instantiable constructor." );
}
public static RunResult toRunResult( File failsafeSummaryXml ) throws JAXBException
{
FailsafeSummary failsafeSummary = JAXB.unmarshal( failsafeSummaryXml, FailsafeSummary.class );
return new RunResult( failsafeSummary.getCompleted(), failsafeSummary.getErrors(),
failsafeSummary.getFailures(), failsafeSummary.getSkipped(),
failsafeSummary.getFailureMessage(), failsafeSummary.isTimeout()
);
}
public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml )
throws JAXBException, IOException
{
fromRunResultToFile( fromRunResult, toFailsafeSummaryXml, UTF8 );
}
public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml, Charset encoding )
throws JAXBException, IOException
{
FailsafeSummary summary = new FailsafeSummary();
summary.setCompleted( fromRunResult.getCompletedCount() );
summary.setFailureMessage( fromRunResult.getFailure() );
summary.setErrors( fromRunResult.getErrors() );
summary.setFailures( fromRunResult.getFailures() );
summary.setSkipped( fromRunResult.getSkipped() );
summary.setTimeout( fromRunResult.isTimeout() );
summary.setResult( ErrorType.fromValue( fromRunResult.getFailsafeCode() ) );
String unmarshalled = JAXB.marshal( summary, encoding );
OutputStreamWriter os = new OutputStreamWriter( new FileOutputStream( toFailsafeSummaryXml ), encoding );
try
{
os.write( unmarshalled );
os.flush();
}
finally
{
os.close();
}
}
public static void writeSummary( RunResult mergedSummary, File mergedSummaryFile, boolean inProgress,
Charset encoding )
throws IOException, JAXBException
{
if ( !mergedSummaryFile.getParentFile().isDirectory() )
{
//noinspection ResultOfMethodCallIgnored
mergedSummaryFile.getParentFile().mkdirs();
}
if ( mergedSummaryFile.exists() && inProgress )
{
RunResult runResult = toRunResult( mergedSummaryFile );
mergedSummary = mergedSummary.aggregate( runResult );
}
fromRunResultToFile( mergedSummary, mergedSummaryFile, encoding );
}
}
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java
new file mode 100644
index 0000000000..ba3fdd0420
--- /dev/null
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java
@@ -0,0 +1 @@
+package org.apache.maven.plugin.failsafe.xmlsummary;
/*
* 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.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.PropertyException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.helpers.DefaultValidationEventHandler;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import static javax.xml.bind.JAXBContext.newInstance;
import static javax.xml.bind.Marshaller.JAXB_ENCODING;
import static javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT;
import static javax.xml.bind.Marshaller.JAXB_FRAGMENT;
/**
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class JAXB
{
private JAXB()
{
throw new IllegalStateException( "Not instantiated constructor." );
}
public static T unmarshal( File source, Class rootXmlNode ) throws JAXBException
{
return unmarshal( source, rootXmlNode, Collections.emptyMap() );
}
public static T unmarshal( File source, Class rootXmlNode, Map props )
throws JAXBException
{
Class>[] classesToBeBound = { rootXmlNode };
JAXBContext ctx = newInstance( classesToBeBound );
Unmarshaller unmarshaller = ctx.createUnmarshaller();
properties( props, unmarshaller );
unmarshaller.setEventHandler( new DefaultValidationEventHandler() );
JAXBElement element = unmarshaller.unmarshal( new StreamSource( source ), rootXmlNode );
return element.getValue();
}
public static String marshal( T bean, Charset encoding ) throws JAXBException, IOException
{
return marshal( bean, Collections.emptyMap(), encoding ).toString();
}
@SuppressWarnings( "unchecked" )
public static StringWriter marshal( T bean, Map props, Charset encoding )
throws JAXBException, IOException
{
return marshal( bean, (Class) bean.getClass(), props, encoding );
}
public static StringWriter marshal( T bean, Class type, Map props, Charset encoding )
throws JAXBException, IOException
{
JAXBElement rootElement = buildJaxbElement( bean, type );
return marshal( rootElement, type, props, encoding );
}
public static StringWriter marshal( JAXBElement rootElement, Class type,
Map props, Charset encoding )
throws JAXBException, IOException
{
StringWriter destination = new StringWriter( 256 );
marshal( rootElement, type, props, destination, encoding );
destination.flush();
return destination;
}
public static void marshal( JAXBElement rootElement, Class type, Map props,
Writer destination, Charset encoding ) throws JAXBException
{
Class>[] classesToBeBound = { type };
JAXBContext context = newInstance( classesToBeBound );
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty( JAXB_ENCODING, encoding.name() );
marshaller.setProperty( JAXB_FORMATTED_OUTPUT, true );
marshaller.setProperty( JAXB_FRAGMENT, true );
properties( props, marshaller );
marshaller.marshal( rootElement, destination );
}
private static JAXBElement buildJaxbElement( T bean, Class type )
{
XmlRootElement xmlRootElement = type.getAnnotation( XmlRootElement.class );
if ( xmlRootElement == null )
{
return null;
}
QName root = new QName( "", xmlRootElement.name() );
return new JAXBElement( root, type, bean );
}
private static void properties( Map props, Unmarshaller unmarshaller ) throws PropertyException
{
for ( Entry e : props.entrySet() )
{
unmarshaller.setProperty( e.getKey(), e.getValue() );
}
}
private static void properties( Map props, Marshaller marshaller ) throws PropertyException
{
for ( Entry e : props.entrySet() )
{
marshaller.setProperty( e.getKey(), e.getValue() );
}
}
}
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ObjectFactory.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ObjectFactory.java
new file mode 100644
index 0000000000..7e1c252c62
--- /dev/null
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ObjectFactory.java
@@ -0,0 +1 @@
+package org.apache.maven.plugin.failsafe.xmlsummary;
/*
* 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.xml.bind.annotation.XmlRegistry;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the org.apache.maven.surefire.suite package.
*
An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*/
@XmlRegistry
public class ObjectFactory
{
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package:
* org.apache.maven.surefire.suite
*/
public ObjectFactory()
{
}
/**
* Create an instance of {@link FailsafeSummary }
*/
public FailsafeSummary createFailsafeSummary()
{
return new FailsafeSummary();
}
}
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/MarshallerUnmarshallerTest.java b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/MarshallerUnmarshallerTest.java
new file mode 100644
index 0000000000..4386d71754
--- /dev/null
+++ b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/MarshallerUnmarshallerTest.java
@@ -0,0 +1 @@
+package org.apache.maven.plugin.failsafe;
/*
* 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.failsafe.xmlsummary.FailsafeSummary;
import org.apache.maven.plugin.failsafe.xmlsummary.FailsafeSummaryXmlUtils;
import org.apache.maven.plugin.failsafe.xmlsummary.JAXB;
import org.junit.Test;
import java.io.File;
import java.io.FileWriter;
import java.util.List;
import static org.apache.maven.plugin.failsafe.xmlsummary.ErrorType.FAILURE;
import static org.fest.assertions.Assertions.assertThat;
public class MarshallerUnmarshallerTest
{
@Test
public void shouldUnmarshallExistingXmlFile() throws Exception
{
File xml = new File( "target/test-classes/org/apache/maven/plugin/failsafe/failsafe-summary.xml" );
FailsafeSummary summary = JAXB.unmarshal( xml, FailsafeSummary.class );
assertThat( summary.getCompleted() )
.isEqualTo( 7 );
assertThat( summary.getErrors() )
.isEqualTo( 1 );
assertThat( summary.getFailures() )
.isEqualTo( 2 );
assertThat( summary.getSkipped() )
.isEqualTo( 3 );
assertThat( summary.getFailureMessage() )
.contains( "There was an error in the forked processtest "
+ "subsystem#no method RuntimeException Hi There!"
);
assertThat( summary.getFailureMessage() )
.contains( "There was an error in the forked processtest "
+ "subsystem#no method RuntimeException Hi There!"
+ "\n\tat org.apache.maven.plugin.surefire.booterclient.ForkStarter"
+ ".awaitResultsDone(ForkStarter.java:489)"
);
List exceptionMessages = summary.extractExceptionMessageLines();
assertThat( exceptionMessages )
.hasSize( 1 );
assertThat( exceptionMessages.get( 0 ) )
.isEqualTo( "ExecutionException There was an error in the forked processtest "
+ "subsystem#no method RuntimeException Hi There!"
);
summary.setFailureMessage( null );
assertThat( summary.extractExceptionMessageLines() )
.isEmpty();
}
@Test
public void shouldEqualTwoSameXml() throws Exception
{
File xml = new File( "target/test-classes/org/apache/maven/plugin/failsafe/failsafe-summary.xml" );
FailsafeSummary summary1 = JAXB.unmarshal( xml, FailsafeSummary.class );
FailsafeSummary summary2 = JAXB.unmarshal( xml, FailsafeSummary.class );
assertThat( summary1 )
.isEqualTo( summary2 );
}
@Test
public void shouldMarshallAndUnmarshallSameXml() throws Exception
{
FailsafeSummary expected = new FailsafeSummary();
expected.setResult( FAILURE );
expected.setTimeout( true );
expected.setCompleted( 7 );
expected.setErrors( 1 );
expected.setFailures( 2 );
expected.setSkipped( 3 );
expected.setFailureMessage( "There was an error in the forked processtest "
+ "subsystem#no method RuntimeException Hi There!"
+ "\n\tat org.apache.maven.plugin.surefire.booterclient.ForkStarter"
+ ".awaitResultsDone(ForkStarter.java:489)"
);
File xml = File.createTempFile( "failsafe-summary", ".xml" );
String xmlText = JAXB.marshal( expected, FailsafeSummaryXmlUtils.UTF8 );
FileWriter fileWriter = new FileWriter( xml );
fileWriter.write( xmlText );
fileWriter.flush();
fileWriter.close();
FailsafeSummary actual = JAXB.unmarshal( xml, FailsafeSummary.class );
assertThat( actual )
.isEqualTo( expected );
List exceptionMessages = actual.extractExceptionMessageLines();
assertThat( exceptionMessages )
.hasSize( 1 );
assertThat( exceptionMessages.get( 0 ) )
.isEqualTo( "There was an error in the forked processtest "
+ "subsystem#no method RuntimeException Hi There!"
);
}
}
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java
new file mode 100644
index 0000000000..1ffb7d92ee
--- /dev/null
+++ b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java
@@ -0,0 +1 @@
+package org.apache.maven.plugin.failsafe;
/*
* 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.failsafe.xmlsummary.FailsafeSummaryXmlUtils;
import org.apache.maven.surefire.suite.RunResult;
import org.junit.Test;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import static org.fest.assertions.Assertions.assertThat;
/**
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public class RunResultTest
{
@Test
public void testAggregatedValues()
{
RunResult simple = getSimpleAggregate();
assertThat( simple.getCompletedCount() )
.isEqualTo( 20 );
assertThat( simple.getErrors() )
.isEqualTo( 3 );
assertThat( simple.getFailures() )
.isEqualTo( 7 );
assertThat( simple.getSkipped() )
.isEqualTo( 4 );
assertThat( simple.getFlakes() )
.isEqualTo( 2 );
}
@Test
public void testSerialization()
throws IOException, JAXBException
{
writeReadCheck( getSimpleAggregate() );
}
@Test
public void testFailures()
throws IOException, JAXBException
{
writeReadCheck( new RunResult( 0, 1, 2, 3, "stacktraceHere", false ) );
}
@Test
public void testSkipped()
throws IOException, JAXBException
{
writeReadCheck( new RunResult( 3, 2, 1, 0, null, true ) );
}
@Test
public void testAppendSerialization()
throws IOException, JAXBException
{
RunResult simpleAggregate = getSimpleAggregate();
RunResult additional = new RunResult( 2, 1, 2, 2, "msg " + ( (char) 0x0E01 ), true );
File summary = File.createTempFile( "failsafe", "test" );
FailsafeSummaryXmlUtils.writeSummary( simpleAggregate, summary, false, FailsafeSummaryXmlUtils.UTF8 );
FailsafeSummaryXmlUtils.writeSummary( additional, summary, true, FailsafeSummaryXmlUtils.UTF8 );
RunResult actual = FailsafeSummaryXmlUtils.toRunResult( summary );
//noinspection ResultOfMethodCallIgnored
summary.delete();
RunResult expected = simpleAggregate.aggregate( additional );
assertThat( expected.getCompletedCount() )
.isEqualTo( 22 );
assertThat( expected.getErrors() )
.isEqualTo( 4 );
assertThat( expected.getFailures() )
.isEqualTo( 9 );
assertThat( expected.getSkipped() )
.isEqualTo( 6 );
assertThat( expected.getFlakes() )
.isEqualTo( 2 );
assertThat( expected.getFailure() )
.isEqualTo( "msg " + ( (char) 0x0E01 ) );
assertThat( expected.isTimeout() )
.isTrue();
assertThat( actual )
.isEqualTo( expected );
}
@Test
public void shouldAcceptAliasCharset()
{
Charset charset1 = IntegrationTestMojo.toCharset( "UTF8" );
assertThat( charset1.name() ).isEqualTo( "UTF-8" );
Charset charset2 = IntegrationTestMojo.toCharset( "utf8" );
assertThat( charset2.name() ).isEqualTo( "UTF-8" );
}
private void writeReadCheck( RunResult expected )
throws IOException, JAXBException
{
File tmp = File.createTempFile( "test", "xml" );
FailsafeSummaryXmlUtils.fromRunResultToFile( expected, tmp );
RunResult actual = FailsafeSummaryXmlUtils.toRunResult( tmp );
//noinspection ResultOfMethodCallIgnored
tmp.delete();
assertThat( actual )
.isEqualTo( expected );
}
private RunResult getSimpleAggregate()
{
RunResult resultOne = new RunResult( 10, 1, 3, 2, 1 );
RunResult resultTwo = new RunResult( 10, 2, 4, 2, 1 );
return resultOne.aggregate( resultTwo );
}
}
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/test/resources/org/apache/maven/plugin/failsafe/failsafe-summary.xml b/maven-failsafe-plugin/src/test/resources/org/apache/maven/plugin/failsafe/failsafe-summary.xml
new file mode 100644
index 0000000000..b1fe1f9f21
--- /dev/null
+++ b/maven-failsafe-plugin/src/test/resources/org/apache/maven/plugin/failsafe/failsafe-summary.xml
@@ -0,0 +1 @@
+
7123
\ No newline at end of file
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 e4b340a70f..bab37c722c 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
@@ -165,31 +165,31 @@ private static boolean failIfNoTests( SurefireReportParameters reportParameters
return reportParameters.getFailIfNoTests() != null && reportParameters.getFailIfNoTests();
}
- private static boolean isNotFatal( Exception firstForkException )
+ private static boolean isFatal( Exception firstForkException )
{
- return firstForkException == null || firstForkException instanceof TestSetFailedException;
+ return firstForkException != null && !( firstForkException instanceof TestSetFailedException );
}
private static void throwException( SurefireReportParameters reportParameters, RunResult result,
Exception firstForkException )
throws MojoFailureException, MojoExecutionException
{
- if ( isNotFatal( firstForkException ) )
+ if ( isFatal( firstForkException ) || result.isInternalError() )
{
- throw new MojoFailureException( createErrorMessage( reportParameters, result, firstForkException ),
+ throw new MojoExecutionException( createErrorMessage( reportParameters, result, firstForkException ),
firstForkException );
}
else
{
- throw new MojoExecutionException( createErrorMessage( reportParameters, result, firstForkException ),
- firstForkException );
+ throw new MojoFailureException( createErrorMessage( reportParameters, result, firstForkException ),
+ firstForkException );
}
}
private static String createErrorMessage( SurefireReportParameters reportParameters, RunResult result,
Exception firstForkException )
{
- StringBuilder msg = new StringBuilder( 128 );
+ StringBuilder msg = new StringBuilder( 512 );
if ( result.isTimeout() )
{
@@ -199,7 +199,10 @@ private static String createErrorMessage( SurefireReportParameters reportParamet
{
msg.append( "There are test failures.\n\nPlease refer to " )
.append( reportParameters.getReportsDirectory() )
- .append( " for the individual test results." );
+ .append( " for the individual test results." )
+ .append( '\n' )
+ .append( "Please refer to dump files (if any exist) "
+ + "[date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream" );
}
if ( firstForkException != null && firstForkException.getLocalizedMessage() != null )
@@ -208,6 +211,12 @@ private static String createErrorMessage( SurefireReportParameters reportParamet
.append( firstForkException.getLocalizedMessage() );
}
+ if ( result.isFailure() )
+ {
+ msg.append( '\n' )
+ .append( result.getFailure() );
+ }
+
return msg.toString();
}
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 3981c792d0..2d0ae387d9 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
@@ -30,6 +30,7 @@
import org.apache.maven.plugin.surefire.booterclient.output.ForkClient;
import org.apache.maven.plugin.surefire.booterclient.output.NativeStdErrStreamConsumer;
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;
@@ -44,11 +45,11 @@
import org.apache.maven.surefire.booter.SurefireBooterForkException;
import org.apache.maven.surefire.booter.SurefireExecutionException;
import org.apache.maven.surefire.providerapi.SurefireProvider;
-import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.surefire.report.StackTraceWriter;
import org.apache.maven.surefire.suite.RunResult;
import org.apache.maven.surefire.testset.TestRequest;
import org.apache.maven.surefire.util.DefaultScanResult;
+import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.io.Closeable;
import java.io.File;
@@ -83,20 +84,20 @@
import static org.apache.maven.plugin.surefire.booterclient.ForkNumberBucket.drawNumber;
import static org.apache.maven.plugin.surefire.booterclient.ForkNumberBucket.returnNumber;
import static org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream
- .TestLessInputStreamBuilder;
+ .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.booter.Classpath.join;
import static org.apache.maven.surefire.booter.SystemPropertyManager.writePropertiesFile;
-import static org.apache.maven.surefire.suite.RunResult.timeout;
-import static org.apache.maven.surefire.suite.RunResult.failure;
import static org.apache.maven.surefire.suite.RunResult.SUCCESS;
+import static org.apache.maven.surefire.suite.RunResult.failure;
+import static org.apache.maven.surefire.suite.RunResult.timeout;
import static org.apache.maven.surefire.util.internal.ConcurrencyUtils.countDownToZero;
import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThread;
import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThreadFactory;
-import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
+import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
/**
* Starts the fork or runs in-process.
@@ -128,6 +129,10 @@ public class ForkStarter
private static final AtomicInteger SYSTEM_PROPERTIES_FILE_COUNTER = new AtomicInteger();
+ private static final String DUMP_FILE_PREFIX = DumpFileUtils.newFormattedDateFileName() + "-jvmRun";
+
+ private static final AtomicInteger DUMP_FILE_POSTFIX_COUNTER = new AtomicInteger();
+
private final ScheduledExecutorService pingThreadScheduler = createPingScheduler();
private final ScheduledExecutorService timeoutCheckScheduler;
@@ -529,10 +534,12 @@ private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkC
AbstractForkInputStream testProvidingInputStream, boolean readTestsFromInStream )
throws SurefireBooterForkException
{
+ final String tempDir;
final File surefireProperties;
final File systPropsFile;
try
{
+ tempDir = forkConfiguration.getTempDirectory().getCanonicalPath();
BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration );
surefireProperties = booterSerializer.serialize( providerProperties, providerConfiguration,
@@ -577,11 +584,12 @@ private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkC
testProvidingInputStream.setFlushReceiverProvider( cli );
}
- cli.createArg().setFile( surefireProperties );
-
+ cli.createArg().setValue( tempDir );
+ cli.createArg().setValue( DUMP_FILE_PREFIX + DUMP_FILE_POSTFIX_COUNTER.incrementAndGet() );
+ cli.createArg().setValue( surefireProperties.getName() );
if ( systPropsFile != null )
{
- cli.createArg().setFile( systPropsFile );
+ cli.createArg().setValue( systPropsFile.getName() );
}
final ThreadedStreamConsumer threadedStreamConsumer = new ThreadedStreamConsumer( forkClient );
@@ -640,10 +648,10 @@ else if ( result != SUCCESS )
{
StackTraceWriter errorInFork = forkClient.getErrorInFork();
// noinspection ThrowFromFinallyBlock
- throw new RuntimeException( "There was an error in the forked process"
+ throw new SurefireBooterForkException( "There was an error in the forked process"
+ detail
+ '\n'
- + errorInFork.writeTraceToString(), cause );
+ + errorInFork.getThrowable().getLocalizedMessage(), cause );
}
if ( !forkClient.isSaidGoodBye() )
{
@@ -654,7 +662,7 @@ else if ( result != SUCCESS )
testsInProgress += "\n" + test;
}
// noinspection ThrowFromFinallyBlock
- throw new RuntimeException(
+ throw new SurefireBooterForkException(
"The forked VM terminated without properly saying goodbye. VM crash or System.exit called?"
+ "\nCommand was " + cli.toString() + detail + errorCode + testsInProgress, cause );
}
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 898a165e02..46c747b276 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
@@ -271,6 +271,7 @@ private void processLine( String s )
.warning( createConsoleMessage( remaining ) );
break;
default:
+ LostCommandsDumpSingleton.getSingleton().dumpText( s, defaultReporterFactory );
log.warning( s );
}
}
@@ -278,15 +279,18 @@ private void processLine( String s )
{
// SUREFIRE-859
log.warning( s );
+ LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
}
catch ( NoSuchElementException e )
{
// SUREFIRE-859
log.warning( s );
+ LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
}
catch ( ReporterException e )
{
- throw new RuntimeException( e );
+ LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
+ throw e;
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
new file mode 100644
index 0000000000..364d8c3a00
--- /dev/null
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
@@ -0,0 +1 @@
+package org.apache.maven.plugin.surefire.booterclient.output;
/*
* 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.report.DefaultReporterFactory;
import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.io.File;
/**
* Dumps lost commands and caused exceptions in {@link ForkClient}.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
final class LostCommandsDumpSingleton
{
private static final LostCommandsDumpSingleton SINGLETON = new LostCommandsDumpSingleton();
private final String creationDate = DumpFileUtils.newFormattedDateFileName();
private LostCommandsDumpSingleton()
{
}
static LostCommandsDumpSingleton getSingleton()
{
return SINGLETON;
}
synchronized void dumpException( Throwable t, String msg, DefaultReporterFactory defaultReporterFactory )
{
File reportsDirectory = defaultReporterFactory.getReportsDirectory();
File dumpFile = new File( reportsDirectory, creationDate + ".dumpstream" );
DumpFileUtils.dumpException( t, msg, dumpFile );
}
synchronized void dumpException( Throwable t, DefaultReporterFactory defaultReporterFactory )
{
dumpException( t, null, defaultReporterFactory );
}
synchronized void dumpText( String msg, DefaultReporterFactory defaultReporterFactory )
{
File reportsDirectory = defaultReporterFactory.getReportsDirectory();
File dumpFile = new File( reportsDirectory, creationDate + ".dumpstream" );
DumpFileUtils.dumpText( msg, dumpFile );
}
}
\ No newline at end of file
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 24f5b3b23d..342e8833cf 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
@@ -31,6 +31,7 @@
import org.apache.maven.surefire.report.StackTraceWriter;
import org.apache.maven.surefire.suite.RunResult;
+import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -100,6 +101,11 @@ public RunListener createReporter()
return testSetRunListener;
}
+ public File getReportsDirectory()
+ {
+ return reportConfiguration.getReportsDirectory();
+ }
+
private ConsoleReporter createConsoleReporter()
{
return shouldReportToConsole() ? new ConsoleReporter( consoleLogger ) : NullConsoleReporter.INSTANCE;
diff --git a/maven-surefire-plugin/src/site/apt/developing.apt.vm b/maven-surefire-plugin/src/site/apt/developing.apt.vm
index fcb1930162..680201af66 100644
--- a/maven-surefire-plugin/src/site/apt/developing.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/developing.apt.vm
@@ -114,9 +114,9 @@ ForkedBooter#main
* JDK Versions
- The surefire booter is capable of booting all the way back to jdk1.5. Specifically
+ The surefire booter is capable of booting all the way back to jdk1.6. Specifically
this means <<>>, <<>>, <<>> and <<>> are
- source/target 1.5. The plugin and several providers are 1.5.
+ source/target 1.6. The plugin and several providers are 1.6.
* Provider Isolation
diff --git a/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm b/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm
index 9257c42b89..a5468530c3 100644
--- a/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm
@@ -89,6 +89,7 @@ Shutdown of Forked JVM
* Crashed forked JVM caused listing the crashed test(s)
- After the JVM exited abruptly, the console lists the message <<>> if the entire
- test-set has not been yet completed. This happens if a test exited, killed JVM or segmentation fault crashed JVM.
+ After the JVM exited abruptly, the console lists the message <<>> with a list of crashed tests if the
+ entire test-set has not been yet completed. This happens if a test exited, killed JVM or a segmentation fault crashed
+ JVM. In such cases you may be interested in dump files generated in reports directory, see {{{../faq.html#dumpfiles}FAQ}}.
diff --git a/maven-surefire-plugin/src/site/apt/index.apt.vm b/maven-surefire-plugin/src/site/apt/index.apt.vm
index 85c4d66328..0ec361cd9f 100644
--- a/maven-surefire-plugin/src/site/apt/index.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/index.apt.vm
@@ -31,7 +31,7 @@
Maven ${thisPlugin} Plugin
- Requirements: Maven 2.2.1 or 3.x, and JDK 1.5 or higher. Due to wrong formatting of console text messages
+ Requirements: Maven 2.2.1 or 3.x, and JDK 1.6 or higher. Due to wrong formatting of console text messages
in Maven Version prior to 3.1.0 it is highly recommended to use Maven 3.1.0 or higher.
#{if}(${project.artifactId}=="maven-surefire-plugin")
@@ -81,7 +81,7 @@ mvn verify
[]
- By default, these files are generated at <<<$\{basedir\}/target/${thisPlugin.toLowerCase()}-reports>>>.
+ By default, these files are generated in <<<$\{basedir\}/target/${thisPlugin.toLowerCase()}-reports/TEST-*.xml>>>.
The schema for the ${thisPlugin} XML reports is available at
{{{./xsd/${thisPlugin.toLowerCase()}-test-report.xsd}${thisPlugin} XML Report Schema}}.
@@ -89,6 +89,11 @@ mvn verify
For an HTML format of the report, please see the
{{{http://maven.apache.org/plugins/maven-surefire-report-plugin/}Maven Surefire Report Plugin}}.
+#{if}(${project.artifactId}=="maven-failsafe-plugin")
+ By default this plugin generates summary XML file at <<<$\{basedir\}/target/failsafe-reports/failsafe-summary.xml>>>
+ and the schema is available at {{{./xsd/failsafe-summary.xsd}Failsafe XML Summary Schema}}.
+#{end}
+
* Goals Overview
#{if}(${project.artifactId}=="maven-surefire-plugin")
diff --git a/maven-surefire-plugin/src/site/fml/faq.fml b/maven-surefire-plugin/src/site/fml/faq.fml
index de736dd778..92cbb1dca2 100644
--- a/maven-surefire-plugin/src/site/fml/faq.fml
+++ b/maven-surefire-plugin/src/site/fml/faq.fml
@@ -108,15 +108,34 @@ under the License.
- How maven-failsafe-plugin allows me to configure the jar file or classes to use
+ How maven-failsafe-plugin allows me to configure the jar file or classes to use?
- By default maven-failsafe-plugin uses project artifact file if packaging is set to "jar" in pom.xml.
- This can be modified and for instance set to main project classes if you use configuration parameter
+ By default maven-failsafe-plugin uses project artifact file in test classpath if packaging is set to "jar" in
+ pom.xml. This can be modified and for instance set to main project classes if you use configuration parameter
"classesDirectory". This would mean that you set value "${project.build.outputDirectory}" for the parameter
"classesDirectory" in the configuration of plugin.
+
+ How to dump fatal errors and stack trace of plugin runtime if it fails?
+
+
+ By default maven-failsafe-plugin and maven-surefire-plugin dumps fatal errors in dump files
+ and these are located in target/failsafe-reports and target/surefire-reports.
+ Names of dump files are formatted as follows:
+
+
+
+
+
+
+
+ Forked JVM process and plugin process communicate via std/out. If this channel is corrupted, for a whatever
+ reason, the dump of the corrupted stream appears in *.dumpstream.
+
+
+
diff --git a/maven-surefire-plugin/src/site/resources/xsd/bindings.xml b/maven-surefire-plugin/src/site/resources/xsd/bindings.xml
new file mode 100644
index 0000000000..4e2d9498f9
--- /dev/null
+++ b/maven-surefire-plugin/src/site/resources/xsd/bindings.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd b/maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd
new file mode 100644
index 0000000000..dca134b091
--- /dev/null
+++ b/maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
index bdd609211e..408e4a4ca9 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
@@ -22,9 +22,11 @@
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.io.DataInputStream;
import java.io.EOFException;
+import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Iterator;
@@ -85,6 +87,8 @@ public final class CommandReader
private volatile ConsoleLogger logger = new NullConsoleLogger();
+ private volatile File dumpFile;
+
private CommandReader()
{
}
@@ -99,6 +103,11 @@ public static CommandReader getReader()
return reader;
}
+ public void setDumpFile( File dumpFile )
+ {
+ this.dumpFile = dumpFile;
+ }
+
public CommandReader setShutdown( Shutdown shutdown )
{
this.shutdown = shutdown;
@@ -123,6 +132,7 @@ public boolean awaitStarted()
}
catch ( InterruptedException e )
{
+ DumpFileUtils.dumpException( e, dumpFile );
throw new TestSetFailedException( e.getLocalizedMessage() );
}
}
@@ -375,7 +385,9 @@ public void run()
Command command = decode( stdIn );
if ( command == null )
{
- logger.error( "[SUREFIRE] std/in stream corrupted: first sequence not recognized" );
+ String errorMessage = "[SUREFIRE] std/in stream corrupted: first sequence not recognized";
+ DumpFileUtils.dumpText( errorMessage, dumpFile );
+ logger.error( errorMessage );
break;
}
else
@@ -411,6 +423,8 @@ public void run()
}
catch ( EOFException e )
{
+ DumpFileUtils.dumpException( e, dumpFile );
+
CommandReader.this.state.set( TERMINATED );
if ( !isTestSetFinished )
{
@@ -420,6 +434,8 @@ public void run()
}
catch ( IOException e )
{
+ DumpFileUtils.dumpException( e, dumpFile );
+
CommandReader.this.state.set( TERMINATED );
// If #stop() method is called, reader thread is interrupted and cause is InterruptedException.
if ( !( e.getCause() instanceof InterruptedException ) )
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
index a8466b28fe..1525e80c5d 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
@@ -19,21 +19,7 @@
* under the License.
*/
-import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.io.IOUtil;
-import org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter;
-import org.apache.maven.shared.utils.xml.Xpp3Dom;
-import org.apache.maven.shared.utils.xml.Xpp3DomBuilder;
-import org.apache.maven.shared.utils.xml.Xpp3DomWriter;
-
-import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
import java.io.PrintWriter;
/**
@@ -79,8 +65,7 @@ public static RunResult failure( RunResult accumulatedAtTimeout, Exception cause
private static RunResult errorCode( RunResult other, String failure, boolean timeout )
{
return new RunResult( other.getCompletedCount(), other.getErrors(), other.getFailures(), other.getSkipped(),
- failure, timeout );
-
+ failure, timeout );
}
public RunResult( int completedCount, int errors, int failures, int skipped )
@@ -171,7 +156,12 @@ public Integer getFailsafeCode() // Only used for compatibility reasons.
/* Indicates if the tests are error free */
public boolean isErrorFree()
{
- return getFailures() == 0 && getErrors() == 0;
+ return getFailures() == 0 && getErrors() == 0 && !isFailure();
+ }
+
+ public boolean isInternalError()
+ {
+ return getFailures() == 0 && getErrors() == 0 && isFailure();
}
/* Indicates test timeout or technical failure */
@@ -212,83 +202,6 @@ public static RunResult noTestsRun()
return new RunResult( 0, 0, 0, 0 );
}
- private Xpp3Dom create( String node, String value )
- {
- Xpp3Dom dom = new Xpp3Dom( node );
- dom.setValue( value );
- return dom;
- }
-
- private Xpp3Dom create( String node, int value )
- {
- return create( node, Integer.toString( value ) );
- }
-
- Xpp3Dom asXpp3Dom()
- {
- Xpp3Dom dom = new Xpp3Dom( "failsafe-summary" );
- Integer failsafeCode = getFailsafeCode();
- if ( failsafeCode != null )
- {
- dom.setAttribute( "result", Integer.toString( failsafeCode ) );
- }
- dom.setAttribute( "timeout", Boolean.toString( this.timeout ) );
- dom.addChild( create( "completed", this.completedCount ) );
- dom.addChild( create( "errors", this.errors ) );
- dom.addChild( create( "failures", this.failures ) );
- dom.addChild( create( "skipped", this.skipped ) );
- dom.addChild( create( "failureMessage", this.failure ) );
- return dom;
- }
-
- public static RunResult fromInputStream( InputStream inputStream, String encoding )
- throws FileNotFoundException
- {
- Xpp3Dom dom = Xpp3DomBuilder.build( inputStream, encoding );
- boolean timeout = Boolean.parseBoolean( dom.getAttribute( "timeout" ) );
- int completed = Integer.parseInt( dom.getChild( "completed" ).getValue() );
- int errors = Integer.parseInt( dom.getChild( "errors" ).getValue() );
- int failures = Integer.parseInt( dom.getChild( "failures" ).getValue() );
- int skipped = Integer.parseInt( dom.getChild( "skipped" ).getValue() );
- String failureMessage1 = dom.getChild( "failureMessage" ).getValue();
- String failureMessage = StringUtils.isEmpty( failureMessage1 ) ? null : failureMessage1;
- return new RunResult( completed, errors, failures, skipped, failureMessage, timeout );
- }
-
- public void writeSummary( File summaryFile, boolean inProgress, String encoding )
- throws IOException
- {
- if ( !summaryFile.getParentFile().isDirectory() )
- {
- //noinspection ResultOfMethodCallIgnored
- summaryFile.getParentFile().mkdirs();
- }
-
- FileInputStream fin = null;
- FileWriter writer = null;
- try
- {
- RunResult mergedSummary = this;
- if ( summaryFile.exists() && inProgress )
- {
- fin = new FileInputStream( summaryFile );
-
- RunResult runResult = RunResult.fromInputStream( new BufferedInputStream( fin ), encoding );
- mergedSummary = mergedSummary.aggregate( runResult );
- }
-
- writer = new FileWriter( summaryFile );
- writer.write( "\n" );
- PrettyPrintXMLWriter prettyPrintXMLWriter = new PrettyPrintXMLWriter( writer );
- Xpp3DomWriter.write( prettyPrintXMLWriter, mergedSummary.asXpp3Dom() );
- }
- finally
- {
- IOUtil.close( fin );
- IOUtil.close( writer );
- }
- }
-
@SuppressWarnings( "RedundantIfStatement" )
public boolean equals( Object o )
{
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
new file mode 100644
index 0000000000..47a13868d7
--- /dev/null
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
@@ -0,0 +1 @@
+package org.apache.maven.surefire.util.internal;
/*
* 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.report.ReporterConfiguration;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Dumps a text or exception in dump file.
* Each call logs a date when it was written to the dump file.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class DumpFileUtils
{
private DumpFileUtils()
{
throw new IllegalStateException( "no instantiable constructor" );
}
/**
* New dump file. Synchronized object appears in main memory and perfectly visible in other threads.
*/
public static synchronized File newDumpFile( String dumpFileName, ReporterConfiguration configuration )
{
return new File( configuration.getReportsDirectory(), dumpFileName );
}
public static void dumpException( Throwable t, File dumpFile )
{
dumpException( t, null, dumpFile );
}
public static void dumpException( Throwable t, String msg, File dumpFile )
{
try
{
if ( t != null && dumpFile != null && ( dumpFile.exists() || dumpFile.createNewFile() ) )
{
Writer fw = createWriter( dumpFile );
if ( msg != null )
{
fw.append( msg )
.append( StringUtils.NL );
}
PrintWriter pw = new PrintWriter( fw );
t.printStackTrace( pw );
pw.flush();
fw.append( StringUtils.NL )
.append( StringUtils.NL );
fw.flush();
fw.close();
}
}
catch ( Exception e )
{
// do nothing
}
}
public static void dumpText( String msg, File dumpFile )
{
try
{
if ( msg != null && dumpFile != null && ( dumpFile.exists() || dumpFile.createNewFile() ) )
{
Writer fw = createWriter( dumpFile )
.append( msg )
.append( StringUtils.NL )
.append( StringUtils.NL );
fw.flush();
fw.close();
}
}
catch ( Exception e )
{
// do nothing
}
}
public static String newFormattedDateFileName()
{
return new SimpleDateFormat( "yyyy-MM-dd'T'hh-mm-ss_SSS" ).format( new Date() );
}
private static Writer createWriter( File dumpFile ) throws IOException
{
return new OutputStreamWriter( new FileOutputStream( dumpFile, true ), "UTF-8" )
.append( "# Created on " )
.append( new SimpleDateFormat( "yyyy-MM-dd'T'hh:mm:ss.SSS" ).format( new Date() ) )
.append( StringUtils.NL );
}
}
\ No newline at end of file
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/suite/RunResultTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/suite/RunResultTest.java
index 007a26cdaf..e888ca259d 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/suite/RunResultTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/suite/RunResultTest.java
@@ -19,22 +19,13 @@
* under the License.
*/
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.StringWriter;
-import org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter;
-import org.apache.maven.shared.utils.xml.Xpp3DomWriter;
-
import junit.framework.TestCase;
/**
* @author Kristian Rosenvold
*/
public class RunResultTest
- extends TestCase
+ extends TestCase
{
public void testEmptySummaryShouldBeErrorFree()
@@ -49,76 +40,4 @@ public void testFailuresInFirstRun()
RunResult resultTwo = new RunResult( 20, 0, 0, 0 );
assertFalse( resultOne.aggregate( resultTwo ).isErrorFree() );
}
-
-
- public void testAggregatedValues()
- {
- RunResult simple = getSimpleAggregate();
- assertEquals( 20, simple.getCompletedCount() );
- assertEquals( 3, simple.getErrors() );
- assertEquals( 7, simple.getFailures() );
- assertEquals( 4, simple.getSkipped() );
- assertEquals( 2, simple.getFlakes() );
-
- }
-
- public void testSerialization()
- throws FileNotFoundException
- {
- writeReadCheck( getSimpleAggregate() );
- }
-
- public void testFailures()
- throws FileNotFoundException
- {
- writeReadCheck( new RunResult( 0, 1, 2, 3, "stacktraceHere", false ) );
- }
-
- public void testSkipped()
- throws FileNotFoundException
- {
- writeReadCheck( new RunResult( 3, 2, 1, 0, null, true ) );
- }
-
- public void testAppendSerialization()
- throws IOException
- {
- RunResult simpleAggregate = getSimpleAggregate();
- RunResult additional = new RunResult( 2, 1, 2, 2, null, true );
- File summary = File.createTempFile( "failsafe", "test" );
- simpleAggregate.writeSummary( summary, false, "utf-8" );
- additional.writeSummary( summary, true, "utf-8" );
-
- RunResult actual = RunResult.fromInputStream( new FileInputStream( summary ), "utf-8" );
- RunResult expected = simpleAggregate.aggregate( additional );
- assertEquals( expected, actual );
- //noinspection ResultOfMethodCallIgnored
- summary.delete();
-
- }
-
- private void writeReadCheck( RunResult simpleAggregate )
- throws FileNotFoundException
- {
- StringWriter writer = getStringWriter( simpleAggregate );
-
- RunResult actual =
- RunResult.fromInputStream( new ByteArrayInputStream( writer.getBuffer().toString().getBytes() ), "UTF-8" );
- assertEquals( simpleAggregate, actual );
- }
-
- private StringWriter getStringWriter( RunResult simpleAggregate )
- {
- StringWriter writer = new StringWriter();
- PrettyPrintXMLWriter wr = new PrettyPrintXMLWriter( writer );
- Xpp3DomWriter.write( wr, simpleAggregate.asXpp3Dom() );
- return writer;
- }
-
- private RunResult getSimpleAggregate()
- {
- RunResult resultOne = new RunResult( 10, 1, 3, 2, 1 );
- RunResult resultTwo = new RunResult( 10, 2, 4, 2, 1 );
- return resultOne.aggregate( resultTwo );
- }
}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 98040db30c..29047f2892 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -19,8 +19,17 @@
* under the License.
*/
+import org.apache.maven.surefire.providerapi.ProviderParameters;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
+import org.apache.maven.surefire.report.LegacyPojoStackTraceWriter;
+import org.apache.maven.surefire.report.ReporterFactory;
+import org.apache.maven.surefire.report.StackTraceWriter;
+import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
@@ -30,30 +39,24 @@
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.maven.surefire.providerapi.ProviderParameters;
-import org.apache.maven.surefire.providerapi.SurefireProvider;
-import org.apache.maven.surefire.report.LegacyPojoStackTraceWriter;
-import org.apache.maven.surefire.report.ReporterFactory;
-import org.apache.maven.surefire.report.StackTraceWriter;
-import org.apache.maven.surefire.suite.RunResult;
-import org.apache.maven.surefire.testset.TestSetFailedException;
-
import static java.lang.System.err;
import static java.lang.System.out;
import static java.lang.System.setErr;
import static java.lang.System.setOut;
import static java.lang.Thread.currentThread;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.maven.surefire.booter.CommandReader.getReader;
-import static org.apache.maven.surefire.booter.Shutdown.EXIT;
-import static org.apache.maven.surefire.booter.Shutdown.KILL;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_BYE;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_ERROR;
import static org.apache.maven.surefire.booter.ForkingRunListener.encode;
+import static org.apache.maven.surefire.booter.Shutdown.EXIT;
+import static org.apache.maven.surefire.booter.Shutdown.KILL;
import static org.apache.maven.surefire.booter.SystemPropertyManager.setSystemProperties;
import static org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg;
import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThreadFactory;
+import static org.apache.maven.surefire.util.internal.DumpFileUtils.dumpException;
+import static org.apache.maven.surefire.util.internal.DumpFileUtils.newDumpFile;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
-import static java.util.concurrent.TimeUnit.SECONDS;
/**
* The part of the booter that is unique to a forked vm.
@@ -70,6 +73,8 @@ public final class ForkedBooter
private static final long DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS = 30;
private static final long PING_TIMEOUT_IN_SECONDS = 20;
private static final ScheduledExecutorService JVM_TERMINATOR = createJvmTerminator();
+ private static final String DUMP_FILE_EXT = ".dump";
+ private static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
private static volatile long systemExitTimeoutInSeconds = DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS;
@@ -84,22 +89,31 @@ public static void main( String... args )
final CommandReader reader = startupMasterProcessReader();
final ScheduledFuture> pingScheduler = listenToShutdownCommands( reader );
final PrintStream originalOut = out;
+ File dumpFile = null;
try
{
- if ( args.length > 1 )
+ final String tmpDir = args[0];
+ final String dumpFileName = args[1];
+ final String surefirePropsFileName = args[2];
+
+ BooterDeserializer booterDeserializer =
+ new BooterDeserializer( createSurefirePropertiesIfFileExists( tmpDir, surefirePropsFileName ) );
+ if ( args.length > 3 )
{
- setSystemProperties( new File( args[1] ) );
+ final String effectiveSystemPropertiesFileName = args[3];
+ setSystemProperties( new File( tmpDir, effectiveSystemPropertiesFileName ) );
}
- File surefirePropertiesFile = new File( args[0] );
- InputStream stream = surefirePropertiesFile.exists() ? new FileInputStream( surefirePropertiesFile ) : null;
- BooterDeserializer booterDeserializer = new BooterDeserializer( stream );
- ProviderConfiguration providerConfiguration = booterDeserializer.deserialize();
+ final ProviderConfiguration providerConfiguration = booterDeserializer.deserialize();
+
+ dumpFile = createDumpFile( dumpFileName, providerConfiguration );
+ reader.setDumpFile( createDumpstreamFile( dumpFileName, providerConfiguration ) );
+
final StartupConfiguration startupConfiguration = booterDeserializer.getProviderConfiguration();
systemExitTimeoutInSeconds =
providerConfiguration.systemExitTimeout( DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS );
- TypeEncodedValue forkedTestSet = providerConfiguration.getTestForFork();
- boolean readTestsFromInputStream = providerConfiguration.isReadTestsFromInStream();
+ final TypeEncodedValue forkedTestSet = providerConfiguration.getTestForFork();
+ final boolean readTestsFromInputStream = providerConfiguration.isReadTestsFromInStream();
final ClasspathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration();
if ( startupConfiguration.isManifestOnlyJarRequestedAndUsable() )
@@ -107,7 +121,7 @@ public static void main( String... args )
classpathConfiguration.trickClassPathWhenManifestOnlyClasspath();
}
- ClassLoader classLoader = currentThread().getContextClassLoader();
+ final ClassLoader classLoader = currentThread().getContextClassLoader();
classLoader.setDefaultAssertionStatus( classpathConfiguration.isEnableAssertions() );
startupConfiguration.writeSurefireTestClasspathProperty();
@@ -131,6 +145,7 @@ else if ( readTestsFromInputStream )
}
catch ( InvocationTargetException t )
{
+ dumpException( t, dumpFile );
StackTraceWriter stackTraceWriter =
new LegacyPojoStackTraceWriter( "test subsystem", "no method", t.getTargetException() );
StringBuilder stringBuilder = new StringBuilder();
@@ -139,6 +154,7 @@ else if ( readTestsFromInputStream )
}
catch ( Throwable t )
{
+ dumpException( t, dumpFile );
StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter( "test subsystem", "no method", t );
StringBuilder stringBuilder = new StringBuilder();
encode( stringBuilder, stackTraceWriter, false );
@@ -152,6 +168,7 @@ else if ( readTestsFromInputStream )
}
catch ( Throwable t )
{
+ dumpException( t, dumpFile );
// Just throwing does getMessage() and a local trace - we want to call printStackTrace for a full trace
// noinspection UseOfSystemOutOrSystemErr
t.printStackTrace( err );
@@ -330,4 +347,21 @@ private static SurefireProvider createProviderInCurrentClassloader( StartupConfi
String providerClass = startupConfiguration.getActualClassName();
return (SurefireProvider) instantiateOneArg( classLoader, providerClass, ProviderParameters.class, bpf );
}
+
+ private static InputStream createSurefirePropertiesIfFileExists( String tmpDir, String propFileName )
+ throws FileNotFoundException
+ {
+ File surefirePropertiesFile = new File( tmpDir, propFileName );
+ return surefirePropertiesFile.exists() ? new FileInputStream( surefirePropertiesFile ) : null;
+ }
+
+ private static File createDumpFile( String dumpFileName, ProviderConfiguration providerConfiguration )
+ {
+ return newDumpFile( dumpFileName + DUMP_FILE_EXT, providerConfiguration.getReporterConfiguration() );
+ }
+
+ private static File createDumpstreamFile( String dumpFileName, ProviderConfiguration providerConfiguration )
+ {
+ return newDumpFile( dumpFileName + DUMPSTREAM_FILE_EXT, providerConfiguration.getReporterConfiguration() );
+ }
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java
index ce90b3bc6e..2d03900507 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java
@@ -23,6 +23,11 @@
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Test;
+import java.io.File;
+import java.io.FilenameFilter;
+
+import static org.fest.assertions.Assertions.assertThat;
+
/**
* Test for checking that the output from a forked suite is properly captured even if the suite encounters a severe error.
@@ -37,7 +42,26 @@ public class CheckTestNgExecuteErrorIT
public void executionError()
throws Exception
{
- OutputValidator outputValidator = unpack( "/testng-execute-error" ).maven().withFailure().executeTest();
- outputValidator.verifyTextInLog( "at org.apache.maven.surefire.testng.TestNGExecutor.run" );
+ OutputValidator outputValidator = unpack( "/testng-execute-error" )
+ .maven()
+ .showErrorStackTraces()
+ .withFailure()
+ .executeTest();
+
+ File reportDir = outputValidator.getSurefireReportsDirectory();
+ String[] dumpFiles = reportDir.list( new FilenameFilter()
+ {
+ @Override
+ public boolean accept( File dir, String name )
+ {
+ return name.endsWith( ".dump" );
+ }
+ });
+ assertThat( dumpFiles ).isNotEmpty();
+ for ( String dump : dumpFiles )
+ {
+ outputValidator.getSurefireReportsFile( dump )
+ .assertContainsText( "at org.apache.maven.surefire.testng.TestNGExecutor.run" );
+ }
}
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java
index 8184abef4d..afd64932d3 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java
@@ -184,16 +184,21 @@ public TestFile getTargetFile( String fileName )
public TestFile getSurefireReportsFile( String fileName )
{
- File targetDir = getSubFile( "target/surefire-reports" );
+ File targetDir = getSurefireReportsDirectory();
return new TestFile( new File( targetDir, fileName ), this );
}
public TestFile getSurefireReportsXmlFile( String fileName )
{
- File targetDir = getSubFile( "target/surefire-reports" );
+ File targetDir = getSurefireReportsDirectory();
return new TestFile( new File( targetDir, fileName ), Charset.forName("UTF-8"), this );
}
+ public File getSurefireReportsDirectory()
+ {
+ return getSubFile( "target/surefire-reports" );
+ }
+
public TestFile getSiteFile( String fileName )
{
File targetDir = getSubFile( "target/site" );
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
index ecf01a801f..fdc10a88ec 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
@@ -20,11 +20,16 @@
*/
import org.apache.maven.it.VerificationException;
+import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
-
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.File;
+import java.io.FilenameFilter;
+
+import static org.fest.assertions.Assertions.assertThat;
+
/**
* SUREFIRE-613 Asserts proper test counts when running in parallel
*
@@ -83,12 +88,28 @@ public void invokeReporterException()
public void constructorRuntimeException()
throws Exception
{
- unpack( "surefire-141-pluggableproviders" )
- .sysProp( "constructorCrash", "runtimeException" )
- .maven()
- .withFailure()
- .executeTest()
- .verifyTextInLog( "Let's fail with a runtimeException" );
+ OutputValidator validator = unpack( "surefire-141-pluggableproviders" )
+ .sysProp( "constructorCrash", "runtimeException" )
+ .maven()
+ .withFailure()
+ .executeTest()
+ .verifyTextInLog( "Let's fail with a runtimeException" );
+
+ File reportDir = validator.getSurefireReportsDirectory();
+ String[] dumpFiles = reportDir.list( new FilenameFilter()
+ {
+ @Override
+ public boolean accept( File dir, String name )
+ {
+ return name.endsWith( ".dump" );
+ }
+ });
+ assertThat( dumpFiles ).isNotEmpty();
+ for ( String dump : dumpFiles )
+ {
+ validator.getSurefireReportsFile( dump )
+ .assertContainsText( "Let's fail with a runtimeException" );
+ }
}
}
\ No newline at end of file
From bd75bac320301db3fc4d8aec5b431f4d10171eb9 Mon Sep 17 00:00:00 2001
From: Michael Osipov
Date: Mon, 26 Dec 2016 17:51:23 +0100
Subject: [PATCH 029/194] [SUREFIRE-1315] Fix stylistic errors in
DefaultReporterFactory
Label refinements based on discussion on maven-dev.
---
.../surefire/report/DefaultReporterFactory.java | 12 ++++++------
.../surefire/report/DefaultReporterFactoryTest.java | 4 ++--
.../src/site/markdown/newerrorsummary.md | 4 ++--
.../surefire/its/JUnit4RerunFailingTestsIT.java | 10 +++++-----
.../Surefire1146RerunFailedAndParameterized.java | 2 +-
5 files changed, 16 insertions(+), 16 deletions(-)
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 342e8833cf..b4a6f30f3f 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
@@ -427,12 +427,12 @@ boolean printTestFailures( TestResultType type )
enum TestResultType
{
- error( "Erroneous Tests: " ),
- failure( "Failed Tests: " ),
- flake( "Flaky Tests: " ),
- success( "Success: " ),
- skipped( "Skipped: " ),
- unknown( "Unknown: " );
+ error( "Errors: " ),
+ failure( "Failures: " ),
+ flake( "Flakes: " ),
+ success( "Success: " ),
+ skipped( "Skipped: " ),
+ unknown( "Unknown: " );
private final String logPrefix;
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 98f97bd81b..fbe875de2a 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
@@ -120,7 +120,7 @@ public void testMergeTestHistoryResult()
// Now test the result will be printed out correctly
factory.printTestFailures( flake );
String[] expectedFlakeOutput =
- { "Flaky Tests: ", TEST_FOUR, " Run 1: " + ASSERTION_FAIL, " Run 2: PASS", "", TEST_ONE,
+ { "Flakes: ", TEST_FOUR, " Run 1: " + ASSERTION_FAIL, " Run 2: PASS", "", TEST_ONE,
" Run 1: " + ERROR, " Run 2: " + ASSERTION_FAIL, " Run 3: PASS", "", TEST_TWO, " Run 1: " + ERROR,
" Run 2: PASS", "" };
assertEquals( asList( expectedFlakeOutput ), reporter.getMessages() );
@@ -128,7 +128,7 @@ public void testMergeTestHistoryResult()
reporter.reset();
factory.printTestFailures( error );
String[] expectedFailureOutput =
- { "Erroneous Tests: ", TEST_THREE, " Run 1: " + ASSERTION_FAIL, " Run 2: " + ERROR, " Run 3: " + ERROR, ""
+ { "Errors: ", TEST_THREE, " Run 1: " + ASSERTION_FAIL, " Run 2: " + ERROR, " Run 3: " + ERROR, ""
};
assertEquals( asList( expectedFailureOutput ), reporter.getMessages() );
diff --git a/maven-surefire-plugin/src/site/markdown/newerrorsummary.md b/maven-surefire-plugin/src/site/markdown/newerrorsummary.md
index 09537e3e26..88cd7c305b 100644
--- a/maven-surefire-plugin/src/site/markdown/newerrorsummary.md
+++ b/maven-surefire-plugin/src/site/markdown/newerrorsummary.md
@@ -26,11 +26,11 @@ report of the run or the files on disk.
### Example output:
- Failed Tests:
+ Failures:
Test1.assertion1:59 Bending maths expected:<[123]> but was:<[312]>
Test1.assertion2:64 True is false
- Erroneous Tests:
+ Errors:
Test1.nullPointerInLibrary:38 » NullPointer
Test1.failInMethod:43->innerFailure:68 NullPointer Fail here
Test1.failInLibInMethod:48 » NullPointer
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java
index f216e08e0c..7d6f5609d0 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4RerunFailingTestsIT.java
@@ -216,11 +216,11 @@ private void verifyFailuresOneRetryOneMethod( OutputValidator outputValidator )
private void verifyFailuresOneRetry( OutputValidator outputValidator, int run, int failures, int errors,
int flakes )
{
- outputValidator.verifyTextInLog( "Failed Tests:" );
+ outputValidator.verifyTextInLog( "Failures:" );
outputValidator.verifyTextInLog( "Run 1: FlakyFirstTimeTest.testFailingTestOne" );
outputValidator.verifyTextInLog( "Run 2: FlakyFirstTimeTest.testFailingTestOne" );
- outputValidator.verifyTextInLog( "Erroneous Tests:" );
+ outputValidator.verifyTextInLog( "Errors:" );
outputValidator.verifyTextInLog( "Run 1: FlakyFirstTimeTest.testErrorTestOne" );
outputValidator.verifyTextInLog( "Run 2: FlakyFirstTimeTest.testErrorTestOne" );
@@ -230,7 +230,7 @@ private void verifyFailuresOneRetry( OutputValidator outputValidator, int run, i
private void verifyOnlyFailuresOneRetry( OutputValidator outputValidator, int run, int failures, int errors,
int flakes )
{
- outputValidator.verifyTextInLog( "Failed Tests:" );
+ outputValidator.verifyTextInLog( "Failures:" );
outputValidator.verifyTextInLog( "Run 1: FlakyFirstTimeTest.testFailingTestOne" );
outputValidator.verifyTextInLog( "Run 2: FlakyFirstTimeTest.testFailingTestOne" );
@@ -240,7 +240,7 @@ private void verifyOnlyFailuresOneRetry( OutputValidator outputValidator, int ru
private void verifyFailuresTwoRetry( OutputValidator outputValidator, int run, int failures, int errors,
int flakes )
{
- outputValidator.verifyTextInLog( "Flaky Tests:" );
+ outputValidator.verifyTextInLog( "Flakes:" );
outputValidator.verifyTextInLog( "Run 1: FlakyFirstTimeTest.testFailingTestOne" );
outputValidator.verifyTextInLog( "Run 2: FlakyFirstTimeTest.testFailingTestOne" );
outputValidator.verifyTextInLog( "Run 3: PASS" );
@@ -253,7 +253,7 @@ private void verifyFailuresTwoRetry( OutputValidator outputValidator, int run, i
private void verifyFailuresNoRetry( OutputValidator outputValidator, int run, int failures, int errors, int flakes )
{
- outputValidator.verifyTextInLog( "Failed Tests:" );
+ outputValidator.verifyTextInLog( "Failures:" );
outputValidator.verifyTextInLog( "testFailingTestOne(junit4.FlakyFirstTimeTest)" );
outputValidator.verifyTextInLog( "ERROR" );
outputValidator.verifyTextInLog( "testErrorTestOne(junit4.FlakyFirstTimeTest)" );
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java
index 8ebc6ecc02..84735a9607 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java
@@ -39,7 +39,7 @@ public void testsAreRerun()
private void verify( OutputValidator outputValidator, int run, int failures, int errors, int skipped, int flakes )
{
- outputValidator.verifyTextInLog( "Flaky Tests:" );
+ outputValidator.verifyTextInLog( "Flakes:" );
outputValidator.verifyTextInLog( "jiras.surefire1146.CustomDescriptionParameterizedTest.flakyTest[0: (Test11); Test12; Test13;](jiras.surefire1146.CustomDescriptionParameterizedTest)" );
outputValidator.verifyTextInLog( "Run 1: CustomDescriptionParameterizedTest.flakyTest:" );
outputValidator.verifyTextInLog( "Run 2: CustomDescriptionParameterizedTest.flakyTest:" );
From bd11d15edea9ea3c3785dc48d408b3f87193734e Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Wed, 28 Dec 2016 16:47:52 +0100
Subject: [PATCH 030/194] [SUREFIRE-1309] Added TODO @ 3.0
---
.../java/org/apache/maven/surefire/testset/TestListResolver.java | 1 +
1 file changed, 1 insertion(+)
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 f43d51eb0d..e2ae963b38 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
@@ -35,6 +35,7 @@
import static org.apache.maven.surefire.testset.ResolvedTest.Type.CLASS;
import static org.apache.maven.surefire.testset.ResolvedTest.Type.METHOD;
+// TODO In Surefire 3.0 see SUREFIRE-1309 and use normal fully qualified class name regex instead.
/**
* Resolved multi pattern filter e.g. -Dtest=MyTest#test,!AnotherTest#otherTest into an object model
* composed of included and excluded tests.
From cf6e75c8f1707cfcc12ccd7f1dbc95f2569ac252 Mon Sep 17 00:00:00 2001
From: Sander Verhagen
Date: Mon, 26 Dec 2016 23:39:56 -0800
Subject: [PATCH 031/194] SUREFIRE-1309: Clarifying use of regular expressions
for inclusion/exclusion
---
.../site/apt/examples/inclusion-exclusion.apt.vm | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/maven-surefire-plugin/src/site/apt/examples/inclusion-exclusion.apt.vm b/maven-surefire-plugin/src/site/apt/examples/inclusion-exclusion.apt.vm
index 22b1ce2e92..e5d3408b95 100644
--- a/maven-surefire-plugin/src/site/apt/examples/inclusion-exclusion.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/inclusion-exclusion.apt.vm
@@ -5,7 +5,7 @@
------
2010-01-09
------
-
+
~~ 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
@@ -164,7 +164,16 @@ Inclusions and Exclusions of Tests
+---+
Note the syntax <<<%regex[expr]>>>, where <<>> is the actual expression and the rest is just wrapping. Also
- note that regex matches are done over <<<*.class>>> files and not <<<*.java>>> files.
+ note the following about the use of regular expressions:
+
+ * Regex matches are done over <<<*.class>>> files and not <<<*.java>>> files
+
+ * Regex matches are done over paths using slashes ("<<>>>") and not package names using dots ("<<<.>>>"), so the
+ "<<<.>>>" in <<>> is a regex metacharacter, which happens to match any character, notably
+ the (forward) slashes ("<<>>>") that make up the path. Slashes here are , even on Windows
+
+ * The trailing <<<.class>>> is interpreted literally, and not as a regular expression ("<<<\.class>>>" does not
+ work here)
* Multiple Formats in One
From 9dd4074e83c0edae5e2050f66e9cadfdba40fe01 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 31 Dec 2016 02:42:35 +0100
Subject: [PATCH 032/194] [SUREFIRE-1239] ExecutionException
java.lang.RuntimeException:
org.apache.maven.surefire.report.ReporterException: When writing xml report
stdout/stderr (No such file or directory)
---
.../apache/maven/plugin/surefire/report/TestSetRunListener.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
index ca12c9031b..f0f996dd24 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
@@ -166,6 +166,7 @@ public void testSetCompleted( ReportEntry report )
addTestMethodStats();
detailsForThis.reset();
+ clearCapture();
}
// ----------------------------------------------------------------------
From df7e143c26b09678a0e6885b7ffcc65070688eb9 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 31 Dec 2016 06:26:36 +0100
Subject: [PATCH 033/194] [SUREFIRE-1322] Surefire and Failsafe should dump
critical errors in dump file and console
---
.../plugin/surefire/booterclient/ForkStarter.java | 9 ++++++---
.../surefire/booterclient/output/ForkClient.java | 3 ---
.../output/NativeStdErrStreamConsumer.java | 10 +++++++++-
3 files changed, 15 insertions(+), 7 deletions(-)
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 2d0ae387d9..05c4cc246a 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
@@ -603,10 +603,13 @@ private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkC
SurefireBooterForkException booterForkException = null;
try
{
+ NativeStdErrStreamConsumer stdErrConsumer =
+ new NativeStdErrStreamConsumer( forkClient.getDefaultReporterFactory() );
+
CommandLineCallable future =
- executeCommandLineAsCallable( cli, testProvidingInputStream, threadedStreamConsumer,
- new NativeStdErrStreamConsumer(), 0, closer,
- Charset.forName( FORK_STREAM_CHARSET_NAME ) );
+ executeCommandLineAsCallable( cli, testProvidingInputStream, threadedStreamConsumer,
+ stdErrConsumer, 0, closer,
+ Charset.forName( FORK_STREAM_CHARSET_NAME ) );
currentForkClients.add( forkClient );
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 46c747b276..d0aecf9302 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
@@ -272,19 +272,16 @@ private void processLine( String s )
break;
default:
LostCommandsDumpSingleton.getSingleton().dumpText( s, defaultReporterFactory );
- log.warning( s );
}
}
catch ( NumberFormatException e )
{
// SUREFIRE-859
- log.warning( s );
LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
}
catch ( NoSuchElementException e )
{
// SUREFIRE-859
- log.warning( s );
LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
}
catch ( ReporterException e )
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 84ca474e52..c92361dcaa 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
@@ -19,6 +19,7 @@
* under the License.
*/
+import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
import org.apache.maven.shared.utils.cli.StreamConsumer;
/**
@@ -31,8 +32,15 @@
public final class NativeStdErrStreamConsumer
implements StreamConsumer
{
+ private final DefaultReporterFactory defaultReporterFactory;
+
+ public NativeStdErrStreamConsumer( DefaultReporterFactory defaultReporterFactory )
+ {
+ this.defaultReporterFactory = defaultReporterFactory;
+ }
+
public void consumeLine( String line )
{
- System.err.println( line );
+ LostCommandsDumpSingleton.getSingleton().dumpText( line, defaultReporterFactory );
}
}
From 27fbe2c190a204e19dc42c86e9769bf384e7ec91 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 31 Dec 2016 06:46:06 +0100
Subject: [PATCH 034/194] [SUREFIRE-1310] ForkClient should handle only one
channel-id
---
.../booterclient/output/ForkClient.java | 37 ++++++++++++-------
1 file changed, 23 insertions(+), 14 deletions(-)
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 d0aecf9302..68ce40deeb 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
@@ -79,8 +79,6 @@ public class ForkClient
private static final long START_TIME_ZERO = 0L;
private static final long START_TIME_NEGATIVE_TIMEOUT = -1L;
- private final RunListener testSetReporter;
-
private final DefaultReporterFactory defaultReporterFactory;
private final Properties testVmSystemProperties;
@@ -97,6 +95,8 @@ public class ForkClient
private final ConsoleLogger log;
+ private RunListener testSetReporter;
+
private volatile boolean saidGoodBye;
private volatile StackTraceWriter errorInFork;
@@ -104,7 +104,6 @@ public class ForkClient
public ForkClient( DefaultReporterFactory defaultReporterFactory, Properties testVmSystemProperties,
NotifiableTestStream notifiableTestStream, ConsoleLogger log )
{
- testSetReporter = defaultReporterFactory.createReporter();
this.defaultReporterFactory = defaultReporterFactory;
this.testVmSystemProperties = testVmSystemProperties;
this.notifiableTestStream = notifiableTestStream;
@@ -168,6 +167,15 @@ public final boolean hadTimeout()
return testSetStartedAt.get() == START_TIME_NEGATIVE_TIMEOUT;
}
+ private RunListener getTestSetReporter()
+ {
+ if ( testSetReporter == null )
+ {
+ testSetReporter = defaultReporterFactory.createReporter();
+ }
+ return testSetReporter;
+ }
+
private void processLine( String s )
{
try
@@ -185,49 +193,49 @@ private void processLine( String s )
switch ( operationId )
{
case BOOTERCODE_TESTSET_STARTING:
- testSetReporter.testSetStarting( createReportEntry( remaining ) );
+ getTestSetReporter().testSetStarting( createReportEntry( remaining ) );
setCurrentStartTime();
break;
case BOOTERCODE_TESTSET_COMPLETED:
testsInProgress.clear();
- testSetReporter.testSetCompleted( createReportEntry( remaining ) );
+ getTestSetReporter().testSetCompleted( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_STARTING:
ReportEntry reportEntry = createReportEntry( remaining );
testsInProgress.offer( reportEntry.getSourceName() );
- testSetReporter.testStarting( createReportEntry( remaining ) );
+ getTestSetReporter().testStarting( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_SUCCEEDED:
reportEntry = createReportEntry( remaining );
testsInProgress.remove( reportEntry.getSourceName() );
- testSetReporter.testSucceeded( createReportEntry( remaining ) );
+ getTestSetReporter().testSucceeded( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_FAILED:
reportEntry = createReportEntry( remaining );
testsInProgress.remove( reportEntry.getSourceName() );
- testSetReporter.testFailed( createReportEntry( remaining ) );
+ getTestSetReporter().testFailed( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_SKIPPED:
reportEntry = createReportEntry( remaining );
testsInProgress.remove( reportEntry.getSourceName() );
- testSetReporter.testSkipped( createReportEntry( remaining ) );
+ getTestSetReporter().testSkipped( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_ERROR:
reportEntry = createReportEntry( remaining );
testsInProgress.remove( reportEntry.getSourceName() );
- testSetReporter.testError( createReportEntry( remaining ) );
+ getTestSetReporter().testError( createReportEntry( remaining ) );
break;
case BOOTERCODE_TEST_ASSUMPTIONFAILURE:
reportEntry = createReportEntry( remaining );
testsInProgress.remove( reportEntry.getSourceName() );
- testSetReporter.testAssumptionFailure( createReportEntry( remaining ) );
+ getTestSetReporter().testAssumptionFailure( createReportEntry( remaining ) );
break;
case BOOTERCODE_SYSPROPS:
int keyEnd = remaining.indexOf( "," );
@@ -373,22 +381,23 @@ private String unescape( String source )
/**
* Used when getting reporters on the plugin side of a fork.
+ * Used by testing purposes only. May not be volatile variable.
*
* @return A mock provider reporter
*/
public final RunListener getReporter()
{
- return testSetReporter;
+ return getTestSetReporter();
}
private ConsoleOutputReceiver getOrCreateConsoleOutputReceiver()
{
- return (ConsoleOutputReceiver) testSetReporter;
+ return (ConsoleOutputReceiver) getTestSetReporter();
}
private ConsoleLogger getOrCreateConsoleLogger()
{
- return (ConsoleLogger) testSetReporter;
+ return (ConsoleLogger) getTestSetReporter();
}
public void close( boolean hadTimeout )
From 66bc4c0839ba11af7a8915930f76abf3cd58ee53 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 31 Dec 2016 10:25:00 +0100
Subject: [PATCH 035/194] [SUREFIRE-1322] Surefire and Failsafe should dump
critical errors in dump file and console
---
.../surefire/util/internal/DumpFileUtils.java | 2 +-
...35ForkFailWithRedirectConsoleOutputIT.java | 32 ++++++++++++++++---
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
index 47a13868d7..2c110f5da6 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
@@ -1 +1 @@
-package org.apache.maven.surefire.util.internal;
/*
* 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.report.ReporterConfiguration;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Dumps a text or exception in dump file.
* Each call logs a date when it was written to the dump file.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class DumpFileUtils
{
private DumpFileUtils()
{
throw new IllegalStateException( "no instantiable constructor" );
}
/**
* New dump file. Synchronized object appears in main memory and perfectly visible in other threads.
*/
public static synchronized File newDumpFile( String dumpFileName, ReporterConfiguration configuration )
{
return new File( configuration.getReportsDirectory(), dumpFileName );
}
public static void dumpException( Throwable t, File dumpFile )
{
dumpException( t, null, dumpFile );
}
public static void dumpException( Throwable t, String msg, File dumpFile )
{
try
{
if ( t != null && dumpFile != null && ( dumpFile.exists() || dumpFile.createNewFile() ) )
{
Writer fw = createWriter( dumpFile );
if ( msg != null )
{
fw.append( msg )
.append( StringUtils.NL );
}
PrintWriter pw = new PrintWriter( fw );
t.printStackTrace( pw );
pw.flush();
fw.append( StringUtils.NL )
.append( StringUtils.NL );
fw.flush();
fw.close();
}
}
catch ( Exception e )
{
// do nothing
}
}
public static void dumpText( String msg, File dumpFile )
{
try
{
if ( msg != null && dumpFile != null && ( dumpFile.exists() || dumpFile.createNewFile() ) )
{
Writer fw = createWriter( dumpFile )
.append( msg )
.append( StringUtils.NL )
.append( StringUtils.NL );
fw.flush();
fw.close();
}
}
catch ( Exception e )
{
// do nothing
}
}
public static String newFormattedDateFileName()
{
return new SimpleDateFormat( "yyyy-MM-dd'T'hh-mm-ss_SSS" ).format( new Date() );
}
private static Writer createWriter( File dumpFile ) throws IOException
{
return new OutputStreamWriter( new FileOutputStream( dumpFile, true ), "UTF-8" )
.append( "# Created on " )
.append( new SimpleDateFormat( "yyyy-MM-dd'T'hh:mm:ss.SSS" ).format( new Date() ) )
.append( StringUtils.NL );
}
}
\ No newline at end of file
+package org.apache.maven.surefire.util.internal;
/*
* 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.report.ReporterConfiguration;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Dumps a text or exception in dump file.
* Each call logs a date when it was written to the dump file.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class DumpFileUtils
{
private DumpFileUtils()
{
throw new IllegalStateException( "no instantiable constructor" );
}
/**
* New dump file. Synchronized object appears in main memory and perfectly visible in other threads.
*/
public static synchronized File newDumpFile( String dumpFileName, ReporterConfiguration configuration )
{
return new File( configuration.getReportsDirectory(), dumpFileName );
}
public static void dumpException( Throwable t, File dumpFile )
{
dumpException( t, null, dumpFile );
}
public static void dumpException( Throwable t, String msg, File dumpFile )
{
try
{
if ( t != null && dumpFile != null && ( dumpFile.exists() || dumpFile.createNewFile() ) )
{
Writer fw = createWriter( dumpFile );
if ( msg != null )
{
fw.append( msg )
.append( StringUtils.NL );
}
PrintWriter pw = new PrintWriter( fw );
t.printStackTrace( pw );
pw.flush();
fw.append( StringUtils.NL )
.append( StringUtils.NL );
fw.flush();
fw.close();
}
}
catch ( Exception e )
{
// do nothing
}
}
public static void dumpText( String msg, File dumpFile )
{
try
{
if ( msg != null && dumpFile != null
&& ( dumpFile.exists() || mkdirs( dumpFile ) && dumpFile.createNewFile() ) )
{
Writer fw = createWriter( dumpFile )
.append( msg )
.append( StringUtils.NL )
.append( StringUtils.NL );
fw.flush();
fw.close();
}
}
catch ( Exception e )
{
// do nothing
}
}
public static String newFormattedDateFileName()
{
return new SimpleDateFormat( "yyyy-MM-dd'T'hh-mm-ss_SSS" ).format( new Date() );
}
private static Writer createWriter( File dumpFile ) throws IOException
{
return new OutputStreamWriter( new FileOutputStream( dumpFile, true ), "UTF-8" )
.append( "# Created on " )
.append( new SimpleDateFormat( "yyyy-MM-dd'T'hh:mm:ss.SSS" ).format( new Date() ) )
.append( StringUtils.NL );
}
private static boolean mkdirs( File dumpFile )
{
return dumpFile.getParentFile().mkdirs();
}
}
\ No newline at end of file
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java
index cabb90e75f..4117d8cc09 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java
@@ -19,28 +19,50 @@
* under the License.
*/
+import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
-
import org.junit.Test;
+import java.io.File;
+import java.io.FilenameFilter;
+
+import static org.fest.assertions.Assertions.assertThat;
+
/**
* @author Kristian Rosenvold
*/
public class Surefire735ForkFailWithRedirectConsoleOutputIT
- extends SurefireJUnit4IntegrationTestCase
+ extends SurefireJUnit4IntegrationTestCase
{
@Test
public void vmStartFail()
- throws Exception
+ throws Exception
{
- unpack().failNever().executeTest().verifyTextInLog( "Invalid maximum heap size: -Xmxxxx712743m" );
+ OutputValidator outputValidator = unpack().failNever().executeTest();
+
+ File reportDir = outputValidator.getSurefireReportsDirectory();
+ String[] dumpFiles = reportDir.list( new FilenameFilter()
+ {
+ @Override
+ public boolean accept( File dir, String name )
+ {
+ return name.endsWith( ".dumpstream" );
+ }
+ }
+ );
+ assertThat( dumpFiles ).isNotEmpty();
+ for ( String dump : dumpFiles )
+ {
+ outputValidator.getSurefireReportsFile( dump )
+ .assertContainsText( "Invalid maximum heap size: -Xmxxxx712743m" );
+ }
}
@Test
public void vmStartFailShouldFailBuildk()
- throws Exception
+ throws Exception
{
unpack().maven().withFailure().executeTest();
}
From e5a6b9c8d4f514100a01dea2acf1fb059e294968 Mon Sep 17 00:00:00 2001
From: Christian Schulte
Date: Mon, 2 Jan 2017 00:54:07 +0100
Subject: [PATCH 036/194] [SUREFIRE-1324] Surefire incorrectly suppresses
exceptions when closing resources.
---
.../plugin/surefire/SurefireProperties.java | 41 ++++++------
.../booterclient/ForkConfiguration.java | 27 ++++----
.../report/ConsoleOutputFileReporter.java | 15 ++++-
.../plugin/surefire/report/FileReporter.java | 65 ++++++++++++++-----
.../surefire/report/TestSetRunListener.java | 37 ++++++-----
.../surefire/runorder/StatisticsReporter.java | 4 +-
.../util/DependenciesScannerTest.java | 8 ++-
.../surefire/report/FileReporterTest.java | 5 +-
.../report/SurefireReportMojoTest.java | 2 +
surefire-api/pom.xml | 4 ++
.../runorder/RunEntryStatisticsMap.java | 30 ++++++---
.../surefire/booter/ForkingRunListener.java | 8 +++
.../surefire/booter/MasterProcessCommand.java | 5 +-
.../booter/SystemPropertyManager.java | 21 +++++-
.../maven/surefire/its/fixture/TestFile.java | 18 ++++-
.../src/test/java/it/BasicTest.java | 31 +++++++--
.../src/test/java/runListener/FileHelper.java | 26 ++++++--
.../maven/surefire/test/FailingTest.java | 4 +-
.../maven/surefire/test/SucceedingTest.java | 3 +
.../plugins/surefire/dumppid/DumpPidMojo.java | 30 ++++++---
.../test/java/listenReport/FileHelper.java | 30 ++++++---
.../java/testng/objectfactory/FileHelper.java | 28 ++++++--
.../testng/testrunnerfactory/FileHelper.java | 28 ++++++--
23 files changed, 341 insertions(+), 129 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
index 3663f3978d..2e3aa58b85 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
@@ -32,13 +32,11 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-
+import static java.util.Arrays.asList;
import org.apache.maven.surefire.booter.Classpath;
import org.apache.maven.surefire.booter.KeyValueSource;
import org.apache.maven.surefire.util.internal.StringUtils;
-import static java.util.Arrays.asList;
-
/**
* A properties implementation that preserves insertion order.
*/
@@ -46,6 +44,7 @@ public class SurefireProperties
extends Properties
implements KeyValueSource
{
+
private static final Collection KEYS_THAT_CANNOT_BE_USED_AS_SYSTEM_PROPERTIES =
asList( "java.library.path", "file.encoding", "jdk.map.althashing.threshold", "line.separator" );
@@ -153,7 +152,6 @@ static SurefireProperties calculateEffectiveProperties( Properties systemPropert
// user specified properties for SUREFIRE-121, causing SUREFIRE-491.
// Not gonna do THAT any more... instead, we only propagate those system properties
// that have been explicitly specified by the user via -Dkey=value on the CLI
-
result.copyPropertiesFrom( userProperties );
return result;
}
@@ -224,18 +222,32 @@ public void setClasspath( String prefix, Classpath classpath )
}
}
- private static SurefireProperties loadProperties( InputStream inStream )
+ private static SurefireProperties loadProperties( final InputStream inStream )
throws IOException
{
+ InputStream in = inStream;
+
try
{
- Properties p = new Properties();
- p.load( inStream );
+ final Properties p = new Properties();
+ p.load( in );
+ in.close();
+ in = null;
return new SurefireProperties( p );
}
finally
{
- close( inStream );
+ try
+ {
+ if ( in != null )
+ {
+ in.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
}
}
@@ -245,18 +257,6 @@ public static SurefireProperties loadProperties( File file )
return file == null ? new SurefireProperties() : loadProperties( new FileInputStream( file ) );
}
- private static void close( InputStream inputStream )
- {
- try
- {
- inputStream.close();
- }
- catch ( IOException ex )
- {
- // ignore
- }
- }
-
public void setNullableProperty( String key, String value )
{
if ( value != null )
@@ -264,4 +264,5 @@ public void setNullableProperty( String key, String value )
super.setProperty( key, value );
}
}
+
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 988af8f5c1..f42c8aada0 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -19,15 +19,6 @@
* under the License.
*/
-import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
-import org.apache.maven.plugin.surefire.util.Relocator;
-import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.surefire.booter.Classpath;
-import org.apache.maven.surefire.booter.ForkedBooter;
-import org.apache.maven.surefire.booter.StartupConfiguration;
-import org.apache.maven.surefire.booter.SurefireBooterForkException;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -38,6 +29,15 @@
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
+import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.util.Relocator;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.io.IOUtil;
+import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.ForkedBooter;
+import org.apache.maven.surefire.booter.StartupConfiguration;
+import org.apache.maven.surefire.booter.SurefireBooterForkException;
/**
* Configuration for forking tests.
@@ -270,10 +270,10 @@ private File createJar( List classPath, String startClassName )
{
file.deleteOnExit();
}
- FileOutputStream fos = new FileOutputStream( file );
- JarOutputStream jos = new JarOutputStream( fos );
+ JarOutputStream jos = null;
try
{
+ jos = new JarOutputStream( new FileOutputStream( file ) );
jos.setLevel( JarOutputStream.STORED );
JarEntry je = new JarEntry( "META-INF/MANIFEST.MF" );
jos.putNextEntry( je );
@@ -297,10 +297,13 @@ private File createJar( List classPath, String startClassName )
man.getMainAttributes().putValue( "Main-Class", startClassName );
man.write( jos );
+
+ jos.close();
+ jos = null;
}
finally
{
- jos.close();
+ IOUtil.close( jos );
}
return file;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
index f9e59fe87c..552c12a6ae 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
@@ -69,13 +69,15 @@ public void close()
{
try
{
- fileOutputStream.flush();
fileOutputStream.close();
}
catch ( IOException e )
{
}
- fileOutputStream = null;
+ finally
+ {
+ fileOutputStream = null;
+ }
}
}
@@ -97,6 +99,15 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
}
catch ( IOException e )
{
+ try
+ {
+ fileOutputStream.close();
+ // Intentionally no setting to null.
+ }
+ catch ( final IOException e1 )
+ {
+ // Suppressed.
+ }
throw new RuntimeException( e );
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
index a4d8c8e064..d7a41af70e 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
@@ -19,15 +19,13 @@
* under the License.
*/
-import org.apache.maven.surefire.report.ReportEntry;
-import org.apache.maven.surefire.report.ReporterException;
-
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.PrintWriter;
import java.util.List;
-
+import org.apache.maven.surefire.report.ReportEntry;
+import org.apache.maven.surefire.report.ReporterException;
import static org.apache.maven.plugin.surefire.report.FileReporterUtils.stripIllegalFilenameChars;
import static org.apache.maven.surefire.util.internal.StringUtils.isNotBlank;
@@ -49,7 +47,7 @@ public FileReporter( File reportsDirectory, String reportNameSuffix )
this.reportNameSuffix = reportNameSuffix;
}
- private PrintWriter testSetStarting( ReportEntry report )
+ private BufferedWriter testSetStarting( ReportEntry report )
{
File reportFile = getReportFile( reportsDirectory, report.getName(), reportNameSuffix, ".txt" );
@@ -58,21 +56,39 @@ private PrintWriter testSetStarting( ReportEntry report )
// noinspection ResultOfMethodCallIgnored
reportDir.mkdirs();
+ BufferedWriter writer = null;
try
{
- PrintWriter writer = new PrintWriter( new FileWriter( reportFile ) );
+ writer = new BufferedWriter( new FileWriter( reportFile ) );
- writer.println( "-------------------------------------------------------------------------------" );
+ writer.append( "-------------------------------------------------------------------------------" );
+ writer.newLine();
- writer.println( "Test set: " + report.getName() );
+ writer.append( "Test set: " + report.getName() );
+ writer.newLine();
- writer.println( "-------------------------------------------------------------------------------" );
+ writer.append( "-------------------------------------------------------------------------------" );
+ writer.newLine();
return writer;
}
catch ( IOException e )
{
- throw new ReporterException( "Unable to create file for report: " + e.getMessage(), e );
+ try
+ {
+ if ( writer != null )
+ {
+ writer.close();
+ }
+ }
+ catch ( final IOException e1 )
+ {
+ // Suppressed.
+ }
+ finally
+ {
+ throw new ReporterException( "Unable to create file for report: " + e.getMessage(), e );
+ }
}
}
@@ -85,20 +101,37 @@ public static File getReportFile( File reportsDirectory, String reportEntryName,
}
public void testSetCompleted( WrappedReportEntry report, TestSetStats testSetStats, List testResults )
+ throws IOException
{
- PrintWriter writer = testSetStarting( report );
+ BufferedWriter writer = null;
try
{
- writer.println( testSetStats.getTestSetSummary( report ) );
+ writer = testSetStarting( report );
+ writer.append( testSetStats.getTestSetSummary( report ) );
+ writer.newLine();
+
for ( String testResult : testResults )
{
- writer.println( testResult );
+ writer.append( testResult );
+ writer.newLine();
}
- writer.flush();
+
+ writer.close();
+ writer = null;
}
finally
{
- writer.close();
+ try
+ {
+ if ( writer != null )
+ {
+ writer.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
}
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
index f0f996dd24..0643896b37 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
@@ -151,22 +151,29 @@ public void clearCapture()
public void testSetCompleted( ReportEntry report )
{
- final WrappedReportEntry wrap = wrapTestSet( report );
- final List testResults =
+ try
+ {
+ final WrappedReportEntry wrap = wrapTestSet( report );
+ final List testResults =
briefOrPlainFormat ? detailsForThis.getTestResults() : Collections.emptyList();
- fileReporter.testSetCompleted( wrap, detailsForThis, testResults );
- simpleXMLReporter.testSetCompleted( wrap, detailsForThis );
- statisticsReporter.testSetCompleted();
- consoleReporter.testSetCompleted( wrap, detailsForThis, testResults );
- consoleOutputReceiver.testSetCompleted( wrap );
- consoleReporter.reset();
-
- wrap.getStdout().free();
- wrap.getStdErr().free();
-
- addTestMethodStats();
- detailsForThis.reset();
- clearCapture();
+ fileReporter.testSetCompleted( wrap, detailsForThis, testResults );
+ simpleXMLReporter.testSetCompleted( wrap, detailsForThis );
+ statisticsReporter.testSetCompleted();
+ consoleReporter.testSetCompleted( wrap, detailsForThis, testResults );
+ consoleOutputReceiver.testSetCompleted( wrap );
+ consoleReporter.reset();
+
+ wrap.getStdout().free();
+ wrap.getStdErr().free();
+
+ addTestMethodStats();
+ detailsForThis.reset();
+ clearCapture();
+ }
+ catch ( final IOException e )
+ {
+ throw new RuntimeException( "Unexpected IOException.e", e );
+ }
}
// ----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
index a53db0241d..bf4523ef92 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
@@ -20,7 +20,7 @@
*/
import java.io.File;
-import java.io.FileNotFoundException;
+import java.io.IOException;
import org.apache.maven.surefire.report.ReportEntry;
import static org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMap.fromFile;
@@ -54,7 +54,7 @@ public synchronized void testSetCompleted()
{
newResults.serialize( dataFile );
}
- catch ( FileNotFoundException e )
+ catch ( IOException e )
{
throw new RuntimeException( e );
}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java
index c8dd436471..a223a0d95f 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java
@@ -75,9 +75,10 @@ private File writeTestFile()
File output = new File( "target/DependenciesScannerTest-tests.jar" );
output.delete();
- ZipOutputStream out = new ZipOutputStream( new FileOutputStream( output ) );
+ ZipOutputStream out = null;
try
{
+ out = new ZipOutputStream( new FileOutputStream( output ) );
out.putNextEntry( new ZipEntry( "org/test/TestA.class" ) );
out.closeEntry();
out.putNextEntry( new ZipEntry( "org/test/TestB.class" ) );
@@ -86,7 +87,10 @@ private File writeTestFile()
}
finally
{
- out.close();
+ if ( out != null )
+ {
+ out.close();
+ }
}
}
}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
index 7c49547bee..87d4b0c64e 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
@@ -20,6 +20,7 @@
*/
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import org.apache.maven.plugin.surefire.report.FileReporter;
import org.apache.maven.plugin.surefire.report.ReportEntryType;
@@ -38,7 +39,7 @@ public class FileReporterTest
private static final String testName = "org.apache.maven.surefire.report.FileReporterTest";
- public void testFileNameWithoutSuffix()
+ public void testFileNameWithoutSuffix() throws IOException
{
File reportDir = new File( "target" );
reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
@@ -58,7 +59,7 @@ private TestSetStats createTestSetStats()
return new TestSetStats( true, true );
}
- public void testFileNameWithSuffix()
+ public void testFileNameWithSuffix() throws IOException
{
File reportDir = new File( "target" );
String suffixText = "sampleSuffixText";
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
index f138d8a7db..9fca00753a 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
@@ -640,6 +640,8 @@ private void renderer( SurefireReportMojo mojo, File outputHtml )
writer = WriterFactory.newXmlWriter( outputHtml );
renderer.generateDocument( writer, (SiteRendererSink) mojo.getSink(), context );
+ writer.close();
+ writer = null;
}
finally
{
diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml
index a35f983668..258397281d 100644
--- a/surefire-api/pom.xml
+++ b/surefire-api/pom.xml
@@ -32,6 +32,10 @@
API used in Surefire and Failsafe MOJO, Booter, Common and test framework providers.
+
+ com.google.code.findbugs
+ jsr305
+ org.apache.maven.surefiresurefire-logger-api
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
index d47e8039b8..a66e797b7f 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
@@ -23,12 +23,13 @@
import org.apache.maven.surefire.report.ReportEntry;
import java.io.BufferedReader;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.OutputStreamWriter;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Comparator;
@@ -40,6 +41,7 @@
import java.util.regex.Pattern;
import static java.util.Collections.sort;
+import org.apache.maven.shared.utils.io.IOUtil;
import static org.apache.maven.plugin.surefire.runorder.RunEntryStatistics.fromReportEntry;
import static org.apache.maven.plugin.surefire.runorder.RunEntryStatistics.fromString;
@@ -64,9 +66,14 @@ public static RunEntryStatisticsMap fromFile( File file )
{
if ( file.exists() )
{
+ Reader reader = null;
try
{
- return fromReader( new FileReader( file ) );
+ reader = new FileReader( file );
+ final RunEntryStatisticsMap result = fromReader( reader );
+ reader.close();
+ reader = null;
+ return result;
}
catch ( FileNotFoundException e )
{
@@ -76,6 +83,10 @@ public static RunEntryStatisticsMap fromFile( File file )
{
throw new RuntimeException( e );
}
+ finally
+ {
+ IOUtil.close( reader );
+ }
}
else
{
@@ -102,23 +113,26 @@ static RunEntryStatisticsMap fromReader( Reader fileReader )
}
public void serialize( File file )
- throws FileNotFoundException
+ throws IOException
{
- FileOutputStream fos = new FileOutputStream( file );
- PrintWriter printWriter = new PrintWriter( fos );
+ BufferedWriter writer = null;
try
{
+ writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ) ) );
List items = new ArrayList( runEntryStatistics.values() );
sort( items, new RunCountComparator() );
for ( RunEntryStatistics item : items )
{
- printWriter.println( item.toString() );
+ writer.append( item.toString() );
+ writer.newLine();
}
- printWriter.flush();
+
+ writer.close();
+ writer = null;
}
finally
{
- printWriter.close();
+ IOUtil.close( writer );
}
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index 282c4d43ce..4558abad29 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -206,6 +206,10 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
synchronized ( target ) // See notes about synchronization/thread safety in class javadoc
{
target.write( encodeBytes, 0, encodeBytes.length );
+ if ( target.checkError() )
+ {
+ throw new RuntimeException( "Unexpected IOException." );
+ }
}
}
@@ -268,6 +272,10 @@ private void encodeAndWriteToTarget( String string )
synchronized ( target ) // See notes about synchronization/thread safety in class javadoc
{
target.write( encodeBytes, 0, encodeBytes.length );
+ if ( target.checkError() )
+ {
+ throw new RuntimeException( "Unexpected IOException." );
+ }
}
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index a53a046723..d2d1673d01 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -124,14 +124,15 @@ public static Command decode( DataInputStream is )
int dataLength = is.readInt();
if ( dataLength > 0 )
{
- byte[] buffer = new byte[dataLength];
+ byte[] buffer = new byte[ dataLength ];
int read = 0;
int total = 0;
do
{
total += read;
read = is.read( buffer, total, dataLength - total );
- } while ( read > 0 );
+ }
+ while ( total < dataLength && read >= 0 );
if ( command.getDataType() == Void.class )
{
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
index 713d4fed89..4046b7b7d7 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
@@ -24,6 +24,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
@@ -48,6 +49,8 @@ public static PropertiesWrapper loadProperties( InputStream inStream )
{
Properties p = new Properties();
p.load( inStream );
+ inStream.close();
+ inStream = null;
Map map = new ConcurrentHashMap( p.size() );
// @todo use .stringPropertyNames() JDK6 instead of .keySet()
for ( Map.Entry, ?> entry : p.entrySet() )
@@ -93,15 +96,27 @@ public static File writePropertiesFile( Properties properties, File tempDirector
public static void writePropertiesFile( File file, String name, Properties properties )
throws IOException
{
- FileOutputStream out = new FileOutputStream( file );
-
+ OutputStream out = null;
try
{
+ out = new FileOutputStream( file );
properties.store( out, name );
+ out.close();
+ out = null;
}
finally
{
- out.close();
+ try
+ {
+ if ( out != null )
+ {
+ out.close();
+ }
+ }
+ catch ( final IOException e1 )
+ {
+ // Suppressed.
+ }
}
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
index 61736df46e..a2f021fdf3 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
@@ -94,23 +94,37 @@ public FileInputStream getFileInputStream()
public String slurpFile()
{
+ BufferedReader reader = null;
try
{
StringBuilder sb = new StringBuilder();
- BufferedReader reader;
reader = new BufferedReader( new FileReader( file ) );
for ( String line = reader.readLine(); line != null; line = reader.readLine() )
{
sb.append( line );
}
reader.close();
+ reader = null;
return sb.toString();
}
catch ( IOException e )
{
throw new SurefireVerifierException( e );
}
-
+ finally
+ {
+ try
+ {
+ if ( reader != null )
+ {
+ reader.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
+ }
}
public String readFileToString()
diff --git a/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java b/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
index 739e134c83..258fd0f2f0 100644
--- a/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
+++ b/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
@@ -43,19 +43,36 @@ public void testMainClassesBeforeDependencies()
private Properties getProperties(String resource)
{
- InputStream in = getClass().getResourceAsStream( resource );
- assertNotNull( in );
+ InputStream in = null;
try
{
- Properties props = new Properties();
- props.load( in );
- return props;
+ in = getClass().getResourceAsStream( resource );
+ assertNotNull( in );
+ Properties props = new Properties();
+ props.load( in );
+ in.close();
+ in = null;
+ return props;
}
- catch (IOException e)
+ catch ( IOException e )
{
- fail(e.toString());
+ fail( e.toString() );
return null;
}
+ finally
+ {
+ try
+ {
+ if ( in != null )
+ {
+ in.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
+ }
}
}
diff --git a/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java b/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
index 85d0a5b73d..1acfa6027c 100644
--- a/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
@@ -22,23 +22,37 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Writer;
public class FileHelper
{
public static void writeFile( String fileName, String content )
{
+ Writer writer = null;
try
{
- File target = new File( "target" ).getAbsoluteFile();
- File listenerOutput = new File( target, fileName );
- FileWriter out = new FileWriter( listenerOutput );
- out.write( content );
- out.flush();
- out.close();
+ writer = new FileWriter( new File( new File( "target" ).getAbsoluteFile(), fileName ) );
+ writer.write( content );
+ writer.close();
+ writer = null;
}
catch ( IOException e )
{
throw new RuntimeException( e );
}
+ finally
+ {
+ try
+ {
+ if ( writer != null )
+ {
+ writer.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
+ }
}
}
diff --git a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
index a4d0cd3f6d..30224e19af 100644
--- a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
+++ b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
@@ -61,11 +61,12 @@ public void writeFile()
f.getParentFile().mkdirs();
FileWriter w = null;
-
try
{
w = new FileWriter( f, true );
w.write( name.getMethodName() );
+ w.close();
+ w = null;
}
finally
{
@@ -77,6 +78,7 @@ public void writeFile()
}
catch ( final IOException e )
{
+ // Suppressed.
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
index c9167c1216..2ed21ebe5f 100644
--- a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
+++ b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
@@ -66,6 +66,8 @@ public void writeFile()
{
w = new FileWriter( f, true );
w.write( name.getMethodName() );
+ w.close();
+ w = null;
}
finally
{
@@ -77,6 +79,7 @@ public void writeFile()
}
catch ( final IOException e )
{
+ // Suppressed.
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
index 035976b403..5e70556335 100644
--- a/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
+++ b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
@@ -41,30 +41,42 @@ public class DumpPidMojo
public void execute()
throws MojoExecutionException
{
- File target;
+ FileWriter fw = null;
try
{
getLog().info( "Dumping PID to " + targetDir );
-
+
if ( !targetDir.exists() )
{
targetDir.mkdirs();
}
-
- target = new File( targetDir, "maven.pid" ).getCanonicalFile();
- FileWriter fw = new FileWriter( target );
- String pid = ManagementFactory.getRuntimeMXBean().getName();
+ final String pid = ManagementFactory.getRuntimeMXBean().getName();
+ final File target = new File( targetDir, "maven.pid" ).getCanonicalFile();
+ fw = new FileWriter( target );
fw.write( pid );
- fw.flush();
fw.close();
-
+ fw = null;
+
getLog().info( "Wrote " + pid + " to " + target );
-
}
catch ( IOException e )
{
throw new MojoExecutionException( "Unable to create pid file", e );
}
+ finally
+ {
+ try
+ {
+ if ( fw != null )
+ {
+ fw.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
+ }
}
}
diff --git a/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
index 6a6688a656..4405996c1a 100644
--- a/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
@@ -22,23 +22,37 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Writer;
public class FileHelper
{
- public static void writeFile(String fileName, String content)
+ public static void writeFile( String fileName, String content )
{
+ Writer writer = null;
try
{
- File target = new File( "target" ).getAbsoluteFile();
- File listenerOutput = new File( target, fileName );
- FileWriter out = new FileWriter(listenerOutput);
- out.write( content );
- out.flush();
- out.close();
+ writer = new FileWriter( new File( new File( "target" ).getAbsoluteFile(), fileName ) );
+ writer.write( content );
+ writer.close();
+ writer = null;
}
catch ( IOException e )
{
- throw new RuntimeException(e);
+ throw new RuntimeException( e );
+ }
+ finally
+ {
+ try
+ {
+ if ( writer != null )
+ {
+ writer.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
index 4db30b6d02..4525e29160 100644
--- a/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
@@ -3,23 +3,39 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Writer;
public class FileHelper
{
public static void writeFile( String fileName, String content )
{
+ Writer writer = null;
try
{
- File target = new File( System.getProperty("user.dir"), "target" ).getCanonicalFile();
- File listenerOutput = new File( target, fileName );
- FileWriter out = new FileWriter( listenerOutput, true );
- out.write( content );
- out.flush();
- out.close();
+ writer = new FileWriter( new File( new File( System.getProperty( "user.dir" ),
+ "target" ).getCanonicalFile(), fileName ), true );
+
+ writer.write( content );
+ writer.close();
+ writer = null;
}
catch ( IOException exception )
{
throw new RuntimeException( exception );
}
+ finally
+ {
+ try
+ {
+ if ( writer != null )
+ {
+ writer.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
+ }
}
}
diff --git a/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
index 4b998ed34e..b72bfc6bb3 100644
--- a/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
@@ -3,23 +3,39 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Writer;
public class FileHelper
{
public static void writeFile( String fileName, String content )
{
+ Writer writer = null;
try
{
- File target = new File( System.getProperty("user.dir"), "target" ).getCanonicalFile();
- File listenerOutput = new File( target, fileName );
- FileWriter out = new FileWriter( listenerOutput, true );
- out.write( content );
- out.flush();
- out.close();
+ writer = new FileWriter( new File( new File( System.getProperty( "user.dir" ),
+ "target" ).getCanonicalFile(), fileName ), true );
+
+ writer.write( content );
+ writer.close();
+ writer = null;
}
catch ( IOException exception )
{
throw new RuntimeException( exception );
}
+ finally
+ {
+ try
+ {
+ if ( writer != null )
+ {
+ writer.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
+ }
}
}
From 201a3134673f3794d71262bdf1cf057bbb3d1056 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 7 Jan 2017 18:28:50 +0100
Subject: [PATCH 037/194] [SUREFIRE-1324] Surefire incorrectly suppresses
exceptions when closing resources.
---
.../plugin/surefire/SurefireProperties.java | 30 ++----
.../booterclient/ForkConfiguration.java | 7 +-
.../output/LostCommandsDumpSingleton.java | 62 +++++++++++-
.../output/ThreadedStreamConsumer.java | 35 ++++---
.../report/ConsoleOutputFileReporter.java | 8 +-
.../plugin/surefire/report/FileReporter.java | 12 ++-
.../surefire/runorder/StatisticsReporter.java | 3 +-
.../surefire/report/FileReporterTest.java | 6 +-
.../report/SurefireReportMojoTest.java | 2 +-
surefire-api/pom.xml | 4 +
.../runorder/RunEntryStatisticsMap.java | 34 ++++---
.../maven/surefire/booter/CommandReader.java | 21 ++--
.../surefire/booter/DumpErrorSingleton.java | 99 +++++++++++++++++++
.../surefire/booter/ForkingRunListener.java | 21 +++-
.../surefire/booter/MasterProcessCommand.java | 26 +----
.../maven/surefire/booter/ForkedBooter.java | 25 +----
.../booter/SystemPropertyManager.java | 3 +
.../maven/surefire/its/fixture/TestFile.java | 18 +++-
.../src/test/java/it/BasicTest.java | 30 ++++--
.../src/test/java/runListener/FileHelper.java | 25 +++--
.../maven/surefire/test/FailingTest.java | 15 +--
.../maven/surefire/test/SucceedingTest.java | 14 +--
.../plugins/surefire/dumppid/DumpPidMojo.java | 28 ++++--
.../test/java/listenReport/FileHelper.java | 28 ++++--
.../java/testng/objectfactory/FileHelper.java | 27 +++--
.../testng/testrunnerfactory/FileHelper.java | 22 ++++-
26 files changed, 412 insertions(+), 193 deletions(-)
create mode 100644 surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
index 3663f3978d..53aa134fc8 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
@@ -19,6 +19,10 @@
* under the License.
*/
+import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.KeyValueSource;
+import org.apache.maven.surefire.util.internal.StringUtils;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -33,11 +37,8 @@
import java.util.Properties;
import java.util.Set;
-import org.apache.maven.surefire.booter.Classpath;
-import org.apache.maven.surefire.booter.KeyValueSource;
-import org.apache.maven.surefire.util.internal.StringUtils;
-
import static java.util.Arrays.asList;
+import static org.apache.maven.shared.utils.io.IOUtil.close;
/**
* A properties implementation that preserves insertion order.
@@ -46,6 +47,7 @@ public class SurefireProperties
extends Properties
implements KeyValueSource
{
+
private static final Collection KEYS_THAT_CANNOT_BE_USED_AS_SYSTEM_PROPERTIES =
asList( "java.library.path", "file.encoding", "jdk.map.althashing.threshold", "line.separator" );
@@ -153,7 +155,6 @@ static SurefireProperties calculateEffectiveProperties( Properties systemPropert
// user specified properties for SUREFIRE-121, causing SUREFIRE-491.
// Not gonna do THAT any more... instead, we only propagate those system properties
// that have been explicitly specified by the user via -Dkey=value on the CLI
-
result.copyPropertiesFrom( userProperties );
return result;
}
@@ -224,18 +225,18 @@ public void setClasspath( String prefix, Classpath classpath )
}
}
- private static SurefireProperties loadProperties( InputStream inStream )
+ private static SurefireProperties loadProperties( final InputStream inStream )
throws IOException
{
try
{
- Properties p = new Properties();
+ final Properties p = new Properties();
p.load( inStream );
return new SurefireProperties( p );
}
finally
{
- close( inStream );
+ close( inStream ); // @todo use try-with-resources JDK7, search in all code
}
}
@@ -245,18 +246,6 @@ public static SurefireProperties loadProperties( File file )
return file == null ? new SurefireProperties() : loadProperties( new FileInputStream( file ) );
}
- private static void close( InputStream inputStream )
- {
- try
- {
- inputStream.close();
- }
- catch ( IOException ex )
- {
- // ignore
- }
- }
-
public void setNullableProperty( String key, String value )
{
if ( value != null )
@@ -264,4 +253,5 @@ public void setNullableProperty( String key, String value )
super.setProperty( key, value );
}
}
+
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 988af8f5c1..6cb0fabed1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -23,6 +23,7 @@
import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
import org.apache.maven.plugin.surefire.util.Relocator;
import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.io.IOUtil;
import org.apache.maven.surefire.booter.Classpath;
import org.apache.maven.surefire.booter.ForkedBooter;
import org.apache.maven.surefire.booter.StartupConfiguration;
@@ -270,10 +271,10 @@ private File createJar( List classPath, String startClassName )
{
file.deleteOnExit();
}
- FileOutputStream fos = new FileOutputStream( file );
- JarOutputStream jos = new JarOutputStream( fos );
+ JarOutputStream jos = null;
try
{
+ jos = new JarOutputStream( new FileOutputStream( file ) );
jos.setLevel( JarOutputStream.STORED );
JarEntry je = new JarEntry( "META-INF/MANIFEST.MF" );
jos.putNextEntry( je );
@@ -300,7 +301,7 @@ private File createJar( List classPath, String startClassName )
}
finally
{
- jos.close();
+ IOUtil.close( jos );
}
return file;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
index 364d8c3a00..fa38c053c9 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
@@ -1 +1,61 @@
-package org.apache.maven.plugin.surefire.booterclient.output;
/*
* 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.report.DefaultReporterFactory;
import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.io.File;
/**
* Dumps lost commands and caused exceptions in {@link ForkClient}.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
final class LostCommandsDumpSingleton
{
private static final LostCommandsDumpSingleton SINGLETON = new LostCommandsDumpSingleton();
private final String creationDate = DumpFileUtils.newFormattedDateFileName();
private LostCommandsDumpSingleton()
{
}
static LostCommandsDumpSingleton getSingleton()
{
return SINGLETON;
}
synchronized void dumpException( Throwable t, String msg, DefaultReporterFactory defaultReporterFactory )
{
File reportsDirectory = defaultReporterFactory.getReportsDirectory();
File dumpFile = new File( reportsDirectory, creationDate + ".dumpstream" );
DumpFileUtils.dumpException( t, msg, dumpFile );
}
synchronized void dumpException( Throwable t, DefaultReporterFactory defaultReporterFactory )
{
dumpException( t, null, defaultReporterFactory );
}
synchronized void dumpText( String msg, DefaultReporterFactory defaultReporterFactory )
{
File reportsDirectory = defaultReporterFactory.getReportsDirectory();
File dumpFile = new File( reportsDirectory, creationDate + ".dumpstream" );
DumpFileUtils.dumpText( msg, dumpFile );
}
}
\ No newline at end of file
+package org.apache.maven.plugin.surefire.booterclient.output;
+
+/*
+ * 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.report.DefaultReporterFactory;
+import org.apache.maven.surefire.util.internal.DumpFileUtils;
+import java.io.File;
+
+final class LostCommandsDumpSingleton
+{
+ private static final LostCommandsDumpSingleton SINGLETON = new LostCommandsDumpSingleton();
+
+ private final String creationDate = DumpFileUtils.newFormattedDateFileName();
+
+ private LostCommandsDumpSingleton()
+ {
+ }
+
+ static LostCommandsDumpSingleton getSingleton()
+ {
+ return SINGLETON;
+ }
+
+ synchronized void dumpException( Throwable t, String msg, DefaultReporterFactory defaultReporterFactory )
+ {
+ DumpFileUtils.dumpException( t, msg == null ? "null" : msg, newDumpFile( defaultReporterFactory ) );
+ }
+
+ synchronized void dumpException( Throwable t, DefaultReporterFactory defaultReporterFactory )
+ {
+ DumpFileUtils.dumpException( t, newDumpFile( defaultReporterFactory ) );
+ }
+
+ synchronized void dumpText( String msg, DefaultReporterFactory defaultReporterFactory )
+ {
+ DumpFileUtils.dumpText( msg == null ? "null" : msg, newDumpFile( defaultReporterFactory ) );
+ }
+
+ private File newDumpFile( DefaultReporterFactory defaultReporterFactory )
+ {
+ File reportsDirectory = defaultReporterFactory.getReportsDirectory();
+ return new File( reportsDirectory, creationDate + ".dumpstream" );
+ }
+}
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 3f1abd8f0e..ebf3edbe00 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
@@ -60,24 +60,35 @@ static class Pumper
this.target = target;
}
+ /**
+ * Calls {@link ForkClient#consumeLine(String)} throwing {@link RuntimeException}. Even if {@link ForkClient}
+ * is not fault-tolerant, this method MUST be fault-tolerant except for {@link InterruptedException}.
+ * This Thread is interrupted by {@link #close() closing the consumer}.
+ * If {@link org.apache.maven.plugin.surefire.report.ConsoleOutputFileReporter#writeTestOutput} throws
+ * {@link java.io.IOException} this method MUST NOT interrupt reading the events from forked JVM; otherwise
+ * we can simply loose events like acquire-next-test which means that {@link ForkClient} hangs on waiting
+ * for old test to complete and therefore the plugin permanently in progress.
+ */
+ @SuppressWarnings( "checkstyle:stringliteralequalitycheck" )
public void run()
{
- try
+ String item = null;
+ do
{
- String item = queue.take();
- //noinspection StringEquality
- while ( item != POISON )
+ try
{
- target.consumeLine( item );
item = queue.take();
+ target.consumeLine( item );
}
- }
- catch ( Throwable t )
- {
- // Think about what happens if the producer overruns us and creates an OOME. Not nice.
- // Maybe limit length of blocking queue
- this.throwable = t;
- }
+ catch ( InterruptedException e )
+ {
+ break;
+ }
+ catch ( Throwable t )
+ {
+ throwable = t;
+ }
+ } while ( item != POISON );
}
public Throwable getThrowable()
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
index f9e59fe87c..914d6844a4 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
@@ -23,6 +23,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
+import org.apache.maven.shared.utils.io.IOUtil;
import org.apache.maven.surefire.report.ReportEntry;
import static org.apache.maven.plugin.surefire.report.FileReporter.getReportFile;
@@ -74,8 +75,12 @@ public void close()
}
catch ( IOException e )
{
+ // do nothing
+ }
+ finally
+ {
+ fileOutputStream = null;
}
- fileOutputStream = null;
}
}
@@ -97,6 +102,7 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
}
catch ( IOException e )
{
+ IOUtil.close( fileOutputStream );
throw new RuntimeException( e );
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
index a4d8c8e064..6239f77d02 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
@@ -23,7 +23,6 @@
import org.apache.maven.surefire.report.ReporterException;
import java.io.File;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@@ -60,7 +59,13 @@ private PrintWriter testSetStarting( ReportEntry report )
try
{
- PrintWriter writer = new PrintWriter( new FileWriter( reportFile ) );
+ /**
+ * The implementation of constructor {@link PrintWriter(File)}
+ * uses {@link java.io.BufferedWriter}
+ * which is guaranteed by Java 1.5 Javadoc of the constructor:
+ * "The output will be written to the file and is buffered."
+ */
+ PrintWriter writer = new PrintWriter( reportFile );
writer.println( "-------------------------------------------------------------------------------" );
@@ -86,6 +91,9 @@ public static File getReportFile( File reportsDirectory, String reportEntryName,
public void testSetCompleted( WrappedReportEntry report, TestSetStats testSetStats, List testResults )
{
+ /**
+ * Using buffered stream internally.
+ */
PrintWriter writer = testSetStarting( report );
try
{
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
index a53db0241d..5776cc9bcc 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
@@ -19,9 +19,10 @@
* under the License.
*/
+import org.apache.maven.surefire.report.ReportEntry;
+
import java.io.File;
import java.io.FileNotFoundException;
-import org.apache.maven.surefire.report.ReportEntry;
import static org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMap.fromFile;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
index 7c49547bee..076b23c340 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
@@ -19,14 +19,14 @@
* under the License.
*/
-import java.io.File;
-import java.util.ArrayList;
+import junit.framework.TestCase;
import org.apache.maven.plugin.surefire.report.FileReporter;
import org.apache.maven.plugin.surefire.report.ReportEntryType;
import org.apache.maven.plugin.surefire.report.TestSetStats;
import org.apache.maven.plugin.surefire.report.WrappedReportEntry;
-import junit.framework.TestCase;
+import java.io.File;
+import java.util.ArrayList;
public class FileReporterTest
extends TestCase
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
index f138d8a7db..724e72d51a 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
@@ -638,7 +638,7 @@ private void renderer( SurefireReportMojo mojo, File outputHtml )
{
outputHtml.getParentFile().mkdirs();
writer = WriterFactory.newXmlWriter( outputHtml );
-
+ // renderer doxia 1.6 already closed the writer
renderer.generateDocument( writer, (SiteRendererSink) mojo.getSink(), context );
}
finally
diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml
index a35f983668..258397281d 100644
--- a/surefire-api/pom.xml
+++ b/surefire-api/pom.xml
@@ -32,6 +32,10 @@
API used in Surefire and Failsafe MOJO, Booter, Common and test framework providers.
+
+ com.google.code.findbugs
+ jsr305
+ org.apache.maven.surefiresurefire-logger-api
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
index d47e8039b8..eab2a81966 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
@@ -20,12 +20,12 @@
*/
+import org.apache.maven.shared.utils.io.IOUtil;
import org.apache.maven.surefire.report.ReportEntry;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
@@ -64,17 +64,19 @@ public static RunEntryStatisticsMap fromFile( File file )
{
if ( file.exists() )
{
+ Reader reader = null;
try
{
- return fromReader( new FileReader( file ) );
+ reader = new FileReader( file );
+ return fromReader( reader );
}
- catch ( FileNotFoundException e )
+ catch ( IOException e )
{
throw new RuntimeException( e );
}
- catch ( IOException e )
+ finally
{
- throw new RuntimeException( e );
+ IOUtil.close( reader );
}
}
else
@@ -87,16 +89,11 @@ static RunEntryStatisticsMap fromReader( Reader fileReader )
throws IOException
{
Map result = new HashMap();
- BufferedReader bufferedReader = new BufferedReader( fileReader );
- String line = bufferedReader.readLine();
- while ( line != null )
+ BufferedReader reader = new BufferedReader( fileReader );
+ for ( String line = reader.readLine(); line != null && !line.startsWith( "#" ); line = reader.readLine() )
{
- if ( !line.startsWith( "#" ) )
- {
- final RunEntryStatistics stats = fromString( line );
- result.put( stats.getTestName(), stats );
- }
- line = bufferedReader.readLine();
+ RunEntryStatistics stats = fromString( line );
+ result.put( stats.getTestName(), stats );
}
return new RunEntryStatisticsMap( result );
}
@@ -104,8 +101,13 @@ static RunEntryStatisticsMap fromReader( Reader fileReader )
public void serialize( File file )
throws FileNotFoundException
{
- FileOutputStream fos = new FileOutputStream( file );
- PrintWriter printWriter = new PrintWriter( fos );
+ /**
+ * The implementation of constructor {@link PrintWriter(File)}
+ * uses {@link java.io.BufferedWriter}
+ * which is guaranteed by Java 1.5 Javadoc of the constructor:
+ * "The output will be written to the file and is buffered."
+ */
+ PrintWriter printWriter = new PrintWriter( file );
try
{
List items = new ArrayList( runEntryStatistics.values() );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
index 408e4a4ca9..3990d467ac 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
@@ -22,11 +22,9 @@
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
import org.apache.maven.surefire.testset.TestSetFailedException;
-import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.io.DataInputStream;
import java.io.EOFException;
-import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Iterator;
@@ -38,10 +36,10 @@
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicReference;
+import static java.lang.StrictMath.max;
import static java.lang.Thread.State.NEW;
import static java.lang.Thread.State.RUNNABLE;
import static java.lang.Thread.State.TERMINATED;
-import static java.lang.StrictMath.max;
import static org.apache.maven.surefire.booter.Command.toShutdown;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_NEXT_TEST;
import static org.apache.maven.surefire.booter.MasterProcessCommand.NOOP;
@@ -51,10 +49,10 @@
import static org.apache.maven.surefire.booter.MasterProcessCommand.TEST_SET_FINISHED;
import static org.apache.maven.surefire.booter.MasterProcessCommand.decode;
import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThread;
+import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
import static org.apache.maven.surefire.util.internal.StringUtils.isBlank;
import static org.apache.maven.surefire.util.internal.StringUtils.isNotBlank;
-import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
/**
* Reader of commands coming from plugin(master) process.
@@ -87,8 +85,6 @@ public final class CommandReader
private volatile ConsoleLogger logger = new NullConsoleLogger();
- private volatile File dumpFile;
-
private CommandReader()
{
}
@@ -103,11 +99,6 @@ public static CommandReader getReader()
return reader;
}
- public void setDumpFile( File dumpFile )
- {
- this.dumpFile = dumpFile;
- }
-
public CommandReader setShutdown( Shutdown shutdown )
{
this.shutdown = shutdown;
@@ -132,7 +123,7 @@ public boolean awaitStarted()
}
catch ( InterruptedException e )
{
- DumpFileUtils.dumpException( e, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpException( e );
throw new TestSetFailedException( e.getLocalizedMessage() );
}
}
@@ -386,7 +377,7 @@ public void run()
if ( command == null )
{
String errorMessage = "[SUREFIRE] std/in stream corrupted: first sequence not recognized";
- DumpFileUtils.dumpText( errorMessage, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpText( errorMessage );
logger.error( errorMessage );
break;
}
@@ -423,7 +414,7 @@ public void run()
}
catch ( EOFException e )
{
- DumpFileUtils.dumpException( e, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpException( e );
CommandReader.this.state.set( TERMINATED );
if ( !isTestSetFinished )
@@ -434,7 +425,7 @@ public void run()
}
catch ( IOException e )
{
- DumpFileUtils.dumpException( e, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpException( e );
CommandReader.this.state.set( TERMINATED );
// If #stop() method is called, reader thread is interrupted and cause is InterruptedException.
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
new file mode 100644
index 0000000000..5df6d59ced
--- /dev/null
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
@@ -0,0 +1,99 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * 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.report.ReporterConfiguration;
+import org.apache.maven.surefire.util.internal.DumpFileUtils;
+
+import java.io.File;
+
+import static org.apache.maven.surefire.util.internal.DumpFileUtils.newDumpFile;
+
+/**
+ * Dumps lost commands and caused exceptions in forked JVM.
+ * Fail-safe.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.19.2
+ */
+public final class DumpErrorSingleton
+{
+ private static final String DUMP_FILE_EXT = ".dump";
+ private static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
+ private static final DumpErrorSingleton SINGLETON = new DumpErrorSingleton();
+
+ private File dumpFile;
+ private File dumpStreamFile;
+
+ private DumpErrorSingleton()
+ {
+ }
+
+ public static DumpErrorSingleton getSingleton()
+ {
+ return SINGLETON;
+ }
+
+ public synchronized void init( String dumpFileName, ReporterConfiguration configuration )
+ {
+ dumpFile = createDumpFile( dumpFileName, configuration );
+ dumpStreamFile = createDumpStreamFile( dumpFileName, configuration );
+ }
+
+ public synchronized void dumpException( Throwable t, String msg )
+ {
+ DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dumpFile );
+ }
+
+ public synchronized void dumpException( Throwable t )
+ {
+ DumpFileUtils.dumpException( t, dumpFile );
+ }
+
+ public synchronized void dumpText( String msg )
+ {
+ DumpFileUtils.dumpText( msg == null ? "null" : msg, dumpFile );
+ }
+
+ public synchronized void dumpStreamException( Throwable t, String msg )
+ {
+ DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dumpStreamFile );
+ }
+
+ public synchronized void dumpStreamException( Throwable t )
+ {
+ DumpFileUtils.dumpException( t, dumpStreamFile );
+ }
+
+ public synchronized void dumpStreamText( String msg )
+ {
+ DumpFileUtils.dumpText( msg == null ? "null" : msg, dumpStreamFile );
+ }
+
+ private File createDumpFile( String dumpFileName, ReporterConfiguration configuration )
+ {
+ return newDumpFile( dumpFileName + DUMP_FILE_EXT, configuration );
+ }
+
+ private File createDumpStreamFile( String dumpFileName, ReporterConfiguration configuration )
+ {
+ return newDumpFile( dumpFileName + DUMPSTREAM_FILE_EXT, configuration );
+ }
+}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index 282c4d43ce..aa0daddd2c 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -19,10 +19,6 @@
* under the License.
*/
-import java.io.PrintStream;
-import java.util.Enumeration;
-import java.util.Properties;
-
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.ConsoleLoggerUtils;
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
@@ -33,6 +29,10 @@
import org.apache.maven.surefire.report.SimpleReportEntry;
import org.apache.maven.surefire.report.StackTraceWriter;
+import java.io.PrintStream;
+import java.util.Enumeration;
+import java.util.Properties;
+
import static java.lang.Integer.toHexString;
import static java.nio.charset.Charset.defaultCharset;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
@@ -206,6 +206,13 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
synchronized ( target ) // See notes about synchronization/thread safety in class javadoc
{
target.write( encodeBytes, 0, encodeBytes.length );
+ if ( target.checkError() )
+ {
+ // We MUST NOT throw any exception from this method; otherwise we are in loop and CPU goes up:
+ // ForkingRunListener -> Exception -> JUnit Notifier and RunListener -> ForkingRunListener -> Exception
+ DumpErrorSingleton.getSingleton()
+ .dumpStreamText( "Unexpected IOException with stream: " + new String( buf, off, len ) );
+ }
}
}
@@ -268,6 +275,12 @@ private void encodeAndWriteToTarget( String string )
synchronized ( target ) // See notes about synchronization/thread safety in class javadoc
{
target.write( encodeBytes, 0, encodeBytes.length );
+ if ( target.checkError() )
+ {
+ // We MUST NOT throw any exception from this method; otherwise we are in loop and CPU goes up:
+ // ForkingRunListener -> Exception -> JUnit Notifier and RunListener -> ForkingRunListener -> Exception
+ DumpErrorSingleton.getSingleton().dumpStreamText( "Unexpected IOException: " + string );
+ }
}
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index a53a046723..a75aa83890 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -22,15 +22,14 @@
import org.apache.maven.surefire.util.internal.StringUtils;
import java.io.DataInputStream;
-import java.io.EOFException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
+import static java.lang.String.format;
+import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
-import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
-import static java.lang.String.format;
/**
* Commands which are sent from plugin to the forked jvm.
@@ -124,14 +123,8 @@ public static Command decode( DataInputStream is )
int dataLength = is.readInt();
if ( dataLength > 0 )
{
- byte[] buffer = new byte[dataLength];
- int read = 0;
- int total = 0;
- do
- {
- total += read;
- read = is.read( buffer, total, dataLength - total );
- } while ( read > 0 );
+ byte[] buffer = new byte[ dataLength ];
+ is.readFully( buffer );
if ( command.getDataType() == Void.class )
{
@@ -140,17 +133,6 @@ public static Command decode( DataInputStream is )
command, dataLength ) );
}
- if ( total != dataLength )
- {
- if ( read == -1 )
- {
- throw new EOFException( "stream closed" );
- }
-
- throw new IOException( format( "%s read %d out of %d bytes",
- MasterProcessCommand.class, total, dataLength ) );
- }
-
String data = command.toDataTypeAsString( buffer );
return new Command( command, data );
}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 29047f2892..b76df2f0f1 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -54,8 +54,6 @@
import static org.apache.maven.surefire.booter.SystemPropertyManager.setSystemProperties;
import static org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg;
import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThreadFactory;
-import static org.apache.maven.surefire.util.internal.DumpFileUtils.dumpException;
-import static org.apache.maven.surefire.util.internal.DumpFileUtils.newDumpFile;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
/**
@@ -73,8 +71,6 @@ public final class ForkedBooter
private static final long DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS = 30;
private static final long PING_TIMEOUT_IN_SECONDS = 20;
private static final ScheduledExecutorService JVM_TERMINATOR = createJvmTerminator();
- private static final String DUMP_FILE_EXT = ".dump";
- private static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
private static volatile long systemExitTimeoutInSeconds = DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS;
@@ -89,7 +85,6 @@ public static void main( String... args )
final CommandReader reader = startupMasterProcessReader();
final ScheduledFuture> pingScheduler = listenToShutdownCommands( reader );
final PrintStream originalOut = out;
- File dumpFile = null;
try
{
final String tmpDir = args[0];
@@ -105,9 +100,7 @@ public static void main( String... args )
}
final ProviderConfiguration providerConfiguration = booterDeserializer.deserialize();
-
- dumpFile = createDumpFile( dumpFileName, providerConfiguration );
- reader.setDumpFile( createDumpstreamFile( dumpFileName, providerConfiguration ) );
+ DumpErrorSingleton.getSingleton().init( dumpFileName, providerConfiguration.getReporterConfiguration() );
final StartupConfiguration startupConfiguration = booterDeserializer.getProviderConfiguration();
systemExitTimeoutInSeconds =
@@ -145,7 +138,7 @@ else if ( readTestsFromInputStream )
}
catch ( InvocationTargetException t )
{
- dumpException( t, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpException( t );
StackTraceWriter stackTraceWriter =
new LegacyPojoStackTraceWriter( "test subsystem", "no method", t.getTargetException() );
StringBuilder stringBuilder = new StringBuilder();
@@ -154,7 +147,7 @@ else if ( readTestsFromInputStream )
}
catch ( Throwable t )
{
- dumpException( t, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpException( t );
StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter( "test subsystem", "no method", t );
StringBuilder stringBuilder = new StringBuilder();
encode( stringBuilder, stackTraceWriter, false );
@@ -168,7 +161,7 @@ else if ( readTestsFromInputStream )
}
catch ( Throwable t )
{
- dumpException( t, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpException( t );
// Just throwing does getMessage() and a local trace - we want to call printStackTrace for a full trace
// noinspection UseOfSystemOutOrSystemErr
t.printStackTrace( err );
@@ -354,14 +347,4 @@ private static InputStream createSurefirePropertiesIfFileExists( String tmpDir,
File surefirePropertiesFile = new File( tmpDir, propFileName );
return surefirePropertiesFile.exists() ? new FileInputStream( surefirePropertiesFile ) : null;
}
-
- private static File createDumpFile( String dumpFileName, ProviderConfiguration providerConfiguration )
- {
- return newDumpFile( dumpFileName + DUMP_FILE_EXT, providerConfiguration.getReporterConfiguration() );
- }
-
- private static File createDumpstreamFile( String dumpFileName, ProviderConfiguration providerConfiguration )
- {
- return newDumpFile( dumpFileName + DUMPSTREAM_FILE_EXT, providerConfiguration.getReporterConfiguration() );
- }
}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
index 713d4fed89..a80656ea44 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
@@ -97,6 +97,9 @@ public static void writePropertiesFile( File file, String name, Properties prope
try
{
+ /**
+ * See {@link Properties#store(java.io.OutputStream, String)} Javadoc - stream is flushed.
+ */
properties.store( out, name );
}
finally
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
index 61736df46e..6d3d8e2766 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
@@ -94,23 +94,35 @@ public FileInputStream getFileInputStream()
public String slurpFile()
{
+ BufferedReader reader = null;
try
{
StringBuilder sb = new StringBuilder();
- BufferedReader reader;
reader = new BufferedReader( new FileReader( file ) );
for ( String line = reader.readLine(); line != null; line = reader.readLine() )
{
sb.append( line );
}
- reader.close();
return sb.toString();
}
catch ( IOException e )
{
throw new SurefireVerifierException( e );
}
-
+ finally
+ {
+ try
+ {
+ if ( reader != null )
+ {
+ reader.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
+ }
}
public String readFileToString()
diff --git a/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java b/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
index 739e134c83..f46e3bedb3 100644
--- a/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
+++ b/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
@@ -19,43 +19,53 @@
* under the License.
*/
-import java.io.InputStream;
+import junit.framework.TestCase;
+
import java.io.IOException;
+import java.io.InputStream;
import java.util.Properties;
-import junit.framework.TestCase;
-
public class BasicTest
- extends TestCase
+ extends TestCase
{
public void testTestClassesBeforeMainClasses()
+ throws IOException
{
Properties props = getProperties( "/surefire-classpath-order.properties" );
assertEquals( "test-classes", props.getProperty( "Surefire" ) );
}
public void testMainClassesBeforeDependencies()
+ throws IOException
{
Properties props = getProperties( "/surefire-report.properties" );
assertEquals( "classes", props.getProperty( "Surefire" ) );
}
- private Properties getProperties(String resource)
+ private Properties getProperties( String resource )
+ throws IOException
{
InputStream in = getClass().getResourceAsStream( resource );
assertNotNull( in );
try
{
- Properties props = new Properties();
- props.load( in );
- return props;
+ Properties props = new Properties();
+ props.load( in );
+ return props;
}
- catch (IOException e)
+ catch ( IOException e )
{
- fail(e.toString());
+ fail( e.toString() );
return null;
}
+ finally
+ {
+ if ( in != null )
+ {
+ in.close();
+ }
+ }
}
}
diff --git a/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java b/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
index 85d0a5b73d..0112f3143c 100644
--- a/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
@@ -22,23 +22,36 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Writer;
public class FileHelper
{
public static void writeFile( String fileName, String content )
{
+ Writer writer = null;
try
{
- File target = new File( "target" ).getAbsoluteFile();
- File listenerOutput = new File( target, fileName );
- FileWriter out = new FileWriter( listenerOutput );
- out.write( content );
- out.flush();
- out.close();
+ writer = new FileWriter( new File( new File( "target" ).getAbsoluteFile(), fileName ) );
+ writer.write( content );
+ writer.flush();
}
catch ( IOException e )
{
throw new RuntimeException( e );
}
+ finally
+ {
+ try
+ {
+ if ( writer != null )
+ {
+ writer.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
+ }
}
}
diff --git a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
index a4d0cd3f6d..dc651e78e8 100644
--- a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
+++ b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
@@ -60,25 +60,14 @@ public void writeFile()
final File f = new File( "target/tests-run", getClass().getName() + ".txt" );
f.getParentFile().mkdirs();
- FileWriter w = null;
-
+ FileWriter w = new FileWriter( f, true );
try
{
- w = new FileWriter( f, true );
w.write( name.getMethodName() );
}
finally
{
- if ( w != null )
- {
- try
- {
- w.close();
- }
- catch ( final IOException e )
- {
- }
- }
+ w.close();
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
index c9167c1216..f924074854 100644
--- a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
+++ b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
@@ -60,25 +60,15 @@ public void writeFile()
final File f = new File( "target/tests-run", getClass().getName() + ".txt" );
f.getParentFile().mkdirs();
- FileWriter w = null;
+ FileWriter w = new FileWriter( f, true );
try
{
- w = new FileWriter( f, true );
w.write( name.getMethodName() );
}
finally
{
- if ( w != null )
- {
- try
- {
- w.close();
- }
- catch ( final IOException e )
- {
- }
- }
+ w.close();
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
index 035976b403..aa44b64e5d 100644
--- a/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
+++ b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
@@ -41,30 +41,40 @@ public class DumpPidMojo
public void execute()
throws MojoExecutionException
{
- File target;
+ FileWriter fw = null;
try
{
+ File target = new File( targetDir, "maven.pid" ).getCanonicalFile();
getLog().info( "Dumping PID to " + targetDir );
-
+
if ( !targetDir.exists() )
{
targetDir.mkdirs();
}
-
- target = new File( targetDir, "maven.pid" ).getCanonicalFile();
-
- FileWriter fw = new FileWriter( target );
+ fw = new FileWriter( target );
String pid = ManagementFactory.getRuntimeMXBean().getName();
fw.write( pid );
fw.flush();
- fw.close();
-
+
getLog().info( "Wrote " + pid + " to " + target );
-
}
catch ( IOException e )
{
throw new MojoExecutionException( "Unable to create pid file", e );
}
+ finally
+ {
+ try
+ {
+ if ( fw != null )
+ {
+ fw.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
+ }
}
}
diff --git a/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
index 6a6688a656..031b1fa073 100644
--- a/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
@@ -22,23 +22,35 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Writer;
public class FileHelper
{
- public static void writeFile(String fileName, String content)
+ public static void writeFile( String fileName, String content )
{
+ Writer writer = null;
try
{
- File target = new File( "target" ).getAbsoluteFile();
- File listenerOutput = new File( target, fileName );
- FileWriter out = new FileWriter(listenerOutput);
- out.write( content );
- out.flush();
- out.close();
+ writer = new FileWriter( new File( new File( "target" ).getAbsoluteFile(), fileName ) );
+ writer.write( content );
}
catch ( IOException e )
{
- throw new RuntimeException(e);
+ throw new RuntimeException( e );
+ }
+ finally
+ {
+ try
+ {
+ if ( writer != null )
+ {
+ writer.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ throw new RuntimeException( e );
+ }
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
index 4db30b6d02..7e2e8208c8 100644
--- a/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
@@ -3,23 +3,38 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Writer;
public class FileHelper
{
public static void writeFile( String fileName, String content )
{
+ Writer writer = null;
try
{
- File target = new File( System.getProperty("user.dir"), "target" ).getCanonicalFile();
- File listenerOutput = new File( target, fileName );
- FileWriter out = new FileWriter( listenerOutput, true );
- out.write( content );
- out.flush();
- out.close();
+ writer = new FileWriter( new File( new File( System.getProperty( "user.dir" ),
+ "target" ).getCanonicalFile(), fileName ), true );
+
+ writer.write( content );
+ writer.flush();
}
catch ( IOException exception )
{
throw new RuntimeException( exception );
}
+ finally
+ {
+ try
+ {
+ if ( writer != null )
+ {
+ writer.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ // Suppressed.
+ }
+ }
}
}
diff --git a/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
index 4b998ed34e..5451dbfc9b 100644
--- a/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
@@ -8,18 +8,32 @@ public class FileHelper
{
public static void writeFile( String fileName, String content )
{
+ FileWriter out = null;
try
{
File target = new File( System.getProperty("user.dir"), "target" ).getCanonicalFile();
File listenerOutput = new File( target, fileName );
- FileWriter out = new FileWriter( listenerOutput, true );
+ out = new FileWriter( listenerOutput, true );
out.write( content );
out.flush();
- out.close();
}
- catch ( IOException exception )
+ catch ( IOException e )
{
- throw new RuntimeException( exception );
+ throw new RuntimeException( e );
+ }
+ finally
+ {
+ if ( out != null )
+ {
+ try
+ {
+ out.close();
+ }
+ catch ( IOException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
}
}
}
From b50ea3acf0701e4a66ad8f55930cb41dd2bfc999 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 8 Jan 2017 00:21:34 +0100
Subject: [PATCH 038/194] [SUREFIRE-1317] - Refactoring
---
maven-surefire-common/pom.xml | 1 +
.../plugin/surefire/AbstractSurefireMojo.java | 1 +
.../surefire/StartupReportConfiguration.java | 7 ++-
.../surefire/booterclient/ForkStarter.java | 4 +-
.../output/DeserializedStacktraceWriter.java | 2 +-
.../booterclient/output/ForkClient.java | 13 ++++-
.../output/LostCommandsDumpSingleton.java | 7 +++
.../output/ThreadedStreamConsumer.java | 49 ++++++++-----------
.../report/DefaultReporterFactory.java | 13 ++---
.../report/NullStatelessXmlReporter.java | 2 +-
.../surefire/report/StatelessXmlReporter.java | 10 ++--
.../surefire/report/TestSetRunListener.java | 2 +-
.../surefire/runorder/StatisticsReporter.java | 4 +-
.../report/DefaultReporterFactoryTest.java | 18 +++----
.../report/StatelessXmlReporterTest.java | 6 +--
.../maven/plugins/surefire/report/Utils.java | 1 +
.../surefire/booter/MasterProcessCommand.java | 8 ++-
.../report/CategorizedReportEntry.java | 17 +++----
.../maven/surefire/report/SafeThrowable.java | 5 ++
.../surefire/util/internal/StringUtils.java | 28 +----------
20 files changed, 93 insertions(+), 105 deletions(-)
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index 54825b757e..ae71f0d215 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -141,6 +141,7 @@
+
maven-dependency-plugin
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 4f7744fc1e..99eca2cb11 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
@@ -234,6 +234,7 @@ public abstract class AbstractSurefireMojo
* unless overridden.
*/
@Parameter
+ // TODO use regex for fully qualified class names in 3.0 and change the filtering abilities
private List excludes;
/**
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 482ce00582..bf6e5ef81e 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
@@ -171,11 +171,16 @@ public int getRerunFailingTestsCount()
return rerunFailingTestsCount;
}
+ public boolean hasRerunFailingTestsCount()
+ {
+ return getRerunFailingTestsCount() > 0;
+ }
+
public StatelessXmlReporter instantiateStatelessXmlReporter()
{
return isDisableXmlReport()
? null
- : new StatelessXmlReporter( reportsDirectory, reportNameSuffix, trimStackTrace, rerunFailingTestsCount,
+ : new StatelessXmlReporter( reportsDirectory, reportNameSuffix, trimStackTrace, hasRerunFailingTestsCount(),
testClassMethodRunHistory, xsdSchemaLocation );
}
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 05c4cc246a..b864076437 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
@@ -189,9 +189,9 @@ public void run()
{
closeable.close();
}
- catch ( IOException e )
+ catch ( Throwable e )
{
- // ignore
+ e.printStackTrace();
}
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
index 8832a3642b..952feb8d5a 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
@@ -64,6 +64,6 @@ public String writeTrimmedTraceToString()
public SafeThrowable getThrowable()
{
- return new SafeThrowable( new Throwable( message ) );
+ return new SafeThrowable( message );
}
}
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 68ce40deeb..e37e82fe56 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
@@ -25,7 +25,6 @@
import org.apache.maven.shared.utils.cli.StreamConsumer;
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
import org.apache.maven.surefire.report.ReportEntry;
-import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.RunListener;
import org.apache.maven.surefire.report.StackTraceWriter;
@@ -68,6 +67,7 @@
import static org.apache.maven.surefire.util.internal.StringUtils.unescapeBytes;
import static org.apache.maven.surefire.util.internal.StringUtils.unescapeString;
+// todo move to the same package with ForkStarter
/**
* Knows how to reconstruct *all* the state transmitted over stdout by the forked process.
*
@@ -284,16 +284,25 @@ private void processLine( String s )
}
catch ( NumberFormatException e )
{
+ // native stream sent a text e.g. GC verbose
// SUREFIRE-859
LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
}
catch ( NoSuchElementException e )
{
+ // native stream sent a text e.g. GC verbose
// SUREFIRE-859
LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
}
- catch ( ReporterException e )
+ catch ( IndexOutOfBoundsException e )
{
+ // native stream sent a text e.g. GC verbose
+ // SUREFIRE-859
+ LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
+ }
+ catch ( RuntimeException e )
+ {
+ // e.g. ReporterException
LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
throw e;
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
index fa38c053c9..a8f11e48c4 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
@@ -21,8 +21,15 @@
import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
import org.apache.maven.surefire.util.internal.DumpFileUtils;
+
import java.io.File;
+/**
+ * Dumps lost commands and caused exceptions in {@link ForkClient}.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.19.2
+ */
final class LostCommandsDumpSingleton
{
private static final LostCommandsDumpSingleton SINGLETON = new LostCommandsDumpSingleton();
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 ebf3edbe00..c095199c9e 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
@@ -20,12 +20,15 @@
*/
import org.apache.maven.shared.utils.cli.StreamConsumer;
-import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
-import java.util.concurrent.BlockingQueue;
import java.io.Closeable;
+import java.io.IOException;
+import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThread;
+
/**
* Knows how to reconstruct *all* the state transmitted over stdout by the forked process.
*
@@ -36,27 +39,21 @@ public final class ThreadedStreamConsumer
{
private static final String POISON = "Pioson";
- private static final int ITEM_LIMIT_BEFORE_SLEEP = 10000;
-
private final BlockingQueue items = new LinkedBlockingQueue();
private final Thread thread;
private final Pumper pumper;
- static class Pumper
+ final class Pumper
implements Runnable
{
- private final BlockingQueue queue;
-
private final StreamConsumer target;
private volatile Throwable throwable;
-
- Pumper( BlockingQueue queue, StreamConsumer target )
+ Pumper( StreamConsumer target )
{
- this.queue = queue;
this.target = target;
}
@@ -77,7 +74,7 @@ public void run()
{
try
{
- item = queue.take();
+ item = items.take();
target.consumeLine( item );
}
catch ( InterruptedException e )
@@ -99,8 +96,8 @@ public Throwable getThrowable()
public ThreadedStreamConsumer( StreamConsumer target )
{
- pumper = new Pumper( items, target );
- thread = DaemonThreadFactory.newDaemonThread( pumper, "ThreadedStreamConsumer" );
+ pumper = new Pumper( target );
+ thread = newDaemonThread( pumper, ThreadedStreamConsumer.class.getSimpleName() );
thread.start();
}
@@ -108,35 +105,29 @@ public ThreadedStreamConsumer( StreamConsumer target )
public void consumeLine( String s )
{
items.add( s );
- if ( items.size() > ITEM_LIMIT_BEFORE_SLEEP )
- {
- try
- {
- Thread.sleep( 100 );
- }
- catch ( InterruptedException ignore )
- {
- }
- }
}
-
- public void close()
+ public void close() throws IOException
{
try
{
items.add( POISON );
- thread.join();
+ if ( thread.isAlive() )
+ {
+ thread.join( SECONDS.toMillis( 10L ) );
+ thread.interrupt();
+ }
}
catch ( InterruptedException e )
{
- throw new RuntimeException( e );
+ throw new IOException( e );
}
//noinspection ThrowableResultOfMethodCallIgnored
- if ( pumper.getThrowable() != null )
+ Throwable e = pumper.getThrowable();
+ if ( e != null )
{
- throw new RuntimeException( pumper.getThrowable() );
+ throw new IOException( e );
}
}
}
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 b4a6f30f3f..1c2c68c5e6 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
@@ -37,6 +37,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -218,11 +219,11 @@ public static DefaultReporterFactory defaultNoXml()
* if it only has errors or failures, then count its result based on its first run
*
* @param reportEntries the list of test run report type for a given test
- * @param rerunFailingTestsCount configured rerun count for failing tests
+ * @param hasRerunFailingTestsCount true if rerun count for failing tests is greater than zero
* @return the type of test result
*/
// Use default visibility for testing
- static TestResultType getTestResultType( List reportEntries, int rerunFailingTestsCount )
+ static TestResultType getTestResultType( List reportEntries, boolean hasRerunFailingTestsCount )
{
if ( reportEntries == null || reportEntries.isEmpty() )
{
@@ -248,7 +249,7 @@ else if ( resultType == ERROR )
if ( seenFailure || seenError )
{
- if ( seenSuccess && rerunFailingTestsCount > 0 )
+ if ( seenSuccess & hasRerunFailingTestsCount )
{
return flake;
}
@@ -310,7 +311,7 @@ void mergeTestHistoryResult()
// Update globalStatistics by iterating through mergedTestHistoryResult
int completedCount = 0, skipped = 0;
- for ( Map.Entry> entry : mergedTestHistoryResult.entrySet() )
+ for ( Entry> entry : mergedTestHistoryResult.entrySet() )
{
List testMethodStats = entry.getValue();
String testClassMethodName = entry.getKey();
@@ -322,7 +323,7 @@ void mergeTestHistoryResult()
resultTypes.add( methodStats.getResultType() );
}
- switch ( getTestResultType( resultTypes, reportConfiguration.getRerunFailingTestsCount() ) )
+ switch ( getTestResultType( resultTypes, reportConfiguration.hasRerunFailingTestsCount() ) )
{
case success:
// If there are multiple successful runs of the same test, count all of them
@@ -393,7 +394,7 @@ boolean printTestFailures( TestResultType type )
printed = true;
}
- for ( Map.Entry> entry : testStats.entrySet() )
+ for ( Entry> entry : testStats.entrySet() )
{
printed = true;
List testMethodStats = entry.getValue();
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
index 5895c8ad38..e72adc7f52 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
@@ -33,7 +33,7 @@ class NullStatelessXmlReporter
private NullStatelessXmlReporter()
{
- super( null, null, false, 0, null, null );
+ super( null, null, false, false, null, null );
}
@Override
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 8ebeb96c2c..271d3f0dc8 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
@@ -92,7 +92,7 @@ public class StatelessXmlReporter
private final boolean trimStackTrace;
- private final int rerunFailingTestsCount;
+ private final boolean hasRerunFailingTestsCount;
private final String xsdSchemaLocation;
@@ -101,14 +101,14 @@ public class StatelessXmlReporter
private final Map>> testClassMethodRunHistoryMap;
public StatelessXmlReporter( File reportsDirectory, String reportNameSuffix, boolean trimStackTrace,
- int rerunFailingTestsCount,
+ boolean hasRerunFailingTestsCount,
Map>> testClassMethodRunHistoryMap,
String xsdSchemaLocation )
{
this.reportsDirectory = reportsDirectory;
this.reportNameSuffix = reportNameSuffix;
this.trimStackTrace = trimStackTrace;
- this.rerunFailingTestsCount = rerunFailingTestsCount;
+ this.hasRerunFailingTestsCount = hasRerunFailingTestsCount;
this.testClassMethodRunHistoryMap = testClassMethodRunHistoryMap;
this.xsdSchemaLocation = xsdSchemaLocation;
}
@@ -147,7 +147,7 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat
if ( !methodEntryList.isEmpty() )
{
- if ( rerunFailingTestsCount > 0 )
+ if ( hasRerunFailingTestsCount )
{
TestResultType resultType = getTestResultType( methodEntryList );
switch ( resultType )
@@ -268,7 +268,7 @@ private TestResultType getTestResultType( List methodEntryLi
testResultTypeList.add( singleRunEntry.getReportEntryType() );
}
- return DefaultReporterFactory.getTestResultType( testResultTypeList, rerunFailingTestsCount );
+ return DefaultReporterFactory.getTestResultType( testResultTypeList, hasRerunFailingTestsCount );
}
private Map> getAddMethodRunHistoryMap( String testClassName )
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
index f0f996dd24..c5a17d3e47 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
@@ -269,7 +269,7 @@ public void addTestMethodStats()
}
}
- public List getTestMethodStats()
+ List getTestMethodStats()
{
return testMethodStats;
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
index 5776cc9bcc..3f78939082 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
@@ -42,11 +42,11 @@ public StatisticsReporter( File dataFile )
this( dataFile, fromFile( dataFile ), new RunEntryStatisticsMap() );
}
- protected StatisticsReporter( File dataFile, RunEntryStatisticsMap existing, RunEntryStatisticsMap newRestuls )
+ protected StatisticsReporter( File dataFile, RunEntryStatisticsMap existing, RunEntryStatisticsMap newResults )
{
this.dataFile = dataFile;
this.existing = existing;
- this.newResults = newRestuls;
+ this.newResults = newResults;
}
public synchronized void testSetCompleted()
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 fbe875de2a..c4c2556190 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
@@ -185,41 +185,41 @@ void reset()
public void testGetTestResultType()
{
List emptyList = new ArrayList();
- assertEquals( unknown, getTestResultType( emptyList, 1 ) );
+ assertEquals( unknown, getTestResultType( emptyList, true ) );
List successList = new ArrayList();
successList.add( ReportEntryType.SUCCESS );
successList.add( ReportEntryType.SUCCESS );
- assertEquals( success, getTestResultType( successList, 1 ) );
+ assertEquals( success, getTestResultType( successList, true ) );
List failureErrorList = new ArrayList();
failureErrorList.add( ReportEntryType.FAILURE );
failureErrorList.add( ReportEntryType.ERROR );
- assertEquals( error, getTestResultType( failureErrorList, 1 ) );
+ assertEquals( error, getTestResultType( failureErrorList, true ) );
List errorFailureList = new ArrayList();
errorFailureList.add( ReportEntryType.ERROR );
errorFailureList.add( ReportEntryType.FAILURE );
- assertEquals( error, getTestResultType( errorFailureList, 1 ) );
+ assertEquals( error, getTestResultType( errorFailureList, true ) );
List flakeList = new ArrayList();
flakeList.add( ReportEntryType.SUCCESS );
flakeList.add( ReportEntryType.FAILURE );
- assertEquals( flake, getTestResultType( flakeList, 1 ) );
+ assertEquals( flake, getTestResultType( flakeList, true ) );
- assertEquals( failure, getTestResultType( flakeList, 0 ) );
+ assertEquals( failure, getTestResultType( flakeList, false ) );
flakeList = new ArrayList();
flakeList.add( ReportEntryType.ERROR );
flakeList.add( ReportEntryType.SUCCESS );
flakeList.add( ReportEntryType.FAILURE );
- assertEquals( flake, getTestResultType( flakeList, 1 ) );
+ assertEquals( flake, getTestResultType( flakeList, true ) );
- assertEquals( error, getTestResultType( flakeList, 0 ) );
+ assertEquals( error, getTestResultType( flakeList, false ) );
List skippedList = new ArrayList();
skippedList.add( ReportEntryType.SKIPPED );
- assertEquals( skipped, getTestResultType( skippedList, 1 ) );
+ assertEquals( skipped, getTestResultType( skippedList, true ) );
}
static class DummyStackTraceWriter
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 5b649e3a09..553ee40841 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
@@ -83,7 +83,7 @@ protected void tearDown()
public void testFileNameWithoutSuffix()
{
StatelessXmlReporter reporter =
- new StatelessXmlReporter( reportDir, null, false, 0,
+ new StatelessXmlReporter( reportDir, null, false, false,
new ConcurrentHashMap>>(), XSD );
reporter.cleanTestHistoryMap();
@@ -136,7 +136,7 @@ public void testAllFieldsSerialized()
ReportEntryType.ERROR, 13, stdOut, stdErr );
stats.testSucceeded( t2 );
- StatelessXmlReporter reporter = new StatelessXmlReporter( reportDir, null, false, 0,
+ StatelessXmlReporter reporter = new StatelessXmlReporter( reportDir, null, false, false,
new ConcurrentHashMap>>(), XSD );
reporter.testSetCompleted( testSetReportEntry, stats );
@@ -216,7 +216,7 @@ public void testOutputRerunFlakyFailure()
rerunStats.testSucceeded( testThreeSecondRun );
StatelessXmlReporter reporter =
- new StatelessXmlReporter( reportDir, null, false, 1,
+ new StatelessXmlReporter( reportDir, null, false, true,
new HashMap>>(), XSD );
reporter.testSetCompleted( testSetReportEntry, stats );
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
index 8fd91bf24b..d2cb04e5c4 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
@@ -23,6 +23,7 @@ public final class Utils
{
private Utils()
{
+ throw new IllegalStateException( "no instantiable constructor" );
}
public static String toSystemNewLine( String s )
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index a75aa83890..0bd7b89b4f 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -19,8 +19,6 @@
* under the License.
*/
-import org.apache.maven.surefire.util.internal.StringUtils;
-
import java.io.DataInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -48,7 +46,7 @@ public enum MasterProcessCommand
/** To tell a forked process that the master process is still alive. Repeated after 10 seconds. */
NOOP( 4, Void.class );
- private static final Charset ASCII = Charset.forName( "ASCII" );
+ private static final Charset ASCII = Charset.forName( "US-ASCII" );
private final int id;
@@ -152,7 +150,7 @@ String toDataTypeAsString( byte... data )
case RUN_CLASS:
return new String( data, FORK_STREAM_CHARSET_NAME );
case SHUTDOWN:
- return StringUtils.decode( data, ASCII );
+ return new String( data, ASCII );
default:
return null;
}
@@ -170,7 +168,7 @@ byte[] fromDataType( String data )
case RUN_CLASS:
return encodeStringForForkCommunication( data );
case SHUTDOWN:
- return StringUtils.encode( data, ASCII );
+ return data.getBytes( ASCII );
default:
return new byte[0];
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
index 77cfaf363e..0cccd6e97c 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
@@ -67,17 +67,7 @@ public String getGroup()
@Override
public String getNameWithGroup()
{
- StringBuilder result = new StringBuilder();
- result.append( getName() );
-
- if ( getGroup() != null && !getName().equals( getGroup() ) )
- {
- result.append( GROUP_PREFIX );
- result.append( getGroup() );
- result.append( GROUP_SUFIX );
- }
-
- return result.toString();
+ return isNameWithGroup() ? getName() + GROUP_PREFIX + getGroup() + GROUP_SUFIX : getName();
}
public boolean equals( Object o )
@@ -107,4 +97,9 @@ public int hashCode()
result = 31 * result + ( group != null ? group.hashCode() : 0 );
return result;
}
+
+ private boolean isNameWithGroup()
+ {
+ return getGroup() != null && !getGroup().equals( getName() );
+ }
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
index 60c78975aa..b3b86f2761 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
@@ -31,6 +31,11 @@ public SafeThrowable( Throwable target )
this.target = target;
}
+ public SafeThrowable( String message )
+ {
+ this( new Throwable( message ) );
+ }
+
public String getLocalizedMessage()
{
try
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index 830cace5e8..352b5fd4f4 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -57,7 +57,7 @@
*/
public final class StringUtils
{
- public static final String NL = System.getProperty( "line.separator" );
+ public static final String NL = System.getProperty( "line.separator", "\n" );
private static final byte[] HEX_CHARS = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
@@ -345,32 +345,6 @@ public static ByteBuffer unescapeBytes( String str, String charsetName )
return ByteBuffer.wrap( out, 0, outPos );
}
- public static String decode( byte[] toDecode, Charset charset )
- {
- try
- {
- // @todo use new JDK 1.6 constructor String(byte bytes[], Charset charset)
- return new String( toDecode, charset.name() );
- }
- catch ( UnsupportedEncodingException e )
- {
- throw new RuntimeException( "The JVM must support Charset " + charset, e );
- }
- }
-
- public static byte[] encode( String toEncode, Charset charset )
- {
- try
- {
- // @todo use new JDK 1.6 method getBytes(Charset charset)
- return toEncode.getBytes( charset.name() );
- }
- catch ( UnsupportedEncodingException e )
- {
- throw new RuntimeException( "The JVM must support Charset " + charset, e );
- }
- }
-
public static byte[] encodeStringForForkCommunication( String string )
{
try
From 4d3673c42e2af75c22f3abbaa2a0237a5c25e0ce Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 8 Jan 2017 00:22:48 +0100
Subject: [PATCH 039/194] [SUREFIRE-1322] - Surefire and Failsafe should dump
critical errors in dump file and console
---
.../maven/surefire/booter/CommandReader.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
index 3990d467ac..3f24a1b54d 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
@@ -377,7 +377,7 @@ public void run()
if ( command == null )
{
String errorMessage = "[SUREFIRE] std/in stream corrupted: first sequence not recognized";
- DumpErrorSingleton.getSingleton().dumpText( errorMessage );
+ DumpErrorSingleton.getSingleton().dumpStreamText( errorMessage );
logger.error( errorMessage );
break;
}
@@ -414,24 +414,27 @@ public void run()
}
catch ( EOFException e )
{
- DumpErrorSingleton.getSingleton().dumpException( e );
-
CommandReader.this.state.set( TERMINATED );
if ( !isTestSetFinished )
{
+ String msg = "TestSet has not finished before stream error has appeared >> "
+ + "initializing exit by non-null configuration: "
+ + CommandReader.this.shutdown;
+ DumpErrorSingleton.getSingleton().dumpStreamException( e, msg );
+
exitByConfiguration();
// does not go to finally
}
}
catch ( IOException e )
{
- DumpErrorSingleton.getSingleton().dumpException( e );
-
CommandReader.this.state.set( TERMINATED );
// If #stop() method is called, reader thread is interrupted and cause is InterruptedException.
if ( !( e.getCause() instanceof InterruptedException ) )
{
- logger.error( "[SUREFIRE] std/in stream corrupted", e );
+ String msg = "[SUREFIRE] std/in stream corrupted";
+ DumpErrorSingleton.getSingleton().dumpStreamException( e, msg );
+ logger.error( msg, e );
}
}
finally
From 8004064be0f1e40539cd7879aa7752a78af97891 Mon Sep 17 00:00:00 2001
From: Christian Schulte
Date: Sun, 8 Jan 2017 00:33:35 +0100
Subject: [PATCH 040/194] [SUREFIRE-1324] Surefire incorrectly suppresses
exceptions when closing resources.
o Updated various comments.
---
.../org/apache/maven/plugin/surefire/SurefireProperties.java | 2 +-
.../org/apache/maven/surefire/booter/SystemPropertyManager.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
index b645032b9a..0125aa463b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
@@ -247,7 +247,7 @@ private static SurefireProperties loadProperties( final InputStream inStream )
}
catch ( final IOException e )
{
- // Suppressed.
+ // Suppressed, so that the exception thrown in the try block will be propagated.
}
}
}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
index 68d79a4ce8..8d301dca37 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
@@ -71,7 +71,7 @@ public static PropertiesWrapper loadProperties( InputStream inStream )
}
catch ( final IOException e1 )
{
- // Suppressed.
+ // Suppressed, so that the exception thrown in the try block will be propagated.
}
}
}
From d580f672bad6bb234309890f30dc0c8a83a427d8 Mon Sep 17 00:00:00 2001
From: Christian Schulte
Date: Sun, 8 Jan 2017 01:12:09 +0100
Subject: [PATCH 041/194] o Updated to correct issues introduced by latest
commits. I did not notice the merge commits also had simple-merge file
changes.
o I missed this email
but I read this email
and pulled.
---
.../plugin/surefire/report/ConsoleOutputFileReporter.java | 5 ++++-
.../plugin/surefire/runorder/RunEntryStatisticsMap.java | 1 +
.../apache/maven/surefire/booter/MasterProcessCommand.java | 1 -
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
index da08d01414..4c49c9ebf1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
@@ -66,7 +66,10 @@ public void close()
{
try
{
- this.fileOutputStream.close();
+ if ( this.fileOutputStream != null )
+ {
+ this.fileOutputStream.close();
+ }
}
catch ( final IOException e )
{
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
index 2e9c133854..b9f9b0e6df 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
@@ -23,6 +23,7 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index d5f6375f98..095201d417 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -24,7 +24,6 @@
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import static java.lang.String.format;
-import org.apache.maven.surefire.util.internal.StringUtils;
import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
From cc09759a9adfa1de4ce968fa8745fc305b7c52e3 Mon Sep 17 00:00:00 2001
From: Christian Schulte
Date: Sun, 8 Jan 2017 06:03:13 +0100
Subject: [PATCH 042/194] [MSUREFIRE-1324] Surefire incorrectly suppresses
exceptions when closing resources.
---
.../surefire/report/StatelessXmlReporter.java | 27 +++++++++++++------
1 file changed, 19 insertions(+), 8 deletions(-)
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 271d3f0dc8..b846942987 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
@@ -125,10 +125,12 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat
getAddMethodEntryList( methodRunHistoryMap, methodEntry );
}
- FileOutputStream outputStream = getOutputStream( testSetReportEntry );
- OutputStreamWriter fw = getWriter( outputStream );
+ FileOutputStream outputStream = null;
+ OutputStreamWriter fw = null;
try
{
+ outputStream = getOutputStream( testSetReportEntry );
+ fw = getWriter( outputStream );
XMLWriter ppw = new PrettyPrintXMLWriter( fw );
ppw.setEncoding( ENCODING );
@@ -239,10 +241,19 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat
}
}
ppw.endElement(); // TestSuite
+
+ fw.close();
+ fw = null;
+ outputStream = null;
+ }
+ catch ( final IOException e )
+ {
+ throw new RuntimeException( "Failure creating report.", e );
}
finally
{
IOUtil.close( fw );
+ IOUtil.close( outputStream );
}
}
@@ -326,7 +337,7 @@ private static File getReportFile( ReportEntry report, File reportsDirectory, St
}
private static void startTestElement( XMLWriter ppw, WrappedReportEntry report, String reportNameSuffix,
- String timeAsString )
+ String timeAsString ) throws IOException
{
ppw.startElement( "testcase" );
ppw.addAttribute( "name", report.getReportName() );
@@ -349,7 +360,7 @@ private static void startTestElement( XMLWriter ppw, WrappedReportEntry report,
}
private void createTestSuiteElement( XMLWriter ppw, WrappedReportEntry report, TestSetStats testSetStats,
- String timeAsString )
+ String timeAsString ) throws IOException
{
ppw.startElement( "testsuite" );
@@ -376,7 +387,7 @@ private void createTestSuiteElement( XMLWriter ppw, WrappedReportEntry report, T
private static void getTestProblems( OutputStreamWriter outputStreamWriter, XMLWriter ppw,
WrappedReportEntry report, boolean trimStackTrace, FileOutputStream fw,
- String testErrorType, boolean createOutErrElementsInside )
+ String testErrorType, boolean createOutErrElementsInside ) throws IOException
{
ppw.startElement( testErrorType );
@@ -421,7 +432,7 @@ private static void getTestProblems( OutputStreamWriter outputStreamWriter, XMLW
// Create system-out and system-err elements
private static void createOutErrElements( OutputStreamWriter outputStreamWriter, XMLWriter ppw,
- WrappedReportEntry report, FileOutputStream fw )
+ WrappedReportEntry report, FileOutputStream fw ) throws IOException
{
EncodingOutputStream eos = new EncodingOutputStream( fw );
addOutputStreamElement( outputStreamWriter, eos, ppw, report.getStdout(), "system-out" );
@@ -431,7 +442,7 @@ private static void createOutErrElements( OutputStreamWriter outputStreamWriter,
private static void addOutputStreamElement( OutputStreamWriter outputStreamWriter,
EncodingOutputStream eos, XMLWriter xmlWriter,
Utf8RecodingDeferredFileOutputStream utf8RecodingDeferredFileOutputStream,
- String name )
+ String name ) throws IOException
{
if ( utf8RecodingDeferredFileOutputStream != null && utf8RecodingDeferredFileOutputStream.getByteCount() > 0 )
{
@@ -461,7 +472,7 @@ private static void addOutputStreamElement( OutputStreamWriter outputStreamWrite
*
* @param xmlWriter The test suite to report to
*/
- private static void showProperties( XMLWriter xmlWriter )
+ private static void showProperties( XMLWriter xmlWriter ) throws IOException
{
xmlWriter.startElement( "properties" );
From 18018cce343fb8394f017b867b277378c5774405 Mon Sep 17 00:00:00 2001
From: Christian Schulte
Date: Sun, 8 Jan 2017 06:03:57 +0100
Subject: [PATCH 043/194] [MSUREFIRE-1326] Upgrade maven-shared-utils to 3.2.0.
o Updated to 3.2.0-SNAPSHOT temporarily.
---
pom.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 3b8ab650cd..4338a3e1e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -215,7 +215,8 @@
org.apache.maven.sharedmaven-shared-utils
- 0.9
+
+ 3.2.0-SNAPSHOTorg.apache.maven.shared
From 9c8bc861a5c1a78955246e38e97eb747370a55c7 Mon Sep 17 00:00:00 2001
From: Christian Schulte
Date: Sun, 8 Jan 2017 07:44:59 +0100
Subject: [PATCH 044/194] [MSUREFIRE-1326] Upgrade maven-shared-utils to 3.2.0.
o Upgraded to include transitive 'commons-io' in the shaded package.
---
maven-failsafe-plugin/pom.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index a5d41ff5a1..c66d22b58f 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -196,6 +196,7 @@
org.apache.maven.shared:maven-shared-utils
+ commons-io:commons-io
From 073d5b32615c5c95c8682c113a586007c6200cb5 Mon Sep 17 00:00:00 2001
From: Stephen Connolly
Date: Mon, 23 Jan 2017 10:55:03 +0000
Subject: [PATCH 045/194] Revert "[MSUREFIRE-1326] Upgrade maven-shared-utils
to 3.2.0."
This reverts commit 9c8bc861a5c1a78955246e38e97eb747370a55c7.
---
maven-failsafe-plugin/pom.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index c66d22b58f..a5d41ff5a1 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -196,7 +196,6 @@
org.apache.maven.shared:maven-shared-utils
- commons-io:commons-io
From cc7e85ccf50a3281ab6b47ae1d806297fc40ba1c Mon Sep 17 00:00:00 2001
From: Stephen Connolly
Date: Mon, 23 Jan 2017 10:55:06 +0000
Subject: [PATCH 046/194] Revert "[MSUREFIRE-1326] Upgrade maven-shared-utils
to 3.2.0."
This reverts commit 18018cce343fb8394f017b867b277378c5774405.
---
pom.xml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 4338a3e1e7..3b8ab650cd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -215,8 +215,7 @@
org.apache.maven.sharedmaven-shared-utils
-
- 3.2.0-SNAPSHOT
+ 0.9org.apache.maven.shared
From 0dbb5bb8a6522cc50a3609c353f0f7802946c0e2 Mon Sep 17 00:00:00 2001
From: Stephen Connolly
Date: Mon, 23 Jan 2017 10:55:07 +0000
Subject: [PATCH 047/194] Revert "[MSUREFIRE-1324] Surefire incorrectly
suppresses exceptions when closing resources."
This reverts commit cc09759a9adfa1de4ce968fa8745fc305b7c52e3.
---
.../surefire/report/StatelessXmlReporter.java | 27 ++++++-------------
1 file changed, 8 insertions(+), 19 deletions(-)
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 b846942987..271d3f0dc8 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
@@ -125,12 +125,10 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat
getAddMethodEntryList( methodRunHistoryMap, methodEntry );
}
- FileOutputStream outputStream = null;
- OutputStreamWriter fw = null;
+ FileOutputStream outputStream = getOutputStream( testSetReportEntry );
+ OutputStreamWriter fw = getWriter( outputStream );
try
{
- outputStream = getOutputStream( testSetReportEntry );
- fw = getWriter( outputStream );
XMLWriter ppw = new PrettyPrintXMLWriter( fw );
ppw.setEncoding( ENCODING );
@@ -241,19 +239,10 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat
}
}
ppw.endElement(); // TestSuite
-
- fw.close();
- fw = null;
- outputStream = null;
- }
- catch ( final IOException e )
- {
- throw new RuntimeException( "Failure creating report.", e );
}
finally
{
IOUtil.close( fw );
- IOUtil.close( outputStream );
}
}
@@ -337,7 +326,7 @@ private static File getReportFile( ReportEntry report, File reportsDirectory, St
}
private static void startTestElement( XMLWriter ppw, WrappedReportEntry report, String reportNameSuffix,
- String timeAsString ) throws IOException
+ String timeAsString )
{
ppw.startElement( "testcase" );
ppw.addAttribute( "name", report.getReportName() );
@@ -360,7 +349,7 @@ private static void startTestElement( XMLWriter ppw, WrappedReportEntry report,
}
private void createTestSuiteElement( XMLWriter ppw, WrappedReportEntry report, TestSetStats testSetStats,
- String timeAsString ) throws IOException
+ String timeAsString )
{
ppw.startElement( "testsuite" );
@@ -387,7 +376,7 @@ private void createTestSuiteElement( XMLWriter ppw, WrappedReportEntry report, T
private static void getTestProblems( OutputStreamWriter outputStreamWriter, XMLWriter ppw,
WrappedReportEntry report, boolean trimStackTrace, FileOutputStream fw,
- String testErrorType, boolean createOutErrElementsInside ) throws IOException
+ String testErrorType, boolean createOutErrElementsInside )
{
ppw.startElement( testErrorType );
@@ -432,7 +421,7 @@ private static void getTestProblems( OutputStreamWriter outputStreamWriter, XMLW
// Create system-out and system-err elements
private static void createOutErrElements( OutputStreamWriter outputStreamWriter, XMLWriter ppw,
- WrappedReportEntry report, FileOutputStream fw ) throws IOException
+ WrappedReportEntry report, FileOutputStream fw )
{
EncodingOutputStream eos = new EncodingOutputStream( fw );
addOutputStreamElement( outputStreamWriter, eos, ppw, report.getStdout(), "system-out" );
@@ -442,7 +431,7 @@ private static void createOutErrElements( OutputStreamWriter outputStreamWriter,
private static void addOutputStreamElement( OutputStreamWriter outputStreamWriter,
EncodingOutputStream eos, XMLWriter xmlWriter,
Utf8RecodingDeferredFileOutputStream utf8RecodingDeferredFileOutputStream,
- String name ) throws IOException
+ String name )
{
if ( utf8RecodingDeferredFileOutputStream != null && utf8RecodingDeferredFileOutputStream.getByteCount() > 0 )
{
@@ -472,7 +461,7 @@ private static void addOutputStreamElement( OutputStreamWriter outputStreamWrite
*
* @param xmlWriter The test suite to report to
*/
- private static void showProperties( XMLWriter xmlWriter ) throws IOException
+ private static void showProperties( XMLWriter xmlWriter )
{
xmlWriter.startElement( "properties" );
From 45457a33657aa4ab1a4d3fc96274490a47890cbd Mon Sep 17 00:00:00 2001
From: Stephen Connolly
Date: Mon, 23 Jan 2017 10:55:09 +0000
Subject: [PATCH 048/194] Revert "o Updated to correct issues introduced by
latest commits. I did not notice the"
This reverts commit d580f672bad6bb234309890f30dc0c8a83a427d8.
---
.../plugin/surefire/report/ConsoleOutputFileReporter.java | 5 +----
.../plugin/surefire/runorder/RunEntryStatisticsMap.java | 1 -
.../apache/maven/surefire/booter/MasterProcessCommand.java | 1 +
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
index 4c49c9ebf1..da08d01414 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
@@ -66,10 +66,7 @@ public void close()
{
try
{
- if ( this.fileOutputStream != null )
- {
- this.fileOutputStream.close();
- }
+ this.fileOutputStream.close();
}
catch ( final IOException e )
{
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
index b9f9b0e6df..2e9c133854 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
@@ -23,7 +23,6 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index 095201d417..d5f6375f98 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -24,6 +24,7 @@
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import static java.lang.String.format;
+import org.apache.maven.surefire.util.internal.StringUtils;
import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
From 90654a0ae2d5cae286b00badaa039cdaa0e05c4c Mon Sep 17 00:00:00 2001
From: Stephen Connolly
Date: Mon, 23 Jan 2017 10:55:35 +0000
Subject: [PATCH 049/194] Revert "Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/maven-surefire"
This reverts commit 780f91393046fd11129cd9ee5bd10ca1d59286f0, reversing
changes made to 4d3673c42e2af75c22f3abbaa2a0237a5c25e0ce.
---
.../plugin/surefire/SurefireProperties.java | 28 ++-----
.../booterclient/ForkConfiguration.java | 22 +++---
.../report/ConsoleOutputFileReporter.java | 26 ++++---
.../plugin/surefire/report/FileReporter.java | 75 +++++++------------
.../surefire/report/TestSetRunListener.java | 37 ++++-----
.../surefire/runorder/StatisticsReporter.java | 7 +-
.../util/DependenciesScannerTest.java | 8 +-
.../surefire/report/FileReporterTest.java | 10 +--
.../report/SurefireReportMojoTest.java | 2 -
.../runorder/RunEntryStatisticsMap.java | 58 ++++++--------
.../surefire/booter/ForkingRunListener.java | 15 ++--
.../surefire/booter/MasterProcessCommand.java | 2 +-
.../maven/surefire/booter/ForkedBooter.java | 16 ++--
.../booter/SystemPropertyManager.java | 41 ++--------
.../maven/surefire/its/fixture/TestFile.java | 6 +-
.../src/test/java/it/BasicTest.java | 20 ++---
.../src/test/java/runListener/FileHelper.java | 5 +-
.../maven/surefire/test/FailingTest.java | 17 +----
.../maven/surefire/test/SucceedingTest.java | 17 +----
.../plugins/surefire/dumppid/DumpPidMojo.java | 7 +-
.../test/java/listenReport/FileHelper.java | 4 +-
.../java/testng/objectfactory/FileHelper.java | 3 +-
.../testng/testrunnerfactory/FileHelper.java | 20 +++--
23 files changed, 161 insertions(+), 285 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
index 0125aa463b..53aa134fc8 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
@@ -19,6 +19,10 @@
* under the License.
*/
+import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.KeyValueSource;
+import org.apache.maven.surefire.util.internal.StringUtils;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -32,10 +36,9 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+
import static java.util.Arrays.asList;
-import org.apache.maven.surefire.booter.Classpath;
-import org.apache.maven.surefire.booter.KeyValueSource;
-import org.apache.maven.surefire.util.internal.StringUtils;
+import static org.apache.maven.shared.utils.io.IOUtil.close;
/**
* A properties implementation that preserves insertion order.
@@ -225,30 +228,15 @@ public void setClasspath( String prefix, Classpath classpath )
private static SurefireProperties loadProperties( final InputStream inStream )
throws IOException
{
- InputStream in = inStream;
-
try
{
final Properties p = new Properties();
- p.load( in );
- in.close();
- in = null;
+ p.load( inStream );
return new SurefireProperties( p );
}
finally
{
- // @todo use try-with-resources JDK7, search in all code
- try
- {
- if ( in != null )
- {
- in.close();
- }
- }
- catch ( final IOException e )
- {
- // Suppressed, so that the exception thrown in the try block will be propagated.
- }
+ close( inStream ); // @todo use try-with-resources JDK7, search in all code
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index f42c8aada0..6cb0fabed1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -19,6 +19,16 @@
* under the License.
*/
+import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.util.Relocator;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.io.IOUtil;
+import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.ForkedBooter;
+import org.apache.maven.surefire.booter.StartupConfiguration;
+import org.apache.maven.surefire.booter.SurefireBooterForkException;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -29,15 +39,6 @@
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
-import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
-import org.apache.maven.plugin.surefire.util.Relocator;
-import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.io.IOUtil;
-import org.apache.maven.surefire.booter.Classpath;
-import org.apache.maven.surefire.booter.ForkedBooter;
-import org.apache.maven.surefire.booter.StartupConfiguration;
-import org.apache.maven.surefire.booter.SurefireBooterForkException;
/**
* Configuration for forking tests.
@@ -297,9 +298,6 @@ private File createJar( List classPath, String startClassName )
man.getMainAttributes().putValue( "Main-Class", startClassName );
man.write( jos );
-
- jos.close();
- jos = null;
}
finally
{
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
index da08d01414..914d6844a4 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
@@ -22,8 +22,10 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+
import org.apache.maven.shared.utils.io.IOUtil;
import org.apache.maven.surefire.report.ReportEntry;
+
import static org.apache.maven.plugin.surefire.report.FileReporter.getReportFile;
/**
@@ -64,17 +66,21 @@ public void testSetCompleted( ReportEntry report )
@SuppressWarnings( "checkstyle:emptyblock" )
public void close()
{
- try
- {
- this.fileOutputStream.close();
- }
- catch ( final IOException e )
- {
- throw new RuntimeException( "Failure closing reporter.", e );
- }
- finally
+ if ( fileOutputStream != null )
{
- this.fileOutputStream = null;
+ try
+ {
+ fileOutputStream.flush();
+ fileOutputStream.close();
+ }
+ catch ( IOException e )
+ {
+ // do nothing
+ }
+ finally
+ {
+ fileOutputStream = null;
+ }
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
index d7a41af70e..6239f77d02 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
@@ -19,13 +19,14 @@
* under the License.
*/
-import java.io.BufferedWriter;
+import org.apache.maven.surefire.report.ReportEntry;
+import org.apache.maven.surefire.report.ReporterException;
+
import java.io.File;
-import java.io.FileWriter;
import java.io.IOException;
+import java.io.PrintWriter;
import java.util.List;
-import org.apache.maven.surefire.report.ReportEntry;
-import org.apache.maven.surefire.report.ReporterException;
+
import static org.apache.maven.plugin.surefire.report.FileReporterUtils.stripIllegalFilenameChars;
import static org.apache.maven.surefire.util.internal.StringUtils.isNotBlank;
@@ -47,7 +48,7 @@ public FileReporter( File reportsDirectory, String reportNameSuffix )
this.reportNameSuffix = reportNameSuffix;
}
- private BufferedWriter testSetStarting( ReportEntry report )
+ private PrintWriter testSetStarting( ReportEntry report )
{
File reportFile = getReportFile( reportsDirectory, report.getName(), reportNameSuffix, ".txt" );
@@ -56,39 +57,27 @@ private BufferedWriter testSetStarting( ReportEntry report )
// noinspection ResultOfMethodCallIgnored
reportDir.mkdirs();
- BufferedWriter writer = null;
try
{
- writer = new BufferedWriter( new FileWriter( reportFile ) );
+ /**
+ * The implementation of constructor {@link PrintWriter(File)}
+ * uses {@link java.io.BufferedWriter}
+ * which is guaranteed by Java 1.5 Javadoc of the constructor:
+ * "The output will be written to the file and is buffered."
+ */
+ PrintWriter writer = new PrintWriter( reportFile );
- writer.append( "-------------------------------------------------------------------------------" );
- writer.newLine();
+ writer.println( "-------------------------------------------------------------------------------" );
- writer.append( "Test set: " + report.getName() );
- writer.newLine();
+ writer.println( "Test set: " + report.getName() );
- writer.append( "-------------------------------------------------------------------------------" );
- writer.newLine();
+ writer.println( "-------------------------------------------------------------------------------" );
return writer;
}
catch ( IOException e )
{
- try
- {
- if ( writer != null )
- {
- writer.close();
- }
- }
- catch ( final IOException e1 )
- {
- // Suppressed.
- }
- finally
- {
- throw new ReporterException( "Unable to create file for report: " + e.getMessage(), e );
- }
+ throw new ReporterException( "Unable to create file for report: " + e.getMessage(), e );
}
}
@@ -101,37 +90,23 @@ public static File getReportFile( File reportsDirectory, String reportEntryName,
}
public void testSetCompleted( WrappedReportEntry report, TestSetStats testSetStats, List testResults )
- throws IOException
{
- BufferedWriter writer = null;
+ /**
+ * Using buffered stream internally.
+ */
+ PrintWriter writer = testSetStarting( report );
try
{
- writer = testSetStarting( report );
- writer.append( testSetStats.getTestSetSummary( report ) );
- writer.newLine();
-
+ writer.println( testSetStats.getTestSetSummary( report ) );
for ( String testResult : testResults )
{
- writer.append( testResult );
- writer.newLine();
+ writer.println( testResult );
}
-
- writer.close();
- writer = null;
+ writer.flush();
}
finally
{
- try
- {
- if ( writer != null )
- {
- writer.close();
- }
- }
- catch ( final IOException e )
- {
- // Suppressed.
- }
+ writer.close();
}
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
index a9b8f3bb90..c5a17d3e47 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
@@ -151,29 +151,22 @@ public void clearCapture()
public void testSetCompleted( ReportEntry report )
{
- try
- {
- final WrappedReportEntry wrap = wrapTestSet( report );
- final List testResults =
+ final WrappedReportEntry wrap = wrapTestSet( report );
+ final List testResults =
briefOrPlainFormat ? detailsForThis.getTestResults() : Collections.emptyList();
- fileReporter.testSetCompleted( wrap, detailsForThis, testResults );
- simpleXMLReporter.testSetCompleted( wrap, detailsForThis );
- statisticsReporter.testSetCompleted();
- consoleReporter.testSetCompleted( wrap, detailsForThis, testResults );
- consoleOutputReceiver.testSetCompleted( wrap );
- consoleReporter.reset();
-
- wrap.getStdout().free();
- wrap.getStdErr().free();
-
- addTestMethodStats();
- detailsForThis.reset();
- clearCapture();
- }
- catch ( final IOException e )
- {
- throw new RuntimeException( "Unexpected IOException.e", e );
- }
+ fileReporter.testSetCompleted( wrap, detailsForThis, testResults );
+ simpleXMLReporter.testSetCompleted( wrap, detailsForThis );
+ statisticsReporter.testSetCompleted();
+ consoleReporter.testSetCompleted( wrap, detailsForThis, testResults );
+ consoleOutputReceiver.testSetCompleted( wrap );
+ consoleReporter.reset();
+
+ wrap.getStdout().free();
+ wrap.getStdErr().free();
+
+ addTestMethodStats();
+ detailsForThis.reset();
+ clearCapture();
}
// ----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
index ee3421e3f3..3f78939082 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
@@ -19,10 +19,11 @@
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
import org.apache.maven.surefire.report.ReportEntry;
+import java.io.File;
+import java.io.FileNotFoundException;
+
import static org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMap.fromFile;
/**
@@ -54,7 +55,7 @@ public synchronized void testSetCompleted()
{
newResults.serialize( dataFile );
}
- catch ( IOException e )
+ catch ( FileNotFoundException e )
{
throw new RuntimeException( e );
}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java
index a223a0d95f..c8dd436471 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java
@@ -75,10 +75,9 @@ private File writeTestFile()
File output = new File( "target/DependenciesScannerTest-tests.jar" );
output.delete();
- ZipOutputStream out = null;
+ ZipOutputStream out = new ZipOutputStream( new FileOutputStream( output ) );
try
{
- out = new ZipOutputStream( new FileOutputStream( output ) );
out.putNextEntry( new ZipEntry( "org/test/TestA.class" ) );
out.closeEntry();
out.putNextEntry( new ZipEntry( "org/test/TestB.class" ) );
@@ -87,10 +86,7 @@ private File writeTestFile()
}
finally
{
- if ( out != null )
- {
- out.close();
- }
+ out.close();
}
}
}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
index f8a92d8f12..076b23c340 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
@@ -19,15 +19,15 @@
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
import junit.framework.TestCase;
import org.apache.maven.plugin.surefire.report.FileReporter;
import org.apache.maven.plugin.surefire.report.ReportEntryType;
import org.apache.maven.plugin.surefire.report.TestSetStats;
import org.apache.maven.plugin.surefire.report.WrappedReportEntry;
+import java.io.File;
+import java.util.ArrayList;
+
public class FileReporterTest
extends TestCase
{
@@ -38,7 +38,7 @@ public class FileReporterTest
private static final String testName = "org.apache.maven.surefire.report.FileReporterTest";
- public void testFileNameWithoutSuffix() throws IOException
+ public void testFileNameWithoutSuffix()
{
File reportDir = new File( "target" );
reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
@@ -58,7 +58,7 @@ private TestSetStats createTestSetStats()
return new TestSetStats( true, true );
}
- public void testFileNameWithSuffix() throws IOException
+ public void testFileNameWithSuffix()
{
File reportDir = new File( "target" );
String suffixText = "sampleSuffixText";
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
index 8532b1bac0..724e72d51a 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
@@ -640,8 +640,6 @@ private void renderer( SurefireReportMojo mojo, File outputHtml )
writer = WriterFactory.newXmlWriter( outputHtml );
// renderer doxia 1.6 already closed the writer
renderer.generateDocument( writer, (SiteRendererSink) mojo.getSink(), context );
- writer.close();
- writer = null;
}
finally
{
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
index 2e9c133854..eab2a81966 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
@@ -20,12 +20,15 @@
*/
+import org.apache.maven.shared.utils.io.IOUtil;
+import org.apache.maven.surefire.report.ReportEntry;
+
import java.io.BufferedReader;
-import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
-import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Comparator;
@@ -35,9 +38,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import static java.util.Collections.sort;
-import org.apache.maven.shared.utils.io.IOUtil;
-import org.apache.maven.surefire.report.ReportEntry;
import static org.apache.maven.plugin.surefire.runorder.RunEntryStatistics.fromReportEntry;
import static org.apache.maven.plugin.surefire.runorder.RunEntryStatistics.fromString;
@@ -66,10 +68,7 @@ public static RunEntryStatisticsMap fromFile( File file )
try
{
reader = new FileReader( file );
- final RunEntryStatisticsMap result = fromReader( reader );
- reader.close();
- reader = null;
- return result;
+ return fromReader( reader );
}
catch ( IOException e )
{
@@ -89,50 +88,39 @@ public static RunEntryStatisticsMap fromFile( File file )
static RunEntryStatisticsMap fromReader( Reader fileReader )
throws IOException
{
- BufferedReader reader = null;
Map result = new HashMap();
- try
+ BufferedReader reader = new BufferedReader( fileReader );
+ for ( String line = reader.readLine(); line != null && !line.startsWith( "#" ); line = reader.readLine() )
{
- reader = new BufferedReader( fileReader );
- for ( String line = reader.readLine(); line != null; line = reader.readLine() )
- {
- if ( !line.startsWith( "#" ) )
- {
- RunEntryStatistics stats = fromString( line );
- result.put( stats.getTestName(), stats );
- }
- }
- reader.close();
- reader = null;
- return new RunEntryStatisticsMap( result );
- }
- finally
- {
- IOUtil.close( reader );
+ RunEntryStatistics stats = fromString( line );
+ result.put( stats.getTestName(), stats );
}
+ return new RunEntryStatisticsMap( result );
}
public void serialize( File file )
- throws IOException
+ throws FileNotFoundException
{
- BufferedWriter writer = null;
+ /**
+ * The implementation of constructor {@link PrintWriter(File)}
+ * uses {@link java.io.BufferedWriter}
+ * which is guaranteed by Java 1.5 Javadoc of the constructor:
+ * "The output will be written to the file and is buffered."
+ */
+ PrintWriter printWriter = new PrintWriter( file );
try
{
- writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ) ) );
List items = new ArrayList( runEntryStatistics.values() );
sort( items, new RunCountComparator() );
for ( RunEntryStatistics item : items )
{
- writer.append( item.toString() );
- writer.newLine();
+ printWriter.println( item.toString() );
}
-
- writer.close();
- writer = null;
+ printWriter.flush();
}
finally
{
- IOUtil.close( writer );
+ printWriter.close();
}
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index 7439ec3527..aa0daddd2c 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -19,11 +19,6 @@
* under the License.
*/
-import java.io.PrintStream;
-import java.util.Enumeration;
-import java.util.Properties;
-import static java.lang.Integer.toHexString;
-import static java.nio.charset.Charset.defaultCharset;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.ConsoleLoggerUtils;
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
@@ -33,6 +28,13 @@
import org.apache.maven.surefire.report.SafeThrowable;
import org.apache.maven.surefire.report.SimpleReportEntry;
import org.apache.maven.surefire.report.StackTraceWriter;
+
+import java.io.PrintStream;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import static java.lang.Integer.toHexString;
+import static java.nio.charset.Charset.defaultCharset;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
import static org.apache.maven.surefire.util.internal.StringUtils.escapeBytesToPrintable;
import static org.apache.maven.surefire.util.internal.StringUtils.escapeToPrintable;
@@ -209,8 +211,7 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
// We MUST NOT throw any exception from this method; otherwise we are in loop and CPU goes up:
// ForkingRunListener -> Exception -> JUnit Notifier and RunListener -> ForkingRunListener -> Exception
DumpErrorSingleton.getSingleton()
- .dumpStreamText( "Unexpected IOException with stream: " + new String( buf, off, len ) );
-
+ .dumpStreamText( "Unexpected IOException with stream: " + new String( buf, off, len ) );
}
}
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index d5f6375f98..0bd7b89b4f 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -23,8 +23,8 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
+
import static java.lang.String.format;
-import org.apache.maven.surefire.util.internal.StringUtils;
import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 6df3009e52..b76df2f0f1 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -19,6 +19,14 @@
* under the License.
*/
+import org.apache.maven.surefire.providerapi.ProviderParameters;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
+import org.apache.maven.surefire.report.LegacyPojoStackTraceWriter;
+import org.apache.maven.surefire.report.ReporterFactory;
+import org.apache.maven.surefire.report.StackTraceWriter;
+import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -30,19 +38,13 @@
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicBoolean;
+
import static java.lang.System.err;
import static java.lang.System.out;
import static java.lang.System.setErr;
import static java.lang.System.setOut;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.TimeUnit.SECONDS;
-import org.apache.maven.surefire.providerapi.ProviderParameters;
-import org.apache.maven.surefire.providerapi.SurefireProvider;
-import org.apache.maven.surefire.report.LegacyPojoStackTraceWriter;
-import org.apache.maven.surefire.report.ReporterFactory;
-import org.apache.maven.surefire.report.StackTraceWriter;
-import org.apache.maven.surefire.suite.RunResult;
-import org.apache.maven.surefire.testset.TestSetFailedException;
import static org.apache.maven.surefire.booter.CommandReader.getReader;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_BYE;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_ERROR;
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
index 8d301dca37..a80656ea44 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
@@ -24,7 +24,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
@@ -49,8 +48,6 @@ public static PropertiesWrapper loadProperties( InputStream inStream )
{
Properties p = new Properties();
p.load( inStream );
- inStream.close();
- inStream = null;
Map map = new ConcurrentHashMap( p.size() );
// @todo use .stringPropertyNames() JDK6 instead of .keySet()
for ( Map.Entry, ?> entry : p.entrySet() )
@@ -61,18 +58,7 @@ public static PropertiesWrapper loadProperties( InputStream inStream )
}
finally
{
- // @todo use try-with-resources JDK7, search in all code
- try
- {
- if ( inStream != null )
- {
- inStream.close();
- }
- }
- catch ( final IOException e1 )
- {
- // Suppressed, so that the exception thrown in the try block will be propagated.
- }
+ close( inStream ); // @todo use try-with-resources JDK7, search in all code
}
}
@@ -107,34 +93,21 @@ public static File writePropertiesFile( Properties properties, File tempDirector
public static void writePropertiesFile( File file, String name, Properties properties )
throws IOException
{
- OutputStream out = null;
+ FileOutputStream out = new FileOutputStream( file );
+
try
{
- out = new FileOutputStream( file );
+ /**
+ * See {@link Properties#store(java.io.OutputStream, String)} Javadoc - stream is flushed.
+ */
properties.store( out, name );
- out.close();
- out = null;
}
finally
{
- try
- {
- if ( out != null )
- {
- out.close();
- }
- }
- catch ( final IOException e1 )
- {
- // Suppressed.
- }
+ out.close();
}
}
- /**
- * @deprecated As of Java 7, please use the try-with-resources statement.
- */
- @Deprecated
public static void close( InputStream inputStream )
{
if ( inputStream == null )
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
index eb33e78fab..6d3d8e2766 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
@@ -28,8 +28,10 @@
import java.net.URI;
import java.nio.charset.Charset;
import java.util.List;
-import junit.framework.Assert;
import org.apache.commons.io.FileUtils;
+
+import junit.framework.Assert;
+
import static junit.framework.Assert.assertTrue;
/**
@@ -101,8 +103,6 @@ public String slurpFile()
{
sb.append( line );
}
- reader.close();
- reader = null;
return sb.toString();
}
catch ( IOException e )
diff --git a/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java b/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
index e595cd6e3a..f46e3bedb3 100644
--- a/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
+++ b/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
@@ -44,17 +44,14 @@ public void testMainClassesBeforeDependencies()
}
private Properties getProperties( String resource )
- throws IOException
+ throws IOException
{
- InputStream in = null;
+ InputStream in = getClass().getResourceAsStream( resource );
+ assertNotNull( in );
try
{
- in = getClass().getResourceAsStream( resource );
- assertNotNull( in );
Properties props = new Properties();
props.load( in );
- in.close();
- in = null;
return props;
}
catch ( IOException e )
@@ -64,16 +61,9 @@ private Properties getProperties( String resource )
}
finally
{
- try
- {
- if ( in != null )
- {
- in.close();
- }
- }
- catch ( final IOException e )
+ if ( in != null )
{
- // Suppressed.
+ in.close();
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java b/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
index c842a1dd67..0112f3143c 100644
--- a/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
@@ -33,8 +33,7 @@ public static void writeFile( String fileName, String content )
{
writer = new FileWriter( new File( new File( "target" ).getAbsoluteFile(), fileName ) );
writer.write( content );
- writer.close();
- writer = null;
+ writer.flush();
}
catch ( IOException e )
{
@@ -51,7 +50,7 @@ public static void writeFile( String fileName, String content )
}
catch ( final IOException e )
{
- // Suppressed, so that the exception thrown in the try block will be propagated.
+ // Suppressed.
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
index 30224e19af..dc651e78e8 100644
--- a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
+++ b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
@@ -60,27 +60,14 @@ public void writeFile()
final File f = new File( "target/tests-run", getClass().getName() + ".txt" );
f.getParentFile().mkdirs();
- FileWriter w = null;
+ FileWriter w = new FileWriter( f, true );
try
{
- w = new FileWriter( f, true );
w.write( name.getMethodName() );
- w.close();
- w = null;
}
finally
{
- if ( w != null )
- {
- try
- {
- w.close();
- }
- catch ( final IOException e )
- {
- // Suppressed.
- }
- }
+ w.close();
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
index 2ed21ebe5f..f924074854 100644
--- a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
+++ b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
@@ -60,28 +60,15 @@ public void writeFile()
final File f = new File( "target/tests-run", getClass().getName() + ".txt" );
f.getParentFile().mkdirs();
- FileWriter w = null;
+ FileWriter w = new FileWriter( f, true );
try
{
- w = new FileWriter( f, true );
w.write( name.getMethodName() );
- w.close();
- w = null;
}
finally
{
- if ( w != null )
- {
- try
- {
- w.close();
- }
- catch ( final IOException e )
- {
- // Suppressed.
- }
- }
+ w.close();
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
index b010d2260a..aa44b64e5d 100644
--- a/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
+++ b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
@@ -51,12 +51,11 @@ public void execute()
{
targetDir.mkdirs();
}
-
fw = new FileWriter( target );
- final String pid = ManagementFactory.getRuntimeMXBean().getName();
+ String pid = ManagementFactory.getRuntimeMXBean().getName();
fw.write( pid );
- fw.close();
- fw = null;
+ fw.flush();
+
getLog().info( "Wrote " + pid + " to " + target );
}
catch ( IOException e )
diff --git a/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
index 4405996c1a..031b1fa073 100644
--- a/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
@@ -33,8 +33,6 @@ public static void writeFile( String fileName, String content )
{
writer = new FileWriter( new File( new File( "target" ).getAbsoluteFile(), fileName ) );
writer.write( content );
- writer.close();
- writer = null;
}
catch ( IOException e )
{
@@ -51,7 +49,7 @@ public static void writeFile( String fileName, String content )
}
catch ( final IOException e )
{
- // Suppressed.
+ throw new RuntimeException( e );
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
index 4525e29160..7e2e8208c8 100644
--- a/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
@@ -16,8 +16,7 @@ public static void writeFile( String fileName, String content )
"target" ).getCanonicalFile(), fileName ), true );
writer.write( content );
- writer.close();
- writer = null;
+ writer.flush();
}
catch ( IOException exception )
{
diff --git a/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
index b0a8e92d0f..5451dbfc9b 100644
--- a/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
@@ -3,21 +3,19 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.Writer;
public class FileHelper
{
public static void writeFile( String fileName, String content )
{
- Writer writer = null;
+ FileWriter out = null;
try
{
- writer = new FileWriter( new File( new File( System.getProperty( "user.dir" ),
- "target" ).getCanonicalFile(), fileName ), true );
-
- writer.write( content );
- writer.close();
- writer = null;
+ File target = new File( System.getProperty("user.dir"), "target" ).getCanonicalFile();
+ File listenerOutput = new File( target, fileName );
+ out = new FileWriter( listenerOutput, true );
+ out.write( content );
+ out.flush();
}
catch ( IOException e )
{
@@ -25,15 +23,15 @@ public static void writeFile( String fileName, String content )
}
finally
{
- if ( writer != null )
+ if ( out != null )
{
try
{
- writer.close();
+ out.close();
}
catch ( IOException e )
{
- // Suppressed, so that the exception thrown in the try block will be propagated.
+ throw new RuntimeException( e );
}
}
}
From c12adb87547a56c54c22c86191d214dc9b79b2eb Mon Sep 17 00:00:00 2001
From: Stephen Connolly
Date: Mon, 23 Jan 2017 10:56:01 +0000
Subject: [PATCH 050/194] Revert "[SUREFIRE-1322] - Surefire and Failsafe
should dump critical errors in dump file and console"
This reverts commit 4d3673c42e2af75c22f3abbaa2a0237a5c25e0ce.
---
.../maven/surefire/booter/CommandReader.java | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
index 3f24a1b54d..3990d467ac 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
@@ -377,7 +377,7 @@ public void run()
if ( command == null )
{
String errorMessage = "[SUREFIRE] std/in stream corrupted: first sequence not recognized";
- DumpErrorSingleton.getSingleton().dumpStreamText( errorMessage );
+ DumpErrorSingleton.getSingleton().dumpText( errorMessage );
logger.error( errorMessage );
break;
}
@@ -414,27 +414,24 @@ public void run()
}
catch ( EOFException e )
{
+ DumpErrorSingleton.getSingleton().dumpException( e );
+
CommandReader.this.state.set( TERMINATED );
if ( !isTestSetFinished )
{
- String msg = "TestSet has not finished before stream error has appeared >> "
- + "initializing exit by non-null configuration: "
- + CommandReader.this.shutdown;
- DumpErrorSingleton.getSingleton().dumpStreamException( e, msg );
-
exitByConfiguration();
// does not go to finally
}
}
catch ( IOException e )
{
+ DumpErrorSingleton.getSingleton().dumpException( e );
+
CommandReader.this.state.set( TERMINATED );
// If #stop() method is called, reader thread is interrupted and cause is InterruptedException.
if ( !( e.getCause() instanceof InterruptedException ) )
{
- String msg = "[SUREFIRE] std/in stream corrupted";
- DumpErrorSingleton.getSingleton().dumpStreamException( e, msg );
- logger.error( msg, e );
+ logger.error( "[SUREFIRE] std/in stream corrupted", e );
}
}
finally
From e36fe19ebd1e4db3ced9e853b4a60489a54e569c Mon Sep 17 00:00:00 2001
From: Stephen Connolly
Date: Mon, 23 Jan 2017 10:56:20 +0000
Subject: [PATCH 051/194] Revert "[SUREFIRE-1317] - Refactoring"
This reverts commit b50ea3acf0701e4a66ad8f55930cb41dd2bfc999.
---
maven-surefire-common/pom.xml | 1 -
.../plugin/surefire/AbstractSurefireMojo.java | 1 -
.../surefire/StartupReportConfiguration.java | 7 +--
.../surefire/booterclient/ForkStarter.java | 4 +-
.../output/DeserializedStacktraceWriter.java | 2 +-
.../booterclient/output/ForkClient.java | 13 +----
.../output/LostCommandsDumpSingleton.java | 7 ---
.../output/ThreadedStreamConsumer.java | 49 +++++++++++--------
.../report/DefaultReporterFactory.java | 13 +++--
.../report/NullStatelessXmlReporter.java | 2 +-
.../surefire/report/StatelessXmlReporter.java | 10 ++--
.../surefire/report/TestSetRunListener.java | 2 +-
.../surefire/runorder/StatisticsReporter.java | 4 +-
.../report/DefaultReporterFactoryTest.java | 18 +++----
.../report/StatelessXmlReporterTest.java | 6 +--
.../maven/plugins/surefire/report/Utils.java | 1 -
.../surefire/booter/MasterProcessCommand.java | 8 +--
.../report/CategorizedReportEntry.java | 17 ++++---
.../maven/surefire/report/SafeThrowable.java | 5 --
.../surefire/util/internal/StringUtils.java | 28 ++++++++++-
20 files changed, 105 insertions(+), 93 deletions(-)
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index ae71f0d215..54825b757e 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -141,7 +141,6 @@
-
maven-dependency-plugin
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 99eca2cb11..4f7744fc1e 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
@@ -234,7 +234,6 @@ public abstract class AbstractSurefireMojo
* unless overridden.
*/
@Parameter
- // TODO use regex for fully qualified class names in 3.0 and change the filtering abilities
private List excludes;
/**
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 bf6e5ef81e..482ce00582 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
@@ -171,16 +171,11 @@ public int getRerunFailingTestsCount()
return rerunFailingTestsCount;
}
- public boolean hasRerunFailingTestsCount()
- {
- return getRerunFailingTestsCount() > 0;
- }
-
public StatelessXmlReporter instantiateStatelessXmlReporter()
{
return isDisableXmlReport()
? null
- : new StatelessXmlReporter( reportsDirectory, reportNameSuffix, trimStackTrace, hasRerunFailingTestsCount(),
+ : new StatelessXmlReporter( reportsDirectory, reportNameSuffix, trimStackTrace, rerunFailingTestsCount,
testClassMethodRunHistory, xsdSchemaLocation );
}
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 b864076437..05c4cc246a 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
@@ -189,9 +189,9 @@ public void run()
{
closeable.close();
}
- catch ( Throwable e )
+ catch ( IOException e )
{
- e.printStackTrace();
+ // ignore
}
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
index 952feb8d5a..8832a3642b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
@@ -64,6 +64,6 @@ public String writeTrimmedTraceToString()
public SafeThrowable getThrowable()
{
- return new SafeThrowable( message );
+ return new SafeThrowable( new Throwable( message ) );
}
}
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 e37e82fe56..68ce40deeb 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
@@ -25,6 +25,7 @@
import org.apache.maven.shared.utils.cli.StreamConsumer;
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
import org.apache.maven.surefire.report.ReportEntry;
+import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.RunListener;
import org.apache.maven.surefire.report.StackTraceWriter;
@@ -67,7 +68,6 @@
import static org.apache.maven.surefire.util.internal.StringUtils.unescapeBytes;
import static org.apache.maven.surefire.util.internal.StringUtils.unescapeString;
-// todo move to the same package with ForkStarter
/**
* Knows how to reconstruct *all* the state transmitted over stdout by the forked process.
*
@@ -284,25 +284,16 @@ private void processLine( String s )
}
catch ( NumberFormatException e )
{
- // native stream sent a text e.g. GC verbose
// SUREFIRE-859
LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
}
catch ( NoSuchElementException e )
{
- // native stream sent a text e.g. GC verbose
// SUREFIRE-859
LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
}
- catch ( IndexOutOfBoundsException e )
+ catch ( ReporterException e )
{
- // native stream sent a text e.g. GC verbose
- // SUREFIRE-859
- LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
- }
- catch ( RuntimeException e )
- {
- // e.g. ReporterException
LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
throw e;
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
index a8f11e48c4..fa38c053c9 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
@@ -21,15 +21,8 @@
import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
import org.apache.maven.surefire.util.internal.DumpFileUtils;
-
import java.io.File;
-/**
- * Dumps lost commands and caused exceptions in {@link ForkClient}.
- *
- * @author Tibor Digana (tibor17)
- * @since 2.19.2
- */
final class LostCommandsDumpSingleton
{
private static final LostCommandsDumpSingleton SINGLETON = new LostCommandsDumpSingleton();
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 c095199c9e..ebf3edbe00 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
@@ -20,15 +20,12 @@
*/
import org.apache.maven.shared.utils.cli.StreamConsumer;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
-import java.io.Closeable;
-import java.io.IOException;
import java.util.concurrent.BlockingQueue;
+import java.io.Closeable;
import java.util.concurrent.LinkedBlockingQueue;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThread;
-
/**
* Knows how to reconstruct *all* the state transmitted over stdout by the forked process.
*
@@ -39,21 +36,27 @@ public final class ThreadedStreamConsumer
{
private static final String POISON = "Pioson";
+ private static final int ITEM_LIMIT_BEFORE_SLEEP = 10000;
+
private final BlockingQueue items = new LinkedBlockingQueue();
private final Thread thread;
private final Pumper pumper;
- final class Pumper
+ static class Pumper
implements Runnable
{
+ private final BlockingQueue queue;
+
private final StreamConsumer target;
private volatile Throwable throwable;
- Pumper( StreamConsumer target )
+
+ Pumper( BlockingQueue queue, StreamConsumer target )
{
+ this.queue = queue;
this.target = target;
}
@@ -74,7 +77,7 @@ public void run()
{
try
{
- item = items.take();
+ item = queue.take();
target.consumeLine( item );
}
catch ( InterruptedException e )
@@ -96,8 +99,8 @@ public Throwable getThrowable()
public ThreadedStreamConsumer( StreamConsumer target )
{
- pumper = new Pumper( target );
- thread = newDaemonThread( pumper, ThreadedStreamConsumer.class.getSimpleName() );
+ pumper = new Pumper( items, target );
+ thread = DaemonThreadFactory.newDaemonThread( pumper, "ThreadedStreamConsumer" );
thread.start();
}
@@ -105,29 +108,35 @@ public ThreadedStreamConsumer( StreamConsumer target )
public void consumeLine( String s )
{
items.add( s );
+ if ( items.size() > ITEM_LIMIT_BEFORE_SLEEP )
+ {
+ try
+ {
+ Thread.sleep( 100 );
+ }
+ catch ( InterruptedException ignore )
+ {
+ }
+ }
}
- public void close() throws IOException
+
+ public void close()
{
try
{
items.add( POISON );
- if ( thread.isAlive() )
- {
- thread.join( SECONDS.toMillis( 10L ) );
- thread.interrupt();
- }
+ thread.join();
}
catch ( InterruptedException e )
{
- throw new IOException( e );
+ throw new RuntimeException( e );
}
//noinspection ThrowableResultOfMethodCallIgnored
- Throwable e = pumper.getThrowable();
- if ( e != null )
+ if ( pumper.getThrowable() != null )
{
- throw new IOException( e );
+ throw new RuntimeException( pumper.getThrowable() );
}
}
}
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 1c2c68c5e6..b4a6f30f3f 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
@@ -37,7 +37,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -219,11 +218,11 @@ public static DefaultReporterFactory defaultNoXml()
* if it only has errors or failures, then count its result based on its first run
*
* @param reportEntries the list of test run report type for a given test
- * @param hasRerunFailingTestsCount true if rerun count for failing tests is greater than zero
+ * @param rerunFailingTestsCount configured rerun count for failing tests
* @return the type of test result
*/
// Use default visibility for testing
- static TestResultType getTestResultType( List reportEntries, boolean hasRerunFailingTestsCount )
+ static TestResultType getTestResultType( List reportEntries, int rerunFailingTestsCount )
{
if ( reportEntries == null || reportEntries.isEmpty() )
{
@@ -249,7 +248,7 @@ else if ( resultType == ERROR )
if ( seenFailure || seenError )
{
- if ( seenSuccess & hasRerunFailingTestsCount )
+ if ( seenSuccess && rerunFailingTestsCount > 0 )
{
return flake;
}
@@ -311,7 +310,7 @@ void mergeTestHistoryResult()
// Update globalStatistics by iterating through mergedTestHistoryResult
int completedCount = 0, skipped = 0;
- for ( Entry> entry : mergedTestHistoryResult.entrySet() )
+ for ( Map.Entry> entry : mergedTestHistoryResult.entrySet() )
{
List testMethodStats = entry.getValue();
String testClassMethodName = entry.getKey();
@@ -323,7 +322,7 @@ void mergeTestHistoryResult()
resultTypes.add( methodStats.getResultType() );
}
- switch ( getTestResultType( resultTypes, reportConfiguration.hasRerunFailingTestsCount() ) )
+ switch ( getTestResultType( resultTypes, reportConfiguration.getRerunFailingTestsCount() ) )
{
case success:
// If there are multiple successful runs of the same test, count all of them
@@ -394,7 +393,7 @@ boolean printTestFailures( TestResultType type )
printed = true;
}
- for ( Entry> entry : testStats.entrySet() )
+ for ( Map.Entry> entry : testStats.entrySet() )
{
printed = true;
List testMethodStats = entry.getValue();
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
index e72adc7f52..5895c8ad38 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
@@ -33,7 +33,7 @@ class NullStatelessXmlReporter
private NullStatelessXmlReporter()
{
- super( null, null, false, false, null, null );
+ super( null, null, false, 0, null, null );
}
@Override
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 271d3f0dc8..8ebeb96c2c 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
@@ -92,7 +92,7 @@ public class StatelessXmlReporter
private final boolean trimStackTrace;
- private final boolean hasRerunFailingTestsCount;
+ private final int rerunFailingTestsCount;
private final String xsdSchemaLocation;
@@ -101,14 +101,14 @@ public class StatelessXmlReporter
private final Map>> testClassMethodRunHistoryMap;
public StatelessXmlReporter( File reportsDirectory, String reportNameSuffix, boolean trimStackTrace,
- boolean hasRerunFailingTestsCount,
+ int rerunFailingTestsCount,
Map>> testClassMethodRunHistoryMap,
String xsdSchemaLocation )
{
this.reportsDirectory = reportsDirectory;
this.reportNameSuffix = reportNameSuffix;
this.trimStackTrace = trimStackTrace;
- this.hasRerunFailingTestsCount = hasRerunFailingTestsCount;
+ this.rerunFailingTestsCount = rerunFailingTestsCount;
this.testClassMethodRunHistoryMap = testClassMethodRunHistoryMap;
this.xsdSchemaLocation = xsdSchemaLocation;
}
@@ -147,7 +147,7 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat
if ( !methodEntryList.isEmpty() )
{
- if ( hasRerunFailingTestsCount )
+ if ( rerunFailingTestsCount > 0 )
{
TestResultType resultType = getTestResultType( methodEntryList );
switch ( resultType )
@@ -268,7 +268,7 @@ private TestResultType getTestResultType( List methodEntryLi
testResultTypeList.add( singleRunEntry.getReportEntryType() );
}
- return DefaultReporterFactory.getTestResultType( testResultTypeList, hasRerunFailingTestsCount );
+ return DefaultReporterFactory.getTestResultType( testResultTypeList, rerunFailingTestsCount );
}
private Map> getAddMethodRunHistoryMap( String testClassName )
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
index c5a17d3e47..f0f996dd24 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
@@ -269,7 +269,7 @@ public void addTestMethodStats()
}
}
- List getTestMethodStats()
+ public List getTestMethodStats()
{
return testMethodStats;
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
index 3f78939082..5776cc9bcc 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
@@ -42,11 +42,11 @@ public StatisticsReporter( File dataFile )
this( dataFile, fromFile( dataFile ), new RunEntryStatisticsMap() );
}
- protected StatisticsReporter( File dataFile, RunEntryStatisticsMap existing, RunEntryStatisticsMap newResults )
+ protected StatisticsReporter( File dataFile, RunEntryStatisticsMap existing, RunEntryStatisticsMap newRestuls )
{
this.dataFile = dataFile;
this.existing = existing;
- this.newResults = newResults;
+ this.newResults = newRestuls;
}
public synchronized void testSetCompleted()
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 c4c2556190..fbe875de2a 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
@@ -185,41 +185,41 @@ void reset()
public void testGetTestResultType()
{
List emptyList = new ArrayList();
- assertEquals( unknown, getTestResultType( emptyList, true ) );
+ assertEquals( unknown, getTestResultType( emptyList, 1 ) );
List successList = new ArrayList();
successList.add( ReportEntryType.SUCCESS );
successList.add( ReportEntryType.SUCCESS );
- assertEquals( success, getTestResultType( successList, true ) );
+ assertEquals( success, getTestResultType( successList, 1 ) );
List failureErrorList = new ArrayList();
failureErrorList.add( ReportEntryType.FAILURE );
failureErrorList.add( ReportEntryType.ERROR );
- assertEquals( error, getTestResultType( failureErrorList, true ) );
+ assertEquals( error, getTestResultType( failureErrorList, 1 ) );
List errorFailureList = new ArrayList();
errorFailureList.add( ReportEntryType.ERROR );
errorFailureList.add( ReportEntryType.FAILURE );
- assertEquals( error, getTestResultType( errorFailureList, true ) );
+ assertEquals( error, getTestResultType( errorFailureList, 1 ) );
List flakeList = new ArrayList();
flakeList.add( ReportEntryType.SUCCESS );
flakeList.add( ReportEntryType.FAILURE );
- assertEquals( flake, getTestResultType( flakeList, true ) );
+ assertEquals( flake, getTestResultType( flakeList, 1 ) );
- assertEquals( failure, getTestResultType( flakeList, false ) );
+ assertEquals( failure, getTestResultType( flakeList, 0 ) );
flakeList = new ArrayList();
flakeList.add( ReportEntryType.ERROR );
flakeList.add( ReportEntryType.SUCCESS );
flakeList.add( ReportEntryType.FAILURE );
- assertEquals( flake, getTestResultType( flakeList, true ) );
+ assertEquals( flake, getTestResultType( flakeList, 1 ) );
- assertEquals( error, getTestResultType( flakeList, false ) );
+ assertEquals( error, getTestResultType( flakeList, 0 ) );
List skippedList = new ArrayList();
skippedList.add( ReportEntryType.SKIPPED );
- assertEquals( skipped, getTestResultType( skippedList, true ) );
+ assertEquals( skipped, getTestResultType( skippedList, 1 ) );
}
static class DummyStackTraceWriter
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 553ee40841..5b649e3a09 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
@@ -83,7 +83,7 @@ protected void tearDown()
public void testFileNameWithoutSuffix()
{
StatelessXmlReporter reporter =
- new StatelessXmlReporter( reportDir, null, false, false,
+ new StatelessXmlReporter( reportDir, null, false, 0,
new ConcurrentHashMap>>(), XSD );
reporter.cleanTestHistoryMap();
@@ -136,7 +136,7 @@ public void testAllFieldsSerialized()
ReportEntryType.ERROR, 13, stdOut, stdErr );
stats.testSucceeded( t2 );
- StatelessXmlReporter reporter = new StatelessXmlReporter( reportDir, null, false, false,
+ StatelessXmlReporter reporter = new StatelessXmlReporter( reportDir, null, false, 0,
new ConcurrentHashMap>>(), XSD );
reporter.testSetCompleted( testSetReportEntry, stats );
@@ -216,7 +216,7 @@ public void testOutputRerunFlakyFailure()
rerunStats.testSucceeded( testThreeSecondRun );
StatelessXmlReporter reporter =
- new StatelessXmlReporter( reportDir, null, false, true,
+ new StatelessXmlReporter( reportDir, null, false, 1,
new HashMap>>(), XSD );
reporter.testSetCompleted( testSetReportEntry, stats );
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
index d2cb04e5c4..8fd91bf24b 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
@@ -23,7 +23,6 @@ public final class Utils
{
private Utils()
{
- throw new IllegalStateException( "no instantiable constructor" );
}
public static String toSystemNewLine( String s )
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index 0bd7b89b4f..a75aa83890 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -19,6 +19,8 @@
* under the License.
*/
+import org.apache.maven.surefire.util.internal.StringUtils;
+
import java.io.DataInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -46,7 +48,7 @@ public enum MasterProcessCommand
/** To tell a forked process that the master process is still alive. Repeated after 10 seconds. */
NOOP( 4, Void.class );
- private static final Charset ASCII = Charset.forName( "US-ASCII" );
+ private static final Charset ASCII = Charset.forName( "ASCII" );
private final int id;
@@ -150,7 +152,7 @@ String toDataTypeAsString( byte... data )
case RUN_CLASS:
return new String( data, FORK_STREAM_CHARSET_NAME );
case SHUTDOWN:
- return new String( data, ASCII );
+ return StringUtils.decode( data, ASCII );
default:
return null;
}
@@ -168,7 +170,7 @@ byte[] fromDataType( String data )
case RUN_CLASS:
return encodeStringForForkCommunication( data );
case SHUTDOWN:
- return data.getBytes( ASCII );
+ return StringUtils.encode( data, ASCII );
default:
return new byte[0];
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
index 0cccd6e97c..77cfaf363e 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
@@ -67,7 +67,17 @@ public String getGroup()
@Override
public String getNameWithGroup()
{
- return isNameWithGroup() ? getName() + GROUP_PREFIX + getGroup() + GROUP_SUFIX : getName();
+ StringBuilder result = new StringBuilder();
+ result.append( getName() );
+
+ if ( getGroup() != null && !getName().equals( getGroup() ) )
+ {
+ result.append( GROUP_PREFIX );
+ result.append( getGroup() );
+ result.append( GROUP_SUFIX );
+ }
+
+ return result.toString();
}
public boolean equals( Object o )
@@ -97,9 +107,4 @@ public int hashCode()
result = 31 * result + ( group != null ? group.hashCode() : 0 );
return result;
}
-
- private boolean isNameWithGroup()
- {
- return getGroup() != null && !getGroup().equals( getName() );
- }
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
index b3b86f2761..60c78975aa 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
@@ -31,11 +31,6 @@ public SafeThrowable( Throwable target )
this.target = target;
}
- public SafeThrowable( String message )
- {
- this( new Throwable( message ) );
- }
-
public String getLocalizedMessage()
{
try
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index 352b5fd4f4..830cace5e8 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -57,7 +57,7 @@
*/
public final class StringUtils
{
- public static final String NL = System.getProperty( "line.separator", "\n" );
+ public static final String NL = System.getProperty( "line.separator" );
private static final byte[] HEX_CHARS = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
@@ -345,6 +345,32 @@ public static ByteBuffer unescapeBytes( String str, String charsetName )
return ByteBuffer.wrap( out, 0, outPos );
}
+ public static String decode( byte[] toDecode, Charset charset )
+ {
+ try
+ {
+ // @todo use new JDK 1.6 constructor String(byte bytes[], Charset charset)
+ return new String( toDecode, charset.name() );
+ }
+ catch ( UnsupportedEncodingException e )
+ {
+ throw new RuntimeException( "The JVM must support Charset " + charset, e );
+ }
+ }
+
+ public static byte[] encode( String toEncode, Charset charset )
+ {
+ try
+ {
+ // @todo use new JDK 1.6 method getBytes(Charset charset)
+ return toEncode.getBytes( charset.name() );
+ }
+ catch ( UnsupportedEncodingException e )
+ {
+ throw new RuntimeException( "The JVM must support Charset " + charset, e );
+ }
+ }
+
public static byte[] encodeStringForForkCommunication( String string )
{
try
From 1c9df460e2e7e7ddaee9c0fe4ca79fe895744577 Mon Sep 17 00:00:00 2001
From: Stephen Connolly
Date: Mon, 23 Jan 2017 10:56:33 +0000
Subject: [PATCH 052/194] Revert "[SUREFIRE-1324] Surefire incorrectly
suppresses exceptions when closing resources."
This reverts commit 201a3134673f3794d71262bdf1cf057bbb3d1056.
---
.../plugin/surefire/SurefireProperties.java | 30 ++++--
.../booterclient/ForkConfiguration.java | 7 +-
.../output/LostCommandsDumpSingleton.java | 62 +-----------
.../output/ThreadedStreamConsumer.java | 35 +++----
.../report/ConsoleOutputFileReporter.java | 8 +-
.../plugin/surefire/report/FileReporter.java | 12 +--
.../surefire/runorder/StatisticsReporter.java | 3 +-
.../surefire/report/FileReporterTest.java | 6 +-
.../report/SurefireReportMojoTest.java | 2 +-
surefire-api/pom.xml | 4 -
.../runorder/RunEntryStatisticsMap.java | 34 +++----
.../maven/surefire/booter/CommandReader.java | 21 ++--
.../surefire/booter/DumpErrorSingleton.java | 99 -------------------
.../surefire/booter/ForkingRunListener.java | 21 +---
.../surefire/booter/MasterProcessCommand.java | 26 ++++-
.../maven/surefire/booter/ForkedBooter.java | 25 ++++-
.../booter/SystemPropertyManager.java | 3 -
.../maven/surefire/its/fixture/TestFile.java | 18 +---
.../src/test/java/it/BasicTest.java | 30 ++----
.../src/test/java/runListener/FileHelper.java | 25 ++---
.../maven/surefire/test/FailingTest.java | 15 ++-
.../maven/surefire/test/SucceedingTest.java | 14 ++-
.../plugins/surefire/dumppid/DumpPidMojo.java | 28 ++----
.../test/java/listenReport/FileHelper.java | 28 ++----
.../java/testng/objectfactory/FileHelper.java | 27 ++---
.../testng/testrunnerfactory/FileHelper.java | 22 +----
26 files changed, 193 insertions(+), 412 deletions(-)
delete mode 100644 surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
index 53aa134fc8..3663f3978d 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
@@ -19,10 +19,6 @@
* under the License.
*/
-import org.apache.maven.surefire.booter.Classpath;
-import org.apache.maven.surefire.booter.KeyValueSource;
-import org.apache.maven.surefire.util.internal.StringUtils;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -37,8 +33,11 @@
import java.util.Properties;
import java.util.Set;
+import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.KeyValueSource;
+import org.apache.maven.surefire.util.internal.StringUtils;
+
import static java.util.Arrays.asList;
-import static org.apache.maven.shared.utils.io.IOUtil.close;
/**
* A properties implementation that preserves insertion order.
@@ -47,7 +46,6 @@ public class SurefireProperties
extends Properties
implements KeyValueSource
{
-
private static final Collection KEYS_THAT_CANNOT_BE_USED_AS_SYSTEM_PROPERTIES =
asList( "java.library.path", "file.encoding", "jdk.map.althashing.threshold", "line.separator" );
@@ -155,6 +153,7 @@ static SurefireProperties calculateEffectiveProperties( Properties systemPropert
// user specified properties for SUREFIRE-121, causing SUREFIRE-491.
// Not gonna do THAT any more... instead, we only propagate those system properties
// that have been explicitly specified by the user via -Dkey=value on the CLI
+
result.copyPropertiesFrom( userProperties );
return result;
}
@@ -225,18 +224,18 @@ public void setClasspath( String prefix, Classpath classpath )
}
}
- private static SurefireProperties loadProperties( final InputStream inStream )
+ private static SurefireProperties loadProperties( InputStream inStream )
throws IOException
{
try
{
- final Properties p = new Properties();
+ Properties p = new Properties();
p.load( inStream );
return new SurefireProperties( p );
}
finally
{
- close( inStream ); // @todo use try-with-resources JDK7, search in all code
+ close( inStream );
}
}
@@ -246,6 +245,18 @@ public static SurefireProperties loadProperties( File file )
return file == null ? new SurefireProperties() : loadProperties( new FileInputStream( file ) );
}
+ private static void close( InputStream inputStream )
+ {
+ try
+ {
+ inputStream.close();
+ }
+ catch ( IOException ex )
+ {
+ // ignore
+ }
+ }
+
public void setNullableProperty( String key, String value )
{
if ( value != null )
@@ -253,5 +264,4 @@ public void setNullableProperty( String key, String value )
super.setProperty( key, value );
}
}
-
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 6cb0fabed1..988af8f5c1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -23,7 +23,6 @@
import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
import org.apache.maven.plugin.surefire.util.Relocator;
import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.io.IOUtil;
import org.apache.maven.surefire.booter.Classpath;
import org.apache.maven.surefire.booter.ForkedBooter;
import org.apache.maven.surefire.booter.StartupConfiguration;
@@ -271,10 +270,10 @@ private File createJar( List classPath, String startClassName )
{
file.deleteOnExit();
}
- JarOutputStream jos = null;
+ FileOutputStream fos = new FileOutputStream( file );
+ JarOutputStream jos = new JarOutputStream( fos );
try
{
- jos = new JarOutputStream( new FileOutputStream( file ) );
jos.setLevel( JarOutputStream.STORED );
JarEntry je = new JarEntry( "META-INF/MANIFEST.MF" );
jos.putNextEntry( je );
@@ -301,7 +300,7 @@ private File createJar( List classPath, String startClassName )
}
finally
{
- IOUtil.close( jos );
+ jos.close();
}
return file;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
index fa38c053c9..364d8c3a00 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
@@ -1,61 +1 @@
-package org.apache.maven.plugin.surefire.booterclient.output;
-
-/*
- * 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.report.DefaultReporterFactory;
-import org.apache.maven.surefire.util.internal.DumpFileUtils;
-import java.io.File;
-
-final class LostCommandsDumpSingleton
-{
- private static final LostCommandsDumpSingleton SINGLETON = new LostCommandsDumpSingleton();
-
- private final String creationDate = DumpFileUtils.newFormattedDateFileName();
-
- private LostCommandsDumpSingleton()
- {
- }
-
- static LostCommandsDumpSingleton getSingleton()
- {
- return SINGLETON;
- }
-
- synchronized void dumpException( Throwable t, String msg, DefaultReporterFactory defaultReporterFactory )
- {
- DumpFileUtils.dumpException( t, msg == null ? "null" : msg, newDumpFile( defaultReporterFactory ) );
- }
-
- synchronized void dumpException( Throwable t, DefaultReporterFactory defaultReporterFactory )
- {
- DumpFileUtils.dumpException( t, newDumpFile( defaultReporterFactory ) );
- }
-
- synchronized void dumpText( String msg, DefaultReporterFactory defaultReporterFactory )
- {
- DumpFileUtils.dumpText( msg == null ? "null" : msg, newDumpFile( defaultReporterFactory ) );
- }
-
- private File newDumpFile( DefaultReporterFactory defaultReporterFactory )
- {
- File reportsDirectory = defaultReporterFactory.getReportsDirectory();
- return new File( reportsDirectory, creationDate + ".dumpstream" );
- }
-}
+package org.apache.maven.plugin.surefire.booterclient.output;
/*
* 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.report.DefaultReporterFactory;
import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.io.File;
/**
* Dumps lost commands and caused exceptions in {@link ForkClient}.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
final class LostCommandsDumpSingleton
{
private static final LostCommandsDumpSingleton SINGLETON = new LostCommandsDumpSingleton();
private final String creationDate = DumpFileUtils.newFormattedDateFileName();
private LostCommandsDumpSingleton()
{
}
static LostCommandsDumpSingleton getSingleton()
{
return SINGLETON;
}
synchronized void dumpException( Throwable t, String msg, DefaultReporterFactory defaultReporterFactory )
{
File reportsDirectory = defaultReporterFactory.getReportsDirectory();
File dumpFile = new File( reportsDirectory, creationDate + ".dumpstream" );
DumpFileUtils.dumpException( t, msg, dumpFile );
}
synchronized void dumpException( Throwable t, DefaultReporterFactory defaultReporterFactory )
{
dumpException( t, null, defaultReporterFactory );
}
synchronized void dumpText( String msg, DefaultReporterFactory defaultReporterFactory )
{
File reportsDirectory = defaultReporterFactory.getReportsDirectory();
File dumpFile = new File( reportsDirectory, creationDate + ".dumpstream" );
DumpFileUtils.dumpText( msg, dumpFile );
}
}
\ No newline at end of file
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 ebf3edbe00..3f1abd8f0e 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
@@ -60,35 +60,24 @@ static class Pumper
this.target = target;
}
- /**
- * Calls {@link ForkClient#consumeLine(String)} throwing {@link RuntimeException}. Even if {@link ForkClient}
- * is not fault-tolerant, this method MUST be fault-tolerant except for {@link InterruptedException}.
- * This Thread is interrupted by {@link #close() closing the consumer}.
- * If {@link org.apache.maven.plugin.surefire.report.ConsoleOutputFileReporter#writeTestOutput} throws
- * {@link java.io.IOException} this method MUST NOT interrupt reading the events from forked JVM; otherwise
- * we can simply loose events like acquire-next-test which means that {@link ForkClient} hangs on waiting
- * for old test to complete and therefore the plugin permanently in progress.
- */
- @SuppressWarnings( "checkstyle:stringliteralequalitycheck" )
public void run()
{
- String item = null;
- do
+ try
{
- try
+ String item = queue.take();
+ //noinspection StringEquality
+ while ( item != POISON )
{
- item = queue.take();
target.consumeLine( item );
+ item = queue.take();
}
- catch ( InterruptedException e )
- {
- break;
- }
- catch ( Throwable t )
- {
- throwable = t;
- }
- } while ( item != POISON );
+ }
+ catch ( Throwable t )
+ {
+ // Think about what happens if the producer overruns us and creates an OOME. Not nice.
+ // Maybe limit length of blocking queue
+ this.throwable = t;
+ }
}
public Throwable getThrowable()
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
index 914d6844a4..f9e59fe87c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
@@ -23,7 +23,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
-import org.apache.maven.shared.utils.io.IOUtil;
import org.apache.maven.surefire.report.ReportEntry;
import static org.apache.maven.plugin.surefire.report.FileReporter.getReportFile;
@@ -75,12 +74,8 @@ public void close()
}
catch ( IOException e )
{
- // do nothing
- }
- finally
- {
- fileOutputStream = null;
}
+ fileOutputStream = null;
}
}
@@ -102,7 +97,6 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
}
catch ( IOException e )
{
- IOUtil.close( fileOutputStream );
throw new RuntimeException( e );
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
index 6239f77d02..a4d8c8e064 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
@@ -23,6 +23,7 @@
import org.apache.maven.surefire.report.ReporterException;
import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@@ -59,13 +60,7 @@ private PrintWriter testSetStarting( ReportEntry report )
try
{
- /**
- * The implementation of constructor {@link PrintWriter(File)}
- * uses {@link java.io.BufferedWriter}
- * which is guaranteed by Java 1.5 Javadoc of the constructor:
- * "The output will be written to the file and is buffered."
- */
- PrintWriter writer = new PrintWriter( reportFile );
+ PrintWriter writer = new PrintWriter( new FileWriter( reportFile ) );
writer.println( "-------------------------------------------------------------------------------" );
@@ -91,9 +86,6 @@ public static File getReportFile( File reportsDirectory, String reportEntryName,
public void testSetCompleted( WrappedReportEntry report, TestSetStats testSetStats, List testResults )
{
- /**
- * Using buffered stream internally.
- */
PrintWriter writer = testSetStarting( report );
try
{
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
index 5776cc9bcc..a53db0241d 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
@@ -19,10 +19,9 @@
* under the License.
*/
-import org.apache.maven.surefire.report.ReportEntry;
-
import java.io.File;
import java.io.FileNotFoundException;
+import org.apache.maven.surefire.report.ReportEntry;
import static org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMap.fromFile;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
index 076b23c340..7c49547bee 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
@@ -19,14 +19,14 @@
* under the License.
*/
-import junit.framework.TestCase;
+import java.io.File;
+import java.util.ArrayList;
import org.apache.maven.plugin.surefire.report.FileReporter;
import org.apache.maven.plugin.surefire.report.ReportEntryType;
import org.apache.maven.plugin.surefire.report.TestSetStats;
import org.apache.maven.plugin.surefire.report.WrappedReportEntry;
-import java.io.File;
-import java.util.ArrayList;
+import junit.framework.TestCase;
public class FileReporterTest
extends TestCase
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
index 724e72d51a..f138d8a7db 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
@@ -638,7 +638,7 @@ private void renderer( SurefireReportMojo mojo, File outputHtml )
{
outputHtml.getParentFile().mkdirs();
writer = WriterFactory.newXmlWriter( outputHtml );
- // renderer doxia 1.6 already closed the writer
+
renderer.generateDocument( writer, (SiteRendererSink) mojo.getSink(), context );
}
finally
diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml
index 258397281d..a35f983668 100644
--- a/surefire-api/pom.xml
+++ b/surefire-api/pom.xml
@@ -32,10 +32,6 @@
API used in Surefire and Failsafe MOJO, Booter, Common and test framework providers.
-
- com.google.code.findbugs
- jsr305
- org.apache.maven.surefiresurefire-logger-api
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
index eab2a81966..d47e8039b8 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
@@ -20,12 +20,12 @@
*/
-import org.apache.maven.shared.utils.io.IOUtil;
import org.apache.maven.surefire.report.ReportEntry;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
@@ -64,19 +64,17 @@ public static RunEntryStatisticsMap fromFile( File file )
{
if ( file.exists() )
{
- Reader reader = null;
try
{
- reader = new FileReader( file );
- return fromReader( reader );
+ return fromReader( new FileReader( file ) );
}
- catch ( IOException e )
+ catch ( FileNotFoundException e )
{
throw new RuntimeException( e );
}
- finally
+ catch ( IOException e )
{
- IOUtil.close( reader );
+ throw new RuntimeException( e );
}
}
else
@@ -89,11 +87,16 @@ static RunEntryStatisticsMap fromReader( Reader fileReader )
throws IOException
{
Map result = new HashMap();
- BufferedReader reader = new BufferedReader( fileReader );
- for ( String line = reader.readLine(); line != null && !line.startsWith( "#" ); line = reader.readLine() )
+ BufferedReader bufferedReader = new BufferedReader( fileReader );
+ String line = bufferedReader.readLine();
+ while ( line != null )
{
- RunEntryStatistics stats = fromString( line );
- result.put( stats.getTestName(), stats );
+ if ( !line.startsWith( "#" ) )
+ {
+ final RunEntryStatistics stats = fromString( line );
+ result.put( stats.getTestName(), stats );
+ }
+ line = bufferedReader.readLine();
}
return new RunEntryStatisticsMap( result );
}
@@ -101,13 +104,8 @@ static RunEntryStatisticsMap fromReader( Reader fileReader )
public void serialize( File file )
throws FileNotFoundException
{
- /**
- * The implementation of constructor {@link PrintWriter(File)}
- * uses {@link java.io.BufferedWriter}
- * which is guaranteed by Java 1.5 Javadoc of the constructor:
- * "The output will be written to the file and is buffered."
- */
- PrintWriter printWriter = new PrintWriter( file );
+ FileOutputStream fos = new FileOutputStream( file );
+ PrintWriter printWriter = new PrintWriter( fos );
try
{
List items = new ArrayList( runEntryStatistics.values() );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
index 3990d467ac..408e4a4ca9 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
@@ -22,9 +22,11 @@
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.io.DataInputStream;
import java.io.EOFException;
+import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Iterator;
@@ -36,10 +38,10 @@
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicReference;
-import static java.lang.StrictMath.max;
import static java.lang.Thread.State.NEW;
import static java.lang.Thread.State.RUNNABLE;
import static java.lang.Thread.State.TERMINATED;
+import static java.lang.StrictMath.max;
import static org.apache.maven.surefire.booter.Command.toShutdown;
import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_NEXT_TEST;
import static org.apache.maven.surefire.booter.MasterProcessCommand.NOOP;
@@ -49,10 +51,10 @@
import static org.apache.maven.surefire.booter.MasterProcessCommand.TEST_SET_FINISHED;
import static org.apache.maven.surefire.booter.MasterProcessCommand.decode;
import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThread;
-import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
import static org.apache.maven.surefire.util.internal.StringUtils.isBlank;
import static org.apache.maven.surefire.util.internal.StringUtils.isNotBlank;
+import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
/**
* Reader of commands coming from plugin(master) process.
@@ -85,6 +87,8 @@ public final class CommandReader
private volatile ConsoleLogger logger = new NullConsoleLogger();
+ private volatile File dumpFile;
+
private CommandReader()
{
}
@@ -99,6 +103,11 @@ public static CommandReader getReader()
return reader;
}
+ public void setDumpFile( File dumpFile )
+ {
+ this.dumpFile = dumpFile;
+ }
+
public CommandReader setShutdown( Shutdown shutdown )
{
this.shutdown = shutdown;
@@ -123,7 +132,7 @@ public boolean awaitStarted()
}
catch ( InterruptedException e )
{
- DumpErrorSingleton.getSingleton().dumpException( e );
+ DumpFileUtils.dumpException( e, dumpFile );
throw new TestSetFailedException( e.getLocalizedMessage() );
}
}
@@ -377,7 +386,7 @@ public void run()
if ( command == null )
{
String errorMessage = "[SUREFIRE] std/in stream corrupted: first sequence not recognized";
- DumpErrorSingleton.getSingleton().dumpText( errorMessage );
+ DumpFileUtils.dumpText( errorMessage, dumpFile );
logger.error( errorMessage );
break;
}
@@ -414,7 +423,7 @@ public void run()
}
catch ( EOFException e )
{
- DumpErrorSingleton.getSingleton().dumpException( e );
+ DumpFileUtils.dumpException( e, dumpFile );
CommandReader.this.state.set( TERMINATED );
if ( !isTestSetFinished )
@@ -425,7 +434,7 @@ public void run()
}
catch ( IOException e )
{
- DumpErrorSingleton.getSingleton().dumpException( e );
+ DumpFileUtils.dumpException( e, dumpFile );
CommandReader.this.state.set( TERMINATED );
// If #stop() method is called, reader thread is interrupted and cause is InterruptedException.
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
deleted file mode 100644
index 5df6d59ced..0000000000
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package org.apache.maven.surefire.booter;
-
-/*
- * 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.report.ReporterConfiguration;
-import org.apache.maven.surefire.util.internal.DumpFileUtils;
-
-import java.io.File;
-
-import static org.apache.maven.surefire.util.internal.DumpFileUtils.newDumpFile;
-
-/**
- * Dumps lost commands and caused exceptions in forked JVM.
- * Fail-safe.
- *
- * @author Tibor Digana (tibor17)
- * @since 2.19.2
- */
-public final class DumpErrorSingleton
-{
- private static final String DUMP_FILE_EXT = ".dump";
- private static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
- private static final DumpErrorSingleton SINGLETON = new DumpErrorSingleton();
-
- private File dumpFile;
- private File dumpStreamFile;
-
- private DumpErrorSingleton()
- {
- }
-
- public static DumpErrorSingleton getSingleton()
- {
- return SINGLETON;
- }
-
- public synchronized void init( String dumpFileName, ReporterConfiguration configuration )
- {
- dumpFile = createDumpFile( dumpFileName, configuration );
- dumpStreamFile = createDumpStreamFile( dumpFileName, configuration );
- }
-
- public synchronized void dumpException( Throwable t, String msg )
- {
- DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dumpFile );
- }
-
- public synchronized void dumpException( Throwable t )
- {
- DumpFileUtils.dumpException( t, dumpFile );
- }
-
- public synchronized void dumpText( String msg )
- {
- DumpFileUtils.dumpText( msg == null ? "null" : msg, dumpFile );
- }
-
- public synchronized void dumpStreamException( Throwable t, String msg )
- {
- DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dumpStreamFile );
- }
-
- public synchronized void dumpStreamException( Throwable t )
- {
- DumpFileUtils.dumpException( t, dumpStreamFile );
- }
-
- public synchronized void dumpStreamText( String msg )
- {
- DumpFileUtils.dumpText( msg == null ? "null" : msg, dumpStreamFile );
- }
-
- private File createDumpFile( String dumpFileName, ReporterConfiguration configuration )
- {
- return newDumpFile( dumpFileName + DUMP_FILE_EXT, configuration );
- }
-
- private File createDumpStreamFile( String dumpFileName, ReporterConfiguration configuration )
- {
- return newDumpFile( dumpFileName + DUMPSTREAM_FILE_EXT, configuration );
- }
-}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index aa0daddd2c..282c4d43ce 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -19,6 +19,10 @@
* under the License.
*/
+import java.io.PrintStream;
+import java.util.Enumeration;
+import java.util.Properties;
+
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.ConsoleLoggerUtils;
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
@@ -29,10 +33,6 @@
import org.apache.maven.surefire.report.SimpleReportEntry;
import org.apache.maven.surefire.report.StackTraceWriter;
-import java.io.PrintStream;
-import java.util.Enumeration;
-import java.util.Properties;
-
import static java.lang.Integer.toHexString;
import static java.nio.charset.Charset.defaultCharset;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
@@ -206,13 +206,6 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
synchronized ( target ) // See notes about synchronization/thread safety in class javadoc
{
target.write( encodeBytes, 0, encodeBytes.length );
- if ( target.checkError() )
- {
- // We MUST NOT throw any exception from this method; otherwise we are in loop and CPU goes up:
- // ForkingRunListener -> Exception -> JUnit Notifier and RunListener -> ForkingRunListener -> Exception
- DumpErrorSingleton.getSingleton()
- .dumpStreamText( "Unexpected IOException with stream: " + new String( buf, off, len ) );
- }
}
}
@@ -275,12 +268,6 @@ private void encodeAndWriteToTarget( String string )
synchronized ( target ) // See notes about synchronization/thread safety in class javadoc
{
target.write( encodeBytes, 0, encodeBytes.length );
- if ( target.checkError() )
- {
- // We MUST NOT throw any exception from this method; otherwise we are in loop and CPU goes up:
- // ForkingRunListener -> Exception -> JUnit Notifier and RunListener -> ForkingRunListener -> Exception
- DumpErrorSingleton.getSingleton().dumpStreamText( "Unexpected IOException: " + string );
- }
}
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index a75aa83890..a53a046723 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -22,14 +22,15 @@
import org.apache.maven.surefire.util.internal.StringUtils;
import java.io.DataInputStream;
+import java.io.EOFException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
-import static java.lang.String.format;
-import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
+import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
+import static java.lang.String.format;
/**
* Commands which are sent from plugin to the forked jvm.
@@ -123,8 +124,14 @@ public static Command decode( DataInputStream is )
int dataLength = is.readInt();
if ( dataLength > 0 )
{
- byte[] buffer = new byte[ dataLength ];
- is.readFully( buffer );
+ byte[] buffer = new byte[dataLength];
+ int read = 0;
+ int total = 0;
+ do
+ {
+ total += read;
+ read = is.read( buffer, total, dataLength - total );
+ } while ( read > 0 );
if ( command.getDataType() == Void.class )
{
@@ -133,6 +140,17 @@ public static Command decode( DataInputStream is )
command, dataLength ) );
}
+ if ( total != dataLength )
+ {
+ if ( read == -1 )
+ {
+ throw new EOFException( "stream closed" );
+ }
+
+ throw new IOException( format( "%s read %d out of %d bytes",
+ MasterProcessCommand.class, total, dataLength ) );
+ }
+
String data = command.toDataTypeAsString( buffer );
return new Command( command, data );
}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index b76df2f0f1..29047f2892 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -54,6 +54,8 @@
import static org.apache.maven.surefire.booter.SystemPropertyManager.setSystemProperties;
import static org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg;
import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThreadFactory;
+import static org.apache.maven.surefire.util.internal.DumpFileUtils.dumpException;
+import static org.apache.maven.surefire.util.internal.DumpFileUtils.newDumpFile;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
/**
@@ -71,6 +73,8 @@ public final class ForkedBooter
private static final long DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS = 30;
private static final long PING_TIMEOUT_IN_SECONDS = 20;
private static final ScheduledExecutorService JVM_TERMINATOR = createJvmTerminator();
+ private static final String DUMP_FILE_EXT = ".dump";
+ private static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
private static volatile long systemExitTimeoutInSeconds = DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS;
@@ -85,6 +89,7 @@ public static void main( String... args )
final CommandReader reader = startupMasterProcessReader();
final ScheduledFuture> pingScheduler = listenToShutdownCommands( reader );
final PrintStream originalOut = out;
+ File dumpFile = null;
try
{
final String tmpDir = args[0];
@@ -100,7 +105,9 @@ public static void main( String... args )
}
final ProviderConfiguration providerConfiguration = booterDeserializer.deserialize();
- DumpErrorSingleton.getSingleton().init( dumpFileName, providerConfiguration.getReporterConfiguration() );
+
+ dumpFile = createDumpFile( dumpFileName, providerConfiguration );
+ reader.setDumpFile( createDumpstreamFile( dumpFileName, providerConfiguration ) );
final StartupConfiguration startupConfiguration = booterDeserializer.getProviderConfiguration();
systemExitTimeoutInSeconds =
@@ -138,7 +145,7 @@ else if ( readTestsFromInputStream )
}
catch ( InvocationTargetException t )
{
- DumpErrorSingleton.getSingleton().dumpException( t );
+ dumpException( t, dumpFile );
StackTraceWriter stackTraceWriter =
new LegacyPojoStackTraceWriter( "test subsystem", "no method", t.getTargetException() );
StringBuilder stringBuilder = new StringBuilder();
@@ -147,7 +154,7 @@ else if ( readTestsFromInputStream )
}
catch ( Throwable t )
{
- DumpErrorSingleton.getSingleton().dumpException( t );
+ dumpException( t, dumpFile );
StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter( "test subsystem", "no method", t );
StringBuilder stringBuilder = new StringBuilder();
encode( stringBuilder, stackTraceWriter, false );
@@ -161,7 +168,7 @@ else if ( readTestsFromInputStream )
}
catch ( Throwable t )
{
- DumpErrorSingleton.getSingleton().dumpException( t );
+ dumpException( t, dumpFile );
// Just throwing does getMessage() and a local trace - we want to call printStackTrace for a full trace
// noinspection UseOfSystemOutOrSystemErr
t.printStackTrace( err );
@@ -347,4 +354,14 @@ private static InputStream createSurefirePropertiesIfFileExists( String tmpDir,
File surefirePropertiesFile = new File( tmpDir, propFileName );
return surefirePropertiesFile.exists() ? new FileInputStream( surefirePropertiesFile ) : null;
}
+
+ private static File createDumpFile( String dumpFileName, ProviderConfiguration providerConfiguration )
+ {
+ return newDumpFile( dumpFileName + DUMP_FILE_EXT, providerConfiguration.getReporterConfiguration() );
+ }
+
+ private static File createDumpstreamFile( String dumpFileName, ProviderConfiguration providerConfiguration )
+ {
+ return newDumpFile( dumpFileName + DUMPSTREAM_FILE_EXT, providerConfiguration.getReporterConfiguration() );
+ }
}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
index a80656ea44..713d4fed89 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
@@ -97,9 +97,6 @@ public static void writePropertiesFile( File file, String name, Properties prope
try
{
- /**
- * See {@link Properties#store(java.io.OutputStream, String)} Javadoc - stream is flushed.
- */
properties.store( out, name );
}
finally
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
index 6d3d8e2766..61736df46e 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
@@ -94,35 +94,23 @@ public FileInputStream getFileInputStream()
public String slurpFile()
{
- BufferedReader reader = null;
try
{
StringBuilder sb = new StringBuilder();
+ BufferedReader reader;
reader = new BufferedReader( new FileReader( file ) );
for ( String line = reader.readLine(); line != null; line = reader.readLine() )
{
sb.append( line );
}
+ reader.close();
return sb.toString();
}
catch ( IOException e )
{
throw new SurefireVerifierException( e );
}
- finally
- {
- try
- {
- if ( reader != null )
- {
- reader.close();
- }
- }
- catch ( final IOException e )
- {
- // Suppressed.
- }
- }
+
}
public String readFileToString()
diff --git a/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java b/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
index f46e3bedb3..739e134c83 100644
--- a/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
+++ b/surefire-integration-tests/src/test/resources/classpath-order/src/test/java/it/BasicTest.java
@@ -19,53 +19,43 @@
* under the License.
*/
-import junit.framework.TestCase;
-
-import java.io.IOException;
import java.io.InputStream;
+import java.io.IOException;
import java.util.Properties;
+import junit.framework.TestCase;
+
public class BasicTest
- extends TestCase
+ extends TestCase
{
public void testTestClassesBeforeMainClasses()
- throws IOException
{
Properties props = getProperties( "/surefire-classpath-order.properties" );
assertEquals( "test-classes", props.getProperty( "Surefire" ) );
}
public void testMainClassesBeforeDependencies()
- throws IOException
{
Properties props = getProperties( "/surefire-report.properties" );
assertEquals( "classes", props.getProperty( "Surefire" ) );
}
- private Properties getProperties( String resource )
- throws IOException
+ private Properties getProperties(String resource)
{
InputStream in = getClass().getResourceAsStream( resource );
assertNotNull( in );
try
{
- Properties props = new Properties();
- props.load( in );
- return props;
+ Properties props = new Properties();
+ props.load( in );
+ return props;
}
- catch ( IOException e )
+ catch (IOException e)
{
- fail( e.toString() );
+ fail(e.toString());
return null;
}
- finally
- {
- if ( in != null )
- {
- in.close();
- }
- }
}
}
diff --git a/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java b/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
index 0112f3143c..85d0a5b73d 100644
--- a/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java
@@ -22,36 +22,23 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.Writer;
public class FileHelper
{
public static void writeFile( String fileName, String content )
{
- Writer writer = null;
try
{
- writer = new FileWriter( new File( new File( "target" ).getAbsoluteFile(), fileName ) );
- writer.write( content );
- writer.flush();
+ File target = new File( "target" ).getAbsoluteFile();
+ File listenerOutput = new File( target, fileName );
+ FileWriter out = new FileWriter( listenerOutput );
+ out.write( content );
+ out.flush();
+ out.close();
}
catch ( IOException e )
{
throw new RuntimeException( e );
}
- finally
- {
- try
- {
- if ( writer != null )
- {
- writer.close();
- }
- }
- catch ( final IOException e )
- {
- // Suppressed.
- }
- }
}
}
diff --git a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
index dc651e78e8..a4d0cd3f6d 100644
--- a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
+++ b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/FailingTest.java
@@ -60,14 +60,25 @@ public void writeFile()
final File f = new File( "target/tests-run", getClass().getName() + ".txt" );
f.getParentFile().mkdirs();
- FileWriter w = new FileWriter( f, true );
+ FileWriter w = null;
+
try
{
+ w = new FileWriter( f, true );
w.write( name.getMethodName() );
}
finally
{
- w.close();
+ if ( w != null )
+ {
+ try
+ {
+ w.close();
+ }
+ catch ( final IOException e )
+ {
+ }
+ }
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
index f924074854..c9167c1216 100644
--- a/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
+++ b/surefire-integration-tests/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/src/test/java/org/apache/maven/surefire/test/SucceedingTest.java
@@ -60,15 +60,25 @@ public void writeFile()
final File f = new File( "target/tests-run", getClass().getName() + ".txt" );
f.getParentFile().mkdirs();
- FileWriter w = new FileWriter( f, true );
+ FileWriter w = null;
try
{
+ w = new FileWriter( f, true );
w.write( name.getMethodName() );
}
finally
{
- w.close();
+ if ( w != null )
+ {
+ try
+ {
+ w.close();
+ }
+ catch ( final IOException e )
+ {
+ }
+ }
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
index aa44b64e5d..035976b403 100644
--- a/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
+++ b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
@@ -41,40 +41,30 @@ public class DumpPidMojo
public void execute()
throws MojoExecutionException
{
- FileWriter fw = null;
+ File target;
try
{
- File target = new File( targetDir, "maven.pid" ).getCanonicalFile();
getLog().info( "Dumping PID to " + targetDir );
-
+
if ( !targetDir.exists() )
{
targetDir.mkdirs();
}
- fw = new FileWriter( target );
+
+ target = new File( targetDir, "maven.pid" ).getCanonicalFile();
+
+ FileWriter fw = new FileWriter( target );
String pid = ManagementFactory.getRuntimeMXBean().getName();
fw.write( pid );
fw.flush();
-
+ fw.close();
+
getLog().info( "Wrote " + pid + " to " + target );
+
}
catch ( IOException e )
{
throw new MojoExecutionException( "Unable to create pid file", e );
}
- finally
- {
- try
- {
- if ( fw != null )
- {
- fw.close();
- }
- }
- catch ( final IOException e )
- {
- // Suppressed.
- }
- }
}
}
diff --git a/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
index 031b1fa073..6a6688a656 100644
--- a/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-listener-reporter/src/test/java/listenReport/FileHelper.java
@@ -22,35 +22,23 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.Writer;
public class FileHelper
{
- public static void writeFile( String fileName, String content )
+ public static void writeFile(String fileName, String content)
{
- Writer writer = null;
try
{
- writer = new FileWriter( new File( new File( "target" ).getAbsoluteFile(), fileName ) );
- writer.write( content );
+ File target = new File( "target" ).getAbsoluteFile();
+ File listenerOutput = new File( target, fileName );
+ FileWriter out = new FileWriter(listenerOutput);
+ out.write( content );
+ out.flush();
+ out.close();
}
catch ( IOException e )
{
- throw new RuntimeException( e );
- }
- finally
- {
- try
- {
- if ( writer != null )
- {
- writer.close();
- }
- }
- catch ( final IOException e )
- {
- throw new RuntimeException( e );
- }
+ throw new RuntimeException(e);
}
}
}
diff --git a/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
index 7e2e8208c8..4db30b6d02 100644
--- a/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-objectFactory/src/test/java/testng/objectfactory/FileHelper.java
@@ -3,38 +3,23 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.Writer;
public class FileHelper
{
public static void writeFile( String fileName, String content )
{
- Writer writer = null;
try
{
- writer = new FileWriter( new File( new File( System.getProperty( "user.dir" ),
- "target" ).getCanonicalFile(), fileName ), true );
-
- writer.write( content );
- writer.flush();
+ File target = new File( System.getProperty("user.dir"), "target" ).getCanonicalFile();
+ File listenerOutput = new File( target, fileName );
+ FileWriter out = new FileWriter( listenerOutput, true );
+ out.write( content );
+ out.flush();
+ out.close();
}
catch ( IOException exception )
{
throw new RuntimeException( exception );
}
- finally
- {
- try
- {
- if ( writer != null )
- {
- writer.close();
- }
- }
- catch ( final IOException e )
- {
- // Suppressed.
- }
- }
}
}
diff --git a/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java b/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
index 5451dbfc9b..4b998ed34e 100644
--- a/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
+++ b/surefire-integration-tests/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java
@@ -8,32 +8,18 @@ public class FileHelper
{
public static void writeFile( String fileName, String content )
{
- FileWriter out = null;
try
{
File target = new File( System.getProperty("user.dir"), "target" ).getCanonicalFile();
File listenerOutput = new File( target, fileName );
- out = new FileWriter( listenerOutput, true );
+ FileWriter out = new FileWriter( listenerOutput, true );
out.write( content );
out.flush();
+ out.close();
}
- catch ( IOException e )
+ catch ( IOException exception )
{
- throw new RuntimeException( e );
- }
- finally
- {
- if ( out != null )
- {
- try
- {
- out.close();
- }
- catch ( IOException e )
- {
- throw new RuntimeException( e );
- }
- }
+ throw new RuntimeException( exception );
}
}
}
From 2360dacc974c112a3ca14d7a27535c6241275357 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 13 Feb 2017 08:03:09 +0100
Subject: [PATCH 053/194] [SUREFIRE-1332] SurefireLauncher duplicates functions
and breaks build with Maven 3.5.0
---
.../maven/surefire/its/CrashDetectionIT.java | 17 +++++++++++++++--
.../apache/maven/surefire/its/ForkModeIT.java | 13 ++++++++++---
.../surefire/its/fixture/SurefireLauncher.java | 7 +------
...urefire1295AttributeJvmCrashesToTestsIT.java | 3 ++-
.../Surefire839TestWithoutCategoriesIT.java | 9 +++++++--
...urefire907PerThreadWithoutThreadCountIT.java | 8 +++++++-
...efire946KillMainProcessInReusableForkIT.java | 2 +-
7 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java
index 90c46306ec..b5489d1c72 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java
@@ -37,12 +37,25 @@ public void crashInFork()
@Test
public void crashInReusableFork()
{
- unpack( "crash-detection" ).forkOncePerThread().threadCount( 1 ).maven().withFailure().executeTest();
+ unpack( "crash-detection" )
+ .forkPerThread()
+ .reuseForks( true )
+ .threadCount( 1 )
+ .maven()
+ .withFailure()
+ .executeTest();
}
@Test
public void hardCrashInReusableFork()
{
- unpack( "crash-detection" ).forkOncePerThread().threadCount( 1 ).addGoal( "-DkillHard=true" ).maven().withFailure().executeTest();
+ unpack( "crash-detection" )
+ .forkPerThread()
+ .reuseForks( true )
+ .threadCount( 1 )
+ .addGoal( "-DkillHard=true" )
+ .maven()
+ .withFailure()
+ .executeTest();
}
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java
index 061c5a6026..0be212321c 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java
@@ -91,7 +91,11 @@ public void testForkModeNone()
@Test
public void testForkModeOncePerThreadSingleThread()
{
- String[] pids = doTest( unpack( getProject() ).setForkJvm().forkOncePerThread().threadCount( 1 ) );
+ String[] pids = doTest( unpack( getProject() )
+ .setForkJvm()
+ .forkPerThread()
+ .reuseForks( true )
+ .threadCount( 1 ) );
assertSamePids( pids );
assertEndWith( pids, "_1_1", 3 );
assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
@@ -100,8 +104,11 @@ public void testForkModeOncePerThreadSingleThread()
@Test
public void testForkModeOncePerThreadTwoThreads()
{
- String[] pids =
- doTest( unpack( getProject() ).forkOncePerThread().threadCount( 2 ).addGoal( "-DsleepLength=1200" ) );
+ String[] pids = doTest( unpack( getProject() )
+ .forkPerThread()
+ .reuseForks( true )
+ .threadCount( 2 )
+ .addGoal( "-DsleepLength=1200" ) );
assertDifferentPids( pids, 2 );
assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
index cf0d90d847..23a09b0def 100755
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
@@ -264,12 +264,7 @@ public SurefireLauncher forkPerTest()
public SurefireLauncher forkPerThread()
{
- return forkMode( "perthread" ).reuseForks( false );
- }
-
- public SurefireLauncher forkOncePerThread()
- {
- return forkPerThread().reuseForks( true );
+ return forkMode( "perthread" );
}
public SurefireLauncher threadCount( int threadCount )
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
index 94532b9c28..f7f518d655 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
@@ -70,7 +70,8 @@ public void crashInSingleUseFork() throws VerificationException
public void crashInReusableFork() throws VerificationException
{
SurefireLauncher launcher = unpack( "crash-during-test" )
- .forkOncePerThread()
+ .forkPerThread()
+ .reuseForks( true )
.threadCount( 1 );
checkCrashTypes( launcher );
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire839TestWithoutCategoriesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire839TestWithoutCategoriesIT.java
index ebb6672564..0babe664d8 100755
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire839TestWithoutCategoriesIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire839TestWithoutCategoriesIT.java
@@ -34,7 +34,12 @@ public void classWithoutCategory()
@Test
public void classWithoutCategoryForked()
{
- unpack( "junit48-categories" ).setJUnitVersion( "4.11" ).forkOncePerThread().threadCount(
- 2 ).executeTest().verifyErrorFree( 3 );
+ unpack( "junit48-categories" )
+ .setJUnitVersion( "4.11" )
+ .forkPerThread()
+ .reuseForks( true )
+ .threadCount( 2 )
+ .executeTest()
+ .verifyErrorFree( 3 );
}
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire907PerThreadWithoutThreadCountIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire907PerThreadWithoutThreadCountIT.java
index 96e913c06c..8317c52719 100755
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire907PerThreadWithoutThreadCountIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire907PerThreadWithoutThreadCountIT.java
@@ -29,7 +29,13 @@ public class Surefire907PerThreadWithoutThreadCountIT
@Test
public void categoryAB()
{
- OutputValidator validator = unpack( "fork-mode" ).forkPerThread().maven().withFailure().executeTest();
+ OutputValidator validator = unpack( "fork-mode" )
+ .forkPerThread()
+ .reuseForks( false )
+ .maven()
+ .withFailure()
+ .executeTest();
+
validator.verifyTextInLog( "Fork mode perthread requires a thread count" );
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire946KillMainProcessInReusableForkIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire946KillMainProcessInReusableForkIT.java
index bef2378fad..ea663ab911 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire946KillMainProcessInReusableForkIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire946KillMainProcessInReusableForkIT.java
@@ -66,6 +66,6 @@ private void doTest( String method )
.sysProp( "testSleepTime", String.valueOf( TEST_SLEEP_TIME ) )
.addGoal( "org.apache.maven.plugins.surefire:maven-selfdestruct-plugin:selfdestruct" )
.setForkJvm()
- .forkOncePerThread().threadCount( 1 ).maven().withFailure().executeTest();
+ .forkPerThread().threadCount( 1 ).reuseForks( true ).maven().withFailure().executeTest();
}
}
From 572954801c0d192a68b42116f28a7dd4c4c20ba6 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Mon, 13 Feb 2017 18:20:26 +0100
Subject: [PATCH 054/194] [SUREFIRE-1322] Surefire and Failsafe should dump
critical errors in dump file and console
---
.../surefire/booterclient/ForkStarter.java | 13 +-
.../booterclient/output/ForkClient.java | 18 ++-
.../output/InPluginProcessDumpSingleton.java | 65 ++++++++++
.../output/LostCommandsDumpSingleton.java | 1 -
.../output/MultipleFailureException.java | 72 +++++++++++
.../output/NativeStdErrStreamConsumer.java | 2 +-
.../output/ThreadedStreamConsumer.java | 112 +++++++++++-------
.../maven/surefire/booter/CommandReader.java | 26 ++--
.../surefire/booter/DumpErrorSingleton.java | 99 ++++++++++++++++
.../surefire/booter/ForkingRunListener.java | 13 ++
.../surefire/booter/MasterProcessCommand.java | 23 +---
.../maven/surefire/booter/ForkedBooter.java | 25 +---
...efire1295AttributeJvmCrashesToTestsIT.java | 6 +-
.../Surefire141PluggableProvidersIT.java | 75 +++++++++---
...35ForkFailWithRedirectConsoleOutputIT.java | 29 +++--
15 files changed, 439 insertions(+), 140 deletions(-)
create mode 100644 maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/InPluginProcessDumpSingleton.java
delete mode 100644 maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
create mode 100644 maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/MultipleFailureException.java
create mode 100644 surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
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 05c4cc246a..54d304a769 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
@@ -28,6 +28,7 @@
import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream;
import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStream;
import org.apache.maven.plugin.surefire.booterclient.output.ForkClient;
+import org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
import org.apache.maven.plugin.surefire.booterclient.output.NativeStdErrStreamConsumer;
import org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
@@ -158,7 +159,7 @@ public class ForkStarter
/**
* Closes stuff, with a shutdown hook to make sure things really get closed.
*/
- private static class CloseableCloser
+ private final class CloseableCloser
implements Runnable, Closeable
{
private final Queue testProvidingInputStream;
@@ -191,7 +192,15 @@ public void run()
}
catch ( IOException e )
{
- // ignore
+ // This error does not fail a test and does not necessarily mean that the forked JVM std/out stream
+ // was not closed, see ThreadedStreamConsumer. This error means that JVM wrote messages to a native
+ // stream which could not be parsed or report failed. The tests may still correctly run nevertheless
+ // this exception happened => warning on console. The user would see hint to check dump file only
+ // if tests failed, but if this does not happen then printing warning to console is the only way to
+ // inform the users.
+ String msg = "ForkStarter IOException: " + e.getLocalizedMessage();
+ log.warning( msg );
+ InPluginProcessDumpSingleton.getSingleton().dumpException( e, msg, defaultReporterFactory );
}
}
}
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 68ce40deeb..d6afcb2963 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
@@ -25,7 +25,6 @@
import org.apache.maven.shared.utils.cli.StreamConsumer;
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
import org.apache.maven.surefire.report.ReportEntry;
-import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.RunListener;
import org.apache.maven.surefire.report.StackTraceWriter;
@@ -279,22 +278,29 @@ private void processLine( String s )
.warning( createConsoleMessage( remaining ) );
break;
default:
- LostCommandsDumpSingleton.getSingleton().dumpText( s, defaultReporterFactory );
+ InPluginProcessDumpSingleton.getSingleton().dumpText( s, defaultReporterFactory );
}
}
catch ( NumberFormatException e )
{
// SUREFIRE-859
- LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
+ InPluginProcessDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
}
catch ( NoSuchElementException e )
{
// SUREFIRE-859
- LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
+ InPluginProcessDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
}
- catch ( ReporterException e )
+ catch ( IndexOutOfBoundsException e )
{
- LostCommandsDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
+ // native stream sent a text e.g. GC verbose
+ InPluginProcessDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
+ throw e;
+ }
+ catch ( RuntimeException e )
+ {
+ // e.g. ReporterException
+ InPluginProcessDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
throw e;
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/InPluginProcessDumpSingleton.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/InPluginProcessDumpSingleton.java
new file mode 100644
index 0000000000..6580c43679
--- /dev/null
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/InPluginProcessDumpSingleton.java
@@ -0,0 +1,65 @@
+package org.apache.maven.plugin.surefire.booterclient.output;
+
+/*
+ * 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.report.DefaultReporterFactory;
+import org.apache.maven.surefire.util.internal.DumpFileUtils;
+import java.io.File;
+
+/**
+ * Reports errors to dump file.
+ * Used only within java process of the plugin itself and not the forked JVM.
+ */
+public final class InPluginProcessDumpSingleton
+{
+ private static final InPluginProcessDumpSingleton SINGLETON = new InPluginProcessDumpSingleton();
+
+ private final String creationDate = DumpFileUtils.newFormattedDateFileName();
+
+ private InPluginProcessDumpSingleton()
+ {
+ }
+
+ public static InPluginProcessDumpSingleton getSingleton()
+ {
+ return SINGLETON;
+ }
+
+ public synchronized void dumpException( Throwable t, String msg, DefaultReporterFactory defaultReporterFactory )
+ {
+ DumpFileUtils.dumpException( t, msg == null ? "null" : msg, newDumpFile( defaultReporterFactory ) );
+ }
+
+ public synchronized void dumpException( Throwable t, DefaultReporterFactory defaultReporterFactory )
+ {
+ DumpFileUtils.dumpException( t, newDumpFile( defaultReporterFactory ) );
+ }
+
+ public synchronized void dumpText( String msg, DefaultReporterFactory defaultReporterFactory )
+ {
+ DumpFileUtils.dumpText( msg == null ? "null" : msg, newDumpFile( defaultReporterFactory ) );
+ }
+
+ private File newDumpFile( DefaultReporterFactory defaultReporterFactory )
+ {
+ File reportsDirectory = defaultReporterFactory.getReportsDirectory();
+ return new File( reportsDirectory, creationDate + ".dumpstream" );
+ }
+}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
deleted file mode 100644
index 364d8c3a00..0000000000
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/LostCommandsDumpSingleton.java
+++ /dev/null
@@ -1 +0,0 @@
-package org.apache.maven.plugin.surefire.booterclient.output;
/*
* 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.report.DefaultReporterFactory;
import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.io.File;
/**
* Dumps lost commands and caused exceptions in {@link ForkClient}.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
final class LostCommandsDumpSingleton
{
private static final LostCommandsDumpSingleton SINGLETON = new LostCommandsDumpSingleton();
private final String creationDate = DumpFileUtils.newFormattedDateFileName();
private LostCommandsDumpSingleton()
{
}
static LostCommandsDumpSingleton getSingleton()
{
return SINGLETON;
}
synchronized void dumpException( Throwable t, String msg, DefaultReporterFactory defaultReporterFactory )
{
File reportsDirectory = defaultReporterFactory.getReportsDirectory();
File dumpFile = new File( reportsDirectory, creationDate + ".dumpstream" );
DumpFileUtils.dumpException( t, msg, dumpFile );
}
synchronized void dumpException( Throwable t, DefaultReporterFactory defaultReporterFactory )
{
dumpException( t, null, defaultReporterFactory );
}
synchronized void dumpText( String msg, DefaultReporterFactory defaultReporterFactory )
{
File reportsDirectory = defaultReporterFactory.getReportsDirectory();
File dumpFile = new File( reportsDirectory, creationDate + ".dumpstream" );
DumpFileUtils.dumpText( msg, dumpFile );
}
}
\ No newline at end of file
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/MultipleFailureException.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/MultipleFailureException.java
new file mode 100644
index 0000000000..4149ad9c90
--- /dev/null
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/MultipleFailureException.java
@@ -0,0 +1,72 @@
+package org.apache.maven.plugin.surefire.booterclient.output;
+
+/*
+ * 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 java.io.IOException;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+final class MultipleFailureException
+ extends IOException
+{
+ private final Queue exceptions = new ConcurrentLinkedQueue();
+
+ void addException( Throwable exception )
+ {
+ exceptions.add( exception );
+ }
+
+ boolean hasNestedExceptions()
+ {
+ return !exceptions.isEmpty();
+ }
+
+ @Override
+ public String getLocalizedMessage()
+ {
+ StringBuilder messages = new StringBuilder();
+ for ( Throwable exception = exceptions.peek(); exception != null; exception = exceptions.peek() )
+ {
+ if ( messages.length() != 0 )
+ {
+ messages.append( '\n' );
+ }
+ String message = exception.getLocalizedMessage();
+ messages.append( message == null ? exception.toString() : message );
+ }
+ return messages.toString();
+ }
+
+ @Override
+ public String getMessage()
+ {
+ StringBuilder messages = new StringBuilder();
+ for ( Throwable exception = exceptions.peek(); exception != null; exception = exceptions.peek() )
+ {
+ if ( messages.length() != 0 )
+ {
+ messages.append( '\n' );
+ }
+ String message = exception.getMessage();
+ messages.append( message == null ? exception.toString() : message );
+ }
+ return messages.toString();
+ }
+}
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 c92361dcaa..48063d3cf1 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
@@ -41,6 +41,6 @@ public NativeStdErrStreamConsumer( DefaultReporterFactory defaultReporterFactory
public void consumeLine( String line )
{
- LostCommandsDumpSingleton.getSingleton().dumpText( line, defaultReporterFactory );
+ InPluginProcessDumpSingleton.getSingleton().dumpText( line, defaultReporterFactory );
}
}
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 3f1abd8f0e..71831c0917 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
@@ -22,9 +22,12 @@
import org.apache.maven.shared.utils.cli.StreamConsumer;
import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
-import java.util.concurrent.BlockingQueue;
import java.io.Closeable;
-import java.util.concurrent.LinkedBlockingQueue;
+import java.io.IOException;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+
+import static java.lang.Thread.currentThread;
/**
* Knows how to reconstruct *all* the state transmitted over stdout by the forked process.
@@ -32,100 +35,123 @@
* @author Kristian Rosenvold
*/
public final class ThreadedStreamConsumer
- implements StreamConsumer, Closeable
+ implements StreamConsumer, Closeable
{
- private static final String POISON = "Pioson";
+ private static final String END_ITEM = "";
private static final int ITEM_LIMIT_BEFORE_SLEEP = 10000;
- private final BlockingQueue items = new LinkedBlockingQueue();
+ private final BlockingQueue items = new ArrayBlockingQueue( ITEM_LIMIT_BEFORE_SLEEP );
private final Thread thread;
private final Pumper pumper;
- static class Pumper
- implements Runnable
- {
- private final BlockingQueue queue;
+ private volatile boolean closed;
+ final class Pumper
+ implements Runnable
+ {
private final StreamConsumer target;
- private volatile Throwable throwable;
-
+ private final MultipleFailureException errors = new MultipleFailureException();
- Pumper( BlockingQueue queue, StreamConsumer target )
+ Pumper( StreamConsumer target )
{
- this.queue = queue;
this.target = target;
}
+ /**
+ * Calls {@link ForkClient#consumeLine(String)} which may throw any {@link RuntimeException}.
+ * Even if {@link ForkClient} is not fault-tolerant, this method MUST be fault-tolerant and thus the
+ * try-catch block must be inside of the loop which prevents from loosing events from {@link StreamConsumer}.
+ *
+ * If {@link org.apache.maven.plugin.surefire.report.ConsoleOutputFileReporter#writeTestOutput} throws
+ * {@link java.io.IOException} and then target.consumeLine() throws any RuntimeException, this method
+ * MUST NOT skip reading the events from the forked JVM; otherwise we could simply lost events
+ * e.g. acquire-next-test which means that {@link ForkClient} could hang on waiting for old test to complete
+ * and therefore the plugin could be permanently in progress.
+ */
public void run()
{
- try
+ while ( !ThreadedStreamConsumer.this.closed )
{
- String item = queue.take();
- //noinspection StringEquality
- while ( item != POISON )
+ try
{
+ String item = ThreadedStreamConsumer.this.items.take();
+ if ( shouldStopQueueing( item ) )
+ {
+ break;
+ }
target.consumeLine( item );
- item = queue.take();
}
- }
- catch ( Throwable t )
- {
- // Think about what happens if the producer overruns us and creates an OOME. Not nice.
- // Maybe limit length of blocking queue
- this.throwable = t;
+ catch ( Throwable t )
+ {
+ errors.addException( t );
+ }
}
}
- public Throwable getThrowable()
+ boolean hasErrors()
{
- return throwable;
+ return errors.hasNestedExceptions();
+ }
+
+ void throwErrors() throws IOException
+ {
+ throw errors;
}
}
public ThreadedStreamConsumer( StreamConsumer target )
{
- pumper = new Pumper( items, target );
+ pumper = new Pumper( target );
thread = DaemonThreadFactory.newDaemonThread( pumper, "ThreadedStreamConsumer" );
thread.start();
}
- @SuppressWarnings( "checkstyle:emptyblock" )
public void consumeLine( String s )
{
- items.add( s );
- if ( items.size() > ITEM_LIMIT_BEFORE_SLEEP )
+ if ( closed && !thread.isAlive() )
{
- try
- {
- Thread.sleep( 100 );
- }
- catch ( InterruptedException ignore )
- {
- }
+ items.clear();
+ return;
}
- }
+ try
+ {
+ items.put( s );
+ }
+ catch ( InterruptedException e )
+ {
+ currentThread().interrupt();
+ throw new IllegalStateException( e );
+ }
+ }
public void close()
+ throws IOException
{
try
{
- items.add( POISON );
+ closed = true;
+ items.put( END_ITEM );
thread.join();
}
catch ( InterruptedException e )
{
- throw new RuntimeException( e );
+ currentThread().interrupt();
+ throw new IOException( e );
}
- //noinspection ThrowableResultOfMethodCallIgnored
- if ( pumper.getThrowable() != null )
+ if ( pumper.hasErrors() )
{
- throw new RuntimeException( pumper.getThrowable() );
+ pumper.throwErrors();
}
}
+
+ private boolean shouldStopQueueing( String item )
+ {
+ return closed && item == END_ITEM;
+ }
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
index 408e4a4ca9..57f1c2cbab 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
@@ -22,11 +22,9 @@
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
import org.apache.maven.surefire.testset.TestSetFailedException;
-import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.io.DataInputStream;
import java.io.EOFException;
-import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Iterator;
@@ -87,8 +85,6 @@ public final class CommandReader
private volatile ConsoleLogger logger = new NullConsoleLogger();
- private volatile File dumpFile;
-
private CommandReader()
{
}
@@ -103,11 +99,6 @@ public static CommandReader getReader()
return reader;
}
- public void setDumpFile( File dumpFile )
- {
- this.dumpFile = dumpFile;
- }
-
public CommandReader setShutdown( Shutdown shutdown )
{
this.shutdown = shutdown;
@@ -132,7 +123,7 @@ public boolean awaitStarted()
}
catch ( InterruptedException e )
{
- DumpFileUtils.dumpException( e, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpException( e );
throw new TestSetFailedException( e.getLocalizedMessage() );
}
}
@@ -386,7 +377,7 @@ public void run()
if ( command == null )
{
String errorMessage = "[SUREFIRE] std/in stream corrupted: first sequence not recognized";
- DumpFileUtils.dumpText( errorMessage, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpStreamText( errorMessage );
logger.error( errorMessage );
break;
}
@@ -423,24 +414,27 @@ public void run()
}
catch ( EOFException e )
{
- DumpFileUtils.dumpException( e, dumpFile );
-
CommandReader.this.state.set( TERMINATED );
if ( !isTestSetFinished )
{
+ String msg = "TestSet has not finished before stream error has appeared >> "
+ + "initializing exit by non-null configuration: "
+ + CommandReader.this.shutdown;
+ DumpErrorSingleton.getSingleton().dumpStreamException( e, msg );
+
exitByConfiguration();
// does not go to finally
}
}
catch ( IOException e )
{
- DumpFileUtils.dumpException( e, dumpFile );
-
CommandReader.this.state.set( TERMINATED );
// If #stop() method is called, reader thread is interrupted and cause is InterruptedException.
if ( !( e.getCause() instanceof InterruptedException ) )
{
- logger.error( "[SUREFIRE] std/in stream corrupted", e );
+ String msg = "[SUREFIRE] std/in stream corrupted";
+ DumpErrorSingleton.getSingleton().dumpStreamException( e, msg );
+ logger.error( msg, e );
}
}
finally
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
new file mode 100644
index 0000000000..5df6d59ced
--- /dev/null
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
@@ -0,0 +1,99 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * 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.report.ReporterConfiguration;
+import org.apache.maven.surefire.util.internal.DumpFileUtils;
+
+import java.io.File;
+
+import static org.apache.maven.surefire.util.internal.DumpFileUtils.newDumpFile;
+
+/**
+ * Dumps lost commands and caused exceptions in forked JVM.
+ * Fail-safe.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.19.2
+ */
+public final class DumpErrorSingleton
+{
+ private static final String DUMP_FILE_EXT = ".dump";
+ private static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
+ private static final DumpErrorSingleton SINGLETON = new DumpErrorSingleton();
+
+ private File dumpFile;
+ private File dumpStreamFile;
+
+ private DumpErrorSingleton()
+ {
+ }
+
+ public static DumpErrorSingleton getSingleton()
+ {
+ return SINGLETON;
+ }
+
+ public synchronized void init( String dumpFileName, ReporterConfiguration configuration )
+ {
+ dumpFile = createDumpFile( dumpFileName, configuration );
+ dumpStreamFile = createDumpStreamFile( dumpFileName, configuration );
+ }
+
+ public synchronized void dumpException( Throwable t, String msg )
+ {
+ DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dumpFile );
+ }
+
+ public synchronized void dumpException( Throwable t )
+ {
+ DumpFileUtils.dumpException( t, dumpFile );
+ }
+
+ public synchronized void dumpText( String msg )
+ {
+ DumpFileUtils.dumpText( msg == null ? "null" : msg, dumpFile );
+ }
+
+ public synchronized void dumpStreamException( Throwable t, String msg )
+ {
+ DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dumpStreamFile );
+ }
+
+ public synchronized void dumpStreamException( Throwable t )
+ {
+ DumpFileUtils.dumpException( t, dumpStreamFile );
+ }
+
+ public synchronized void dumpStreamText( String msg )
+ {
+ DumpFileUtils.dumpText( msg == null ? "null" : msg, dumpStreamFile );
+ }
+
+ private File createDumpFile( String dumpFileName, ReporterConfiguration configuration )
+ {
+ return newDumpFile( dumpFileName + DUMP_FILE_EXT, configuration );
+ }
+
+ private File createDumpStreamFile( String dumpFileName, ReporterConfiguration configuration )
+ {
+ return newDumpFile( dumpFileName + DUMPSTREAM_FILE_EXT, configuration );
+ }
+}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index 282c4d43ce..12165029ca 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -206,6 +206,13 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
synchronized ( target ) // See notes about synchronization/thread safety in class javadoc
{
target.write( encodeBytes, 0, encodeBytes.length );
+ if ( target.checkError() )
+ {
+ // We MUST NOT throw any exception from this method; otherwise we are in loop and CPU goes up:
+ // ForkingRunListener -> Exception -> JUnit Notifier and RunListener -> ForkingRunListener -> Exception
+ DumpErrorSingleton.getSingleton()
+ .dumpStreamText( "Unexpected IOException with stream: " + new String( buf, off, len ) );
+ }
}
}
@@ -268,6 +275,12 @@ private void encodeAndWriteToTarget( String string )
synchronized ( target ) // See notes about synchronization/thread safety in class javadoc
{
target.write( encodeBytes, 0, encodeBytes.length );
+ if ( target.checkError() )
+ {
+ // We MUST NOT throw any exception from this method; otherwise we are in loop and CPU goes up:
+ // ForkingRunListener -> Exception -> JUnit Notifier and RunListener -> ForkingRunListener -> Exception
+ DumpErrorSingleton.getSingleton().dumpStreamText( "Unexpected IOException: " + string );
+ }
}
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index a53a046723..d5e314a79d 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -22,7 +22,6 @@
import org.apache.maven.surefire.util.internal.StringUtils;
import java.io.DataInputStream;
-import java.io.EOFException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
@@ -124,33 +123,15 @@ public static Command decode( DataInputStream is )
int dataLength = is.readInt();
if ( dataLength > 0 )
{
- byte[] buffer = new byte[dataLength];
- int read = 0;
- int total = 0;
- do
- {
- total += read;
- read = is.read( buffer, total, dataLength - total );
- } while ( read > 0 );
+ byte[] buffer = new byte[ dataLength ];
+ is.readFully( buffer );
if ( command.getDataType() == Void.class )
{
- // must read entire sequence to get to the next command; cannot be above the loop
throw new IOException( format( "Command %s unexpectedly read Void data with length %d.",
command, dataLength ) );
}
- if ( total != dataLength )
- {
- if ( read == -1 )
- {
- throw new EOFException( "stream closed" );
- }
-
- throw new IOException( format( "%s read %d out of %d bytes",
- MasterProcessCommand.class, total, dataLength ) );
- }
-
String data = command.toDataTypeAsString( buffer );
return new Command( command, data );
}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 29047f2892..b76df2f0f1 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -54,8 +54,6 @@
import static org.apache.maven.surefire.booter.SystemPropertyManager.setSystemProperties;
import static org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg;
import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThreadFactory;
-import static org.apache.maven.surefire.util.internal.DumpFileUtils.dumpException;
-import static org.apache.maven.surefire.util.internal.DumpFileUtils.newDumpFile;
import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
/**
@@ -73,8 +71,6 @@ public final class ForkedBooter
private static final long DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS = 30;
private static final long PING_TIMEOUT_IN_SECONDS = 20;
private static final ScheduledExecutorService JVM_TERMINATOR = createJvmTerminator();
- private static final String DUMP_FILE_EXT = ".dump";
- private static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
private static volatile long systemExitTimeoutInSeconds = DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS;
@@ -89,7 +85,6 @@ public static void main( String... args )
final CommandReader reader = startupMasterProcessReader();
final ScheduledFuture> pingScheduler = listenToShutdownCommands( reader );
final PrintStream originalOut = out;
- File dumpFile = null;
try
{
final String tmpDir = args[0];
@@ -105,9 +100,7 @@ public static void main( String... args )
}
final ProviderConfiguration providerConfiguration = booterDeserializer.deserialize();
-
- dumpFile = createDumpFile( dumpFileName, providerConfiguration );
- reader.setDumpFile( createDumpstreamFile( dumpFileName, providerConfiguration ) );
+ DumpErrorSingleton.getSingleton().init( dumpFileName, providerConfiguration.getReporterConfiguration() );
final StartupConfiguration startupConfiguration = booterDeserializer.getProviderConfiguration();
systemExitTimeoutInSeconds =
@@ -145,7 +138,7 @@ else if ( readTestsFromInputStream )
}
catch ( InvocationTargetException t )
{
- dumpException( t, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpException( t );
StackTraceWriter stackTraceWriter =
new LegacyPojoStackTraceWriter( "test subsystem", "no method", t.getTargetException() );
StringBuilder stringBuilder = new StringBuilder();
@@ -154,7 +147,7 @@ else if ( readTestsFromInputStream )
}
catch ( Throwable t )
{
- dumpException( t, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpException( t );
StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter( "test subsystem", "no method", t );
StringBuilder stringBuilder = new StringBuilder();
encode( stringBuilder, stackTraceWriter, false );
@@ -168,7 +161,7 @@ else if ( readTestsFromInputStream )
}
catch ( Throwable t )
{
- dumpException( t, dumpFile );
+ DumpErrorSingleton.getSingleton().dumpException( t );
// Just throwing does getMessage() and a local trace - we want to call printStackTrace for a full trace
// noinspection UseOfSystemOutOrSystemErr
t.printStackTrace( err );
@@ -354,14 +347,4 @@ private static InputStream createSurefirePropertiesIfFileExists( String tmpDir,
File surefirePropertiesFile = new File( tmpDir, propFileName );
return surefirePropertiesFile.exists() ? new FileInputStream( surefirePropertiesFile ) : null;
}
-
- private static File createDumpFile( String dumpFileName, ProviderConfiguration providerConfiguration )
- {
- return newDumpFile( dumpFileName + DUMP_FILE_EXT, providerConfiguration.getReporterConfiguration() );
- }
-
- private static File createDumpstreamFile( String dumpFileName, ProviderConfiguration providerConfiguration )
- {
- return newDumpFile( dumpFileName + DUMPSTREAM_FILE_EXT, providerConfiguration.getReporterConfiguration() );
- }
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
index f7f518d655..710a23601e 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
@@ -27,10 +27,11 @@
import org.junit.Test;
import java.util.Iterator;
+import java.util.Locale;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
/**
* https://issues.apache.org/jira/browse/SUREFIRE-1295
@@ -45,7 +46,8 @@ public class Surefire1295AttributeJvmCrashesToTestsIT
@Before
public void skipWindows()
{
- assumeFalse( System.getProperty( "os.name" ).startsWith( "Windows" ) );
+ String os = System.getProperty( "os.name" ).toLowerCase( Locale.ROOT );
+ assumeTrue( os.equals( "mac os x" ) || os.equals( "linux" ) /*|| os.contains( "windows" )*/ );
}
@Test
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
index fdc10a88ec..75aa7431d8 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
@@ -22,6 +22,7 @@
import org.apache.maven.it.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.SurefireVerifierException;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -64,52 +65,96 @@ public void pluggableProviderPresent()
public void invokeRuntimeException()
throws Exception
{
- unpack( "surefire-141-pluggableproviders" )
+ final String errorText = "Let's fail with a runtimeException";
+
+ OutputValidator validator = unpack( "surefire-141-pluggableproviders" )
.sysProp( "invokeCrash", "runtimeException" )
.maven()
.withFailure()
.executeTest()
- .verifyTextInLog( "Let's fail with a runtimeException" );
+ .verifyTextInLog( errorText );
+
+ assertErrorMessage( validator, errorText );
}
@Test
public void invokeReporterException()
throws Exception
{
- unpack( "surefire-141-pluggableproviders" )
+ final String errorText = "Let's fail with a reporterexception";
+
+ OutputValidator validator = unpack( "surefire-141-pluggableproviders" )
.sysProp( "invokeCrash", "reporterException" )
.maven()
.withFailure()
.executeTest()
- .verifyTextInLog( "Let's fail with a reporterexception" );
+ .verifyTextInLog( errorText );
+
+ assertErrorMessage( validator, errorText );
}
@Test
public void constructorRuntimeException()
throws Exception
{
+ final String errorText = "Let's fail with a runtimeException";
+
OutputValidator validator = unpack( "surefire-141-pluggableproviders" )
.sysProp( "constructorCrash", "runtimeException" )
.maven()
.withFailure()
- .executeTest()
- .verifyTextInLog( "Let's fail with a runtimeException" );
+ .executeTest();
+
+ boolean verifiedInLog = verifiedErrorInLog( validator, errorText );
+ boolean verifiedInDump = verifiedErrorInDump( validator, errorText );
+ assertThat( verifiedInLog || verifiedInDump )
+ .describedAs( "'" + errorText + "' could not be verified in log.txt nor *.dump file." )
+ .isTrue();
+ }
+ private static void assertErrorMessage( OutputValidator validator, String message )
+ {
File reportDir = validator.getSurefireReportsDirectory();
String[] dumpFiles = reportDir.list( new FilenameFilter()
- {
- @Override
- public boolean accept( File dir, String name )
- {
- return name.endsWith( ".dump" );
- }
- });
+ {
+ @Override
+ public boolean accept( File dir, String name )
+ {
+ return name.endsWith( ".dump" );
+ }
+ });
assertThat( dumpFiles ).isNotEmpty();
for ( String dump : dumpFiles )
{
validator.getSurefireReportsFile( dump )
- .assertContainsText( "Let's fail with a runtimeException" );
+ .assertContainsText( message );
+ }
+ }
+
+ private static boolean verifiedErrorInLog( OutputValidator validator, String errorText )
+ {
+ try
+ {
+ validator.verifyTextInLog( errorText );
+ return true;
+ }
+ catch ( SurefireVerifierException e )
+ {
+ return false;
+ }
+ }
+
+ private static boolean verifiedErrorInDump( OutputValidator validator, String errorText )
+ {
+ try
+ {
+ assertErrorMessage( validator, errorText );
+ return true;
+ }
+ catch ( AssertionError e )
+ {
+ return false;
}
}
-}
\ No newline at end of file
+}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java
index 4117d8cc09..34504c123a 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java
@@ -41,7 +41,24 @@ public void vmStartFail()
throws Exception
{
OutputValidator outputValidator = unpack().failNever().executeTest();
+ assertJvmCrashed( outputValidator );
+ }
+
+ @Test
+ public void vmStartFailShouldFailBuildk()
+ throws Exception
+ {
+ OutputValidator outputValidator = unpack().maven().withFailure().executeTest();
+ assertJvmCrashed( outputValidator );
+ }
+
+ private SurefireLauncher unpack()
+ {
+ return unpack( "fork-fail" );
+ }
+ private static void assertJvmCrashed( OutputValidator outputValidator )
+ {
File reportDir = outputValidator.getSurefireReportsDirectory();
String[] dumpFiles = reportDir.list( new FilenameFilter()
{
@@ -60,16 +77,4 @@ public boolean accept( File dir, String name )
}
}
- @Test
- public void vmStartFailShouldFailBuildk()
- throws Exception
- {
- unpack().maven().withFailure().executeTest();
- }
-
- public SurefireLauncher unpack()
- {
- return unpack( "fork-fail" );
- }
-
}
From 179abbf026902e44b1d95f7ef41b69bdb24434df Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Tue, 14 Feb 2017 01:26:24 +0100
Subject: [PATCH 055/194] [SUREFIRE-1333] Process pending events from forked
process after exited and then finish forked Thread.
---
.../output/ThreadedStreamConsumer.java | 30 ++++++++++++++-----
1 file changed, 23 insertions(+), 7 deletions(-)
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 71831c0917..c7d39aefcd 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
@@ -39,7 +39,9 @@ public final class ThreadedStreamConsumer
{
private static final String END_ITEM = "";
- private static final int ITEM_LIMIT_BEFORE_SLEEP = 10000;
+ private static final int ITEM_LIMIT_BEFORE_SLEEP = 10 * 1000;
+
+ private static final long CLOSE_TIMEOUT_MILLIS = 5 * 60 * 1000L;
private final BlockingQueue items = new ArrayBlockingQueue( ITEM_LIMIT_BEFORE_SLEEP );
@@ -47,7 +49,7 @@ public final class ThreadedStreamConsumer
private final Pumper pumper;
- private volatile boolean closed;
+ private volatile boolean stop;
final class Pumper
implements Runnable
@@ -74,7 +76,7 @@ final class Pumper
*/
public void run()
{
- while ( !ThreadedStreamConsumer.this.closed )
+ while ( !ThreadedStreamConsumer.this.stop )
{
try
{
@@ -112,7 +114,7 @@ public ThreadedStreamConsumer( StreamConsumer target )
public void consumeLine( String s )
{
- if ( closed && !thread.isAlive() )
+ if ( stop && !thread.isAlive() )
{
items.clear();
return;
@@ -132,17 +134,25 @@ public void consumeLine( String s )
public void close()
throws IOException
{
+ if ( stop )
+ {
+ return;
+ }
+
try
{
- closed = true;
items.put( END_ITEM );
- thread.join();
+ thread.join( CLOSE_TIMEOUT_MILLIS );
}
catch ( InterruptedException e )
{
currentThread().interrupt();
throw new IOException( e );
}
+ finally
+ {
+ stop = true;
+ }
if ( pumper.hasErrors() )
{
@@ -150,8 +160,14 @@ public void close()
}
}
+ /**
+ * Compared item with {@link #END_ITEM} by identity.
+ *
+ * @param item element from items
+ * @return true if tail of the queue
+ */
private boolean shouldStopQueueing( String item )
{
- return closed && item == END_ITEM;
+ return item == END_ITEM;
}
}
From 332b19fa287708906a3e85e7935855039329cf60 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Thu, 16 Feb 2017 18:40:45 +0100
Subject: [PATCH 056/194] SUREFIRE_SYSPROP_DUPLICATES
---
surefire-integration-tests/pom.xml | 2 -
.../its/CheckTestNgBeforeMethodFailureIT.java | 8 +-
.../its/CheckTestNgBeforeMethodIT.java | 6 +-
.../its/CheckTestNgExecuteErrorIT.java | 2 +
.../its/CheckTestNgGroupThreadParallelIT.java | 6 +-
.../its/CheckTestNgListenerReporterIT.java | 41 +++--
.../its/CheckTestNgPathWithSpacesIT.java | 6 +-
.../surefire/its/CheckTestNgReportTestIT.java | 12 +-
.../surefire/its/CheckTestNgSuiteXmlIT.java | 4 +-
.../its/CheckTestNgSuiteXmlSingleIT.java | 7 +-
.../surefire/its/CheckTestNgVersionsIT.java | 55 +++++--
.../surefire/its/TestMethodPatternIT.java | 37 +++--
.../its/TestNgSuccessPercentageIT.java | 6 +-
.../surefire/its/TestSingleMethodIT.java | 35 ++--
.../maven/surefire/its/TwoTestCasesIT.java | 22 ++-
.../surefire/its/fixture/MavenLauncher.java | 47 +++++-
.../its/fixture/MavenLauncherTest.java | 47 ++++++
.../its/fixture/SurefireLauncher.java | 52 +-----
...re1135ImproveIgnoreMessageForTestNGIT.java | 153 +++++++++++++++++-
.../Surefire376TestNgAfterSuiteFailureIT.java | 9 +-
.../Surefire377TestNgAndJUnitTogetherIT.java | 12 +-
.../pom.xml | 83 +++++++++-
.../testng-afterSuiteFailure/pom.xml | 5 -
.../resources/testng-beforeMethod/pom.xml | 5 -
.../testng-beforeMethodFailure/pom.xml | 5 -
.../resources/testng-execute-error/pom.xml | 5 -
.../testng-group-thread-parallel/pom.xml | 5 -
.../resources/testng-junit-together/pom.xml | 5 -
.../testng-listener-reporter/pom.xml | 5 -
.../testng-method-pattern-after/pom.xml | 6 -
.../testng-method-pattern-before/pom.xml | 6 -
.../resources/testng-method-pattern/pom.xml | 6 -
.../resources/testng-path with spaces/pom.xml | 5 -
.../src/test/resources/testng-simple/pom.xml | 1 -
.../resources/testng-single-method/pom.xml | 6 -
.../testng-succes-percentage/pom.xml | 5 -
.../test/resources/testng-suite-xml/pom.xml | 5 -
.../resources/testng-twoTestCaseSuite/pom.xml | 5 -
38 files changed, 526 insertions(+), 206 deletions(-)
create mode 100644 surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncherTest.java
diff --git a/surefire-integration-tests/pom.xml b/surefire-integration-tests/pom.xml
index beab2be96b..d55d14b9b9 100644
--- a/surefire-integration-tests/pom.xml
+++ b/surefire-integration-tests/pom.xml
@@ -35,7 +35,6 @@
UTF-8false
- 5.75false
@@ -105,7 +104,6 @@
${project.version}
- ${testng.version}${maven.home}${project.basedir}/../surefire-setup-integration-tests/target/private/it-settings.xml
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java
index 9e9d688695..440955cc74 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java
@@ -36,6 +36,12 @@ public class CheckTestNgBeforeMethodFailureIT
public void TestNgBeforeMethodFailure()
throws Exception
{
- unpack( "/testng-beforeMethodFailure" ).maven().withFailure().executeTest().assertTestSuiteResults( 2, 0, 1, 1 );
+ unpack( "/testng-beforeMethodFailure" )
+ .maven()
+ .sysProp( "testNgVersion", "5.7" )
+ .sysProp( "testNgClassifier", "jdk15" )
+ .withFailure()
+ .executeTest()
+ .assertTestSuiteResults( 2, 0, 1, 1 );
}
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java
index ab252795bc..d96fefc6fd 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java
@@ -35,6 +35,10 @@ public class CheckTestNgBeforeMethodIT
public void TestNgBeforeMethod()
throws Exception
{
- unpack( "/testng-beforeMethod" ).executeTest().verifyErrorFree( 1 );
+ unpack( "/testng-beforeMethod" )
+ .sysProp( "testNgVersion", "5.7" )
+ .sysProp( "testNgClassifier", "jdk15" )
+ .executeTest()
+ .verifyErrorFree( 1 );
}
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java
index 2d03900507..24ee3e638c 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java
@@ -44,6 +44,8 @@ public void executionError()
{
OutputValidator outputValidator = unpack( "/testng-execute-error" )
.maven()
+ .sysProp( "testNgVersion", "5.7" )
+ .sysProp( "testNgClassifier", "jdk15" )
.showErrorStackTraces()
.withFailure()
.executeTest();
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java
index 36ef57ea83..f56e2e4d46 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java
@@ -34,6 +34,10 @@ public class CheckTestNgGroupThreadParallelIT
@Test
public void TestNgGroupThreadParallel()
{
- unpack( "testng-group-thread-parallel" ).executeTest().verifyErrorFree( 3 );
+ unpack( "testng-group-thread-parallel" )
+ .sysProp( "testNgVersion", "5.7" )
+ .sysProp( "testNgClassifier", "jdk15" )
+ .executeTest()
+ .verifyErrorFree( 3 );
}
}
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
index e028215bea..9c223ea983 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
@@ -21,6 +21,7 @@
import org.apache.commons.lang3.JavaVersion;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -48,32 +49,32 @@ public class CheckTestNgListenerReporterIT
public static Collection
+
maven-dependency-plugin
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 4f7744fc1e..8a9780c77a 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
@@ -234,6 +234,7 @@ public abstract class AbstractSurefireMojo
* unless overridden.
*/
@Parameter
+ // TODO use regex for fully qualified class names in 3.0 and change the filtering abilities
private List excludes;
/**
@@ -2173,7 +2174,7 @@ private Classpath generateTestClasspath()
@SuppressWarnings( "unchecked" ) Set classpathArtifacts = getProject().getArtifacts();
- if ( getClasspathDependencyScopeExclude() != null && !getClasspathDependencyScopeExclude().equals( "" ) )
+ if ( getClasspathDependencyScopeExclude() != null && !getClasspathDependencyScopeExclude().isEmpty() )
{
ArtifactFilter dependencyFilter = new ScopeArtifactFilter( getClasspathDependencyScopeExclude() );
classpathArtifacts = this.filterArtifacts( classpathArtifacts, dependencyFilter );
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 52bc928c73..7f2c536aba 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -21,6 +21,7 @@
import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.util.ImmutableMap;
import org.apache.maven.plugin.surefire.util.Relocator;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.surefire.booter.Classpath;
@@ -31,7 +32,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.util.Enumeration;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -64,7 +65,7 @@ public class ForkConfiguration
private final String jvmExecutable;
- private Properties modelProperties;
+ private final Properties modelProperties;
private final String argLine;
@@ -91,7 +92,7 @@ public ForkConfiguration( Classpath bootClasspathConfiguration, File tmpDir, Str
this.workingDirectory = workingDirectory;
this.modelProperties = modelProperties;
this.argLine = argLine;
- this.environmentVariables = environmentVariables;
+ this.environmentVariables = toImmutable( environmentVariables );
this.debug = debugEnabled;
this.forkCount = forkCount;
this.reuseForks = reuseForks;
@@ -158,16 +159,13 @@ OutputStreamFlushableCommandline createCommandLine( List classPath, bool
threadNumber ) );
}
- if ( environmentVariables != null )
+ for ( Map.Entry entry : environmentVariables.entrySet() )
{
- for ( Map.Entry entry : environmentVariables.entrySet() )
- {
- String value = entry.getValue();
- cli.addEnvironment( entry.getKey(), value == null ? "" : value );
- }
+ String value = entry.getValue();
+ cli.addEnvironment( entry.getKey(), value == null ? "" : value );
}
- if ( getDebugLine() != null && !"".equals( getDebugLine() ) )
+ if ( getDebugLine() != null && !getDebugLine().isEmpty() )
{
cli.createArg().setLine( getDebugLine() );
}
@@ -240,9 +238,8 @@ private String replacePropertyExpressions( String argLine )
return null;
}
- for ( Enumeration> e = modelProperties.propertyNames(); e.hasMoreElements(); )
+ for ( final String key : modelProperties.stringPropertyNames() )
{
- String key = e.nextElement().toString();
String field = "@{" + key + "}";
if ( argLine.contains( field ) )
{
@@ -314,11 +311,6 @@ public boolean isDebug()
return debug;
}
- public String stripNewLines( String argline )
- {
- return argline.replace( "\n", " " ).replace( "\r", " " );
- }
-
public String getDebugLine()
{
return debugLine;
@@ -334,9 +326,26 @@ public int getForkCount()
return forkCount;
}
-
public boolean isReuseForks()
{
return reuseForks;
}
+
+ private static String stripNewLines( String argLine )
+ {
+ return argLine.replace( "\n", " " ).replace( "\r", " " );
+ }
+
+ /**
+ * Immutable map.
+ *
+ * @param map immutable map copies elements from map
+ * @param key type
+ * @param value type
+ * @return never returns null
+ */
+ private static Map toImmutable( Map map )
+ {
+ return map == null ? Collections.emptyMap() : new ImmutableMap( map );
+ }
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
index 8832a3642b..952feb8d5a 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
@@ -64,6 +64,6 @@ public String writeTrimmedTraceToString()
public SafeThrowable getThrowable()
{
- return new SafeThrowable( new Throwable( message ) );
+ return new SafeThrowable( message );
}
}
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 faace0f99a..32fcea4c2b 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
@@ -67,6 +67,8 @@
import static org.apache.maven.surefire.util.internal.StringUtils.unescapeBytes;
import static org.apache.maven.surefire.util.internal.StringUtils.unescapeString;
+// todo move to the same package with ForkStarter
+
/**
* Knows how to reconstruct *all* the state transmitted over stdout by the forked process.
*
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 8ebeb96c2c..397c4c165a 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
@@ -36,7 +36,6 @@
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -469,12 +468,8 @@ private static void showProperties( XMLWriter xmlWriter )
if ( systemProperties != null )
{
- Enumeration> propertyKeys = systemProperties.propertyNames();
-
- while ( propertyKeys.hasMoreElements() )
+ for ( final String key : systemProperties.stringPropertyNames() )
{
- String key = (String) propertyKeys.nextElement();
-
String value = systemProperties.getProperty( key );
if ( value == null )
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java
new file mode 100644
index 0000000000..576194dfcf
--- /dev/null
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java
@@ -0,0 +1,133 @@
+package org.apache.maven.plugin.surefire.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 java.util.AbstractMap;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Copies input map in {@link #ImmutableMap(Map) constructor}, and Entries are linked and thread-safe.
+ * The map is immutable.
+ *
+ * @param key
+ * @param value
+ * @since 2.20
+ */
+public final class ImmutableMap
+ extends AbstractMap
+{
+ private final Node first;
+
+ public ImmutableMap( Map map )
+ {
+ Node first = null;
+ Node previous = null;
+ for ( Entry e : map.entrySet() )
+ {
+ Node node = new Node( e.getKey(), e.getValue() );
+ if ( first == null )
+ {
+ first = node;
+ }
+ else
+ {
+ previous.next = node;
+ }
+ previous = node;
+ }
+ this.first = first;
+ }
+
+ @Override
+ public Set> entrySet()
+ {
+ Set> entries = new LinkedHashSet>();
+ Node node = first;
+ while ( node != null )
+ {
+ entries.add( node );
+ node = node.next;
+ }
+ return Collections.>unmodifiableSet( entries );
+ }
+
+ static final class Node
+ implements Entry
+ {
+ final K key;
+ final V value;
+ volatile Node next;
+
+ Node( K key, V value )
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ @Override
+ public K getKey()
+ {
+ return key;
+ }
+
+ @Override
+ public V getValue()
+ {
+ return value;
+ }
+
+ @Override
+ public V setValue( V value )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+
+ if ( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ Node, ?> node = (Node, ?>) o;
+
+ return getKey() != null ? getKey().equals( node.getKey() ) : node.getKey() == null
+ && getValue() != null ? getValue().equals( node.getValue() ) : node.getValue() == null;
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = getKey() != null ? getKey().hashCode() : 0;
+ result = 31 * result + ( getValue() != null ? getValue().hashCode() : 0 );
+ return result;
+ }
+ }
+}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
index 89117af299..2237698667 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
@@ -30,11 +30,10 @@
*/
public class Relocator
{
- @Nullable
- private final String relocation;
-
private static final String RELOCATION_BASE = "org.apache.maven.surefire.";
+ @Nullable
+ private final String relocation;
public Relocator( @Nullable String relocation )
{
@@ -61,7 +60,7 @@ public Relocator()
{
return className;
}
- String rest = className.substring( "org.apache.maven.surefire.".length() );
+ String rest = className.substring( RELOCATION_BASE.length() );
final String s = RELOCATION_BASE + getRelocation() + ".";
return s + rest;
}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java
new file mode 100644
index 0000000000..8fcf2bb9ca
--- /dev/null
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java
@@ -0,0 +1,86 @@
+package org.apache.maven.plugin.surefire.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.plugin.surefire.util.ImmutableMap.Node;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * @since 2.20
+ */
+public class ImmutableMapTest
+{
+ private ImmutableMap map;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ Map backingMap = new HashMap();
+ backingMap.put( "a", "1" );
+ backingMap.put( "x", null );
+ backingMap.put( "b", "2" );
+ backingMap.put( "c", "3" );
+ backingMap.put( "", "" );
+ backingMap.put( null, "1" );
+ map = new ImmutableMap( backingMap );
+ }
+
+ @Test
+ public void testEntrySet() throws Exception
+ {
+ Set> entries = map.entrySet();
+ assertThat( entries, hasSize( 6 ) );
+ assertThat( entries, hasItem( new Node( "a", "1" ) ) );
+ assertThat( entries, hasItem( new Node( "x", null ) ) );
+ assertThat( entries, hasItem( new Node( "b", "2" ) ) );
+ assertThat( entries, hasItem( new Node( "c", "3" ) ) );
+ assertThat( entries, hasItem( new Node( "", "" ) ) );
+ assertThat( entries, hasItem( new Node( null, "1" ) ) );
+ }
+
+ @Test
+ public void testGetter()
+ {
+ assertThat( map.size(), is( 6 ) );
+ assertThat( map.get( "a" ), is( "1" ) );
+ assertThat( map.get( "x" ), is( (String) null ) );
+ assertThat( map.get( "b" ), is( "2" ) );
+ assertThat( map.get( "c" ), is( "3" ) );
+ assertThat( map.get( "" ), is( "" ) );
+ assertThat( map.get( null ), is( "1" ) );
+ }
+
+ @Test( expected = UnsupportedOperationException.class )
+ public void shouldNotModifyEntries()
+ {
+ map.entrySet().clear();
+ }
+}
\ No newline at end of file
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 d03f1b9703..4309ad3e79 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
@@ -35,6 +35,7 @@
import org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMapTest;
import org.apache.maven.plugin.surefire.util.DependenciesScannerTest;
import org.apache.maven.plugin.surefire.util.DirectoryScannerTest;
+import org.apache.maven.plugin.surefire.util.ImmutableMapTest;
import org.apache.maven.plugin.surefire.util.SpecificFileFilterTest;
import org.apache.maven.surefire.report.ConsoleOutputFileReporterTest;
import org.apache.maven.surefire.report.FileReporterTest;
@@ -70,7 +71,8 @@
TestProvidingInputStreamTest.class,
TestLessInputStreamBuilderTest.class,
SPITest.class,
- SurefireReflectorTest.class
+ SurefireReflectorTest.class,
+ ImmutableMapTest.class
} )
@RunWith( Suite.class )
public class JUnit4SuiteTest
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
index 8fd91bf24b..d2cb04e5c4 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Utils.java
@@ -23,6 +23,7 @@ public final class Utils
{
private Utils()
{
+ throw new IllegalStateException( "no instantiable constructor" );
}
public static String toSystemNewLine( String s )
diff --git a/pom.xml b/pom.xml
index 1a9ba58671..02f9b80174 100644
--- a/pom.xml
+++ b/pom.xml
@@ -226,6 +226,12 @@
org.mockitomockito-core1.10.19
+
+
+ org.hamcrest
+ hamcrest-core
+
+ junit
@@ -255,6 +261,12 @@
junitjunittest
+
+
+ org.hamcrest
+ hamcrest-core
+
+ org.hamcrest
diff --git a/surefire-api/src/main/appended-resources/META-INF/NOTICE b/surefire-api/src/main/appended-resources/META-INF/NOTICE
deleted file mode 100644
index 9d9184d276..0000000000
--- a/surefire-api/src/main/appended-resources/META-INF/NOTICE
+++ /dev/null
@@ -1,3 +0,0 @@
-
-This product includes software developed by the Spring Framework
-Project (http://www.springframework.org).
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index 7856dacb91..6c0842aaee 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -20,7 +20,6 @@
*/
import java.io.PrintStream;
-import java.util.Enumeration;
import java.util.Properties;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
@@ -183,9 +182,8 @@ void sendProps()
if ( systemProperties != null )
{
- for ( Enumeration> propertyKeys = systemProperties.propertyNames(); propertyKeys.hasMoreElements(); )
+ for ( final String key : systemProperties.stringPropertyNames() )
{
- String key = (String) propertyKeys.nextElement();
String value = systemProperties.getProperty( key );
encodeAndWriteToTarget( toPropertyString( key, value == null ? "null" : value ) );
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index 229c8afa61..f985d26d78 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -19,8 +19,6 @@
* under the License.
*/
-import org.apache.maven.surefire.util.internal.StringUtils;
-
import java.io.DataInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -49,7 +47,7 @@ public enum MasterProcessCommand
NOOP( 4, Void.class ),
BYE_ACK( 5, Void.class );
- private static final Charset ASCII = Charset.forName( "ASCII" );
+ private static final Charset ASCII = Charset.forName( "US-ASCII" );
private final int id;
@@ -152,7 +150,7 @@ String toDataTypeAsString( byte... data )
case RUN_CLASS:
return new String( data, FORK_STREAM_CHARSET_NAME );
case SHUTDOWN:
- return StringUtils.decode( data, ASCII );
+ return new String( data, ASCII );
default:
return null;
}
@@ -170,7 +168,7 @@ byte[] fromDataType( String data )
case RUN_CLASS:
return encodeStringForForkCommunication( data );
case SHUTDOWN:
- return StringUtils.encode( data, ASCII );
+ return data.getBytes( ASCII );
default:
return new byte[0];
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
index 77cfaf363e..0cccd6e97c 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
@@ -67,17 +67,7 @@ public String getGroup()
@Override
public String getNameWithGroup()
{
- StringBuilder result = new StringBuilder();
- result.append( getName() );
-
- if ( getGroup() != null && !getName().equals( getGroup() ) )
- {
- result.append( GROUP_PREFIX );
- result.append( getGroup() );
- result.append( GROUP_SUFIX );
- }
-
- return result.toString();
+ return isNameWithGroup() ? getName() + GROUP_PREFIX + getGroup() + GROUP_SUFIX : getName();
}
public boolean equals( Object o )
@@ -107,4 +97,9 @@ public int hashCode()
result = 31 * result + ( group != null ? group.hashCode() : 0 );
return result;
}
+
+ private boolean isNameWithGroup()
+ {
+ return getGroup() != null && !getGroup().equals( getName() );
+ }
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java
index 6ff45dee82..d1e1890ac0 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java
@@ -69,7 +69,7 @@ public String writeTraceToString()
{
// SUREFIRE-986
String exc = t.getClass().getName() + ": ";
- if ( builder.toString().startsWith( exc ) )
+ if ( StringUtils.startsWith( builder, exc ) )
{
builder.insert( exc.length(), '\n' );
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
index 60c78975aa..b3b86f2761 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/SafeThrowable.java
@@ -31,6 +31,11 @@ public SafeThrowable( Throwable target )
this.target = target;
}
+ public SafeThrowable( String message )
+ {
+ this( new Throwable( message ) );
+ }
+
public String getLocalizedMessage()
{
try
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index 830cace5e8..d1838b2966 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -345,41 +345,40 @@ public static ByteBuffer unescapeBytes( String str, String charsetName )
return ByteBuffer.wrap( out, 0, outPos );
}
- public static String decode( byte[] toDecode, Charset charset )
- {
- try
- {
- // @todo use new JDK 1.6 constructor String(byte bytes[], Charset charset)
- return new String( toDecode, charset.name() );
- }
- catch ( UnsupportedEncodingException e )
- {
- throw new RuntimeException( "The JVM must support Charset " + charset, e );
- }
- }
-
- public static byte[] encode( String toEncode, Charset charset )
+ public static byte[] encodeStringForForkCommunication( String string )
{
try
{
- // @todo use new JDK 1.6 method getBytes(Charset charset)
- return toEncode.getBytes( charset.name() );
+ return string.getBytes( FORK_STREAM_CHARSET_NAME );
}
catch ( UnsupportedEncodingException e )
{
- throw new RuntimeException( "The JVM must support Charset " + charset, e );
+ throw new RuntimeException( "The JVM must support Charset " + FORK_STREAM_CHARSET_NAME, e );
}
}
- public static byte[] encodeStringForForkCommunication( String string )
+ /**
+ *
+ * @param buffer Examined StringBuffer
+ * @param pattern a pattern which should start in buffer
+ * @return true if buffer's literal starts with given pattern
+ */
+ public static boolean startsWith( StringBuffer buffer, String pattern )
{
- try
+ if ( buffer.length() < pattern.length() )
{
- return string.getBytes( FORK_STREAM_CHARSET_NAME );
+ return false;
}
- catch ( UnsupportedEncodingException e )
+ else
{
- throw new RuntimeException( "The JVM must support Charset " + FORK_STREAM_CHARSET_NAME, e );
+ for ( int i = 0, len = pattern.length(); i < len; i++ )
+ {
+ if ( buffer.charAt( i ) != pattern.charAt( i ) )
+ {
+ return false;
+ }
+ }
+ return true;
}
}
}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 5401abfef3..4589088c0d 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -239,6 +239,7 @@ public void run()
private static void encodeAndWriteToOutput( String string, PrintStream out )
{
byte[] encodeBytes = encodeStringForForkCommunication( string );
+ //noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized ( out )
{
out.write( encodeBytes, 0, encodeBytes.length );
@@ -352,7 +353,7 @@ private static RunResult invokeProviderInSameClassLoader( Object testSet, Object
{
final PrintStream orgSystemOut = out;
final PrintStream orgSystemErr = err;
- // Note that System.out/System.err are also read in the "ReporterConfiguration" instatiation
+ // Note that System.out/System.err are also read in the "ReporterConfiguration" instantiation
// in createProvider below. These are the same values as here.
try
diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
index f8e4511473..fdbc1be204 100644
--- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
+++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
@@ -20,6 +20,8 @@
*/
+import org.apache.maven.surefire.util.internal.StringUtils;
+
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -64,7 +66,7 @@ public String writeTraceToString()
{
// SUREFIRE-986
String exc = t.getClass().getName() + ": ";
- if ( builder.toString().startsWith( exc ) )
+ if ( StringUtils.startsWith( builder, exc ) )
{
builder.insert( exc.length(), '\n' );
}
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
index e89d061cc0..a471f0d4f7 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
@@ -112,7 +112,7 @@ private void configureInstance( Object testngInstance, Map optio
static List loadListenerClasses( String listenerClasses )
throws TestSetFailedException
{
- if ( listenerClasses == null || "".equals( listenerClasses.trim() ) )
+ if ( listenerClasses == null || listenerClasses.trim().isEmpty() )
{
return new ArrayList();
}
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
index ce44dd44cb..b00378988e 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
@@ -42,7 +42,7 @@ protected Object convertListeners( String listenerClasses ) throws TestSetFailed
static String convertListenersString( String listenerClasses )
{
- if ( listenerClasses == null || "".equals( listenerClasses.trim() ) )
+ if ( listenerClasses == null || listenerClasses.trim().isEmpty() )
{
return listenerClasses;
}
From 04a90a8a93077090b74ab0c585ee019b63d0f217 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 2 Apr 2017 13:31:31 +0200
Subject: [PATCH 072/194] [SUREFIRE-1348] Documentation of parameter "argLine"
for goal "surefire:test" lacks mention of a key change made in v2.17
---
.../apache/maven/plugin/surefire/AbstractSurefireMojo.java | 5 +++--
maven-surefire-plugin/src/site/fml/faq.fml | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
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 8a9780c77a..c76d8a1fd9 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
@@ -355,8 +355,9 @@ public abstract class AbstractSurefireMojo
* Arbitrary JVM options to set on the command line.
*
*
- * Using an alternate syntax for argLine,
@{...}
allows late replacement of properties when the
- * plugin is executed, so properties that have been modified by other plugins will be picked up correctly.
+ * Since the Version 2.17 using an alternate syntax for argLine,
@{...}
allows late replacement
+ * of properties when the plugin is executed, so properties that have been modified by other plugins will be picked
+ * up correctly.
* See the Frequently Asked Questions page with more details:
*
* http://maven.apache.org/surefire/maven-surefire-plugin/faq.html
diff --git a/maven-surefire-plugin/src/site/fml/faq.fml b/maven-surefire-plugin/src/site/fml/faq.fml
index 92cbb1dca2..bc39ddc7af 100644
--- a/maven-surefire-plugin/src/site/fml/faq.fml
+++ b/maven-surefire-plugin/src/site/fml/faq.fml
@@ -101,8 +101,8 @@ under the License.
plugin is run. So Surefire would never see the place-holders in its argLine property.
- Using an alternate syntax for these properties,
@{...}
allows late replacement
- of properties when the plugin is executed, so properties that have been modified by other
+ Since the Version 2.17 using an alternate syntax for these properties,
@{...}
allows late
+ replacement of properties when the plugin is executed, so properties that have been modified by other
plugins will be picked up correctly.
From 93d3f8a9e41a334a5e1dacdb511e5d6596f04162 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 2 Apr 2017 14:04:04 +0200
Subject: [PATCH 073/194] renamed version 2.19.2 to cut release version 2.20
---
maven-failsafe-plugin/pom.xml | 2 +-
.../org/apache/maven/plugin/failsafe/IntegrationTestMojo.java | 2 +-
.../plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java | 2 +-
.../org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java | 2 +-
.../apache/maven/plugin/failsafe/IntegrationTestMojoTest.java | 2 +-
.../java/org/apache/maven/plugin/failsafe/RunResultTest.java | 2 +-
maven-surefire-common/pom.xml | 2 +-
.../apache/maven/plugin/surefire/AbstractSurefireMojo.java | 4 ++--
.../booterclient/output/NativeStdErrStreamConsumer.java | 2 +-
.../apache/maven/plugin/surefire/log/PluginConsoleLogger.java | 2 +-
.../plugin/surefire/report/NullConsoleOutputReceiver.java | 2 +-
.../maven/plugin/surefire/report/NullConsoleReporter.java | 2 +-
.../apache/maven/plugin/surefire/report/NullFileReporter.java | 2 +-
.../plugin/surefire/report/NullStatelessXmlReporter.java | 2 +-
.../maven/plugin/surefire/report/NullStatisticsReporter.java | 2 +-
.../java/org/apache/maven/surefire/spi/ServiceLoader.java | 2 +-
.../apache/maven/plugin/surefire/SurefireReflectorTest.java | 2 +-
.../java/org/apache/maven/surefire/spi/CustomizedImpl.java | 2 +-
.../test/java/org/apache/maven/surefire/spi/DefaultImpl.java | 2 +-
.../org/apache/maven/surefire/spi/EmptyServiceInterface.java | 2 +-
.../apache/maven/surefire/spi/ExistingServiceInterface.java | 2 +-
.../src/test/java/org/apache/maven/surefire/spi/IDefault.java | 2 +-
.../org/apache/maven/surefire/spi/NoServiceInterface.java | 2 +-
.../src/test/java/org/apache/maven/surefire/spi/SPITest.java | 2 +-
.../src/test/java/org/apache/maven/surefire/spi/SPImpl1.java | 2 +-
.../src/test/java/org/apache/maven/surefire/spi/SPImpl2.java | 2 +-
maven-surefire-plugin/pom.xml | 2 +-
.../java/org/apache/maven/plugin/surefire/SurefirePlugin.java | 2 +-
maven-surefire-report-plugin/pom.xml | 2 +-
.../maven/plugins/surefire/report/PluginConsoleLogger.java | 2 +-
pom.xml | 2 +-
surefire-api/pom.xml | 2 +-
.../org/apache/maven/surefire/booter/DumpErrorSingleton.java | 2 +-
.../apache/maven/surefire/util/internal/DumpFileUtils.java | 2 +-
.../org/apache/maven/surefire/util/internal/ObjectUtils.java | 2 +-
.../surefire/util/internal/TestClassMethodNameUtils.java | 2 +-
surefire-booter/pom.xml | 2 +-
surefire-grouper/pom.xml | 2 +-
surefire-integration-tests/pom.xml | 2 +-
.../apache/maven/surefire/its/fixture/MavenLauncherTest.java | 2 +-
.../maven/surefire/its/jiras/Surefire1260NewTestsPattern.java | 2 +-
.../its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java | 2 +-
surefire-logger-api/pom.xml | 2 +-
.../maven/plugin/surefire/log/api/ConsoleLoggerDecorator.java | 2 +-
.../maven/plugin/surefire/log/api/ConsoleLoggerUtils.java | 2 +-
.../java/org/apache/maven/plugin/surefire/log/api/Level.java | 2 +-
.../maven/plugin/surefire/log/api/NullConsoleLogger.java | 2 +-
surefire-providers/common-java5/pom.xml | 2 +-
surefire-providers/common-junit3/pom.xml | 2 +-
surefire-providers/common-junit4/pom.xml | 2 +-
surefire-providers/common-junit48/pom.xml | 2 +-
surefire-providers/pom.xml | 2 +-
surefire-providers/surefire-junit3/pom.xml | 2 +-
surefire-providers/surefire-junit4/pom.xml | 2 +-
surefire-providers/surefire-junit47/pom.xml | 2 +-
surefire-providers/surefire-testng-utils/pom.xml | 2 +-
surefire-providers/surefire-testng/pom.xml | 2 +-
surefire-report-parser/pom.xml | 2 +-
surefire-setup-integration-tests/pom.xml | 2 +-
surefire-shadefire/pom.xml | 2 +-
60 files changed, 61 insertions(+), 61 deletions(-)
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index dc1df6d2ed..5cd8afd05a 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTorg.apache.maven.plugins
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
index 51c36ee659..ddfbe7daae 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
@@ -167,7 +167,7 @@ public class IntegrationTestMojo
* see the documentation:
* http://maven.apache.org/surefire/maven-failsafe-plugin/examples/shutdown.html
*
- * @since 2.19.2
+ * @since 2.20
*/
@Parameter( property = "failsafe.exitTimeout", defaultValue = "30" )
private int forkedProcessExitTimeoutInSeconds;
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java
index 6bfa945c5e..7993a055dc 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java
@@ -1 +1 @@
-package org.apache.maven.plugin.failsafe.xmlsummary;
/*
* 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.suite.RunResult;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
/**
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class FailsafeSummaryXmlUtils
{
public static final Charset UTF8 = Charset.forName( "UTF-8" );
private FailsafeSummaryXmlUtils()
{
throw new IllegalStateException( "No instantiable constructor." );
}
public static RunResult toRunResult( File failsafeSummaryXml ) throws JAXBException
{
FailsafeSummary failsafeSummary = JAXB.unmarshal( failsafeSummaryXml, FailsafeSummary.class );
return new RunResult( failsafeSummary.getCompleted(), failsafeSummary.getErrors(),
failsafeSummary.getFailures(), failsafeSummary.getSkipped(),
failsafeSummary.getFailureMessage(), failsafeSummary.isTimeout()
);
}
public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml )
throws JAXBException, IOException
{
fromRunResultToFile( fromRunResult, toFailsafeSummaryXml, UTF8 );
}
public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml, Charset encoding )
throws JAXBException, IOException
{
FailsafeSummary summary = new FailsafeSummary();
summary.setCompleted( fromRunResult.getCompletedCount() );
summary.setFailureMessage( fromRunResult.getFailure() );
summary.setErrors( fromRunResult.getErrors() );
summary.setFailures( fromRunResult.getFailures() );
summary.setSkipped( fromRunResult.getSkipped() );
summary.setTimeout( fromRunResult.isTimeout() );
summary.setResult( ErrorType.fromValue( fromRunResult.getFailsafeCode() ) );
String unmarshalled = JAXB.marshal( summary, encoding );
OutputStreamWriter os = new OutputStreamWriter( new FileOutputStream( toFailsafeSummaryXml ), encoding );
try
{
os.write( unmarshalled );
os.flush();
}
finally
{
os.close();
}
}
public static void writeSummary( RunResult mergedSummary, File mergedSummaryFile, boolean inProgress,
Charset encoding )
throws IOException, JAXBException
{
if ( !mergedSummaryFile.getParentFile().isDirectory() )
{
//noinspection ResultOfMethodCallIgnored
mergedSummaryFile.getParentFile().mkdirs();
}
if ( mergedSummaryFile.exists() && inProgress )
{
RunResult runResult = toRunResult( mergedSummaryFile );
mergedSummary = mergedSummary.aggregate( runResult );
}
fromRunResultToFile( mergedSummary, mergedSummaryFile, encoding );
}
}
\ No newline at end of file
+package org.apache.maven.plugin.failsafe.xmlsummary;
/*
* 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.suite.RunResult;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
/**
* @author Tibor Digana (tibor17)
* @since 2.20
*/
public final class FailsafeSummaryXmlUtils
{
public static final Charset UTF8 = Charset.forName( "UTF-8" );
private FailsafeSummaryXmlUtils()
{
throw new IllegalStateException( "No instantiable constructor." );
}
public static RunResult toRunResult( File failsafeSummaryXml ) throws JAXBException
{
FailsafeSummary failsafeSummary = JAXB.unmarshal( failsafeSummaryXml, FailsafeSummary.class );
return new RunResult( failsafeSummary.getCompleted(), failsafeSummary.getErrors(),
failsafeSummary.getFailures(), failsafeSummary.getSkipped(),
failsafeSummary.getFailureMessage(), failsafeSummary.isTimeout()
);
}
public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml )
throws JAXBException, IOException
{
fromRunResultToFile( fromRunResult, toFailsafeSummaryXml, UTF8 );
}
public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml, Charset encoding )
throws JAXBException, IOException
{
FailsafeSummary summary = new FailsafeSummary();
summary.setCompleted( fromRunResult.getCompletedCount() );
summary.setFailureMessage( fromRunResult.getFailure() );
summary.setErrors( fromRunResult.getErrors() );
summary.setFailures( fromRunResult.getFailures() );
summary.setSkipped( fromRunResult.getSkipped() );
summary.setTimeout( fromRunResult.isTimeout() );
summary.setResult( ErrorType.fromValue( fromRunResult.getFailsafeCode() ) );
String unmarshalled = JAXB.marshal( summary, encoding );
OutputStreamWriter os = new OutputStreamWriter( new FileOutputStream( toFailsafeSummaryXml ), encoding );
try
{
os.write( unmarshalled );
os.flush();
}
finally
{
os.close();
}
}
public static void writeSummary( RunResult mergedSummary, File mergedSummaryFile, boolean inProgress,
Charset encoding )
throws IOException, JAXBException
{
if ( !mergedSummaryFile.getParentFile().isDirectory() )
{
//noinspection ResultOfMethodCallIgnored
mergedSummaryFile.getParentFile().mkdirs();
}
if ( mergedSummaryFile.exists() && inProgress )
{
RunResult runResult = toRunResult( mergedSummaryFile );
mergedSummary = mergedSummary.aggregate( runResult );
}
fromRunResultToFile( mergedSummary, mergedSummaryFile, encoding );
}
}
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java
index ba3fdd0420..723200c096 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java
@@ -1 +1 @@
-package org.apache.maven.plugin.failsafe.xmlsummary;
/*
* 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.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.PropertyException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.helpers.DefaultValidationEventHandler;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import static javax.xml.bind.JAXBContext.newInstance;
import static javax.xml.bind.Marshaller.JAXB_ENCODING;
import static javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT;
import static javax.xml.bind.Marshaller.JAXB_FRAGMENT;
/**
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class JAXB
{
private JAXB()
{
throw new IllegalStateException( "Not instantiated constructor." );
}
public static T unmarshal( File source, Class rootXmlNode ) throws JAXBException
{
return unmarshal( source, rootXmlNode, Collections.emptyMap() );
}
public static T unmarshal( File source, Class rootXmlNode, Map props )
throws JAXBException
{
Class>[] classesToBeBound = { rootXmlNode };
JAXBContext ctx = newInstance( classesToBeBound );
Unmarshaller unmarshaller = ctx.createUnmarshaller();
properties( props, unmarshaller );
unmarshaller.setEventHandler( new DefaultValidationEventHandler() );
JAXBElement element = unmarshaller.unmarshal( new StreamSource( source ), rootXmlNode );
return element.getValue();
}
public static String marshal( T bean, Charset encoding ) throws JAXBException, IOException
{
return marshal( bean, Collections.emptyMap(), encoding ).toString();
}
@SuppressWarnings( "unchecked" )
public static StringWriter marshal( T bean, Map props, Charset encoding )
throws JAXBException, IOException
{
return marshal( bean, (Class) bean.getClass(), props, encoding );
}
public static StringWriter marshal( T bean, Class type, Map props, Charset encoding )
throws JAXBException, IOException
{
JAXBElement rootElement = buildJaxbElement( bean, type );
return marshal( rootElement, type, props, encoding );
}
public static StringWriter marshal( JAXBElement rootElement, Class type,
Map props, Charset encoding )
throws JAXBException, IOException
{
StringWriter destination = new StringWriter( 256 );
marshal( rootElement, type, props, destination, encoding );
destination.flush();
return destination;
}
public static void marshal( JAXBElement rootElement, Class type, Map props,
Writer destination, Charset encoding ) throws JAXBException
{
Class>[] classesToBeBound = { type };
JAXBContext context = newInstance( classesToBeBound );
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty( JAXB_ENCODING, encoding.name() );
marshaller.setProperty( JAXB_FORMATTED_OUTPUT, true );
marshaller.setProperty( JAXB_FRAGMENT, true );
properties( props, marshaller );
marshaller.marshal( rootElement, destination );
}
private static JAXBElement buildJaxbElement( T bean, Class type )
{
XmlRootElement xmlRootElement = type.getAnnotation( XmlRootElement.class );
if ( xmlRootElement == null )
{
return null;
}
QName root = new QName( "", xmlRootElement.name() );
return new JAXBElement( root, type, bean );
}
private static void properties( Map props, Unmarshaller unmarshaller ) throws PropertyException
{
for ( Entry e : props.entrySet() )
{
unmarshaller.setProperty( e.getKey(), e.getValue() );
}
}
private static void properties( Map props, Marshaller marshaller ) throws PropertyException
{
for ( Entry e : props.entrySet() )
{
marshaller.setProperty( e.getKey(), e.getValue() );
}
}
}
\ No newline at end of file
+package org.apache.maven.plugin.failsafe.xmlsummary;
/*
* 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.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.PropertyException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.helpers.DefaultValidationEventHandler;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import static javax.xml.bind.JAXBContext.newInstance;
import static javax.xml.bind.Marshaller.JAXB_ENCODING;
import static javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT;
import static javax.xml.bind.Marshaller.JAXB_FRAGMENT;
/**
* @author Tibor Digana (tibor17)
* @since 2.20
*/
public final class JAXB
{
private JAXB()
{
throw new IllegalStateException( "Not instantiated constructor." );
}
public static T unmarshal( File source, Class rootXmlNode ) throws JAXBException
{
return unmarshal( source, rootXmlNode, Collections.emptyMap() );
}
public static T unmarshal( File source, Class rootXmlNode, Map props )
throws JAXBException
{
Class>[] classesToBeBound = { rootXmlNode };
JAXBContext ctx = newInstance( classesToBeBound );
Unmarshaller unmarshaller = ctx.createUnmarshaller();
properties( props, unmarshaller );
unmarshaller.setEventHandler( new DefaultValidationEventHandler() );
JAXBElement element = unmarshaller.unmarshal( new StreamSource( source ), rootXmlNode );
return element.getValue();
}
public static String marshal( T bean, Charset encoding ) throws JAXBException, IOException
{
return marshal( bean, Collections.emptyMap(), encoding ).toString();
}
@SuppressWarnings( "unchecked" )
public static StringWriter marshal( T bean, Map props, Charset encoding )
throws JAXBException, IOException
{
return marshal( bean, (Class) bean.getClass(), props, encoding );
}
public static StringWriter marshal( T bean, Class type, Map props, Charset encoding )
throws JAXBException, IOException
{
JAXBElement rootElement = buildJaxbElement( bean, type );
return marshal( rootElement, type, props, encoding );
}
public static StringWriter marshal( JAXBElement rootElement, Class type,
Map props, Charset encoding )
throws JAXBException, IOException
{
StringWriter destination = new StringWriter( 256 );
marshal( rootElement, type, props, destination, encoding );
destination.flush();
return destination;
}
public static void marshal( JAXBElement rootElement, Class type, Map props,
Writer destination, Charset encoding ) throws JAXBException
{
Class>[] classesToBeBound = { type };
JAXBContext context = newInstance( classesToBeBound );
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty( JAXB_ENCODING, encoding.name() );
marshaller.setProperty( JAXB_FORMATTED_OUTPUT, true );
marshaller.setProperty( JAXB_FRAGMENT, true );
properties( props, marshaller );
marshaller.marshal( rootElement, destination );
}
private static JAXBElement buildJaxbElement( T bean, Class type )
{
XmlRootElement xmlRootElement = type.getAnnotation( XmlRootElement.class );
if ( xmlRootElement == null )
{
return null;
}
QName root = new QName( "", xmlRootElement.name() );
return new JAXBElement( root, type, bean );
}
private static void properties( Map props, Unmarshaller unmarshaller ) throws PropertyException
{
for ( Entry e : props.entrySet() )
{
unmarshaller.setProperty( e.getKey(), e.getValue() );
}
}
private static void properties( Map props, Marshaller marshaller ) throws PropertyException
{
for ( Entry e : props.entrySet() )
{
marshaller.setProperty( e.getKey(), e.getValue() );
}
}
}
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/IntegrationTestMojoTest.java b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/IntegrationTestMojoTest.java
index cd69d68d0c..8414d6b00d 100644
--- a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/IntegrationTestMojoTest.java
+++ b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/IntegrationTestMojoTest.java
@@ -1 +1 @@
-package org.apache.maven.plugin.failsafe;
/*
* 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.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.project.MavenProject;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.fest.assertions.Assertions.assertThat;
/**
* @since 2.19.2
*/
public class IntegrationTestMojoTest
{
private IntegrationTestMojo mojo;
@Before
public void init() throws InvalidVersionSpecificationException, IOException
{
Artifact artifact = new DefaultArtifact( "g", "a", createFromVersionSpec( "1.0" ), "compile", "jar", "", null );
artifact.setFile( new File( "./target/tmp/a-1.0.jar" ) );
new File( "./target/tmp" ).mkdir();
artifact.getFile().createNewFile();
mojo = spy( IntegrationTestMojo.class );
MavenProject project = mock( MavenProject.class );
when( project.getArtifact() ).thenReturn( artifact );
when( mojo.getProject() ).thenReturn( project );
}
@Test
public void shouldBeJar()
{
mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
File binaries = mojo.getClassesDirectory();
assertThat( binaries.getName() ).isEqualTo( "a-1.0.jar" );
}
@Test
public void shouldBeAnotherJar()
{
mojo.setClassesDirectory( new File( "./target/another-1.0.jar" ) );
mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
File binaries = mojo.getClassesDirectory();
assertThat( binaries.getName() ).isEqualTo( "another-1.0.jar" );
}
@Test
public void shouldBeClasses()
{
mojo.setClassesDirectory( new File( "./target/classes" ) );
mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
File binaries = mojo.getClassesDirectory();
assertThat( binaries.getName() ).isEqualTo( "classes" );
}
}
\ No newline at end of file
+package org.apache.maven.plugin.failsafe;
/*
* 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.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.project.MavenProject;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import static org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.fest.assertions.Assertions.assertThat;
/**
* @since 2.20
*/
public class IntegrationTestMojoTest
{
private IntegrationTestMojo mojo;
@Before
public void init() throws InvalidVersionSpecificationException, IOException
{
Artifact artifact = new DefaultArtifact( "g", "a", createFromVersionSpec( "1.0" ), "compile", "jar", "", null );
artifact.setFile( new File( "./target/tmp/a-1.0.jar" ) );
new File( "./target/tmp" ).mkdir();
artifact.getFile().createNewFile();
mojo = spy( IntegrationTestMojo.class );
MavenProject project = mock( MavenProject.class );
when( project.getArtifact() ).thenReturn( artifact );
when( mojo.getProject() ).thenReturn( project );
}
@Test
public void shouldBeJar()
{
mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
File binaries = mojo.getClassesDirectory();
assertThat( binaries.getName() ).isEqualTo( "a-1.0.jar" );
}
@Test
public void shouldBeAnotherJar()
{
mojo.setClassesDirectory( new File( "./target/another-1.0.jar" ) );
mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
File binaries = mojo.getClassesDirectory();
assertThat( binaries.getName() ).isEqualTo( "another-1.0.jar" );
}
@Test
public void shouldBeClasses()
{
mojo.setClassesDirectory( new File( "./target/classes" ) );
mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
File binaries = mojo.getClassesDirectory();
assertThat( binaries.getName() ).isEqualTo( "classes" );
}
}
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java
index 1ffb7d92ee..fa7ac8e788 100644
--- a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java
+++ b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java
@@ -1 +1 @@
-package org.apache.maven.plugin.failsafe;
/*
* 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.failsafe.xmlsummary.FailsafeSummaryXmlUtils;
import org.apache.maven.surefire.suite.RunResult;
import org.junit.Test;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import static org.fest.assertions.Assertions.assertThat;
/**
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public class RunResultTest
{
@Test
public void testAggregatedValues()
{
RunResult simple = getSimpleAggregate();
assertThat( simple.getCompletedCount() )
.isEqualTo( 20 );
assertThat( simple.getErrors() )
.isEqualTo( 3 );
assertThat( simple.getFailures() )
.isEqualTo( 7 );
assertThat( simple.getSkipped() )
.isEqualTo( 4 );
assertThat( simple.getFlakes() )
.isEqualTo( 2 );
}
@Test
public void testSerialization()
throws IOException, JAXBException
{
writeReadCheck( getSimpleAggregate() );
}
@Test
public void testFailures()
throws IOException, JAXBException
{
writeReadCheck( new RunResult( 0, 1, 2, 3, "stacktraceHere", false ) );
}
@Test
public void testSkipped()
throws IOException, JAXBException
{
writeReadCheck( new RunResult( 3, 2, 1, 0, null, true ) );
}
@Test
public void testAppendSerialization()
throws IOException, JAXBException
{
RunResult simpleAggregate = getSimpleAggregate();
RunResult additional = new RunResult( 2, 1, 2, 2, "msg " + ( (char) 0x0E01 ), true );
File summary = File.createTempFile( "failsafe", "test" );
FailsafeSummaryXmlUtils.writeSummary( simpleAggregate, summary, false, FailsafeSummaryXmlUtils.UTF8 );
FailsafeSummaryXmlUtils.writeSummary( additional, summary, true, FailsafeSummaryXmlUtils.UTF8 );
RunResult actual = FailsafeSummaryXmlUtils.toRunResult( summary );
//noinspection ResultOfMethodCallIgnored
summary.delete();
RunResult expected = simpleAggregate.aggregate( additional );
assertThat( expected.getCompletedCount() )
.isEqualTo( 22 );
assertThat( expected.getErrors() )
.isEqualTo( 4 );
assertThat( expected.getFailures() )
.isEqualTo( 9 );
assertThat( expected.getSkipped() )
.isEqualTo( 6 );
assertThat( expected.getFlakes() )
.isEqualTo( 2 );
assertThat( expected.getFailure() )
.isEqualTo( "msg " + ( (char) 0x0E01 ) );
assertThat( expected.isTimeout() )
.isTrue();
assertThat( actual )
.isEqualTo( expected );
}
@Test
public void shouldAcceptAliasCharset()
{
Charset charset1 = IntegrationTestMojo.toCharset( "UTF8" );
assertThat( charset1.name() ).isEqualTo( "UTF-8" );
Charset charset2 = IntegrationTestMojo.toCharset( "utf8" );
assertThat( charset2.name() ).isEqualTo( "UTF-8" );
}
private void writeReadCheck( RunResult expected )
throws IOException, JAXBException
{
File tmp = File.createTempFile( "test", "xml" );
FailsafeSummaryXmlUtils.fromRunResultToFile( expected, tmp );
RunResult actual = FailsafeSummaryXmlUtils.toRunResult( tmp );
//noinspection ResultOfMethodCallIgnored
tmp.delete();
assertThat( actual )
.isEqualTo( expected );
}
private RunResult getSimpleAggregate()
{
RunResult resultOne = new RunResult( 10, 1, 3, 2, 1 );
RunResult resultTwo = new RunResult( 10, 2, 4, 2, 1 );
return resultOne.aggregate( resultTwo );
}
}
\ No newline at end of file
+package org.apache.maven.plugin.failsafe;
/*
* 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.failsafe.xmlsummary.FailsafeSummaryXmlUtils;
import org.apache.maven.surefire.suite.RunResult;
import org.junit.Test;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import static org.fest.assertions.Assertions.assertThat;
/**
* @author Tibor Digana (tibor17)
* @since 2.20
*/
public class RunResultTest
{
@Test
public void testAggregatedValues()
{
RunResult simple = getSimpleAggregate();
assertThat( simple.getCompletedCount() )
.isEqualTo( 20 );
assertThat( simple.getErrors() )
.isEqualTo( 3 );
assertThat( simple.getFailures() )
.isEqualTo( 7 );
assertThat( simple.getSkipped() )
.isEqualTo( 4 );
assertThat( simple.getFlakes() )
.isEqualTo( 2 );
}
@Test
public void testSerialization()
throws IOException, JAXBException
{
writeReadCheck( getSimpleAggregate() );
}
@Test
public void testFailures()
throws IOException, JAXBException
{
writeReadCheck( new RunResult( 0, 1, 2, 3, "stacktraceHere", false ) );
}
@Test
public void testSkipped()
throws IOException, JAXBException
{
writeReadCheck( new RunResult( 3, 2, 1, 0, null, true ) );
}
@Test
public void testAppendSerialization()
throws IOException, JAXBException
{
RunResult simpleAggregate = getSimpleAggregate();
RunResult additional = new RunResult( 2, 1, 2, 2, "msg " + ( (char) 0x0E01 ), true );
File summary = File.createTempFile( "failsafe", "test" );
FailsafeSummaryXmlUtils.writeSummary( simpleAggregate, summary, false, FailsafeSummaryXmlUtils.UTF8 );
FailsafeSummaryXmlUtils.writeSummary( additional, summary, true, FailsafeSummaryXmlUtils.UTF8 );
RunResult actual = FailsafeSummaryXmlUtils.toRunResult( summary );
//noinspection ResultOfMethodCallIgnored
summary.delete();
RunResult expected = simpleAggregate.aggregate( additional );
assertThat( expected.getCompletedCount() )
.isEqualTo( 22 );
assertThat( expected.getErrors() )
.isEqualTo( 4 );
assertThat( expected.getFailures() )
.isEqualTo( 9 );
assertThat( expected.getSkipped() )
.isEqualTo( 6 );
assertThat( expected.getFlakes() )
.isEqualTo( 2 );
assertThat( expected.getFailure() )
.isEqualTo( "msg " + ( (char) 0x0E01 ) );
assertThat( expected.isTimeout() )
.isTrue();
assertThat( actual )
.isEqualTo( expected );
}
@Test
public void shouldAcceptAliasCharset()
{
Charset charset1 = IntegrationTestMojo.toCharset( "UTF8" );
assertThat( charset1.name() ).isEqualTo( "UTF-8" );
Charset charset2 = IntegrationTestMojo.toCharset( "utf8" );
assertThat( charset2.name() ).isEqualTo( "UTF-8" );
}
private void writeReadCheck( RunResult expected )
throws IOException, JAXBException
{
File tmp = File.createTempFile( "test", "xml" );
FailsafeSummaryXmlUtils.fromRunResultToFile( expected, tmp );
RunResult actual = FailsafeSummaryXmlUtils.toRunResult( tmp );
//noinspection ResultOfMethodCallIgnored
tmp.delete();
assertThat( actual )
.isEqualTo( expected );
}
private RunResult getSimpleAggregate()
{
RunResult resultOne = new RunResult( 10, 1, 3, 2, 1 );
RunResult resultTwo = new RunResult( 10, 2, 4, 2, 1 );
return resultOne.aggregate( resultTwo );
}
}
\ No newline at end of file
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index 6e8ac703e8..dfe9a0202b 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTmaven-surefire-common
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 c76d8a1fd9..16c25ecca4 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
@@ -336,7 +336,7 @@ public abstract class AbstractSurefireMojo
* Relative path to project.build.directory containing internal Surefire temporary files.
* It is deleted after the test set has completed.
*
- * @since 2.19.2
+ * @since 2.20
*/
@Parameter( property = "tempDir", defaultValue = "surefire" )
private String tempDir;
@@ -664,7 +664,7 @@ public abstract class AbstractSurefireMojo
/**
* Read-only parameter with value of Maven property project.build.directory.
- * @since 2.19.2
+ * @since 2.20
*/
@Parameter( defaultValue = "${project.build.directory}", readonly = true )
private File projectBuildDirectory;
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 48063d3cf1..0ddc39224b 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
@@ -26,7 +26,7 @@
* Used by forked JMV, see {@link org.apache.maven.plugin.surefire.booterclient.ForkStarter}.
*
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
* @see org.apache.maven.plugin.surefire.booterclient.ForkStarter
*/
public final class NativeStdErrStreamConsumer
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java
index 7884270ed5..d93813ebbf 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java
@@ -27,7 +27,7 @@
* Calling {@link Log#isInfoEnabled()} before {@link Log#info(CharSequence)} due to Maven 2.2.1.
*
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
* @see ConsoleLogger
*/
public final class PluginConsoleLogger
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleOutputReceiver.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleOutputReceiver.java
index 55e4ee23f1..e18f3aa5cb 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleOutputReceiver.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleOutputReceiver.java
@@ -25,7 +25,7 @@
* ConsoleReporter doing nothing rather than using null.
*
* @author Benedikt Ritter
- * @since 2.19.2
+ * @since 2.20
*/
class NullConsoleOutputReceiver
implements TestcycleConsoleOutputReceiver
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleReporter.java
index 1bd4e9a037..af68d1e01d 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleReporter.java
@@ -28,7 +28,7 @@
* ConsoleReporter doing nothing rather than using null.
*
* @author Benedikt Ritter
- * @since 2.19.2
+ * @since 2.20
*/
class NullConsoleReporter
extends ConsoleReporter
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullFileReporter.java
index bf7e3ef3a2..bca3c4cb74 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullFileReporter.java
@@ -25,7 +25,7 @@
* FileReporter doing nothing rather than using null.
*
* @author Benedikt Ritter
- * @since 2.19.2
+ * @since 2.20
*/
class NullFileReporter
extends FileReporter
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
index 5895c8ad38..7f5d202146 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
@@ -23,7 +23,7 @@
* FileReporter doing nothing rather than using null.
*
* @author Benedikt Ritter
- * @since 2.19.2
+ * @since 2.20
*/
class NullStatelessXmlReporter
extends StatelessXmlReporter
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatisticsReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatisticsReporter.java
index 5e355cac69..3d58096aa1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatisticsReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatisticsReporter.java
@@ -26,7 +26,7 @@
* StatisticsReporter doing nothing rather than using null.
*
* @author Benedikt Ritter
- * @since 2.19.2
+ * @since 2.20
*/
class NullStatisticsReporter
extends StatisticsReporter
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/surefire/spi/ServiceLoader.java b/maven-surefire-common/src/main/java/org/apache/maven/surefire/spi/ServiceLoader.java
index c23e5d627b..1deae7ca80 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/surefire/spi/ServiceLoader.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/surefire/spi/ServiceLoader.java
@@ -38,7 +38,7 @@
/**
* SPI loader for Java 1.5.
*
- * @since 2.19.2
+ * @since 2.20
*/
public class ServiceLoader
{
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireReflectorTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireReflectorTest.java
index cd31d34424..a7c8b9da4a 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireReflectorTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireReflectorTest.java
@@ -1 +1 @@
-package org.apache.maven.plugin.surefire;
/*
* 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.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.ConsoleLoggerDecorator;
import org.apache.maven.plugin.surefire.log.api.PrintStreamLogger;
import org.apache.maven.surefire.booter.IsolatedClassLoader;
import org.apache.maven.surefire.booter.SurefireReflector;
import org.junit.Before;
import org.junit.Test;
import static org.apache.maven.surefire.util.ReflectionUtils.getMethod;
import static org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/**
* @author Tibor Digana (tibor17)
* @see ConsoleLogger
* @see SurefireReflector
* @since 2.19.2
*/
public class SurefireReflectorTest
{
private ConsoleLogger logger;
private SurefireReflector reflector;
@Before
public void prepareData()
{
logger = spy( new PrintStreamLogger( System.out ) );
ClassLoader cl = new IsolatedClassLoader( Thread.currentThread().getContextClassLoader(), false, "role" );
reflector = new SurefireReflector( cl );
}
@Test
public void shouldProxyConsoleLogger()
{
Object mirror = reflector.createConsoleLogger( logger );
assertThat( mirror, is( notNullValue() ) );
assertThat( mirror.getClass().getInterfaces()[0].getName(), is( ConsoleLogger.class.getName() ) );
assertThat( mirror, is( not( sameInstance( (Object) logger ) ) ) );
assertThat( mirror, is( instanceOf( ConsoleLoggerDecorator.class ) ) );
invokeMethodWithArray( mirror, getMethod( mirror, "info", String.class ), "Hi There!" );
verify( logger, times( 1 ) ).info( "Hi There!" );
}
}
\ No newline at end of file
+package org.apache.maven.plugin.surefire;
/*
* 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.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.ConsoleLoggerDecorator;
import org.apache.maven.plugin.surefire.log.api.PrintStreamLogger;
import org.apache.maven.surefire.booter.IsolatedClassLoader;
import org.apache.maven.surefire.booter.SurefireReflector;
import org.junit.Before;
import org.junit.Test;
import static org.apache.maven.surefire.util.ReflectionUtils.getMethod;
import static org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/**
* @author Tibor Digana (tibor17)
* @see ConsoleLogger
* @see SurefireReflector
* @since 2.20
*/
public class SurefireReflectorTest
{
private ConsoleLogger logger;
private SurefireReflector reflector;
@Before
public void prepareData()
{
logger = spy( new PrintStreamLogger( System.out ) );
ClassLoader cl = new IsolatedClassLoader( Thread.currentThread().getContextClassLoader(), false, "role" );
reflector = new SurefireReflector( cl );
}
@Test
public void shouldProxyConsoleLogger()
{
Object mirror = reflector.createConsoleLogger( logger );
assertThat( mirror, is( notNullValue() ) );
assertThat( mirror.getClass().getInterfaces()[0].getName(), is( ConsoleLogger.class.getName() ) );
assertThat( mirror, is( not( sameInstance( (Object) logger ) ) ) );
assertThat( mirror, is( instanceOf( ConsoleLoggerDecorator.class ) ) );
invokeMethodWithArray( mirror, getMethod( mirror, "info", String.class ), "Hi There!" );
verify( logger, times( 1 ) ).info( "Hi There!" );
}
}
\ No newline at end of file
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/CustomizedImpl.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/CustomizedImpl.java
index 70e22553f7..2809f2cbb4 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/CustomizedImpl.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/CustomizedImpl.java
@@ -21,7 +21,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public class CustomizedImpl
implements IDefault
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/DefaultImpl.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/DefaultImpl.java
index e623f0b8ab..54de2b76c7 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/DefaultImpl.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/DefaultImpl.java
@@ -21,7 +21,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public class DefaultImpl
implements IDefault
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/EmptyServiceInterface.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/EmptyServiceInterface.java
index 38a186cfa6..30abd698ff 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/EmptyServiceInterface.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/EmptyServiceInterface.java
@@ -22,7 +22,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public interface EmptyServiceInterface
{
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/ExistingServiceInterface.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/ExistingServiceInterface.java
index 9d7fa258e6..45e3ab4f8c 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/ExistingServiceInterface.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/ExistingServiceInterface.java
@@ -22,7 +22,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public interface ExistingServiceInterface
{
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/IDefault.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/IDefault.java
index 53b7b385be..db8127eae2 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/IDefault.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/IDefault.java
@@ -21,7 +21,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public interface IDefault
{
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/NoServiceInterface.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/NoServiceInterface.java
index af649b90a4..e28a07c107 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/NoServiceInterface.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/NoServiceInterface.java
@@ -22,7 +22,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public interface NoServiceInterface
{
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPITest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPITest.java
index a8058f8556..2d8cc9f30d 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPITest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPITest.java
@@ -29,7 +29,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public class SPITest
{
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl1.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl1.java
index e96cec7ac2..3f3f2769e1 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl1.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl1.java
@@ -21,7 +21,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public class SPImpl1 implements ExistingServiceInterface
{
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl2.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl2.java
index 75806b9271..42b446b197 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl2.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl2.java
@@ -21,7 +21,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public class SPImpl2 implements ExistingServiceInterface
{
diff --git a/maven-surefire-plugin/pom.xml b/maven-surefire-plugin/pom.xml
index ba4b748dff..d6bed25465 100644
--- a/maven-surefire-plugin/pom.xml
+++ b/maven-surefire-plugin/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTorg.apache.maven.plugins
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index 943ed69ff3..8008a47987 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -145,7 +145,7 @@ public class SurefirePlugin
* http://maven.apache.org/surefire/maven-surefire-plugin/examples/shutdown.html
* Turns to default fallback value of 30 seconds if negative integer.
*
- * @since 2.19.2
+ * @since 2.20
*/
@Parameter( property = "surefire.exitTimeout", defaultValue = "30" )
private int forkedProcessExitTimeoutInSeconds;
diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml
index 81e0214953..36fb3c4d48 100644
--- a/maven-surefire-report-plugin/pom.xml
+++ b/maven-surefire-report-plugin/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTorg.apache.maven.plugins
diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/PluginConsoleLogger.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/PluginConsoleLogger.java
index ba83734ec1..667bc95c16 100644
--- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/PluginConsoleLogger.java
+++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/PluginConsoleLogger.java
@@ -31,7 +31,7 @@
* Calling {@link Log#isInfoEnabled()} before {@link Log#info(CharSequence)} due to Maven 2.2.1.
*
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
* @see ConsoleLogger
*/
final class PluginConsoleLogger
diff --git a/pom.xml b/pom.xml
index 02f9b80174..688379dd48 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTpomApache Maven Surefire
diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml
index a35f983668..5f0f2fd3e9 100644
--- a/surefire-api/pom.xml
+++ b/surefire-api/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-api
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
index 5df6d59ced..99c921d926 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
@@ -31,7 +31,7 @@
* Fail-safe.
*
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public final class DumpErrorSingleton
{
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
index b561295445..ebf0795390 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
@@ -35,7 +35,7 @@
* Each call logs a date when it was written to the dump file.
*
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public final class DumpFileUtils
{
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ObjectUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ObjectUtils.java
index 93d914df12..996c3be569 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ObjectUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ObjectUtils.java
@@ -1 +1 @@
-package org.apache.maven.surefire.util.internal;
/*
* 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.
*/
/**
* Similar to Java 7 java.util.Objects.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class ObjectUtils
{
private ObjectUtils()
{
throw new IllegalStateException( "no instantiable constructor" );
}
public static T useNonNull( T target, T fallback )
{
return isNull( target ) ? fallback : target;
}
/*
* In JDK7 use java.util.Objects instead.
* todo
* */
public static boolean isNull( Object target )
{
return target == null;
}
/*
* In JDK7 use java.util.Objects instead.
* todo
* */
public static boolean nonNull( Object target )
{
return !isNull( target );
}
/*
* In JDK7 use java.util.Objects instead.
* todo
* */
public static T requireNonNull( T obj, String message )
{
if ( isNull( obj ) )
{
throw new NullPointerException( message );
}
return obj;
}
/*
* In JDK7 use java.util.Objects instead.
* todo
* */
public static T requireNonNull( T obj )
{
return requireNonNull( obj, null );
}
}
\ No newline at end of file
+package org.apache.maven.surefire.util.internal;
/*
* 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.
*/
/**
* Similar to Java 7 java.util.Objects.
*
* @author Tibor Digana (tibor17)
* @since 2.20
*/
public final class ObjectUtils
{
private ObjectUtils()
{
throw new IllegalStateException( "no instantiable constructor" );
}
public static T useNonNull( T target, T fallback )
{
return isNull( target ) ? fallback : target;
}
/*
* In JDK7 use java.util.Objects instead.
* todo
* */
public static boolean isNull( Object target )
{
return target == null;
}
/*
* In JDK7 use java.util.Objects instead.
* todo
* */
public static boolean nonNull( Object target )
{
return !isNull( target );
}
/*
* In JDK7 use java.util.Objects instead.
* todo
* */
public static T requireNonNull( T obj, String message )
{
if ( isNull( obj ) )
{
throw new NullPointerException( message );
}
return obj;
}
/*
* In JDK7 use java.util.Objects instead.
* todo
* */
public static T requireNonNull( T obj )
{
return requireNonNull( obj, null );
}
}
\ No newline at end of file
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TestClassMethodNameUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TestClassMethodNameUtils.java
index 29b4f51871..1a30c72df6 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TestClassMethodNameUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TestClassMethodNameUtils.java
@@ -1 +1 @@
-package org.apache.maven.surefire.util.internal;
/*
* 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 java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* JUnit Description parser.
* Used by JUnit Version lower than 4.7.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class TestClassMethodNameUtils
{
private static final Pattern METHOD_CLASS_PATTERN = Pattern.compile( "([\\s\\S]*)\\((.*)\\)" );
private TestClassMethodNameUtils()
{
throw new IllegalStateException( "no instantiable constructor" );
}
public static String extractClassName( String displayName )
{
Matcher m = METHOD_CLASS_PATTERN.matcher( displayName );
return m.matches() ? m.group( 2 ) : displayName;
}
public static String extractMethodName( String displayName )
{
int i = displayName.indexOf( "(" );
return i >= 0 ? displayName.substring( 0, i ) : displayName;
}
}
\ No newline at end of file
+package org.apache.maven.surefire.util.internal;
/*
* 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 java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* JUnit Description parser.
* Used by JUnit Version lower than 4.7.
*
* @author Tibor Digana (tibor17)
* @since 2.20
*/
public final class TestClassMethodNameUtils
{
private static final Pattern METHOD_CLASS_PATTERN = Pattern.compile( "([\\s\\S]*)\\((.*)\\)" );
private TestClassMethodNameUtils()
{
throw new IllegalStateException( "no instantiable constructor" );
}
public static String extractClassName( String displayName )
{
Matcher m = METHOD_CLASS_PATTERN.matcher( displayName );
return m.matches() ? m.group( 2 ) : displayName;
}
public static String extractMethodName( String displayName )
{
int i = displayName.indexOf( "(" );
return i >= 0 ? displayName.substring( 0, i ) : displayName;
}
}
\ No newline at end of file
diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml
index 4ded628787..803366bb1c 100644
--- a/surefire-booter/pom.xml
+++ b/surefire-booter/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-booter
diff --git a/surefire-grouper/pom.xml b/surefire-grouper/pom.xml
index bcd1b3f799..5abf38ce82 100644
--- a/surefire-grouper/pom.xml
+++ b/surefire-grouper/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-grouper
diff --git a/surefire-integration-tests/pom.xml b/surefire-integration-tests/pom.xml
index d55d14b9b9..b8c6d76314 100644
--- a/surefire-integration-tests/pom.xml
+++ b/surefire-integration-tests/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-integration-tests
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncherTest.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncherTest.java
index 4a638b6f0a..42657c0589 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncherTest.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncherTest.java
@@ -27,7 +27,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public class MavenLauncherTest
{
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java
index 63b1e243c4..870daf18ba 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java
@@ -1 +1 @@
-package org.apache.maven.surefire.its.jiras;
/*
* 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.its.fixture.*;
import org.junit.Test;
/**
* Added included pattern Tests.java.
*
* Found in Surefire 2.19.1.
*
* @author Tibor Digana (tibor17)
* @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-12-60}
* @since 2.19.2
*/
public class Surefire1260NewTestsPattern
extends SurefireJUnit4IntegrationTestCase
{
@Test
public void defaultConfig()
{
unpack()
.executeTest()
.verifyErrorFree( 5 );
}
private SurefireLauncher unpack()
{
return unpack( "/surefire-1260-new-tests-pattern" );
}
}
\ No newline at end of file
+package org.apache.maven.surefire.its.jiras;
/*
* 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.its.fixture.*;
import org.junit.Test;
/**
* Added included pattern Tests.java.
*
* Found in Surefire 2.19.1.
*
* @author Tibor Digana (tibor17)
* @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-12-60}
* @since 2.20
*/
public class Surefire1260NewTestsPattern
extends SurefireJUnit4IntegrationTestCase
{
@Test
public void defaultConfig()
{
unpack()
.executeTest()
.verifyErrorFree( 5 );
}
private SurefireLauncher unpack()
{
return unpack( "/surefire-1260-new-tests-pattern" );
}
}
\ No newline at end of file
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
index 710a23601e..1fa88f654d 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
@@ -38,7 +38,7 @@
* https://github.com/apache/maven-surefire/pull/136
*
* @author michaeltandy
- * @since 2.19.2
+ * @since 2.20
*/
public class Surefire1295AttributeJvmCrashesToTestsIT
extends SurefireJUnit4IntegrationTestCase
diff --git a/surefire-logger-api/pom.xml b/surefire-logger-api/pom.xml
index 1e641590f8..f3359990c8 100644
--- a/surefire-logger-api/pom.xml
+++ b/surefire-logger-api/pom.xml
@@ -25,7 +25,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-logger-api
diff --git a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerDecorator.java b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerDecorator.java
index d0761d8672..e5653533fd 100644
--- a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerDecorator.java
+++ b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerDecorator.java
@@ -1 +1 @@
-package org.apache.maven.plugin.surefire.log.api;
/*
* 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.
*/
/**
* Decorator around {@link ConsoleLogger}.
* This class is loaded in the isolated ClassLoader and the child logger in the in-plugin ClassLoader.
*
* @author Tibor Digana (tibor17)
* @since 2.19.2
*/
public final class ConsoleLoggerDecorator
implements ConsoleLogger
{
private final Object logger;
public ConsoleLoggerDecorator( Object logger )
{
if ( logger == null )
{
throw new NullPointerException( "logger argument is null in " + ConsoleLoggerDecorator.class );
}
this.logger = logger;
}
public void debug( String message )
{
try
{
logger.getClass()
.getMethod( "debug", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void info( String message )
{
try
{
logger.getClass()
.getMethod( "info", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void warning( String message )
{
try
{
logger.getClass()
.getMethod( "warning", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void error( String message )
{
try
{
logger.getClass()
.getMethod( "error", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void error( String message, Throwable t )
{
try
{
logger.getClass()
.getMethod( "error", String.class, Throwable.class )
.invoke( logger, message, t );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void error( Throwable t )
{
try
{
logger.getClass()
.getMethod( "error", Throwable.class )
.invoke( logger, t );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
}
\ No newline at end of file
+package org.apache.maven.plugin.surefire.log.api;
/*
* 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.
*/
/**
* Decorator around {@link ConsoleLogger}.
* This class is loaded in the isolated ClassLoader and the child logger in the in-plugin ClassLoader.
*
* @author Tibor Digana (tibor17)
* @since 2.20
*/
public final class ConsoleLoggerDecorator
implements ConsoleLogger
{
private final Object logger;
public ConsoleLoggerDecorator( Object logger )
{
if ( logger == null )
{
throw new NullPointerException( "logger argument is null in " + ConsoleLoggerDecorator.class );
}
this.logger = logger;
}
public void debug( String message )
{
try
{
logger.getClass()
.getMethod( "debug", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void info( String message )
{
try
{
logger.getClass()
.getMethod( "info", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void warning( String message )
{
try
{
logger.getClass()
.getMethod( "warning", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void error( String message )
{
try
{
logger.getClass()
.getMethod( "error", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void error( String message, Throwable t )
{
try
{
logger.getClass()
.getMethod( "error", String.class, Throwable.class )
.invoke( logger, message, t );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void error( Throwable t )
{
try
{
logger.getClass()
.getMethod( "error", Throwable.class )
.invoke( logger, t );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
}
\ No newline at end of file
diff --git a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerUtils.java b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerUtils.java
index fe12ceb74a..7eca90bf10 100644
--- a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerUtils.java
+++ b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerUtils.java
@@ -24,7 +24,7 @@
/**
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public final class ConsoleLoggerUtils
{
diff --git a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/Level.java b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/Level.java
index 0e7164d974..9195000275 100644
--- a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/Level.java
+++ b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/Level.java
@@ -24,7 +24,7 @@
* Writing to console without color via {@link #NO_COLOR}.
*
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public enum Level
{
diff --git a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/NullConsoleLogger.java b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/NullConsoleLogger.java
index a78a615e5f..fa09d83ca8 100644
--- a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/NullConsoleLogger.java
+++ b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/NullConsoleLogger.java
@@ -23,7 +23,7 @@
* Logger doing nothing rather than using null.
*
* @author Tibor Digana (tibor17)
- * @since 2.19.2
+ * @since 2.20
*/
public final class NullConsoleLogger implements ConsoleLogger
{
diff --git a/surefire-providers/common-java5/pom.xml b/surefire-providers/common-java5/pom.xml
index 1717d5079a..ea4766fb63 100644
--- a/surefire-providers/common-java5/pom.xml
+++ b/surefire-providers/common-java5/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTcommon-java5
diff --git a/surefire-providers/common-junit3/pom.xml b/surefire-providers/common-junit3/pom.xml
index a9d3b5d00f..bb87398cad 100644
--- a/surefire-providers/common-junit3/pom.xml
+++ b/surefire-providers/common-junit3/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTcommon-junit3
diff --git a/surefire-providers/common-junit4/pom.xml b/surefire-providers/common-junit4/pom.xml
index 5a8b528258..ac8303326a 100644
--- a/surefire-providers/common-junit4/pom.xml
+++ b/surefire-providers/common-junit4/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTcommon-junit4
diff --git a/surefire-providers/common-junit48/pom.xml b/surefire-providers/common-junit48/pom.xml
index e6e697619d..24ba8ff8b5 100644
--- a/surefire-providers/common-junit48/pom.xml
+++ b/surefire-providers/common-junit48/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTcommon-junit48
diff --git a/surefire-providers/pom.xml b/surefire-providers/pom.xml
index 1501554d16..9b154c6d36 100644
--- a/surefire-providers/pom.xml
+++ b/surefire-providers/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-providers
diff --git a/surefire-providers/surefire-junit3/pom.xml b/surefire-providers/surefire-junit3/pom.xml
index 3ca1825e9b..40e2f4ea3d 100644
--- a/surefire-providers/surefire-junit3/pom.xml
+++ b/surefire-providers/surefire-junit3/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-junit3
diff --git a/surefire-providers/surefire-junit4/pom.xml b/surefire-providers/surefire-junit4/pom.xml
index 9beee45aa9..dc581546ba 100644
--- a/surefire-providers/surefire-junit4/pom.xml
+++ b/surefire-providers/surefire-junit4/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-junit4
diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml
index 919c52512a..39f68f156b 100644
--- a/surefire-providers/surefire-junit47/pom.xml
+++ b/surefire-providers/surefire-junit47/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-junit47
diff --git a/surefire-providers/surefire-testng-utils/pom.xml b/surefire-providers/surefire-testng-utils/pom.xml
index 5529ae2e31..b8388da74d 100644
--- a/surefire-providers/surefire-testng-utils/pom.xml
+++ b/surefire-providers/surefire-testng-utils/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-testng-utils
diff --git a/surefire-providers/surefire-testng/pom.xml b/surefire-providers/surefire-testng/pom.xml
index 408e067552..baa9f76029 100644
--- a/surefire-providers/surefire-testng/pom.xml
+++ b/surefire-providers/surefire-testng/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-testng
diff --git a/surefire-report-parser/pom.xml b/surefire-report-parser/pom.xml
index 33c535ff46..ff6480d317 100644
--- a/surefire-report-parser/pom.xml
+++ b/surefire-report-parser/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-report-parser
diff --git a/surefire-setup-integration-tests/pom.xml b/surefire-setup-integration-tests/pom.xml
index c16a4314f9..aaba714209 100644
--- a/surefire-setup-integration-tests/pom.xml
+++ b/surefire-setup-integration-tests/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-setup-integration-tests
diff --git a/surefire-shadefire/pom.xml b/surefire-shadefire/pom.xml
index ca64bbaad6..60e801dd17 100644
--- a/surefire-shadefire/pom.xml
+++ b/surefire-shadefire/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire
- 2.19.2-SNAPSHOT
+ 2.20-SNAPSHOTsurefire-shadefire
From 9116f8cf431d104017cc8477ed6e7710f74ec9e5 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 2 Apr 2017 14:49:40 +0200
Subject: [PATCH 074/194] fixed build without profile "jenkins"
---
pom.xml | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 688379dd48..07addb8403 100644
--- a/pom.xml
+++ b/pom.xml
@@ -314,7 +314,7 @@
false
- -Xms128m -Xmx128m ${jacoco.agent}
+ -Xms128m -Xmx128m
@@ -566,6 +566,12 @@
+
+ maven-surefire-plugin
+
+ -Xms128m -Xmx144m ${jacoco.agent}
+
+
From a1d224a8e75dcf64252d3374c9db43fc752082cd Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Wed, 5 Apr 2017 20:41:47 +0200
Subject: [PATCH 075/194] [SUREFIRE-1355] Close reportSets tag
---
maven-surefire-plugin/src/site/apt/usage.apt.vm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/maven-surefire-plugin/src/site/apt/usage.apt.vm b/maven-surefire-plugin/src/site/apt/usage.apt.vm
index b5dd3bd04b..c442e67f37 100644
--- a/maven-surefire-plugin/src/site/apt/usage.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/usage.apt.vm
@@ -281,7 +281,8 @@ mvn verify
failsafe-report-only
-
+
+
From bdde67c5c26691fc1899931c20a6d25b38bd9fbf Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Wed, 5 Apr 2017 23:38:58 +0200
Subject: [PATCH 076/194] [SUREFIRE-1356] ForkClient should distinguish between
internal and stream errors
---
.../maven/plugin/surefire/SurefireHelper.java | 29 +-
.../surefire/booterclient/ForkStarter.java | 21 +-
.../booterclient/output/ForkClient.java | 276 ++++++++++--------
.../output/InPluginProcessDumpSingleton.java | 28 +-
.../plugin/surefire/SurefireHelperTest.java | 65 +++++
.../maven/surefire/JUnit4SuiteTest.java | 4 +-
.../surefire/booter/DumpErrorSingleton.java | 4 +-
7 files changed, 292 insertions(+), 135 deletions(-)
create mode 100644 maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java
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 bab37c722c..8bdf75e2b6 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
@@ -27,6 +27,7 @@
import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.suite.RunResult;
import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -35,6 +36,8 @@
import java.util.List;
import static java.util.Collections.unmodifiableList;
+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;
import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_ERROR;
import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_INFO;
@@ -46,6 +49,18 @@
*/
public final class SurefireHelper
{
+ private static final String DUMP_FILE_DATE = DumpFileUtils.newFormattedDateFileName();
+
+ public static final String DUMP_FILE_PREFIX = DUMP_FILE_DATE + "-jvmRun";
+
+ public static final String DUMPSTREAM_FILENAME_FORMATTER = DUMP_FILE_PREFIX + "%d" + DUMPSTREAM_FILE_EXT;
+
+ private static final String[] DUMP_FILES_PRINT =
+ {
+ "[date]-jvmRun[N]" + DUMP_FILE_EXT,
+ "[date]" + DUMPSTREAM_FILE_EXT,
+ "[date]-jvmRun[N]" + DUMPSTREAM_FILE_EXT
+ };
/**
* Do not instantiate.
@@ -55,6 +70,11 @@ private SurefireHelper()
throw new IllegalAccessError( "Utility class" );
}
+ public static String[] getDumpFilesToPrint()
+ {
+ return DUMP_FILES_PRINT.clone();
+ }
+
public static void reportExecution( SurefireReportParameters reportParameters, RunResult result,
PluginConsoleLogger log, Exception firstForkException )
throws MojoFailureException, MojoExecutionException
@@ -201,8 +221,13 @@ private static String createErrorMessage( SurefireReportParameters reportParamet
.append( reportParameters.getReportsDirectory() )
.append( " for the individual test results." )
.append( '\n' )
- .append( "Please refer to dump files (if any exist) "
- + "[date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream" );
+ .append( "Please refer to dump files (if any exist) " )
+ .append( DUMP_FILES_PRINT[0] )
+ .append( ", " )
+ .append( DUMP_FILES_PRINT[1] )
+ .append( " and " )
+ .append( DUMP_FILES_PRINT[2] )
+ .append( "." );
}
if ( firstForkException != null && firstForkException.getLocalizedMessage() != null )
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 5360b4cdbc..b3a3f91b0a 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
@@ -50,7 +50,6 @@
import org.apache.maven.surefire.suite.RunResult;
import org.apache.maven.surefire.testset.TestRequest;
import org.apache.maven.surefire.util.DefaultScanResult;
-import org.apache.maven.surefire.util.internal.DumpFileUtils;
import java.io.Closeable;
import java.io.File;
@@ -82,6 +81,7 @@
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.maven.plugin.surefire.AbstractSurefireMojo.createCopyAndReplaceForkNumPlaceholder;
+import static org.apache.maven.plugin.surefire.SurefireHelper.DUMP_FILE_PREFIX;
import static org.apache.maven.plugin.surefire.booterclient.ForkNumberBucket.drawNumber;
import static org.apache.maven.plugin.surefire.booterclient.ForkNumberBucket.returnNumber;
import static org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream
@@ -130,8 +130,6 @@ public class ForkStarter
private static final AtomicInteger SYSTEM_PROPERTIES_FILE_COUNTER = new AtomicInteger();
- private static final String DUMP_FILE_PREFIX = DumpFileUtils.newFormattedDateFileName() + "-jvmRun";
-
private final ScheduledExecutorService pingThreadScheduler = createPingScheduler();
private final ScheduledExecutorService timeoutCheckScheduler;
@@ -160,12 +158,15 @@ public class ForkStarter
private final class CloseableCloser
implements Runnable, Closeable
{
+ private final int jvmRun;
+
private final Queue testProvidingInputStream;
private final Thread inputStreamCloserHook;
- public CloseableCloser( Closeable... testProvidingInputStream )
+ public CloseableCloser( int jvmRun, Closeable... testProvidingInputStream )
{
+ this.jvmRun = jvmRun;
this.testProvidingInputStream = new ConcurrentLinkedQueue();
addAll( this.testProvidingInputStream, testProvidingInputStream );
if ( this.testProvidingInputStream.isEmpty() )
@@ -196,9 +197,10 @@ public void run()
// this exception happened => warning on console. The user would see hint to check dump file only
// if tests failed, but if this does not happen then printing warning to console is the only way to
// inform the users.
- String msg = "ForkStarter IOException: " + e.getLocalizedMessage();
- log.warning( msg );
- InPluginProcessDumpSingleton.getSingleton().dumpException( e, msg, defaultReporterFactory );
+ String msg = "ForkStarter IOException: " + e.getLocalizedMessage() + ".";
+ File dump = InPluginProcessDumpSingleton.getSingleton()
+ .dumpException( e, msg, defaultReporterFactory, jvmRun );
+ log.warning( msg + " See the dump file " + dump.getAbsolutePath() );
}
}
}
@@ -525,6 +527,7 @@ private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkC
throws SurefireBooterForkException
{
int forkNumber = drawNumber();
+ forkClient.setForkNumber( forkNumber );
try
{
return fork( testSet, providerProperties, forkClient, effectiveSystemProperties, forkNumber,
@@ -600,8 +603,8 @@ private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkC
}
final ThreadedStreamConsumer threadedStreamConsumer = new ThreadedStreamConsumer( forkClient );
- final CloseableCloser closer =
- new CloseableCloser( threadedStreamConsumer, requireNonNull( testProvidingInputStream, "null param" ) );
+ final CloseableCloser closer = new CloseableCloser( forkNumber, threadedStreamConsumer,
+ requireNonNull( testProvidingInputStream, "null param" ) );
log.debug( "Forking command line: " + cli );
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 32fcea4c2b..583460f46d 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
@@ -29,10 +29,10 @@
import org.apache.maven.surefire.report.StackTraceWriter;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.nio.ByteBuffer;
-import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Queue;
import java.util.Set;
@@ -102,6 +102,11 @@ public class ForkClient
private volatile StackTraceWriter errorInFork;
+ private volatile int forkNumber;
+
+ // prevents from printing same warning
+ private boolean printedErrorStream;
+
public ForkClient( DefaultReporterFactory defaultReporterFactory, Properties testVmSystemProperties,
NotifiableTestStream notifiableTestStream, ConsoleLogger log )
{
@@ -177,134 +182,130 @@ private RunListener getTestSetReporter()
return testSetReporter;
}
- private void processLine( String s )
+ private void processLine( String event )
{
+ final OperationalData op;
try
{
- final byte operationId = (byte) s.charAt( 0 );
- int comma = s.indexOf( ",", 3 );
- if ( comma < 0 )
- {
- log.warning( s );
- return;
- }
- int rest = s.indexOf( ",", comma );
- final String remaining = s.substring( rest + 1 );
-
- switch ( operationId )
- {
- case BOOTERCODE_TESTSET_STARTING:
- getTestSetReporter().testSetStarting( createReportEntry( remaining ) );
- setCurrentStartTime();
- break;
- case BOOTERCODE_TESTSET_COMPLETED:
- testsInProgress.clear();
-
- getTestSetReporter().testSetCompleted( createReportEntry( remaining ) );
- break;
- case BOOTERCODE_TEST_STARTING:
- ReportEntry reportEntry = createReportEntry( remaining );
- testsInProgress.offer( reportEntry.getSourceName() );
-
- getTestSetReporter().testStarting( createReportEntry( remaining ) );
- break;
- case BOOTERCODE_TEST_SUCCEEDED:
- reportEntry = createReportEntry( remaining );
- testsInProgress.remove( reportEntry.getSourceName() );
-
- getTestSetReporter().testSucceeded( createReportEntry( remaining ) );
- break;
- case BOOTERCODE_TEST_FAILED:
- reportEntry = createReportEntry( remaining );
- testsInProgress.remove( reportEntry.getSourceName() );
-
- getTestSetReporter().testFailed( createReportEntry( remaining ) );
- break;
- case BOOTERCODE_TEST_SKIPPED:
- reportEntry = createReportEntry( remaining );
- testsInProgress.remove( reportEntry.getSourceName() );
-
- getTestSetReporter().testSkipped( createReportEntry( remaining ) );
- break;
- case BOOTERCODE_TEST_ERROR:
- reportEntry = createReportEntry( remaining );
- testsInProgress.remove( reportEntry.getSourceName() );
-
- getTestSetReporter().testError( createReportEntry( remaining ) );
- break;
- case BOOTERCODE_TEST_ASSUMPTIONFAILURE:
- reportEntry = createReportEntry( remaining );
- testsInProgress.remove( reportEntry.getSourceName() );
-
- getTestSetReporter().testAssumptionFailure( createReportEntry( remaining ) );
- break;
- case BOOTERCODE_SYSPROPS:
- int keyEnd = remaining.indexOf( "," );
- StringBuilder key = new StringBuilder();
- StringBuilder value = new StringBuilder();
- unescapeString( key, remaining.substring( 0, keyEnd ) );
- unescapeString( value, remaining.substring( keyEnd + 1 ) );
- synchronized ( testVmSystemProperties )
- {
- testVmSystemProperties.put( key.toString(), value.toString() );
- }
- break;
- case BOOTERCODE_STDOUT:
- writeTestOutput( remaining, true );
- break;
- case BOOTERCODE_STDERR:
- writeTestOutput( remaining, false );
- break;
- case BOOTERCODE_CONSOLE:
- getOrCreateConsoleLogger()
- .info( createConsoleMessage( remaining ) );
- break;
- case BOOTERCODE_NEXT_TEST:
- notifiableTestStream.provideNewTest();
- break;
- case BOOTERCODE_ERROR:
- errorInFork = deserializeStackTraceWriter( new StringTokenizer( remaining, "," ) );
- break;
- case BOOTERCODE_BYE:
- saidGoodBye = true;
- notifiableTestStream.acknowledgeByeEventReceived();
- break;
- case BOOTERCODE_STOP_ON_NEXT_TEST:
- stopOnNextTest();
- break;
- case BOOTERCODE_DEBUG:
- getOrCreateConsoleLogger()
- .debug( createConsoleMessage( remaining ) );
- break;
- case BOOTERCODE_WARNING:
- getOrCreateConsoleLogger()
- .warning( createConsoleMessage( remaining ) );
- break;
- default:
- InPluginProcessDumpSingleton.getSingleton().dumpText( s, defaultReporterFactory );
- }
- }
- catch ( NumberFormatException e )
- {
- // SUREFIRE-859
- InPluginProcessDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
+ op = new OperationalData( event );
}
- catch ( NoSuchElementException e )
+ catch ( RuntimeException e )
{
- // SUREFIRE-859
- InPluginProcessDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
+ logStreamWarning( e, event );
+ return;
}
- catch ( IndexOutOfBoundsException e )
+ final String remaining = op.getData();
+ switch ( op.getOperationId() )
{
- // native stream sent a text e.g. GC verbose
- InPluginProcessDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
- throw e;
+ case BOOTERCODE_TESTSET_STARTING:
+ getTestSetReporter().testSetStarting( createReportEntry( remaining ) );
+ setCurrentStartTime();
+ break;
+ case BOOTERCODE_TESTSET_COMPLETED:
+ testsInProgress.clear();
+
+ getTestSetReporter().testSetCompleted( createReportEntry( remaining ) );
+ break;
+ case BOOTERCODE_TEST_STARTING:
+ ReportEntry reportEntry = createReportEntry( remaining );
+ testsInProgress.offer( reportEntry.getSourceName() );
+
+ getTestSetReporter().testStarting( createReportEntry( remaining ) );
+ break;
+ case BOOTERCODE_TEST_SUCCEEDED:
+ reportEntry = createReportEntry( remaining );
+ testsInProgress.remove( reportEntry.getSourceName() );
+
+ getTestSetReporter().testSucceeded( createReportEntry( remaining ) );
+ break;
+ case BOOTERCODE_TEST_FAILED:
+ reportEntry = createReportEntry( remaining );
+ testsInProgress.remove( reportEntry.getSourceName() );
+
+ getTestSetReporter().testFailed( createReportEntry( remaining ) );
+ break;
+ case BOOTERCODE_TEST_SKIPPED:
+ reportEntry = createReportEntry( remaining );
+ testsInProgress.remove( reportEntry.getSourceName() );
+
+ getTestSetReporter().testSkipped( createReportEntry( remaining ) );
+ break;
+ case BOOTERCODE_TEST_ERROR:
+ reportEntry = createReportEntry( remaining );
+ testsInProgress.remove( reportEntry.getSourceName() );
+
+ getTestSetReporter().testError( createReportEntry( remaining ) );
+ break;
+ case BOOTERCODE_TEST_ASSUMPTIONFAILURE:
+ reportEntry = createReportEntry( remaining );
+ testsInProgress.remove( reportEntry.getSourceName() );
+
+ getTestSetReporter().testAssumptionFailure( createReportEntry( remaining ) );
+ break;
+ case BOOTERCODE_SYSPROPS:
+ int keyEnd = remaining.indexOf( "," );
+ StringBuilder key = new StringBuilder();
+ StringBuilder value = new StringBuilder();
+ unescapeString( key, remaining.substring( 0, keyEnd ) );
+ unescapeString( value, remaining.substring( keyEnd + 1 ) );
+ synchronized ( testVmSystemProperties )
+ {
+ testVmSystemProperties.put( key.toString(), value.toString() );
+ }
+ break;
+ case BOOTERCODE_STDOUT:
+ writeTestOutput( remaining, true );
+ break;
+ case BOOTERCODE_STDERR:
+ writeTestOutput( remaining, false );
+ break;
+ case BOOTERCODE_CONSOLE:
+ getOrCreateConsoleLogger()
+ .info( createConsoleMessage( remaining ) );
+ break;
+ case BOOTERCODE_NEXT_TEST:
+ notifiableTestStream.provideNewTest();
+ break;
+ case BOOTERCODE_ERROR:
+ errorInFork = deserializeStackTraceWriter( new StringTokenizer( remaining, "," ) );
+ break;
+ case BOOTERCODE_BYE:
+ saidGoodBye = true;
+ notifiableTestStream.acknowledgeByeEventReceived();
+ break;
+ case BOOTERCODE_STOP_ON_NEXT_TEST:
+ stopOnNextTest();
+ break;
+ case BOOTERCODE_DEBUG:
+ getOrCreateConsoleLogger()
+ .debug( createConsoleMessage( remaining ) );
+ break;
+ case BOOTERCODE_WARNING:
+ getOrCreateConsoleLogger()
+ .warning( createConsoleMessage( remaining ) );
+ break;
+ default:
+ logStreamWarning( event );
}
- catch ( RuntimeException e )
+ }
+
+ private void logStreamWarning( String event )
+ {
+ logStreamWarning( null, event );
+ }
+
+ private void logStreamWarning( Throwable e, String event )
+ {
+ final String msg = "Corrupted stdin stream in forked JVM " + forkNumber + ".";
+ final InPluginProcessDumpSingleton util = InPluginProcessDumpSingleton.getSingleton();
+ final File dump =
+ e == null ? util.dumpText( msg + " Stream '" + event + "'.", defaultReporterFactory, forkNumber )
+ : util.dumpException( e, msg + " Stream '" + event + "'.", defaultReporterFactory, forkNumber );
+
+ if ( !printedErrorStream )
{
- // e.g. ReporterException
- InPluginProcessDumpSingleton.getSingleton().dumpException( e, s, defaultReporterFactory );
- throw e;
+ printedErrorStream = true;
+ log.warning( msg + " See the dump file " + dump.getAbsolutePath() );
}
}
@@ -438,4 +439,39 @@ public boolean hasTestsInProgress()
{
return !testsInProgress.isEmpty();
}
+
+ public void setForkNumber( int forkNumber )
+ {
+ assert this.forkNumber == 0;
+ this.forkNumber = forkNumber;
+ }
+
+ private static final class OperationalData
+ {
+ private final byte operationId;
+ private final String data;
+
+ OperationalData( String event )
+ {
+ operationId = (byte) event.charAt( 0 );
+ int comma = event.indexOf( ",", 3 );
+ if ( comma < 0 )
+ {
+ throw new IllegalArgumentException( "Stream stdin corrupted. Expected comma after third character "
+ + "in command '" + event + "'." );
+ }
+ int rest = event.indexOf( ",", comma );
+ data = event.substring( rest + 1 );
+ }
+
+ byte getOperationId()
+ {
+ return operationId;
+ }
+
+ String getData()
+ {
+ return data;
+ }
+ }
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/InPluginProcessDumpSingleton.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/InPluginProcessDumpSingleton.java
index 6580c43679..0676b5290c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/InPluginProcessDumpSingleton.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/InPluginProcessDumpSingleton.java
@@ -21,8 +21,13 @@
import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
import org.apache.maven.surefire.util.internal.DumpFileUtils;
+
import java.io.File;
+import static java.lang.String.format;
+import static org.apache.maven.plugin.surefire.SurefireHelper.DUMPSTREAM_FILENAME_FORMATTER;
+import static org.apache.maven.surefire.booter.DumpErrorSingleton.DUMPSTREAM_FILE_EXT;
+
/**
* Reports errors to dump file.
* Used only within java process of the plugin itself and not the forked JVM.
@@ -42,6 +47,14 @@ public static InPluginProcessDumpSingleton getSingleton()
return SINGLETON;
}
+ public synchronized File dumpException( Throwable t, String msg, DefaultReporterFactory defaultReporterFactory,
+ int jvmRun )
+ {
+ File dump = newDumpFile( defaultReporterFactory, jvmRun );
+ DumpFileUtils.dumpException( t, msg == null ? "null" : msg, dump );
+ return dump;
+ }
+
public synchronized void dumpException( Throwable t, String msg, DefaultReporterFactory defaultReporterFactory )
{
DumpFileUtils.dumpException( t, msg == null ? "null" : msg, newDumpFile( defaultReporterFactory ) );
@@ -52,6 +65,13 @@ public synchronized void dumpException( Throwable t, DefaultReporterFactory defa
DumpFileUtils.dumpException( t, newDumpFile( defaultReporterFactory ) );
}
+ public synchronized File dumpText( String msg, DefaultReporterFactory defaultReporterFactory, int jvmRun )
+ {
+ File dump = newDumpFile( defaultReporterFactory, jvmRun );
+ DumpFileUtils.dumpText( msg == null ? "null" : msg, dump );
+ return dump;
+ }
+
public synchronized void dumpText( String msg, DefaultReporterFactory defaultReporterFactory )
{
DumpFileUtils.dumpText( msg == null ? "null" : msg, newDumpFile( defaultReporterFactory ) );
@@ -60,6 +80,12 @@ public synchronized void dumpText( String msg, DefaultReporterFactory defaultRep
private File newDumpFile( DefaultReporterFactory defaultReporterFactory )
{
File reportsDirectory = defaultReporterFactory.getReportsDirectory();
- return new File( reportsDirectory, creationDate + ".dumpstream" );
+ return new File( reportsDirectory, creationDate + DUMPSTREAM_FILE_EXT );
+ }
+
+ private static File newDumpFile( DefaultReporterFactory defaultReporterFactory, int jvmRun )
+ {
+ File reportsDirectory = defaultReporterFactory.getReportsDirectory();
+ return new File( reportsDirectory, format( DUMPSTREAM_FILENAME_FORMATTER, jvmRun ) );
}
}
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
new file mode 100644
index 0000000000..b249aca0e2
--- /dev/null
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java
@@ -0,0 +1,65 @@
+package org.apache.maven.plugin.surefire;
+
+/*
+ * 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.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static java.util.Collections.addAll;
+import static java.util.Collections.singleton;
+import static org.fest.assertions.Assertions.assertThat;
+
+/**
+ * Test of {@link SurefireHelper}.
+ */
+public class SurefireHelperTest
+{
+ @Test
+ public void shouldBeThreeDumpFiles()
+ {
+ String[] dumps = SurefireHelper.getDumpFilesToPrint();
+ assertThat( dumps ).hasSize( 3 );
+ assertThat( dumps ).doesNotHaveDuplicates();
+ List onlyStrings = new ArrayList();
+ addAll( onlyStrings, dumps );
+ onlyStrings.removeAll( singleton( (String) null ) );
+ assertThat( onlyStrings ).hasSize( 3 );
+ }
+
+ @Test
+ public void shouldCloneDumpFiles()
+ {
+ String[] dumps1 = SurefireHelper.getDumpFilesToPrint();
+ String[] dumps2 = SurefireHelper.getDumpFilesToPrint();
+ assertThat( dumps1 ).isNotSameAs( dumps2 );
+ }
+
+ @Test
+ public void testConstants()
+ {
+ assertThat( SurefireHelper.DUMPSTREAM_FILENAME_FORMATTER )
+ .isEqualTo( SurefireHelper.DUMP_FILE_PREFIX + "%d.dumpstream" );
+
+ assertThat( String.format( SurefireHelper.DUMPSTREAM_FILENAME_FORMATTER, 5) )
+ .endsWith( "-jvmRun5.dumpstream" );
+ }
+}
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 4309ad3e79..9fb45bfe28 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
@@ -21,6 +21,7 @@
import junit.framework.JUnit4TestAdapter;
import junit.framework.Test;
+import org.apache.maven.plugin.surefire.SurefireHelperTest;
import org.apache.maven.plugin.surefire.SurefireReflectorTest;
import org.apache.maven.plugin.surefire.SurefirePropertiesTest;
import org.apache.maven.plugin.surefire.booterclient.BooterDeserializerProviderConfigurationTest;
@@ -72,7 +73,8 @@
TestLessInputStreamBuilderTest.class,
SPITest.class,
SurefireReflectorTest.class,
- ImmutableMapTest.class
+ ImmutableMapTest.class,
+ SurefireHelperTest.class,
} )
@RunWith( Suite.class )
public class JUnit4SuiteTest
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
index 99c921d926..fc92c70834 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DumpErrorSingleton.java
@@ -35,8 +35,8 @@
*/
public final class DumpErrorSingleton
{
- private static final String DUMP_FILE_EXT = ".dump";
- private static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
+ public static final String DUMP_FILE_EXT = ".dump";
+ public static final String DUMPSTREAM_FILE_EXT = ".dumpstream";
private static final DumpErrorSingleton SINGLETON = new DumpErrorSingleton();
private File dumpFile;
From e7bb6fc8b37bd9057c0baa25ce1cb2f16d643e63 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Thu, 6 Apr 2017 00:10:11 +0200
Subject: [PATCH 077/194] [SUREFIRE-1354] Sometimes BYE_ACK command is lost
---
.../apache/maven/surefire/booter/ForkedBooter.java | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 4589088c0d..fef21d1674 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -156,10 +156,7 @@ else if ( readTestsFromInputStream )
encode( stringBuilder, stackTraceWriter, false );
encodeAndWriteToOutput( ( (char) BOOTERCODE_ERROR ) + ",0," + stringBuilder + "\n", originalOut );
}
- // Say bye.
- encodeAndWriteToOutput( ( (char) BOOTERCODE_BYE ) + ",0,BYE!\n", originalOut );
- // noinspection CallToSystemExit
- exit( 0, reader );
+ acknowledgedExit( reader, originalOut );
}
catch ( Throwable t )
{
@@ -258,7 +255,7 @@ private static void exit( int returnCode )
System.exit( returnCode );
}
- private static void exit( int returnCode, final CommandReader reader )
+ private static void acknowledgedExit( CommandReader reader, PrintStream originalOut )
{
final Semaphore barrier = new Semaphore( 0 );
reader.addByeAckListener( new CommandListener()
@@ -270,10 +267,11 @@ public void update( Command command )
}
}
);
- launchLastDitchDaemonShutdownThread( returnCode );
- final long timeoutMillis = max( systemExitTimeoutInSeconds * ONE_SECOND_IN_MILLIS, ONE_SECOND_IN_MILLIS );
+ encodeAndWriteToOutput( ( (char) BOOTERCODE_BYE ) + ",0,BYE!\n", originalOut );
+ launchLastDitchDaemonShutdownThread( 0 );
+ long timeoutMillis = max( systemExitTimeoutInSeconds * ONE_SECOND_IN_MILLIS, ONE_SECOND_IN_MILLIS );
acquireOnePermit( barrier, timeoutMillis );
- System.exit( returnCode );
+ System.exit( 0 );
}
private static boolean acquireOnePermit( Semaphore barrier, long timeoutMillis )
From eed317207695e3174d2f283390dd0386fc09f3e4 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Fri, 7 Apr 2017 22:38:45 +0200
Subject: [PATCH 078/194] [SUREFIRE-1357] PING scheduler kills JVM in debug
mode
---
.../booterclient/output/ForkClient.java | 27 ++++++++-----
.../maven/surefire/booter/ForkedBooter.java | 38 ++++++++++++++-----
2 files changed, 47 insertions(+), 18 deletions(-)
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 583460f46d..7aaa0f1ee7 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
@@ -77,6 +77,7 @@
public class ForkClient
implements StreamConsumer
{
+ private static final String PRINTABLE_JVM_NATIVE_STREAM = "Listening for transport dt_socket at address:";
private static final long START_TIME_ZERO = 0L;
private static final long START_TIME_NEGATIVE_TIMEOUT = -1L;
@@ -296,16 +297,24 @@ private void logStreamWarning( String event )
private void logStreamWarning( Throwable e, String event )
{
- final String msg = "Corrupted stdin stream in forked JVM " + forkNumber + ".";
- final InPluginProcessDumpSingleton util = InPluginProcessDumpSingleton.getSingleton();
- final File dump =
- e == null ? util.dumpText( msg + " Stream '" + event + "'.", defaultReporterFactory, forkNumber )
- : util.dumpException( e, msg + " Stream '" + event + "'.", defaultReporterFactory, forkNumber );
-
- if ( !printedErrorStream )
+ if ( event == null || !event.contains( PRINTABLE_JVM_NATIVE_STREAM ) )
+ {
+ final String msg = "Corrupted stdin stream in forked JVM " + forkNumber + ".";
+ final InPluginProcessDumpSingleton util = InPluginProcessDumpSingleton.getSingleton();
+ final File dump =
+ e == null
+ ? util.dumpText( msg + " Stream '" + event + "'.", defaultReporterFactory, forkNumber )
+ : util.dumpException( e, msg + " Stream '" + event + "'.", defaultReporterFactory, forkNumber );
+
+ if ( !printedErrorStream )
+ {
+ printedErrorStream = true;
+ log.warning( msg + " See the dump file " + dump.getAbsolutePath() );
+ }
+ }
+ else
{
- printedErrorStream = true;
- log.warning( msg + " See the dump file " + dump.getAbsolutePath() );
+ log.info( event );
}
}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index fef21d1674..a0115940e9 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -32,9 +32,10 @@
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadFactory;
@@ -72,7 +73,6 @@ public final class ForkedBooter
private static final long DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS = 30;
private static final long PING_TIMEOUT_IN_SECONDS = 20;
private static final long ONE_SECOND_IN_MILLIS = 1000;
- private static final ScheduledExecutorService JVM_PING = createPingScheduler();
private static volatile ScheduledThreadPoolExecutor jvmTerminator;
private static volatile long systemExitTimeoutInSeconds = DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS;
@@ -86,7 +86,7 @@ public final class ForkedBooter
public static void main( String... args )
{
final CommandReader reader = startupMasterProcessReader();
- final ScheduledFuture> pingScheduler = listenToShutdownCommands( reader );
+ final ExecutorService pingScheduler = isDebugging() ? null : listenToShutdownCommands( reader );
final PrintStream originalOut = out;
try
{
@@ -156,7 +156,7 @@ else if ( readTestsFromInputStream )
encode( stringBuilder, stackTraceWriter, false );
encodeAndWriteToOutput( ( (char) BOOTERCODE_ERROR ) + ",0," + stringBuilder + "\n", originalOut );
}
- acknowledgedExit( reader, originalOut );
+ acknowledgedExit( reader, originalOut, pingScheduler );
}
catch ( Throwable t )
{
@@ -164,12 +164,17 @@ else if ( readTestsFromInputStream )
// Just throwing does getMessage() and a local trace - we want to call printStackTrace for a full trace
// noinspection UseOfSystemOutOrSystemErr
t.printStackTrace( err );
+ cancelPingScheduler( pingScheduler );
// noinspection ProhibitedExceptionThrown,CallToSystemExit
exit( 1 );
}
- finally
+ }
+
+ private static void cancelPingScheduler( ExecutorService pingScheduler )
+ {
+ if ( pingScheduler != null )
{
- pingScheduler.cancel( true );
+ pingScheduler.shutdown();
}
}
@@ -178,13 +183,15 @@ private static CommandReader startupMasterProcessReader()
return getReader();
}
- private static ScheduledFuture> listenToShutdownCommands( CommandReader reader )
+ private static ExecutorService listenToShutdownCommands( CommandReader reader )
{
reader.addShutdownListener( createExitHandler() );
AtomicBoolean pingDone = new AtomicBoolean( true );
reader.addNoopListener( createPingHandler( pingDone ) );
Runnable pingJob = createPingJob( pingDone );
- return JVM_PING.scheduleAtFixedRate( pingJob, 0, PING_TIMEOUT_IN_SECONDS, SECONDS );
+ ScheduledExecutorService pingScheduler = createPingScheduler();
+ pingScheduler.scheduleAtFixedRate( pingJob, 0, PING_TIMEOUT_IN_SECONDS, SECONDS );
+ return pingScheduler;
}
private static CommandListener createPingHandler( final AtomicBoolean pingDone )
@@ -255,7 +262,7 @@ private static void exit( int returnCode )
System.exit( returnCode );
}
- private static void acknowledgedExit( CommandReader reader, PrintStream originalOut )
+ private static void acknowledgedExit( CommandReader reader, PrintStream originalOut, ExecutorService pingScheduler )
{
final Semaphore barrier = new Semaphore( 0 );
reader.addByeAckListener( new CommandListener()
@@ -271,6 +278,7 @@ public void update( Command command )
launchLastDitchDaemonShutdownThread( 0 );
long timeoutMillis = max( systemExitTimeoutInSeconds * ONE_SECOND_IN_MILLIS, ONE_SECOND_IN_MILLIS );
acquireOnePermit( barrier, timeoutMillis );
+ cancelPingScheduler( pingScheduler );
System.exit( 0 );
}
@@ -397,4 +405,16 @@ private static InputStream createSurefirePropertiesIfFileExists( String tmpDir,
File surefirePropertiesFile = new File( tmpDir, propFileName );
return surefirePropertiesFile.exists() ? new FileInputStream( surefirePropertiesFile ) : null;
}
+
+ private static boolean isDebugging()
+ {
+ for ( String argument : ManagementFactory.getRuntimeMXBean().getInputArguments() )
+ {
+ if ( "-Xdebug".equals( argument ) || argument.startsWith( "-agentlib:jdwp" ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
}
From 6fd0a3e7ca7c27234dab67be27efc10875d7a2e6 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Fri, 7 Apr 2017 23:00:47 +0200
Subject: [PATCH 079/194] [SUREFIRE-1358] Directory in Class-Path in manifest
of forked jvm ends with two slashes //
---
.../booterclient/ForkConfiguration.java | 20 +++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 7f2c536aba..c56453a4f2 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -33,6 +33,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -280,13 +281,20 @@ private File createJar( List classPath, String startClassName )
// we can't use StringUtils.join here since we need to add a '/' to
// the end of directory entries - otherwise the jvm will ignore them.
StringBuilder cp = new StringBuilder();
- for ( String el : classPath )
+ for ( Iterator it = classPath.iterator(); it.hasNext(); )
{
- File file1 = new File( el );
- String pathEnd = file1.isDirectory() ? "/" : "";
- cp.append( file1.toURI().toASCIIString() )
- .append( pathEnd )
- .append( " " );
+ File file1 = new File( it.next() );
+ String uri = file1.toURI().toASCIIString();
+ cp.append( uri );
+ if ( file1.isDirectory() && !uri.endsWith( "/" ) )
+ {
+ cp.append( '/' );
+ }
+
+ if ( it.hasNext() )
+ {
+ cp.append( ' ' );
+ }
}
man.getMainAttributes().putValue( "Manifest-Version", "1.0" );
From f4f78c9f155ad57fe75c8845eb4916481ae675ab Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 8 Apr 2017 00:24:49 +0200
Subject: [PATCH 080/194] Fixed buid: Surefire34SecurityManagerIT
---
.../maven/surefire/booter/ForkedBooter.java | 23 +++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index a0115940e9..3c18578047 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -34,6 +34,9 @@
import java.io.PrintStream;
import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationTargetException;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -170,11 +173,27 @@ else if ( readTestsFromInputStream )
}
}
- private static void cancelPingScheduler( ExecutorService pingScheduler )
+ private static void cancelPingScheduler( final ExecutorService pingScheduler )
{
if ( pingScheduler != null )
{
- pingScheduler.shutdown();
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedAction()
+ {
+ @Override
+ public Object run()
+ {
+ pingScheduler.shutdown();
+ return null;
+ }
+ }
+ );
+ }
+ catch ( AccessControlException e )
+ {
+ // ignore
+ }
}
}
From 8c786523414018099b54a0868ae1bc3d64847411 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 8 Apr 2017 10:41:30 +0200
Subject: [PATCH 081/194] [maven-release-plugin] prepare release
surefire-2.20_vote-3
---
maven-failsafe-plugin/pom.xml | 5 ++---
maven-surefire-common/pom.xml | 2 +-
maven-surefire-plugin/pom.xml | 2 +-
maven-surefire-report-plugin/pom.xml | 2 +-
pom.xml | 4 ++--
surefire-api/pom.xml | 2 +-
surefire-booter/pom.xml | 2 +-
surefire-grouper/pom.xml | 2 +-
surefire-integration-tests/pom.xml | 2 +-
surefire-logger-api/pom.xml | 6 ++----
surefire-providers/common-java5/pom.xml | 2 +-
surefire-providers/common-junit3/pom.xml | 2 +-
surefire-providers/common-junit4/pom.xml | 2 +-
surefire-providers/common-junit48/pom.xml | 2 +-
surefire-providers/pom.xml | 2 +-
surefire-providers/surefire-junit3/pom.xml | 2 +-
surefire-providers/surefire-junit4/pom.xml | 2 +-
surefire-providers/surefire-junit47/pom.xml | 2 +-
surefire-providers/surefire-testng-utils/pom.xml | 2 +-
surefire-providers/surefire-testng/pom.xml | 2 +-
surefire-report-parser/pom.xml | 2 +-
surefire-setup-integration-tests/pom.xml | 2 +-
surefire-shadefire/pom.xml | 2 +-
23 files changed, 26 insertions(+), 29 deletions(-)
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index 5cd8afd05a..57e7b526fb 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20org.apache.maven.plugins
@@ -168,8 +168,7 @@
-
+
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index dfe9a0202b..3798f58625 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20maven-surefire-common
diff --git a/maven-surefire-plugin/pom.xml b/maven-surefire-plugin/pom.xml
index d6bed25465..fe2c47710d 100644
--- a/maven-surefire-plugin/pom.xml
+++ b/maven-surefire-plugin/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20org.apache.maven.plugins
diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml
index 36fb3c4d48..389dfb4d73 100644
--- a/maven-surefire-report-plugin/pom.xml
+++ b/maven-surefire-report-plugin/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20org.apache.maven.plugins
diff --git a/pom.xml b/pom.xml
index 07addb8403..5655eea4b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20pomApache Maven Surefire
@@ -68,7 +68,7 @@
${maven.surefire.scm.devConnection}${maven.surefire.scm.devConnection}https://github.com/apache/maven-surefire/tree/${project.scm.tag}
- HEAD
+ surefire-2.20_vote-3jira
diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml
index 5f0f2fd3e9..045ab16355 100644
--- a/surefire-api/pom.xml
+++ b/surefire-api/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20surefire-api
diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml
index 803366bb1c..ce8dcb356c 100644
--- a/surefire-booter/pom.xml
+++ b/surefire-booter/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20surefire-booter
diff --git a/surefire-grouper/pom.xml b/surefire-grouper/pom.xml
index 5abf38ce82..3fcbf6fd72 100644
--- a/surefire-grouper/pom.xml
+++ b/surefire-grouper/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20surefire-grouper
diff --git a/surefire-integration-tests/pom.xml b/surefire-integration-tests/pom.xml
index b8c6d76314..4224281d8f 100644
--- a/surefire-integration-tests/pom.xml
+++ b/surefire-integration-tests/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20surefire-integration-tests
diff --git a/surefire-logger-api/pom.xml b/surefire-logger-api/pom.xml
index f3359990c8..461a3f760a 100644
--- a/surefire-logger-api/pom.xml
+++ b/surefire-logger-api/pom.xml
@@ -17,15 +17,13 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
+4.0.0org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20surefire-logger-api
diff --git a/surefire-providers/common-java5/pom.xml b/surefire-providers/common-java5/pom.xml
index ea4766fb63..6f819eaec9 100644
--- a/surefire-providers/common-java5/pom.xml
+++ b/surefire-providers/common-java5/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20-SNAPSHOT
+ 2.20common-java5
diff --git a/surefire-providers/common-junit3/pom.xml b/surefire-providers/common-junit3/pom.xml
index bb87398cad..ea4ced0e3a 100644
--- a/surefire-providers/common-junit3/pom.xml
+++ b/surefire-providers/common-junit3/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20-SNAPSHOT
+ 2.20common-junit3
diff --git a/surefire-providers/common-junit4/pom.xml b/surefire-providers/common-junit4/pom.xml
index ac8303326a..e53691a33c 100644
--- a/surefire-providers/common-junit4/pom.xml
+++ b/surefire-providers/common-junit4/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20-SNAPSHOT
+ 2.20common-junit4
diff --git a/surefire-providers/common-junit48/pom.xml b/surefire-providers/common-junit48/pom.xml
index 24ba8ff8b5..4149ffef21 100644
--- a/surefire-providers/common-junit48/pom.xml
+++ b/surefire-providers/common-junit48/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20-SNAPSHOT
+ 2.20common-junit48
diff --git a/surefire-providers/pom.xml b/surefire-providers/pom.xml
index 9b154c6d36..b4e50d07fd 100644
--- a/surefire-providers/pom.xml
+++ b/surefire-providers/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20surefire-providers
diff --git a/surefire-providers/surefire-junit3/pom.xml b/surefire-providers/surefire-junit3/pom.xml
index 40e2f4ea3d..b2f660692a 100644
--- a/surefire-providers/surefire-junit3/pom.xml
+++ b/surefire-providers/surefire-junit3/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20-SNAPSHOT
+ 2.20surefire-junit3
diff --git a/surefire-providers/surefire-junit4/pom.xml b/surefire-providers/surefire-junit4/pom.xml
index dc581546ba..f323d50436 100644
--- a/surefire-providers/surefire-junit4/pom.xml
+++ b/surefire-providers/surefire-junit4/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20-SNAPSHOT
+ 2.20surefire-junit4
diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml
index 39f68f156b..c1a956285e 100644
--- a/surefire-providers/surefire-junit47/pom.xml
+++ b/surefire-providers/surefire-junit47/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20-SNAPSHOT
+ 2.20surefire-junit47
diff --git a/surefire-providers/surefire-testng-utils/pom.xml b/surefire-providers/surefire-testng-utils/pom.xml
index b8388da74d..36dc2937fb 100644
--- a/surefire-providers/surefire-testng-utils/pom.xml
+++ b/surefire-providers/surefire-testng-utils/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20-SNAPSHOT
+ 2.20surefire-testng-utils
diff --git a/surefire-providers/surefire-testng/pom.xml b/surefire-providers/surefire-testng/pom.xml
index baa9f76029..72082f7f28 100644
--- a/surefire-providers/surefire-testng/pom.xml
+++ b/surefire-providers/surefire-testng/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20-SNAPSHOT
+ 2.20surefire-testng
diff --git a/surefire-report-parser/pom.xml b/surefire-report-parser/pom.xml
index ff6480d317..5f6b161b82 100644
--- a/surefire-report-parser/pom.xml
+++ b/surefire-report-parser/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20surefire-report-parser
diff --git a/surefire-setup-integration-tests/pom.xml b/surefire-setup-integration-tests/pom.xml
index aaba714209..5bfd01cffe 100644
--- a/surefire-setup-integration-tests/pom.xml
+++ b/surefire-setup-integration-tests/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20surefire-setup-integration-tests
diff --git a/surefire-shadefire/pom.xml b/surefire-shadefire/pom.xml
index 60e801dd17..a53453724e 100644
--- a/surefire-shadefire/pom.xml
+++ b/surefire-shadefire/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire
- 2.20-SNAPSHOT
+ 2.20surefire-shadefire
From 0039f56dc04ff4c26693b4533014bce3d475daf6 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 8 Apr 2017 10:41:42 +0200
Subject: [PATCH 082/194] [maven-release-plugin] prepare for next development
iteration
---
maven-failsafe-plugin/pom.xml | 2 +-
maven-surefire-common/pom.xml | 2 +-
maven-surefire-plugin/pom.xml | 2 +-
maven-surefire-report-plugin/pom.xml | 2 +-
pom.xml | 4 ++--
surefire-api/pom.xml | 2 +-
surefire-booter/pom.xml | 2 +-
surefire-grouper/pom.xml | 2 +-
surefire-integration-tests/pom.xml | 2 +-
surefire-logger-api/pom.xml | 2 +-
surefire-providers/common-java5/pom.xml | 2 +-
surefire-providers/common-junit3/pom.xml | 2 +-
surefire-providers/common-junit4/pom.xml | 2 +-
surefire-providers/common-junit48/pom.xml | 2 +-
surefire-providers/pom.xml | 2 +-
surefire-providers/surefire-junit3/pom.xml | 2 +-
surefire-providers/surefire-junit4/pom.xml | 2 +-
surefire-providers/surefire-junit47/pom.xml | 2 +-
surefire-providers/surefire-testng-utils/pom.xml | 2 +-
surefire-providers/surefire-testng/pom.xml | 2 +-
surefire-report-parser/pom.xml | 2 +-
surefire-setup-integration-tests/pom.xml | 2 +-
surefire-shadefire/pom.xml | 2 +-
23 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index 57e7b526fb..ed1d751a54 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTorg.apache.maven.plugins
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index 3798f58625..f4bab594cf 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTmaven-surefire-common
diff --git a/maven-surefire-plugin/pom.xml b/maven-surefire-plugin/pom.xml
index fe2c47710d..62ec4a7422 100644
--- a/maven-surefire-plugin/pom.xml
+++ b/maven-surefire-plugin/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTorg.apache.maven.plugins
diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml
index 389dfb4d73..9f35967e24 100644
--- a/maven-surefire-report-plugin/pom.xml
+++ b/maven-surefire-report-plugin/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTorg.apache.maven.plugins
diff --git a/pom.xml b/pom.xml
index 5655eea4b8..60d6376219 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTpomApache Maven Surefire
@@ -68,7 +68,7 @@
${maven.surefire.scm.devConnection}${maven.surefire.scm.devConnection}https://github.com/apache/maven-surefire/tree/${project.scm.tag}
- surefire-2.20_vote-3
+ HEADjira
diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml
index 045ab16355..7e407d2ba2 100644
--- a/surefire-api/pom.xml
+++ b/surefire-api/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTsurefire-api
diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml
index ce8dcb356c..b79cceb381 100644
--- a/surefire-booter/pom.xml
+++ b/surefire-booter/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTsurefire-booter
diff --git a/surefire-grouper/pom.xml b/surefire-grouper/pom.xml
index 3fcbf6fd72..b38803498c 100644
--- a/surefire-grouper/pom.xml
+++ b/surefire-grouper/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTsurefire-grouper
diff --git a/surefire-integration-tests/pom.xml b/surefire-integration-tests/pom.xml
index 4224281d8f..267cedadd7 100644
--- a/surefire-integration-tests/pom.xml
+++ b/surefire-integration-tests/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTsurefire-integration-tests
diff --git a/surefire-logger-api/pom.xml b/surefire-logger-api/pom.xml
index 461a3f760a..a80af6e784 100644
--- a/surefire-logger-api/pom.xml
+++ b/surefire-logger-api/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTsurefire-logger-api
diff --git a/surefire-providers/common-java5/pom.xml b/surefire-providers/common-java5/pom.xml
index 6f819eaec9..39373b03f8 100644
--- a/surefire-providers/common-java5/pom.xml
+++ b/surefire-providers/common-java5/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20
+ 2.21-SNAPSHOTcommon-java5
diff --git a/surefire-providers/common-junit3/pom.xml b/surefire-providers/common-junit3/pom.xml
index ea4ced0e3a..1584af85b8 100644
--- a/surefire-providers/common-junit3/pom.xml
+++ b/surefire-providers/common-junit3/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20
+ 2.21-SNAPSHOTcommon-junit3
diff --git a/surefire-providers/common-junit4/pom.xml b/surefire-providers/common-junit4/pom.xml
index e53691a33c..4e70b4560c 100644
--- a/surefire-providers/common-junit4/pom.xml
+++ b/surefire-providers/common-junit4/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20
+ 2.21-SNAPSHOTcommon-junit4
diff --git a/surefire-providers/common-junit48/pom.xml b/surefire-providers/common-junit48/pom.xml
index 4149ffef21..020e413609 100644
--- a/surefire-providers/common-junit48/pom.xml
+++ b/surefire-providers/common-junit48/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20
+ 2.21-SNAPSHOTcommon-junit48
diff --git a/surefire-providers/pom.xml b/surefire-providers/pom.xml
index b4e50d07fd..9ed020deee 100644
--- a/surefire-providers/pom.xml
+++ b/surefire-providers/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTsurefire-providers
diff --git a/surefire-providers/surefire-junit3/pom.xml b/surefire-providers/surefire-junit3/pom.xml
index b2f660692a..1bfaf6b6b6 100644
--- a/surefire-providers/surefire-junit3/pom.xml
+++ b/surefire-providers/surefire-junit3/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20
+ 2.21-SNAPSHOTsurefire-junit3
diff --git a/surefire-providers/surefire-junit4/pom.xml b/surefire-providers/surefire-junit4/pom.xml
index f323d50436..f5e35fe92c 100644
--- a/surefire-providers/surefire-junit4/pom.xml
+++ b/surefire-providers/surefire-junit4/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20
+ 2.21-SNAPSHOTsurefire-junit4
diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml
index c1a956285e..9f1fa0fc92 100644
--- a/surefire-providers/surefire-junit47/pom.xml
+++ b/surefire-providers/surefire-junit47/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20
+ 2.21-SNAPSHOTsurefire-junit47
diff --git a/surefire-providers/surefire-testng-utils/pom.xml b/surefire-providers/surefire-testng-utils/pom.xml
index 36dc2937fb..bc5c2d3f05 100644
--- a/surefire-providers/surefire-testng-utils/pom.xml
+++ b/surefire-providers/surefire-testng-utils/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20
+ 2.21-SNAPSHOTsurefire-testng-utils
diff --git a/surefire-providers/surefire-testng/pom.xml b/surefire-providers/surefire-testng/pom.xml
index 72082f7f28..fe293c07e1 100644
--- a/surefire-providers/surefire-testng/pom.xml
+++ b/surefire-providers/surefire-testng/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire-providers
- 2.20
+ 2.21-SNAPSHOTsurefire-testng
diff --git a/surefire-report-parser/pom.xml b/surefire-report-parser/pom.xml
index 5f6b161b82..648b0c2087 100644
--- a/surefire-report-parser/pom.xml
+++ b/surefire-report-parser/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTsurefire-report-parser
diff --git a/surefire-setup-integration-tests/pom.xml b/surefire-setup-integration-tests/pom.xml
index 5bfd01cffe..fde80ae269 100644
--- a/surefire-setup-integration-tests/pom.xml
+++ b/surefire-setup-integration-tests/pom.xml
@@ -24,7 +24,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTsurefire-setup-integration-tests
diff --git a/surefire-shadefire/pom.xml b/surefire-shadefire/pom.xml
index a53453724e..b061467ce3 100644
--- a/surefire-shadefire/pom.xml
+++ b/surefire-shadefire/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.surefiresurefire
- 2.20
+ 2.21-SNAPSHOTsurefire-shadefire
From 03ae55f4443aeca188edbdffa4e216c74063b33d Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sat, 15 Apr 2017 02:56:34 +0200
Subject: [PATCH 083/194] [SUREFIRE-1363] Java 1.6 features @Override and
Charset
---
.../plugin/failsafe/IntegrationTestMojo.java | 50 ++++++
.../maven/plugin/failsafe/VerifyMojo.java | 17 ++
.../xmlsummary/FailsafeSummaryXmlUtils.java | 105 +++++++++++-
.../failsafe/MarshallerUnmarshallerTest.java | 132 ++++++++++++++-
.../maven/plugin/failsafe/RunResultTest.java | 155 +++++++++++++++++-
.../plugin/surefire/AbstractSurefireMojo.java | 30 ++++
.../plugin/surefire/SurefireProperties.java | 2 +
.../booterclient/ChecksumCalculator.java | 14 +-
.../surefire/booterclient/ForkStarter.java | 16 +-
.../OutputStreamFlushableCommandline.java | 2 +
.../lazytestprovider/TestLessInputStream.java | 16 ++
.../TestProvidingInputStream.java | 4 +
.../output/DeserializedStacktraceWriter.java | 4 +
.../booterclient/output/ForkClient.java | 1 +
.../output/NativeStdErrStreamConsumer.java | 1 +
.../output/ThreadedStreamConsumer.java | 3 +
.../surefire/log/PluginConsoleLogger.java | 6 +
.../report/ConsoleOutputFileReporter.java | 4 +
.../report/DefaultReporterFactory.java | 2 +
.../surefire/report/DirectConsoleOutput.java | 4 +
.../report/NullConsoleOutputReceiver.java | 4 +
.../surefire/report/StatelessXmlReporter.java | 29 +---
.../surefire/report/TestSetRunListener.java | 16 ++
.../Utf8RecodingDeferredFileOutputStream.java | 10 +-
.../surefire/report/WrappedReportEntry.java | 7 +
.../MockNotifiableTestStream.java | 4 +
.../surefire/booterclient/MockReporter.java | 16 ++
.../TestSetMockReporterFactory.java | 1 +
.../TestProvidingInputStreamTest.java | 3 +
.../report/DefaultReporterFactoryTest.java | 10 ++
.../report/StatelessXmlReporterTest.java | 7 +-
.../maven/surefire/spi/CustomizedImpl.java | 1 +
.../maven/surefire/spi/DefaultImpl.java | 1 +
.../apache/maven/surefire/spi/SPImpl1.java | 1 +
.../apache/maven/surefire/spi/SPImpl2.java | 1 +
.../maven/plugin/surefire/SurefirePlugin.java | 51 ++++++
.../plugin/surefire/SurefirePluginTest.java | 2 +
.../report/AbstractSurefireReportMojo.java | 4 +
.../surefire/report/FailsafeReportMojo.java | 6 +
.../surefire/report/PluginConsoleLogger.java | 6 +
.../surefire/report/SurefireReportMojo.java | 4 +
.../stubs/SurefireRepMavenProjectStub.java | 1 +
.../stubs/SurefireRepMavenProjectStub2.java | 1 +
.../runorder/RunEntryStatisticsMap.java | 4 +
.../surefire/NonAbstractClassFilter.java | 1 +
.../surefire/SpecificTestClassFilter.java | 1 +
.../surefire/booter/BaseProviderFactory.java | 26 +++
.../maven/surefire/booter/CommandReader.java | 5 +
.../booter/ForkingReporterFactory.java | 2 +
.../surefire/booter/ForkingRunListener.java | 18 ++
.../surefire/booter/MasterProcessCommand.java | 34 ++--
.../surefire/booter/SurefireReflector.java | 1 +
.../providerapi/AbstractProvider.java | 1 +
.../report/CategorizedReportEntry.java | 3 +
.../surefire/report/ConsoleOutputCapture.java | 6 +
.../report/DefaultDirectConsoleReporter.java | 2 +
.../report/LegacyPojoStackTraceWriter.java | 4 +
.../surefire/report/SimpleReportEntry.java | 10 ++
.../maven/surefire/suite/RunResult.java | 2 +
.../surefire/testset/TestListResolver.java | 10 ++
.../surefire/util/CloseableIterator.java | 101 +++++++++++-
.../util/DefaultDirectoryScanner.java | 1 +
.../util/DefaultRunOrderCalculator.java | 3 +
.../surefire/util/DefaultScanResult.java | 5 +
.../apache/maven/surefire/util/RunOrder.java | 1 +
.../maven/surefire/util/TestsToRun.java | 2 +
.../surefire/util/internal/ByteBuffer.java | 1 +
.../util/internal/DaemonThreadFactory.java | 2 +
.../surefire/util/internal/DumpFileUtils.java | 4 +-
.../surefire/util/internal/StringUtils.java | 20 +--
.../surefire/util/internal/UrlUtils.java | 51 ++----
.../booter/SurefireReflectorTest.java | 2 +
.../LegacyPojoStackTraceWriterTest.java | 1 +
.../maven/surefire/util/UrlUtilsTest.java | 1 +
.../util/internal/ConcurrencyUtilsTest.java | 1 +
.../maven/surefire/booter/Classpath.java | 3 +
.../maven/surefire/booter/ForkedBooter.java | 4 +
.../surefire/booter/IsolatedClassLoader.java | 3 +
.../maven/surefire/booter/LazyTestsToRun.java | 7 +
.../surefire/booter/PropertiesWrapper.java | 1 +
.../surefire/booter/ProviderFactory.java | 3 +
.../surefire/booter/TypeEncodedValue.java | 9 +-
.../surefire/booter/CommandReaderTest.java | 6 +-
.../org/apache/maven/surefire/booter/Foo.java | 7 +
.../surefire/group/match/AndGroupMatcher.java | 2 +
.../group/match/InverseGroupMatcher.java | 3 +
.../group/match/JoinGroupMatcher.java | 1 +
.../surefire/group/match/OrGroupMatcher.java | 2 +
.../group/match/SingleGroupMatcher.java | 3 +
.../maven/surefire/its/ForkModeTestNGIT.java | 1 +
.../its/fixture/FailsafeOutputValidator.java | 1 +
.../surefire/its/fixture/OutputValidator.java | 2 +-
...efire1082ParallelJUnitParameterizedIT.java | 2 +
.../log/api/ConsoleLoggerDecorator.java | 2 +-
.../surefire/log/api/NullConsoleLogger.java | 6 +
.../surefire/log/api/PrintStreamLogger.java | 73 ++++++++-
.../report/ClassNameStackTraceFilter.java | 1 +
.../surefire/report/NullStackTraceFilter.java | 1 +
.../surefire/report/PojoStackTraceWriter.java | 4 +
.../surefire/report/RunnableTestClass1.java | 1 +
.../surefire/report/RunnableTestClass2.java | 1 +
.../common/junit3/JUnit3TestChecker.java | 1 +
.../common/junit3/JUnit3TestCheckerTest.java | 2 +
.../common/junit4/JUnit4Reflector.java | 2 +
.../common/junit4/JUnit4RunListener.java | 4 +
.../common/junit4/JUnit4StackTraceWriter.java | 4 +
.../common/junit4/JUnit4TestChecker.java | 1 +
.../maven/surefire/junit4/MockReporter.java | 9 +
.../common/junit4/JUnit4RunListenerTest.java | 1 +
.../junit4/JUnit4TestCheckerTest.java | 2 +
.../junit48/JUnit46StackTraceWriter.java | 2 +
.../common/junit48/JUnit48TestChecker.java | 1 +
.../maven/surefire/junit/JUnit3Provider.java | 2 +
.../maven/surefire/junit/JUnitTestSet.java | 2 +
.../surefire/junit/PojoAndJUnit3Checker.java | 1 +
.../maven/surefire/junit/PojoTestSet.java | 2 +
.../junit/TestListenerInvocationHandler.java | 3 +
.../surefire/junit/JUnitTestSetTest.java | 9 +
.../maven/surefire/junit4/JUnit4Provider.java | 4 +
.../junitcore/AsynchronousRunner.java | 2 +
.../junitcore/ConcurrentRunListener.java | 10 ++
.../surefire/junitcore/JUnitCoreProvider.java | 4 +
.../junitcore/JUnitCoreRunListener.java | 1 +
.../junitcore/NonConcurrentRunListener.java | 2 +
.../surefire/junitcore/SynchronousRunner.java | 2 +
.../maven/surefire/junitcore/TestMethod.java | 1 +
.../pc/AbstractThreadPoolStrategy.java | 1 +
.../junitcore/pc/InvokerStrategy.java | 1 +
.../surefire/junitcore/pc/NullBalancer.java | 3 +
.../junitcore/pc/ParallelComputer.java | 2 +
.../surefire/junitcore/pc/Scheduler.java | 4 +
.../junitcore/pc/ThreadResourcesBalancer.java | 3 +
.../junitcore/DefaultConsoleReporter.java | 6 +
.../pc/ParallelComputerBuilderTest.java | 2 +
.../surefire/junitcore/pc/RangeMatcher.java | 2 +
.../pc/SchedulingStrategiesTest.java | 1 +
.../testng/utils/FailFastListener.java | 7 +
.../testng/utils/FailFastNotifier.java | 2 +
.../utils/GroupMatcherMethodSelector.java | 2 +
.../surefire/testng/utils/MethodSelector.java | 2 +
.../maven/surefire/testng/TestNGExecutor.java | 1 +
.../maven/surefire/testng/TestNGProvider.java | 4 +
.../maven/surefire/testng/TestNGReporter.java | 9 +
.../conf/AbstractDirectConfigurator.java | 2 +
.../testng/conf/TestNG60Configurator.java | 1 +
.../testng/conf/TestNGMapConfigurator.java | 2 +
.../surefire/report/ReportTestCase.java | 1 +
.../surefire/report/ReportTestSuite.java | 1 +
.../surefire/report/TestSuiteXmlParser.java | 3 +
.../surefire/report/ReportTestCaseTest.java | 1 +
.../surefire/report/ReportTestSuiteTest.java | 1 +
.../report/SurefireReportParserTest.java | 1 +
.../report/TestSuiteXmlParserTest.java | 6 +
153 files changed, 1255 insertions(+), 119 deletions(-)
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
index ddfbe7daae..1ad317fa51 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
@@ -350,11 +350,13 @@ public class IntegrationTestMojo
@Parameter( property = "failsafe.shutdown", defaultValue = "testset" )
private String shutdown;
+ @Override
protected int getRerunFailingTestsCount()
{
return rerunFailingTestsCount;
}
+ @Override
@SuppressWarnings( "unchecked" )
protected void handleSummary( RunResult summary, Exception firstForkException )
throws MojoExecutionException, MojoFailureException
@@ -418,17 +420,20 @@ private static File toAbsoluteCanonical( File f )
}
}
+ @Override
@SuppressWarnings( "deprecation" )
protected boolean isSkipExecution()
{
return isSkip() || isSkipTests() || isSkipITs() || isSkipExec();
}
+ @Override
protected String getPluginName()
{
return "failsafe";
}
+ @Override
protected String[] getDefaultIncludes()
{
return new String[]{ "**/IT*.java", "**/*IT.java", "**/*ITCase.java" };
@@ -440,11 +445,13 @@ protected String getReportSchemaLocation()
return "https://maven.apache.org/surefire/maven-failsafe-plugin/xsd/failsafe-test-report.xsd";
}
+ @Override
public boolean isSkipTests()
{
return skipTests;
}
+ @Override
public void setSkipTests( boolean skipTests )
{
this.skipTests = skipTests;
@@ -460,6 +467,7 @@ public void setSkipITs( boolean skipITs )
this.skipITs = skipITs;
}
+ @Override
@SuppressWarnings( "deprecation" )
@Deprecated
public boolean isSkipExec()
@@ -467,6 +475,7 @@ public boolean isSkipExec()
return skipExec;
}
+ @Override
@SuppressWarnings( "deprecation" )
@Deprecated
public void setSkipExec( boolean skipExec )
@@ -474,31 +483,37 @@ public void setSkipExec( boolean skipExec )
this.skipExec = skipExec;
}
+ @Override
public boolean isSkip()
{
return skip;
}
+ @Override
public void setSkip( boolean skip )
{
this.skip = skip;
}
+ @Override
public File getBasedir()
{
return basedir;
}
+ @Override
public void setBasedir( File basedir )
{
this.basedir = basedir;
}
+ @Override
public File getTestClassesDirectory()
{
return testClassesDirectory;
}
+ @Override
public void setTestClassesDirectory( File testClassesDirectory )
{
this.testClassesDirectory = testClassesDirectory;
@@ -509,6 +524,7 @@ public void setTestClassesDirectory( File testClassesDirectory )
* {@link #useSystemClassLoader} is ignored and the {@link org.apache.maven.surefire.booter.IsolatedClassLoader} is
* used instead. See the resolution of {@link #getClassLoaderConfiguration() ClassLoaderConfiguration}.
*/
+ @Override
public File getClassesDirectory()
{
File artifact = getProject().getArtifact().getFile();
@@ -516,6 +532,7 @@ public File getClassesDirectory()
return isDefaultClsDir ? ( isJarArtifact( artifact ) ? artifact : defaultClassesDirectory ) : classesDirectory;
}
+ @Override
public void setClassesDirectory( File classesDirectory )
{
this.classesDirectory = toAbsoluteCanonical( classesDirectory );
@@ -526,21 +543,25 @@ public void setDefaultClassesDirectory( File defaultClassesDirectory )
this.defaultClassesDirectory = toAbsoluteCanonical( defaultClassesDirectory );
}
+ @Override
public File getReportsDirectory()
{
return reportsDirectory;
}
+ @Override
public void setReportsDirectory( File reportsDirectory )
{
this.reportsDirectory = reportsDirectory;
}
+ @Override
public String getTest()
{
return test;
}
+ @Override
public void setTest( String test )
{
this.test = test;
@@ -556,101 +577,121 @@ public void setSummaryFile( File summaryFile )
this.summaryFile = summaryFile;
}
+ @Override
public boolean isPrintSummary()
{
return printSummary;
}
+ @Override
public void setPrintSummary( boolean printSummary )
{
this.printSummary = printSummary;
}
+ @Override
public String getReportFormat()
{
return reportFormat;
}
+ @Override
public void setReportFormat( String reportFormat )
{
this.reportFormat = reportFormat;
}
+ @Override
public boolean isUseFile()
{
return useFile;
}
+ @Override
public void setUseFile( boolean useFile )
{
this.useFile = useFile;
}
+ @Override
public String getDebugForkedProcess()
{
return debugForkedProcess;
}
+ @Override
public void setDebugForkedProcess( String debugForkedProcess )
{
this.debugForkedProcess = debugForkedProcess;
}
+ @Override
public int getForkedProcessTimeoutInSeconds()
{
return forkedProcessTimeoutInSeconds;
}
+ @Override
public void setForkedProcessTimeoutInSeconds( int forkedProcessTimeoutInSeconds )
{
this.forkedProcessTimeoutInSeconds = forkedProcessTimeoutInSeconds;
}
+ @Override
public int getForkedProcessExitTimeoutInSeconds()
{
return forkedProcessExitTimeoutInSeconds;
}
+ @Override
public void setForkedProcessExitTimeoutInSeconds( int forkedProcessExitTimeoutInSeconds )
{
this.forkedProcessExitTimeoutInSeconds = forkedProcessExitTimeoutInSeconds;
}
+ @Override
public double getParallelTestsTimeoutInSeconds()
{
return parallelTestsTimeoutInSeconds;
}
+ @Override
public void setParallelTestsTimeoutInSeconds( double parallelTestsTimeoutInSeconds )
{
this.parallelTestsTimeoutInSeconds = parallelTestsTimeoutInSeconds;
}
+ @Override
public double getParallelTestsTimeoutForcedInSeconds()
{
return parallelTestsTimeoutForcedInSeconds;
}
+ @Override
public void setParallelTestsTimeoutForcedInSeconds( double parallelTestsTimeoutForcedInSeconds )
{
this.parallelTestsTimeoutForcedInSeconds = parallelTestsTimeoutForcedInSeconds;
}
+ @Override
public boolean isUseSystemClassLoader()
{
return useSystemClassLoader;
}
+ @Override
public void setUseSystemClassLoader( boolean useSystemClassLoader )
{
this.useSystemClassLoader = useSystemClassLoader;
}
+ @Override
public boolean isUseManifestOnlyJar()
{
return useManifestOnlyJar;
}
+ @Override
public void setUseManifestOnlyJar( boolean useManifestOnlyJar )
{
this.useManifestOnlyJar = useManifestOnlyJar;
@@ -668,27 +709,32 @@ public void setTestFailureIgnore( boolean testFailureIgnore )
// ignore
}
+ @Override
protected void addPluginSpecificChecksumItems( ChecksumCalculator checksum )
{
checksum.add( skipITs );
checksum.add( summaryFile );
}
+ @Override
public Boolean getFailIfNoSpecifiedTests()
{
return failIfNoSpecifiedTests;
}
+ @Override
public void setFailIfNoSpecifiedTests( boolean failIfNoSpecifiedTests )
{
this.failIfNoSpecifiedTests = failIfNoSpecifiedTests;
}
+ @Override
public int getSkipAfterFailureCount()
{
return skipAfterFailureCount;
}
+ @Override
public String getShutdown()
{
return shutdown;
@@ -706,22 +752,26 @@ public void setIncludes( List includes )
this.includes = includes;
}
+ @Override
public File[] getSuiteXmlFiles()
{
return suiteXmlFiles.clone();
}
+ @Override
@SuppressWarnings( "UnusedDeclaration" )
public void setSuiteXmlFiles( File[] suiteXmlFiles )
{
this.suiteXmlFiles = suiteXmlFiles.clone();
}
+ @Override
public String getRunOrder()
{
return runOrder;
}
+ @Override
@SuppressWarnings( "UnusedDeclaration" )
public void setRunOrder( String runOrder )
{
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 a56d5215e7..0ad7f80d4a 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
@@ -161,6 +161,7 @@ public class VerifyMojo
private volatile PluginConsoleLogger consoleLogger;
+ @Override
public void execute()
throws MojoExecutionException, MojoFailureException
{
@@ -248,11 +249,13 @@ protected String[] getDefaultIncludes()
return null;
}
+ @Override
public boolean isSkipTests()
{
return skipTests;
}
+ @Override
public void setSkipTests( boolean skipTests )
{
this.skipTests = skipTests;
@@ -268,73 +271,87 @@ public void setSkipITs( boolean skipITs )
this.skipITs = skipITs;
}
+ @Override
@Deprecated
public boolean isSkipExec()
{
return skipExec;
}
+ @Override
@Deprecated
public void setSkipExec( boolean skipExec )
{
this.skipExec = skipExec;
}
+ @Override
public boolean isSkip()
{
return skip;
}
+ @Override
public void setSkip( boolean skip )
{
this.skip = skip;
}
+ @Override
public boolean isTestFailureIgnore()
{
return testFailureIgnore;
}
+ @Override
public void setTestFailureIgnore( boolean testFailureIgnore )
{
this.testFailureIgnore = testFailureIgnore;
}
+ @Override
public File getBasedir()
{
return basedir;
}
+ @Override
public void setBasedir( File basedir )
{
this.basedir = basedir;
}
+ @Override
public File getTestClassesDirectory()
{
return testClassesDirectory;
}
+ @Override
public void setTestClassesDirectory( File testClassesDirectory )
{
this.testClassesDirectory = testClassesDirectory;
}
+ @Override
public File getReportsDirectory()
{
return reportsDirectory;
}
+ @Override
public void setReportsDirectory( File reportsDirectory )
{
this.reportsDirectory = reportsDirectory;
}
+ @Override
public Boolean getFailIfNoTests()
{
return failIfNoTests;
}
+ @Override
public void setFailIfNoTests( boolean failIfNoTests )
{
this.failIfNoTests = failIfNoTests;
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java
index 7993a055dc..c5623c1ef8 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java
@@ -1 +1,104 @@
-package org.apache.maven.plugin.failsafe.xmlsummary;
/*
* 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.suite.RunResult;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
/**
* @author Tibor Digana (tibor17)
* @since 2.20
*/
public final class FailsafeSummaryXmlUtils
{
public static final Charset UTF8 = Charset.forName( "UTF-8" );
private FailsafeSummaryXmlUtils()
{
throw new IllegalStateException( "No instantiable constructor." );
}
public static RunResult toRunResult( File failsafeSummaryXml ) throws JAXBException
{
FailsafeSummary failsafeSummary = JAXB.unmarshal( failsafeSummaryXml, FailsafeSummary.class );
return new RunResult( failsafeSummary.getCompleted(), failsafeSummary.getErrors(),
failsafeSummary.getFailures(), failsafeSummary.getSkipped(),
failsafeSummary.getFailureMessage(), failsafeSummary.isTimeout()
);
}
public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml )
throws JAXBException, IOException
{
fromRunResultToFile( fromRunResult, toFailsafeSummaryXml, UTF8 );
}
public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml, Charset encoding )
throws JAXBException, IOException
{
FailsafeSummary summary = new FailsafeSummary();
summary.setCompleted( fromRunResult.getCompletedCount() );
summary.setFailureMessage( fromRunResult.getFailure() );
summary.setErrors( fromRunResult.getErrors() );
summary.setFailures( fromRunResult.getFailures() );
summary.setSkipped( fromRunResult.getSkipped() );
summary.setTimeout( fromRunResult.isTimeout() );
summary.setResult( ErrorType.fromValue( fromRunResult.getFailsafeCode() ) );
String unmarshalled = JAXB.marshal( summary, encoding );
OutputStreamWriter os = new OutputStreamWriter( new FileOutputStream( toFailsafeSummaryXml ), encoding );
try
{
os.write( unmarshalled );
os.flush();
}
finally
{
os.close();
}
}
public static void writeSummary( RunResult mergedSummary, File mergedSummaryFile, boolean inProgress,
Charset encoding )
throws IOException, JAXBException
{
if ( !mergedSummaryFile.getParentFile().isDirectory() )
{
//noinspection ResultOfMethodCallIgnored
mergedSummaryFile.getParentFile().mkdirs();
}
if ( mergedSummaryFile.exists() && inProgress )
{
RunResult runResult = toRunResult( mergedSummaryFile );
mergedSummary = mergedSummary.aggregate( runResult );
}
fromRunResultToFile( mergedSummary, mergedSummaryFile, encoding );
}
}
\ No newline at end of file
+package org.apache.maven.plugin.failsafe.xmlsummary;
+
+/*
+ * 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.suite.RunResult;
+
+import javax.xml.bind.JAXBException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+
+import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8;
+
+/**
+ * @author Tibor Digana (tibor17)
+ * @since 2.20
+ */
+public final class FailsafeSummaryXmlUtils
+{
+ private FailsafeSummaryXmlUtils()
+ {
+ throw new IllegalStateException( "No instantiable constructor." );
+ }
+
+ public static RunResult toRunResult( File failsafeSummaryXml ) throws JAXBException
+ {
+ FailsafeSummary failsafeSummary = JAXB.unmarshal( failsafeSummaryXml, FailsafeSummary.class );
+
+ return new RunResult( failsafeSummary.getCompleted(), failsafeSummary.getErrors(),
+ failsafeSummary.getFailures(), failsafeSummary.getSkipped(),
+ failsafeSummary.getFailureMessage(), failsafeSummary.isTimeout()
+ );
+ }
+
+ public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml )
+ throws JAXBException, IOException
+ {
+ fromRunResultToFile( fromRunResult, toFailsafeSummaryXml, UTF_8 );
+ }
+
+ public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml, Charset encoding )
+ throws JAXBException, IOException
+ {
+ FailsafeSummary summary = new FailsafeSummary();
+ summary.setCompleted( fromRunResult.getCompletedCount() );
+ summary.setFailureMessage( fromRunResult.getFailure() );
+ summary.setErrors( fromRunResult.getErrors() );
+ summary.setFailures( fromRunResult.getFailures() );
+ summary.setSkipped( fromRunResult.getSkipped() );
+ summary.setTimeout( fromRunResult.isTimeout() );
+ summary.setResult( ErrorType.fromValue( fromRunResult.getFailsafeCode() ) );
+
+ String unmarshalled = JAXB.marshal( summary, encoding );
+
+ OutputStreamWriter os = new OutputStreamWriter( new FileOutputStream( toFailsafeSummaryXml ), encoding );
+ try
+ {
+ os.write( unmarshalled );
+ os.flush();
+ }
+ finally
+ {
+ os.close();
+ }
+ }
+
+ public static void writeSummary( RunResult mergedSummary, File mergedSummaryFile, boolean inProgress,
+ Charset encoding )
+ throws IOException, JAXBException
+ {
+ if ( !mergedSummaryFile.getParentFile().isDirectory() )
+ {
+ //noinspection ResultOfMethodCallIgnored
+ mergedSummaryFile.getParentFile().mkdirs();
+ }
+
+ if ( mergedSummaryFile.exists() && inProgress )
+ {
+ RunResult runResult = toRunResult( mergedSummaryFile );
+ mergedSummary = mergedSummary.aggregate( runResult );
+ }
+
+ fromRunResultToFile( mergedSummary, mergedSummaryFile, encoding );
+ }
+}
diff --git a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/MarshallerUnmarshallerTest.java b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/MarshallerUnmarshallerTest.java
index 4386d71754..a4487253a7 100644
--- a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/MarshallerUnmarshallerTest.java
+++ b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/MarshallerUnmarshallerTest.java
@@ -1 +1,131 @@
-package org.apache.maven.plugin.failsafe;
/*
* 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.failsafe.xmlsummary.FailsafeSummary;
import org.apache.maven.plugin.failsafe.xmlsummary.FailsafeSummaryXmlUtils;
import org.apache.maven.plugin.failsafe.xmlsummary.JAXB;
import org.junit.Test;
import java.io.File;
import java.io.FileWriter;
import java.util.List;
import static org.apache.maven.plugin.failsafe.xmlsummary.ErrorType.FAILURE;
import static org.fest.assertions.Assertions.assertThat;
public class MarshallerUnmarshallerTest
{
@Test
public void shouldUnmarshallExistingXmlFile() throws Exception
{
File xml = new File( "target/test-classes/org/apache/maven/plugin/failsafe/failsafe-summary.xml" );
FailsafeSummary summary = JAXB.unmarshal( xml, FailsafeSummary.class );
assertThat( summary.getCompleted() )
.isEqualTo( 7 );
assertThat( summary.getErrors() )
.isEqualTo( 1 );
assertThat( summary.getFailures() )
.isEqualTo( 2 );
assertThat( summary.getSkipped() )
.isEqualTo( 3 );
assertThat( summary.getFailureMessage() )
.contains( "There was an error in the forked processtest "
+ "subsystem#no method RuntimeException Hi There!"
);
assertThat( summary.getFailureMessage() )
.contains( "There was an error in the forked processtest "
+ "subsystem#no method RuntimeException Hi There!"
+ "\n\tat org.apache.maven.plugin.surefire.booterclient.ForkStarter"
+ ".awaitResultsDone(ForkStarter.java:489)"
);
List exceptionMessages = summary.extractExceptionMessageLines();
assertThat( exceptionMessages )
.hasSize( 1 );
assertThat( exceptionMessages.get( 0 ) )
.isEqualTo( "ExecutionException There was an error in the forked processtest "
+ "subsystem#no method RuntimeException Hi There!"
);
summary.setFailureMessage( null );
assertThat( summary.extractExceptionMessageLines() )
.isEmpty();
}
@Test
public void shouldEqualTwoSameXml() throws Exception
{
File xml = new File( "target/test-classes/org/apache/maven/plugin/failsafe/failsafe-summary.xml" );
FailsafeSummary summary1 = JAXB.unmarshal( xml, FailsafeSummary.class );
FailsafeSummary summary2 = JAXB.unmarshal( xml, FailsafeSummary.class );
assertThat( summary1 )
.isEqualTo( summary2 );
}
@Test
public void shouldMarshallAndUnmarshallSameXml() throws Exception
{
FailsafeSummary expected = new FailsafeSummary();
expected.setResult( FAILURE );
expected.setTimeout( true );
expected.setCompleted( 7 );
expected.setErrors( 1 );
expected.setFailures( 2 );
expected.setSkipped( 3 );
expected.setFailureMessage( "There was an error in the forked processtest "
+ "subsystem#no method RuntimeException Hi There!"
+ "\n\tat org.apache.maven.plugin.surefire.booterclient.ForkStarter"
+ ".awaitResultsDone(ForkStarter.java:489)"
);
File xml = File.createTempFile( "failsafe-summary", ".xml" );
String xmlText = JAXB.marshal( expected, FailsafeSummaryXmlUtils.UTF8 );
FileWriter fileWriter = new FileWriter( xml );
fileWriter.write( xmlText );
fileWriter.flush();
fileWriter.close();
FailsafeSummary actual = JAXB.unmarshal( xml, FailsafeSummary.class );
assertThat( actual )
.isEqualTo( expected );
List exceptionMessages = actual.extractExceptionMessageLines();
assertThat( exceptionMessages )
.hasSize( 1 );
assertThat( exceptionMessages.get( 0 ) )
.isEqualTo( "There was an error in the forked processtest "
+ "subsystem#no method RuntimeException Hi There!"
);
}
}
\ No newline at end of file
+package org.apache.maven.plugin.failsafe;
+
+/*
+ * 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.failsafe.xmlsummary.FailsafeSummary;
+import org.apache.maven.plugin.failsafe.xmlsummary.JAXB;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.util.List;
+
+import static org.apache.maven.plugin.failsafe.xmlsummary.ErrorType.FAILURE;
+import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8;
+import static org.fest.assertions.Assertions.assertThat;
+
+public class MarshallerUnmarshallerTest
+{
+ @Test
+ public void shouldUnmarshallExistingXmlFile() throws Exception
+ {
+ File xml = new File( "target/test-classes/org/apache/maven/plugin/failsafe/failsafe-summary.xml" );
+ FailsafeSummary summary = JAXB.unmarshal( xml, FailsafeSummary.class );
+
+ assertThat( summary.getCompleted() )
+ .isEqualTo( 7 );
+
+ assertThat( summary.getErrors() )
+ .isEqualTo( 1 );
+
+ assertThat( summary.getFailures() )
+ .isEqualTo( 2 );
+
+ assertThat( summary.getSkipped() )
+ .isEqualTo( 3 );
+
+ assertThat( summary.getFailureMessage() )
+ .contains( "There was an error in the forked processtest "
+ + "subsystem#no method RuntimeException Hi There!"
+ );
+
+ assertThat( summary.getFailureMessage() )
+ .contains( "There was an error in the forked processtest "
+ + "subsystem#no method RuntimeException Hi There!"
+ + "\n\tat org.apache.maven.plugin.surefire.booterclient.ForkStarter"
+ + ".awaitResultsDone(ForkStarter.java:489)"
+ );
+
+ List exceptionMessages = summary.extractExceptionMessageLines();
+
+ assertThat( exceptionMessages )
+ .hasSize( 1 );
+
+ assertThat( exceptionMessages.get( 0 ) )
+ .isEqualTo( "ExecutionException There was an error in the forked processtest "
+ + "subsystem#no method RuntimeException Hi There!"
+ );
+
+ summary.setFailureMessage( null );
+
+ assertThat( summary.extractExceptionMessageLines() )
+ .isEmpty();
+ }
+
+ @Test
+ public void shouldEqualTwoSameXml() throws Exception
+ {
+ File xml = new File( "target/test-classes/org/apache/maven/plugin/failsafe/failsafe-summary.xml" );
+ FailsafeSummary summary1 = JAXB.unmarshal( xml, FailsafeSummary.class );
+ FailsafeSummary summary2 = JAXB.unmarshal( xml, FailsafeSummary.class );
+
+ assertThat( summary1 )
+ .isEqualTo( summary2 );
+ }
+
+ @Test
+ public void shouldMarshallAndUnmarshallSameXml() throws Exception
+ {
+ FailsafeSummary expected = new FailsafeSummary();
+ expected.setResult( FAILURE );
+ expected.setTimeout( true );
+ expected.setCompleted( 7 );
+ expected.setErrors( 1 );
+ expected.setFailures( 2 );
+ expected.setSkipped( 3 );
+ expected.setFailureMessage( "There was an error in the forked processtest "
+ + "subsystem#no method RuntimeException Hi There!"
+ + "\n\tat org.apache.maven.plugin.surefire.booterclient.ForkStarter"
+ + ".awaitResultsDone(ForkStarter.java:489)"
+ );
+
+ File xml = File.createTempFile( "failsafe-summary", ".xml" );
+ String xmlText = JAXB.marshal( expected, UTF_8 );
+ FileWriter fileWriter = new FileWriter( xml );
+ fileWriter.write( xmlText );
+ fileWriter.flush();
+ fileWriter.close();
+
+ FailsafeSummary actual = JAXB.unmarshal( xml, FailsafeSummary.class );
+
+ assertThat( actual )
+ .isEqualTo( expected );
+
+ List exceptionMessages = actual.extractExceptionMessageLines();
+
+ assertThat( exceptionMessages )
+ .hasSize( 1 );
+
+ assertThat( exceptionMessages.get( 0 ) )
+ .isEqualTo( "There was an error in the forked processtest "
+ + "subsystem#no method RuntimeException Hi There!"
+ );
+ }
+}
diff --git a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java
index fa7ac8e788..811c53892c 100644
--- a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java
+++ b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/RunResultTest.java
@@ -1 +1,154 @@
-package org.apache.maven.plugin.failsafe;
/*
* 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.failsafe.xmlsummary.FailsafeSummaryXmlUtils;
import org.apache.maven.surefire.suite.RunResult;
import org.junit.Test;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import static org.fest.assertions.Assertions.assertThat;
/**
* @author Tibor Digana (tibor17)
* @since 2.20
*/
public class RunResultTest
{
@Test
public void testAggregatedValues()
{
RunResult simple = getSimpleAggregate();
assertThat( simple.getCompletedCount() )
.isEqualTo( 20 );
assertThat( simple.getErrors() )
.isEqualTo( 3 );
assertThat( simple.getFailures() )
.isEqualTo( 7 );
assertThat( simple.getSkipped() )
.isEqualTo( 4 );
assertThat( simple.getFlakes() )
.isEqualTo( 2 );
}
@Test
public void testSerialization()
throws IOException, JAXBException
{
writeReadCheck( getSimpleAggregate() );
}
@Test
public void testFailures()
throws IOException, JAXBException
{
writeReadCheck( new RunResult( 0, 1, 2, 3, "stacktraceHere", false ) );
}
@Test
public void testSkipped()
throws IOException, JAXBException
{
writeReadCheck( new RunResult( 3, 2, 1, 0, null, true ) );
}
@Test
public void testAppendSerialization()
throws IOException, JAXBException
{
RunResult simpleAggregate = getSimpleAggregate();
RunResult additional = new RunResult( 2, 1, 2, 2, "msg " + ( (char) 0x0E01 ), true );
File summary = File.createTempFile( "failsafe", "test" );
FailsafeSummaryXmlUtils.writeSummary( simpleAggregate, summary, false, FailsafeSummaryXmlUtils.UTF8 );
FailsafeSummaryXmlUtils.writeSummary( additional, summary, true, FailsafeSummaryXmlUtils.UTF8 );
RunResult actual = FailsafeSummaryXmlUtils.toRunResult( summary );
//noinspection ResultOfMethodCallIgnored
summary.delete();
RunResult expected = simpleAggregate.aggregate( additional );
assertThat( expected.getCompletedCount() )
.isEqualTo( 22 );
assertThat( expected.getErrors() )
.isEqualTo( 4 );
assertThat( expected.getFailures() )
.isEqualTo( 9 );
assertThat( expected.getSkipped() )
.isEqualTo( 6 );
assertThat( expected.getFlakes() )
.isEqualTo( 2 );
assertThat( expected.getFailure() )
.isEqualTo( "msg " + ( (char) 0x0E01 ) );
assertThat( expected.isTimeout() )
.isTrue();
assertThat( actual )
.isEqualTo( expected );
}
@Test
public void shouldAcceptAliasCharset()
{
Charset charset1 = IntegrationTestMojo.toCharset( "UTF8" );
assertThat( charset1.name() ).isEqualTo( "UTF-8" );
Charset charset2 = IntegrationTestMojo.toCharset( "utf8" );
assertThat( charset2.name() ).isEqualTo( "UTF-8" );
}
private void writeReadCheck( RunResult expected )
throws IOException, JAXBException
{
File tmp = File.createTempFile( "test", "xml" );
FailsafeSummaryXmlUtils.fromRunResultToFile( expected, tmp );
RunResult actual = FailsafeSummaryXmlUtils.toRunResult( tmp );
//noinspection ResultOfMethodCallIgnored
tmp.delete();
assertThat( actual )
.isEqualTo( expected );
}
private RunResult getSimpleAggregate()
{
RunResult resultOne = new RunResult( 10, 1, 3, 2, 1 );
RunResult resultTwo = new RunResult( 10, 2, 4, 2, 1 );
return resultOne.aggregate( resultTwo );
}
}
\ No newline at end of file
+package org.apache.maven.plugin.failsafe;
+
+/*
+ * 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.failsafe.xmlsummary.FailsafeSummaryXmlUtils;
+import org.apache.maven.surefire.suite.RunResult;
+import org.junit.Test;
+
+import javax.xml.bind.JAXBException;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+
+import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8;
+import static org.fest.assertions.Assertions.assertThat;
+
+/**
+ * @author Tibor Digana (tibor17)
+ * @since 2.20
+ */
+public class RunResultTest
+{
+
+ @Test
+ public void testAggregatedValues()
+ {
+ RunResult simple = getSimpleAggregate();
+
+ assertThat( simple.getCompletedCount() )
+ .isEqualTo( 20 );
+
+ assertThat( simple.getErrors() )
+ .isEqualTo( 3 );
+
+ assertThat( simple.getFailures() )
+ .isEqualTo( 7 );
+
+ assertThat( simple.getSkipped() )
+ .isEqualTo( 4 );
+
+ assertThat( simple.getFlakes() )
+ .isEqualTo( 2 );
+ }
+
+ @Test
+ public void testSerialization()
+ throws IOException, JAXBException
+ {
+ writeReadCheck( getSimpleAggregate() );
+ }
+
+ @Test
+ public void testFailures()
+ throws IOException, JAXBException
+ {
+ writeReadCheck( new RunResult( 0, 1, 2, 3, "stacktraceHere", false ) );
+ }
+
+ @Test
+ public void testSkipped()
+ throws IOException, JAXBException
+ {
+ writeReadCheck( new RunResult( 3, 2, 1, 0, null, true ) );
+ }
+
+ @Test
+ public void testAppendSerialization()
+ throws IOException, JAXBException
+ {
+ RunResult simpleAggregate = getSimpleAggregate();
+ RunResult additional = new RunResult( 2, 1, 2, 2, "msg " + ( (char) 0x0E01 ), true );
+
+ File summary = File.createTempFile( "failsafe", "test" );
+ FailsafeSummaryXmlUtils.writeSummary( simpleAggregate, summary, false, UTF_8 );
+ FailsafeSummaryXmlUtils.writeSummary( additional, summary, true, UTF_8 );
+ RunResult actual = FailsafeSummaryXmlUtils.toRunResult( summary );
+ //noinspection ResultOfMethodCallIgnored
+ summary.delete();
+
+ RunResult expected = simpleAggregate.aggregate( additional );
+
+ assertThat( expected.getCompletedCount() )
+ .isEqualTo( 22 );
+
+ assertThat( expected.getErrors() )
+ .isEqualTo( 4 );
+
+ assertThat( expected.getFailures() )
+ .isEqualTo( 9 );
+
+ assertThat( expected.getSkipped() )
+ .isEqualTo( 6 );
+
+ assertThat( expected.getFlakes() )
+ .isEqualTo( 2 );
+
+ assertThat( expected.getFailure() )
+ .isEqualTo( "msg " + ( (char) 0x0E01 ) );
+
+ assertThat( expected.isTimeout() )
+ .isTrue();
+
+ assertThat( actual )
+ .isEqualTo( expected );
+ }
+
+ @Test
+ public void shouldAcceptAliasCharset()
+ {
+ Charset charset1 = IntegrationTestMojo.toCharset( "UTF8" );
+ assertThat( charset1.name() ).isEqualTo( "UTF-8" );
+
+ Charset charset2 = IntegrationTestMojo.toCharset( "utf8" );
+ assertThat( charset2.name() ).isEqualTo( "UTF-8" );
+ }
+
+ private void writeReadCheck( RunResult expected )
+ throws IOException, JAXBException
+ {
+ File tmp = File.createTempFile( "test", "xml" );
+ FailsafeSummaryXmlUtils.fromRunResultToFile( expected, tmp );
+
+ RunResult actual = FailsafeSummaryXmlUtils.toRunResult( tmp );
+ //noinspection ResultOfMethodCallIgnored
+ tmp.delete();
+
+ assertThat( actual )
+ .isEqualTo( expected );
+ }
+
+ private RunResult getSimpleAggregate()
+ {
+ RunResult resultOne = new RunResult( 10, 1, 3, 2, 1 );
+ RunResult resultTwo = new RunResult( 10, 2, 4, 2, 1 );
+ return resultOne.aggregate( resultTwo );
+ }
+}
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 16c25ecca4..f2c32d01cb 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
@@ -710,10 +710,12 @@ public abstract class AbstractSurefireMojo
protected abstract int getRerunFailingTestsCount();
+ @Override
public abstract List getIncludes();
public abstract File getIncludesFile();
+ @Override
public abstract void setIncludes( List includes );
public abstract File getExcludesFile();
@@ -761,6 +763,7 @@ private String getDefaultExcludes()
private volatile PluginConsoleLogger consoleLogger;
+ @Override
public void execute()
throws MojoExecutionException, MojoFailureException
{
@@ -2544,21 +2547,25 @@ final class TestNgProviderInfo
this.testNgArtifact = testNgArtifact;
}
+ @Override
@Nonnull public String getProviderName()
{
return "org.apache.maven.surefire.testng.TestNGProvider";
}
+ @Override
public boolean isApplicable()
{
return testNgArtifact != null;
}
+ @Override
public void addProviderProperties() throws MojoExecutionException
{
convertTestNGParameters();
}
+ @Override
public Classpath getProviderClasspath()
throws ArtifactResolutionException, ArtifactNotFoundException
{
@@ -2571,20 +2578,24 @@ public Classpath getProviderClasspath()
final class JUnit3ProviderInfo
implements ProviderInfo
{
+ @Override
@Nonnull public String getProviderName()
{
return "org.apache.maven.surefire.junit.JUnit3Provider";
}
+ @Override
public boolean isApplicable()
{
return true;
}
+ @Override
public void addProviderProperties() throws MojoExecutionException
{
}
+ @Override
public Classpath getProviderClasspath()
throws ArtifactResolutionException, ArtifactNotFoundException
{
@@ -2609,20 +2620,24 @@ final class JUnit4ProviderInfo
this.junitDepArtifact = junitDepArtifact;
}
+ @Override
@Nonnull public String getProviderName()
{
return "org.apache.maven.surefire.junit4.JUnit4Provider";
}
+ @Override
public boolean isApplicable()
{
return junitDepArtifact != null || isAnyJunit4( junitArtifact );
}
+ @Override
public void addProviderProperties() throws MojoExecutionException
{
}
+ @Override
public Classpath getProviderClasspath()
throws ArtifactResolutionException, ArtifactNotFoundException
{
@@ -2645,6 +2660,7 @@ final class JUnitCoreProviderInfo
this.junitDepArtifact = junitDepArtifact;
}
+ @Override
@Nonnull public String getProviderName()
{
return "org.apache.maven.surefire.junitcore.JUnitCoreProvider";
@@ -2655,6 +2671,7 @@ private boolean is47CompatibleJunitDep()
return junitDepArtifact != null && isJunit47Compatible( junitDepArtifact );
}
+ @Override
public boolean isApplicable()
{
final boolean isJunitArtifact47 = isAnyJunit4( junitArtifact ) && isJunit47Compatible( junitArtifact );
@@ -2662,12 +2679,14 @@ public boolean isApplicable()
return isAny47ProvidersForcers && ( isJunitArtifact47 || is47CompatibleJunitDep() );
}
+ @Override
public void addProviderProperties() throws MojoExecutionException
{
convertJunitCoreParameters();
convertGroupParameters();
}
+ @Override
public Classpath getProviderClasspath()
throws ArtifactResolutionException, ArtifactNotFoundException
{
@@ -2689,22 +2708,26 @@ final class DynamicProviderInfo
this.providerName = providerName;
}
+ @Override
public ProviderInfo instantiate( String providerName )
{
return new DynamicProviderInfo( providerName );
}
+ @Override
@Nonnull
public String getProviderName()
{
return providerName;
}
+ @Override
public boolean isApplicable()
{
return true;
}
+ @Override
public void addProviderProperties() throws MojoExecutionException
{
// Ok this is a bit lazy.
@@ -2712,6 +2735,7 @@ public void addProviderProperties() throws MojoExecutionException
convertTestNGParameters();
}
+ @Override
public Classpath getProviderClasspath()
throws ArtifactResolutionException, ArtifactNotFoundException
{
@@ -2790,21 +2814,25 @@ private ProviderInfo findByName( String providerClassName )
}
}
+ @Override
public List getExcludes()
{
return excludes;
}
+ @Override
public void setExcludes( List excludes )
{
this.excludes = excludes;
}
+ @Override
public ArtifactRepository getLocalRepository()
{
return localRepository;
}
+ @Override
public void setLocalRepository( ArtifactRepository localRepository )
{
this.localRepository = localRepository;
@@ -3259,11 +3287,13 @@ public void setProject( MavenProject project )
this.project = project;
}
+ @Override
public File getTestSourceDirectory()
{
return testSourceDirectory;
}
+ @Override
public void setTestSourceDirectory( File testSourceDirectory )
{
this.testSourceDirectory = testSourceDirectory;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
index 3663f3978d..fd2b4fb42b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
@@ -92,6 +92,7 @@ public synchronized void clear()
super.clear();
}
+ @Override
public synchronized Enumeration keys()
{
return Collections.enumeration( items );
@@ -170,6 +171,7 @@ public static void copyProperties( Properties target, Map source
}
}
+ @Override
public void copyTo( Map target )
{
target.putAll( this );
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
index cc6a80801f..5931f9ee38 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
@@ -19,15 +19,17 @@
* under the License.
*/
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+
import java.io.File;
-import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
+
+import static org.apache.maven.surefire.util.internal.StringUtils.ISO_8859_1;
/**
* @author Kristian Rosenvold
@@ -153,7 +155,7 @@ public String getSha1()
{
MessageDigest md = MessageDigest.getInstance( "SHA-1" );
String configValue = getConfig();
- md.update( configValue.getBytes( "iso-8859-1" ), 0, configValue.length() );
+ md.update( configValue.getBytes( ISO_8859_1 ), 0, configValue.length() );
byte[] sha1hash = md.digest();
return asHexString( sha1hash );
}
@@ -161,10 +163,6 @@ public String getSha1()
{
throw new RuntimeException( e );
}
- catch ( UnsupportedEncodingException e )
- {
- throw new RuntimeException( e );
- }
}
}
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 b3a3f91b0a..c46cfb6767 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
@@ -54,7 +54,6 @@
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
-import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
@@ -98,7 +97,7 @@
import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThread;
import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThreadFactory;
import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
-import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
+import static org.apache.maven.surefire.util.internal.StringUtils.ISO_8859_1;
/**
* Starts the fork or runs in-process.
@@ -180,6 +179,7 @@ public CloseableCloser( int jvmRun, Closeable... testProvidingInputStream )
}
}
+ @Override
@SuppressWarnings( "checkstyle:innerassignment" )
public void run()
{
@@ -205,6 +205,7 @@ public void run()
}
}
+ @Override
public void close()
{
run();
@@ -340,6 +341,7 @@ private RunResult runSuitesForkOnceMultiple( final SurefireProperties effectiveS
{
Callable pf = new Callable()
{
+ @Override
public RunResult call()
throws Exception
{
@@ -404,6 +406,7 @@ private RunResult runSuitesForkPerTestSet( final SurefireProperties effectiveSys
{
Callable pf = new Callable()
{
+ @Override
public RunResult call()
throws Exception
{
@@ -618,8 +621,7 @@ private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkC
CommandLineCallable future =
executeCommandLineAsCallable( cli, testProvidingInputStream, threadedStreamConsumer,
- stdErrConsumer, 0, closer,
- Charset.forName( FORK_STREAM_CHARSET_NAME ) );
+ stdErrConsumer, 0, closer, ISO_8859_1 );
currentForkClients.add( forkClient );
@@ -719,6 +721,7 @@ private static Thread createImmediateShutdownHookThread( final TestLessInputStre
{
return SHUTDOWN_HOOK_THREAD_FACTORY.newThread( new Runnable()
{
+ @Override
public void run()
{
builder.getImmediateCommands().shutdown( shutdownType );
@@ -731,6 +734,7 @@ private static Thread createCachableShutdownHookThread( final TestLessInputStrea
{
return SHUTDOWN_HOOK_THREAD_FACTORY.newThread( new Runnable()
{
+ @Override
public void run()
{
builder.getCachableCommands().shutdown( shutdownType );
@@ -743,6 +747,7 @@ private static Thread createShutdownHookThread( final Iterable triggerPingTimerForShutdown( final TestLessInputStrea
{
return pingThreadScheduler.scheduleAtFixedRate( new Runnable()
{
+ @Override
public void run()
{
builder.getImmediateCommands().noop();
@@ -780,6 +786,7 @@ private ScheduledFuture> triggerPingTimerForShutdown( final Iterable triggerTimeoutCheck()
{
return timeoutCheckScheduler.scheduleAtFixedRate( new Runnable()
{
+ @Override
public void run()
{
long systemTime = currentTimeMillis();
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 0abf42fa2f..eb1ab5b61a 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
@@ -48,6 +48,7 @@ private OutputStreamFlushReceiver( OutputStream outputStream )
this.outputStream = outputStream;
}
+ @Override
public void flush()
throws IOException
{
@@ -71,6 +72,7 @@ public Process execute()
return process;
}
+ @Override
public FlushReceiver getFlushReceiver()
{
return flushReceiver;
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestLessInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestLessInputStream.java
index d0ae47a56d..521130c2ef 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestLessInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestLessInputStream.java
@@ -62,10 +62,12 @@ private TestLessInputStream( TestLessInputStreamBuilder builder )
this.builder = builder;
}
+ @Override
public void provideNewTest()
{
}
+ @Override
public void skipSinceNextTest()
{
if ( canContinue() )
@@ -75,6 +77,7 @@ public void skipSinceNextTest()
}
}
+ @Override
public void shutdown( Shutdown shutdownType )
{
if ( canContinue() )
@@ -84,6 +87,7 @@ public void shutdown( Shutdown shutdownType )
}
}
+ @Override
public void noop()
{
if ( canContinue() )
@@ -186,6 +190,7 @@ public TestLessInputStreamBuilder()
{
iterableCachable = new Iterable()
{
+ @Override
public Iterator iterator()
{
return new CIt();
@@ -270,11 +275,13 @@ private final class CIt
{
private Node node = TestLessInputStreamBuilder.this.head;
+ @Override
public boolean hasNext()
{
return examineNext( false ) != null;
}
+ @Override
public Command next()
{
Command command = examineNext( true );
@@ -285,6 +292,7 @@ public Command next()
return command;
}
+ @Override
public void remove()
{
throw new UnsupportedOperationException();
@@ -307,10 +315,12 @@ private Command examineNext( boolean store )
private final class ImmediateCommands
implements NotifiableTestStream
{
+ @Override
public void provideNewTest()
{
}
+ @Override
public void skipSinceNextTest()
{
Lock lock = rwLock.readLock();
@@ -328,6 +338,7 @@ public void skipSinceNextTest()
}
}
+ @Override
public void shutdown( Shutdown shutdownType )
{
Lock lock = rwLock.readLock();
@@ -345,6 +356,7 @@ public void shutdown( Shutdown shutdownType )
}
}
+ @Override
public void noop()
{
Lock lock = rwLock.readLock();
@@ -387,10 +399,12 @@ public void acknowledgeByeEventReceived()
private final class CachableCommands
implements NotifiableTestStream
{
+ @Override
public void provideNewTest()
{
}
+ @Override
public void skipSinceNextTest()
{
Lock lock = rwLock.readLock();
@@ -408,6 +422,7 @@ public void skipSinceNextTest()
}
}
+ @Override
public void shutdown( Shutdown shutdownType )
{
Lock lock = rwLock.readLock();
@@ -425,6 +440,7 @@ public void shutdown( Shutdown shutdownType )
}
}
+ @Override
public void noop()
{
Lock lock = rwLock.readLock();
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index 69f73a2ede..35cb2d428a 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -82,6 +82,7 @@ void testSetFinished()
}
}
+ @Override
public void skipSinceNextTest()
{
if ( canContinue() )
@@ -91,6 +92,7 @@ public void skipSinceNextTest()
}
}
+ @Override
public void shutdown( Shutdown shutdownType )
{
if ( canContinue() )
@@ -100,6 +102,7 @@ public void shutdown( Shutdown shutdownType )
}
}
+ @Override
public void noop()
{
if ( canContinue() )
@@ -150,6 +153,7 @@ protected boolean isClosed()
/**
* Signal that a new test is to be provided.
*/
+ @Override
public void provideNewTest()
{
if ( canContinue() )
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
index 952feb8d5a..b5a53b4c47 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
@@ -46,22 +46,26 @@ public DeserializedStacktraceWriter( String message, String smartTrimmed, String
this.stackTrace = stackTrace;
}
+ @Override
public String smartTrimmedStackTrace()
{
return smartTrimmed;
}
// Trimming or not is decided on the forking side
+ @Override
public String writeTraceToString()
{
return stackTrace;
}
+ @Override
public String writeTrimmedTraceToString()
{
return stackTrace;
}
+ @Override
public SafeThrowable getThrowable()
{
return new SafeThrowable( message );
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 7aaa0f1ee7..b02ae540a6 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
@@ -151,6 +151,7 @@ public final DefaultReporterFactory getDefaultReporterFactory()
return defaultReporterFactory;
}
+ @Override
public final void consumeLine( String s )
{
if ( isNotBlank( s ) )
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 0ddc39224b..d4605838c7 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
@@ -39,6 +39,7 @@ public NativeStdErrStreamConsumer( DefaultReporterFactory defaultReporterFactory
this.defaultReporterFactory = defaultReporterFactory;
}
+ @Override
public void consumeLine( String line )
{
InPluginProcessDumpSingleton.getSingleton().dumpText( line, defaultReporterFactory );
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 ff9c238ed2..972eaa7465 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
@@ -73,6 +73,7 @@ final class Pumper
* e.g. acquire-next-test which means that {@link ForkClient} could hang on waiting for old test to complete
* and therefore the plugin could be permanently in progress.
*/
+ @Override
public void run()
{
while ( !ThreadedStreamConsumer.this.stop.get() )
@@ -111,6 +112,7 @@ public ThreadedStreamConsumer( StreamConsumer target )
thread.start();
}
+ @Override
public void consumeLine( String s )
{
if ( stop.get() && !thread.isAlive() )
@@ -130,6 +132,7 @@ public void consumeLine( String s )
}
}
+ @Override
public void close()
throws IOException
{
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java
index d93813ebbf..0f1217cf2e 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java
@@ -45,6 +45,7 @@ public boolean isDebugEnabled()
return mojoLogger.isDebugEnabled();
}
+ @Override
public void debug( String message )
{
if ( mojoLogger.isDebugEnabled() )
@@ -66,6 +67,7 @@ public boolean isInfoEnabled()
return mojoLogger.isInfoEnabled();
}
+ @Override
public void info( String message )
{
if ( mojoLogger.isInfoEnabled() )
@@ -79,6 +81,7 @@ public boolean isWarnEnabled()
return mojoLogger.isWarnEnabled();
}
+ @Override
public void warning( String message )
{
if ( mojoLogger.isWarnEnabled() )
@@ -100,6 +103,7 @@ public boolean isErrorEnabled()
return mojoLogger.isErrorEnabled();
}
+ @Override
public void error( String message )
{
if ( mojoLogger.isErrorEnabled() )
@@ -108,6 +112,7 @@ public void error( String message )
}
}
+ @Override
public void error( String message, Throwable t )
{
if ( mojoLogger.isErrorEnabled() )
@@ -116,6 +121,7 @@ public void error( String message, Throwable t )
}
}
+ @Override
public void error( Throwable t )
{
if ( mojoLogger.isErrorEnabled() )
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
index f9e59fe87c..682686ca7e 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
@@ -52,16 +52,19 @@ public ConsoleOutputFileReporter( File reportsDirectory, String reportNameSuffix
this.reportNameSuffix = reportNameSuffix;
}
+ @Override
public void testSetStarting( ReportEntry reportEntry )
{
close();
reportEntryName = reportEntry.getName();
}
+ @Override
public void testSetCompleted( ReportEntry report )
{
}
+ @Override
@SuppressWarnings( "checkstyle:emptyblock" )
public void close()
{
@@ -79,6 +82,7 @@ public void close()
}
}
+ @Override
public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
{
try
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 b4a6f30f3f..3b8d765681 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
@@ -86,6 +86,7 @@ public DefaultReporterFactory( StartupReportConfiguration reportConfiguration, C
listeners = new ConcurrentLinkedQueue();
}
+ @Override
public RunListener createReporter()
{
TestSetRunListener testSetRunListener =
@@ -159,6 +160,7 @@ final void addListener( TestSetRunListener listener )
listeners.add( listener );
}
+ @Override
public RunResult close()
{
mergeTestHistoryResult();
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DirectConsoleOutput.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DirectConsoleOutput.java
index 25312aaebe..ab33cb8506 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DirectConsoleOutput.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DirectConsoleOutput.java
@@ -50,6 +50,7 @@ public DirectConsoleOutput( PrintStream sout, PrintStream serr )
}
+ @Override
public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
{
final PrintStream stream = stdout ? sout : serr;
@@ -64,14 +65,17 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
}
}
+ @Override
public void testSetStarting( ReportEntry reportEntry )
{
}
+ @Override
public void testSetCompleted( ReportEntry report )
{
}
+ @Override
public void close()
{
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleOutputReceiver.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleOutputReceiver.java
index e18f3aa5cb..327c77d46e 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleOutputReceiver.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullConsoleOutputReceiver.java
@@ -37,18 +37,22 @@ private NullConsoleOutputReceiver()
{
}
+ @Override
public void testSetStarting( ReportEntry reportEntry )
{
}
+ @Override
public void testSetCompleted( ReportEntry report )
{
}
+ @Override
public void close()
{
}
+ @Override
public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
{
}
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 397c4c165a..c57123e645 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
@@ -25,6 +25,7 @@
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.SafeThrowable;
+import org.apache.maven.surefire.util.internal.StringUtils;
import java.io.File;
import java.io.FileOutputStream;
@@ -32,8 +33,6 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -44,6 +43,7 @@
import static org.apache.maven.plugin.surefire.report.DefaultReporterFactory.TestResultType;
import static org.apache.maven.plugin.surefire.report.FileReporterUtils.stripIllegalFilenameChars;
+import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8;
import static org.apache.maven.surefire.util.internal.StringUtils.isBlank;
// CHECKSTYLE_OFF: LineLength
@@ -81,10 +81,6 @@
*/
public class StatelessXmlReporter
{
- private static final String ENCODING = "UTF-8";
-
- private static final Charset ENCODING_CS = Charset.forName( ENCODING );
-
private final File reportsDirectory;
private final String reportNameSuffix;
@@ -129,7 +125,7 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat
try
{
XMLWriter ppw = new PrettyPrintXMLWriter( fw );
- ppw.setEncoding( ENCODING );
+ ppw.setEncoding( StringUtils.UTF_8.name() );
createTestSuiteElement( ppw, testSetReportEntry, testSetStats, testSetReportEntry.elapsedTimeAsString() );
@@ -302,7 +298,7 @@ private FileOutputStream getOutputStream( WrappedReportEntry testSetReportEntry
private static OutputStreamWriter getWriter( FileOutputStream fos )
{
- return new OutputStreamWriter( fos, ENCODING_CS );
+ return new OutputStreamWriter( fos, UTF_8 );
}
private static void getAddMethodEntryList( Map> methodRunHistoryMap,
@@ -540,7 +536,7 @@ else if ( isIllegalEscape( b ) )
// there's nothing better we can do! :-(
// SUREFIRE-456
out.write( ByteConstantsHolder.AMP_BYTES );
- out.write( String.valueOf( b ).getBytes( ENCODING ) );
+ out.write( String.valueOf( b ).getBytes( UTF_8 ) );
out.write( ';' ); // & Will be encoded to amp inside xml encodingSHO
}
else
@@ -612,17 +608,10 @@ private static final class ByteConstantsHolder
static
{
- try
- {
- CDATA_START_BYTES = "".getBytes( ENCODING );
- CDATA_ESCAPE_STRING_BYTES = "]]>".getBytes( ENCODING );
- AMP_BYTES = "&#".getBytes( ENCODING );
- }
- catch ( UnsupportedEncodingException e )
- {
- throw new RuntimeException( e );
- }
+ CDATA_START_BYTES = "".getBytes( UTF_8 );
+ CDATA_ESCAPE_STRING_BYTES = "]]>".getBytes( UTF_8 );
+ AMP_BYTES = "&#".getBytes( UTF_8 );
}
}
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
index f0f996dd24..472586b9ae 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
@@ -86,36 +86,43 @@ public TestSetRunListener( ConsoleReporter consoleReporter, FileReporter fileRep
testMethodStats = new ArrayList();
}
+ @Override
public void debug( String message )
{
consoleReporter.getConsoleLogger().debug( trimTrailingNewLine( message ) );
}
+ @Override
public void info( String message )
{
consoleReporter.getConsoleLogger().info( trimTrailingNewLine( message ) );
}
+ @Override
public void warning( String message )
{
consoleReporter.getConsoleLogger().warning( trimTrailingNewLine( message ) );
}
+ @Override
public void error( String message )
{
consoleReporter.getConsoleLogger().error( trimTrailingNewLine( message ) );
}
+ @Override
public void error( String message, Throwable t )
{
consoleReporter.getConsoleLogger().error( message, t );
}
+ @Override
public void error( Throwable t )
{
consoleReporter.getConsoleLogger().error( t );
}
+ @Override
public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
{
try
@@ -136,6 +143,7 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
consoleOutputReceiver.writeTestOutput( buf, off, len, stdout );
}
+ @Override
public void testSetStarting( ReportEntry report )
{
detailsForThis.testSetStart();
@@ -149,6 +157,7 @@ public void clearCapture()
testStdErr = initDeferred( "stderr" );
}
+ @Override
public void testSetCompleted( ReportEntry report )
{
final WrappedReportEntry wrap = wrapTestSet( report );
@@ -173,11 +182,13 @@ public void testSetCompleted( ReportEntry report )
// Test
// ----------------------------------------------------------------------
+ @Override
public void testStarting( ReportEntry report )
{
detailsForThis.testStart();
}
+ @Override
public void testSucceeded( ReportEntry reportEntry )
{
WrappedReportEntry wrapped = wrap( reportEntry, SUCCESS );
@@ -186,6 +197,7 @@ public void testSucceeded( ReportEntry reportEntry )
clearCapture();
}
+ @Override
public void testError( ReportEntry reportEntry )
{
WrappedReportEntry wrapped = wrap( reportEntry, ERROR );
@@ -194,6 +206,7 @@ public void testError( ReportEntry reportEntry )
clearCapture();
}
+ @Override
public void testFailed( ReportEntry reportEntry )
{
WrappedReportEntry wrapped = wrap( reportEntry, FAILURE );
@@ -206,6 +219,7 @@ public void testFailed( ReportEntry reportEntry )
// Counters
// ----------------------------------------------------------------------
+ @Override
public void testSkipped( ReportEntry reportEntry )
{
WrappedReportEntry wrapped = wrap( reportEntry, SKIPPED );
@@ -215,10 +229,12 @@ public void testSkipped( ReportEntry reportEntry )
clearCapture();
}
+ @Override
public void testExecutionSkippedByUser()
{
}
+ @Override
public void testAssumptionFailure( ReportEntry report )
{
testSkipped( report );
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 954a2bb320..0aa00c7bba 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,13 +19,15 @@
* under the License.
*/
+import org.apache.commons.io.output.DeferredFileOutputStream;
+
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
-import org.apache.commons.io.output.DeferredFileOutputStream;
+import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8;
/**
* A deferred file output stream decorator that recodes the bytes written into the stream from the VM default encoding
@@ -39,8 +41,6 @@ class Utf8RecodingDeferredFileOutputStream
private boolean closed = false;
- private static final Charset UTF8 = Charset.forName( "UTF-8" );
-
@SuppressWarnings( "checkstyle:magicnumber" )
public Utf8RecodingDeferredFileOutputStream( String channel )
{
@@ -55,10 +55,10 @@ public synchronized void write( byte[] buf, int off, int len )
return;
}
- if ( !Charset.defaultCharset().equals( UTF8 ) )
+ if ( !Charset.defaultCharset().equals( UTF_8 ) )
{
CharBuffer decodedFromDefaultCharset = Charset.defaultCharset().decode( ByteBuffer.wrap( buf, off, len ) );
- ByteBuffer utf8Encoded = UTF8.encode( decodedFromDefaultCharset );
+ ByteBuffer utf8Encoded = UTF_8.encode( decodedFromDefaultCharset );
if ( utf8Encoded.hasArray() )
{
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
index 2394ff0b33..439fdec2e5 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
@@ -51,6 +51,7 @@ public WrappedReportEntry( ReportEntry original, ReportEntryType reportEntryType
this.stdErr = stdErr;
}
+ @Override
public Integer getElapsed()
{
return elapsed;
@@ -71,11 +72,13 @@ public Utf8RecodingDeferredFileOutputStream getStdErr()
return stdErr;
}
+ @Override
public String getSourceName()
{
return original.getSourceName();
}
+ @Override
public String getName()
{
return original.getName();
@@ -86,16 +89,19 @@ public String getClassMethodName()
return getSourceName() + "." + getName();
}
+ @Override
public String getGroup()
{
return original.getGroup();
}
+ @Override
public StackTraceWriter getStackTraceWriter()
{
return original.getStackTraceWriter();
}
+ @Override
public String getMessage()
{
return original.getMessage();
@@ -160,6 +166,7 @@ public boolean isSucceeded()
return ReportEntryType.SUCCESS == getReportEntryType();
}
+ @Override
public String getNameWithGroup()
{
return original.getNameWithGroup();
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MockNotifiableTestStream.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MockNotifiableTestStream.java
index 9e94e7fafa..b98aca7470 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MockNotifiableTestStream.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MockNotifiableTestStream.java
@@ -31,18 +31,22 @@
final class MockNotifiableTestStream
implements NotifiableTestStream
{
+ @Override
public void provideNewTest()
{
}
+ @Override
public void skipSinceNextTest()
{
}
+ @Override
public void shutdown( Shutdown shutdownType )
{
}
+ @Override
public void noop()
{
}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java
index b8c9ef01cd..bfc8faf2df 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java
@@ -65,24 +65,28 @@ public class MockReporter
private final AtomicInteger testFailed = new AtomicInteger();
+ @Override
public void testSetStarting( ReportEntry report )
{
events.add( SET_STARTING );
data.add( report );
}
+ @Override
public void testSetCompleted( ReportEntry report )
{
events.add( SET_COMPLETED );
data.add( report );
}
+ @Override
public void testStarting( ReportEntry report )
{
events.add( TEST_STARTING );
data.add( report );
}
+ @Override
public void testSucceeded( ReportEntry report )
{
events.add( TEST_SUCCEEDED );
@@ -90,6 +94,7 @@ public void testSucceeded( ReportEntry report )
data.add( report );
}
+ @Override
public void testError( ReportEntry report )
{
events.add( TEST_ERROR );
@@ -97,6 +102,7 @@ public void testError( ReportEntry report )
testFailed.incrementAndGet();
}
+ @Override
public void testFailed( ReportEntry report )
{
events.add( TEST_FAILED );
@@ -104,6 +110,7 @@ public void testFailed( ReportEntry report )
testFailed.incrementAndGet();
}
+ @Override
public void testSkipped( ReportEntry report )
{
events.add( TEST_SKIPPED );
@@ -111,6 +118,7 @@ public void testSkipped( ReportEntry report )
testIgnored.incrementAndGet();
}
+ @Override
public void testExecutionSkippedByUser()
{
}
@@ -140,6 +148,7 @@ public ReportEntry getFirstData()
return (ReportEntry) data.get( 0 );
}
+ @Override
public void testAssumptionFailure( ReportEntry report )
{
events.add( TEST_ASSUMPTION_FAIL );
@@ -147,38 +156,45 @@ public void testAssumptionFailure( ReportEntry report )
testIgnored.incrementAndGet();
}
+ @Override
public void debug( String message )
{
events.add( CONSOLE_OUTPUT );
data.add( message );
}
+ @Override
public void info( String message )
{
events.add( CONSOLE_OUTPUT );
data.add( message );
}
+ @Override
public void warning( String message )
{
events.add( CONSOLE_OUTPUT );
data.add( message );
}
+ @Override
public void error( String message )
{
events.add( CONSOLE_OUTPUT );
data.add( message );
}
+ @Override
public void error( String message, Throwable t )
{
}
+ @Override
public void error( Throwable t )
{
}
+ @Override
public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
{
events.add( stdout ? STDOUT : STDERR );
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
index ada54a2750..5e4f682086 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
@@ -38,6 +38,7 @@ public TestSetMockReporterFactory()
super( defaultValue(), new NullConsoleLogger() );
}
+ @Override
public RunListener createReporter()
{
return new MockReporter();
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStreamTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStreamTest.java
index b117a38891..6f25ec3a02 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStreamTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStreamTest.java
@@ -58,6 +58,7 @@ public void emptyStreamShouldWaitUntilClosed()
final Thread streamThread = Thread.currentThread();
FutureTask futureTask = new FutureTask( new Callable()
{
+ @Override
public Thread.State call()
{
sleep( 1000 );
@@ -82,6 +83,7 @@ public void finishedTestsetShouldNotBlock()
is.testSetFinished();
new Thread( new Runnable()
{
+ @Override
public void run()
{
is.provideNewTest();
@@ -108,6 +110,7 @@ public void shouldReadTest()
final TestProvidingInputStream is = new TestProvidingInputStream( commands );
new Thread( new Runnable()
{
+ @Override
public void run()
{
is.provideNewTest();
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 fbe875de2a..a6076dece5 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
@@ -142,31 +142,37 @@ static final class DummyTestReporter implements ConsoleLogger
{
private final List messages = new ArrayList();
+ @Override
public void debug( String message )
{
messages.add( message );
}
+ @Override
public void info( String message )
{
messages.add( message );
}
+ @Override
public void warning( String message )
{
messages.add( message );
}
+ @Override
public void error( String message )
{
messages.add( message );
}
+ @Override
public void error( String message, Throwable t )
{
messages.add( message );
}
+ @Override
public void error( Throwable t )
{
}
@@ -233,21 +239,25 @@ public DummyStackTraceWriter( String stackTrace )
this.stackTrace = stackTrace;
}
+ @Override
public String writeTraceToString()
{
return "";
}
+ @Override
public String writeTrimmedTraceToString()
{
return "";
}
+ @Override
public String smartTrimmedStackTrace()
{
return stackTrace;
}
+ @Override
public SafeThrowable getThrowable()
{
return null;
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 5b649e3a09..c5b7a1e4eb 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
@@ -20,7 +20,6 @@
*/
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;
@@ -39,6 +38,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
+import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8;
+
@SuppressWarnings( "ResultOfMethodCallIgnored" )
public class StatelessXmlReporterTest
extends TestCase
@@ -142,7 +143,7 @@ public void testAllFieldsSerialized()
FileInputStream fileInputStream = new FileInputStream( expectedReportFile );
- Xpp3Dom testSuite = Xpp3DomBuilder.build( new InputStreamReader( fileInputStream, "UTF-8") );
+ Xpp3Dom testSuite = Xpp3DomBuilder.build( new InputStreamReader( fileInputStream, UTF_8) );
assertEquals( "testsuite", testSuite.getName() );
Xpp3Dom properties = testSuite.getChild( "properties" );
assertEquals( System.getProperties().size(), properties.getChildCount() );
@@ -224,7 +225,7 @@ public void testOutputRerunFlakyFailure()
FileInputStream fileInputStream = new FileInputStream( expectedReportFile );
- Xpp3Dom testSuite = Xpp3DomBuilder.build( new InputStreamReader( fileInputStream, "UTF-8" ) );
+ Xpp3Dom testSuite = Xpp3DomBuilder.build( new InputStreamReader( fileInputStream, UTF_8 ) );
assertEquals( "testsuite", testSuite.getName() );
assertEquals( "0.012", testSuite.getAttribute( "time" ) );
Xpp3Dom properties = testSuite.getChild( "properties" );
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/CustomizedImpl.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/CustomizedImpl.java
index 2809f2cbb4..e2f654c3c8 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/CustomizedImpl.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/CustomizedImpl.java
@@ -26,6 +26,7 @@
public class CustomizedImpl
implements IDefault
{
+ @Override
public boolean isDefault()
{
return false;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/DefaultImpl.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/DefaultImpl.java
index 54de2b76c7..207f56261e 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/DefaultImpl.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/DefaultImpl.java
@@ -26,6 +26,7 @@
public class DefaultImpl
implements IDefault
{
+ @Override
public boolean isDefault()
{
return true;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl1.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl1.java
index 3f3f2769e1..d9e6b4d228 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl1.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl1.java
@@ -25,6 +25,7 @@
*/
public class SPImpl1 implements ExistingServiceInterface
{
+ @Override
public String whoAmI()
{
return SPImpl1.class.getSimpleName();
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl2.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl2.java
index 42b446b197..9ecccef04f 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl2.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/spi/SPImpl2.java
@@ -25,6 +25,7 @@
*/
public class SPImpl2 implements ExistingServiceInterface
{
+ @Override
public String whoAmI()
{
return SPImpl2.class.getSimpleName();
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index 8008a47987..4a404dfebb 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -323,27 +323,32 @@ public class SurefirePlugin
@Parameter( property = "surefire.shutdown", defaultValue = "testset" )
private String shutdown;
+ @Override
protected int getRerunFailingTestsCount()
{
return rerunFailingTestsCount;
}
+ @Override
protected void handleSummary( RunResult summary, Exception firstForkException )
throws MojoExecutionException, MojoFailureException
{
reportExecution( this, summary, getConsoleLogger(), firstForkException );
}
+ @Override
protected boolean isSkipExecution()
{
return isSkip() || isSkipTests() || isSkipExec();
}
+ @Override
protected String getPluginName()
{
return "surefire";
}
+ @Override
protected String[] getDefaultIncludes()
{
return new String[]{ "**/Test*.java", "**/*Test.java", "**/*Tests.java", "**/*TestCase.java" };
@@ -357,11 +362,13 @@ protected String getReportSchemaLocation()
// now for the implementation of the field accessors
+ @Override
public boolean isSkipTests()
{
return skipTests;
}
+ @Override
public void setSkipTests( boolean skipTests )
{
this.skipTests = skipTests;
@@ -370,6 +377,7 @@ public void setSkipTests( boolean skipTests )
/**
* @noinspection deprecation
*/
+ @Override
public boolean isSkipExec()
{
return skipExec;
@@ -378,196 +386,235 @@ public boolean isSkipExec()
/**
* @noinspection deprecation
*/
+ @Override
public void setSkipExec( boolean skipExec )
{
this.skipExec = skipExec;
}
+ @Override
public boolean isSkip()
{
return skip;
}
+ @Override
public void setSkip( boolean skip )
{
this.skip = skip;
}
+ @Override
public boolean isTestFailureIgnore()
{
return testFailureIgnore;
}
+ @Override
public void setTestFailureIgnore( boolean testFailureIgnore )
{
this.testFailureIgnore = testFailureIgnore;
}
+ @Override
public File getBasedir()
{
return basedir;
}
+ @Override
public void setBasedir( File basedir )
{
this.basedir = basedir;
}
+ @Override
public File getTestClassesDirectory()
{
return testClassesDirectory;
}
+ @Override
public void setTestClassesDirectory( File testClassesDirectory )
{
this.testClassesDirectory = testClassesDirectory;
}
+ @Override
public File getClassesDirectory()
{
return classesDirectory;
}
+ @Override
public void setClassesDirectory( File classesDirectory )
{
this.classesDirectory = classesDirectory;
}
+ @Override
public File getReportsDirectory()
{
return reportsDirectory;
}
+ @Override
public void setReportsDirectory( File reportsDirectory )
{
this.reportsDirectory = reportsDirectory;
}
+ @Override
public String getTest()
{
return test;
}
+ @Override
public boolean isUseSystemClassLoader()
{
return useSystemClassLoader;
}
+ @Override
public void setUseSystemClassLoader( boolean useSystemClassLoader )
{
this.useSystemClassLoader = useSystemClassLoader;
}
+ @Override
public boolean isUseManifestOnlyJar()
{
return useManifestOnlyJar;
}
+ @Override
public void setUseManifestOnlyJar( boolean useManifestOnlyJar )
{
this.useManifestOnlyJar = useManifestOnlyJar;
}
+ @Override
public Boolean getFailIfNoSpecifiedTests()
{
return failIfNoSpecifiedTests;
}
+ @Override
public void setFailIfNoSpecifiedTests( boolean failIfNoSpecifiedTests )
{
this.failIfNoSpecifiedTests = failIfNoSpecifiedTests;
}
+ @Override
public int getSkipAfterFailureCount()
{
return skipAfterFailureCount;
}
+ @Override
public String getShutdown()
{
return shutdown;
}
+ @Override
public boolean isPrintSummary()
{
return printSummary;
}
+ @Override
public void setPrintSummary( boolean printSummary )
{
this.printSummary = printSummary;
}
+ @Override
public String getReportFormat()
{
return reportFormat;
}
+ @Override
public void setReportFormat( String reportFormat )
{
this.reportFormat = reportFormat;
}
+ @Override
public boolean isUseFile()
{
return useFile;
}
+ @Override
public void setUseFile( boolean useFile )
{
this.useFile = useFile;
}
+ @Override
public String getDebugForkedProcess()
{
return debugForkedProcess;
}
+ @Override
public void setDebugForkedProcess( String debugForkedProcess )
{
this.debugForkedProcess = debugForkedProcess;
}
+ @Override
public int getForkedProcessTimeoutInSeconds()
{
return forkedProcessTimeoutInSeconds;
}
+ @Override
public void setForkedProcessTimeoutInSeconds( int forkedProcessTimeoutInSeconds )
{
this.forkedProcessTimeoutInSeconds = forkedProcessTimeoutInSeconds;
}
+ @Override
public int getForkedProcessExitTimeoutInSeconds()
{
return forkedProcessExitTimeoutInSeconds;
}
+ @Override
public void setForkedProcessExitTimeoutInSeconds( int forkedProcessExitTimeoutInSeconds )
{
this.forkedProcessExitTimeoutInSeconds = forkedProcessExitTimeoutInSeconds;
}
+ @Override
public double getParallelTestsTimeoutInSeconds()
{
return parallelTestsTimeoutInSeconds;
}
+ @Override
public void setParallelTestsTimeoutInSeconds( double parallelTestsTimeoutInSeconds )
{
this.parallelTestsTimeoutInSeconds = parallelTestsTimeoutInSeconds;
}
+ @Override
public double getParallelTestsTimeoutForcedInSeconds()
{
return parallelTestsTimeoutForcedInSeconds;
}
+ @Override
public void setParallelTestsTimeoutForcedInSeconds( double parallelTestsTimeoutForcedInSeconds )
{
this.parallelTestsTimeoutForcedInSeconds = parallelTestsTimeoutForcedInSeconds;
}
+ @Override
public void setTest( String test )
{
this.test = test;
@@ -585,22 +632,26 @@ public void setIncludes( List includes )
this.includes = includes;
}
+ @Override
public File[] getSuiteXmlFiles()
{
return suiteXmlFiles.clone();
}
+ @Override
@SuppressWarnings( "UnusedDeclaration" )
public void setSuiteXmlFiles( File[] suiteXmlFiles )
{
this.suiteXmlFiles = suiteXmlFiles.clone();
}
+ @Override
public String getRunOrder()
{
return runOrder;
}
+ @Override
@SuppressWarnings( "UnusedDeclaration" )
public void setRunOrder( String runOrder )
{
diff --git a/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java b/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java
index 2f8700a2bc..5fa6df0a46 100644
--- a/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java
+++ b/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java
@@ -102,11 +102,13 @@ private Field findField( Class clazz, String fieldName )
private class MyToolChain
implements Toolchain
{
+ @Override
public String getType()
{
return null;
}
+ @Override
public String findTool( String s )
{
return null;
diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java
index 9621fa117f..a3538b72b8 100644
--- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java
+++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java
@@ -131,6 +131,7 @@ protected boolean isGeneratedWhenNoResults()
/**
* {@inheritDoc}
*/
+ @Override
public void executeReport( Locale locale )
throws MavenReportException
{
@@ -312,6 +313,7 @@ private String determineXrefLocation()
/**
* {@inheritDoc}
*/
+ @Override
public String getName( Locale locale )
{
return getBundle( locale ).getString( "report.surefire.name" );
@@ -320,6 +322,7 @@ public String getName( Locale locale )
/**
* {@inheritDoc}
*/
+ @Override
public String getDescription( Locale locale )
{
return getBundle( locale ).getString( "report.surefire.description" );
@@ -328,6 +331,7 @@ public String getDescription( Locale locale )
/**
* {@inheritDoc}
*/
+ @Override
public abstract String getOutputName();
private ResourceBundle getBundle( Locale locale )
diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/FailsafeReportMojo.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/FailsafeReportMojo.java
index b208c4f80a..b7aa290699 100644
--- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/FailsafeReportMojo.java
+++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/FailsafeReportMojo.java
@@ -68,22 +68,26 @@ public class FailsafeReportMojo
@Parameter( defaultValue = "false", property = "skipFailsafeReport" )
private boolean skipFailsafeReport;
+ @Override
protected File getSurefireReportsDirectory( MavenProject subProject )
{
String buildDir = subProject.getBuild().getDirectory();
return new File( buildDir + "/failsafe-reports" );
}
+ @Override
public String getOutputName()
{
return outputName;
}
+ @Override
protected boolean isSkipped()
{
return skipFailsafeReport;
}
+ @Override
protected boolean isGeneratedWhenNoResults()
{
return alwaysGenerateFailsafeReport;
@@ -92,6 +96,7 @@ protected boolean isGeneratedWhenNoResults()
/**
* {@inheritDoc}
*/
+ @Override
public String getName( Locale locale )
{
return getBundle( locale ).getString( "report.failsafe.name" );
@@ -100,6 +105,7 @@ public String getName( Locale locale )
/**
* {@inheritDoc}
*/
+ @Override
public String getDescription( Locale locale )
{
return getBundle( locale ).getString( "report.failsafe.description" );
diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/PluginConsoleLogger.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/PluginConsoleLogger.java
index 667bc95c16..3a75037a58 100644
--- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/PluginConsoleLogger.java
+++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/PluginConsoleLogger.java
@@ -49,6 +49,7 @@ public boolean isDebugEnabled()
return mojoLogger.isDebugEnabled();
}
+ @Override
public void debug( String message )
{
if ( mojoLogger.isDebugEnabled() )
@@ -70,6 +71,7 @@ public boolean isInfoEnabled()
return mojoLogger.isInfoEnabled();
}
+ @Override
public void info( String message )
{
if ( mojoLogger.isInfoEnabled() )
@@ -83,6 +85,7 @@ public boolean isWarnEnabled()
return mojoLogger.isWarnEnabled();
}
+ @Override
public void warning( String message )
{
if ( mojoLogger.isWarnEnabled() )
@@ -104,6 +107,7 @@ public boolean isErrorEnabled()
return mojoLogger.isErrorEnabled();
}
+ @Override
public void error( String message )
{
if ( mojoLogger.isErrorEnabled() )
@@ -112,6 +116,7 @@ public void error( String message )
}
}
+ @Override
public void error( String message, Throwable t )
{
if ( mojoLogger.isErrorEnabled() )
@@ -120,6 +125,7 @@ public void error( String message, Throwable t )
}
}
+ @Override
public void error( Throwable t )
{
if ( mojoLogger.isErrorEnabled() )
diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java
index 964c1c45fb..a950bcf91d 100644
--- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java
+++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java
@@ -65,22 +65,26 @@ public class SurefireReportMojo
@Parameter( defaultValue = "false", property = "skipSurefireReport" )
private boolean skipSurefireReport;
+ @Override
protected File getSurefireReportsDirectory( MavenProject subProject )
{
String buildDir = subProject.getBuild().getDirectory();
return new File( buildDir + "/surefire-reports" );
}
+ @Override
public String getOutputName()
{
return outputName;
}
+ @Override
protected boolean isSkipped()
{
return skipSurefireReport;
}
+ @Override
protected boolean isGeneratedWhenNoResults()
{
return alwaysGenerateSurefireReport;
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java
index af02470a05..155b68362a 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java
@@ -34,6 +34,7 @@ public class SurefireRepMavenProjectStub
/**
* {@inheritDoc}
*/
+ @Override
public List getReportPlugins()
{
Reporting reporting = new Reporting();
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java
index 18277ca682..23b1e4e7c4 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java
@@ -32,6 +32,7 @@ public class SurefireRepMavenProjectStub2
/**
* {@inheritDoc}
*/
+ @Override
public List getReportPlugins()
{
return new ArrayList();
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
index d47e8039b8..dc871a569e 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
@@ -150,6 +150,7 @@ public void add( RunEntryStatistics item )
static final class RunCountComparator
implements Comparator
{
+ @Override
public int compare( RunEntryStatistics o, RunEntryStatistics o1 )
{
int runtime = o.getSuccessfulBuilds() - o1.getSuccessfulBuilds();
@@ -238,6 +239,7 @@ private Map getPriorities( Comparator priorityComparator )
static final class PrioritizedTestComparator
implements Comparator
{
+ @Override
public int compare( PrioritizedTest o, PrioritizedTest o1 )
{
return o.getPriority() - o1.getPriority();
@@ -247,6 +249,7 @@ public int compare( PrioritizedTest o, PrioritizedTest o1 )
static final class TestRuntimeComparator
implements Comparator
{
+ @Override
public int compare( Priority o, Priority o1 )
{
return o1.getTotalRuntime() - o.getTotalRuntime();
@@ -256,6 +259,7 @@ public int compare( Priority o, Priority o1 )
static final class LeastFailureComparator
implements Comparator
{
+ @Override
public int compare( Priority o, Priority o1 )
{
return o.getMinSuccessRate() - o1.getMinSuccessRate();
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/NonAbstractClassFilter.java b/surefire-api/src/main/java/org/apache/maven/surefire/NonAbstractClassFilter.java
index cc38977071..da3badd58f 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/NonAbstractClassFilter.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/NonAbstractClassFilter.java
@@ -28,6 +28,7 @@
public class NonAbstractClassFilter
implements ScannerFilter
{
+ @Override
public boolean accept( Class testClass )
{
return !Modifier.isAbstract( testClass.getModifiers() );
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 ca98b8c63e..cfe7258e28 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
@@ -48,6 +48,7 @@ public SpecificTestClassFilter( String[] classNames )
}
}
+ @Override
public boolean accept( Class testClass )
{
// If the tests enumeration is empty, allow anything.
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
index 2a713ef0a5..2b329ee5db 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
@@ -85,6 +85,7 @@ public BaseProviderFactory( ReporterFactory reporterFactory, boolean insideFork
this.insideFork = insideFork;
}
+ @Override
@Deprecated
public DirectoryScanner getDirectoryScanner()
{
@@ -95,6 +96,7 @@ public DirectoryScanner getDirectoryScanner()
directoryScannerParameters.getSpecificTests() );
}
+ @Override
public ScanResult getScanResult()
{
return DefaultScanResult.from( providerProperties );
@@ -106,32 +108,38 @@ private int getThreadCount()
return threadcount == null ? 1 : Math.max( Integer.parseInt( threadcount ), 1 );
}
+ @Override
public RunOrderCalculator getRunOrderCalculator()
{
return directoryScannerParameters == null
? null : new DefaultRunOrderCalculator( runOrderParameters, getThreadCount() );
}
+ @Override
public ReporterFactory getReporterFactory()
{
return reporterFactory;
}
+ @Override
public void setDirectoryScannerParameters( DirectoryScannerParameters directoryScannerParameters )
{
this.directoryScannerParameters = directoryScannerParameters;
}
+ @Override
public void setReporterConfiguration( ReporterConfiguration reporterConfiguration )
{
this.reporterConfiguration = reporterConfiguration;
}
+ @Override
public void setClassLoaders( ClassLoader testClassLoader )
{
this.testClassLoader = testClassLoader;
}
+ @Override
public ConsoleStream getConsoleLogger()
{
boolean trim = reporterConfiguration.isTrimStackTrace();
@@ -139,91 +147,109 @@ public ConsoleStream getConsoleLogger()
return insideFork ? new ForkingRunListener( out, ROOT_CHANNEL, trim ) : new DefaultDirectConsoleReporter( out );
}
+ @Override
public void setTestRequest( TestRequest testRequest )
{
this.testRequest = testRequest;
}
+ @Override
public DirectoryScannerParameters getDirectoryScannerParameters()
{
return directoryScannerParameters;
}
+ @Override
public ReporterConfiguration getReporterConfiguration()
{
return reporterConfiguration;
}
+ @Override
public TestRequest getTestRequest()
{
return testRequest;
}
+ @Override
public ClassLoader getTestClassLoader()
{
return testClassLoader;
}
+ @Override
public void setProviderProperties( Map providerProperties )
{
this.providerProperties = providerProperties;
}
+ @Override
public Map getProviderProperties()
{
return providerProperties;
}
+ @Override
public TestArtifactInfo getTestArtifactInfo()
{
return testArtifactInfo;
}
+ @Override
public void setTestArtifactInfo( TestArtifactInfo testArtifactInfo )
{
this.testArtifactInfo = testArtifactInfo;
}
+ @Override
public void setRunOrderParameters( RunOrderParameters runOrderParameters )
{
this.runOrderParameters = runOrderParameters;
}
+ @Override
public List getMainCliOptions()
{
return mainCliOptions;
}
+ @Override
public void setMainCliOptions( List mainCliOptions )
{
this.mainCliOptions = mainCliOptions == null ? Collections.emptyList() : mainCliOptions;
}
+ @Override
public int getSkipAfterFailureCount()
{
return skipAfterFailureCount;
}
+ @Override
public void setSkipAfterFailureCount( int skipAfterFailureCount )
{
this.skipAfterFailureCount = skipAfterFailureCount;
}
+ @Override
public boolean isInsideFork()
{
return insideFork;
}
+ @Override
public Shutdown getShutdown()
{
return shutdown;
}
+ @Override
public void setShutdown( Shutdown shutdown )
{
this.shutdown = shutdown;
}
+ @Override
public Integer getSystemExitTimeout()
{
return systemExitTimeout;
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
index 2e80f449a9..a24424b82a 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/CommandReader.java
@@ -261,6 +261,7 @@ private final class ClassesIterable
this.originalOutStream = originalOutStream;
}
+ @Override
public Iterator iterator()
{
return new ClassesIterator( originalOutStream );
@@ -281,12 +282,14 @@ private ClassesIterator( PrintStream originalOutStream )
this.originalOutStream = originalOutStream;
}
+ @Override
public boolean hasNext()
{
popUnread();
return isNotBlank( clazz );
}
+ @Override
public String next()
{
popUnread();
@@ -307,6 +310,7 @@ public String next()
}
}
+ @Override
public void remove()
{
throw new UnsupportedOperationException();
@@ -374,6 +378,7 @@ private void wakeupIterator()
private final class CommandRunnable
implements Runnable
{
+ @Override
public void run()
{
CommandReader.this.startMonitor.countDown();
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingReporterFactory.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingReporterFactory.java
index def345d246..89469fa27c 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingReporterFactory.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingReporterFactory.java
@@ -49,11 +49,13 @@ public ForkingReporterFactory( boolean trimstackTrace, PrintStream originalSyste
this.originalSystemOut = originalSystemOut;
}
+ @Override
public RunListener createReporter()
{
return new ForkingRunListener( originalSystemOut, testSetChannelId.getAndIncrement(), isTrimstackTrace );
}
+ @Override
public RunResult close()
{
return new RunResult( 17, 17, 17, 17 );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index 6c0842aaee..f0f0ac6604 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -131,46 +131,55 @@ public ForkingRunListener( PrintStream target, int testSetChannelId, boolean tri
sendProps();
}
+ @Override
public void testSetStarting( ReportEntry report )
{
encodeAndWriteToTarget( toString( BOOTERCODE_TESTSET_STARTING, report, testSetChannelId ) );
}
+ @Override
public void testSetCompleted( ReportEntry report )
{
encodeAndWriteToTarget( toString( BOOTERCODE_TESTSET_COMPLETED, report, testSetChannelId ) );
}
+ @Override
public void testStarting( ReportEntry report )
{
encodeAndWriteToTarget( toString( BOOTERCODE_TEST_STARTING, report, testSetChannelId ) );
}
+ @Override
public void testSucceeded( ReportEntry report )
{
encodeAndWriteToTarget( toString( BOOTERCODE_TEST_SUCCEEDED, report, testSetChannelId ) );
}
+ @Override
public void testAssumptionFailure( ReportEntry report )
{
encodeAndWriteToTarget( toString( BOOTERCODE_TEST_ASSUMPTIONFAILURE, report, testSetChannelId ) );
}
+ @Override
public void testError( ReportEntry report )
{
encodeAndWriteToTarget( toString( BOOTERCODE_TEST_ERROR, report, testSetChannelId ) );
}
+ @Override
public void testFailed( ReportEntry report )
{
encodeAndWriteToTarget( toString( BOOTERCODE_TEST_FAILED, report, testSetChannelId ) );
}
+ @Override
public void testSkipped( ReportEntry report )
{
encodeAndWriteToTarget( toString( BOOTERCODE_TEST_SKIPPED, report, testSetChannelId ) );
}
+ @Override
public void testExecutionSkippedByUser()
{
encodeAndWriteToTarget( toString( BOOTERCODE_STOP_ON_NEXT_TEST, new SimpleReportEntry(), testSetChannelId ) );
@@ -190,6 +199,7 @@ void sendProps()
}
}
+ @Override
public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
{
byte[] header = stdout ? stdOutHeader : stdErrHeader;
@@ -238,31 +248,37 @@ private void log( byte bootCode, String message )
}
}
+ @Override
public void debug( String message )
{
log( BOOTERCODE_DEBUG, message );
}
+ @Override
public void info( String message )
{
log( BOOTERCODE_CONSOLE, message );
}
+ @Override
public void warning( String message )
{
log( BOOTERCODE_WARNING, message );
}
+ @Override
public void error( String message )
{
log( BOOTERCODE_ERROR, message );
}
+ @Override
public void error( String message, Throwable t )
{
error( ConsoleLoggerUtils.toString( message, t ) );
}
+ @Override
public void error( Throwable t )
{
error( null, t );
@@ -391,12 +407,14 @@ public static void encode( StringBuilder stringBuilder, StackTraceWriter stackTr
}
}
+ @Override
public void println( String message )
{
byte[] buf = message.getBytes();
println( buf, 0, buf.length );
}
+ @Override
public void println( byte[] buf, int off, int len )
{
writeTestOutput( buf, off, len, true );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
index f985d26d78..c82c798b9e 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -21,13 +21,12 @@
import java.io.DataInputStream;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
-import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
-import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
import static java.lang.String.format;
+import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull;
+import static org.apache.maven.surefire.util.internal.StringUtils.ISO_8859_1;
+import static org.apache.maven.surefire.util.internal.StringUtils.US_ASCII;
+import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
/**
* Commands which are sent from plugin to the forked jvm.
@@ -47,8 +46,6 @@ public enum MasterProcessCommand
NOOP( 4, Void.class ),
BYE_ACK( 5, Void.class );
- private static final Charset ASCII = Charset.forName( "US-ASCII" );
-
private final int id;
private final Class> dataType;
@@ -143,21 +140,14 @@ public static Command decode( DataInputStream is )
String toDataTypeAsString( byte... data )
{
- try
- {
- switch ( this )
- {
- case RUN_CLASS:
- return new String( data, FORK_STREAM_CHARSET_NAME );
- case SHUTDOWN:
- return new String( data, ASCII );
- default:
- return null;
- }
- }
- catch ( UnsupportedEncodingException e )
+ switch ( this )
{
- throw new IllegalStateException( e );
+ case RUN_CLASS:
+ return new String( data, ISO_8859_1 );
+ case SHUTDOWN:
+ return new String( data, US_ASCII );
+ default:
+ return null;
}
}
@@ -168,7 +158,7 @@ byte[] fromDataType( String data )
case RUN_CLASS:
return encodeStringForForkCommunication( data );
case SHUTDOWN:
- return data.getBytes( ASCII );
+ return data.getBytes( US_ASCII );
default:
return new byte[0];
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
index 528589c85d..54677a7c11 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
@@ -169,6 +169,7 @@ public ClassLoaderProxy( Object delegate )
this.target = delegate;
}
+ @Override
public Object invoke( Object proxy, Method method, Object[] args )
throws Throwable
{
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/AbstractProvider.java b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/AbstractProvider.java
index 19d1da3c35..eca3909360 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/AbstractProvider.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/AbstractProvider.java
@@ -29,6 +29,7 @@ public abstract class AbstractProvider
{
private final Thread creatingThread = Thread.currentThread();
+ @Override
public void cancel()
{
synchronized ( creatingThread )
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
index 0cccd6e97c..c357cbafb4 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
@@ -59,6 +59,7 @@ public static ReportEntry reportEntry( String source, String name, String group,
: new SimpleReportEntry( source, name, stackTraceWriter, elapsed, message );
}
+ @Override
public String getGroup()
{
return group;
@@ -70,6 +71,7 @@ public String getNameWithGroup()
return isNameWithGroup() ? getName() + GROUP_PREFIX + getGroup() + GROUP_SUFIX : getName();
}
+ @Override
public boolean equals( Object o )
{
if ( this == o )
@@ -91,6 +93,7 @@ public boolean equals( Object o )
}
+ @Override
public int hashCode()
{
int result = super.hashCode();
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java
index b5835936d0..28f111b66c 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java
@@ -52,6 +52,7 @@ private static class ForwardingPrintStream
this.target = target;
}
+ @Override
public void write( byte[] buf, int off, int len )
{
// Note: At this point the supplied "buf" instance is reused, which means
@@ -59,12 +60,14 @@ public void write( byte[] buf, int off, int len )
target.writeTestOutput( buf, off, len, isStdout );
}
+ @Override
public void write( byte[] b )
throws IOException
{
target.writeTestOutput( b, 0, b.length, isStdout );
}
+ @Override
public void write( int b )
{
byte[] buf = new byte[1];
@@ -79,6 +82,7 @@ public void write( int b )
}
}
+ @Override
public void println( String s )
{
if ( s == null )
@@ -89,10 +93,12 @@ public void println( String s )
target.writeTestOutput( bytes, 0, bytes.length, isStdout );
}
+ @Override
public void close()
{
}
+ @Override
public void flush()
{
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/DefaultDirectConsoleReporter.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/DefaultDirectConsoleReporter.java
index f1e0f48c84..5298ad95b9 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/DefaultDirectConsoleReporter.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/DefaultDirectConsoleReporter.java
@@ -34,11 +34,13 @@ public DefaultDirectConsoleReporter( PrintStream systemOut )
this.systemOut = systemOut;
}
+ @Override
public void println( String message )
{
systemOut.println( message );
}
+ @Override
public void println( byte[] buf, int off, int len )
{
println( new String( buf, off, len ) );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java
index d1e1890ac0..88552cbcef 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriter.java
@@ -49,6 +49,7 @@ public LegacyPojoStackTraceWriter( String testClass, String testMethod, Throwabl
this.t = t;
}
+ @Override
public String writeTraceToString()
{
if ( t != null )
@@ -79,6 +80,7 @@ public String writeTraceToString()
return "";
}
+ @Override
public String smartTrimmedStackTrace()
{
StringBuilder result = new StringBuilder();
@@ -147,6 +149,7 @@ private static String getTruncatedMessage( String msg, int i )
}
+ @Override
public String writeTrimmedTraceToString()
{
String text = writeTraceToString();
@@ -189,6 +192,7 @@ else if ( line.startsWith( "Caused by" ) )
return trace.toString();
}
+ @Override
public SafeThrowable getThrowable()
{
return new SafeThrowable( t );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/SimpleReportEntry.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/SimpleReportEntry.java
index 4715b248ab..28a19f9eac 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/SimpleReportEntry.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/SimpleReportEntry.java
@@ -118,37 +118,44 @@ private static String safeGetMessage( StackTraceWriter stackTraceWriter )
}
}
+ @Override
public String getSourceName()
{
return source;
}
+ @Override
public String getName()
{
return name;
}
+ @Override
public String getGroup()
{
return null;
}
+ @Override
public StackTraceWriter getStackTraceWriter()
{
return stackTraceWriter;
}
+ @Override
public Integer getElapsed()
{
return elapsed;
}
+ @Override
public String toString()
{
return "ReportEntry{" + "source='" + source + '\'' + ", name='" + name + '\'' + ", stackTraceWriter="
+ stackTraceWriter + ", elapsed=" + elapsed + ",message=" + message + '}';
}
+ @Override
public String getMessage()
{
return message;
@@ -157,6 +164,7 @@ public String getMessage()
/**
* @noinspection RedundantIfStatement
*/
+ @Override
public boolean equals( Object o )
{
if ( this == o )
@@ -192,6 +200,7 @@ public boolean equals( Object o )
return true;
}
+ @Override
public int hashCode()
{
int result = source != null ? source.hashCode() : 0;
@@ -201,6 +210,7 @@ public int hashCode()
return result;
}
+ @Override
public String getNameWithGroup()
{
return getName();
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
index 1525e80c5d..aa099c850c 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
@@ -202,6 +202,7 @@ public static RunResult noTestsRun()
return new RunResult( 0, 0, 0, 0 );
}
+ @Override
@SuppressWarnings( "RedundantIfStatement" )
public boolean equals( Object o )
{
@@ -244,6 +245,7 @@ public boolean equals( Object o )
return true;
}
+ @Override
public int hashCode()
{
int result = completedCount;
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 e2ae963b38..a7f0e28a6f 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
@@ -117,16 +117,19 @@ public static TestListResolver newTestListResolver( Set includedPa
includedPatterns, excludedPatterns );
}
+ @Override
public boolean hasIncludedMethodPatterns()
{
return hasIncludedMethodPatterns;
}
+ @Override
public boolean hasExcludedMethodPatterns()
{
return hasExcludedMethodPatterns;
}
+ @Override
public boolean hasMethodPatterns()
{
return hasIncludedMethodPatterns() || hasExcludedMethodPatterns();
@@ -162,6 +165,7 @@ public TestFilter and( final TestListResolver another )
{
return new TestFilter()
{
+ @Override
public boolean shouldRun( String testClass, String methodName )
{
return TestListResolver.this.shouldRun( testClass, methodName )
@@ -174,6 +178,7 @@ public TestFilter or( final TestListResolver another )
{
return new TestFilter()
{
+ @Override
public boolean shouldRun( String testClass, String methodName )
{
return TestListResolver.this.shouldRun( testClass, methodName )
@@ -193,6 +198,7 @@ public boolean shouldRun( Class> testClass, String methodName )
* @param testClassFile format must be e.g. "my/package/MyTest.class" including class extension; or null
* @param methodName real test-method name; or null
*/
+ @Override
public boolean shouldRun( String testClassFile, String methodName )
{
if ( isEmpty() || isBlank( testClassFile ) && isBlank( methodName ) )
@@ -234,11 +240,13 @@ public boolean shouldRun( String testClassFile, String methodName )
}
}
+ @Override
public boolean isEmpty()
{
return equals( EMPTY );
}
+ @Override
public String getPluginParameterTest()
{
String aggregatedTest = aggregatedTest( "", getIncludedPatterns() );
@@ -252,11 +260,13 @@ public String getPluginParameterTest()
return aggregatedTest.length() == 0 ? "" : aggregatedTest;
}
+ @Override
public Set getIncludedPatterns()
{
return includedPatterns;
}
+ @Override
public Set getExcludedPatterns()
{
return excludedPatterns;
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/CloseableIterator.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/CloseableIterator.java
index 52b5b65d52..eec185982b 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/CloseableIterator.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/CloseableIterator.java
@@ -1 +1,100 @@
-package org.apache.maven.surefire.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 java.util.Iterator;
import java.util.NoSuchElementException;
/**
* This iterator is marked as stopped if {@link #isClosed()} returns {@code true}.
* If the iterator has been closed before calling {@link #hasNext()} then the method returns {@code false}.
* If the iterator was closed after {@link #hasNext() hasNext returns true} but before {@link #next()}, the
* method {@link #next()} throws {@link java.util.NoSuchElementException}.
* The method {@link #remove()} throws {@link IllegalStateException} if the iterator has been closed.
*
* @param the type of elements returned by this iterator
*
* @author Tibor Digana (tibor17)
* @since 2.19.1
*/
public abstract class CloseableIterator
implements Iterator
{
private Boolean finishCurrentIteration;
protected abstract boolean isClosed();
protected abstract boolean doHasNext();
protected abstract T doNext();
protected abstract void doRemove();
public boolean hasNext()
{
popMarker();
return !finishCurrentIteration && doHasNext();
}
public T next()
{
try
{
if ( popMarker() && finishCurrentIteration )
{
throw new NoSuchElementException( "iterator closed" );
}
return doNext();
}
finally
{
finishCurrentIteration = null;
}
}
public void remove()
{
try
{
if ( popMarker() && finishCurrentIteration )
{
throw new IllegalStateException( "iterator closed" );
}
doRemove();
}
finally
{
finishCurrentIteration = null;
}
}
/**
* @return {@code true} if marker changed from NULL to anything
*/
private boolean popMarker()
{
if ( finishCurrentIteration == null )
{
finishCurrentIteration = isClosed();
return true;
}
return false;
}
}
\ No newline at end of file
+package org.apache.maven.surefire.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 java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * This iterator is marked as stopped if {@link #isClosed()} returns {@code true}.
+ * If the iterator has been closed before calling {@link #hasNext()} then the method returns {@code false}.
+ * If the iterator was closed after {@link #hasNext() hasNext returns true} but before {@link #next()}, the
+ * method {@link #next()} throws {@link java.util.NoSuchElementException}.
+ * The method {@link #remove()} throws {@link IllegalStateException} if the iterator has been closed.
+ *
+ * @param the type of elements returned by this iterator
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.19.1
+ */
+public abstract class CloseableIterator
+ implements Iterator
+{
+ private Boolean finishCurrentIteration;
+
+ protected abstract boolean isClosed();
+ protected abstract boolean doHasNext();
+ protected abstract T doNext();
+ protected abstract void doRemove();
+
+ @Override
+ public boolean hasNext()
+ {
+ popMarker();
+ return !finishCurrentIteration && doHasNext();
+ }
+
+ @Override
+ public T next()
+ {
+ try
+ {
+ if ( popMarker() && finishCurrentIteration )
+ {
+ throw new NoSuchElementException( "iterator closed" );
+ }
+ return doNext();
+ }
+ finally
+ {
+ finishCurrentIteration = null;
+ }
+ }
+
+ @Override
+ public void remove()
+ {
+ try
+ {
+ if ( popMarker() && finishCurrentIteration )
+ {
+ throw new IllegalStateException( "iterator closed" );
+ }
+ doRemove();
+ }
+ finally
+ {
+ finishCurrentIteration = null;
+ }
+ }
+
+ /**
+ * @return {@code true} if marker changed from NULL to anything
+ */
+ private boolean popMarker()
+ {
+ if ( finishCurrentIteration == null )
+ {
+ finishCurrentIteration = isClosed();
+ return true;
+ }
+ return false;
+ }
+}
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 7353165ab1..b8be70f3ec 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
@@ -64,6 +64,7 @@ public DefaultDirectoryScanner( File basedir, List includes, List 0 ? getSortOrderComparator( this.runOrder[0] ) : null;
}
+ @Override
@SuppressWarnings( "checkstyle:magicnumber" )
public TestsToRun orderTestClasses( TestsToRun scannedClasses )
{
@@ -120,6 +121,7 @@ private Comparator getReverseAlphabeticalComparator()
{
return new Comparator()
{
+ @Override
public int compare( Class o1, Class o2 )
{
return o2.getName().compareTo( o1.getName() );
@@ -131,6 +133,7 @@ private Comparator getAlphabeticalComparator()
{
return new Comparator()
{
+ @Override
public int compare( Class o1, Class o2 )
{
return o1.getName().compareTo( o2.getName() );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
index ff75508b6c..a00a3b56d1 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
@@ -41,16 +41,19 @@ public DefaultScanResult( List files )
this.files = Collections.unmodifiableList( files );
}
+ @Override
public int size()
{
return files.size();
}
+ @Override
public String getClassName( int index )
{
return files.get( index );
}
+ @Override
public void writeTo( Map properties )
{
for ( int i = 0, size = files.size(); i < size; i++ )
@@ -84,6 +87,7 @@ public List getFiles()
return files;
}
+ @Override
public TestsToRun applyFilter( ScannerFilter scannerFilter, ClassLoader testClassLoader )
{
Set> result = new LinkedHashSet>();
@@ -104,6 +108,7 @@ public TestsToRun applyFilter( ScannerFilter scannerFilter, ClassLoader testClas
return new TestsToRun( result );
}
+ @Override
public List> getClassesSkippedByValidation( ScannerFilter scannerFilter, ClassLoader testClassLoader )
{
List> result = new ArrayList>();
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrder.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrder.java
index ebbec70633..79c52357f2 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrder.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrder.java
@@ -143,6 +143,7 @@ public String name()
return name;
}
+ @Override
public String toString()
{
return name;
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
index 204bed862f..8a264ca8fe 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
@@ -73,6 +73,7 @@ public Iterator> iterated()
*
* @return an unmodifiable iterator
*/
+ @Override
public Iterator> iterator()
{
return new ClassesIterator();
@@ -127,6 +128,7 @@ public final boolean isFinished()
return finished;
}
+ @Override
public String toString()
{
StringBuilder sb = new StringBuilder( "TestsToRun: [" );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java
index 69da150bc5..bdd983f2bc 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java
@@ -104,6 +104,7 @@ public int getlength()
return position;
}
+ @Override
public String toString()
{
return new String( data, 0, position );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DaemonThreadFactory.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DaemonThreadFactory.java
index 29eb18d856..4912f8eea0 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DaemonThreadFactory.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DaemonThreadFactory.java
@@ -43,6 +43,7 @@ private DaemonThreadFactory()
namePrefix = "pool-" + POOL_NUMBER.getAndIncrement() + "-thread-";
}
+ @Override
public Thread newThread( Runnable r )
{
Thread t = new Thread( group, r, namePrefix + threadNumber.getAndIncrement() );
@@ -104,6 +105,7 @@ private NamedThreadFactory( String name )
this.name = name;
}
+ @Override
public Thread newThread( Runnable r )
{
return newDaemonThread( r, name );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
index ebf0795390..cad2e7a46b 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DumpFileUtils.java
@@ -30,6 +30,8 @@
import java.text.SimpleDateFormat;
import java.util.Date;
+import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8;
+
/**
* Dumps a text or exception in dump file.
* Each call logs a date when it was written to the dump file.
@@ -111,7 +113,7 @@ public static String newFormattedDateFileName()
private static Writer createWriter( File dumpFile ) throws IOException
{
- return new OutputStreamWriter( new FileOutputStream( dumpFile, true ), "UTF-8" )
+ return new OutputStreamWriter( new FileOutputStream( dumpFile, true ), UTF_8 )
.append( "# Created on " )
.append( new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS" ).format( new Date() ) )
.append( StringUtils.NL );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index d1838b2966..bb7c3a7863 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -19,7 +19,6 @@
* under the License.
*/
-import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
@@ -64,8 +63,16 @@ public final class StringUtils
private static final Charset DEFAULT_CHARSET = Charset.defaultCharset();
+ /**
+ * TODO
+ * Use JDK7 StandardCharsets
+ */
+ public static final Charset US_ASCII = Charset.forName( "US-ASCII" );
+
// 8-bit charset Latin-1
- public static final String FORK_STREAM_CHARSET_NAME = "ISO-8859-1";
+ public static final Charset ISO_8859_1 = Charset.forName( "ISO-8859-1" );
+
+ public static final Charset UTF_8 = Charset.forName( "UTF-8" );
private StringUtils()
{
@@ -347,14 +354,7 @@ public static ByteBuffer unescapeBytes( String str, String charsetName )
public static byte[] encodeStringForForkCommunication( String string )
{
- try
- {
- return string.getBytes( FORK_STREAM_CHARSET_NAME );
- }
- catch ( UnsupportedEncodingException e )
- {
- throw new RuntimeException( "The JVM must support Charset " + FORK_STREAM_CHARSET_NAME, e );
- }
+ return string.getBytes( ISO_8859_1 );
}
/**
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java
index 3a33b7f82a..dd96f28fca 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/UrlUtils.java
@@ -20,11 +20,12 @@
*/
import java.io.File;
-import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.BitSet;
+import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8;
+
/**
* Utility for dealing with URLs in pre-JDK 1.4.
*/
@@ -41,22 +42,12 @@ private UrlUtils()
throw new IllegalStateException( "no instantiable constructor" );
}
- private static final String ENCODING = "UTF-8";
-
static
{
- try
- {
- byte[] bytes =
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'():/".getBytes( ENCODING );
- for ( byte aByte : bytes )
- {
- UNRESERVED.set( aByte );
- }
- }
- catch ( UnsupportedEncodingException e )
+ byte[] bytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'():/".getBytes( UTF_8 );
+ for ( byte aByte : bytes )
{
- // can't happen as UTF-8 must be present
+ UNRESERVED.set( aByte );
}
}
@@ -68,29 +59,21 @@ public static URL toURL( File file )
URL url = file.toURL();
// encode any characters that do not comply with RFC 2396
// this is primarily to handle Windows where the user's home directory contains spaces
- try
+ byte[] bytes = url.toString().getBytes( UTF_8 );
+ StringBuilder buf = new StringBuilder( bytes.length );
+ for ( byte b : bytes )
{
- byte[] bytes = url.toString().getBytes( ENCODING );
- StringBuilder buf = new StringBuilder( bytes.length );
- for ( byte b : bytes )
+ if ( b > 0 && UNRESERVED.get( b ) )
{
- if ( b > 0 && UNRESERVED.get( b ) )
- {
- buf.append( (char) b );
- }
- else
- {
- buf.append( '%' );
- buf.append( Character.forDigit( b >>> 4 & MASK, RADIX ) );
- buf.append( Character.forDigit( b & MASK, RADIX ) );
- }
+ buf.append( (char) b );
+ }
+ else
+ {
+ buf.append( '%' );
+ buf.append( Character.forDigit( b >>> 4 & MASK, RADIX ) );
+ buf.append( Character.forDigit( b & MASK, RADIX ) );
}
- return new URL( buf.toString() );
- }
- catch ( UnsupportedEncodingException e )
- {
- // should not happen as UTF-8 must be present
- throw new RuntimeException( e );
}
+ return new URL( buf.toString() );
}
}
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
index 84a445ddd8..8394e00a1a 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
@@ -29,10 +29,12 @@ public class SurefireReflectorTest
public void testShouldCreateFactoryWithoutException()
{
ReporterFactory factory = new ReporterFactory() {
+ @Override
public RunListener createReporter() {
return null;
}
+ @Override
public RunResult close() {
return null;
}
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriterTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriterTest.java
index eb81871188..d81e8165b9 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriterTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriterTest.java
@@ -136,6 +136,7 @@ public MockThrowable( String stackTrace )
this.stackTrace = stackTrace;
}
+ @Override
public void printStackTrace( PrintWriter s )
{
s.write( stackTrace );
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
index 964fa1087c..d5ecc46812 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
@@ -35,6 +35,7 @@ public class UrlUtilsTest
{
private String homeDir;
+ @Override
public void setUp()
throws Exception
{
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ConcurrencyUtilsTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ConcurrencyUtilsTest.java
index 516f8850d9..7e76fbfa35 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ConcurrencyUtilsTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ConcurrencyUtilsTest.java
@@ -81,6 +81,7 @@ public void countDownShouldBeDecreasedByTwoThreadsModification()
FutureTask task = new FutureTask( new Callable()
{
+ @Override
public Boolean call()
throws Exception
{
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
index e7d97c86e1..346e0755d4 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
@@ -139,6 +139,7 @@ public void writeToSystemProperty( String propertyName )
System.setProperty( propertyName, sb.toString() );
}
+ @Override
public boolean equals( Object o )
{
if ( this == o )
@@ -179,6 +180,7 @@ public ClassLoader createClassLoader( ClassLoader parent, boolean childDelegatio
}
}
+ @Override
public int hashCode()
{
return unmodifiableElements.hashCode();
@@ -223,6 +225,7 @@ public String getCompactLogMessage( String descriptor )
return result.toString();
}
+ @Override
public Iterator iterator()
{
return unmodifiableElements.iterator();
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 3c18578047..d5bba1f751 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -217,6 +217,7 @@ private static CommandListener createPingHandler( final AtomicBoolean pingDone )
{
return new CommandListener()
{
+ @Override
public void update( Command command )
{
pingDone.set( true );
@@ -228,6 +229,7 @@ private static CommandListener createExitHandler()
{
return new CommandListener()
{
+ @Override
public void update( Command command )
{
Shutdown shutdown = command.toShutdownData();
@@ -248,6 +250,7 @@ private static Runnable createPingJob( final AtomicBoolean pingDone )
{
return new Runnable()
{
+ @Override
public void run()
{
boolean hasPing = pingDone.getAndSet( false );
@@ -361,6 +364,7 @@ private static void launchLastDitchDaemonShutdownThread( final int returnCode )
{
getJvmTerminator().schedule( new Runnable()
{
+ @Override
public void run()
{
Runtime.getRuntime().halt( returnCode );
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java
index 31db087a27..a4d7d09778 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java
@@ -53,6 +53,7 @@ public IsolatedClassLoader( ClassLoader parent, boolean childDelegation, String
* @deprecated this method will use {@link java.io.File} instead of {@link URL} in the next
* major version.
*/
+ @Override
@Deprecated
public void addURL( URL url )
{
@@ -65,6 +66,7 @@ public void addURL( URL url )
}
}
+ @Override
public synchronized Class loadClass( String name )
throws ClassNotFoundException
{
@@ -99,6 +101,7 @@ public synchronized Class loadClass( String name )
}
}
+ @Override
public String toString()
{
return "IsolatedClassLoader{roleName='" + roleName + "'}";
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
index 29a59b67c8..3237d077fa 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
@@ -63,16 +63,19 @@ private final class BlockingIterator
{
private final Iterator it = getReader().getIterableClasses( originalOutStream ).iterator();
+ @Override
public boolean hasNext()
{
return it.hasNext();
}
+ @Override
public Class> next()
{
return findClass( it.next() );
}
+ @Override
public void remove()
{
throw new UnsupportedOperationException();
@@ -93,6 +96,7 @@ public Iterator> iterated()
* {@inheritDoc}
* @see org.apache.maven.surefire.util.TestsToRun#iterator()
* */
+ @Override
public Iterator> iterator()
{
return new BlockingIterator();
@@ -102,6 +106,7 @@ public Iterator> iterator()
* {@inheritDoc}
* @see org.apache.maven.surefire.util.TestsToRun#toString()
*/
+ @Override
public String toString()
{
return "LazyTestsToRun";
@@ -111,6 +116,7 @@ public String toString()
* {@inheritDoc}
* @see org.apache.maven.surefire.util.TestsToRun#allowEagerReading()
*/
+ @Override
public boolean allowEagerReading()
{
return false;
@@ -153,6 +159,7 @@ protected void doRemove()
{
}
+ @Override
public void remove()
{
throw new UnsupportedOperationException( "unsupported remove" );
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
index 5a19e26027..41b48500e1 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
@@ -167,6 +167,7 @@ public void addList( List items, String propertyPrefix )
}
}
+ @Override
public void copyTo( Map target )
{
target.putAll( properties );
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
index 36f823b9bd..ae4e08eca5 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
@@ -134,6 +134,7 @@ private ProviderProxy( Object providerInOtherClassLoader, ClassLoader testsClass
this.testsClassLoader = testsClassLoader;
}
+ @Override
@SuppressWarnings( "unchecked" )
public Iterable> getSuites()
{
@@ -148,6 +149,7 @@ public Iterable> getSuites()
}
}
+ @Override
public RunResult invoke( Object forkTestSet )
throws TestSetFailedException, InvocationTargetException
{
@@ -175,6 +177,7 @@ private ClassLoader swapClassLoader( ClassLoader newClassLoader )
return current;
}
+ @Override
public void cancel()
{
Class> providerType = providerInOtherClassLoader.getClass();
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java
index bbd0f7056d..b5ad18fd60 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java
@@ -21,9 +21,11 @@
import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.IOException;
import java.util.Properties;
import static org.apache.maven.surefire.util.ReflectionUtils.loadClass;
+import static org.apache.maven.surefire.util.internal.StringUtils.ISO_8859_1;
/**
* @author Kristian Rosenvold
@@ -79,13 +81,12 @@ else if ( type.equals( Integer.class.getName() ) )
else if ( type.equals( Properties.class.getName() ) )
{
Properties result = new Properties();
- // todo: use jdk7 Closable
try
{
- result.load( new ByteArrayInputStream( value.getBytes( "8859_1" ) ) );
+ result.load( new ByteArrayInputStream( value.getBytes( ISO_8859_1 ) ) );
return result;
}
- catch ( Exception e )
+ catch ( IOException e )
{
throw new IllegalStateException( "bug in property conversion", e );
}
@@ -96,6 +97,7 @@ else if ( type.equals( Properties.class.getName() ) )
}
}
+ @Override
public boolean equals( Object o )
{
if ( this == o )
@@ -113,6 +115,7 @@ public boolean equals( Object o )
}
+ @Override
public int hashCode()
{
int result = type != null ? type.hashCode() : 0;
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/CommandReaderTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/CommandReaderTest.java
index b731dc07cc..ccc33d5fb7 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/CommandReaderTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/CommandReaderTest.java
@@ -40,7 +40,7 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
-import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
+import static org.apache.maven.surefire.util.internal.StringUtils.ISO_8859_1;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -160,6 +160,7 @@ public void stopBeforeReadInThread()
{
Runnable runnable = new Runnable()
{
+ @Override
public void run()
{
Iterator it = reader.getIterableClasses( nul() ).iterator();
@@ -187,6 +188,7 @@ public void readTwoClassesInThread()
final CountDownLatch counter = new CountDownLatch( 1 );
Runnable runnable = new Runnable()
{
+ @Override
public void run()
{
Iterator it = reader.getIterableClasses( nul() ).iterator();
@@ -240,7 +242,7 @@ public int read()
private void addTestToPipeline( String cls )
throws UnsupportedEncodingException
{
- byte[] clazz = cls.getBytes( FORK_STREAM_CHARSET_NAME );
+ byte[] clazz = cls.getBytes( ISO_8859_1 );
ByteBuffer buffer = ByteBuffer.allocate( 8 + clazz.length )
.putInt( MasterProcessCommand.RUN_CLASS.getId() )
.putInt( clazz.length )
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java
index 99b856494c..911c96982f 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java
@@ -52,6 +52,7 @@ public class Foo
boolean called = false;
+ @Override
public void setDirectoryScannerParameters( DirectoryScannerParameters directoryScanner )
{
this.directoryScannerParameters = directoryScanner;
@@ -68,18 +69,21 @@ public Boolean isCalled()
return called;
}
+ @Override
public void setProviderProperties( Map providerProperties )
{
this.providerProperties = providerProperties;
this.called = true;
}
+ @Override
public void setReporterConfiguration( ReporterConfiguration reporterConfiguration )
{
this.reporterConfiguration = reporterConfiguration;
this.called = true;
}
+ @Override
public void setClassLoaders( ClassLoader testClassLoader )
{
this.testClassLoader = testClassLoader;
@@ -87,18 +91,21 @@ public void setClassLoaders( ClassLoader testClassLoader )
this.called = true;
}
+ @Override
public void setTestRequest( TestRequest testRequest1 )
{
this.testRequest = testRequest1;
this.called = true;
}
+ @Override
public void setTestArtifactInfo( TestArtifactInfo testArtifactInfo )
{
this.testArtifactInfo = testArtifactInfo;
this.called = true;
}
+ @Override
public void setRunOrderParameters( RunOrderParameters runOrderParameters )
{
this.runOrderParameters = runOrderParameters;
diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java
index 1ffc89483d..e9adb22b5f 100644
--- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java
+++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java
@@ -45,6 +45,7 @@ public AndGroupMatcher( Collection matchers )
}
}
+ @Override
public boolean enabled( Class>... cats )
{
for ( GroupMatcher matcher : getMatchers() )
@@ -59,6 +60,7 @@ public boolean enabled( Class>... cats )
return true;
}
+ @Override
public boolean enabled( String... cats )
{
for ( GroupMatcher matcher : getMatchers() )
diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java
index 0ab1d43355..2028b1bca1 100644
--- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java
+++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java
@@ -35,11 +35,13 @@ public InverseGroupMatcher( GroupMatcher matcher )
this.matcher = matcher;
}
+ @Override
public boolean enabled( Class>... cats )
{
return cats == null || !matcher.enabled( cats );
}
+ @Override
public boolean enabled( String... cats )
{
return cats == null || !matcher.enabled( cats );
@@ -87,6 +89,7 @@ else if ( !matcher.equals( other.matcher ) )
return true;
}
+ @Override
public void loadGroupClasses( ClassLoader cloader )
{
matcher.loadGroupClasses( cloader );
diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java
index ec8ac7640e..f130ee48a4 100644
--- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java
+++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java
@@ -42,6 +42,7 @@ protected final Set getMatchers()
return matchers;
}
+ @Override
public void loadGroupClasses( ClassLoader cloader )
{
for ( GroupMatcher matcher : matchers )
diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java
index 65122c7a2b..631086e913 100644
--- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java
+++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java
@@ -45,6 +45,7 @@ public OrGroupMatcher( Collection matchers )
}
}
+ @Override
public boolean enabled( Class>... cats )
{
for ( GroupMatcher matcher : getMatchers() )
@@ -59,6 +60,7 @@ public boolean enabled( Class>... cats )
return false;
}
+ @Override
public boolean enabled( String... cats )
{
for ( GroupMatcher matcher : getMatchers() )
diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java
index 99dde99100..72fc801244 100644
--- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java
+++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java
@@ -83,6 +83,7 @@ public String toString()
return "*" + enabled;
}
+ @Override
public boolean enabled( Class>... cats )
{
if ( cats != null )
@@ -105,6 +106,7 @@ public boolean enabled( Class>... cats )
return false;
}
+ @Override
public boolean enabled( String... cats )
{
for ( String cat : cats )
@@ -128,6 +130,7 @@ public boolean enabled( String... cats )
return false;
}
+ @Override
public void loadGroupClasses( ClassLoader classLoader )
{
try
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java
index 05ba2f92f0..5ba0577eac 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java
@@ -27,6 +27,7 @@
public class ForkModeTestNGIT
extends ForkModeIT
{
+ @Override
protected String getProject()
{
return "fork-mode-testng";
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java
index fcfcc9f614..b96cf9bd60 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java
@@ -29,6 +29,7 @@ public FailsafeOutputValidator( OutputValidator source )
super( source.verifier );
}
+ @Override
public OutputValidator verifyErrorFree( int total )
{
try
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java
index afd64932d3..a76f86ffd5 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java
@@ -191,7 +191,7 @@ public TestFile getSurefireReportsFile( String fileName )
public TestFile getSurefireReportsXmlFile( String fileName )
{
File targetDir = getSurefireReportsDirectory();
- return new TestFile( new File( targetDir, fileName ), Charset.forName("UTF-8"), this );
+ return new TestFile( new File( targetDir, fileName ), Charset.forName( "UTF-8" ), this );
}
public File getSurefireReportsDirectory()
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java
index c50d4e40b1..a39f870c31 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java
@@ -105,6 +105,7 @@ private static class IsRegex
this.expectedRegex = expectedRegex;
}
+ @Override
public boolean matches( Object o )
{
if ( o != null && o instanceof Set )
@@ -127,6 +128,7 @@ public boolean matches( Object o )
}
}
+ @Override
public void describeTo( Description description )
{
description.appendValue( expectedRegex );
diff --git a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerDecorator.java b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerDecorator.java
index e5653533fd..0e20105d91 100644
--- a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerDecorator.java
+++ b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLoggerDecorator.java
@@ -1 +1 @@
-package org.apache.maven.plugin.surefire.log.api;
/*
* 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.
*/
/**
* Decorator around {@link ConsoleLogger}.
* This class is loaded in the isolated ClassLoader and the child logger in the in-plugin ClassLoader.
*
* @author Tibor Digana (tibor17)
* @since 2.20
*/
public final class ConsoleLoggerDecorator
implements ConsoleLogger
{
private final Object logger;
public ConsoleLoggerDecorator( Object logger )
{
if ( logger == null )
{
throw new NullPointerException( "logger argument is null in " + ConsoleLoggerDecorator.class );
}
this.logger = logger;
}
public void debug( String message )
{
try
{
logger.getClass()
.getMethod( "debug", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void info( String message )
{
try
{
logger.getClass()
.getMethod( "info", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void warning( String message )
{
try
{
logger.getClass()
.getMethod( "warning", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void error( String message )
{
try
{
logger.getClass()
.getMethod( "error", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void error( String message, Throwable t )
{
try
{
logger.getClass()
.getMethod( "error", String.class, Throwable.class )
.invoke( logger, message, t );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
public void error( Throwable t )
{
try
{
logger.getClass()
.getMethod( "error", Throwable.class )
.invoke( logger, t );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
}
\ No newline at end of file
+package org.apache.maven.plugin.surefire.log.api;
/*
* 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.
*/
/**
* Decorator around {@link ConsoleLogger}.
* This class is loaded in the isolated ClassLoader and the child logger in the in-plugin ClassLoader.
*
* @author Tibor Digana (tibor17)
* @since 2.20
*/
public final class ConsoleLoggerDecorator
implements ConsoleLogger
{
private final Object logger;
public ConsoleLoggerDecorator( Object logger )
{
if ( logger == null )
{
throw new NullPointerException( "logger argument is null in " + ConsoleLoggerDecorator.class );
}
this.logger = logger;
}
@Override
public void debug( String message )
{
try
{
logger.getClass()
.getMethod( "debug", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
@Override
public void info( String message )
{
try
{
logger.getClass()
.getMethod( "info", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
@Override
public void warning( String message )
{
try
{
logger.getClass()
.getMethod( "warning", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
@Override
public void error( String message )
{
try
{
logger.getClass()
.getMethod( "error", String.class )
.invoke( logger, message );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
@Override
public void error( String message, Throwable t )
{
try
{
logger.getClass()
.getMethod( "error", String.class, Throwable.class )
.invoke( logger, message, t );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
@Override
public void error( Throwable t )
{
try
{
logger.getClass()
.getMethod( "error", Throwable.class )
.invoke( logger, t );
}
catch ( Exception e )
{
throw new IllegalStateException( e.getLocalizedMessage(), e );
}
}
}
\ No newline at end of file
diff --git a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/NullConsoleLogger.java b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/NullConsoleLogger.java
index fa09d83ca8..4094fe453e 100644
--- a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/NullConsoleLogger.java
+++ b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/NullConsoleLogger.java
@@ -27,26 +27,32 @@
*/
public final class NullConsoleLogger implements ConsoleLogger
{
+ @Override
public void debug( String message )
{
}
+ @Override
public void info( String message )
{
}
+ @Override
public void warning( String message )
{
}
+ @Override
public void error( String message )
{
}
+ @Override
public void error( String message, Throwable t )
{
}
+ @Override
public void error( Throwable t )
{
}
diff --git a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/PrintStreamLogger.java b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/PrintStreamLogger.java
index 0eac176c5f..5c9c99d47f 100644
--- a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/PrintStreamLogger.java
+++ b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/PrintStreamLogger.java
@@ -1 +1,72 @@
-package org.apache.maven.plugin.surefire.log.api;
/*
* 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 java.io.PrintStream;
/**
* For testing purposes.
*/
public class PrintStreamLogger
implements ConsoleLogger
{
private final PrintStream stream;
public PrintStreamLogger( PrintStream stream )
{
this.stream = stream;
}
public void debug( String message )
{
stream.println( message );
}
public void info( String message )
{
stream.println( message );
}
public void warning( String message )
{
stream.println( message );
}
public void error( String message )
{
stream.println( message );
}
public void error( String message, Throwable t )
{
error( ConsoleLoggerUtils.toString( message, t ) );
}
public void error( Throwable t )
{
error( null, t );
}
}
\ No newline at end of file
+package org.apache.maven.plugin.surefire.log.api;
+
+/*
+ * 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 java.io.PrintStream;
+
+/**
+ * For testing purposes.
+ */
+public class PrintStreamLogger
+ implements ConsoleLogger
+{
+ private final PrintStream stream;
+
+ public PrintStreamLogger( PrintStream stream )
+ {
+ this.stream = stream;
+ }
+
+ @Override
+ public void debug( String message )
+ {
+ stream.println( message );
+ }
+
+ @Override
+ public void info( String message )
+ {
+ stream.println( message );
+ }
+
+ @Override
+ public void warning( String message )
+ {
+ stream.println( message );
+ }
+
+ @Override
+ public void error( String message )
+ {
+ stream.println( message );
+ }
+
+ @Override
+ public void error( String message, Throwable t )
+ {
+ error( ConsoleLoggerUtils.toString( message, t ) );
+ }
+
+ @Override
+ public void error( Throwable t )
+ {
+ error( null, t );
+ }
+}
diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/ClassNameStackTraceFilter.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/ClassNameStackTraceFilter.java
index 676743091a..bfc5b779ba 100644
--- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/ClassNameStackTraceFilter.java
+++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/ClassNameStackTraceFilter.java
@@ -32,6 +32,7 @@ final class ClassNameStackTraceFilter
this.className = className;
}
+ @Override
public boolean matches( StackTraceElement element )
{
return className.equals( element.getClassName() );
diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/NullStackTraceFilter.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/NullStackTraceFilter.java
index cced1d4944..3172320928 100644
--- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/NullStackTraceFilter.java
+++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/NullStackTraceFilter.java
@@ -25,6 +25,7 @@
final class NullStackTraceFilter
implements StackTraceFilter
{
+ @Override
public boolean matches( StackTraceElement element )
{
return true;
diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
index fdbc1be204..99aca603c6 100644
--- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
+++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
@@ -46,6 +46,7 @@ public PojoStackTraceWriter( String testClass, String testMethod, Throwable t )
this.t = t;
}
+ @Override
public String writeTraceToString()
{
if ( t != null )
@@ -76,16 +77,19 @@ public String writeTraceToString()
return "";
}
+ @Override
public String smartTrimmedStackTrace()
{
return t == null ? "" : new SmartStackTraceParser( testClass, t, testMethod ).getString();
}
+ @Override
public String writeTrimmedTraceToString()
{
return t == null ? "" : SmartStackTraceParser.stackTraceWithFocusOnClassAsString( t, testClass );
}
+ @Override
public SafeThrowable getThrowable()
{
return t == null ? null : new SafeThrowable( t );
diff --git a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass1.java b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass1.java
index 841490309a..ef007b23cc 100644
--- a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass1.java
+++ b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass1.java
@@ -27,6 +27,7 @@
class RunnableTestClass1
implements Callable
{
+ @Override
public Object call()
throws Exception
{
diff --git a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass2.java b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass2.java
index 8a13b0ebf1..b782df8ed0 100644
--- a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass2.java
+++ b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass2.java
@@ -25,6 +25,7 @@ class RunnableTestClass2
{
+ @Override
public Object call()
throws Exception
{
diff --git a/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3TestChecker.java b/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3TestChecker.java
index f6837144b2..d7279465a9 100644
--- a/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3TestChecker.java
+++ b/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3TestChecker.java
@@ -49,6 +49,7 @@ public JUnit3TestChecker( ClassLoader testClassLoader )
junitClass = ReflectionUtils.tryLoadClass( testClassLoader, "junit.framework.Test" );
}
+ @Override
public boolean accept( Class testClass )
{
return nonAbstractClassFilter.accept( testClass ) && isValidJUnit3Test( testClass );
diff --git a/surefire-providers/common-junit3/src/test/java/org/apache/maven/surefire/common/junit3/JUnit3TestCheckerTest.java b/surefire-providers/common-junit3/src/test/java/org/apache/maven/surefire/common/junit3/JUnit3TestCheckerTest.java
index 7d4b7517be..e0ae2e7faa 100644
--- a/surefire-providers/common-junit3/src/test/java/org/apache/maven/surefire/common/junit3/JUnit3TestCheckerTest.java
+++ b/surefire-providers/common-junit3/src/test/java/org/apache/maven/surefire/common/junit3/JUnit3TestCheckerTest.java
@@ -106,11 +106,13 @@ public static MySuite2 suite()
public static class MySuite2
implements junit.framework.Test
{
+ @Override
public int countTestCases()
{
return 0;
}
+ @Override
public void run( TestResult testResult )
{
}
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java
index 026e35d382..2d651c42b3 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java
@@ -124,11 +124,13 @@ public IgnoredWithUserError()
this( "" );
}
+ @Override
public String value()
{
return value;
}
+ @Override
public Class extends Annotation> annotationType()
{
return Ignore.class;
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
index 1d365cfc09..06f0fcace9 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
@@ -68,6 +68,7 @@ public JUnit4RunListener( RunListener reporter )
*
* @see org.junit.runner.notification.RunListener#testIgnored(org.junit.runner.Description)
*/
+ @Override
public void testIgnored( Description description )
throws Exception
{
@@ -80,6 +81,7 @@ public void testIgnored( Description description )
*
* @see org.junit.runner.notification.RunListener#testStarted(org.junit.runner.Description)
*/
+ @Override
public void testStarted( Description description )
throws Exception
{
@@ -92,6 +94,7 @@ public void testStarted( Description description )
*
* @see org.junit.runner.notification.RunListener#testFailure(org.junit.runner.notification.Failure)
*/
+ @Override
@SuppressWarnings( { "ThrowableResultOfMethodCallIgnored" } )
public void testFailure( Failure failure )
throws Exception
@@ -131,6 +134,7 @@ public void testAssumptionFailure( Failure failure )
*
* @see org.junit.runner.notification.RunListener#testFinished(org.junit.runner.Description)
*/
+ @Override
public void testFinished( Description description )
throws Exception
{
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
index 33f499e343..78cefb6394 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
@@ -55,6 +55,7 @@ public JUnit4StackTraceWriter( Failure junitFailure )
*
* @see org.apache.maven.surefire.report.StackTraceWriter#writeTraceToString()
*/
+ @Override
public String writeTraceToString()
{
Throwable t = junitFailure.getException();
@@ -87,6 +88,7 @@ protected String getTestMethodName()
return extractMethodName( junitFailure.getDescription().getDisplayName() );
}
+ @Override
@SuppressWarnings( "ThrowableResultOfMethodCallIgnored" )
public String smartTrimmedStackTrace()
{
@@ -101,6 +103,7 @@ public String smartTrimmedStackTrace()
*
* @see org.apache.maven.surefire.report.StackTraceWriter#writeTrimmedTraceToString()
*/
+ @Override
public String writeTrimmedTraceToString()
{
String testClass = getTestClassName();
@@ -120,6 +123,7 @@ public String writeTrimmedTraceToString()
*
* @see org.apache.maven.surefire.report.StackTraceWriter#getThrowable()
*/
+ @Override
public SafeThrowable getThrowable()
{
return new SafeThrowable( junitFailure.getException() );
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4TestChecker.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4TestChecker.java
index c2a6c18527..49afaa7fb3 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4TestChecker.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4TestChecker.java
@@ -47,6 +47,7 @@ public JUnit4TestChecker( ClassLoader testClassLoader )
nonAbstractClassFilter = new NonAbstractClassFilter();
}
+ @Override
public boolean accept( Class testClass )
{
return jUnit3TestChecker.accept( testClass ) || isValidJUnit4Test( testClass );
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java
index 99d7aae6e5..12cbb4c2d1 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java
@@ -55,21 +55,25 @@ public MockReporter()
{
}
+ @Override
public void testSetStarting( ReportEntry report )
{
events.add( SET_STARTED );
}
+ @Override
public void testSetCompleted( ReportEntry report )
{
events.add( SET_COMPLETED );
}
+ @Override
public void testStarting( ReportEntry report )
{
events.add( TEST_STARTED );
}
+ @Override
public void testSucceeded( ReportEntry report )
{
events.add( TEST_COMPLETED );
@@ -77,12 +81,14 @@ public void testSucceeded( ReportEntry report )
}
+ @Override
public void testSkipped( ReportEntry report )
{
events.add( TEST_SKIPPED );
testIgnored.incrementAndGet();
}
+ @Override
public void testExecutionSkippedByUser()
{
}
@@ -102,16 +108,19 @@ public int getTestFailed()
return testFailed.get();
}
+ @Override
public void testError( ReportEntry report )
{
testError.incrementAndGet();
}
+ @Override
public void testFailed( ReportEntry report )
{
testFailed.incrementAndGet();
}
+ @Override
public void testAssumptionFailure( ReportEntry report )
{
}
diff --git a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
index deda5381e3..baf458966d 100644
--- a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
+++ b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
@@ -63,6 +63,7 @@ public void testParallelInvocations()
DaemonThreadFactory.newDaemonThread( new Runnable()
{
+ @Override
public void run()
{
try
diff --git a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java
index a9f1b8006d..a20473476c 100644
--- a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java
+++ b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java
@@ -148,11 +148,13 @@ public static MySuite2 suite()
public static class MySuite2
implements junit.framework.Test
{
+ @Override
public int countTestCases()
{
return 0;
}
+ @Override
public void run( TestResult testResult )
{
}
diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
index c7f2bd7f6e..a07caaa234 100644
--- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
+++ b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
@@ -46,11 +46,13 @@ public JUnit46StackTraceWriter( Failure junitFailure )
}
+ @Override
protected final String getTestClassName()
{
return junitFailure.getDescription().getClassName();
}
+ @Override
protected String getTestMethodName()
{
return junitFailure.getDescription().getMethodName();
diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java
index 9da8715181..ab475ccbfd 100644
--- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java
+++ b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java
@@ -45,6 +45,7 @@ public JUnit48TestChecker( ClassLoader testClassLoader )
this.nonAbstractClassFilter = new NonAbstractClassFilter();
}
+ @Override
public boolean accept( Class testClass )
{
return jUnit4TestChecker.accept( testClass ) || isAbstractWithEnclosedRunner( testClass );
diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
index a707feee29..adfda35b8b 100644
--- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
+++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
@@ -69,6 +69,7 @@ public JUnit3Provider( ProviderParameters booterParameters )
testChecker = new PojoAndJUnit3Checker( jUnit3TestChecker ); // Todo; use reflector
}
+ @Override
public RunResult invoke( Object forkTestSet )
throws TestSetFailedException
{
@@ -143,6 +144,7 @@ private TestsToRun scanClassPath()
return runOrderCalculator.orderTestClasses( testsToRun );
}
+ @Override
public Iterable> getSuites()
{
testsToRun = scanClassPath();
diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java
index 919be7a969..4dd1bbcd95 100644
--- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java
+++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java
@@ -64,6 +64,7 @@ public JUnitTestSet( Class testClass, JUnit3Reflector reflector )
}
+ @Override
public void execute( RunListener reporter, ClassLoader loader )
throws TestSetFailedException
{
@@ -120,6 +121,7 @@ public void execute( RunListener reporter, ClassLoader loader )
}
}
+ @Override
public String getName()
{
return testClass.getName();
diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java
index d3529c110f..e9debcefba 100644
--- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java
+++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java
@@ -38,6 +38,7 @@ public PojoAndJUnit3Checker( JUnit3TestChecker jUnit3TestChecker )
this.jUnit3TestChecker = jUnit3TestChecker;
}
+ @Override
public boolean accept( Class testClass )
{
return jUnit3TestChecker.accept( testClass )
diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java
index d0f15cb984..4d589a63e9 100644
--- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java
+++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java
@@ -75,6 +75,7 @@ public PojoTestSet( Class> testClass )
}
}
+ @Override
public void execute( RunListener reportManager, ClassLoader loader )
throws TestSetFailedException
{
@@ -289,6 +290,7 @@ private static boolean isValidTestMethod( Method m )
return isInstanceMethod && returnsVoid && hasNoParams;
}
+ @Override
public String getName()
{
return testClass.getName();
diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java
index c4c0f51b39..c96b96d10f 100644
--- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java
+++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java
@@ -76,6 +76,7 @@ private static class FailedTest
this.threadOnWhichTestFailed = threadOnWhichTestFailed;
}
+ @Override
public boolean equals( Object obj )
{
boolean retVal = true;
@@ -101,6 +102,7 @@ else if ( !ft.threadOnWhichTestFailed.equals( threadOnWhichTestFailed ) )
return retVal;
}
+ @Override
public int hashCode()
{
return threadOnWhichTestFailed.hashCode();
@@ -117,6 +119,7 @@ public TestListenerInvocationHandler( RunListener reporter )
this.reporter = reporter;
}
+ @Override
public Object invoke( Object proxy, Method method, Object[] args )
throws Throwable
{
diff --git a/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java b/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java
index 9ca397e00d..359a79f3fe 100644
--- a/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java
+++ b/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java
@@ -63,43 +63,52 @@ public static class SuccessListener
private List succeededTests = new ArrayList();
+ @Override
public void testSetStarting( ReportEntry report )
{
}
+ @Override
public void testSetCompleted( ReportEntry report )
{
}
+ @Override
public void testStarting( ReportEntry report )
{
}
+ @Override
public void testSucceeded( ReportEntry report )
{
this.succeededTests.add( report );
}
+ @Override
public void testAssumptionFailure( ReportEntry report )
{
throw new IllegalStateException();
}
+ @Override
public void testError( ReportEntry report )
{
throw new IllegalStateException();
}
+ @Override
public void testFailed( ReportEntry report )
{
throw new IllegalStateException();
}
+ @Override
public void testSkipped( ReportEntry report )
{
throw new IllegalStateException();
}
+ @Override
public void testExecutionSkippedByUser()
{
}
diff --git a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
index f835cec989..12842fae6f 100644
--- a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
+++ b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
@@ -112,6 +112,7 @@ public JUnit4Provider( ProviderParameters bootParams )
rerunFailingTestsCount = testRequest.getRerunFailingTestsCount();
}
+ @Override
public RunResult invoke( Object forkTestSet )
throws TestSetFailedException
{
@@ -209,6 +210,7 @@ private void registerShutdownListener( final TestsToRun testsToRun )
{
commandsReader.addShutdownListener( new CommandListener()
{
+ @Override
public void update( Command command )
{
testsToRun.markTestSetFinished();
@@ -220,6 +222,7 @@ private void registerPleaseStopJUnitListener( final Notifier notifier )
{
commandsReader.addSkipNextTestsListener( new CommandListener()
{
+ @Override
public void update( Command command )
{
notifier.pleaseStop();
@@ -298,6 +301,7 @@ private void executeWithRerun( Class> clazz, Notifier notifier )
}
}
+ @Override
public Iterable> getSuites()
{
testsToRun = scanClassPath();
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java
index 8faa12e13d..0d9bacf1cf 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java
@@ -48,12 +48,14 @@ public AsynchronousRunner( ExecutorService fService )
this.fService = fService;
}
+ @Override
public void schedule( final Runnable childStatement )
{
futures.add( fService.submit( Executors.callable( childStatement ) ) );
}
+ @Override
public void finished()
{
try
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentRunListener.java
index 89c6104d37..8095dbfd06 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentRunListener.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentRunListener.java
@@ -69,10 +69,12 @@ protected RunListener initialValue()
};
}
+ @Override
public void testSetStarting( ReportEntry description )
{
}
+ @Override
public void testSetCompleted( ReportEntry result )
{
final RunListener reporterManager = getRunListener();
@@ -83,6 +85,7 @@ public void testSetCompleted( ReportEntry result )
reporterManagerThreadLocal.remove();
}
+ @Override
public void testFailed( ReportEntry failure )
{
final TestMethod testMethod = getOrCreateThreadAttachedTestMethod( failure );
@@ -93,6 +96,7 @@ public void testFailed( ReportEntry failure )
}
}
+ @Override
public void testError( ReportEntry failure )
{
final TestMethod testMethod = getOrCreateThreadAttachedTestMethod( failure );
@@ -103,6 +107,7 @@ public void testError( ReportEntry failure )
}
}
+ @Override
public void testSkipped( ReportEntry description )
{
TestSet testSet = getTestSet( description );
@@ -112,12 +117,14 @@ public void testSkipped( ReportEntry description )
testMethod.detachFromCurrentThread();
}
+ @Override
public void testExecutionSkippedByUser()
{
// cannot guarantee proper call to all listeners
reporterManagerThreadLocal.get().testExecutionSkippedByUser();
}
+ @Override
public void testAssumptionFailure( ReportEntry failure )
{
final TestMethod testMethod = getOrCreateThreadAttachedTestMethod( failure );
@@ -128,6 +135,7 @@ public void testAssumptionFailure( ReportEntry failure )
}
}
+ @Override
public void testStarting( ReportEntry description )
{
TestSet testSet = getTestSet( description );
@@ -137,6 +145,7 @@ public void testStarting( ReportEntry description )
testSet.attachToThread();
}
+ @Override
public void testSucceeded( ReportEntry report )
{
TestMethod testMethod = getThreadTestMethod();
@@ -196,6 +205,7 @@ public static ConcurrentRunListener createInstance( Map classMe
}
+ @Override
public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
{
TestMethod threadTestMethod = getThreadTestMethod();
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
index 0f41b6f663..a4c061e81d 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
@@ -103,6 +103,7 @@ public JUnitCoreProvider( ProviderParameters bootParams )
jUnit48Reflector = new JUnit48Reflector( testClassLoader );
}
+ @Override
public Iterable> getSuites()
{
testsToRun = scanClassPath();
@@ -114,6 +115,7 @@ private boolean isSingleThreaded()
return jUnitCoreParameters.isNoThreading();
}
+ @Override
public RunResult invoke( Object forkTestSet )
throws TestSetFailedException
{
@@ -219,6 +221,7 @@ private void registerShutdownListener( final TestsToRun testsToRun )
{
commandsReader.addShutdownListener( new CommandListener()
{
+ @Override
public void update( Command command )
{
testsToRun.markTestSetFinished();
@@ -230,6 +233,7 @@ private void registerPleaseStopJUnitListener( final Notifier stoppable )
{
commandsReader.addSkipNextTestsListener( new CommandListener()
{
+ @Override
public void update( Command command )
{
stoppable.pleaseStop();
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
index 81e4f80885..98b87ef5ab 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
@@ -59,6 +59,7 @@ public JUnitCoreRunListener( RunListener reporter, Map classMet
*
* @see org.junit.runner.notification.RunListener#testRunStarted(org.junit.runner.Description)
*/
+ @Override
public void testRunStarted( Description description )
throws Exception
{
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
index 539fd73484..0e5ee776ad 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
@@ -47,12 +47,14 @@ public NonConcurrentRunListener( RunListener reporter )
super( reporter );
}
+ @Override
public synchronized void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
{
// We can write immediately: no parallelism and a single class.
( (ConsoleOutputReceiver) reporter ).writeTestOutput( buf, off, len, stdout );
}
+ @Override
protected SimpleReportEntry createReportEntry( Description description )
{
return new SimpleReportEntry( extractDescriptionClassName( description ), description.getDisplayName() );
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java
index efbca98853..ebcbe8d85d 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java
@@ -31,11 +31,13 @@
class SynchronousRunner
implements RunnerScheduler
{
+ @Override
public void schedule( final Runnable childStatement )
{
childStatement.run();
}
+ @Override
public void finished()
{
}
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
index eb388c6929..ef70027abe 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
@@ -172,6 +172,7 @@ LogicalStream getLogicalStream()
return ls;
}
+ @Override
public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
{
getLogicalStream().write( stdout, buf, off, len );
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/AbstractThreadPoolStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/AbstractThreadPoolStrategy.java
index 5eb7715c8d..a3089525c4 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/AbstractThreadPoolStrategy.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/AbstractThreadPoolStrategy.java
@@ -126,6 +126,7 @@ protected void setDefaultShutdownHandler( Scheduler.ShutdownHandler handler )
}
}
+ @Override
public boolean destroy()
{
try
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java
index cc1a040886..0001b08e82 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java
@@ -91,6 +91,7 @@ public boolean finished()
return disable();
}
+ @Override
public boolean destroy()
{
return stop();
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/NullBalancer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/NullBalancer.java
index 56b95220b2..a80e8c506a 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/NullBalancer.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/NullBalancer.java
@@ -29,15 +29,18 @@
final class NullBalancer
implements Balancer
{
+ @Override
public boolean acquirePermit()
{
return true;
}
+ @Override
public void releasePermit()
{
}
+ @Override
public void releaseAllPermits()
{
}
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java
index afec8a3af5..a198887582 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java
@@ -182,6 +182,7 @@ private Callable createShutdownTask()
{
return new Callable()
{
+ @Override
public ShutdownResult call()
throws Exception
{
@@ -195,6 +196,7 @@ private Callable createForcedShutdownTask()
{
return new Callable()
{
+ @Override
public ShutdownResult call()
throws Exception
{
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Scheduler.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Scheduler.java
index 2c87fdd217..3c21409fb3 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Scheduler.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Scheduler.java
@@ -335,6 +335,7 @@ protected void afterExecute()
{
}
+ @Override
public void schedule( Runnable childStatement )
{
if ( childStatement == null )
@@ -365,6 +366,7 @@ else if ( canSchedule() && strategy.canSchedule() )
}
}
+ @Override
public void finished()
{
try
@@ -385,6 +387,7 @@ private Runnable wrapTask( final Runnable task )
{
return new Runnable()
{
+ @Override
public void run()
{
try
@@ -482,6 +485,7 @@ public void setRejectedExecutionHandler( RejectedExecutionHandler poolHandler )
this.poolHandler = poolHandler;
}
+ @Override
public void rejectedExecution( Runnable r, ThreadPoolExecutor executor )
{
if ( executor.isShutdown() )
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ThreadResourcesBalancer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ThreadResourcesBalancer.java
index 455874cfa5..070c457b21 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ThreadResourcesBalancer.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ThreadResourcesBalancer.java
@@ -68,6 +68,7 @@ final class ThreadResourcesBalancer
* @return true if current thread is NOT interrupted
* while waiting for a permit.
*/
+ @Override
public boolean acquirePermit()
{
try
@@ -84,11 +85,13 @@ public boolean acquirePermit()
/**
* Releases a permit, returning it to the balancer.
*/
+ @Override
public void releasePermit()
{
balancer.release();
}
+ @Override
public void releaseAllPermits()
{
balancer.release( numPermits );
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DefaultConsoleReporter.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DefaultConsoleReporter.java
index 0c8e856f21..53b20bb24f 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DefaultConsoleReporter.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DefaultConsoleReporter.java
@@ -36,31 +36,37 @@ public DefaultConsoleReporter( PrintStream systemOut )
this.systemOut = systemOut;
}
+ @Override
public void debug( String message )
{
}
+ @Override
public void info( String message )
{
systemOut.println( message );
}
+ @Override
public void warning( String message )
{
}
+ @Override
public void error( String message )
{
}
+ @Override
public void error( String message, Throwable t )
{
}
+ @Override
public void error( Throwable t )
{
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java
index 0af17cd45c..bef7bafa4e 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java
@@ -556,6 +556,7 @@ private static Collection jvmThreads()
appThreads.removeAll( Collections.singleton( (Thread) null ) );
Collections.sort( appThreads, new Comparator()
{
+ @Override
public int compare( Thread t1, Thread t2 )
{
return (int) Math.signum( t1.getId() - t2.getId() );
@@ -580,6 +581,7 @@ Result run( final boolean useInterrupt )
(ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer();
shutdownTask = new Runnable()
{
+ @Override
public void run()
{
Collection startedTests = computer.describeStopped( useInterrupt ).getTriggeredTests();
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/RangeMatcher.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/RangeMatcher.java
index a71d853e3a..0ee8033fd3 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/RangeMatcher.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/RangeMatcher.java
@@ -45,11 +45,13 @@ public static Matcher between( long from, long to )
return new RangeMatcher( from, to );
}
+ @Override
public void describeTo( Description description )
{
description.appendValueList( "between ", " and ", "", from, to );
}
+ @Override
public boolean matches( Object o )
{
long actual = (Long) o;
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java
index 98c3721d3d..812355f00e 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java
@@ -166,6 +166,7 @@ static class Task
{
volatile boolean result = false;
+ @Override
public void run()
{
result = true;
diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastListener.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastListener.java
index 91f3461216..b85826ff44 100644
--- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastListener.java
+++ b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastListener.java
@@ -39,36 +39,43 @@ public FailFastListener( Stoppable stoppable )
this.stoppable = stoppable;
}
+ @Override
public void onTestStart( ITestResult result )
{
}
+ @Override
public void onTestSuccess( ITestResult result )
{
}
+ @Override
public void onTestFailure( ITestResult result )
{
stoppable.fireStopEvent();
}
+ @Override
public void onTestSkipped( ITestResult result )
{
}
+ @Override
public void onTestFailedButWithinSuccessPercentage( ITestResult result )
{
}
+ @Override
public void onStart( ITestContext context )
{
}
+ @Override
public void onFinish( ITestContext context )
{
diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastNotifier.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastNotifier.java
index 735c2ce384..d9d7307759 100644
--- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastNotifier.java
+++ b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastNotifier.java
@@ -34,6 +34,7 @@ public class FailFastNotifier
implements IInvokedMethodListener
{
+ @Override
public void beforeInvocation( IInvokedMethod iInvokedMethod, ITestResult iTestResult )
{
if ( FailFastEventsSingleton.getInstance().isSkipAfterFailure() )
@@ -43,6 +44,7 @@ public void beforeInvocation( IInvokedMethod iInvokedMethod, ITestResult iTestRe
}
}
+ @Override
public void afterInvocation( IInvokedMethod iInvokedMethod, ITestResult iTestResult )
{
diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java
index db3bb41fcd..0017b54efe 100644
--- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java
+++ b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java
@@ -46,6 +46,7 @@ public class GroupMatcherMethodSelector
private Map answers = new HashMap();
+ @Override
public boolean includeMethod( IMethodSelectorContext context, ITestNGMethod method, boolean isTestMethod )
{
Boolean result = answers.get( method );
@@ -65,6 +66,7 @@ public boolean includeMethod( IMethodSelectorContext context, ITestNGMethod meth
return result;
}
+ @Override
public void setTestMethods( List testMethods )
{
}
diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java
index 9c601bba36..d55c079242 100644
--- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java
+++ b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java
@@ -38,10 +38,12 @@ public class MethodSelector
{
private static volatile TestListResolver testListResolver = null;
+ @Override
public void setTestMethods( List arg0 )
{
}
+ @Override
public boolean includeMethod( IMethodSelectorContext context, ITestNGMethod testngMethod, boolean isTestMethod )
{
return testngMethod.isBeforeClassConfiguration() || testngMethod.isBeforeGroupsConfiguration()
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
index f95c0f2e90..0b52c4d5ef 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
@@ -335,6 +335,7 @@ private static Stoppable createStoppable( final RunListener reportManager, int s
return new Stoppable()
{
+ @Override
public void fireStopEvent()
{
if ( countDownToZero( currentFaultCount ) )
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
index 56f98de3ca..a8a383754d 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
@@ -90,6 +90,7 @@ public TestNGProvider( ProviderParameters bootParams )
mainCliOptions = bootParams.getMainCliOptions();
}
+ @Override
public RunResult invoke( Object forkTestSet )
throws TestSetFailedException
{
@@ -173,6 +174,7 @@ private void registerShutdownListener( final TestsToRun testsToRun )
{
commandsReader.addShutdownListener( new CommandListener()
{
+ @Override
public void update( Command command )
{
testsToRun.markTestSetFinished();
@@ -184,6 +186,7 @@ private void registerPleaseStopListener()
{
commandsReader.addSkipNextTestsListener( new CommandListener()
{
+ @Override
public void update( Command command )
{
FailFastEventsSingleton.getInstance().setSkipOnNextTest();
@@ -206,6 +209,7 @@ private TestNGXmlTestSuite newXmlSuite()
reporterConfiguration.getReportsDirectory(), getSkipAfterFailureCount() );
}
+ @Override
@SuppressWarnings( "unchecked" )
public Iterable> getSuites()
{
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
index c6790be41d..d7d5ff9462 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
@@ -62,6 +62,7 @@ public TestNGReporter( RunListener reportManager )
this.reporter = reportManager;
}
+ @Override
public void onTestStart( ITestResult result )
{
String group = groupString( result.getMethod().getGroups(), result.getTestClass().getName() );
@@ -74,12 +75,14 @@ private String getSource( ITestResult result )
return result.getTestClass().getName();
}
+ @Override
public void onTestSuccess( ITestResult result )
{
ReportEntry report = new SimpleReportEntry( getSource( result ), getUserFriendlyTestName( result ) );
reporter.testSucceeded( report );
}
+ @Override
public void onTestFailure( ITestResult result )
{
ReportEntry report = withException( getSource( result ), getUserFriendlyTestName( result ),
@@ -96,6 +99,7 @@ private static String getUserFriendlyTestName( ITestResult result )
return result.getName() + "(" + result.getTestClass().getName() + ")";
}
+ @Override
public void onTestSkipped( ITestResult result )
{
Throwable t = result.getThrowable();
@@ -104,6 +108,7 @@ public void onTestSkipped( ITestResult result )
reporter.testSkipped( report );
}
+ @Override
public void onTestFailedButWithinSuccessPercentage( ITestResult result )
{
ReportEntry report = withException( getSource( result ), getUserFriendlyTestName( result ),
@@ -114,22 +119,26 @@ public void onTestFailedButWithinSuccessPercentage( ITestResult result )
reporter.testSucceeded( report );
}
+ @Override
public void onStart( ITestContext context )
{
}
+ @Override
public void onFinish( ITestContext context )
{
}
+ @Override
public void onStart( ISuite suite )
{
}
+ @Override
public void onFinish( ISuite suite )
{
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
index a471f0d4f7..c639ce928a 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
@@ -51,6 +51,7 @@ public abstract class AbstractDirectConfigurator
this.setters = options;
}
+ @Override
public void configure( TestNG testng, Map options )
throws TestSetFailedException
{
@@ -65,6 +66,7 @@ public void configure( TestNG testng, Map options )
testng.setListenerClasses( loadListenerClasses( listeners ) );
}
+ @Override
public void configure( XmlSuite suite, Map options )
throws TestSetFailedException
{
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java
index e374001500..1e4859f016 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java
@@ -34,6 +34,7 @@ public class TestNG60Configurator
extends TestNG5143Configurator
{
+ @Override
Map getConvertedOptions( Map options )
throws TestSetFailedException
{
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
index 91ade69f39..b819298e59 100755
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
@@ -49,6 +49,7 @@
public class TestNGMapConfigurator
implements Configurator
{
+ @Override
public void configure( TestNG testng, Map options )
throws TestSetFailedException
{
@@ -56,6 +57,7 @@ public void configure( TestNG testng, Map options )
testng.configure( convertedOptions );
}
+ @Override
public void configure( XmlSuite suite, Map options )
throws TestSetFailedException
{
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 96df5b81fb..cd94afd71d 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
@@ -159,6 +159,7 @@ public boolean hasFailure()
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return fullName;
diff --git a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestSuite.java b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestSuite.java
index a76b2ee881..76420baea2 100644
--- a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestSuite.java
+++ b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestSuite.java
@@ -196,6 +196,7 @@ ReportTestSuite setTestCases( List testCases )
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return fullClassName + " [" + getNumberOfTests() + "/" + getNumberOfFailures() + "/"
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 c28b4b191b..0d48e98f0b 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
@@ -117,6 +117,7 @@ public List parse( InputStreamReader stream )
/**
* {@inheritDoc}
*/
+ @Override
public void startElement( String uri, String localName, String qName, Attributes attributes )
throws SAXException
{
@@ -224,6 +225,7 @@ else if ( "failsafe-summary".equals( qName ) )
/**
* {@inheritDoc}
*/
+ @Override
public void endElement( String uri, String localName, String qName )
throws SAXException
{
@@ -254,6 +256,7 @@ else if ( "time".equals( qName ) )
/**
* {@inheritDoc}
*/
+ @Override
public void characters( char[] ch, int start, int length )
throws SAXException
{
diff --git a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/ReportTestCaseTest.java b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/ReportTestCaseTest.java
index a0abbfabea..ce7f2f375c 100644
--- a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/ReportTestCaseTest.java
+++ b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/ReportTestCaseTest.java
@@ -32,6 +32,7 @@ public class ReportTestCaseTest
/**
* {@inheritDoc}
*/
+ @Override
protected void setUp()
throws Exception
{
diff --git a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/ReportTestSuiteTest.java b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/ReportTestSuiteTest.java
index b9940b2e2f..729b60bf34 100644
--- a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/ReportTestSuiteTest.java
+++ b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/ReportTestSuiteTest.java
@@ -35,6 +35,7 @@ public class ReportTestSuiteTest
/**
* {@inheritDoc}
*/
+ @Override
protected void setUp()
throws Exception
{
diff --git a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportParserTest.java b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportParserTest.java
index 0fad166cfa..bfd9d49436 100644
--- a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportParserTest.java
+++ b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportParserTest.java
@@ -46,6 +46,7 @@ public class SurefireReportParserTest
/**
* {@inheritDoc}
*/
+ @Override
protected void setUp()
throws Exception
{
diff --git a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParserTest.java b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParserTest.java
index 6e0a325f3e..9e03f4a4f4 100644
--- a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParserTest.java
+++ b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParserTest.java
@@ -53,29 +53,35 @@ public void instantiateLogger()
{
consoleLogger = new ConsoleLogger()
{
+ @Override
public void debug( String message )
{
}
+ @Override
public void info( String message )
{
}
+ @Override
public void warning( String message )
{
loggedErrors.add( message );
}
+ @Override
public void error( String message )
{
loggedErrors.add( message );
}
+ @Override
public void error( String message, Throwable t )
{
loggedErrors.add( message );
}
+ @Override
public void error( Throwable t )
{
loggedErrors.add( t.getLocalizedMessage() );
From 9c0025ed53d70c06279fef6c0fc30a54aeeab27b Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 16 Apr 2017 17:52:44 +0200
Subject: [PATCH 084/194] [SUREFIRE-1361] Buffering in StatelessXmlReporter
---
.../report/ConsoleOutputFileReporter.java | 18 +++++++++++++++---
.../plugin/surefire/report/FileReporter.java | 11 ++++++++---
.../surefire/report/StatelessXmlReporter.java | 13 +++++++------
3 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
index 682686ca7e..35ee965048 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
@@ -19,9 +19,11 @@
* under the License.
*/
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import org.apache.maven.surefire.report.ReportEntry;
@@ -44,7 +46,7 @@ public class ConsoleOutputFileReporter
private String reportEntryName;
- private FileOutputStream fileOutputStream;
+ private OutputStream fileOutputStream;
public ConsoleOutputFileReporter( File reportsDirectory, String reportNameSuffix )
{
@@ -70,14 +72,24 @@ public void close()
{
if ( fileOutputStream != null )
{
+ //noinspection EmptyCatchBlock
try
{
fileOutputStream.flush();
- fileOutputStream.close();
}
catch ( IOException e )
{
}
+ finally
+ {
+ try
+ {
+ fileOutputStream.close();
+ }
+ catch ( IOException ignored )
+ {
+ }
+ }
fileOutputStream = null;
}
}
@@ -95,7 +107,7 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
reportsDirectory.mkdirs();
}
File file = getReportFile( reportsDirectory, reportEntryName, reportNameSuffix, "-output.txt" );
- fileOutputStream = new FileOutputStream( file );
+ fileOutputStream = new BufferedOutputStream( new FileOutputStream( file ), 16 * 1024 );
}
fileOutputStream.write( buf, off, len );
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
index a4d8c8e064..15b902de96 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
@@ -22,6 +22,7 @@
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.ReporterException;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
@@ -60,7 +61,7 @@ private PrintWriter testSetStarting( ReportEntry report )
try
{
- PrintWriter writer = new PrintWriter( new FileWriter( reportFile ) );
+ PrintWriter writer = new PrintWriter( new BufferedWriter( new FileWriter( reportFile ), 16 * 1024 ) );
writer.println( "-------------------------------------------------------------------------------" );
@@ -86,9 +87,10 @@ public static File getReportFile( File reportsDirectory, String reportEntryName,
public void testSetCompleted( WrappedReportEntry report, TestSetStats testSetStats, List testResults )
{
- PrintWriter writer = testSetStarting( report );
+ PrintWriter writer = null;
try
{
+ writer = testSetStarting( report );
writer.println( testSetStats.getTestSetSummary( report ) );
for ( String testResult : testResults )
{
@@ -98,7 +100,10 @@ public void testSetCompleted( WrappedReportEntry report, TestSetStats testSetSta
}
finally
{
- writer.close();
+ if ( writer != null )
+ {
+ writer.close();
+ }
}
}
}
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 c57123e645..d10151aaa4 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
@@ -27,6 +27,7 @@
import org.apache.maven.surefire.report.SafeThrowable;
import org.apache.maven.surefire.util.internal.StringUtils;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
@@ -120,7 +121,7 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat
getAddMethodEntryList( methodRunHistoryMap, methodEntry );
}
- FileOutputStream outputStream = getOutputStream( testSetReportEntry );
+ OutputStream outputStream = getOutputStream( testSetReportEntry );
OutputStreamWriter fw = getWriter( outputStream );
try
{
@@ -277,7 +278,7 @@ private Map> getAddMethodRunHistoryMap( String
return methodRunHistoryMap;
}
- private FileOutputStream getOutputStream( WrappedReportEntry testSetReportEntry )
+ private OutputStream getOutputStream( WrappedReportEntry testSetReportEntry )
{
File reportFile = getReportFile( testSetReportEntry, reportsDirectory, reportNameSuffix );
@@ -288,7 +289,7 @@ private FileOutputStream getOutputStream( WrappedReportEntry testSetReportEntry
try
{
- return new FileOutputStream( reportFile );
+ return new BufferedOutputStream( new FileOutputStream( reportFile ), 16 * 1024 );
}
catch ( Exception e )
{
@@ -296,7 +297,7 @@ private FileOutputStream getOutputStream( WrappedReportEntry testSetReportEntry
}
}
- private static OutputStreamWriter getWriter( FileOutputStream fos )
+ private static OutputStreamWriter getWriter( OutputStream fos )
{
return new OutputStreamWriter( fos, UTF_8 );
}
@@ -370,7 +371,7 @@ private void createTestSuiteElement( XMLWriter ppw, WrappedReportEntry report, T
}
private static void getTestProblems( OutputStreamWriter outputStreamWriter, XMLWriter ppw,
- WrappedReportEntry report, boolean trimStackTrace, FileOutputStream fw,
+ WrappedReportEntry report, boolean trimStackTrace, OutputStream fw,
String testErrorType, boolean createOutErrElementsInside )
{
ppw.startElement( testErrorType );
@@ -416,7 +417,7 @@ private static void getTestProblems( OutputStreamWriter outputStreamWriter, XMLW
// Create system-out and system-err elements
private static void createOutErrElements( OutputStreamWriter outputStreamWriter, XMLWriter ppw,
- WrappedReportEntry report, FileOutputStream fw )
+ WrappedReportEntry report, OutputStream fw )
{
EncodingOutputStream eos = new EncodingOutputStream( fw );
addOutputStreamElement( outputStreamWriter, eos, ppw, report.getStdout(), "system-out" );
From cba4adb1b93002c5b4bb2d2f22f461cc53bd8738 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Thu, 20 Apr 2017 21:07:55 +0200
Subject: [PATCH 085/194] [SUREFIRE-1265] reuseForks=false fails on jdk-9-ea
builds
---
.../surefire/util/internal/SystemUtils.java | 99 +++++++++++++++++++
.../org/apache/maven/JUnit4SuiteTest.java | 4 +-
.../util/internal/SystemUtilsTest.java | 98 ++++++++++++++++++
.../maven/surefire/booter/Classpath.java | 6 +-
.../booter/ClasspathConfiguration.java | 2 +-
.../its/jiras/Surefire1265Java9IT.java | 57 +++++++++++
.../src/test/resources/surefire-1265/pom.xml | 49 +++++++++
.../surefire-1265/src/test/java/J9Test.java | 15 +++
8 files changed, 326 insertions(+), 4 deletions(-)
create mode 100644 surefire-api/src/main/java/org/apache/maven/surefire/util/internal/SystemUtils.java
create mode 100644 surefire-api/src/test/java/org/apache/maven/surefire/util/internal/SystemUtilsTest.java
create mode 100644 surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java
create mode 100644 surefire-integration-tests/src/test/resources/surefire-1265/pom.xml
create mode 100644 surefire-integration-tests/src/test/resources/surefire-1265/src/test/java/J9Test.java
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/SystemUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/SystemUtils.java
new file mode 100644
index 0000000000..7881b5d841
--- /dev/null
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/SystemUtils.java
@@ -0,0 +1,99 @@
+package org.apache.maven.surefire.util.internal;
+
+/*
+ * 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.util.ReflectionUtils;
+
+import java.lang.reflect.Method;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static java.lang.Integer.parseInt;
+import static java.lang.Math.pow;
+
+/**
+ * JDK 9 support.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.20.1
+ */
+public final class SystemUtils
+{
+ private static final Pattern JAVA_SPEC_VERSION_PATTERN = Pattern.compile( "(\\d+)(\\.?)(\\d*).*" );
+ private static final double JAVA_SPEC_VERSION = javaSpecVersion();
+
+ public SystemUtils()
+ {
+ throw new IllegalStateException( "no instantiable constructor" );
+ }
+
+ public static ClassLoader platformClassLoader()
+ {
+ if ( JAVA_SPEC_VERSION < 9 )
+ {
+ return null;
+ }
+
+ return reflectClassLoader( ClassLoader.class, "getPlatformClassLoader" );
+ }
+
+ public static double javaSpecVersion()
+ {
+ return extractJavaSpecVersion( System.getProperty( "java.specification.version" ) );
+ }
+
+ static ClassLoader reflectClassLoader( Class> target, String getterMethodName )
+ {
+ try
+ {
+ Method getter = ReflectionUtils.getMethod( target, getterMethodName );
+ return (ClassLoader) ReflectionUtils.invokeMethodWithArray( null, getter );
+ }
+ catch ( RuntimeException e )
+ {
+ return null;
+ }
+ }
+
+ static double extractJavaSpecVersion( String property )
+ {
+ Matcher versionRegexMatcher = JAVA_SPEC_VERSION_PATTERN.matcher( property );
+ int groups = versionRegexMatcher.groupCount();
+ if ( !versionRegexMatcher.matches() )
+ {
+ throw new IllegalStateException( "Java Spec Version does not match the pattern "
+ + JAVA_SPEC_VERSION_PATTERN
+ );
+ }
+
+ if ( groups >= 3 )
+ {
+ String majorVersion = versionRegexMatcher.group( 1 );
+ String minorVersion = versionRegexMatcher.group( 3 );
+ int major = parseInt( majorVersion );
+ double minor = minorVersion.isEmpty() ? 0 : parseInt( minorVersion ) / pow( 10, minorVersion.length() );
+ return major + minor;
+ }
+ else
+ {
+ return parseInt( versionRegexMatcher.group( 0 ) );
+ }
+ }
+}
diff --git a/surefire-api/src/test/java/org/apache/maven/JUnit4SuiteTest.java b/surefire-api/src/test/java/org/apache/maven/JUnit4SuiteTest.java
index c43a3a6605..22378bf5dd 100644
--- a/surefire-api/src/test/java/org/apache/maven/JUnit4SuiteTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/JUnit4SuiteTest.java
@@ -40,6 +40,7 @@
import org.apache.maven.surefire.util.internal.ByteBufferTest;
import org.apache.maven.surefire.util.internal.ConcurrencyUtilsTest;
import org.apache.maven.surefire.util.internal.StringUtilsTest;
+import org.apache.maven.surefire.util.internal.SystemUtilsTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -68,7 +69,8 @@
TestsToRunTest.class,
UrlUtilsTest.class,
SpecificTestClassFilterTest.class,
- FundamentalFilterTest.class
+ FundamentalFilterTest.class,
+ SystemUtilsTest.class
} )
@RunWith( Suite.class )
public class JUnit4SuiteTest
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/SystemUtilsTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/SystemUtilsTest.java
new file mode 100644
index 0000000000..bbd9b3c750
--- /dev/null
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/SystemUtilsTest.java
@@ -0,0 +1,98 @@
+package org.apache.maven.surefire.util.internal;
+
+/*
+ * 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.junit.Test;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+/**
+ * Test of {@link SystemUtils}.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.20.1
+ */
+public class SystemUtilsTest
+{
+ @Test
+ public void shouldBeJava9()
+ {
+ String simpleVersion = "9";
+ double version = SystemUtils.extractJavaSpecVersion( simpleVersion );
+ assertThat( version ).isEqualTo( 9d );
+ }
+
+ @Test
+ public void shouldBeJava8()
+ {
+ String simpleVersion = "1.8";
+ double version = SystemUtils.extractJavaSpecVersion( simpleVersion );
+ assertThat( version ).isEqualTo( 1.8d );
+ }
+
+ @Test
+ public void shouldBeJavaMajorAndMinor()
+ {
+ String simpleVersion = "12.345.6";
+ double version = SystemUtils.extractJavaSpecVersion( simpleVersion );
+ assertThat( version ).isEqualTo( 12.345d );
+ }
+
+ @Test
+ public void shouldBeCurrentJavaVersion()
+ {
+ Double parsedVersion = SystemUtils.javaSpecVersion();
+ String expectedVersion = System.getProperty( "java.specification.version" );
+ assertThat( parsedVersion.toString() ).isEqualTo( expectedVersion );
+ }
+
+ @Test
+ public void shouldBePlatformClassLoader()
+ {
+ ClassLoader cl = SystemUtils.platformClassLoader();
+ if ( SystemUtils.javaSpecVersion() < 9 )
+ {
+ assertThat( cl ).isNull();
+ }
+ else
+ {
+ assertThat( cl ).isNotNull();
+ }
+ }
+
+ @Test
+ public void shouldNotFindClassLoader()
+ {
+ ClassLoader cl = SystemUtils.reflectClassLoader( getClass(), "_getPlatformClassLoader_" );
+ assertThat( cl ).isNull();
+ }
+
+ @Test
+ public void shouldFindClassLoader()
+ {
+ ClassLoader cl = SystemUtils.reflectClassLoader( getClass(), "getPlatformClassLoader" );
+ assertThat( cl ).isSameAs( ClassLoader.getSystemClassLoader() );
+ }
+
+ public static ClassLoader getPlatformClassLoader()
+ {
+ return ClassLoader.getSystemClassLoader();
+ }
+}
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
index 346e0755d4..84ed9ebebb 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
@@ -19,6 +19,8 @@
* under the License.
*/
+import org.apache.maven.surefire.util.internal.SystemUtils;
+
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
@@ -156,12 +158,12 @@ public boolean equals( Object o )
return unmodifiableElements.equals( classpath.unmodifiableElements );
}
- public ClassLoader createClassLoader( ClassLoader parent, boolean childDelegation, boolean enableAssertions,
- String roleName )
+ public ClassLoader createClassLoader( boolean childDelegation, boolean enableAssertions, String roleName )
throws SurefireExecutionException
{
try
{
+ ClassLoader parent = SystemUtils.platformClassLoader();
IsolatedClassLoader classLoader = new IsolatedClassLoader( parent, childDelegation, roleName );
for ( String classPathElement : unmodifiableElements )
{
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
index 3389a375b0..7425e3d8e7 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
@@ -82,7 +82,7 @@ public ClassLoader createMergedClassLoader()
throws SurefireExecutionException
{
return Classpath.join( inprocClasspath, classpathUrls )
- .createClassLoader( null, childDelegation, enableAssertions, "test" );
+ .createClassLoader( childDelegation, enableAssertions, "test" );
}
public Classpath getProviderClasspath()
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java
new file mode 100644
index 0000000000..88c0daad80
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java
@@ -0,0 +1,57 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.SurefireLauncher;
+import org.junit.Test;
+
+import static org.junit.Assume.assumeTrue;
+
+/**
+ * IsolatedClassLoader should take platform ClassLoader as a parent ClassLoader if running on the top of JDK9.
+ * The IsolatedClassLoader should not fail like this:
+ *
+ * [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project
+ * maven-surefire-plugin-example: Execution default-test of goal
+ * org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed:
+ * java.lang.NoClassDefFoundError: java/sql/SQLException: java.sql.SQLException -> [Help 1]
+ *
+ * @author Tibor Digana (tibor17)
+ * @see {@linkplain https://issues.apache.org/jira/browse/SUREFIRE-1265}
+ * @since 2.20.1
+ */
+public class Surefire1265Java9IT
+ extends SurefireJUnit4IntegrationTestCase
+{
+ @Test
+ public void shouldRunInPluginJava9()
+ {
+ assumeTrue( System.getProperty( "java.specification.version" ).compareTo( "1.8" ) > 0 );
+ unpack()
+ .executeTest()
+ .verifyErrorFree( 2 );
+ }
+
+ private SurefireLauncher unpack()
+ {
+ return unpack( "/surefire-1265" );
+ }
+}
diff --git a/surefire-integration-tests/src/test/resources/surefire-1265/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1265/pom.xml
new file mode 100644
index 0000000000..a702f30a4d
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1265/pom.xml
@@ -0,0 +1,49 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.surefire
+ it-parent
+ 1.0
+
+
+ org.apache.maven.plugins.surefire
+ surefire-1265
+ 1.0
+
+
+ UTF-8
+ 9
+ 9
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
diff --git a/surefire-integration-tests/src/test/resources/surefire-1265/src/test/java/J9Test.java b/surefire-integration-tests/src/test/resources/surefire-1265/src/test/java/J9Test.java
new file mode 100644
index 0000000000..3d41aea7a2
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1265/src/test/java/J9Test.java
@@ -0,0 +1,15 @@
+import org.junit.Test;
+
+public class J9Test
+{
+ @Test
+ public void test_sql_mod() throws java.sql.SQLException
+ {
+ System.out.println( System.getProperty( "java.specification.version" ) );
+ }
+
+ @Test
+ public void test_corba_mod() /*throws org.omg.CORBA.BAD_INV_ORDER*/
+ {
+ }
+}
From b54e33e68e9c3e13f8fca4b66dbb5c89a0a30715 Mon Sep 17 00:00:00 2001
From: Tibor17
Date: Sun, 23 Apr 2017 10:20:35 +0200
Subject: [PATCH 086/194] [SUREFIRE-1366] mvn javadoc:javadoc fails on Javadoc
syntax with JDK 1.8
---
maven-failsafe-plugin/pom.xml | 23 ++
.../plugin/failsafe/IntegrationTestMojo.java | 203 +++++++++--------
.../maven/plugin/failsafe/VerifyMojo.java | 2 +-
.../FailsafeSummaryXmlUtils.java | 22 +-
.../maven/plugin/failsafe/util/JAXB.java | 104 +++++++++
.../plugin/failsafe/xmlsummary/ErrorType.java | 1 -
.../failsafe/xmlsummary/FailsafeSummary.java | 1 -
.../plugin/failsafe/xmlsummary/JAXB.java | 1 -
.../failsafe/xmlsummary/ObjectFactory.java | 1 -
.../failsafe/MarshallerUnmarshallerTest.java | 62 ++---
.../maven/plugin/failsafe/RunResultTest.java | 2 +-
maven-surefire-common/pom.xml | 1 -
.../plugin/surefire/AbstractSurefireMojo.java | 214 +++++++++---------
.../surefire/InPluginVMSurefireStarter.java | 2 +-
.../surefire/StartupReportConfiguration.java | 6 +-
.../surefire/SurefireExecutionParameters.java | 1 -
.../surefire/SurefireReportParameters.java | 1 -
.../booterclient/BooterSerializer.java | 4 +-
.../booterclient/ForkConfiguration.java | 3 +-
.../surefire/booterclient/ForkStarter.java | 4 +-
.../booterclient/ProviderDetector.java | 1 -
.../AbstractCommandStream.java | 4 +
.../TestProvidingInputStream.java | 6 +-
.../output/DeserializedStacktraceWriter.java | 2 +-
.../booterclient/output/ForkClient.java | 6 +-
.../output/ThreadedStreamConsumer.java | 8 +-
.../report/ConsoleOutputFileReporter.java | 2 +-
.../report/DefaultReporterFactory.java | 4 +-
.../surefire/report/DirectConsoleOutput.java | 2 +-
.../surefire/report/StatelessXmlReporter.java | 5 +-
.../surefire/report/TestSetRunListener.java | 2 +-
.../apache/maven/surefire/spi/IDefault.java | 4 +-
.../maven/plugin/surefire/SurefirePlugin.java | 204 +++++++++--------
.../src/site/resources/xsd/bindings.xml | 1 -
.../site/resources/xsd/failsafe-summary.xjb | 31 +++
maven-surefire-report-plugin/pom.xml | 1 -
.../surefire/report/FailsafeReportMojo.java | 2 +-
.../surefire/report/SurefireReportMojo.java | 2 +-
.../resources/surefire-report_sv.properties | 2 +
pom.xml | 53 ++++-
.../maven/surefire/booter/CommandReader.java | 4 +-
.../surefire/booter/DumpErrorSingleton.java | 2 +-
.../maven/surefire/booter/FailFastAware.java | 2 +-
.../booter/ForkingReporterFactory.java | 2 -
.../surefire/booter/ForkingRunListener.java | 6 +-
.../maven/surefire/booter/ShutdownAware.java | 2 +-
.../surefire/booter/SurefireReflector.java | 2 +-
.../maven/surefire/cli/CommandLineOption.java | 2 +-
.../providerapi/ProviderParameters.java | 8 +-
.../providerapi/SurefireProvider.java | 17 +-
.../surefire/report/ConsoleOutputCapture.java | 2 +-
.../report/LegacyPojoStackTraceWriter.java | 1 -
.../maven/surefire/report/ReportEntry.java | 3 +-
.../report/ReporterConfiguration.java | 2 +-
.../maven/surefire/report/RunListener.java | 2 +-
.../surefire/report/SimpleReportEntry.java | 45 ++--
.../maven/surefire/suite/RunResult.java | 2 +-
.../maven/surefire/testset/ResolvedTest.java | 29 ++-
.../surefire/testset/TestListResolver.java | 8 +-
.../maven/surefire/testset/TestRequest.java | 2 +
.../testset/TestSetFailedException.java | 23 +-
.../util/SurefireReflectionException.java | 5 +-
.../util/internal/DaemonThreadFactory.java | 1 +
.../surefire/util/internal/DumpFileUtils.java | 3 +
.../surefire/util/internal/StringUtils.java | 66 ++----
.../testset/FundamentalFilterTest.java | 1 +
.../surefire/booter/BooterDeserializer.java | 4 +-
.../maven/surefire/booter/Classpath.java | 3 +
.../booter/ClasspathConfiguration.java | 2 +-
.../maven/surefire/booter/ForkedBooter.java | 6 +-
.../surefire/booter/IsolatedClassLoader.java | 2 +-
.../booter/ProviderConfiguration.java | 2 +-
.../surefire/booter/ProviderFactory.java | 2 +-
.../surefire/booter/StartupConfiguration.java | 4 +-
.../surefire/its/AbstractFailFastIT.java | 2 +-
.../maven/surefire/its/FailFastJUnitIT.java | 2 +-
.../maven/surefire/its/FailFastTestNgIT.java | 2 +-
.../its/IncludesExcludesFromFileIT.java | 2 +-
.../its/JUnit47ParallelNotThreadSafeIT.java | 2 +-
.../surefire/its/UnicodeTestNamesIT.java | 2 +-
.../surefire/its/fixture/MavenLauncher.java | 2 +-
.../SurefireJUnit4IntegrationTestCase.java | 2 +-
.../its/fixture/SurefireLauncher.java | 2 +-
.../Surefire1024VerifyFailsafeIfTestedIT.java | 2 +-
.../Surefire1028UnableToRunSingleIT.java | 8 +-
...FilterableJUnitRunnerWithCategoriesIT.java | 2 +-
.../jiras/Surefire1053SystemPropertiesIT.java | 2 +-
.../Surefire1080ParallelForkDoubleTestIT.java | 6 +-
...efire1082ParallelJUnitParameterizedIT.java | 2 +-
.../jiras/Surefire1095NpeInRunListener.java | 7 +-
.../jiras/Surefire1098BalancedRunOrderIT.java | 14 +-
.../Surefire1122ParallelAndFlakyTestsIT.java | 2 +-
...refire1146RerunFailedAndParameterized.java | 2 +-
.../jiras/Surefire1158RemoveInfoLinesIT.java | 2 +-
.../its/jiras/Surefire1202RerunAndSkipIT.java | 2 +-
.../Surefire1209RerunAndForkCountIT.java | 76 ++++++-
.../its/jiras/Surefire1211JUnitTestNgIT.java | 64 +++++-
.../jiras/Surefire1260NewTestsPattern.java | 50 +++-
.../its/jiras/Surefire1265Java9IT.java | 3 +-
...efire649EmptyStringSystemPropertiesIT.java | 2 +-
.../its/jiras/Surefire817SystemExitIT.java | 2 +-
...fire855AllowFailsafeUseArtifactFileIT.java | 2 +-
.../Surefire995CategoryInheritanceIT.java | 2 +-
.../test/resources/SurefireToolchains/pom.xml | 2 +-
.../resources/additional-classpath/pom.xml | 2 +-
.../resources/aggregate-report/child1/pom.xml | 2 +-
.../resources/aggregate-report/child2/pom.xml | 2 +-
.../test/resources/aggregate-report/pom.xml | 2 +-
.../src/test/resources/ant-ignore/pom.xml | 2 +-
.../test/resources/argLine-parameter/pom.xml | 2 +-
.../test/resources/argLine-properties/pom.xml | 2 +-
.../assumpationFailureReport/pom.xml | 2 +-
.../resources/classpath-filtering/pom.xml | 2 +-
.../test/resources/classpath-order/pom.xml | 2 +-
.../classpath-scope-filtering/pom.xml | 2 +-
.../src/test/resources/consoleOutput/pom.xml | 2 +-
.../resources/consoleOutputEncoding/pom.xml | 2 +-
.../resources/consoleoutput-noisy/pom.xml | 2 +-
.../test/resources/crash-detection/pom.xml | 2 +-
.../test/resources/crash-during-test/pom.xml | 2 +-
.../default-configuration-abstract/pom.xml | 2 +-
.../pom.xml | 2 +-
.../default-configuration-noTests/pom.xml | 2 +-
.../resources/default-configuration/pom.xml | 2 +-
.../resources/environment-variables/pom.xml | 2 +-
.../test/resources/fail-fast-junit/pom.xml | 2 +-
.../test/resources/fail-fast-testng/pom.xml | 2 +-
.../src/test/resources/failingBuilds/pom.xml | 2 +-
.../resources/failure-result-counting/pom.xml | 2 +-
.../src/test/resources/failureOutput/pom.xml | 2 +-
.../test/resources/fork-consoleOutput/pom.xml | 2 +-
.../fork-consoleOutputWithErrors/pom.xml | 2 +-
.../src/test/resources/fork-fail/pom.xml | 2 +-
.../fork-mode-multimodule/module-a/pom.xml | 2 +-
.../fork-mode-multimodule/module-b/pom.xml | 2 +-
.../resources/fork-mode-multimodule/pom.xml | 2 +-
.../fork-mode-resource-loading/pom.xml | 2 +-
.../test/resources/fork-mode-testng/pom.xml | 2 +-
.../src/test/resources/fork-mode/pom.xml | 2 +-
.../src/test/resources/fork-timeout/pom.xml | 2 +-
.../resources/isolated-classloader/pom.xml | 2 +-
.../resources/junit-fork-mode-always/pom.xml | 2 +-
.../src/test/resources/junit-ignore/pom.xml | 2 +-
.../test/resources/junit-innerClass/pom.xml | 2 +-
.../junit-notExtendingTestCase/pom.xml | 2 +-
.../resources/junit-pathWithUmlaut/pom.xml | 2 +-
.../resources/junit-twoTestCaseSuite/pom.xml | 2 +-
.../test/resources/junit-twoTestCases/pom.xml | 2 +-
.../junit4-forkAlways-staticInit/pom.xml | 2 +-
.../junit4-rerun-failing-tests/pom.xml | 2 +-
.../test/resources/junit4-runlistener/pom.xml | 2 +-
.../resources/junit4-twoTestCaseSuite/pom.xml | 2 +-
.../src/test/resources/junit4/pom.xml | 2 +-
.../src/test/resources/junit44-dep/pom.xml | 2 +-
.../resources/junit44-environment/pom.xml | 2 +-
.../test/resources/junit44-hamcrest/pom.xml | 2 +-
.../resources/junit44-method-pattern/pom.xml | 2 +-
.../junit44-multiple-methods/pom.xml | 2 +-
.../resources/junit44-single-method/pom.xml | 2 +-
.../resources/junit47-concurrency/pom.xml | 2 +-
.../resources/junit47-parallel-nts/pom.xml | 2 +-
.../junit47-parallel-with-suite/pom.xml | 2 +-
.../test/resources/junit47-parallel/pom.xml | 2 +-
.../resources/junit47-redirect-output/pom.xml | 2 +-
.../junit47-static-inner-class-tests/pom.xml | 2 +-
.../test/resources/junit48-categories/pom.xml | 2 +-
.../resources/junit48-method-pattern/pom.xml | 2 +-
.../junit48-multiple-method-patterns/pom.xml | 2 +-
.../junit48-multiple-methods/pom.xml | 2 +-
.../resources/junit48-single-method/pom.xml | 2 +-
.../resources/junit48-smartStackTrace/pom.xml | 2 +-
.../test/resources/large-test-results/pom.xml | 2 +-
.../test/resources/norunnableTests/pom.xml | 2 +-
.../test/resources/parallel-runtime/pom.xml | 2 +-
.../plain-old-java-classpath/pom.xml | 2 +-
.../test/resources/plexus-conflict/pom.xml | 2 +-
.../src/test/resources/pojo-simple/pom.xml | 2 +-
.../src/test/resources/reporters/pom.xml | 2 +-
.../test/resources/result-counting/pom.xml | 2 +-
.../src/test/resources/runOrder/pom.xml | 2 +-
.../test/resources/runorder-parallel/pom.xml | 2 +-
.../sibling-aggregator/aggregator/pom.xml | 2 +-
.../sibling-aggregator/child1/pom.xml | 2 +-
.../sibling-aggregator/child2/pom.xml | 2 +-
.../resources/small-result-counting/pom.xml | 2 +-
.../jiras-surefire-1024-it/pom.xml | 2 +-
.../jiras-surefire-1024-testjar/pom.xml | 2 +-
.../src/test/resources/surefire-1024/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-1053-system-properties/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-1095-npe-in-runlistener/pom.xml | 2 +-
.../surefire-1098-balanced-runorder/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-1144-xml-runtime/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-1158-remove-info-lines/pom.xml | 2 +-
.../src/test/resources/surefire-1185/pom.xml | 2 +-
.../src/test/resources/surefire-1211/pom.xml | 2 +-
.../surefire-1260-new-tests-pattern/pom.xml | 61 ++++-
.../src/test/resources/surefire-1265/pom.xml | 2 +-
.../surefire-1278-group-name-ending/pom.xml | 2 +-
.../surefire-141-pluggableproviders/pom.xml | 2 +-
.../surefire-146-forkPerTestNoSetup/pom.xml | 2 +-
.../pom.xml | 2 +-
.../module1/pom.xml | 2 +-
.../module2/pom.xml | 2 +-
.../surefire-257-rerunningTests/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-34-securityManager/pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-500-puzzling-error/pom.xml | 2 +-
.../surefire-510-testClassPath/pom.xml | 2 +-
.../module1/pom.xml | 2 +-
.../pom.xml | 2 +-
.../testjar/pom.xml | 2 +-
.../module1/pom.xml | 2 +-
.../module2/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-649-systemProperties/pom.xml | 2 +-
.../pom.xml | 2 +-
.../resources/surefire-673-mockito/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-697-niceSummary/pom.xml | 2 +-
.../surefire-733-allOverridesCaptured/pom.xml | 2 +-
.../surefire-740-comma-truncated/pom.xml | 2 +-
.../surefire-772-both-reports/pom.xml | 2 +-
.../surefire-772-no-failsafe-reports/pom.xml | 2 +-
.../resources/surefire-772-no-reports/pom.xml | 2 +-
.../surefire-772-no-surefire-reports/pom.xml | 2 +-
.../surefire-772-specified-reports/pom.xml | 2 +-
.../surefire-806-specifiedTests-multi/pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-809-groupExpr-junit48/pom.xml | 2 +-
.../surefire-809-groupExpr-testng/pom.xml | 2 +-
.../surefire-812-log4j-classloader/pom.xml | 2 +-
.../surefire-817-system-exit/pom.xml | 2 +-
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-832-provider-selection/pom.xml | 2 +-
.../surefire-855-failsafe-use-bundle/pom.xml | 2 +-
.../surefire-855-failsafe-use-jar/pom.xml | 2 +-
.../surefire-855-failsafe-use-war/pom.xml | 2 +-
.../surefire-930-failsafe-runtests/pom.xml | 2 +-
.../pom.xml | 2 +-
.../boom/pom.xml | 2 +-
.../class-rule/pom.xml | 2 +-
.../surefire-972-bizarre-noclassdef/pom.xml | 2 +-
.../surefire-975-wrong-encoding/pom.xml | 2 +-
.../pom.xml | 2 +-
.../surefire-995-categoryInheritance/pom.xml | 2 +-
.../test/resources/system-properties/pom.xml | 2 +-
.../testng-afterSuiteFailure/pom.xml | 2 +-
.../resources/testng-beforeMethod/pom.xml | 2 +-
.../testng-beforeMethodFailure/pom.xml | 2 +-
.../resources/testng-execute-error/pom.xml | 2 +-
.../testng-group-thread-parallel/pom.xml | 2 +-
.../src/test/resources/testng-groups/pom.xml | 2 +-
.../src/test/resources/testng-jdk14/pom.xml | 2 +-
.../resources/testng-junit-together/pom.xml | 2 +-
.../resources/testng-junit4-together/pom.xml | 2 +-
.../testng-listener-reporter/pom.xml | 2 +-
.../testng-method-pattern-after/pom.xml | 2 +-
.../testng-method-pattern-before/pom.xml | 2 +-
.../resources/testng-method-pattern/pom.xml | 2 +-
.../testng-multiple-method-patterns/pom.xml | 2 +-
.../resources/testng-parallel-suites/pom.xml | 2 +-
.../testng-parallel-with-annotations/pom.xml | 2 +-
.../resources/testng-path with spaces/pom.xml | 2 +-
.../src/test/resources/testng-simple/pom.xml | 2 +-
.../testng-single-method-5-14-9/pom.xml | 2 +-
.../resources/testng-single-method/pom.xml | 2 +-
.../testng-succes-percentage/pom.xml | 2 +-
.../test/resources/testng-suite-xml/pom.xml | 2 +-
.../resources/testng-twoTestCaseSuite/pom.xml | 2 +-
.../src/test/resources/timeout-forked/pom.xml | 2 +-
.../test/resources/unicode-testnames/pom.xml | 2 +-
.../src/test/resources/webapp/pom.xml | 2 +-
.../pom.xml | 2 +-
.../working-directory-missing/pom.xml | 2 +-
.../resources/working-directory/child/pom.xml | 2 +-
.../test/resources/working-directory/pom.xml | 2 +-
.../surefire/log/api/ConsoleLogger.java | 7 +-
.../common/junit4/JUnit4RunListener.java | 5 +-
.../common/junit48/FilterFactory.java | 2 +-
.../junit48/JUnit46StackTraceWriter.java | 2 +-
.../junitcore/ConcurrentRunListener.java | 2 +-
.../maven/surefire/junitcore/JUnitCore.java | 2 +-
.../junitcore/JUnitCoreParameters.java | 5 +-
.../junitcore/JUnitCoreRunListener.java | 2 +-
.../maven/surefire/junitcore/TestMethod.java | 2 +-
.../maven/surefire/junitcore/ThreadSafe.java | 2 +-
.../maven/surefire/junitcore/pc/Balancer.java | 4 +-
.../junitcore/pc/BalancerFactory.java | 3 +
.../junitcore/pc/ExecutionStatus.java | 2 +-
.../junitcore/pc/ParallelComputerBuilder.java | 5 +-
.../junitcore/pc/ParallelComputerUtil.java | 3 +-
.../surefire/junitcore/pc/Scheduler.java | 54 +++--
.../junitcore/pc/SchedulingStrategies.java | 2 +-
.../junitcore/pc/SchedulingStrategy.java | 32 +--
.../junitcore/pc/SingleThreadScheduler.java | 4 +-
.../junitcore/pc/ThreadResourcesBalancer.java | 4 +-
.../surefire/junitcore/pc/WrappedRunners.java | 2 +-
.../MavenSurefireJUnit47RunnerTest.java | 16 +-
.../MavenSurefireJUnit48RunnerTest.java | 16 +-
.../surefire/junitcore/Surefire746Test.java | 2 +-
.../pc/SchedulingStrategiesTest.java | 6 +-
.../surefire/testng/utils/MethodSelector.java | 1 -
.../surefire/testng/utils/Stoppable.java | 2 +-
.../ConfigurationAwareTestNGReporter.java | 1 -
.../maven/surefire/testng/TestNGProvider.java | 1 -
.../maven/surefire/testng/TestNGReporter.java | 5 +-
.../testng/conf/TestNG4751Configurator.java | 4 +-
.../testng/conf/TestNG513Configurator.java | 2 +-
.../testng/conf/TestNG5143Configurator.java | 2 +-
.../testng/conf/TestNG52Configurator.java | 4 +-
.../testng/conf/TestNGMapConfigurator.java | 14 +-
328 files changed, 1330 insertions(+), 868 deletions(-)
rename maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/{xmlsummary => util}/FailsafeSummaryXmlUtils.java (86%)
create mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/JAXB.java
delete mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ErrorType.java
delete mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummary.java
delete mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java
delete mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ObjectFactory.java
delete mode 100644 maven-surefire-plugin/src/site/resources/xsd/bindings.xml
create mode 100644 maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index ed1d751a54..506b3c4871 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -82,6 +82,29 @@
+
+ org.apache.cxf
+ cxf-xjc-plugin
+ 3.1.0
+
+
+ generate-failsafe-summary
+
+ xsdtojava
+
+
+ ${project.build.directory}/generated-sources/jaxb
+
+