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-SNAPSHOT Test for rerun failing tests in JUnit 4 - - - 4.4 - - junit junit - ${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.surefire common-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.jacoco jacoco-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.rat apache-rat-plugin + 0.12 rat-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.mojo animal-sniffer-maven-plugin - 1.11 + 1.15 signature-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 + clean verify 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.6 2.2.1 3.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. *

*

 * <simpleType name="errorType">
 *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
 *     <enumeration value="255"/>
 *     <enumeration value="254"/>
 *   </restriction>
 * </simpleType>
 * 
*/ @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. *

*

 * <complexType>
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="completed" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         <element name="errors" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         <element name="failures" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         <element name="skipped" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         <element name="failureMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *       </sequence>
 *       <attribute name="result" type="{}errorType" />
 *       <attribute name="timeout" use="required" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
*/ @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 @@ + 7 1 2 3 \ 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.surefire surefire-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.surefire surefire-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.shared maven-shared-utils - 0.9 + + 3.2.0-SNAPSHOT org.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.shared maven-shared-utils - - 3.2.0-SNAPSHOT + 0.9 org.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.surefire surefire-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-8 false - 5.7 5 false @@ -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 data() { return Arrays.asList(new Object[][] { - { "5.6", JAVA_1_5 }, // First TestNG version with reporter support - { "5.7", JAVA_1_5 }, // default version from pom of the test case - { "5.10", JAVA_1_5 }, - { "5.13", JAVA_1_5 }, // "reporterslist" param becomes String instead of List + { "5.6", "jdk15", JAVA_1_5 }, // First TestNG version with reporter support + { "5.7", "jdk15", JAVA_1_5 }, // default version from pom of the test case + { "5.10", "jdk15", JAVA_1_5 }, + { "5.13", null, JAVA_1_5 }, // "reporterslist" param becomes String instead of List // "listener" param becomes String instead of List // configure(Map) in 5.14.1 and 5.14.2 is transforming List into a String with a space as separator. // Then configure(CommandLineArgs) splits this String into a List with , or ; as separator => fail. // If we used configure(CommandLineArgs), we would not have the problem with white spaces. - //{ "5.14.1", "1.5" }, // "listener" param becomes List instead of String + //{ "5.14.1", null, "1.5" }, // "listener" param becomes List instead of String // Fails: Issue with 5.14.1 and 5.14.2 => join with , split with "," // TODO will work with "configure(CommandLineArgs)" - //{ "5.14.2", "1.5" }, // ReporterConfig is not available + //{ "5.14.2", null, "1.5" }, // ReporterConfig is not available - //{ "5.14.3", "1.5" }, // TestNG uses "reporter" instead of "reporterslist" + //{ "5.14.3", null, "1.5" }, // TestNG uses "reporter" instead of "reporterslist" // Both String or List are possible for "listener" // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI // ClassNotFoundException: com.beust.jcommander.ParameterException - //{ "5.14.4", "1.5" }, { "5.14.5", "1.5" }, // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI + //{ "5.14.4", null, "1.5" }, { "5.14.5", null, "1.5" }, // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI // ClassNotFoundException: com.beust.jcommander.ParameterException - { "5.14.6", JAVA_1_5 }, // Usage of org.testng:guice removed - { "5.14.9", JAVA_1_5 }, // Latest 5.14.x TestNG version - { "6.0", JAVA_1_5 }, - { "6.9.9", JAVA_1_7 } // Currently latest TestNG version + { "5.14.6", null, JAVA_1_5 }, // Usage of org.testng:guice removed + { "5.14.9", null, JAVA_1_5 }, // Latest 5.14.x TestNG version + { "6.0", null, JAVA_1_5 }, + { "6.9.9", null, JAVA_1_7 } // Currently latest TestNG version }); } @@ -81,16 +82,24 @@ public static Collection data() public String version; @Parameter(1) + public String classifier; + + @Parameter(2) public JavaVersion javaVersion; @Test public void testNgListenerReporter() { - assumeJavaVersion( javaVersion ); - unpack( "testng-listener-reporter", "_" + version ) - .resetInitialGoals( version ) - .executeTest() + final SurefireLauncher launcher = unpack( "testng-listener-reporter", "_" + version ) + .sysProp( "testNgVersion", version ); + + if ( classifier != null ) + { + launcher.sysProp( "testNgClassifier", "jdk15" ); + } + + launcher.executeTest() .verifyErrorFree( 1 ) .getTargetFile( "resultlistener-output.txt" ).assertFileExists() .getTargetFile( "suitelistener-output.txt" ).assertFileExists() diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java index bf713d35c9..aa77d1b21e 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java @@ -33,6 +33,10 @@ public class CheckTestNgPathWithSpacesIT @Test public void TestWithSpaces() { - unpack( "testng-path with spaces" ).executeTest().verifyErrorFree( 1 ); + unpack( "testng-path with spaces" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest() + .verifyErrorFree( 1 ); } } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java index 1bad84b251..a358172f7e 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java @@ -19,7 +19,6 @@ * under the License. */ -import org.apache.maven.surefire.its.fixture.OutputValidator; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; import org.junit.Test; @@ -38,9 +37,14 @@ public class CheckTestNgReportTestIT public void testNgReport() throws Exception { - final OutputValidator outputValidator = - unpack( "/testng-simple" ).addSurefireReportGoal().executeCurrentGoals().verifyErrorFree( 3 ); - outputValidator.getSiteFile( "surefire-report.html" ).assertFileExists(); + unpack( "/testng-simple" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .addSurefireReportGoal() + .executeCurrentGoals() + .verifyErrorFree( 3 ) + .getSiteFile( "surefire-report.html" ) + .assertFileExists(); } @Test diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java index e8cef5f8e9..2e56dc93d0 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java @@ -53,6 +53,8 @@ public void suiteXmlForkCountTwoReuse() private SurefireLauncher unpack() { - return unpack( "testng-suite-xml" ); + return unpack( "testng-suite-xml" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ); } } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java index 903c14a0a8..e2b63b63b3 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java @@ -33,7 +33,12 @@ public class CheckTestNgSuiteXmlSingleIT @Test public void TestNgSuite() { - unpack( "/testng-twoTestCaseSuite" ).setTestToRun( "TestNGTestTwo" ).executeTest().verifyErrorFree( 1 ); + unpack( "/testng-twoTestCaseSuite" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .setTestToRun( "TestNGTestTwo" ) + .executeTest() + .verifyErrorFree( 1 ); } } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java index 49c0be7fd9..6d2bbfa214 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java @@ -25,6 +25,7 @@ import org.apache.maven.surefire.its.fixture.HelperAssertions; 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.Ignore; import org.junit.Test; @@ -46,73 +47,73 @@ public class CheckTestNgVersionsIT @Test public void test47() throws Exception { - runTestNgTest( "4.7" ); + runTestNgTest( "4.7", "jdk15" ); } @Test @Ignore( "5.0 and 5.0.1 jars on central are malformed SUREFIRE-375 + MAVENUPLOAD-1024" ) public void XXXtest50() throws Exception { - runTestNgTest( "5.0" ); + runTestNgTest( "5.0", "jdk15" ); } @Test @Ignore( "5.0 and 5.0.1 jars on central are malformed SUREFIRE-375 + MAVENUPLOAD-1024" ) public void XXXtest501() throws Exception { - runTestNgTest( "5.0.1" ); + runTestNgTest( "5.0.1", "jdk15" ); } @Test public void test502() throws Exception { - runTestNgTest( "5.0.2" ); + runTestNgTest( "5.0.2", "jdk15" ); } @Test public void test51() throws Exception { - runTestNgTest( "5.1" ); + runTestNgTest( "5.1", "jdk15" ); } @Test public void test55() throws Exception { - runTestNgTest( "5.5" ); + runTestNgTest( "5.5", "jdk15" ); } @Test public void test56() throws Exception { - runTestNgTest( "5.6" ); + runTestNgTest( "5.6", "jdk15" ); } @Test public void test57() throws Exception { - runTestNgTest( "5.7" ); + runTestNgTest( "5.7", "jdk15" ); } @Test public void test58() throws Exception { - runTestNgTest( "5.8" ); + runTestNgTest( "5.8", "jdk15" ); } @Test public void test59() throws Exception { - runTestNgTest( "5.9" ); + runTestNgTest( "5.9", "jdk15" ); } @Test public void test510() throws Exception { - runTestNgTest( "5.10" ); + runTestNgTest( "5.10", "jdk15" ); } @Test public void test511() throws Exception { - runTestNgTest( "5.11" ); + runTestNgTest( "5.11", "jdk15" ); } @Test public void test512() @@ -154,7 +155,7 @@ public class CheckTestNgVersionsIT @Test public void test60() throws Exception { - runTestNgTest( "6.0", false ); + runTestNgTest( "6.0" ); } @Test public void test685() @@ -166,20 +167,40 @@ public class CheckTestNgVersionsIT private void runTestNgTestWithRunOrder( String version ) throws Exception { - runTestNgTest( version, true ); + runTestNgTest( version, null, true ); } private void runTestNgTest( String version ) - throws Exception + throws Exception { - runTestNgTest( version, false ); + runTestNgTest( version, null, false ); } private void runTestNgTest( String version, boolean validateRunOrder ) + throws Exception + { + runTestNgTest( version, null, validateRunOrder ); + } + + private void runTestNgTest( String version, String classifier ) + throws Exception + { + runTestNgTest( version, classifier, false ); + } + + private void runTestNgTest( String version, String classifier, boolean validateRunOrder ) throws Exception { + final SurefireLauncher launcher = unpack( "testng-simple" ) + .sysProp( "testNgVersion", version ); + + if ( classifier != null ) + { + launcher.sysProp( "testNgClassifier", classifier ); + } + + final OutputValidator outputValidator = launcher.executeTest(); - final OutputValidator outputValidator = unpack( "testng-simple" ).resetInitialGoals( version ).executeTest(); outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 ); if ( validateRunOrder ) diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java index b057a34e74..447d8f1336 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java @@ -24,6 +24,11 @@ import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + /** * Test project using -Dtest=mtClass#myMethod * @@ -34,9 +39,13 @@ public class TestMethodPatternIT { private static final String RUNNING_WITH_PROVIDER47 = "parallel='none', perCoreThreadCount=true, threadCount=0"; - public OutputValidator runMethodPattern( String projectName, String... goals ) + public OutputValidator runMethodPattern( String projectName, Map props, String... goals ) { SurefireLauncher launcher = unpack( projectName ); + for ( Entry entry : props.entrySet() ) + { + launcher.sysProp( entry.getKey(), entry.getValue() ); + } for ( String goal : goals ) { launcher.addGoal( goal ); @@ -49,19 +58,19 @@ public OutputValidator runMethodPattern( String projectName, String... goals ) @Test public void testJUnit44() { - runMethodPattern( "junit44-method-pattern" ); + runMethodPattern( "junit44-method-pattern", Collections.emptyMap() ); } @Test public void testJUnit48Provider4() { - runMethodPattern( "junit48-method-pattern", "-P surefire-junit4" ); + runMethodPattern( "junit48-method-pattern", Collections.emptyMap(), "-P surefire-junit4" ); } @Test public void testJUnit48Provider47() { - runMethodPattern( "junit48-method-pattern", "-P surefire-junit47" ) + runMethodPattern( "junit48-method-pattern", Collections.emptyMap(), "-P surefire-junit47" ) .verifyTextInLog( RUNNING_WITH_PROVIDER47 ); } @@ -71,28 +80,36 @@ public void testJUnit48WithCategoryFilter() unpack( "junit48-method-pattern" ) .addGoal( "-Dgroups=junit4.SampleCategory" ) .executeTest() - .assertTestSuiteResults( 1, 0, 0, 0 );; + .assertTestSuiteResults( 1, 0, 0, 0 ); } @Test public void testTestNgMethodBefore() { - runMethodPattern( "testng-method-pattern-before" ); + Map props = new HashMap(); + props.put( "testNgVersion", "5.7" ); + props.put( "testNgClassifier", "jdk15" ); + runMethodPattern( "testng-method-pattern-before", props ); } @Test public void testTestNGMethodPattern() { - runMethodPattern( "/testng-method-pattern" ); + Map props = new HashMap(); + props.put( "testNgVersion", "5.7" ); + props.put( "testNgClassifier", "jdk15" ); + runMethodPattern( "/testng-method-pattern", props ); } @Test public void testMethodPatternAfter() { unpack( "testng-method-pattern-after" ) - .executeTest() - .verifyErrorFree( 2 ) - .verifyTextInLog( "Called tearDown" ); + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest() + .verifyErrorFree( 2 ) + .verifyTextInLog( "Called tearDown" ); } } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgSuccessPercentageIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgSuccessPercentageIT.java index a9f26e75db..3b12e03567 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgSuccessPercentageIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgSuccessPercentageIT.java @@ -34,7 +34,11 @@ public class TestNgSuccessPercentageIT extends SurefireJUnit4IntegrationTestCase @Test public void testPassesWhenFailuresLessThanSuccessPercentage() { - OutputValidator validator = unpack("/testng-succes-percentage").mavenTestFailureIgnore( true ).executeTest(); + OutputValidator validator = unpack("/testng-succes-percentage") + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .mavenTestFailureIgnore( true ) + .executeTest(); validator.assertTestSuiteResults(8, 0, 1, 0); } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java index 9cc14fbf86..53eddce634 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java @@ -24,6 +24,10 @@ import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + /** * Test project using -Dtest=mtClass#myMethod * @@ -34,10 +38,15 @@ public class TestSingleMethodIT { private static final String RUNNING_WITH_PROVIDER47 = "parallel='none', perCoreThreadCount=true, threadCount=0"; - public OutputValidator singleMethod( String projectName, String testToRun, String... goals ) + public OutputValidator singleMethod( String projectName, Map props, String testToRun, + String... goals ) throws Exception { SurefireLauncher launcher = unpack( projectName ); + for ( Map.Entry entry : props.entrySet() ) + { + launcher.sysProp( entry.getKey(), entry.getValue() ); + } for ( String goal : goals ) { launcher.addGoal( goal ); @@ -56,21 +65,21 @@ public OutputValidator singleMethod( String projectName, String testToRun, Strin public void testJunit44() throws Exception { - singleMethod( "junit44-single-method", null ); + singleMethod( "junit44-single-method", Collections.emptyMap(), null ); } @Test public void testJunit48Provider4() throws Exception { - singleMethod( "junit48-single-method", null, "-P surefire-junit4" ); + singleMethod( "junit48-single-method", Collections.emptyMap(), null, "-P surefire-junit4" ); } @Test public void testJunit48Provider47() throws Exception { - singleMethod( "junit48-single-method", null, "-P surefire-junit47" ) + singleMethod( "junit48-single-method", Collections.emptyMap(), null, "-P surefire-junit47" ) .verifyTextInLog( RUNNING_WITH_PROVIDER47 ); } @@ -90,35 +99,43 @@ public void testJunit48parallel() public void testTestNg() throws Exception { - singleMethod( "testng-single-method", null ); + Map props = new HashMap(); + props.put( "testNgVersion", "5.7" ); + props.put( "testNgClassifier", "jdk15" ); + singleMethod( "testng-single-method", props, null ); } @Test public void testTestNg5149() throws Exception { - singleMethod( "/testng-single-method-5-14-9", null ); + singleMethod( "/testng-single-method-5-14-9", Collections.emptyMap(), null ); } @Test public void fullyQualifiedJunit48Provider4() throws Exception { - singleMethod( "junit48-single-method", "junit4.BasicTest#testSuccessOne", "-P surefire-junit4" ); + singleMethod( "junit48-single-method", Collections.emptyMap(), + "junit4.BasicTest#testSuccessOne", "-P surefire-junit4" ); } @Test public void fullyQualifiedJunit48Provider47() throws Exception { - singleMethod("junit48-single-method", "junit4.BasicTest#testSuccessOne", "-P surefire-junit47"); + singleMethod("junit48-single-method", Collections.emptyMap(), + "junit4.BasicTest#testSuccessOne", "-P surefire-junit47"); } @Test public void fullyQualifiedTestNg() throws Exception { - singleMethod( "testng-single-method", "testng.BasicTest#testSuccessOne" ); + Map props = new HashMap(); + props.put( "testNgVersion", "5.7" ); + props.put( "testNgClassifier", "jdk15" ); + singleMethod( "testng-single-method", props, "testng.BasicTest#testSuccessOne" ); } } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java index eca2fb051d..c218769303 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java @@ -41,7 +41,12 @@ public class TwoTestCasesIT public void testTwoTestCases() throws Exception { - unpack( "junit-twoTestCases" ).executeTest().verifyErrorFreeLog().assertTestSuiteResults( 2, 0, 0, 0 ); + unpack( "junit-twoTestCases" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 2, 0, 0, 0 ); } /** @@ -51,7 +56,10 @@ public void testTwoTestCases() public void testTwoTestCaseSuite() throws Exception { - final OutputValidator outputValidator = unpack( "junit-twoTestCaseSuite" ).executeTest(); + final OutputValidator outputValidator = unpack( "junit-twoTestCaseSuite" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest(); outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 2, 0, 0, 0 ); List reports = HelperAssertions.extractReports( outputValidator.getBaseDir() ); Set classNames = extractClassNames( reports ); @@ -85,7 +93,10 @@ private Set extractClassNames( List reports ) public void testJunit4Suite() throws Exception { - final OutputValidator outputValidator = unpack( "junit4-twoTestCaseSuite" ).executeTest(); + final OutputValidator outputValidator = unpack( "junit4-twoTestCaseSuite" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest(); outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 2, 0, 0, 0 ); List reports = @@ -102,7 +113,10 @@ public void testJunit4Suite() public void testTestNGSuite() throws Exception { - final OutputValidator outputValidator = unpack( "testng-twoTestCaseSuite" ).executeTest(); + final OutputValidator outputValidator = unpack( "testng-twoTestCaseSuite" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest(); outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 2, 0, 0, 0 ); List reports = HelperAssertions.extractReports( outputValidator.getBaseDir() ); Set classNames = extractClassNames( reports ); diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java index 1198fcb6b9..e7aff2e62b 100755 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java @@ -19,18 +19,22 @@ * under the License. */ +import org.apache.commons.lang.text.StrSubstitutor; +import org.apache.maven.it.VerificationException; +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; +import org.apache.maven.shared.utils.io.FileUtils; + import java.io.File; import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.ListIterator; import java.util.Map; -import org.apache.commons.lang.text.StrSubstitutor; -import org.apache.maven.it.VerificationException; -import org.apache.maven.it.Verifier; -import org.apache.maven.it.util.ResourceExtractor; -import org.apache.maven.shared.utils.io.FileUtils; + +import static java.util.Collections.unmodifiableList; /** * Encapsulate all needed features to start a maven run @@ -203,13 +207,13 @@ public MavenLauncher offline() public MavenLauncher skipClean() { - goals.add( "-Dclean.skip=true" ); + writeGoal( "-Dclean.skip=true" ); return this; } public MavenLauncher addGoal( String goal ) { - goals.add( goal ); + writeGoal( goal ); return this; } @@ -223,6 +227,35 @@ public OutputValidator executeTest() return conditionalExec( "test" ); } + List getGoals() + { + return unmodifiableList( goals ); + } + + private void writeGoal( String newGoal ) + { + if ( newGoal != null && newGoal.startsWith( "-D" ) ) + { + final String sysPropKey = + newGoal.contains( "=" ) ? newGoal.substring( 0, newGoal.indexOf( '=' ) ) : newGoal; + + final String sysPropStarter = sysPropKey + "="; + + for ( ListIterator it = goals.listIterator(); it.hasNext(); ) + { + String goal = it.next(); + if ( goal.equals( sysPropKey ) || goal.startsWith( sysPropStarter ) ) + { + System.out.printf( "[WARNING] System property already exists '%s'. Overriding to '%s'.\n", + goal, newGoal ); + it.set( newGoal ); + return; + } + } + } + goals.add( newGoal ); + } + private OutputValidator conditionalExec(String goal) { OutputValidator verify; 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 new file mode 100644 index 0000000000..4a638b6f0a --- /dev/null +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncherTest.java @@ -0,0 +1,47 @@ +package org.apache.maven.surefire.its.fixture; + +/* + * 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.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.hamcrest.CoreMatchers.hasItems; + +/** + * @author Tibor Digana (tibor17) + * @since 2.19.2 + */ +public class MavenLauncherTest +{ + @Test + public void shouldNotDuplicateSystemProperties() + { + MavenLauncher launcher = new MavenLauncher( getClass(), "", "" ) + .addGoal( "-DskipTests" ) + .addGoal( "-Dx=a" ) + .addGoal( "-DskipTests" ) + .addGoal( "-Dx=b" ); + + assertThat( launcher.getGoals(), hasItems( "-Dx=b", "-DskipTests" ) ); + + assertThat( launcher.getGoals().size(), is( 2 ) ); + } +} 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 23a09b0def..4cb162d81b 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 @@ -19,15 +19,13 @@ * under the License. */ +import org.apache.maven.it.VerificationException; + import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.List; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.it.VerificationException; + +import static java.util.Collections.singletonList; /** * Encapsulate all needed features to start a surefire run @@ -37,13 +35,10 @@ * * @author Kristian Rosenvold - */ -public class SurefireLauncher +public final class SurefireLauncher { - private final MavenLauncher mavenLauncher; - private final String testNgVersion = System.getProperty( "testng.version" ); - private final String surefireVersion = System.getProperty( "surefire.version" ); public SurefireLauncher( MavenLauncher mavenLauncher ) @@ -65,7 +60,7 @@ String getTestMethodName() public void reset() { mavenLauncher.reset(); - for ( String s : getInitialGoals( testNgVersion ) ) + for ( String s : getInitialGoals() ) { mavenLauncher.addGoal( s ); } @@ -122,40 +117,9 @@ public SurefireLauncher setMavenOpts(String opts){ return this; } - private List getInitialGoals( String testNgVersion ) + private List getInitialGoals() { - List goals1 = new ArrayList(); - goals1.add( "-Dsurefire.version=" + surefireVersion ); - - if ( this.testNgVersion != null ) - { - goals1.add( "-DtestNgVersion=" + testNgVersion ); - - ArtifactVersion v = new DefaultArtifactVersion( testNgVersion ); - try - { - if ( VersionRange.createFromVersionSpec( "(,5.12.1)" ).containsVersion( v ) ) - { - goals1.add( "-DtestNgClassifier=jdk15" ); - } - } - catch ( InvalidVersionSpecificationException e ) - { - throw new RuntimeException( e.getMessage(), e ); - } - } - - return goals1; - } - - public SurefireLauncher resetInitialGoals( String testNgVersion ) - { - mavenLauncher.resetGoals(); - for ( String s : getInitialGoals( testNgVersion ) ) - { - mavenLauncher.addGoal( s ); - } - return this; + return singletonList( "-Dsurefire.version=" + surefireVersion ); } public SurefireLauncher showErrorStackTraces() diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java index 131244fe9a..f7324c9103 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java @@ -1 +1,152 @@ -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 static org.apache.maven.shared.utils.xml.Xpp3DomBuilder.build; import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertThat; import java.io.FileNotFoundException; import org.apache.maven.shared.utils.xml.Xpp3Dom; import org.apache.maven.surefire.its.fixture.OutputValidator; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; import org.junit.Test; /** * Test surefire-report on TestNG test * * @author Michal Bocek */ public class Surefire1135ImproveIgnoreMessageForTestNGIT extends SurefireJUnit4IntegrationTestCase { private enum ResultType { SKIPPED( "skipped" ), FAILURE( "failure" ); private final String type; ResultType(String type) { this.type = type; } public String getType() { return type; } } @Test public void testNgReport688() throws Exception { testNgReport( "6.8.8", ResultType.SKIPPED, "Skip test", /*"org.testng.SkipException"*/ null, /*"SkipExceptionReportTest.java:30"*/ null ); } @Test public void testNgReport57() throws Exception { testNgReport( "5.7", ResultType.SKIPPED, "Skip test", /*"org.testng.SkipException"*/ null, /*"SkipExceptionReportTest.java:30"*/ null ); } private void testNgReport( String version, ResultType resultType, String message, String type, String stackTrace ) throws Exception { OutputValidator outputValidator = runTest( version, resultType, "/surefire-1135-improve-ignore-message-for-testng" ); Xpp3Dom[] children = readTests( outputValidator, "testng.SkipExceptionReportTest" ); assertThat( "Report should contains only one test case", children.length, is( 1 ) ); Xpp3Dom test = children[0]; assertThat( "Not expected classname", test.getAttribute( "classname" ), is( "testng.SkipExceptionReportTest" ) ); assertThat( "Not expected test name", test.getAttribute( "name" ), is( "testSkipException" ) ); children = test.getChildren( resultType.getType() ); assertThat( "Test should contains only one " + resultType.getType() + " element", children, is( arrayWithSize( 1 ) ) ); Xpp3Dom result = children[0]; if ( message == null ) { assertThat( "Subelement message attribute must be null", result.getAttribute( "message" ), is( nullValue() ) ); } else { assertThat( "Subelement should contains message attribute", result.getAttribute( "message" ), is( message ) ); } if ( type == null ) { assertThat( "Subelement type attribute must be null", result.getAttribute( "type" ), is( nullValue() ) ); } else { assertThat( "Subelement should contains type attribute", result.getAttribute( "type" ), is( type ) ); } if ( stackTrace == null ) { assertThat( "Element body must be null", result.getValue() , isEmptyOrNullString() ); } else { assertThat( "Element body must contains", result.getValue(), containsString( stackTrace ) ); } } private OutputValidator runTest( String version, ResultType resultType, String resource ) { int skipped = ResultType.SKIPPED.equals( resultType ) ? 1 : 0; int failure = ResultType.FAILURE.equals( resultType ) ? 1 : 0; return unpack( resource ) .resetInitialGoals( version ) .addSurefireReportGoal() .executeCurrentGoals() .assertTestSuiteResults( 1, 0, failure, skipped ); } private static Xpp3Dom[] readTests( OutputValidator validator, String className ) throws FileNotFoundException { Xpp3Dom testResult = build( validator.getSurefireReportsXmlFile( "TEST-" + className + ".xml" ).getFileInputStream(), "UTF-8" ); return testResult.getChildren( "testcase" ); } } \ 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 static org.apache.maven.shared.utils.xml.Xpp3DomBuilder.build; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertThat; + +import java.io.FileNotFoundException; + +import org.apache.maven.shared.utils.xml.Xpp3Dom; +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; + +/** + * Test surefire-report on TestNG test + * + * @author Michal Bocek + */ +public class Surefire1135ImproveIgnoreMessageForTestNGIT + extends SurefireJUnit4IntegrationTestCase +{ + + private enum ResultType + { + SKIPPED( "skipped" ), FAILURE( "failure" ); + + private final String type; + + ResultType(String type) + { + this.type = type; + } + + public String getType() { + return type; + } + } + + @Test + public void testNgReport688() throws Exception { + testNgReport( "6.8.8", null, ResultType.SKIPPED, + "Skip test", + /*"org.testng.SkipException"*/ null, + /*"SkipExceptionReportTest.java:30"*/ null ); + } + + @Test + public void testNgReport57() throws Exception { + testNgReport( "5.7", "jdk15", ResultType.SKIPPED, + "Skip test", + /*"org.testng.SkipException"*/ null, + /*"SkipExceptionReportTest.java:30"*/ null ); + } + + private void testNgReport( String version, String classifier, ResultType resultType, String message, String type, + String stackTrace ) + throws Exception + { + OutputValidator outputValidator = + runTest( version, classifier, resultType, "/surefire-1135-improve-ignore-message-for-testng" ); + + Xpp3Dom[] children = readTests( outputValidator, "testng.SkipExceptionReportTest" ); + assertThat( "Report should contains only one test case", children.length, is( 1 ) ); + + Xpp3Dom test = children[0]; + assertThat( "Not expected classname", test.getAttribute( "classname" ), + is( "testng.SkipExceptionReportTest" ) ); + + assertThat( "Not expected test name", test.getAttribute( "name" ), is( "testSkipException" ) ); + + children = test.getChildren( resultType.getType() ); + assertThat( "Test should contains only one " + resultType.getType() + " element", children, + is( arrayWithSize( 1 ) ) ); + + Xpp3Dom result = children[0]; + if ( message == null ) + { + assertThat( "Subelement message attribute must be null", result.getAttribute( "message" ), + is( nullValue() ) ); + } + else + { + assertThat( "Subelement should contains message attribute", result.getAttribute( "message" ), + is( message ) ); + } + + if ( type == null ) + { + assertThat( "Subelement type attribute must be null", result.getAttribute( "type" ), is( nullValue() ) ); + } + else + { + assertThat( "Subelement should contains type attribute", result.getAttribute( "type" ), is( type ) ); + } + + if ( stackTrace == null ) + { + assertThat( "Element body must be null", result.getValue() , isEmptyOrNullString() ); + } + else + { + assertThat( "Element body must contains", result.getValue(), containsString( stackTrace ) ); + } + } + + private OutputValidator runTest( String version, String classifier, ResultType resultType, String resource ) + { + int skipped = ResultType.SKIPPED.equals( resultType ) ? 1 : 0; + int failure = ResultType.FAILURE.equals( resultType ) ? 1 : 0; + + SurefireLauncher launcher = unpack( resource ).sysProp( "testNgVersion", version ); + + if ( classifier != null ) + { + launcher.sysProp( "testNgClassifier", classifier ); + } + + return launcher.addSurefireReportGoal() + .executeCurrentGoals() + .assertTestSuiteResults( 1, 0, failure, skipped ); + } + + private static Xpp3Dom[] readTests( OutputValidator validator, String className ) + throws FileNotFoundException + { + Xpp3Dom testResult = + build( validator.getSurefireReportsXmlFile( "TEST-" + className + ".xml" ).getFileInputStream(), + "UTF-8" + ); + return testResult.getChildren( "testcase" ); + } +} diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java index ee85b2bbc6..ebc0e1e824 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java @@ -33,7 +33,12 @@ public class Surefire376TestNgAfterSuiteFailureIT @Test public void testAfterSuiteFailure() { - unpack( "/testng-afterSuiteFailure" ).maven().withFailure().executeTest(). - assertTestSuiteResults( 2, 0, 1, 0 ); + unpack( "/testng-afterSuiteFailure" ) + .maven() + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .withFailure() + .executeTest() + .assertTestSuiteResults( 2, 0, 1, 0 ); } } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java index 2fe4ff07dc..a29d030306 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java @@ -33,12 +33,20 @@ public class Surefire377TestNgAndJUnitTogetherIT @Test public void testTestNgAndJUnitTogether() { - executeErrorFreeTest( "/testng-junit-together", 2 ); + unpack( "/testng-junit-together" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest() + .verifyErrorFree( 2 ); } @Test public void testTestNgAndJUnit4Together() { - executeErrorFreeTest( "/testng-junit4-together", 3 ); + unpack( "/testng-junit4-together" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest() + .verifyErrorFree( 3 ); } } diff --git a/surefire-integration-tests/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml index 4a88e6dd64..d9a9a847ba 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml @@ -1 +1,82 @@ - 4.0.0 org.apache.maven.plugins.surefire surefire-1135-improve-ignore-message-for-testng 1.0-SNAPSHOT Surefire 1135 testng-old testNgClassifier org.testng testng ${testNgVersion} ${testNgClassifier} testng-new !testNgClassifier org.testng testng ${testNgVersion} 5.7 jdk15 org.apache.maven.plugins maven-surefire-plugin ${surefire.version} SkipExceptionReportTest org.apache.maven.plugins maven-compiler-plugin 1.5 1.5 \ No newline at end of file + + + + + + 4.0.0 + + org.apache.maven.plugins.surefire + surefire-1135-improve-ignore-message-for-testng + 1.0-SNAPSHOT + Surefire 1135 + + + + testng-old + + testNgClassifier + + + + org.testng + testng + ${testNgVersion} + ${testNgClassifier} + + + + + testng-new + + !testNgClassifier + + + + org.testng + testng + ${testNgVersion} + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + SkipExceptionReportTest + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + diff --git a/surefire-integration-tests/src/test/resources/testng-afterSuiteFailure/pom.xml b/surefire-integration-tests/src/test/resources/testng-afterSuiteFailure/pom.xml index 21f1bf0d80..f738827a47 100644 --- a/surefire-integration-tests/src/test/resources/testng-afterSuiteFailure/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-afterSuiteFailure/pom.xml @@ -58,11 +58,6 @@ - - 5.7 - jdk15 - - diff --git a/surefire-integration-tests/src/test/resources/testng-beforeMethod/pom.xml b/surefire-integration-tests/src/test/resources/testng-beforeMethod/pom.xml index 4d2621c148..af46b6bcdc 100644 --- a/surefire-integration-tests/src/test/resources/testng-beforeMethod/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-beforeMethod/pom.xml @@ -58,11 +58,6 @@ - - 5.7 - jdk15 - - diff --git a/surefire-integration-tests/src/test/resources/testng-beforeMethodFailure/pom.xml b/surefire-integration-tests/src/test/resources/testng-beforeMethodFailure/pom.xml index 374b182570..bda724c9b6 100644 --- a/surefire-integration-tests/src/test/resources/testng-beforeMethodFailure/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-beforeMethodFailure/pom.xml @@ -58,11 +58,6 @@ - - 5.7 - jdk15 - - diff --git a/surefire-integration-tests/src/test/resources/testng-execute-error/pom.xml b/surefire-integration-tests/src/test/resources/testng-execute-error/pom.xml index da39df35ee..ae1a1d1e60 100644 --- a/surefire-integration-tests/src/test/resources/testng-execute-error/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-execute-error/pom.xml @@ -58,11 +58,6 @@ - - 5.7 - jdk15 - - diff --git a/surefire-integration-tests/src/test/resources/testng-group-thread-parallel/pom.xml b/surefire-integration-tests/src/test/resources/testng-group-thread-parallel/pom.xml index 8ae10d3c60..f0ad40c8eb 100644 --- a/surefire-integration-tests/src/test/resources/testng-group-thread-parallel/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-group-thread-parallel/pom.xml @@ -65,11 +65,6 @@ - - 5.7 - jdk15 - - diff --git a/surefire-integration-tests/src/test/resources/testng-junit-together/pom.xml b/surefire-integration-tests/src/test/resources/testng-junit-together/pom.xml index 68dcfbf1f8..dac6b9b6cf 100644 --- a/surefire-integration-tests/src/test/resources/testng-junit-together/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-junit-together/pom.xml @@ -58,11 +58,6 @@ - - 5.7 - jdk15 - - junit diff --git a/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml b/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml index b39c11b193..975eff5ece 100644 --- a/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml @@ -65,11 +65,6 @@ - - 5.7 - jdk15 - - diff --git a/surefire-integration-tests/src/test/resources/testng-method-pattern-after/pom.xml b/surefire-integration-tests/src/test/resources/testng-method-pattern-after/pom.xml index dcc76b858f..4cb27c6f31 100644 --- a/surefire-integration-tests/src/test/resources/testng-method-pattern-after/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-method-pattern-after/pom.xml @@ -28,12 +28,6 @@ 1.0-SNAPSHOT Test for Testng - - - 5.7 - jdk15 - - testng-old diff --git a/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml b/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml index dcc76b858f..4cb27c6f31 100644 --- a/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml @@ -28,12 +28,6 @@ 1.0-SNAPSHOT Test for Testng - - - 5.7 - jdk15 - - testng-old diff --git a/surefire-integration-tests/src/test/resources/testng-method-pattern/pom.xml b/surefire-integration-tests/src/test/resources/testng-method-pattern/pom.xml index dcc76b858f..4cb27c6f31 100644 --- a/surefire-integration-tests/src/test/resources/testng-method-pattern/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-method-pattern/pom.xml @@ -28,12 +28,6 @@ 1.0-SNAPSHOT Test for Testng - - - 5.7 - jdk15 - - testng-old diff --git a/surefire-integration-tests/src/test/resources/testng-path with spaces/pom.xml b/surefire-integration-tests/src/test/resources/testng-path with spaces/pom.xml index 31877df3ea..88eb6da047 100644 --- a/surefire-integration-tests/src/test/resources/testng-path with spaces/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-path with spaces/pom.xml @@ -58,11 +58,6 @@ - - 5.7 - jdk15 - - diff --git a/surefire-integration-tests/src/test/resources/testng-simple/pom.xml b/surefire-integration-tests/src/test/resources/testng-simple/pom.xml index fffad183be..bad11784f5 100644 --- a/surefire-integration-tests/src/test/resources/testng-simple/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-simple/pom.xml @@ -73,7 +73,6 @@ - 5.7 0 diff --git a/surefire-integration-tests/src/test/resources/testng-single-method/pom.xml b/surefire-integration-tests/src/test/resources/testng-single-method/pom.xml index 5f99c56b5e..965fc55416 100644 --- a/surefire-integration-tests/src/test/resources/testng-single-method/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-single-method/pom.xml @@ -28,12 +28,6 @@ 1.0-SNAPSHOT Test for Testng - - - 5.7 - jdk15 - - testng-old diff --git a/surefire-integration-tests/src/test/resources/testng-succes-percentage/pom.xml b/surefire-integration-tests/src/test/resources/testng-succes-percentage/pom.xml index 13bc8311c7..1d2cfbd875 100644 --- a/surefire-integration-tests/src/test/resources/testng-succes-percentage/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-succes-percentage/pom.xml @@ -33,11 +33,6 @@ 1.0-SNAPSHOT Test for Testng - - 5.7 - jdk15 - - testng-old diff --git a/surefire-integration-tests/src/test/resources/testng-suite-xml/pom.xml b/surefire-integration-tests/src/test/resources/testng-suite-xml/pom.xml index c43c10b5b3..f51bb49f62 100644 --- a/surefire-integration-tests/src/test/resources/testng-suite-xml/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-suite-xml/pom.xml @@ -58,11 +58,6 @@ - - 5.7 - jdk15 - - diff --git a/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml b/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml index ec9b524779..37d77bf583 100644 --- a/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml @@ -58,11 +58,6 @@ - - 5.7 - jdk15 - - From f4d54fac09f768fc352a1d0c59a6f05a66982183 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Thu, 9 Mar 2017 01:39:46 +0100 Subject: [PATCH 057/194] [SUREFIRE-1341] Documentation of configuration parameters in Failsafe should mention IT instead or Test.java --- .../plugin/failsafe/IntegrationTestMojo.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 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 2d781094d1..51c36ee659 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 @@ -86,13 +86,13 @@ public class IntegrationTestMojo /** * Specify this parameter to run individual tests by file name, overriding the includes/excludes * parameters. Each pattern you specify here will be used to create an include pattern formatted like - * **/${test}.java, so you can just type "-Dit.test=MyTest" to run a single test called - * "foo/MyTest.java".
+ * **/${it.test}.java, so you can just type "-Dit.test=MyIT" to run a single test called + * "foo/MyIT.java".
* This parameter overrides the includes/excludes parameters, and the TestNG suiteXmlFiles * parameter. *

* Since 2.7.3 You can execute a limited number of methods in the test with adding #myMethod or #my*ethod. E.g. type - * "-Dit.test=MyTest#myMethod" supported for junit 4.x and testNg + * "-Dit.test=MyIT#myMethod" supported for junit 4.x and testNg *
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
* "-Dit.test=???IT, !Unstable*, pkg/**/Ci*leIT.java, *IT#test*One+testTwo?????, #fast*+slowTest"
@@ -306,9 +306,9 @@ public class IntegrationTestMojo /** * A file containing include patterns. Blank lines, or lines starting with # are ignored. If {@code includes} are * also specified, these patterns are appended. Example with path, simple and regex includes:
- * */test/*
+ * */it/*
* **/NotIncludedByDefault.java
- * %regex[.*Test.*|.*Not.*]
+ * %regex[.*IT.*|.*Not.*]
*/ @Parameter( property = "failsafe.includesFile" ) private File includesFile; @@ -316,9 +316,9 @@ public class IntegrationTestMojo /** * A file containing exclude patterns. Blank lines, or lines starting with # are ignored. If {@code excludes} are * also specified, these patterns are appended. Example with path, simple and regex excludes:
- * */test/*
- * **/DontRunTest.*
- * %regex[.*Test.*|.*Not.*]
+ * */it/*
+ * **/DontRunIT.*
+ * %regex[.*IT.*|.*Not.*]
*/ @Parameter( property = "failsafe.excludesFile" ) private File excludesFile; From 75619d62e4180f763e20f9e130440094f465c266 Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Sun, 12 Mar 2017 21:20:13 +0000 Subject: [PATCH 058/194] Adding a dummy Jenkinsfile --- Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..e72ff99ff9 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,12 @@ +pipeline { + agent { + label env.NIX_LABEL + } + stages { + stage('Build') { + steps { + sh 'ls -l' + } + } + } +} From 7866b0ffb305aa822b48bcb27916a42d9702ed84 Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Sun, 12 Mar 2017 21:34:19 +0000 Subject: [PATCH 059/194] More tweaks --- Jenkinsfile | 20 ++++++++++++++++++-- pom.xml | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e72ff99ff9..c7006ae0bb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,9 +3,25 @@ pipeline { label env.NIX_LABEL } stages { - stage('Build') { + stage('Unix Build') { + tools { + maven 'Maven 3.3.9' + jdk 'JDK 1.8.0_102' + } + steps { + sh 'mvn -v' + } + } + stage('Windows Build') { + agent { + label env.WIN_LABEL + } + tools { + maven 'Maven 3.3.9 (Windows)' + jdk 'JDK 1.8_121 (Windows Only)' + } steps { - sh 'ls -l' + bat 'mvn -v' } } } diff --git a/pom.xml b/pom.xml index 3b8ab650cd..df9d79b036 100644 --- a/pom.xml +++ b/pom.xml @@ -391,6 +391,7 @@ + Jenkinsfile README.md .gitignore .git/**/* From 728b4ab426c1b8aaa8e2271efab19d73feea9a95 Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Sun, 12 Mar 2017 21:37:52 +0000 Subject: [PATCH 060/194] Let's do a real build --- Jenkinsfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c7006ae0bb..7a73b6bb8b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,12 @@ pipeline { jdk 'JDK 1.8.0_102' } steps { - sh 'mvn -v' + sh 'clean install jacoco:report -B -U -e -fae -V -Prun-its,embedded,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084' + } + post { + success { + junit '**/target/surefire-reports/**/*.xml' + } } } stage('Windows Build') { @@ -21,7 +26,12 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat 'mvn -v' + bat 'clean install jacoco:report -B -U -e -fae -V -Prun-its,embedded,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084' + } + post { + success { + junit '**/target/surefire-reports/**/*.xml' + } } } } From 944c08d7005863899203aa67e2b2aedb533f44a1 Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Sun, 12 Mar 2017 21:39:00 +0000 Subject: [PATCH 061/194] I forgot to actually invoke maven --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7a73b6bb8b..854f959f5f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { jdk 'JDK 1.8.0_102' } steps { - sh 'clean install jacoco:report -B -U -e -fae -V -Prun-its,embedded,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084' + sh 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,embedded,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084' } post { success { @@ -26,7 +26,7 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat 'clean install jacoco:report -B -U -e -fae -V -Prun-its,embedded,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084' + bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,embedded,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084' } post { success { From d468680be5d6f2a936df4a7c2efd2172c9eef773 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 12 Mar 2017 23:06:43 +0100 Subject: [PATCH 062/194] [Jenkinsfile] Included junit: failsafe-reports --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 854f959f5f..cbac90d221 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { } post { success { - junit '**/target/surefire-reports/**/*.xml' + junit '**/target/surefire-reports/**/*.xml,**/target/failsafe-reports/**/*.xml' } } } @@ -30,7 +30,7 @@ pipeline { } post { success { - junit '**/target/surefire-reports/**/*.xml' + junit '**/target/surefire-reports/**/*.xml,**/target/failsafe-reports/**/*.xml' } } } From da7ff6aa25a72094705c24981afbf8294ac4b1dc Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 13 Mar 2017 03:10:08 +0100 Subject: [PATCH 063/194] [SUREFIRE-1342] Acknowledge normal exit of JVM and drain shared memory between processes --- .../surefire/booterclient/ForkStarter.java | 1 + .../AbstractCommandStream.java | 8 +- .../NotifiableTestStream.java | 2 + .../lazytestprovider/TestLessInputStream.java | 49 ++++++- .../TestProvidingInputStream.java | 18 ++- .../booterclient/output/ForkClient.java | 1 + .../output/ThreadedStreamConsumer.java | 40 +++--- .../MockNotifiableTestStream.java | 5 + .../TestProvidingInputStreamTest.java | 1 + .../apache/maven/surefire/booter/Command.java | 1 + .../maven/surefire/booter/CommandReader.java | 22 +-- .../surefire/booter/MasterProcessCommand.java | 3 +- .../maven/surefire/booter/Shutdown.java | 15 +++ .../surefire/util/internal/DumpFileUtils.java | 126 +++++++++++++++++- .../booter/MasterProcessCommandTest.java | 7 + .../maven/surefire/booter/ForkedBooter.java | 124 +++++++++++------ .../Surefire141PluggableProvidersIT.java | 33 ++++- 17 files changed, 362 insertions(+), 94 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 54d304a769..b69d010d06 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 @@ -644,6 +644,7 @@ else if ( result != SUCCESS ) } finally { + currentForkClients.remove( forkClient ); closer.close(); if ( runResult == null ) { diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java index 4d6331c030..3531ccfcee 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java @@ -41,10 +41,12 @@ public abstract class AbstractCommandStream protected abstract boolean isClosed(); /** - * Unnecessarily opposite to {@link #isClosed()} however may respect - * {@link #getLastCommand() last command} and {@link #isClosed()}. + * Opposite to {@link #isClosed()}. */ - protected abstract boolean canContinue(); + protected boolean canContinue() + { + return !isClosed(); + } /** * Possibly waiting for next command (see {@link #nextCommand()}) unless the stream is atomically diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java index 5c89173329..b181de1377 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java @@ -45,4 +45,6 @@ public interface NotifiableTestStream void shutdown( Shutdown shutdownType ); void noop(); + + void acknowledgeByeEventReceived(); } 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 b6ae42cd58..d0ae47a56d 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 @@ -33,6 +33,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import static org.apache.maven.surefire.booter.Command.BYE_ACK; import static org.apache.maven.surefire.booter.Command.NOOP; import static org.apache.maven.surefire.booter.Command.SKIP_SINCE_NEXT_TEST; import static org.apache.maven.surefire.booter.Command.toShutdown; @@ -93,15 +94,19 @@ public void noop() } @Override - protected boolean isClosed() + public void acknowledgeByeEventReceived() { - return closed.get(); + if ( canContinue() ) + { + immediateCommands.add( BYE_ACK ); + barrier.release(); + } } @Override - protected boolean canContinue() + protected boolean isClosed() { - return !isClosed(); + return closed.get(); } @Override @@ -356,6 +361,24 @@ public void noop() lock.unlock(); } } + + @Override + public void acknowledgeByeEventReceived() + { + Lock lock = rwLock.readLock(); + lock.lock(); + try + { + for ( TestLessInputStream aliveStream : TestLessInputStreamBuilder.this.aliveStreams ) + { + aliveStream.acknowledgeByeEventReceived(); + } + } + finally + { + lock.unlock(); + } + } } /** @@ -419,6 +442,24 @@ public void noop() } } + @Override + public void acknowledgeByeEventReceived() + { + Lock lock = rwLock.readLock(); + lock.lock(); + try + { + if ( TestLessInputStreamBuilder.this.addTailNodeIfAbsent( BYE_ACK ) ) + { + release(); + } + } + finally + { + lock.unlock(); + } + } + private void release() { for ( TestLessInputStream aliveStream : TestLessInputStreamBuilder.this.aliveStreams ) 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 766843d76a..69f73a2ede 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 @@ -28,7 +28,7 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; -import static org.apache.maven.surefire.booter.MasterProcessCommand.TEST_SET_FINISHED; +import static org.apache.maven.surefire.booter.Command.BYE_ACK; import static org.apache.maven.surefire.booter.Command.NOOP; import static org.apache.maven.surefire.booter.Command.SKIP_SINCE_NEXT_TEST; import static org.apache.maven.surefire.booter.Command.toRunClass; @@ -109,6 +109,16 @@ public void noop() } } + @Override + public void acknowledgeByeEventReceived() + { + if ( canContinue() ) + { + commands.add( BYE_ACK ); + barrier.release(); + } + } + @Override protected Command nextCommand() { @@ -137,12 +147,6 @@ protected boolean isClosed() return closed.get(); } - @Override - protected boolean canContinue() - { - return getLastCommand() != TEST_SET_FINISHED && !isClosed(); - } - /** * Signal that a new test is to be provided. */ 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 d6afcb2963..faace0f99a 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 @@ -265,6 +265,7 @@ private void processLine( String s ) break; case BOOTERCODE_BYE: saidGoodBye = true; + notifiableTestStream.acknowledgeByeEventReceived(); break; case BOOTERCODE_STOP_ON_NEXT_TEST: stopOnNextTest(); 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 c7d39aefcd..ff9c238ed2 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 @@ -26,6 +26,7 @@ import java.io.IOException; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; +import java.util.concurrent.atomic.AtomicBoolean; import static java.lang.Thread.currentThread; @@ -41,16 +42,14 @@ public final class ThreadedStreamConsumer 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 ); + private final AtomicBoolean stop = new AtomicBoolean(); + private final Thread thread; private final Pumper pumper; - private volatile boolean stop; - final class Pumper implements Runnable { @@ -76,14 +75,14 @@ final class Pumper */ public void run() { - while ( !ThreadedStreamConsumer.this.stop ) + while ( !ThreadedStreamConsumer.this.stop.get() ) { try { String item = ThreadedStreamConsumer.this.items.take(); if ( shouldStopQueueing( item ) ) { - break; + return; } target.consumeLine( item ); } @@ -114,7 +113,7 @@ public ThreadedStreamConsumer( StreamConsumer target ) public void consumeLine( String s ) { - if ( stop && !thread.isAlive() ) + if ( stop.get() && !thread.isAlive() ) { items.clear(); return; @@ -134,24 +133,17 @@ public void consumeLine( String s ) public void close() throws IOException { - if ( stop ) - { - return; - } - - try + if ( stop.compareAndSet( false, true ) ) { - items.put( END_ITEM ); - thread.join( CLOSE_TIMEOUT_MILLIS ); - } - catch ( InterruptedException e ) - { - currentThread().interrupt(); - throw new IOException( e ); - } - finally - { - stop = true; + items.clear(); + try + { + items.put( END_ITEM ); + } + catch ( InterruptedException e ) + { + currentThread().interrupt(); + } } if ( pumper.hasErrors() ) 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 12a5f92375..9e94e7fafa 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 @@ -46,4 +46,9 @@ public void shutdown( Shutdown shutdownType ) public void noop() { } + + @Override + public void acknowledgeByeEventReceived() + { + } } \ No newline at end of file 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 6fc171ef10..b117a38891 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 @@ -95,6 +95,7 @@ public void run() assertThat( is.read(), is( 0 ) ); assertThat( is.read(), is( 0 ) ); assertThat( is.read(), is( 0 ) ); + is.close(); assertThat( is.read(), is( -1 ) ); } diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/Command.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/Command.java index 49ae52d92c..5024992925 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/Command.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/Command.java @@ -36,6 +36,7 @@ public final class Command public static final Command TEST_SET_FINISHED = new Command( MasterProcessCommand.TEST_SET_FINISHED ); public static final Command SKIP_SINCE_NEXT_TEST = new Command( MasterProcessCommand.SKIP_SINCE_NEXT_TEST ); public static final Command NOOP = new Command( MasterProcessCommand.NOOP ); + public static final Command BYE_ACK = new Command( MasterProcessCommand.BYE_ACK ); private final MasterProcessCommand command; private final String data; 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 57f1c2cbab..fb3ad05eee 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 @@ -42,6 +42,7 @@ 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.BYE_ACK; import static org.apache.maven.surefire.booter.MasterProcessCommand.NOOP; import static org.apache.maven.surefire.booter.MasterProcessCommand.RUN_CLASS; import static org.apache.maven.surefire.booter.MasterProcessCommand.SHUTDOWN; @@ -166,6 +167,11 @@ public void addNoopListener( CommandListener listener ) addListener( NOOP, listener ); } + public void addByeAckListener( CommandListener listener ) + { + addListener( BYE_ACK, listener ); + } + private void addListener( MasterProcessCommand cmd, CommandListener listener ) { listeners.add( new BiProperty( cmd, listener ) ); @@ -470,17 +476,15 @@ private void exitByConfiguration() CommandReader.this.makeQueueFull(); CommandReader.this.wakeupIterator(); insertToListeners( toShutdown( shutdown ) ); - switch ( shutdown ) + if ( shutdown.isExit() ) { - case EXIT: - System.exit( 1 ); - case KILL: - Runtime.getRuntime().halt( 1 ); - case DEFAULT: - default: - // should not happen; otherwise you missed enum case - break; + System.exit( 1 ); + } + else if ( shutdown.isKill() ) + { + Runtime.getRuntime().halt( 1 ); } + // else is default: should not happen; otherwise you missed enum case } } } 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 d5e314a79d..229c8afa61 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 @@ -46,7 +46,8 @@ public enum MasterProcessCommand SHUTDOWN( 3, String.class ), /** To tell a forked process that the master process is still alive. Repeated after 10 seconds. */ - NOOP( 4, Void.class ); + NOOP( 4, Void.class ), + BYE_ACK( 5, Void.class ); private static final Charset ASCII = Charset.forName( "ASCII" ); diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/Shutdown.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/Shutdown.java index 262cb2972a..77a09cfcf2 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/Shutdown.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/Shutdown.java @@ -44,6 +44,21 @@ public String getParam() return param; } + public boolean isKill() + { + return this == KILL; + } + + public boolean isExit() + { + return this == EXIT; + } + + public boolean isDefaultShutdown() + { + return this == DEFAULT; + } + public static boolean isKnown( String param ) { for ( Shutdown shutdown : values() ) 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 2c110f5da6..b561295445 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,125 @@ -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 +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() || mkdirs( dumpFile ) && 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 ) + .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() ) ) + { + createWriter( dumpFile ) + .append( msg ) + .append( StringUtils.NL ) + .append( StringUtils.NL ) + .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 ) + { + File dir = dumpFile.getParentFile(); + return dir.exists() || dir.mkdirs(); + } +} diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java index 8396d8b93b..6e66a18494 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java @@ -117,6 +117,13 @@ public void testDataToByteArrayAndBack() decoded = command.toDataTypeAsString( encoded ); assertNull( decoded ); break; + case BYE_ACK: + assertEquals( Void.class, command.getDataType() ); + encoded = command.fromDataType( dummyData ); + assertThat( encoded.length, is( 0 ) ); + decoded = command.toDataTypeAsString( encoded ); + assertNull( decoded ); + break; default: fail(); } 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..665e2f82c5 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 @@ -36,21 +36,22 @@ 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; import java.util.concurrent.atomic.AtomicBoolean; +import static java.lang.Math.max; 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.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; 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; 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; @@ -70,8 +71,10 @@ 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 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; /** @@ -157,7 +160,7 @@ else if ( readTestsFromInputStream ) encodeAndWriteToOutput( ( (char) BOOTERCODE_BYE ) + ",0,BYE!\n", originalOut ); originalOut.flush(); // noinspection CallToSystemExit - exit( 0, EXIT, reader, false ); + exit( 0, reader ); } catch ( Throwable t ) { @@ -166,7 +169,7 @@ else if ( readTestsFromInputStream ) // noinspection UseOfSystemOutOrSystemErr t.printStackTrace( err ); // noinspection ProhibitedExceptionThrown,CallToSystemExit - exit( 1, EXIT, reader, false ); + exit( 1 ); } finally { @@ -181,11 +184,11 @@ private static CommandReader startupMasterProcessReader() private static ScheduledFuture listenToShutdownCommands( CommandReader reader ) { - reader.addShutdownListener( createExitHandler( reader ) ); + reader.addShutdownListener( createExitHandler() ); AtomicBoolean pingDone = new AtomicBoolean( true ); reader.addNoopListener( createPingHandler( pingDone ) ); - return JVM_TERMINATOR.scheduleAtFixedRate( createPingJob( pingDone, reader ), - 0, PING_TIMEOUT_IN_SECONDS, SECONDS ); + Runnable pingJob = createPingJob( pingDone ); + return JVM_PING.scheduleAtFixedRate( pingJob, 0, PING_TIMEOUT_IN_SECONDS, SECONDS ); } private static CommandListener createPingHandler( final AtomicBoolean pingDone ) @@ -199,18 +202,27 @@ public void update( Command command ) }; } - private static CommandListener createExitHandler( final CommandReader reader ) + private static CommandListener createExitHandler() { return new CommandListener() { public void update( Command command ) { - exit( 1, command.toShutdownData(), reader, true ); + Shutdown shutdown = command.toShutdownData(); + if ( shutdown.isKill() ) + { + kill(); + } + else if ( shutdown.isExit() ) + { + exit( 1 ); + } + // else refers to shutdown=testset, but not used now, keeping reader open } }; } - private static Runnable createPingJob( final AtomicBoolean pingDone, final CommandReader reader ) + private static Runnable createPingJob( final AtomicBoolean pingDone ) { return new Runnable() { @@ -219,7 +231,7 @@ public void run() boolean hasPing = pingDone.getAndSet( false ); if ( !hasPing ) { - exit( 1, KILL, reader, true ); + kill(); } } }; @@ -231,23 +243,44 @@ private static void encodeAndWriteToOutput( String string, PrintStream out ) out.write( encodeBytes, 0, encodeBytes.length ); } - private static void exit( int returnCode, Shutdown shutdownType, CommandReader reader, boolean stopReaderOnExit ) + private static void kill() { - switch ( shutdownType ) + Runtime.getRuntime().halt( 1 ); + } + + private static void exit( int returnCode ) + { + launchLastDitchDaemonShutdownThread( returnCode ); + System.exit( returnCode ); + } + + private static void exit( int returnCode, final CommandReader reader ) + { + final Semaphore barrier = new Semaphore( 0 ); + reader.addByeAckListener( new CommandListener() + { + @Override + public void update( Command command ) + { + barrier.release(); + } + } + ); + launchLastDitchDaemonShutdownThread( returnCode ); + final long timeoutMillis = max( systemExitTimeoutInSeconds * ONE_SECOND_IN_MILLIS, ONE_SECOND_IN_MILLIS ); + acquireOnePermit( barrier, timeoutMillis ); + System.exit( returnCode ); + } + + private static boolean acquireOnePermit( Semaphore barrier, long timeoutMillis ) + { + try { - case KILL: - Runtime.getRuntime().halt( returnCode ); - case EXIT: - if ( stopReaderOnExit ) - { - reader.stop(); - } - launchLastDitchDaemonShutdownThread( returnCode ); - System.exit( returnCode ); - case DEFAULT: - // refers to shutdown=testset, but not used now, keeping reader open - default: - break; + return barrier.tryAcquire( timeoutMillis, MILLISECONDS ); + } + catch ( InterruptedException e ) + { + return true; } } @@ -269,11 +302,25 @@ private static ReporterFactory createForkingReporterFactory( ProviderConfigurati return new ForkingReporterFactory( trimStackTrace, originalSystemOut ); } - private static ScheduledExecutorService createJvmTerminator() + private static synchronized ScheduledThreadPoolExecutor getJvmTerminator() + { + if ( jvmTerminator == null ) + { + ThreadFactory threadFactory = + newDaemonThreadFactory( "last-ditch-daemon-shutdown-thread-" + systemExitTimeoutInSeconds + "s" ); + jvmTerminator = new ScheduledThreadPoolExecutor( 1, threadFactory ); + jvmTerminator.setMaximumPoolSize( 1 ); + return jvmTerminator; + } + else + { + return jvmTerminator; + } + } + + private static ScheduledExecutorService createPingScheduler() { - ThreadFactory threadFactory = newDaemonThreadFactory( "last-ditch-daemon-shutdown-thread-" - + systemExitTimeoutInSeconds - + "s" ); + ThreadFactory threadFactory = newDaemonThreadFactory( "ping-" + PING_TIMEOUT_IN_SECONDS + "s" ); ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor( 1, threadFactory ); executor.setMaximumPoolSize( 1 ); executor.prestartCoreThread(); @@ -283,13 +330,14 @@ private static ScheduledExecutorService createJvmTerminator() @SuppressWarnings( "checkstyle:emptyblock" ) private static void launchLastDitchDaemonShutdownThread( final int returnCode ) { - JVM_TERMINATOR.schedule( new Runnable() - { - public void run() - { - Runtime.getRuntime().halt( returnCode ); - } - }, systemExitTimeoutInSeconds, SECONDS ); + getJvmTerminator().schedule( new Runnable() + { + public void run() + { + Runtime.getRuntime().halt( returnCode ); + } + }, systemExitTimeoutInSeconds, SECONDS + ); } private static RunResult invokeProviderInSameClassLoader( Object testSet, Object factory, 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 75aa7431d8..b1852179cc 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 @@ -52,6 +52,7 @@ public void pluggableProviderPresent() throws Exception { unpack( "surefire-141-pluggableproviders" ) + .setForkJvm() .maven() .showExceptionMessages() .debugLogging() @@ -68,13 +69,20 @@ public void invokeRuntimeException() final String errorText = "Let's fail with a runtimeException"; OutputValidator validator = unpack( "surefire-141-pluggableproviders" ) + .setForkJvm() .sysProp( "invokeCrash", "runtimeException" ) .maven() .withFailure() - .executeTest() - .verifyTextInLog( errorText ); + .executeTest(); assertErrorMessage( validator, errorText ); + + boolean hasErrorInLog = verifiedErrorInLog( validator, "There was an error in the forked process" ); + boolean verifiedInLog = verifiedErrorInLog( validator, errorText ); + assertThat( hasErrorInLog && verifiedInLog ) + .describedAs( "'" + errorText + "' could not be verified in log.txt nor *.dump file. (" + + hasErrorInLog + ", " + verifiedInLog + ")" ) + .isTrue(); } @Test @@ -84,13 +92,20 @@ public void invokeReporterException() final String errorText = "Let's fail with a reporterexception"; OutputValidator validator = unpack( "surefire-141-pluggableproviders" ) + .setForkJvm() .sysProp( "invokeCrash", "reporterException" ) .maven() .withFailure() - .executeTest() - .verifyTextInLog( errorText ); + .executeTest(); assertErrorMessage( validator, errorText ); + + boolean hasErrorInLog = verifiedErrorInLog( validator, "There was an error in the forked process" ); + boolean verifiedInLog = verifiedErrorInLog( validator, errorText ); + assertThat( hasErrorInLog && verifiedInLog ) + .describedAs( "'" + errorText + "' could not be verified in log.txt nor *.dump file. (" + + hasErrorInLog + ", " + verifiedInLog + ")" ) + .isTrue(); } @Test @@ -100,15 +115,19 @@ public void constructorRuntimeException() final String errorText = "Let's fail with a runtimeException"; OutputValidator validator = unpack( "surefire-141-pluggableproviders" ) + .setForkJvm() .sysProp( "constructorCrash", "runtimeException" ) .maven() .withFailure() .executeTest(); + assertErrorMessage( validator, errorText ); + + boolean hasErrorInLog = verifiedErrorInLog( validator, "There was an error in the forked process" ); 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." ) + assertThat( hasErrorInLog && verifiedInLog ) + .describedAs( "'" + errorText + "' could not be verified in log.txt nor *.dump file. (" + + hasErrorInLog + ", " + verifiedInLog + ")" ) .isTrue(); } From 67e61b07e35ce2ade82efc8e69240003b28fd83e Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 1 Apr 2017 14:27:07 +0200 Subject: [PATCH 064/194] [SUREFIRE-1349] FreeBSD cross process communication needs to commit stdout data in forked JVM within a synchronized block --- .../plugin/surefire/booterclient/ForkConfiguration.java | 7 +++++-- .../org/apache/maven/surefire/booter/CommandReader.java | 6 +++++- .../apache/maven/surefire/booter/ForkingRunListener.java | 2 ++ .../org/apache/maven/surefire/booter/ForkedBooter.java | 7 +++++-- 4 files changed, 17 insertions(+), 5 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 988af8f5c1..52bc928c73 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 @@ -297,13 +297,16 @@ private File createJar( List classPath, String startClassName ) man.getMainAttributes().putValue( "Main-Class", startClassName ); man.write( jos ); + + jos.closeEntry(); + jos.flush(); + + return file; } finally { jos.close(); } - - return file; } public boolean isDebug() 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 fb3ad05eee..2e80f449a9 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 @@ -342,7 +342,11 @@ private void popUnread() private void requestNextTest() { byte[] encoded = encodeStringForForkCommunication( ( (char) BOOTERCODE_NEXT_TEST ) + ",0,want more!\n" ); - originalOutStream.write( encoded, 0, encoded.length ); + synchronized ( originalOutStream ) + { + originalOutStream.write( encoded, 0, encoded.length ); + originalOutStream.flush(); + } } private boolean shouldFinish() 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 12165029ca..7856dacb91 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,7 @@ 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 ); + target.flush(); if ( target.checkError() ) { // We MUST NOT throw any exception from this method; otherwise we are in loop and CPU goes up: @@ -275,6 +276,7 @@ private void encodeAndWriteToTarget( String string ) synchronized ( target ) // See notes about synchronization/thread safety in class javadoc { target.write( encodeBytes, 0, encodeBytes.length ); + target.flush(); if ( target.checkError() ) { // We MUST NOT throw any exception from this method; otherwise we are in loop and CPU goes up: 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 665e2f82c5..5401abfef3 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 @@ -158,7 +158,6 @@ else if ( readTestsFromInputStream ) } // Say bye. encodeAndWriteToOutput( ( (char) BOOTERCODE_BYE ) + ",0,BYE!\n", originalOut ); - originalOut.flush(); // noinspection CallToSystemExit exit( 0, reader ); } @@ -240,7 +239,11 @@ public void run() private static void encodeAndWriteToOutput( String string, PrintStream out ) { byte[] encodeBytes = encodeStringForForkCommunication( string ); - out.write( encodeBytes, 0, encodeBytes.length ); + synchronized ( out ) + { + out.write( encodeBytes, 0, encodeBytes.length ); + out.flush(); + } } private static void kill() From 40f38c521b839d80a04f0f0de3deebb8009370f3 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 1 Apr 2017 14:52:44 +0200 Subject: [PATCH 065/194] [SUREFIRE-1350] Upgrade Version of maven-invoker-plugin to 2.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index df9d79b036..41e5a5a9a5 100644 --- a/pom.xml +++ b/pom.xml @@ -325,7 +325,7 @@ maven-invoker-plugin - 1.10 + 2.0.0 org.jacoco From 561c696523bf431c65ca1c6eef88a66599f94105 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 1 Apr 2017 14:54:03 +0200 Subject: [PATCH 066/194] improve verify.bsh to verify in maven-invoker-plugin --- maven-failsafe-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index a5d41ff5a1..dc1df6d2ed 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -291,7 +291,7 @@ */pom.xml - verify.bsh + verify src/it/settings.xml ${skipTests} false From dc3f3674e17c3502312a88385272c6add9d4b4ad Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 1 Apr 2017 15:05:02 +0200 Subject: [PATCH 067/194] [SUREFIRE-1351] Performance unit tests should GC to free limited memory size. --- surefire-providers/surefire-junit47/pom.xml | 1 + .../surefire/junitcore/pc/ParallelComputerBuilderTest.java | 5 +++-- .../surefire/junitcore/pc/ParallelComputerUtilTest.java | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml index 919c52512a..91dc0c1678 100644 --- a/surefire-providers/surefire-junit47/pom.xml +++ b/surefire-providers/surefire-junit47/pom.xml @@ -128,6 +128,7 @@ **/JUnit47SuiteTest.java + -Xms256m -Xmx256m 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 5184cddb9f..0af17cd45c 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 @@ -91,8 +91,7 @@ private static void testKeepBeforeAfter( ParallelComputerBuilder builder, Class< } @Before - public void beforeTest() - { + public void beforeTest() throws InterruptedException { Class1.maxConcurrentMethods = 0; Class1.concurrentMethods = 0; shutdownTask = null; @@ -101,6 +100,8 @@ public void beforeTest() NotThreadSafeTest3.t = null; NormalTest1.t = null; NormalTest2.t = null; + System.gc(); + Thread.sleep( 50L ); } @Test diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java index 15daac97f3..e41dbaa66f 100644 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java +++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java @@ -87,7 +87,10 @@ public static void afterClass() @Before public void beforeTest() + throws InterruptedException { + System.gc(); + Thread.sleep( 50L ); assertFalse( Thread.currentThread().isInterrupted() ); } From b08627f0fd21ab16b682badbc205cd2823f64656 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 1 Apr 2017 19:55:45 +0200 Subject: [PATCH 068/194] [SUREFIRE-1352] Dump file [date]-jvmRun[N] where N should be real fork number --- .../maven/plugin/surefire/booterclient/ForkStarter.java | 4 +--- 1 file changed, 1 insertion(+), 3 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 b69d010d06..5360b4cdbc 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 @@ -132,8 +132,6 @@ public class ForkStarter 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; @@ -594,7 +592,7 @@ private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkC } cli.createArg().setValue( tempDir ); - cli.createArg().setValue( DUMP_FILE_PREFIX + DUMP_FILE_POSTFIX_COUNTER.incrementAndGet() ); + cli.createArg().setValue( DUMP_FILE_PREFIX + forkNumber ); cli.createArg().setValue( surefireProperties.getName() ); if ( systPropsFile != null ) { From 9c417780b512533edbe20f630525f75c6248160c Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 1 Apr 2017 20:44:02 +0200 Subject: [PATCH 069/194] [SUREFIRE-1353] Integration tests testing jvm forks should use subprocess and not embedded mode --- .../surefire/its/ForkConsoleOutputIT.java | 36 +++++++++++++------ .../its/ForkConsoleOutputWithErrorsIT.java | 18 +++++----- .../apache/maven/surefire/its/ForkModeIT.java | 2 +- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java index 7ec0039c58..6aac33068e 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java @@ -19,7 +19,6 @@ * 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; @@ -37,30 +36,47 @@ public class ForkConsoleOutputIT @Test public void printSummaryTrueWithRedirect() { - final OutputValidator outputValidator = unpack().redirectToFile( true ).printSummary( true ).executeTest(); - outputValidator.getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ).assertFileExists(); + unpack().setForkJvm() + .redirectToFile( true ) + .printSummary( true ) + .executeTest() + .getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ) + .assertFileExists(); } @Test public void printSummaryTrueWithoutRedirect() { - final OutputValidator outputValidator = unpack().redirectToFile( false ).printSummary( true ).executeTest(); - outputValidator.getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ).assertFileNotExists(); + unpack().setForkJvm() + .redirectToFile( false ) + .printSummary( true ) + .executeTest() + .getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ) + .assertFileNotExists(); } @Test public void printSummaryFalseWithRedirect() { - final OutputValidator outputValidator = - unpack().redirectToFile( true ).printSummary( false ).debugLogging().showErrorStackTraces().executeTest(); - outputValidator.getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ).assertFileExists(); + unpack().setForkJvm() + .redirectToFile( true ) + .printSummary( false ) + .debugLogging() + .showErrorStackTraces() + .executeTest() + .getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ) + .assertFileExists(); } @Test public void printSummaryFalseWithoutRedirect() { - final OutputValidator outputValidator = unpack().redirectToFile( false ).printSummary( false ).executeTest(); - outputValidator.getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ).assertFileNotExists(); + unpack().setForkJvm() + .redirectToFile( false ) + .printSummary( false ) + .executeTest() + .getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ) + .assertFileNotExists(); } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java index af4a6e67eb..e5feb7fe91 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java @@ -19,9 +19,7 @@ * 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.TestFile; import org.junit.Test; /** @@ -32,16 +30,18 @@ * @author Kristian Rosenvold */ public class ForkConsoleOutputWithErrorsIT - extends SurefireJUnit4IntegrationTestCase + extends SurefireJUnit4IntegrationTestCase { @Test public void xmlFileContainsConsoleOutput() { - final OutputValidator outputValidator = unpack( "/fork-consoleOutputWithErrors" ). - failNever().redirectToFile( true ).executeTest(); - final TestFile surefireReportsFile = - outputValidator.getSurefireReportsXmlFile( "TEST-forkConsoleOutput.Test2.xml" ); - surefireReportsFile.assertContainsText( "sout: Will Fail soon" ); - surefireReportsFile.assertContainsText( "serr: Will Fail now" ); + unpack( "/fork-consoleOutputWithErrors" ) + .setForkJvm() + .failNever() + .redirectToFile( true ) + .executeTest() + .getSurefireReportsXmlFile( "TEST-forkConsoleOutput.Test2.xml" ) + .assertContainsText( "sout: Will Fail soon" ) + .assertContainsText( "serr: Will Fail now" ); } } 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 0be212321c..574d144941 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 @@ -144,7 +144,7 @@ public void testForkCountOneReuse() public void testForkCountTwoNoReuse() { String[] pids = - doTest( unpack( getProject() ).forkCount( 2 ).reuseForks( false ).addGoal( "-DsleepLength=1200" ) ); + doTest( unpack( getProject() ).setForkJvm().forkCount( 2 ).reuseForks( false ).addGoal( "-DsleepLength=1200" ) ); assertDifferentPids( pids ); assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) ); } From a72cedddc28ce97e9134271934887667390f0654 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 2 Apr 2017 12:06:13 +0200 Subject: [PATCH 070/194] re-introduce jacoco.agent in surefire-junit47 --- pom.xml | 2 +- surefire-providers/surefire-junit47/pom.xml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 41e5a5a9a5..1a9ba58671 100644 --- a/pom.xml +++ b/pom.xml @@ -302,7 +302,7 @@ false - ${jacoco.agent} + -Xms128m -Xmx128m ${jacoco.agent} diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml index 91dc0c1678..919c52512a 100644 --- a/surefire-providers/surefire-junit47/pom.xml +++ b/surefire-providers/surefire-junit47/pom.xml @@ -128,7 +128,6 @@ **/JUnit47SuiteTest.java - -Xms256m -Xmx256m From c944f26340e2d8873008dbaaf67d9188b39cee11 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 2 Apr 2017 13:26:23 +0200 Subject: [PATCH 071/194] [SUREFIRE-1317] Refactoring --- maven-surefire-common/pom.xml | 4 +- .../plugin/surefire/AbstractSurefireMojo.java | 3 +- .../booterclient/ForkConfiguration.java | 45 +++--- .../output/DeserializedStacktraceWriter.java | 2 +- .../booterclient/output/ForkClient.java | 2 + .../surefire/report/StatelessXmlReporter.java | 7 +- .../plugin/surefire/util/ImmutableMap.java | 133 ++++++++++++++++++ .../maven/plugin/surefire/util/Relocator.java | 7 +- .../surefire/util/ImmutableMapTest.java | 86 +++++++++++ .../maven/surefire/JUnit4SuiteTest.java | 4 +- .../maven/plugins/surefire/report/Utils.java | 1 + pom.xml | 12 ++ .../main/appended-resources/META-INF/NOTICE | 3 - .../surefire/booter/ForkingRunListener.java | 4 +- .../surefire/booter/MasterProcessCommand.java | 8 +- .../report/CategorizedReportEntry.java | 17 +-- .../report/LegacyPojoStackTraceWriter.java | 2 +- .../maven/surefire/report/SafeThrowable.java | 5 + .../surefire/util/internal/StringUtils.java | 43 +++--- .../maven/surefire/booter/ForkedBooter.java | 3 +- .../surefire/report/PojoStackTraceWriter.java | 4 +- .../conf/AbstractDirectConfigurator.java | 2 +- .../testng/conf/TestNG513Configurator.java | 2 +- 23 files changed, 317 insertions(+), 82 deletions(-) create mode 100644 maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java create mode 100644 maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java delete mode 100644 surefire-api/src/main/appended-resources/META-INF/NOTICE diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index 54825b757e..6e8ac703e8 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -113,8 +113,7 @@ org.mockito - mockito-all - 1.8.4 + mockito-core test @@ -141,6 +140,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..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.mockito mockito-core 1.10.19 + + + org.hamcrest + hamcrest-core + + junit @@ -255,6 +261,12 @@ junit junit test + + + 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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT org.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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT maven-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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT org.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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT org.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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT pom Apache 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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire-providers - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT common-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.surefire surefire-providers - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT common-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.surefire surefire-providers - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT common-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.surefire surefire-providers - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT common-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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire-providers - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire-providers - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire-providers - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire-providers - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire-providers - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire - 2.19.2-SNAPSHOT + 2.20-SNAPSHOT surefire-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.surefire surefire - 2.20-SNAPSHOT + 2.20 org.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.surefire surefire - 2.20-SNAPSHOT + 2.20 maven-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.surefire surefire - 2.20-SNAPSHOT + 2.20 org.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.surefire surefire - 2.20-SNAPSHOT + 2.20 org.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.surefire surefire - 2.20-SNAPSHOT + 2.20 pom Apache 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-3 jira 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.surefire surefire - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire - 2.20-SNAPSHOT + 2.20 surefire-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.0 org.apache.maven.surefire surefire - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire-providers - 2.20-SNAPSHOT + 2.20 common-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.surefire surefire-providers - 2.20-SNAPSHOT + 2.20 common-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.surefire surefire-providers - 2.20-SNAPSHOT + 2.20 common-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.surefire surefire-providers - 2.20-SNAPSHOT + 2.20 common-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.surefire surefire - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire-providers - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire-providers - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire-providers - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire-providers - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire-providers - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire - 2.20-SNAPSHOT + 2.20 surefire-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.surefire surefire - 2.20 + 2.21-SNAPSHOT org.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.surefire surefire - 2.20 + 2.21-SNAPSHOT maven-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.surefire surefire - 2.20 + 2.21-SNAPSHOT org.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.surefire surefire - 2.20 + 2.21-SNAPSHOT org.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.surefire surefire - 2.20 + 2.21-SNAPSHOT pom Apache 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 + HEAD jira 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.surefire surefire - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire-providers - 2.20 + 2.21-SNAPSHOT common-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.surefire surefire-providers - 2.20 + 2.21-SNAPSHOT common-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.surefire surefire-providers - 2.20 + 2.21-SNAPSHOT common-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.surefire surefire-providers - 2.20 + 2.21-SNAPSHOT common-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.surefire surefire - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire-providers - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire-providers - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire-providers - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire-providers - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire-providers - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire - 2.20 + 2.21-SNAPSHOT surefire-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.surefire surefire - 2.20 + 2.21-SNAPSHOT surefire-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 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 + + + ../maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd + ../maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb + org.apache.maven.plugin.failsafe.xmlsummary + + + + + + org.apache.maven.plugins maven-plugin-plugin 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 1ad317fa51..a336e281f8 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 @@ -39,7 +39,7 @@ import java.util.List; import java.util.Locale; -import static org.apache.maven.plugin.failsafe.xmlsummary.FailsafeSummaryXmlUtils.writeSummary; +import static org.apache.maven.plugin.failsafe.util.FailsafeSummaryXmlUtils.writeSummary; import static org.apache.maven.shared.utils.ReaderFactory.FILE_ENCODING; /** @@ -47,7 +47,6 @@ * * @author Jason van Zyl * @author Stephen Connolly - * @noinspection JavaDoc, */ @Mojo( name = "integration-test", requiresProject = true, requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.INTEGRATION_TEST, threadSafe = true ) @@ -60,7 +59,7 @@ public class IntegrationTestMojo /** * The path representing project JAR file, if exists; Otherwise the directory containing generated * classes of the project being tested. This will be included after the test classes in the test classpath. - * Defaults to built artifact JAR file or ${project.build.outputDirectory}. + * Defaults to built artifact JAR file or ${project.build.outputDirectory}. */ @Parameter private File classesDirectory; @@ -83,25 +82,28 @@ public class IntegrationTestMojo @Parameter( defaultValue = "${project.build.directory}/failsafe-reports" ) private File reportsDirectory; + @SuppressWarnings( "checkstyle:linelength" ) /** - * Specify this parameter to run individual tests by file name, overriding the includes/excludes - * parameters. Each pattern you specify here will be used to create an include pattern formatted like - * **/${it.test}.java, so you can just type "-Dit.test=MyIT" to run a single test called - * "foo/MyIT.java".
- * This parameter overrides the includes/excludes parameters, and the TestNG suiteXmlFiles - * parameter. - *

- * Since 2.7.3 You can execute a limited number of methods in the test with adding #myMethod or #my*ethod. E.g. type - * "-Dit.test=MyIT#myMethod" supported for junit 4.x and testNg - *
- * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
- * "-Dit.test=???IT, !Unstable*, pkg/**/Ci*leIT.java, *IT#test*One+testTwo?????, #fast*+slowTest"
- * "-Dit.test=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyIT.class#one.*|two.*], %regex[#fast.*|slow.*]"
- *
- * The Parameterized JUnit runner describes test methods using an index in brackets, so the non-regex - * method pattern would become: #testMethod[*]. If using @Parameters(name="{index}: fib({0})={1}") - * and selecting the index e.g. 5 in pattern, the non-regex method pattern would become #testMethod[5:*]. - *
+ * Specify this parameter to run individual tests by file name, overriding parameter {@code includes} and + * {@code excludes}. Each pattern you specify here will be used to create an include pattern formatted like + * **{@literal /}${it.test}.java, so you can just type {@code -Dit.test=MyIT} to run + * a single test file called "foo/MyIT.java". The test patterns prefixed with a ! will be excluded. + *
+ * This parameter overrides the parameter {@code includes} and {@code excludes}, and the TestNG parameter + * {@code suiteXmlFiles}. + *
+ * Since 2.7.3 You can execute a limited number of methods in the test with adding #myMethod or + * #my*ethod. E.g. type {@code -Dit.test=MyIT#myMethod} supported for junit 4.x and TestNg. + *
+ * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): + *

"-Dit.test=???IT, !Unstable*, pkg{@literal /}**{@literal /}Ci*leIT.java, *IT#test*One+testTwo?????, #fast*+slowTest"
+ * or e.g. + *
+ *
"-Dit.test=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyIT.class#one.*|two.*], %regex[#fast.*|slow.*]"
+ *
+ * The Parameterized JUnit runner {@code describes} test methods using an index in brackets, so the non-regex + * method pattern would become: {@code #testMethod[*]}. If using @Parameters(name="{index}: fib({0})={1}") + * and selecting the index e.g. 5 in pattern, the non-regex method pattern would become {@code #testMethod[5:*]}. */ @Parameter( property = "it.test" ) private String test; @@ -143,7 +145,7 @@ public class IntegrationTestMojo /** * Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach * on port 5005. If set to some other string, that string will be appended to the argLine, allowing you to configure - * arbitrary debuggability options (without overwriting the other options specified through the argLine + * arbitrary debugging ability options (without overwriting the other options specified through the {@code argLine} * parameter). * * @since 2.4 @@ -163,7 +165,7 @@ public class IntegrationTestMojo /** * Forked process is normally terminated without any significant delay after given tests have completed. * If the particular tests started non-daemon Thread(s), the process hangs instead of been properly terminated - * by System.exit(). Use this parameter in order to determine the timeout of terminating the process. + * by {@code System.exit()}. Use this parameter in order to determine the timeout of terminating the process. * see the documentation: * http://maven.apache.org/surefire/maven-failsafe-plugin/examples/shutdown.html * @@ -174,11 +176,11 @@ public class IntegrationTestMojo /** * Stop executing queued parallel JUnit tests after a certain number of seconds. - *
- * Example values: "3.5", "4"
- *
+ *
+ * Example values: "3.5", "4"
+ *
* If set to 0, wait forever, never timing out. - * Makes sense with specified parallel different from "none". + * Makes sense with specified {@code parallel} different from "none". * * @since 2.16 */ @@ -187,40 +189,45 @@ public class IntegrationTestMojo /** * Stop executing queued parallel JUnit tests - * and interrupt currently running tests after a certain number of seconds. - *
- * Example values: "3.5", "4"
- *
+ * and interrupt currently running tests after a certain number of seconds. + *
+ * Example values: "3.5", "4"
+ *
* If set to 0, wait forever, never timing out. - * Makes sense with specified parallel different from "none". + * Makes sense with specified {@code parallel} different from "none". * * @since 2.16 */ @Parameter( property = "failsafe.parallel.forcedTimeout" ) private double parallelTestsTimeoutForcedInSeconds; + @SuppressWarnings( "checkstyle:linelength" ) /** - * A list of <include> elements specifying the tests (by pattern) that should be included in testing. When not - * specified and when the test parameter is not specified, the default includes will be
- * <includes>
- *  <include>**/IT*.java</include>
- *  <include>**/*IT.java</include>
- *  <include>**/*ITCase.java</include>
- * </includes>
- *
- *

+ * A list of {@literal } elements specifying the test filter (by pattern) of tests which should be + * included in testing. If it is not specified and the {@code test} parameter is unspecified as well, the default + * includes is + *


+     * {@literal }
+     *     {@literal }**{@literal /}IT*.java{@literal }
+     *     {@literal }**{@literal /}*IT.java{@literal }
+     *     {@literal }**{@literal /}*ITCase.java{@literal }
+     * {@literal }
+     * 
+ *
* Each include item may also contain a comma-separated sublist of items, which will be treated as multiple - *  <include> entries.
- * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
- *  <include>%regex[.*[Cat|Dog].*], Basic????, !Unstable*</include>
- *  <include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg/**/*Fast*.java</include>
- *

- * This parameter is ignored if the TestNG suiteXmlFiles parameter is specified.
- *
- * Notice that these values are relative to the directory containing generated test classes of the project - * being tested. This directory is declared by the parameter testClassesDirectory which defaults - * to the POM property ${project.build.testOutputDirectory}, typically src/test/java - * unless overridden. + * {@literal } entries.
+ * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): + *


+     * {@literal }%regex[.*[Cat|Dog].*], Basic????, !Unstable*{@literal }
+     * {@literal }%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg{@literal /}**{@literal /}*Fast*.java{@literal }
+     * 
+ *
+ * This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified.
+ *
+ * Notice that these values are relative to the directory containing generated test classes of the project + * being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults + * to the POM property ${project.build.testOutputDirectory}, typically + * {@literal src/test/java} unless overridden. */ @Parameter private List includes; @@ -241,7 +248,7 @@ public class IntegrationTestMojo * * 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. * * @since 2.4.3 @@ -265,10 +272,10 @@ public class IntegrationTestMojo private int rerunFailingTestsCount; /** - * (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that - * suiteXmlFiles is incompatible with several other parameters of this plugin, like - * includes/excludes.
- * This parameter is ignored if the test parameter is specified (allowing you to run a single test + * (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that + * {@code suiteXmlFiles} is incompatible with several other parameters of this plugin, like + * {@code includes} and {@code excludes}.
+ * This parameter is ignored if the {@code test} parameter is specified (allowing you to run a single test * instead of an entire suite). * * @since 2.2 @@ -277,26 +284,26 @@ public class IntegrationTestMojo private File[] suiteXmlFiles; /** - * Defines the order the tests will be run in. Supported values are "alphabetical", "reversealphabetical", "random", - * "hourly" (alphabetical on even hours, reverse alphabetical on odd hours), "failedfirst", "balanced" and - * "filesystem". - *
- *
+ * Defines the order the tests will be run in. Supported values are {@code alphabetical}, + * {@code reversealphabetical}, {@code random}, {@code hourly} (alphabetical on even hours, reverse alphabetical + * on odd hours), {@code failedfirst}, {@code balanced} and {@code filesystem}. + *
+ *
* Odd/Even for hourly is determined at the time the of scanning the classpath, meaning it could change during a * multi-module build. - *
- *
+ *
+ *
* Failed first will run tests that failed on previous run first, as well as new tests for this run. - *
- *
+ *
+ *
* Balanced is only relevant with parallel=classes, and will try to optimize the run-order of the tests reducing the * overall execution time. Initially a statistics file is created and every next test run will reorder classes. - *
- *
- * Note that the statistics are stored in a file named .surefire-XXXXXXXXX beside pom.xml, and should not be checked - * into version control. The "XXXXX" is the SHA1 checksum of the entire surefire configuration, so different - * configurations will have different statistics files, meaning if you change any config settings you will re-run - * once before new statistics data can be established. + *
+ *
+ * Note that the statistics are stored in a file named .surefire-XXXXXXXXX beside pom.xml and + * should not be checked into version control. The "XXXXX" is the SHA1 checksum of the entire surefire + * configuration, so different configurations will have different statistics files, meaning if you change any + * configuration settings you will re-run once before new statistics data can be established. * * @since 2.7 */ @@ -304,31 +311,37 @@ public class IntegrationTestMojo private String runOrder; /** - * A file containing include patterns. Blank lines, or lines starting with # are ignored. If {@code includes} are - * also specified, these patterns are appended. Example with path, simple and regex includes:
- * */it/*
- * **/NotIncludedByDefault.java
- * %regex[.*IT.*|.*Not.*]
+ * A file containing include patterns, each in a next line. Blank lines, or lines starting with # are ignored. + * If {@code includes} are also specified, these patterns are appended. Example with path, simple and regex + * includes: + *

+     * *{@literal /}it{@literal /}*
+     * **{@literal /}NotIncludedByDefault.java
+     * %regex[.*IT.*|.*Not.*]
+     * 
*/ @Parameter( property = "failsafe.includesFile" ) private File includesFile; /** - * A file containing exclude patterns. Blank lines, or lines starting with # are ignored. If {@code excludes} are - * also specified, these patterns are appended. Example with path, simple and regex excludes:
- * */it/*
- * **/DontRunIT.*
- * %regex[.*IT.*|.*Not.*]
+ * A file containing exclude patterns, each in a next line. Blank lines, or lines starting with # are ignored. + * If {@code excludes} are also specified, these patterns are appended. + * Example with path, simple and regex excludes: + *

+     * *{@literal /}it{@literal /}*
+     * **{@literal /}DontRunIT.*
+     * %regex[.*IT.*|.*Not.*]
+     * 
*/ @Parameter( property = "failsafe.excludesFile" ) private File excludesFile; /** * Set to error/failure count in order to skip remaining tests. - * Due to race conditions in parallel/forked execution this may not be fully guaranteed.
- * Enable with system property -Dfailsafe.skipAfterFailureCount=1 or any number greater than zero. - * Defaults to "0".
- * See the prerequisites and limitations in documentation:
+ * Due to race conditions in parallel/forked execution this may not be fully guaranteed.
+ * Enable with system property {@code -Dfailsafe.skipAfterFailureCount=1} or any number greater than zero. + * Defaults to "0".
+ * See the prerequisites and limitations in documentation:
* * http://maven.apache.org/plugins/maven-failsafe-plugin/examples/skip-after-failure.html * @@ -338,12 +351,18 @@ public class IntegrationTestMojo private int skipAfterFailureCount; /** - * After the plugin process is shutdown by sending SIGTERM signal (CTRL+C), SHUTDOWN command is received by every - * forked JVM. By default (shutdown=testset) forked JVM would not continue with new test which means that - * the current test may still continue to run.
- * The parameter can be configured with other two values "exit" and "kill".
- * Using "exit" forked JVM executes System.exit(1) after the plugin process has received SIGTERM signal.
- * Using "kill" the JVM executes Runtime.halt(1) and kills itself. + * After the plugin process is shutdown by sending SIGTERM signal (CTRL+C), SHUTDOWN command is + * received by every forked JVM. + *
+ * By default ({@code shutdown=testset}) forked JVM would not continue with new test which means that + * the current test may still continue to run. + *
+ * The parameter can be configured with other two values {@code exit} and {@code kill}. + *
+ * Using {@code exit} forked JVM executes {@code System.exit(1)} after the plugin process has received + * SIGTERM signal. + *
+ * Using {@code kill} the JVM executes {@code Runtime.halt(1)} and kills itself. * * @since 2.19 */ 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 0ad7f80d4a..04cc72c5f9 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 @@ -23,7 +23,7 @@ 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.failsafe.util.FailsafeSummaryXmlUtils; import org.apache.maven.plugin.surefire.SurefireHelper; import org.apache.maven.plugin.surefire.SurefireReportParameters; import org.apache.maven.plugin.surefire.log.PluginConsoleLogger; 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/util/FailsafeSummaryXmlUtils.java similarity index 86% rename from maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummaryXmlUtils.java rename to maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java index c5623c1ef8..1f3f64df5d 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/util/FailsafeSummaryXmlUtils.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.failsafe.xmlsummary; +package org.apache.maven.plugin.failsafe.util; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,13 +19,13 @@ * under the License. */ +import org.apache.maven.plugin.failsafe.xmlsummary.ErrorType; +import org.apache.maven.plugin.failsafe.xmlsummary.FailsafeSummary; 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; @@ -67,20 +67,10 @@ public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafe summary.setFailures( fromRunResult.getFailures() ); summary.setSkipped( fromRunResult.getSkipped() ); summary.setTimeout( fromRunResult.isTimeout() ); - summary.setResult( ErrorType.fromValue( fromRunResult.getFailsafeCode() ) ); + Integer errorCode = fromRunResult.getFailsafeCode(); + summary.setResult( errorCode == null ? null : ErrorType.fromValue( String.valueOf( errorCode ) ) ); - String unmarshalled = JAXB.marshal( summary, encoding ); - - OutputStreamWriter os = new OutputStreamWriter( new FileOutputStream( toFailsafeSummaryXml ), encoding ); - try - { - os.write( unmarshalled ); - os.flush(); - } - finally - { - os.close(); - } + JAXB.marshal( summary, encoding, toFailsafeSummaryXml ); } public static void writeSummary( RunResult mergedSummary, File mergedSummaryFile, boolean inProgress, diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/JAXB.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/JAXB.java new file mode 100644 index 0000000000..ac51292f38 --- /dev/null +++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/JAXB.java @@ -0,0 +1,104 @@ +package org.apache.maven.plugin.failsafe.util; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import javax.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.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(); + } + + @SuppressWarnings( "unchecked" ) + public static void marshal( T bean, Charset encoding, File destination ) throws JAXBException, IOException + { + Class type = (Class) bean.getClass(); + JAXBElement rootElement = buildJaxbElement( bean, type ); + 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 ); + 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() ); + } + } +} 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 deleted file mode 100644 index f301527dcf..0000000000 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ErrorType.java +++ /dev/null @@ -1 +0,0 @@ -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. *

*

 * <simpleType name="errorType">
 *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
 *     <enumeration value="255"/>
 *     <enumeration value="254"/>
 *   </restriction>
 * </simpleType>
 * 
*/ @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 deleted file mode 100644 index d20fd4f897..0000000000 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/FailsafeSummary.java +++ /dev/null @@ -1 +0,0 @@ -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. *

*

 * <complexType>
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="completed" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         <element name="errors" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         <element name="failures" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         <element name="skipped" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         <element name="failureMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *       </sequence>
 *       <attribute name="result" type="{}errorType" />
 *       <attribute name="timeout" use="required" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
*/ @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/JAXB.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java deleted file mode 100644 index 723200c096..0000000000 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/JAXB.java +++ /dev/null @@ -1 +0,0 @@ -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/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 deleted file mode 100644 index 7e1c252c62..0000000000 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/xmlsummary/ObjectFactory.java +++ /dev/null @@ -1 +0,0 @@ -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 index a4487253a7..8d5d32f139 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 @@ -19,13 +19,11 @@ * under the License. */ +import org.apache.maven.plugin.failsafe.util.JAXB; 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; @@ -62,32 +60,6 @@ public void shouldUnmarshallExistingXmlFile() throws Exception + "\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 @@ -107,25 +79,29 @@ public void shouldMarshallAndUnmarshallSameXml() throws Exception ); 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(); + JAXB.marshal( expected, UTF_8, xml ); FailsafeSummary actual = JAXB.unmarshal( xml, FailsafeSummary.class ); - assertThat( actual ) - .isEqualTo( expected ); + assertThat( actual.getFailures() ) + .isEqualTo( expected.getFailures() ); - List exceptionMessages = actual.extractExceptionMessageLines(); + assertThat( actual.isTimeout() ) + .isEqualTo( expected.isTimeout() ); - assertThat( exceptionMessages ) - .hasSize( 1 ); + assertThat( actual.getCompleted() ) + .isEqualTo( expected.getCompleted() ); - assertThat( exceptionMessages.get( 0 ) ) - .isEqualTo( "There was an error in the forked processtest " - + "subsystem#no method RuntimeException Hi There!" - ); + assertThat( actual.getErrors() ) + .isEqualTo( expected.getErrors() ); + + assertThat( actual.getFailures() ) + .isEqualTo( expected.getFailures() ); + + assertThat( actual.getSkipped() ) + .isEqualTo( expected.getSkipped() ); + + assertThat( actual.getFailureMessage() ) + .isEqualTo( expected.getFailureMessage() ); } } 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 811c53892c..f7b62b64ac 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 @@ -19,7 +19,7 @@ * under the License. */ -import org.apache.maven.plugin.failsafe.xmlsummary.FailsafeSummaryXmlUtils; +import org.apache.maven.plugin.failsafe.util.FailsafeSummaryXmlUtils; import org.apache.maven.surefire.suite.RunResult; import org.junit.Test; diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index f4bab594cf..4064bc2c8e 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -123,7 +123,6 @@ org.codehaus.mojo build-helper-maven-plugin - 1.12 add-source 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 f2c32d01cb..551d9800af 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 @@ -135,7 +135,7 @@ public abstract class AbstractSurefireMojo protected boolean skipTests; /** - * This old parameter is just like skipTests, but bound to the old property "maven.test.skip.exec". + * This old parameter is just like {@code skipTests}, but bound to the old property "maven.test.skip.exec". * * @since 2.3 * @deprecated Use skipTests instead. @@ -147,7 +147,7 @@ public abstract class AbstractSurefireMojo /** * Set this to "true" to bypass unit tests entirely. Its use is NOT RECOMMENDED, especially if you enable it using * the "maven.test.skip" property, because maven.test.skip disables both running the tests and compiling the tests. - * Consider using the skipTests parameter instead. + * Consider using the {@code skipTests} parameter instead. */ @Parameter( property = "maven.test.skip", defaultValue = "false" ) protected boolean skip; @@ -184,7 +184,7 @@ public abstract class AbstractSurefireMojo /** * A dependency scope to exclude from the test classpath. The scope should be one of the scopes defined by * org.apache.maven.artifact.Artifact. This includes the following: - *

+ *
*

    *
  • compile - system, provided, compile *
  • runtime - compile, runtime @@ -215,23 +215,28 @@ public abstract class AbstractSurefireMojo private File testSourceDirectory; /** - * A list of <exclude> elements specifying the tests (by pattern) that should be excluded in testing. When not - * specified and when the test parameter is not specified, the default excludes will be
    - * <excludes>
    - *  <exclude>**/*$*</exclude>
    - * </excludes>
    - *
    (which excludes all inner classes).
    - * This parameter is ignored if the TestNG suiteXmlFiles parameter is specified. - *

    - * Each exclude item may also contain a comma-separated sublist of items, which will be treated as multiple - *  <exclude> entries.
    - * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
    - * %regex[pkg.*Slow.*.class], Unstable*
    - *
    - * Notice that these values are relative to the directory containing generated test classes of the project - * being tested. This directory is declared by the parameter testClassesDirectory which defaults - * to the POM property ${project.build.testOutputDirectory}, typically src/test/java - * unless overridden. + * A list of <exclude> elements specifying the tests (by pattern) that should be excluded in testing. When not + * specified and when the {@code test} parameter is not specified, the default excludes will be
    + *

    
    +     * {@literal }
    +     *     {@literal }**{@literal /}*$*{@literal }
    +     * {@literal }
    +     * 
    + * (which excludes all inner classes). + *
    + * This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified. + *
    + * Each exclude item may also contain a comma-separated sub-list of items, which will be treated as multiple + *  <exclude> entries.
    + * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): + *
    
    +     * {@literal }%regex[pkg.*Slow.*.class], Unstable*{@literal }
    +     * 
    + *
    + * Notice that these values are relative to the directory containing generated test classes of the project + * being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults + * to the POM property ${project.build.testOutputDirectory}, typically + * {@literal src/test/java} unless overridden. */ @Parameter // TODO use regex for fully qualified class names in 3.0 and change the filtering abilities @@ -319,13 +324,14 @@ public abstract class AbstractSurefireMojo private Boolean failIfNoTests; /** - * DEPRECATED since version 2.14. Use forkCount and reuseForks instead. - *
    - *
    - * Option to specify the forking mode. Can be "never", "once", "always", "perthread". "none" and "pertest" are also - * accepted for backwards compatibility. "always" forks for each test-class. "perthread" will create - * threadCount parallel forks, each executing one test-class. See also parameter - * reuseForks.
    + * DEPRECATED since version 2.14. Use {@code forkCount} and {@code reuseForks} instead. + *
    + *
    + * Option to specify the forking mode. Can be {@code never}, {@code once}, {@code always}, {@code perthread}.
    + * The {@code none} and {@code pertest} are also accepted for backwards compatibility.
    + * The {@code always} forks for each test-class.
    + * The {@code perthread} creates the number of parallel forks specified by {@code threadCount}, where each forked + * JVM is executing one test-class. See also the parameter {@code reuseForks} for the lifetime of JVM. * * @since 2.1 */ @@ -353,15 +359,15 @@ public abstract class AbstractSurefireMojo /** * Arbitrary JVM options to set on the command line. - *
    - *
    - * Since the Version 2.17 using an alternate syntax for argLine,
    @{...}
    allows late replacement + *
    + *
    + * Since the Version 2.17 using an alternate syntax for {@code 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:
    + * See the Frequently Asked Questions page with more details:
    * * http://maven.apache.org/surefire/maven-surefire-plugin/faq.html - *
    + *
    * * http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html * @@ -388,7 +394,7 @@ public abstract class AbstractSurefireMojo /** * When false it makes tests run using the standard classloader delegation instead of the default Maven isolated - * classloader. Only used when forking (forkMode is not "none").
    + * classloader. Only used when forking ({@code forkMode} is not {@code none}).
    * Setting it to false helps with some problems caused by conflicts between xml parsers in the classpath and the * Java 5 provider parser. * @@ -399,12 +405,12 @@ public abstract class AbstractSurefireMojo /** * (TestNG/JUnit47 provider with JUnit4.8+ only) Groups for this test. Only classes/methods/etc decorated with one - * of the groups specified here will be included in test run, if specified.
    - * For JUnit, this parameter forces the use of the 4.7 provider
    - * This parameter is ignored if the suiteXmlFiles parameter is specified.
    - * Since version 2.18.1 and JUnit 4.12, the @Category annotation type is automatically inherited from - * superclasses, see @java.lang.annotation.Inherited. Make sure that test class inheritance still makes - * sense together with @Category annotation of the JUnit 4.12 or higher appeared in superclass. + * of the groups specified here will be included in test run, if specified.
    + * For JUnit, this parameter forces the use of the 4.7 provider
    + * This parameter is ignored if the {@code suiteXmlFiles} parameter is specified.
    + * Since version 2.18.1 and JUnit 4.12, the {@code @Category} annotation type is automatically inherited from + * superclasses, see {@code @java.lang.annotation.Inherited}. Make sure that test class inheritance still makes + * sense together with {@code @Category} annotation of the JUnit 4.12 or higher appeared in superclass. * * @since 2.2 */ @@ -413,12 +419,12 @@ public abstract class AbstractSurefireMojo /** * (TestNG/JUnit47 provider with JUnit4.8+ only) Excluded groups. Any methods/classes/etc with one of the groups - * specified in this list will specifically not be run.
    - * For JUnit, this parameter forces the use of the 4.7 provider
    - * This parameter is ignored if the suiteXmlFiles parameter is specified.
    - * Since version 2.18.1 and JUnit 4.12, the @Category annotation type is automatically inherited from - * superclasses, see @java.lang.annotation.Inherited. Make sure that test class inheritance still makes - * sense together with @Category annotation of the JUnit 4.12 or higher appeared in superclass. + * specified in this list will specifically not be run.
    + * For JUnit, this parameter forces the use of the 4.7 provider.
    + * This parameter is ignored if the {@code suiteXmlFiles} parameter is specified.
    + * Since version 2.18.1 and JUnit 4.12, the {@code @Category} annotation type is automatically inherited from + * superclasses, see {@code @java.lang.annotation.Inherited}. Make sure that test class inheritance still makes + * sense together with {@code @Category} annotation of the JUnit 4.12 or higher appeared in superclass. * * @since 2.2 */ @@ -426,7 +432,7 @@ public abstract class AbstractSurefireMojo private String excludedGroups; /** - * Allows you to specify the name of the JUnit artifact. If not set, junit:junit will be used. + * Allows you to specify the name of the JUnit artifact. If not set, {@code junit:junit} will be used. * * @since 2.3.1 */ @@ -434,7 +440,7 @@ public abstract class AbstractSurefireMojo private String junitArtifactName; /** - * Allows you to specify the name of the TestNG artifact. If not set, org.testng:testng will be used. + * Allows you to specify the name of the TestNG artifact. If not set, {@code org.testng:testng} will be used. * * @since 2.3.1 */ @@ -443,7 +449,7 @@ public abstract class AbstractSurefireMojo /** * (TestNG/JUnit 4.7 provider) The attribute thread-count allows you to specify how many threads should be - * allocated for this execution. Only makes sense to use in conjunction with the parallel parameter. + * allocated for this execution. Only makes sense to use in conjunction with the {@code parallel} parameter. * * @since 2.2 */ @@ -453,14 +459,14 @@ public abstract class AbstractSurefireMojo /** * Option to specify the number of VMs to fork in parallel in order to execute the tests. When terminated with "C", * the number part is multiplied with the number of CPU cores. Floating point value are only accepted together with - * "C". If set to "0", no VM is forked and all tests are executed within the main process.
    - *
    - * Example values: "1.5C", "4"
    - *
    - * The system properties and the argLine of the forked processes may contain the place holder string + * "C". If set to "0", no VM is forked and all tests are executed within the main process.
    + *
    + * Example values: "1.5C", "4"
    + *
    + * The system properties and the {@code argLine} of the forked processes may contain the place holder string * ${surefire.forkNumber}, which is replaced with a fixed number for each of the parallel forks, - * ranging from 1 to the effective value of forkCount times the maximum number of parallel - * Surefire executions in maven parallel builds, i.e. the effective value of the -T command line + * ranging from 1 to the effective value of {@code forkCount} times the maximum number of parallel + * Surefire executions in maven parallel builds, i.e. the effective value of the -T command line * argument of maven core. * * @since 2.14 @@ -470,7 +476,7 @@ public abstract class AbstractSurefireMojo /** * Indicates if forked VMs can be reused. If set to "false", a new VM is forked for each test class to be executed. - * If set to "true", up to forkCount VMs will be forked and then reused to execute all tests. + * If set to "true", up to {@code forkCount} VMs will be forked and then reused to execute all tests. * * @since 2.13 */ @@ -488,9 +494,9 @@ public abstract class AbstractSurefireMojo private boolean perCoreThreadCount; /** - * (JUnit 4.7 provider) Indicates that the thread pool will be unlimited. The parallel parameter and + * (JUnit 4.7 provider) Indicates that the thread pool will be unlimited. The {@code parallel} parameter and * the actual number of classes/methods will decide. Setting this to "true" effectively disables - * perCoreThreadCount and threadCount. Defaults to "false". + * {@code perCoreThreadCount} and {@code threadCount}. Defaults to "false". * * @since 2.5 */ @@ -498,18 +504,21 @@ public abstract class AbstractSurefireMojo private boolean useUnlimitedThreads; /** - * (TestNG provider) When you use the parallel attribute, TestNG will try to run all your test methods + * (TestNG provider) When you use the parameter {@code parallel}, TestNG will try to run all your test methods * in separate threads, except for methods that depend on each other, which will be run in the same thread in order * to respect their order of execution. - *

    - * (JUnit 4.7 provider) Supports values "classes"/"methods"/"both" to run in separate threads, as controlled by - * threadCount.
    - *
    - * Since version 2.16 (JUnit 4.7 provider), the value "both" is DEPRECATED. - * Use "classesAndMethods" instead.
    - *
    - * Since version 2.16 (JUnit 4.7 provider), additional vales are available - * "suites"/"suitesAndClasses"/"suitesAndMethods"/"classesAndMethods"/"all". + *
    + * (JUnit 4.7 provider) Supports values {@code classes}, {@code methods}, {@code both} to run + * in separate threads been controlled by {@code threadCount}. + *
    + *
    + * Since version 2.16 (JUnit 4.7 provider), the value {@code both} is DEPRECATED. + * Use {@code classesAndMethods} instead. + *
    + *
    + * Since version 2.16 (JUnit 4.7 provider), additional vales are available: + *
    + * {@code suites}, {@code suitesAndClasses}, {@code suitesAndMethods}, {@code classesAndMethods}, {@code all}. * * @since 2.2 */ @@ -519,7 +528,7 @@ public abstract class AbstractSurefireMojo /** * (JUnit 4.7 / provider only) The thread counts do not exceed the number of parallel suite, class runners and * average number of methods per class if set to true. - *

    + *
    * True by default. * * @since 2.17 @@ -530,16 +539,16 @@ public abstract class AbstractSurefireMojo /** * (JUnit 4.7 provider) This attribute allows you to specify the concurrency in test suites, i.e.: *

      - *
    • number of concurrent suites if threadCount is 0 or unspecified
    • - *
    • limited suites concurrency if useUnlimitedThreads is set to true
    • - *
    • if threadCount and certain thread-count parameters are > 0 for parallel, the - * concurrency is computed from ratio. For instance parallel=all and the ratio between - * threadCountSuites:threadCountClasses:threadCountMethods is - * 2:3:5, there is 20% of threadCount in concurrent suites.
    • + *
    • number of concurrent suites if {@code threadCount} is 0 or unspecified
    • + *
    • limited suites concurrency if {@code useUnlimitedThreads} is set to true
    • + *
    • if {@code threadCount} and certain thread-count parameters are > 0 for {@code parallel}, the + * concurrency is computed from ratio. For instance {@code parallel=all} and the ratio between + * {@code threadCountSuites}:{@code threadCountClasses}:{@code threadCountMethods} is + * 2:3:5, there is 20% of {@code threadCount} which appeared in concurrent suites.
    • *
    * - * Only makes sense to use in conjunction with the parallel parameter. - * The default value 0 behaves same as unspecified one. + * Only makes sense to use in conjunction with the {@code parallel} parameter. + * The default value 0 behaves same as unspecified one. * * @since 2.16 */ @@ -549,20 +558,20 @@ public abstract class AbstractSurefireMojo /** * (JUnit 4.7 provider) This attribute allows you to specify the concurrency in test classes, i.e.: *
      - *
    • number of concurrent classes if threadCount is 0 or unspecified
    • - *
    • limited classes concurrency if useUnlimitedThreads is set to true
    • - *
    • if threadCount and certain thread-count parameters are > 0 for parallel, the - * concurrency is computed from ratio. For instance parallel=all and the ratio between - * threadCountSuites:threadCountClasses:threadCountMethods is - * 2:3:5, there is 30% of threadCount in concurrent classes.
    • - *
    • as in the previous case but without this leaf thread-count. Example: parallel=suitesAndClasses, - * threadCount=16, threadCountSuites=5, threadCountClasses is unspecified leaf, the number of concurrent classes - * is varying from >= 11 to 14 or 15. The threadCountSuites become number of threads. - *
    • + *
    • number of concurrent classes if {@code threadCount} is 0 or unspecified
    • + *
    • limited classes concurrency if {@code useUnlimitedThreads} is set to true
    • + *
    • if {@code threadCount} and certain thread-count parameters are > 0 for {@code parallel}, the + * concurrency is computed from ratio. For instance {@code parallel=all} and the ratio between + * {@code threadCountSuites}:{@code threadCountClasses}:{@code threadCountMethods} is + * 2:3:5, there is 30% of {@code threadCount} in concurrent classes.
    • + *
    • as in the previous case but without this leaf thread-count. Example: {@code parallel=suitesAndClasses}, + * {@code threadCount=16}, {@code threadCountSuites=5}, {@code threadCountClasses} is unspecified leaf, the number + * of concurrent classes is varying from >= 11 to 14 or 15. The {@code threadCountSuites} become + * given number of threads.
    • *
    * - * Only makes sense to use in conjunction with the parallel parameter. - * The default value 0 behaves same as unspecified one. + * Only makes sense to use in conjunction with the {@code parallel} parameter. + * The default value 0 behaves same as unspecified one. * * @since 2.16 */ @@ -572,18 +581,18 @@ public abstract class AbstractSurefireMojo /** * (JUnit 4.7 provider) This attribute allows you to specify the concurrency in test methods, i.e.: *
      - *
    • number of concurrent methods if threadCount is 0 or unspecified
    • - *
    • limited concurrency of methods if useUnlimitedThreads is set to true
    • - *
    • if threadCount and certain thread-count parameters are > 0 for parallel, the + *
    • number of concurrent methods if {@code threadCount} is 0 or unspecified
    • + *
    • limited concurrency of methods if {@code useUnlimitedThreads} is set to true
    • + *
    • if {@code threadCount} and certain thread-count parameters are > 0 for {@code parallel}, the * concurrency is computed from ratio. For instance parallel=all and the ratio between - * threadCountSuites:threadCountClasses:threadCountMethods is 2:3:5, - * there is 50% of threadCount in concurrent methods.
    • - *
    • as in the previous case but without this leaf thread-count. Example: parallel=all, threadCount=16, - * threadCountSuites=2, threadCountClasses=3, but threadCountMethods is unspecified leaf, the number of concurrent - * methods is varying from >= 11 to 14 or 15. The threadCountSuites and threadCountClasses become number of - * threads.
    • + * {@code threadCountSuites}:{@code threadCountClasses}:{@code threadCountMethods} is 2:3:5, + * there is 50% of {@code threadCount} which appears in concurrent methods. + *
    • as in the previous case but without this leaf thread-count. Example: {@code parallel=all}, + * {@code threadCount=16}, {@code threadCountSuites=2}, {@code threadCountClasses=3}, but {@code threadCountMethods} + * is unspecified leaf, the number of concurrent methods is varying from >= 11 to 14 or 15. + * The {@code threadCountSuites} and {@code threadCountClasses} become given number of threads.
    • *
    - * Only makes sense to use in conjunction with the parallel parameter. The default value 0 + * Only makes sense to use in conjunction with the {@code parallel} parameter. The default value 0 * behaves same as unspecified one. * * @since 2.16 @@ -723,11 +732,13 @@ public abstract class AbstractSurefireMojo /** * Calls {@link #getSuiteXmlFiles()} as {@link List list}. * Never returns null. + * + * @return list of TestNG suite XML files provided by MOJO */ protected abstract List suiteXmlFiles(); /** - * @return true if {@link #getSuiteXmlFiles() suite-xml files array} is not empty. + * @return {@code true} if {@link #getSuiteXmlFiles() suite-xml files array} is not empty. */ protected abstract boolean hasSuiteXmlFiles(); @@ -2838,9 +2849,6 @@ public void setLocalRepository( ArtifactRepository localRepository ) this.localRepository = localRepository; } - /** - * @noinspection deprecation - */ public Properties getSystemProperties() { return systemProperties; diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/InPluginVMSurefireStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/InPluginVMSurefireStarter.java index f0d299e430..b97c1928bb 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/InPluginVMSurefireStarter.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/InPluginVMSurefireStarter.java @@ -35,7 +35,7 @@ /** * Starts the provider in the same VM as the surefire plugin. - *

    + *
    * This part of the booter is always guaranteed to be in the * same vm as the tests will be run in. * 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..d3cca28a9d 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java @@ -41,7 +41,7 @@ /** * All the parameters used to construct reporters - *

    + *
    * * @author Kristian Rosenvold */ @@ -111,6 +111,8 @@ public StartupReportConfiguration( boolean useFile, boolean printSummary, String /** * For testing purposes only. + * + * @return StartupReportConfiguration fo testing purposes */ public static StartupReportConfiguration defaultValue() { @@ -122,6 +124,8 @@ public static StartupReportConfiguration defaultValue() /** * For testing purposes only. + * + * @return StartupReportConfiguration fo testing purposes */ public static StartupReportConfiguration defaultNoXml() { diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java index 96fb09e4dd..240427f180 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java @@ -27,7 +27,6 @@ * This interface contains all the common parameters that have different implementations in Surefire vs IntegrationTest * * @author Stephen Connolly - * @noinspection UnusedDeclaration, UnusedDeclaration */ public interface SurefireExecutionParameters { diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java index 29997878f4..f345b466b6 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java @@ -25,7 +25,6 @@ * The parameters required to report on a surefire execution. * * @author Stephen Connolly - * @noinspection UnusedDeclaration */ public interface SurefireReportParameters { 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 114150d748..0299525570 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 @@ -44,12 +44,12 @@ /** * Knows how to serialize and deserialize the booter configuration. - *

    + *
    * The internal serialization format is through a properties file. The long-term goal of this * class is not to expose this implementation information to its clients. This still leaks somewhat, * and there are some cases where properties are being accessed as "Properties" instead of * more representative domain objects. - *

    + *
    * * @author Jason van Zyl * @author Emmanuel Venisse 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 c56453a4f2..8ff676886e 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 @@ -129,6 +129,7 @@ else if ( forkMode.equals( FORK_NEVER ) || forkMode.equals( FORK_ONCE ) * @param classPath cla the classpath arguments * @param startupConfiguration The startup configuration * @param threadNumber the thread number, to be the replacement in the argLine @return A commandline + * @return CommandLine able to flush entire command going to be sent to forked JVM * @throws org.apache.maven.surefire.booter.SurefireBooterForkException * when unable to perform the fork */ @@ -255,7 +256,7 @@ private String replacePropertyExpressions( String argLine ) * Create a jar with just a manifest containing a Main-Class entry for BooterConfiguration and a Class-Path entry * for all classpath elements. * - * @param classPath List<String> of all classpath elements. + * @param classPath List<String> of all classpath elements. * @param startClassName The classname to start (main-class) * @return The file pointint to the jar * @throws java.io.IOException When a file operation fails. 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 c46cfb6767..7619d0b637 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 @@ -101,9 +101,9 @@ /** * Starts the fork or runs in-process. - *

    + *
    * Lives only on the plugin-side (not present in remote vms) - *

    + *
    * Knows how to fork new vms and also how to delegate non-forking invocation to SurefireStarter directly * * @author Jason van Zyl diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ProviderDetector.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ProviderDetector.java index 3b93eff58e..3460e3ec50 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ProviderDetector.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ProviderDetector.java @@ -28,7 +28,6 @@ /** * @author Stephen Conolly * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ public final class ProviderDetector { diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java index 3531ccfcee..0bc2036b12 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java @@ -42,6 +42,7 @@ public abstract class AbstractCommandStream /** * Opposite to {@link #isClosed()}. + * @return {@code true} if not closed */ protected boolean canContinue() { @@ -51,6 +52,8 @@ protected boolean canContinue() /** * Possibly waiting for next command (see {@link #nextCommand()}) unless the stream is atomically * closed (see {@link #isClosed()} returns {@code true}) before this method has returned. + * + * @throws IOException stream error while waiting for notification regarding next test required by forked jvm */ protected void beforeNextCommand() throws IOException @@ -68,6 +71,7 @@ protected final void invalidateInternalBuffer() currentPos = 0; } + @Deprecated protected final MasterProcessCommand getLastCommand() { return lastCommand; 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 35cb2d428a..bc26ab254a 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 @@ -36,13 +36,13 @@ /** * An {@link java.io.InputStream} that, when read, provides test class names out of a queue. - *

    + *
    * The Stream provides only one test at a time, but only after {@link #provideNewTest()} has been invoked. - *

    + *
    * After providing each test class name, followed by a newline character, a flush is performed on the * {@link FlushReceiver} provided by the {@link FlushReceiverProvider} that can be set using * {@link #setFlushReceiverProvider(FlushReceiverProvider)}. - *

    + *
    * The instance is used only in reusable forks in {@link org.apache.maven.plugin.surefire.booterclient.ForkStarter} * by one Thread. * 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 b5a53b4c47..d7a01b6f49 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 @@ -25,7 +25,7 @@ /** * Represents a deserialize stacktracewriter that has been * marshalled across to the plugin from the fork. - *

    + *
    * Might be better to represent this whole thing differently * * @author Kristian Rosenvold 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 b02ae540a6..b94fba6a89 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 @@ -90,7 +90,7 @@ public class ForkClient private final Queue testsInProgress = new ConcurrentLinkedQueue(); /** - * testSetStartedAt is set to non-zero after received + * {@code testSetStartedAt} is set to non-zero after received * {@link org.apache.maven.surefire.booter.ForkingRunListener#BOOTERCODE_TESTSET_STARTING test-set}. */ private final AtomicLong testSetStartedAt = new AtomicLong( START_TIME_ZERO ); @@ -131,6 +131,10 @@ public void kill() /** * Called in concurrent Thread. + * Will shutdown if timeout was reached. + * + * @param currentTimeMillis current time in millis seconds + * @param forkedProcessTimeoutInSeconds timeout in seconds given by MOJO */ public final void tryToTimeout( long currentTimeMillis, int forkedProcessTimeoutInSeconds ) { 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 972eaa7465..093c191a5d 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 @@ -63,12 +63,12 @@ final class Pumper } /** - * Calls {@link ForkClient#consumeLine(String)} which may throw any {@link RuntimeException}.

    + * 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 + * {@link java.io.IOException} and then {@code 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. @@ -159,7 +159,7 @@ public void close() * Compared item with {@link #END_ITEM} by identity. * * @param item element from items - * @return true if tail of the queue + * @return {@code true} if tail of the queue */ private boolean shouldStopQueueing( String item ) { 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 35ee965048..84cbabe055 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 @@ -31,7 +31,7 @@ /** * Surefire output consumer proxy that writes test output to a {@link java.io.File} for each test suite. - *

    + *
    * This class is not threadsafe, but can be serially handed off from thread to thread. * * @author Kristian Rosenvold 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 3b8d765681..bbc9591cbe 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 @@ -56,7 +56,7 @@ /** * Provides reporting modules on the plugin side. - *

    + *
    * Keeps a centralized count of test run results. * * @author Kristian Rosenvold @@ -209,6 +209,8 @@ public RunStatistics getGlobalRunStatistics() /** * For testing purposes only. + * + * @return DefaultReporterFactory for testing purposes */ public static DefaultReporterFactory defaultNoXml() { 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 ab33cb8506..acc19bac91 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 @@ -30,7 +30,7 @@ /** * Outputs test system out/system err directly to the console - *

    + *
    * Just a step on the road to getting the separation of reporting concerns * operating properly. * 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 d10151aaa4..aa858f26cb 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 @@ -47,13 +47,14 @@ import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8; import static org.apache.maven.surefire.util.internal.StringUtils.isBlank; +@SuppressWarnings( { "javadoc", "checkstyle:javadoctype" } ) // CHECKSTYLE_OFF: LineLength /** * XML format reporter writing to TEST-reportName[-suffix].xml file like written and read * by Ant's <junit> and * <junitreport> tasks, * then supported by many tools like CI servers. - *

    + *
    *

    <?xml version="1.0" encoding="UTF-8"?>
      * <testsuite name="suite name" [group="group"] tests="0" failures="0" errors="0" skipped="0" time="0,###.###">
      *  <properties>
    @@ -453,7 +454,7 @@ private static void addOutputStreamElement( OutputStreamWriter outputStreamWrite
     
         /**
          * Adds system properties to the XML report.
    -     * 

    + *
    * * @param xmlWriter The test suite to report to */ 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 472586b9ae..eea8a7e33b 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 @@ -37,7 +37,7 @@ /** * Reports data for a single test set. - *

    + *
    * * @author Kristian Rosenvold */ 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 db8127eae2..740798de3d 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 @@ -26,8 +26,8 @@ public interface IDefault { /** - * @return true if SPI implementation vendor is maven-surefire-plugin or maven-failsafe-plugin. - * false if customized by users. + * @return {@code true} if SPI implementation vendor is maven-surefire-plugin or maven-failsafe-plugin. + * {@code false} if customized by users. */ boolean isDefault(); } 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 4a404dfebb..c93d2c9a19 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 @@ -37,7 +37,6 @@ * Run tests using Surefire. * * @author Jason van Zyl - * @noinspection JavaDoc */ @Mojo( name = "test", defaultPhase = LifecyclePhase.TEST, threadSafe = true, requiresDependencyResolution = ResolutionScope.TEST ) @@ -66,25 +65,28 @@ public class SurefirePlugin @Parameter( defaultValue = "${project.build.directory}/surefire-reports" ) private File reportsDirectory; + @SuppressWarnings( "checkstyle:linelength" ) /** - * Specify this parameter to run individual tests by file name, overriding the includes/excludes - * parameters. Each pattern you specify here will be used to create an include pattern formatted like - * **/${test}.java, so you can just type "-Dtest=MyTest" to run a single test called - * "foo/MyTest.java". The test patterns prefixed with a ! will be excluded.
    - * This parameter overrides the includes/excludes parameters, and the TestNG suiteXmlFiles - * parameter. - *

    - * Since 2.7.3, you can execute a limited number of methods in the test by adding #myMethod or #my*ethod. For - * example, "-Dtest=MyTest#myMethod". This is supported for junit 4.x and testNg.
    - *
    - * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
    - * "-Dtest=???Test, !Unstable*, pkg/**/Ci*leTest.java, *Test#test*One+testTwo?????, #fast*+slowTest"
    - * "-Dtest=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyTest.class#one.*|two.*], %regex[#fast.*|slow.*]"
    - *
    - * The Parameterized JUnit runner describes test methods using an index in brackets, so the non-regex - * method pattern would become: #testMethod[*]. If using @Parameters(name="{index}: fib({0})={1}") - * and selecting the index e.g. 5 in pattern, the non-regex method pattern would become #testMethod[5:*]. - *
    + * Specify this parameter to run individual tests by file name, overriding the parameter {@code includes} and + * {@code excludes}. Each pattern you specify here will be used to create an include pattern formatted like + * **{@literal /}${test}.java, so you can just type {@code -Dtest=MyTest} to run a single test called + * "foo/MyTest.java". The test patterns prefixed with a ! will be excluded. + *
    + * This parameter overrides the parameter {@code includes}, {@code excludes}, and the TestNG parameter + * {@code suiteXmlFiles}. + *
    + * Since 2.7.3, you can execute a limited number of methods in the test by adding #myMethod or + * #my*ethod. For example, {@code -Dtest=MyTest#myMethod}. This is supported for junit 4.x and TestNg.
    + *
    + * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): + *

    "-Dtest=???Test, !Unstable*, pkg{@literal /}**{@literal /}Ci*leTest.java, *Test#test*One+testTwo?????, #fast*+slowTest"
    + * or e.g. + *
    "-Dtest=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyTest.class#one.*|two.*], %regex[#fast.*|slow.*]"
    + *
    + * The Parameterized JUnit runner {@code describes} test methods using an index in brackets, so the non-regex + * method pattern would become: {@code #testMethod[*]}. + * If using @Parameters(name="{index}: fib({0})={1}") and selecting the index e.g. 5 in pattern, the + * non-regex method pattern would become {@code #testMethod[5:*]}. */ @Parameter( property = "test" ) private String test; @@ -120,7 +122,7 @@ public class SurefirePlugin /** * Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach * on port 5005. If set to some other string, that string will be appended to the argLine, allowing you to configure - * arbitrary debuggability options (without overwriting the other options specified through the argLine + * arbitrary debuggability options (without overwriting the other options specified through the {@code argLine} * parameter). * * @since 2.4 @@ -140,7 +142,7 @@ public class SurefirePlugin /** * Forked process is normally terminated without any significant delay after given tests have completed. * If the particular tests started non-daemon Thread(s), the process hangs instead of been properly terminated - * by System.exit(). Use this parameter in order to determine the timeout of terminating the process. + * by {@code System.exit()}. Use this parameter in order to determine the timeout of terminating the process. * see the documentation: * http://maven.apache.org/surefire/maven-surefire-plugin/examples/shutdown.html * Turns to default fallback value of 30 seconds if negative integer. @@ -152,11 +154,11 @@ public class SurefirePlugin /** * Stop executing queued parallel JUnit tests after a certain number of seconds. - *
    - * Example values: "3.5", "4"
    - *
    + *
    + * Example values: "3.5", "4"
    + *
    * If set to 0, wait forever, never timing out. - * Makes sense with specified parallel different from "none". + * Makes sense with specified {@code parallel} different from "none". * * @since 2.16 */ @@ -165,41 +167,45 @@ public class SurefirePlugin /** * Stop executing queued parallel JUnit tests - * and interrupt currently running tests after a certain number of seconds. - *
    - * Example values: "3.5", "4"
    - *
    + * and {@code interrupt} currently running tests after a certain number of seconds. + *
    + * Example values: "3.5", "4"
    + *
    * If set to 0, wait forever, never timing out. - * Makes sense with specified parallel different from "none". + * Makes sense with specified {@code parallel} different from "none". * * @since 2.16 */ @Parameter( property = "surefire.parallel.forcedTimeout" ) private double parallelTestsTimeoutForcedInSeconds; + @SuppressWarnings( "checkstyle:linelength" ) /** - * A list of <include> elements specifying the tests (by pattern) that should be included in testing. When not - * specified and when the test parameter is not specified, the default includes will be
    - * <includes>
    - *  <include>**/Test*.java</include>
    - *  <include>**/*Test.java</include>
    - *  <include>**/*Tests.java</include>
    - *  <include>**/*TestCase.java</include>
    - * </includes>
    - *
    - *

    - * Each include item may also contain a comma-separated sublist of items, which will be treated as multiple - *  <include> entries.
    - * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
    - *  <include>%regex[.*[Cat|Dog].*], Basic????, !Unstable*</include>
    - *  <include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg/**/*Fast*.java</include>
    - *

    - * This parameter is ignored if the TestNG suiteXmlFiles parameter is specified.
    - *
    - * Notice that these values are relative to the directory containing generated test classes of the project - * being tested. This directory is declared by the parameter testClassesDirectory which defaults - * to the POM property ${project.build.testOutputDirectory}, typically src/test/java - * unless overridden. + * A list of <include> elements specifying the tests (by pattern) that should be included in testing. When not + * specified and when the {@code test} parameter is not specified, the default includes will be + *

    
    +     * {@literal }
    +     *     {@literal }**{@literal /}Test*.java{@literal }
    +     *     {@literal }**{@literal /}*Test.java{@literal }
    +     *     {@literal }**{@literal /}*Tests.java{@literal }
    +     *     {@literal }**{@literal /}*TestCase.java{@literal }
    +     * {@literal }
    +     * 
    + * Each include item may also contain a comma-separated sub-list of items, which will be treated as multiple + *  <include> entries.
    + * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): + *
    
    +     *
    +     * 
    + * {@literal }%regex[.*[Cat|Dog].*], Basic????, !Unstable*{@literal } + * {@literal }%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg{@literal /}**{@literal /}*Fast*.java{@literal } + *
    + * This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified.
    + *
    + * Notice that these values are relative to the directory containing generated test classes of the project + * being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults + * to the POM property {@code ${project.build.testOutputDirectory}}, typically + * {@literal src/test/java} unless overridden. */ @Parameter private List includes; @@ -207,7 +213,7 @@ public class SurefirePlugin /** * Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking. * Prevents problems with JDKs which implement the service provider lookup mechanism by using the system's - * classloader. + * ClassLoader. * * @since 2.3 */ @@ -220,7 +226,7 @@ public class SurefirePlugin * * http://maven.apache.org/plugins/maven-surefire-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. * * @since 2.4.3 @@ -238,10 +244,10 @@ public class SurefirePlugin private int rerunFailingTestsCount; /** - * (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that - * suiteXmlFiles is incompatible with several other parameters of this plugin, like - * includes/excludes.
    - * This parameter is ignored if the test parameter is specified (allowing you to run a single test + * (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that + * {@code suiteXmlFiles} is incompatible with several other parameters of this plugin, like + * {@code includes} and {@code excludes}.
    + * This parameter is ignored if the {@code test} parameter is specified (allowing you to run a single test * instead of an entire suite). * * @since 2.2 @@ -250,26 +256,26 @@ public class SurefirePlugin private File[] suiteXmlFiles; /** - * Defines the order the tests will be run in. Supported values are "alphabetical", "reversealphabetical", "random", - * "hourly" (alphabetical on even hours, reverse alphabetical on odd hours), "failedfirst", "balanced" and - * "filesystem". - *
    - *
    + * Defines the order the tests will be run in. Supported values are {@code alphabetical}, + * {@code reversealphabetical}, {@code random}, {@code hourly} (alphabetical on even hours, reverse alphabetical + * on odd hours), {@code failedfirst}, {@code balanced} and {@code filesystem}. + *
    + *
    * Odd/Even for hourly is determined at the time the of scanning the classpath, meaning it could change during a * multi-module build. - *
    - *
    + *
    + *
    * Failed first will run tests that failed on previous run first, as well as new tests for this run. - *
    - *
    + *
    + *
    * Balanced is only relevant with parallel=classes, and will try to optimize the run-order of the tests reducing the * overall execution time. Initially a statistics file is created and every next test run will reorder classes. - *
    - *
    - * Note that the statistics are stored in a file named .surefire-XXXXXXXXX beside pom.xml, and should not be checked - * into version control. The "XXXXX" is the SHA1 checksum of the entire surefire configuration, so different - * configurations will have different statistics files, meaning if you change any config settings you will re-run - * once before new statistics data can be established. + *
    + *
    + * Note that the statistics are stored in a file named .surefire-XXXXXXXXX beside pom.xml and + * should not be checked into version control. The "XXXXX" is the SHA1 checksum of the entire surefire + * configuration, so different configurations will have different statistics files, meaning if you change any + * configuration settings you will re-run once before new statistics data can be established. * * @since 2.7 */ @@ -278,30 +284,34 @@ public class SurefirePlugin /** * A file containing include patterns. Blank lines, or lines starting with # are ignored. If {@code includes} are - * also specified, these patterns are appended. Example with path, simple and regex includes:
    - * */test/*
    - * **/NotIncludedByDefault.java
    - * %regex[.*Test.*|.*Not.*]
    + * also specified, these patterns are appended. Example with path, simple and regex includes: + *
    
    +     * *{@literal /}test{@literal /}*
    +     * **{@literal /}NotIncludedByDefault.java
    +     * %regex[.*Test.*|.*Not.*]
    +     * 
    */ @Parameter( property = "surefire.includesFile" ) private File includesFile; /** * A file containing exclude patterns. Blank lines, or lines starting with # are ignored. If {@code excludes} are - * also specified, these patterns are appended. Example with path, simple and regex excludes:
    - * */test/*
    - * **/DontRunTest.*
    - * %regex[.*Test.*|.*Not.*]
    + * also specified, these patterns are appended. Example with path, simple and regex excludes:
    + *
    
    +     * *{@literal /}test{@literal /}*
    +     * **{@literal /}DontRunTest.*
    +     * %regex[.*Test.*|.*Not.*]
    +     * 
    */ @Parameter( property = "surefire.excludesFile" ) private File excludesFile; /** * Set to error/failure count in order to skip remaining tests. - * Due to race conditions in parallel/forked execution this may not be fully guaranteed.
    - * Enable with system property -Dsurefire.skipAfterFailureCount=1 or any number greater than zero. - * Defaults to "0".
    - * See the prerequisites and limitations in documentation:
    + * Due to race conditions in parallel/forked execution this may not be fully guaranteed.
    + * Enable with system property {@code -Dsurefire.skipAfterFailureCount=1} or any number greater than zero. + * Defaults to "0".
    + * See the prerequisites and limitations in documentation:
    * * http://maven.apache.org/plugins/maven-surefire-plugin/examples/skip-after-failure.html * @@ -311,12 +321,18 @@ public class SurefirePlugin private int skipAfterFailureCount; /** - * After the plugin process is shutdown by sending SIGTERM signal (CTRL+C), SHUTDOWN command is received by every - * forked JVM. By default (shutdown=testset) forked JVM would not continue with new test which means that - * the current test may still continue to run.
    - * The parameter can be configured with other two values "exit" and "kill".
    - * Using "exit" forked JVM executes System.exit(1) after the plugin process has received SIGTERM signal.
    - * Using "kill" the JVM executes Runtime.halt(1) and kills itself. + * After the plugin process is shutdown by sending SIGTERM signal (CTRL+C), SHUTDOWN command is + * received by every forked JVM. + *
    + * By default ({@code shutdown=testset}) forked JVM would not continue with new test which means that + * the current test may still continue to run. + *
    + * The parameter can be configured with other two values {@code exit} and {@code kill}. + *
    + * Using {@code exit} forked JVM executes {@code System.exit(1)} after the plugin process has received + * SIGTERM signal. + *
    + * Using {@code kill} the JVM executes {@code Runtime.halt(1)} and kills itself. * * @since 2.19 */ @@ -374,18 +390,12 @@ public void setSkipTests( boolean skipTests ) this.skipTests = skipTests; } - /** - * @noinspection deprecation - */ @Override public boolean isSkipExec() { return skipExec; } - /** - * @noinspection deprecation - */ @Override public void setSkipExec( boolean skipExec ) { diff --git a/maven-surefire-plugin/src/site/resources/xsd/bindings.xml b/maven-surefire-plugin/src/site/resources/xsd/bindings.xml deleted file mode 100644 index 4e2d9498f9..0000000000 --- a/maven-surefire-plugin/src/site/resources/xsd/bindings.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb b/maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb new file mode 100644 index 0000000000..1e076d3150 --- /dev/null +++ b/maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml index 9f35967e24..a4fe7e293a 100644 --- a/maven-surefire-report-plugin/pom.xml +++ b/maven-surefire-report-plugin/pom.xml @@ -136,7 +136,6 @@ org.codehaus.mojo build-helper-maven-plugin - 1.12 add-source 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 b7aa290699..c306305ecb 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 @@ -51,7 +51,7 @@ public class FailsafeReportMojo /** * If set to true the failsafe report will be generated even when there are no failsafe result files. - * Defaults to false to preserve legacy behaviour pre 2.10 + * Defaults to {@code false} to preserve legacy behaviour pre 2.10 * * @noinspection UnusedDeclaration * @since 2.11 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 a950bcf91d..e535a24d42 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 @@ -48,7 +48,7 @@ public class SurefireReportMojo /** * If set to true the surefire report will be generated even when there are no surefire result files. - * Defaults to true to preserve legacy behaviour pre 2.10. + * Defaults to {@code true} to preserve legacy behaviour pre 2.10. * * @noinspection UnusedDeclaration * @since 2.11 diff --git a/maven-surefire-report-plugin/src/main/resources/surefire-report_sv.properties b/maven-surefire-report-plugin/src/main/resources/surefire-report_sv.properties index bdf8361c65..3664c6bce5 100644 --- a/maven-surefire-report-plugin/src/main/resources/surefire-report_sv.properties +++ b/maven-surefire-report-plugin/src/main/resources/surefire-report_sv.properties @@ -35,3 +35,5 @@ report.surefire.label.failuredetails=Detaljer om misslyckade tester report.surefire.text.note1=Notera: misslyckade tester \u00e4r f\u00f6rv\u00e4ntade och har kontrollerats med assertions medan felaktiga tester \u00e4r ov\u00e4ntade. report.surefire.text.note2=Notera: paketstatistiken ber\u00e4knas inte rekursivt, den summerar bara alla testsviters antal. +report.failsafe.name=Failsafe-rapport +report.failsafe.description=Rapport om integration testresultaten f\u00f6r projektet. diff --git a/pom.xml b/pom.xml index 60d6376219..962a5bf74f 100644 --- a/pom.xml +++ b/pom.xml @@ -283,9 +283,60 @@ + + org.codehaus.mojo + build-helper-maven-plugin + 1.12 + org.apache.maven.plugins maven-compiler-plugin + 3.6.1 + + + compile-generated + process-sources + + compile + + + + org/apache/maven/shared/utils/logging/*.java + HelpMojo.java + **/HelpMojo.java + org/apache/maven/plugin/failsafe/xmlsummary/*.java + + + + -Xdoclint:none + + + + + default-compile + compile + + compile + + + + org/apache/maven/shared/utils/logging/*.java + HelpMojo.java + **/HelpMojo.java + org/apache/maven/plugin/failsafe/xmlsummary/*.java + + + -Xdoclint:all + + + + + + true + + -Xdoclint:all + + @@ -367,7 +418,7 @@ - [1.6.0, 1.9.0) + [1.8.0,) 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 a24424b82a..ed7d4fadff 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 @@ -135,7 +135,7 @@ public boolean awaitStarted() } /** - * @param listener listener called with Any {@link MasterProcessCommand command type} + * @param listener listener called with Any {@link MasterProcessCommand command type} */ public void addListener( CommandListener listener ) { @@ -225,7 +225,7 @@ private boolean isStopped() } /** - * @return true if {@link #LAST_TEST_SYMBOL} found at the last index in {@link #testClasses}. + * @return {@code true} if {@link #LAST_TEST_SYMBOL} found at the last index in {@link #testClasses}. */ private boolean isQueueFull() { 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 fc92c70834..e287f05f8c 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 @@ -27,7 +27,7 @@ import static org.apache.maven.surefire.util.internal.DumpFileUtils.newDumpFile; /** - * Dumps lost commands and caused exceptions in forked JVM.

    + * Dumps lost commands and caused exceptions in forked JVM.
    * Fail-safe. * * @author Tibor Digana (tibor17) diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/FailFastAware.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/FailFastAware.java index 06e47bad99..994b60d807 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/FailFastAware.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/FailFastAware.java @@ -20,7 +20,7 @@ */ /** - * See the plugin configuration parameter skipAfterFailureCount. + * See the plugin configuration parameter {@code skipAfterFailureCount}. * * @author Tibor Digana (tibor17) * @since 2.19 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 89469fa27c..7459ad9840 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 @@ -31,9 +31,7 @@ * This factory is only used inside forks. * * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ - public class ForkingReporterFactory implements ReporterFactory { 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 f0f0ac6604..d2c112b3d2 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 @@ -40,14 +40,14 @@ /** * Encodes the full output of the test run to the stdout stream. - *

    + *
    * This class and the ForkClient contain the full definition of the * "wire-level" protocol used by the forked process. The protocol * is *not* part of any public api and may change without further * notice. - *

    + *
    * This class is threadsafe. - *

    + *
    * The synchronization in the underlying PrintStream (target instance) * is used to preserve thread safety of the output stream. To perform * multiple writes/prints for a single request, they must diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ShutdownAware.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ShutdownAware.java index a843b27e6b..0bfcdb8f3b 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ShutdownAware.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ShutdownAware.java @@ -20,7 +20,7 @@ */ /** - * See the plugin configuration parameter shutdown. + * See the plugin configuration parameter {@code shutdown}. * * @author Tibor Digana (tibor17) * @since 2.19 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 54677a7c11..4c88179049 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 @@ -58,7 +58,7 @@ /** * Does reflection based invocation of the surefire methods. - *

    + *
    * This is to avoid complications with linkage issues * * @author Kristian Rosenvold diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java b/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java index 2f82814f24..a806370d53 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java @@ -28,7 +28,7 @@ * * @author Tibor Digana (tibor17) * @since 2.19 - * @see http://books.sonatype.com/mvnref-book/reference/running-sect-options.html + * @see command line options */ public enum CommandLineOption { diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java index 9ef7a94bd9..b487f06589 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java @@ -36,10 +36,10 @@ /** * Injected into the providers upon provider construction. Allows the provider to request services and data it needs. - *

    + *
    * NOTE: This class is part of the proposed public api for surefire providers from 2.7 and up. It may * still be subject to changes, even for minor revisions. - *

    + *
    * The api covers this interface and all the types reachable from it. And nothing else. * * @author Kristian Rosenvold @@ -80,7 +80,7 @@ public interface ProviderParameters /** * Gets a logger intended for console output. - *

    + *
    * This output is intended for provider-oriented messages that are not attached to a single test-set * and will normally be written to something console-like immediately. * @@ -136,7 +136,7 @@ public interface ProviderParameters List getMainCliOptions(); /** - * Defaults to 0. Configured with parameter skipAfterFailureCount in POM. + * @return Defaults to 0. Configured with parameter {@code skipAfterFailureCount} in POM. */ int getSkipAfterFailureCount(); diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java index 9b27c1c8ef..9eccf6b310 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java @@ -26,13 +26,13 @@ /** * Interface to be implemented by all Surefire providers. - *

    + *
    * NOTE: This class is part of the proposed public api for surefire providers for 2.7. It may * still be subject to changes, even for minor revisions. - *

    + *
    * The api covers this interface and all the types reachable from it. And nothing else. - *

    - *

    + *
    + *
    * Called in one of three ways: * Forkmode = never: getSuites is not called, invoke is called with null parameter * Forkmode = once: getSuites is not called, invoke is called with null parameter @@ -45,7 +45,7 @@ public interface SurefireProvider { /** * Determines the number of forks. - *

    + *
    * Called when forkmode is different from "never" or "always", allows the provider to define * how to behave for the fork. * @@ -64,6 +64,7 @@ public interface SurefireProvider * When reporting fails * @throws org.apache.maven.surefire.testset.TestSetFailedException * When testset fails + * @throws InvocationTargetException fails in {@code ProviderFactory} */ @SuppressWarnings( "checkstyle:redundantthrows" ) RunResult invoke( Object forkTestSet ) @@ -72,14 +73,14 @@ RunResult invoke( Object forkTestSet ) /** * Makes an attempt at cancelling the current run, giving the provider a chance to notify * reporting that the remaining tests have been cancelled due to timeout. - *

    + *
    * If the provider thinks it can terminate properly it is the responsibility of * the invoke method to return a RunResult with a booter code of failure. - *

    + *
    * It is up to the provider to find out how to implement this method properly. * A provider may also choose to not do anything at all in this method, * which means surefire will kill the forked process soon afterwards anyway. - *

    + *
    * Will be called on a different thread than the one calling invoke. */ // Todo: Need to think a lot closer about how/if this works and if there is a use case for it. 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 28f111b66c..d4af679675 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 @@ -29,7 +29,7 @@ /** * Deals with system.out/err. - *

    + *
    */ public class ConsoleOutputCapture { 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 88552cbcef..dee095c624 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 @@ -29,7 +29,6 @@ * Write the trace out for a POJO test. Java 1.5 compatible. * * @author Brett Porter - * @noinspection ThrowableResultOfMethodCallIgnored */ public class LegacyPojoStackTraceWriter implements StackTraceWriter diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/ReportEntry.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/ReportEntry.java index 2bc3fcd931..ec0f782e09 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/report/ReportEntry.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/ReportEntry.java @@ -55,8 +55,9 @@ public interface ReportEntry /** * Gets the runtime for the item. Optional parameter. If the value is not set, it will be determined within - * the reporting subsustem. Some providers like to calculate this value themselves, and it gets the + * the reporting subsystem. Some providers like to calculate this value themselves, and it gets the * most accurate value. + * @return duration of a test in milli seconds */ Integer getElapsed(); diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java index 52384731c2..d2bfb13d99 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java @@ -24,7 +24,7 @@ /** * Bits and pieces of reporting configuration that seem to be necessary on the provider side. - *

    + *
    * Todo: Consider moving these fields elsewhere, this concept does not smell too good * * @author Kristian Rosenvold diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java index b9644306cf..22cda617df 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java @@ -22,7 +22,7 @@ /** * Used by providers to report results. * Using this interface integrates the providers together into a common reporting infrastructure. - *

    + *
    * An instance of a reporter is not guaranteed to be thread-safe and concurrent test frameworks * must request an instance of a reporter per-thread from the ReporterFactory. */ 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 28a19f9eac..0dd42641ab 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 @@ -161,9 +161,6 @@ public String getMessage() return message; } - /** - * @noinspection RedundantIfStatement - */ @Override public boolean equals( Object o ) { @@ -177,27 +174,7 @@ public boolean equals( Object o ) } SimpleReportEntry that = (SimpleReportEntry) o; - - if ( elapsed != null ? !elapsed.equals( that.elapsed ) : that.elapsed != null ) - { - return false; - } - if ( name != null ? !name.equals( that.name ) : that.name != null ) - { - return false; - } - if ( source != null ? !source.equals( that.source ) : that.source != null ) - { - return false; - } - if ( stackTraceWriter != null - ? !stackTraceWriter.equals( that.stackTraceWriter ) - : that.stackTraceWriter != null ) - { - return false; - } - - return true; + return isElapsedTimeEqual( that ) && isNameEqual( that ) && isSourceEqual( that ) && isStackEqual( that ); } @Override @@ -215,4 +192,24 @@ public String getNameWithGroup() { return getName(); } + + private boolean isElapsedTimeEqual( SimpleReportEntry en ) + { + return elapsed != null ? elapsed.equals( en.elapsed ) : en.elapsed == null; + } + + private boolean isNameEqual( SimpleReportEntry en ) + { + return name != null ? name.equals( en.name ) : en.name == null; + } + + private boolean isSourceEqual( SimpleReportEntry en ) + { + return source != null ? source.equals( en.source ) : en.source == null; + } + + private boolean isStackEqual( SimpleReportEntry en ) + { + return stackTraceWriter != null ? stackTraceWriter.equals( en.stackTraceWriter ) : en.stackTraceWriter == null; + } } 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 aa099c850c..e318e1fb44 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 @@ -24,7 +24,7 @@ /** * Represents a test-run-result; this may be from a single test run or an aggregated result. - *

    + *
    * In the case of timeout==true, the run-counts reflect the state of the test-run at the time * of the timeout. * diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/testset/ResolvedTest.java b/surefire-api/src/main/java/org/apache/maven/surefire/testset/ResolvedTest.java index 8e46ccb5af..56bc279277 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/testset/ResolvedTest.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/testset/ResolvedTest.java @@ -73,12 +73,12 @@ public enum Type /** * '*' means zero or more characters
    * '?' means one and only one character - * The pattern %regex[] prefix and suffix does not appear. The regex pattern is always + * The pattern %regex[] prefix and suffix does not appear. The regex pattern is always * unwrapped by the caller. * * @param classPattern test class file pattern * @param methodPattern test method - * @param isRegex {@code true} if regex + * @param isRegex {@code true} if pattern is regex */ public ResolvedTest( String classPattern, String methodPattern, boolean isRegex ) { @@ -104,7 +104,11 @@ public ResolvedTest( String classPattern, String methodPattern, boolean isRegex } /** - * The regex pattern is always unwrapped. + * The regex {@code pattern} is always unwrapped. + * + * @param type class or method + * @param pattern pattern or regex + * @param isRegex {@code true} if pattern is regex */ public ResolvedTest( Type type, String pattern, boolean isRegex ) { @@ -123,12 +127,14 @@ public ResolvedTest( Type type, String pattern, boolean isRegex ) } /** - * Test class file pattern, e.g. org/**/Cat*.class
    , or null if not any + * Test class file pattern, e.g. org/**/Cat*.class
    , or null if not any * and {@link #hasTestClassPattern()} returns false. - * Other examples: org/animals/Cat*, org/animals/Ca?.class, %regex[Cat.class|Dog.*]
    - *
    + * Other examples: org/animals/Cat*, org/animals/Ca?.class, %regex[Cat.class|Dog.*]
    + *
    * '*' means zero or more characters
    * '?' means one and only one character + * + * @return class pattern or regex */ public String getTestClassPattern() { @@ -141,11 +147,13 @@ public boolean hasTestClassPattern() } /** - * Test method, e.g. "realTestMethod".
    , or null if not any and {@link #hasTestMethodPattern()} returns false. - * Other examples: test* or testSomethin? or %regex[testOne|testTwo] or %ant[testOne|testTwo]
    - *
    + * Test method, e.g. "realTestMethod".
    , or null if not any and {@link #hasTestMethodPattern()} returns false. + * Other examples: test* or testSomethin? or %regex[testOne|testTwo] or %ant[testOne|testTwo]
    + *
    * '*' means zero or more characters
    * '?' means one and only one character + * + * @return method pattern or regex */ public String getTestMethodPattern() { @@ -266,6 +274,9 @@ private boolean canMatchExclusiveAll( String testClassFile, String methodName ) /** * Prevents {@link #match(String, String)} from throwing NPE in situations when inclusive returns true. + * + * @param testClassFile path to class file + * @return {@code true} if examined class in null and class pattern exists */ private boolean alwaysInclusiveQuietly( String testClassFile ) { 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 a7f0e28a6f..359ac942a7 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 @@ -38,9 +38,9 @@ // 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.
    + * composed of included and excluded tests.
    * The methods {@link #shouldRun(String, String)} are filters easily used in JUnit filter or TestNG. - * This class is independent of JUnit and TestNG API.
    + * This class is independent of JUnit and TestNG API.
    * It is accessed by Java Reflection API in {@link org.apache.maven.surefire.booter.SurefireReflector} * using specific ClassLoader. */ @@ -139,7 +139,7 @@ public boolean hasMethodPatterns() * * @param resolver filter possibly having method patterns * @return {@code resolver} if {@link TestListResolver#hasMethodPatterns() resolver.hasMethodPatterns()} - * returns true; Otherwise wildcard filter *.class is returned. + * returns {@code true}; Otherwise wildcard filter {@code *.class} is returned. */ public static TestListResolver optionallyWildcardFilter( TestListResolver resolver ) { @@ -456,7 +456,7 @@ static void nonRegexClassAndMethods( String clazz, String methods, boolean isExc } /** - * Requires trimmed request been not equal to "!". + * Requires trimmed {@code request} been not equal to "!". */ static void resolveTestRequest( String request, IncludedExcludedPatterns patterns, Collection includedFilters, Collection excludedFilters ) diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestRequest.java b/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestRequest.java index a1c931585c..ef8d666824 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestRequest.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestRequest.java @@ -74,6 +74,8 @@ public File getTestSourceDirectory() /** * A specific test request issued with -Dtest= from the command line. + * + * @return filter */ public TestListResolver getTestListResolver() { diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestSetFailedException.java b/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestSetFailedException.java index e0b03aaa03..f6966b0b5e 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestSetFailedException.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestSetFailedException.java @@ -30,11 +30,11 @@ public class TestSetFailedException { /** - * Create a TestFailedException with a detail message. + * Creates {@code TestSetFailedException} with a detail message. * - * @param message A detail message for this TestFailedException, or - * null. If null is passed, the getMessage - * method will return an empty String. + * @param message A detail message for this {@code TestSetFailedException}, or + * {@code null}. If {@code null} is passed, the {@link #getMessage} + * method will return an empty {@link String string}. */ public TestSetFailedException( String message ) { @@ -42,15 +42,15 @@ public TestSetFailedException( String message ) } /** - * Create a TestFailedException with the specified detail + * Creates {@code TestSetFailedException} with the specified detail * message and cause. - *

    + *
    *

    Note that the detail message associated with cause is - * not automatically incorporated in this throwable's detail + * NOT automatically incorporated in this throwable's detail * message. * - * @param message A detail message for this TestFailedException, or null. - * @param cause the cause, which is saved for later retrieval by the getCause method. + * @param message A detail message for this {@code TestSetFailedException}, or {@code null}. + * @param cause the cause, which is saved for later retrieval by the {@link #getCause} method. * (A null value is permitted, and indicates that the cause is nonexistent or unknown.) */ public TestSetFailedException( String message, Throwable cause ) @@ -59,9 +59,8 @@ public TestSetFailedException( String message, Throwable cause ) } /** - * Create a TestFailedException with the specified cause. The - * getMessage method of this exception object will return - * (cause == null ? "" : cause.toString()). + * Creates {@code TestSetFailedException} with the specified cause. The mthod {@link #getMessage} method of this + * exception object will return {@code cause == null ? "" : cause.toString()}. * * @param cause The cause */ diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireReflectionException.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireReflectionException.java index ca5d2beb5f..eb3b04aee2 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireReflectionException.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireReflectionException.java @@ -30,9 +30,8 @@ public class SurefireReflectionException extends RuntimeException { /** - * Create a SurefireReflectionException with the specified cause. The - * getMessage method of this exception object will return - * (cause == null ? "" : cause.toString()). + * Create a {@link SurefireReflectionException} with the specified cause. The method {@link #getMessage} of this + * exception object will return {@code cause == null ? "" : cause.toString()}. * * @param cause The cause of this exception */ 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 4912f8eea0..3610a4b69a 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 @@ -57,6 +57,7 @@ public Thread newThread( Runnable r ) /** * Should be used by thread pools. + * @return new instance of {@link ThreadFactory} where each {@link Thread thread} is daemon */ public static ThreadFactory newDaemonThreadFactory() { 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 cad2e7a46b..302358c23a 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 @@ -48,6 +48,9 @@ private DumpFileUtils() /** * New dump file. Synchronized object appears in main memory and perfectly visible in other threads. + * + * @param dumpFileName dump file name + * @param configuration only report directory */ public static synchronized File newDumpFile( String dumpFileName, ReporterConfiguration configuration ) { 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 bb7c3a7863..8f16513af7 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 @@ -27,12 +27,14 @@ /** *

    - * Common String manipulation routines. + * Common {@link String java.lang.String} manipulation routines. *

    - *

    + *
    *

    * Originally from Turbine and the GenerationJavaCore library. *

    + *
    + * NOTE: This class is not part of any api and is public purely for technical reasons ! * * @author Jon S. Stevens * @author Daniel Rall @@ -46,12 +48,6 @@ * @author Alexander Day Chaffee * @author Vincent Siveton * @version $Id: StringUtils.java 8001 2009-01-03 13:17:09Z vsiveton $ - * @noinspection JavaDoc - *

    - * A quick borrow from plexus-utils by Kristian Rosenvold, to restore jdk1.3 compat Threw away all the - * unused stuff. - *

    - * NOTE: This class is not part of any api and is public purely for technical reasons ! * @since 1.0 */ public final class StringUtils @@ -81,8 +77,7 @@ private StringUtils() public static String[] split( String text, String separator ) { - int max = -1; - StringTokenizer tok; + final StringTokenizer tok; if ( separator == null ) { // Null separator means we're using StringTokenizer's default @@ -94,46 +89,21 @@ public static String[] split( String text, String separator ) tok = new StringTokenizer( text, separator ); } - int listSize = tok.countTokens(); - if ( max > 0 && listSize > max ) + String[] list = new String[tok.countTokens()]; + for ( int i = 0; tok.hasMoreTokens(); i++ ) { - listSize = max; - } - - String[] list = new String[listSize]; - int i = 0; - int lastTokenBegin; - int lastTokenEnd = 0; - while ( tok.hasMoreTokens() ) - { - if ( max > 0 && i == listSize - 1 ) - { - // In the situation where we hit the max yet have - // tokens left over in our input, the last list - // element gets all remaining text. - String endToken = tok.nextToken(); - lastTokenBegin = text.indexOf( endToken, lastTokenEnd ); - list[i] = text.substring( lastTokenBegin ); - break; - } - else - { - list[i] = tok.nextToken(); - lastTokenBegin = text.indexOf( list[i], lastTokenEnd ); - lastTokenEnd = lastTokenBegin + list[i].length(); - } - i++; + list[i] = tok.nextToken(); } return list; } /** *

    - * Checks if a (trimmed) String is null or blank. + * Checks if a (trimmed) String is {@code null} or blank. *

    * * @param str the String to check - * @return true if the String is null, or length zero once trimmed + * @return {@code true} if the String is {@code null}, or length zero once trimmed */ public static boolean isBlank( String str ) { @@ -142,12 +112,11 @@ public static boolean isBlank( String str ) /** *

    - * Checks if a (trimmed) String is not null and not blank. + * Checks if a (trimmed) String is not {@code null} and not blank. *

    * * @param str the String to check - * @return true if the String is not null and length of trimmed - * str is not zero. + * @return {@code true} if the String is not {@code null} and length of trimmed {@code str} is not zero. */ public static boolean isNotBlank( String str ) { @@ -255,7 +224,7 @@ else if ( ch >= 'A' ) *

    * A save length of {@code out} is {@code len * 3 + outoff}. *

    - * The reverse-method is {@link #unescapeBytes(byte[], String)}. + * The reverse-method is {@link #unescapeBytes(String, String)}. * * @param out output buffer * @param outoff offset in the output buffer @@ -339,9 +308,7 @@ public static ByteBuffer unescapeBytes( String str, String charsetName ) try { decodedFromSourceCharset = sourceCharset.newDecoder().decode( ByteBuffer.wrap( out, 0, outPos ) ); - ByteBuffer defaultEncoded = DEFAULT_CHARSET.encode( decodedFromSourceCharset ); - - return defaultEncoded; + return DEFAULT_CHARSET.encode( decodedFromSourceCharset ); } catch ( CharacterCodingException e ) { @@ -358,10 +325,11 @@ public static byte[] encodeStringForForkCommunication( String string ) } /** + * Determines if {@code buffer} starts with specific literal(s). * * @param buffer Examined StringBuffer - * @param pattern a pattern which should start in buffer - * @return true if buffer's literal starts with given pattern + * @param pattern a pattern which should start in {@code buffer} + * @return {@code true} if buffer's literal starts with given {@code pattern}, or both are empty. */ public static boolean startsWith( StringBuffer buffer, String pattern ) { diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/testset/FundamentalFilterTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/testset/FundamentalFilterTest.java index 911844837a..b99d4f98c8 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/testset/FundamentalFilterTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/testset/FundamentalFilterTest.java @@ -23,6 +23,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; +@SuppressWarnings( { "javadoc", "checkstyle:javadoctype" } ) /** * Inclusive test patters:

    * diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java index bb641158cc..8fa760b6bb 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java @@ -37,12 +37,12 @@ /** * Knows how to serialize and deserialize the booter configuration. - *

    + *
    * The internal serialization format is through a properties file. The long-term goal of this * class is not to expose this implementation information to its clients. This still leaks somewhat, * and there are some cases where properties are being accessed as "Properties" instead of * more representative domain objects. - *

    + *
    * * @author Jason van Zyl * @author Emmanuel Venisse 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 84ed9ebebb..531e7a1c09 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 @@ -116,6 +116,9 @@ public List getClassPath() /** * @deprecated this should be package private method which returns List of Files. It will be * removed in the next major version. + * + * @return list of {@link URL jar files paths} with {@code file} protocol in URL. + * @throws MalformedURLException if {@link URL} could not be created upon given class-path element(s) */ @Deprecated public List getAsUrlList() 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 7425e3d8e7..0e843150db 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 @@ -21,7 +21,7 @@ /** * Represents the classpaths for the BooterConfiguration. - *

    + *
    * * @author Jason van Zyl * @author Emmanuel Venisse 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 d5bba1f751..8dabaef23c 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 @@ -63,9 +63,9 @@ /** * The part of the booter that is unique to a forked vm. - *

    + *
    * Deals with deserialization of the booter wire-level protocol - *

    + *
    * * @author Jason van Zyl * @author Emmanuel Venisse @@ -82,7 +82,7 @@ public final class ForkedBooter /** * This method is invoked when Surefire is forked - this method parses and organizes the arguments passed to it and - * then calls the Surefire class' run method.

    The system exit code will be 1 if an exception is thrown. + * then calls the Surefire class' run method.
    The system exit code will be 1 if an exception is thrown. * * @param args Commandline arguments */ 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 a4d7d09778..601acd564f 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 @@ -25,7 +25,7 @@ import java.util.Set; /** - * @noinspection CustomClassloader + * Loads classes from jar files added via {@link #addURL(URL)}. */ public class IsolatedClassLoader extends URLClassLoader 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 79cbd4258b..c7379e4bc8 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 @@ -33,7 +33,7 @@ /** * Represents the surefire configuration that passes all the way into the provider * classloader and the provider. - *

    + *
    * * @author Jason van Zyl * @author Emmanuel Venisse 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 ae4e08eca5..e800cfe8ba 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 @@ -34,7 +34,7 @@ /** * Creates the surefire provider. - *

    + *
    * * @author Kristian Rosenvold */ diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java index ce23d3e3c1..91530b7a82 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java @@ -95,8 +95,8 @@ public String getActualClassName() /** *

    Strip any of a supplied String from the end of a String.

    - *

    - *

    If the strip String is null, whitespace is + *
    + *

    If the strip String is {@code null}, whitespace is * stripped.

    * * @param str the String to remove characters from diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java index 2dfd1ccf75..9a49d1a78c 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java @@ -32,7 +32,7 @@ import static org.junit.runners.Parameterized.Parameter; /** - * Base test class for SUREFIRE-580, configuration parameter skipAfterFailureCount. + * Base test class for SUREFIRE-580, configuration parameter {@code skipAfterFailureCount}. * * @author Tibor Digana (tibor17) * @since 2.19 diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java index 86df7fa4ed..beb1e328c6 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java @@ -24,7 +24,7 @@ import static org.junit.runners.Parameterized.Parameters; /** - * Test class for SUREFIRE-580, configuration parameter skipAfterFailureCount. + * Test class for SUREFIRE-580, configuration parameter {@code skipAfterFailureCount}. * * @author Tibor Digana (tibor17) * @since 2.19 diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java index 40ebc9fdcf..f4aa2b7f7d 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java @@ -24,7 +24,7 @@ import static org.junit.runners.Parameterized.Parameters; /** - * Test class for SUREFIRE-580, configuration parameter skipAfterFailureCount. + * Test class for SUREFIRE-580, configuration parameter {@code skipAfterFailureCount}. * * @author Tibor Digana (tibor17) * @since 2.19 diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java index 58d270a243..a6c539cbad 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java @@ -26,7 +26,7 @@ /** * Test include/exclude from files. - *

    + *
    * Based on {@link IncludesExcludesIT}. */ public class IncludesExcludesFromFileIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java index d6856b3b5d..bf393caa72 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java @@ -24,7 +24,7 @@ import org.junit.Test; /** - * Testing @net.jcip.annotations.NotThreadSafe with ParallelComputerBuilder. + * Testing {@code @net.jcip.annotations.NotThreadSafe} with ParallelComputerBuilder. * * @author Tibor Digana (tibor17) * @since 2.19 diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java index a99c142372..5470a3f3c9 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java @@ -31,7 +31,7 @@ /** * Verifies unicode filenames pass through correctly. - *

    + *
    * If the underlying file system turns out not to support unicode, we just fail an assumption.s */ public class UnicodeTestNamesIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java index e7aff2e62b..bd12dda5ca 100755 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java @@ -38,7 +38,7 @@ /** * Encapsulate all needed features to start a maven run - *

    + *
    * * @author Kristian Rosenvold */ diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java index c300abf96a..ee04dbcb6c 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java @@ -22,7 +22,7 @@ /** * Contains commonly used features for most tests, encapsulating * common use cases. - *

    + *
    * Also includes thread-safe access to the extracted resource * files, which AbstractSurefireIntegrationTestClass does not. * Thread safe only for running in "classes" mode. 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 4cb162d81b..e2356f4347 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 @@ -29,7 +29,7 @@ /** * Encapsulate all needed features to start a surefire run - *

    + *
    * Also includes thread-safe access to the extracted resource * files * diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java index 9866dd5873..886cd0740f 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java @@ -29,7 +29,7 @@ * Found in Surefire 2.16. * * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1024} + * @see SUREFIRE-1024 * @since 2.19 */ public class Surefire1024VerifyFailsafeIfTestedIT 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 6e4d76c6f6..ec63a8a051 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 @@ -25,20 +25,20 @@ /** * Plugin Configuration: parallel=classes - *

    + *
    * With Surefire 2.15 * {@code $ mvn test -Dtest=MyTest#testFoo} * Results: * Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 - *

    + *
    * With Surefire 2.16 * {@code $ mvn test -Dtest=MyTest#testFoo} - *

    + *
    * Results: * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 * * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1028} + * @see SUREFIRE-1028 * @since 2.18 */ public class Surefire1028UnableToRunSingleIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java index 1d5d353296..0d6d8b6f24 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java @@ -34,7 +34,7 @@ /** * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1036} + * @see SUREFIRE-1036 * @since 2.18 */ public class Surefire1036NonFilterableJUnitRunnerWithCategoriesIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java index 6494b79642..b3ed7444ae 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java @@ -28,7 +28,7 @@ /** * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1053} + * @see SUREFIRE-1053 * @since 2.18 */ public class Surefire1053SystemPropertiesIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java index 27d8cfd2e9..d6a38fa7ce 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java @@ -24,8 +24,8 @@ import org.junit.Test; /** - * Description of SUREFIRE-1080:

    - *

    + * Description of SUREFIRE-1080:
    + *
    * There are 9 tests in total in the attached project, and mvn test will show 9 tests run. * When I use the command " mvn test -Dparallel=classes -DforkCount=2 -DuseUnlimitedThreads=true", it shows 13 tests * run (and sometimes 16), and some tests are run more than once. @@ -35,7 +35,7 @@ * JUnit 4.11 * * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1080} + * @see SUREFIRE-1080 * @since 2.18 */ public class Surefire1080ParallelForkDoubleTestIT 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 a39f870c31..b1d9d4ffda 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 @@ -38,7 +38,7 @@ /** * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1082} + * @see SUREFIRE-1082 * @since 2.18 */ public class Surefire1082ParallelJUnitParameterizedIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListener.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListener.java index 509f3d0abe..f894265a20 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListener.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListener.java @@ -23,6 +23,7 @@ import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; +@SuppressWarnings( { "javadoc", "checkstyle:javadoctype" } ) /** * * In the surefire plugin, it is possible to specify one or more RunListener when running tests with JUnit. @@ -41,7 +42,7 @@ * Note: other methods in the RunListener I tested seems fine (i.e., they get a valid Description object as input) * * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1095} + * @see * @since 2.18 */ public final class Surefire1095NpeInRunListener @@ -50,7 +51,7 @@ public final class Surefire1095NpeInRunListener /** * Method Request.classes( String, Class[] ); exists in JUnit 4.0 - 4.4 - * @see JUnit4Reflector + * See JUnit4Reflector. */ @Test public void testRunStartedWithJUnit40() @@ -64,7 +65,7 @@ public void testRunStartedWithJUnit40() /** * Method Request.classes( Class[] ); Since of JUnit 4.5 - * @see JUnit4Reflector + * See JUnit4Reflector. */ @Test public void testRunStartedWithJUnit45() diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java index fc559ece4a..e81f0663a2 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java @@ -35,17 +35,17 @@ import static org.hamcrest.core.AnyOf.anyOf; /** - * The purpose of this IT is to assert that the run order of test classes is according to the settings:

    + * The purpose of this IT is to assert that the run order of test classes is according to the settings:
    * - * runOrder=balanced

    - * parallel=classes

    - * threadCount=2

    - * perCoreThreadCount=false

    - *

    + * runOrder=balanced
    + * parallel=classes
    + * threadCount=2
    + * perCoreThreadCount=false
    + *
    * The list of tests should be reordered to (DTest, CTest, BTest, ATest) in the second run. * * @author
    Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1098} + * @see SUREFIRE-1098 * @since 2.18 */ public class Surefire1098BalancedRunOrderIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java index 03e76392f7..2f9dca81aa 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java @@ -24,7 +24,7 @@ /** * @author agudian - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1122} + * @see SUREFIRE-1122 */ public class Surefire1122ParallelAndFlakyTestsIT extends SurefireJUnit4IntegrationTestCase 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 84735a9607..f78c16ab28 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 @@ -24,7 +24,7 @@ import org.junit.Test; /** - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1146} + * @see SUREFIRE-1146 */ public class Surefire1146RerunFailedAndParameterized extends SurefireJUnit4IntegrationTestCase diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java index 17064c0c72..706f6b5f40 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java @@ -33,7 +33,7 @@ /** * * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1158} + * @see SUREFIRE-1158 * @since 2.19 */ @RunWith( Parameterized.class ) diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java index 7d601388d4..f886446033 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java @@ -28,7 +28,7 @@ * Allow rerunFailingTestsCount, skipAfterFailureCount together * * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1202} + * @see SUREFIRE-1202 * @since 2.19.1 */ public class Surefire1202RerunAndSkipIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java index a6cb73d529..6ee87fbb0f 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java @@ -1 +1,75 @@ -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.SurefireJUnit4IntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; /** * @author Tibor Digana (tibor17) * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1209} * @since 2.19 */ public class Surefire1209RerunAndForkCountIT extends SurefireJUnit4IntegrationTestCase { @Test public void reusableForksJUnit47() throws VerificationException { unpack().executeTest() .assertTestSuiteResults( 5, 0, 0, 0, 4 ); } @Test public void notReusableForksJUnit47() throws VerificationException { unpack().reuseForks( false ) .executeTest() .assertTestSuiteResults( 5, 0, 0, 0, 4 ); } @Test public void reusableForksJUnit4() throws VerificationException { unpack().addGoal( "-Pjunit4" ) .executeTest() .assertTestSuiteResults( 5, 0, 0, 0, 4 ); } @Test public void notReusableForksJUnit4() throws VerificationException { unpack().addGoal( "-Pjunit4" ) .reuseForks( false ) .executeTest() .assertTestSuiteResults( 5, 0, 0, 0, 4 ); } private SurefireLauncher unpack() { return unpack( "surefire-1209-rerun-and-forkcount" ); } } \ 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.it.VerificationException; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +/** + * @author Tibor Digana (tibor17) + * @see SUREFIRE-1209 + * @since 2.19 + */ +public class Surefire1209RerunAndForkCountIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void reusableForksJUnit47() + throws VerificationException + { + unpack().executeTest() + .assertTestSuiteResults( 5, 0, 0, 0, 4 ); + } + + @Test + public void notReusableForksJUnit47() + throws VerificationException + { + unpack().reuseForks( false ) + .executeTest() + .assertTestSuiteResults( 5, 0, 0, 0, 4 ); + } + + @Test + public void reusableForksJUnit4() + throws VerificationException + { + unpack().addGoal( "-Pjunit4" ) + .executeTest() + .assertTestSuiteResults( 5, 0, 0, 0, 4 ); + } + + @Test + public void notReusableForksJUnit4() + throws VerificationException + { + unpack().addGoal( "-Pjunit4" ) + .reuseForks( false ) + .executeTest() + .assertTestSuiteResults( 5, 0, 0, 0, 4 ); + } + + private SurefireLauncher unpack() + { + return unpack( "surefire-1209-rerun-and-forkcount" ); + } +} diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java index da69e9da35..27b4da8b69 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java @@ -1 +1,63 @@ -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.apache.commons.lang3.JavaVersion.JAVA_1_7; import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion; /** * @author Tibor Digana (tibor17) * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1211} * @since 2.19.1 */ public class Surefire1211JUnitTestNgIT extends SurefireJUnit4IntegrationTestCase { @Test public void withJUnit() { assumeJavaVersion( JAVA_1_7 ); unpack().threadCount( 1 ) .executeTest() .verifyErrorFree( 2 ); } @Test public void withoutJUnit() { assumeJavaVersion( JAVA_1_7 ); unpack().threadCount( 1 ) .sysProp( "junit", "false" ) .executeTest() .verifyErrorFree( 1 ); } private SurefireLauncher unpack() { return unpack( "surefire-1211" ); } } \ 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.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +import static org.apache.commons.lang3.JavaVersion.JAVA_1_7; +import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion; + +/** + * @author Tibor Digana (tibor17) + * @see SUREFIRE-1211 + * @since 2.19.1 + */ +public class Surefire1211JUnitTestNgIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void withJUnit() + { + assumeJavaVersion( JAVA_1_7 ); + + unpack().threadCount( 1 ) + .executeTest() + .verifyErrorFree( 2 ); + } + + @Test + public void withoutJUnit() + { + assumeJavaVersion( JAVA_1_7 ); + + unpack().threadCount( 1 ) + .sysProp( "junit", "false" ) + .executeTest() + .verifyErrorFree( 1 ); + } + + private SurefireLauncher unpack() + { + return unpack( "surefire-1211" ); + } +} 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 870daf18ba..c4031c25e6 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,49 @@ -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 +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 SUREFIRE-1260 + * @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" ); + } +} 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 index 88c0daad80..9e06e8e11b 100644 --- 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 @@ -25,6 +25,7 @@ import static org.junit.Assume.assumeTrue; +@SuppressWarnings( { "javadoc", "checkstyle:javadoctype" } ) /** * IsolatedClassLoader should take platform ClassLoader as a parent ClassLoader if running on the top of JDK9. * The IsolatedClassLoader should not fail like this: @@ -35,7 +36,7 @@ * 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} + * @see SUREFIRE-1265 * @since 2.20.1 */ public class Surefire1265Java9IT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire649EmptyStringSystemPropertiesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire649EmptyStringSystemPropertiesIT.java index 96efa5a826..d6f0a0edfd 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire649EmptyStringSystemPropertiesIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire649EmptyStringSystemPropertiesIT.java @@ -29,7 +29,7 @@ /** * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-649} + * @see SUREFIRE-649 * @since 2.18 */ public class Surefire649EmptyStringSystemPropertiesIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire817SystemExitIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire817SystemExitIT.java index 7ab1568d22..215bd5d7eb 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire817SystemExitIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire817SystemExitIT.java @@ -26,7 +26,7 @@ /** * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-817} + * @see SUREFIRE-817 * @since 2.18 */ public class Surefire817SystemExitIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire855AllowFailsafeUseArtifactFileIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire855AllowFailsafeUseArtifactFileIT.java index 9ee7a41c69..1263ab3315 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire855AllowFailsafeUseArtifactFileIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire855AllowFailsafeUseArtifactFileIT.java @@ -24,7 +24,7 @@ /** * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-855} + * @see SUREFIRE-855 * @since 2.19 */ public class Surefire855AllowFailsafeUseArtifactFileIT diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire995CategoryInheritanceIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire995CategoryInheritanceIT.java index 2085d93c7b..d776724c96 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire995CategoryInheritanceIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire995CategoryInheritanceIT.java @@ -25,7 +25,7 @@ /** * @author Tibor Digana (tibor17) - * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-995} + * @see SUREFIRE-995 * @since 2.18.1 */ public class Surefire995CategoryInheritanceIT diff --git a/surefire-integration-tests/src/test/resources/SurefireToolchains/pom.xml b/surefire-integration-tests/src/test/resources/SurefireToolchains/pom.xml index 623c226091..2d066eb366 100644 --- a/surefire-integration-tests/src/test/resources/SurefireToolchains/pom.xml +++ b/surefire-integration-tests/src/test/resources/SurefireToolchains/pom.xml @@ -1,7 +1,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 test diff --git a/surefire-integration-tests/src/test/resources/additional-classpath/pom.xml b/surefire-integration-tests/src/test/resources/additional-classpath/pom.xml index 4020be505a..01ce10c7b4 100644 --- a/surefire-integration-tests/src/test/resources/additional-classpath/pom.xml +++ b/surefire-integration-tests/src/test/resources/additional-classpath/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/aggregate-report/child1/pom.xml b/surefire-integration-tests/src/test/resources/aggregate-report/child1/pom.xml index b28ab6476e..9897a25f78 100644 --- a/surefire-integration-tests/src/test/resources/aggregate-report/child1/pom.xml +++ b/surefire-integration-tests/src/test/resources/aggregate-report/child1/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/aggregate-report/child2/pom.xml b/surefire-integration-tests/src/test/resources/aggregate-report/child2/pom.xml index 35dee50e20..b67c49a100 100644 --- a/surefire-integration-tests/src/test/resources/aggregate-report/child2/pom.xml +++ b/surefire-integration-tests/src/test/resources/aggregate-report/child2/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/aggregate-report/pom.xml b/surefire-integration-tests/src/test/resources/aggregate-report/pom.xml index 631ca7cc23..42f0f32abe 100644 --- a/surefire-integration-tests/src/test/resources/aggregate-report/pom.xml +++ b/surefire-integration-tests/src/test/resources/aggregate-report/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/ant-ignore/pom.xml b/surefire-integration-tests/src/test/resources/ant-ignore/pom.xml index 3cc74a17d2..6360bedcc3 100644 --- a/surefire-integration-tests/src/test/resources/ant-ignore/pom.xml +++ b/surefire-integration-tests/src/test/resources/ant-ignore/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/argLine-parameter/pom.xml b/surefire-integration-tests/src/test/resources/argLine-parameter/pom.xml index 2eed551052..0cce4c986d 100644 --- a/surefire-integration-tests/src/test/resources/argLine-parameter/pom.xml +++ b/surefire-integration-tests/src/test/resources/argLine-parameter/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/argLine-properties/pom.xml b/surefire-integration-tests/src/test/resources/argLine-properties/pom.xml index e6797673ad..2a6d6c24ad 100644 --- a/surefire-integration-tests/src/test/resources/argLine-properties/pom.xml +++ b/surefire-integration-tests/src/test/resources/argLine-properties/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/assumpationFailureReport/pom.xml b/surefire-integration-tests/src/test/resources/assumpationFailureReport/pom.xml index 069dacf9d4..8530ecad6b 100644 --- a/surefire-integration-tests/src/test/resources/assumpationFailureReport/pom.xml +++ b/surefire-integration-tests/src/test/resources/assumpationFailureReport/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/classpath-filtering/pom.xml b/surefire-integration-tests/src/test/resources/classpath-filtering/pom.xml index 6b16431bd6..49c4e34a4b 100644 --- a/surefire-integration-tests/src/test/resources/classpath-filtering/pom.xml +++ b/surefire-integration-tests/src/test/resources/classpath-filtering/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/classpath-order/pom.xml b/surefire-integration-tests/src/test/resources/classpath-order/pom.xml index a72c2f52d4..b49fda71b4 100644 --- a/surefire-integration-tests/src/test/resources/classpath-order/pom.xml +++ b/surefire-integration-tests/src/test/resources/classpath-order/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/classpath-scope-filtering/pom.xml b/surefire-integration-tests/src/test/resources/classpath-scope-filtering/pom.xml index 84789c5c3e..7dcdfa2034 100644 --- a/surefire-integration-tests/src/test/resources/classpath-scope-filtering/pom.xml +++ b/surefire-integration-tests/src/test/resources/classpath-scope-filtering/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/consoleOutput/pom.xml b/surefire-integration-tests/src/test/resources/consoleOutput/pom.xml index 2602eef28d..407f909d71 100644 --- a/surefire-integration-tests/src/test/resources/consoleOutput/pom.xml +++ b/surefire-integration-tests/src/test/resources/consoleOutput/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/consoleOutputEncoding/pom.xml b/surefire-integration-tests/src/test/resources/consoleOutputEncoding/pom.xml index 059a99ca64..5dec5d8a1b 100644 --- a/surefire-integration-tests/src/test/resources/consoleOutputEncoding/pom.xml +++ b/surefire-integration-tests/src/test/resources/consoleOutputEncoding/pom.xml @@ -19,7 +19,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/consoleoutput-noisy/pom.xml b/surefire-integration-tests/src/test/resources/consoleoutput-noisy/pom.xml index 192134a0fb..e80b9787c3 100644 --- a/surefire-integration-tests/src/test/resources/consoleoutput-noisy/pom.xml +++ b/surefire-integration-tests/src/test/resources/consoleoutput-noisy/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> diff --git a/surefire-integration-tests/src/test/resources/crash-detection/pom.xml b/surefire-integration-tests/src/test/resources/crash-detection/pom.xml index 92a1e5f3de..81e9c6a224 100644 --- a/surefire-integration-tests/src/test/resources/crash-detection/pom.xml +++ b/surefire-integration-tests/src/test/resources/crash-detection/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.apache.maven.surefire it-parent 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 index 38134bdcb7..0d9e3e7ffa 100644 --- a/surefire-integration-tests/src/test/resources/crash-during-test/pom.xml +++ b/surefire-integration-tests/src/test/resources/crash-during-test/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.apache.maven.surefire it-parent diff --git a/surefire-integration-tests/src/test/resources/default-configuration-abstract/pom.xml b/surefire-integration-tests/src/test/resources/default-configuration-abstract/pom.xml index 2d24d313d9..1bd1f918eb 100644 --- a/surefire-integration-tests/src/test/resources/default-configuration-abstract/pom.xml +++ b/surefire-integration-tests/src/test/resources/default-configuration-abstract/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/default-configuration-classWithNoTests/pom.xml b/surefire-integration-tests/src/test/resources/default-configuration-classWithNoTests/pom.xml index 9d2f6824f6..dafe6e5428 100644 --- a/surefire-integration-tests/src/test/resources/default-configuration-classWithNoTests/pom.xml +++ b/surefire-integration-tests/src/test/resources/default-configuration-classWithNoTests/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/default-configuration-noTests/pom.xml b/surefire-integration-tests/src/test/resources/default-configuration-noTests/pom.xml index 453130ffa5..fc77535595 100644 --- a/surefire-integration-tests/src/test/resources/default-configuration-noTests/pom.xml +++ b/surefire-integration-tests/src/test/resources/default-configuration-noTests/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/default-configuration/pom.xml b/surefire-integration-tests/src/test/resources/default-configuration/pom.xml index b5b1686b99..1d9587ae46 100644 --- a/surefire-integration-tests/src/test/resources/default-configuration/pom.xml +++ b/surefire-integration-tests/src/test/resources/default-configuration/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/environment-variables/pom.xml b/surefire-integration-tests/src/test/resources/environment-variables/pom.xml index c18b3b9554..79f4eda54e 100644 --- a/surefire-integration-tests/src/test/resources/environment-variables/pom.xml +++ b/surefire-integration-tests/src/test/resources/environment-variables/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml b/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml index 14fcdfd34a..6d6aca26c1 100644 --- a/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml +++ b/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml b/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml index 4ad397f6f5..47e5e24f07 100644 --- a/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml +++ b/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/failingBuilds/pom.xml b/surefire-integration-tests/src/test/resources/failingBuilds/pom.xml index 200c4c4ab1..46da1bf40b 100644 --- a/surefire-integration-tests/src/test/resources/failingBuilds/pom.xml +++ b/surefire-integration-tests/src/test/resources/failingBuilds/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire failingBuilds-test diff --git a/surefire-integration-tests/src/test/resources/failure-result-counting/pom.xml b/surefire-integration-tests/src/test/resources/failure-result-counting/pom.xml index 5940e674b5..59f60cd246 100644 --- a/surefire-integration-tests/src/test/resources/failure-result-counting/pom.xml +++ b/surefire-integration-tests/src/test/resources/failure-result-counting/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 maven-surefire small-result-counting diff --git a/surefire-integration-tests/src/test/resources/failureOutput/pom.xml b/surefire-integration-tests/src/test/resources/failureOutput/pom.xml index 5be8fc406f..71ff2c409e 100644 --- a/surefire-integration-tests/src/test/resources/failureOutput/pom.xml +++ b/surefire-integration-tests/src/test/resources/failureOutput/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire failureOutput diff --git a/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml b/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml index 931dc534af..29610f9dca 100644 --- a/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml +++ b/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire fork-consoleOutput diff --git a/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/pom.xml b/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/pom.xml index 6e86279aa8..fd92dde09d 100644 --- a/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/pom.xml +++ b/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire fork-consoleOutput diff --git a/surefire-integration-tests/src/test/resources/fork-fail/pom.xml b/surefire-integration-tests/src/test/resources/fork-fail/pom.xml index c71fc02961..e0de5b0679 100644 --- a/surefire-integration-tests/src/test/resources/fork-fail/pom.xml +++ b/surefire-integration-tests/src/test/resources/fork-fail/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/fork-mode-multimodule/module-a/pom.xml b/surefire-integration-tests/src/test/resources/fork-mode-multimodule/module-a/pom.xml index cbaf407bfe..9de3941c36 100644 --- a/surefire-integration-tests/src/test/resources/fork-mode-multimodule/module-a/pom.xml +++ b/surefire-integration-tests/src/test/resources/fork-mode-multimodule/module-a/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/fork-mode-multimodule/module-b/pom.xml b/surefire-integration-tests/src/test/resources/fork-mode-multimodule/module-b/pom.xml index ba076ce6d8..61fd8a01cb 100644 --- a/surefire-integration-tests/src/test/resources/fork-mode-multimodule/module-b/pom.xml +++ b/surefire-integration-tests/src/test/resources/fork-mode-multimodule/module-b/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/fork-mode-multimodule/pom.xml b/surefire-integration-tests/src/test/resources/fork-mode-multimodule/pom.xml index 98e073f720..753556929f 100644 --- a/surefire-integration-tests/src/test/resources/fork-mode-multimodule/pom.xml +++ b/surefire-integration-tests/src/test/resources/fork-mode-multimodule/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/fork-mode-resource-loading/pom.xml b/surefire-integration-tests/src/test/resources/fork-mode-resource-loading/pom.xml index 49fb2f89f8..1c00ea6f09 100644 --- a/surefire-integration-tests/src/test/resources/fork-mode-resource-loading/pom.xml +++ b/surefire-integration-tests/src/test/resources/fork-mode-resource-loading/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/fork-mode-testng/pom.xml b/surefire-integration-tests/src/test/resources/fork-mode-testng/pom.xml index ec5d3c6fbf..a622fa52ea 100644 --- a/surefire-integration-tests/src/test/resources/fork-mode-testng/pom.xml +++ b/surefire-integration-tests/src/test/resources/fork-mode-testng/pom.xml @@ -4,7 +4,7 @@ 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. --> - + 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/fork-mode/pom.xml b/surefire-integration-tests/src/test/resources/fork-mode/pom.xml index ca7d365c59..cf77bb0264 100644 --- a/surefire-integration-tests/src/test/resources/fork-mode/pom.xml +++ b/surefire-integration-tests/src/test/resources/fork-mode/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/fork-timeout/pom.xml b/surefire-integration-tests/src/test/resources/fork-timeout/pom.xml index 55889c6eaa..c0d03c5f44 100644 --- a/surefire-integration-tests/src/test/resources/fork-timeout/pom.xml +++ b/surefire-integration-tests/src/test/resources/fork-timeout/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire fork-timeout-test diff --git a/surefire-integration-tests/src/test/resources/isolated-classloader/pom.xml b/surefire-integration-tests/src/test/resources/isolated-classloader/pom.xml index 6187cdd12e..dbed07b9bd 100644 --- a/surefire-integration-tests/src/test/resources/isolated-classloader/pom.xml +++ b/surefire-integration-tests/src/test/resources/isolated-classloader/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit-fork-mode-always/pom.xml b/surefire-integration-tests/src/test/resources/junit-fork-mode-always/pom.xml index 20f829c8b5..ed2d93063f 100644 --- a/surefire-integration-tests/src/test/resources/junit-fork-mode-always/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit-fork-mode-always/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit-ignore/pom.xml b/surefire-integration-tests/src/test/resources/junit-ignore/pom.xml index a40b9869f0..a73c36248a 100644 --- a/surefire-integration-tests/src/test/resources/junit-ignore/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit-ignore/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit-innerClass/pom.xml b/surefire-integration-tests/src/test/resources/junit-innerClass/pom.xml index 7e61c3ebd3..40b5060dcf 100644 --- a/surefire-integration-tests/src/test/resources/junit-innerClass/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit-innerClass/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit-notExtendingTestCase/pom.xml b/surefire-integration-tests/src/test/resources/junit-notExtendingTestCase/pom.xml index 69fb24756e..e459f457dc 100644 --- a/surefire-integration-tests/src/test/resources/junit-notExtendingTestCase/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit-notExtendingTestCase/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit-pathWithUmlaut/pom.xml b/surefire-integration-tests/src/test/resources/junit-pathWithUmlaut/pom.xml index e40c80a91b..321aba742b 100644 --- a/surefire-integration-tests/src/test/resources/junit-pathWithUmlaut/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit-pathWithUmlaut/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/pom.xml b/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/pom.xml index 92db68d724..0e2a12cc96 100644 --- a/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit-twoTestCaseSuite/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit-twoTestCases/pom.xml b/surefire-integration-tests/src/test/resources/junit-twoTestCases/pom.xml index bcc89e04e6..e74f4856a6 100644 --- a/surefire-integration-tests/src/test/resources/junit-twoTestCases/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit-twoTestCases/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit4-forkAlways-staticInit/pom.xml b/surefire-integration-tests/src/test/resources/junit4-forkAlways-staticInit/pom.xml index 59a9d10aec..57765e0048 100644 --- a/surefire-integration-tests/src/test/resources/junit4-forkAlways-staticInit/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit4-forkAlways-staticInit/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire.test junit4-forkAlways-staticInit 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 5652336780..95e8471db3 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 @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit4-runlistener/pom.xml b/surefire-integration-tests/src/test/resources/junit4-runlistener/pom.xml index b11496b060..1487d3ac2a 100644 --- a/surefire-integration-tests/src/test/resources/junit4-runlistener/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit4-runlistener/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/pom.xml b/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/pom.xml index 64e4348902..6c835384b8 100644 --- a/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit4-twoTestCaseSuite/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit4/pom.xml b/surefire-integration-tests/src/test/resources/junit4/pom.xml index 3d1f971879..894b6089fb 100644 --- a/surefire-integration-tests/src/test/resources/junit4/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit4/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit44-dep/pom.xml b/surefire-integration-tests/src/test/resources/junit44-dep/pom.xml index 6e6d476b74..b19f5f72e5 100644 --- a/surefire-integration-tests/src/test/resources/junit44-dep/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit44-dep/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit44-environment/pom.xml b/surefire-integration-tests/src/test/resources/junit44-environment/pom.xml index d97aeb4d1b..b7904d24b6 100644 --- a/surefire-integration-tests/src/test/resources/junit44-environment/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit44-environment/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit44-hamcrest/pom.xml b/surefire-integration-tests/src/test/resources/junit44-hamcrest/pom.xml index 8eeea1b6a3..8bc0e932cd 100644 --- a/surefire-integration-tests/src/test/resources/junit44-hamcrest/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit44-hamcrest/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit44-method-pattern/pom.xml b/surefire-integration-tests/src/test/resources/junit44-method-pattern/pom.xml index 5c00713737..2ef44712eb 100644 --- a/surefire-integration-tests/src/test/resources/junit44-method-pattern/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit44-method-pattern/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit44-multiple-methods/pom.xml b/surefire-integration-tests/src/test/resources/junit44-multiple-methods/pom.xml index 101dad1b60..2757d54987 100644 --- a/surefire-integration-tests/src/test/resources/junit44-multiple-methods/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit44-multiple-methods/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/junit44-single-method/pom.xml b/surefire-integration-tests/src/test/resources/junit44-single-method/pom.xml index f0810c4260..e3d28acb7b 100644 --- a/surefire-integration-tests/src/test/resources/junit44-single-method/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit44-single-method/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit47-concurrency/pom.xml b/surefire-integration-tests/src/test/resources/junit47-concurrency/pom.xml index 4f648df637..21bd802984 100644 --- a/surefire-integration-tests/src/test/resources/junit47-concurrency/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit47-concurrency/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/junit47-parallel-nts/pom.xml b/surefire-integration-tests/src/test/resources/junit47-parallel-nts/pom.xml index eb3c7fe3ee..d984c58b77 100644 --- a/surefire-integration-tests/src/test/resources/junit47-parallel-nts/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit47-parallel-nts/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/junit47-parallel-with-suite/pom.xml b/surefire-integration-tests/src/test/resources/junit47-parallel-with-suite/pom.xml index eb68f3e94e..e8b08d73b1 100644 --- a/surefire-integration-tests/src/test/resources/junit47-parallel-with-suite/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit47-parallel-with-suite/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire junit4-test diff --git a/surefire-integration-tests/src/test/resources/junit47-parallel/pom.xml b/surefire-integration-tests/src/test/resources/junit47-parallel/pom.xml index b4b0723586..1a61ae182e 100644 --- a/surefire-integration-tests/src/test/resources/junit47-parallel/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit47-parallel/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/junit47-redirect-output/pom.xml b/surefire-integration-tests/src/test/resources/junit47-redirect-output/pom.xml index 7cdb0a1705..f5e7f801e0 100644 --- a/surefire-integration-tests/src/test/resources/junit47-redirect-output/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit47-redirect-output/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire fork-consoleOutput diff --git a/surefire-integration-tests/src/test/resources/junit47-static-inner-class-tests/pom.xml b/surefire-integration-tests/src/test/resources/junit47-static-inner-class-tests/pom.xml index a7ac0555d5..60d3b99759 100644 --- a/surefire-integration-tests/src/test/resources/junit47-static-inner-class-tests/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit47-static-inner-class-tests/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire junit4-test diff --git a/surefire-integration-tests/src/test/resources/junit48-categories/pom.xml b/surefire-integration-tests/src/test/resources/junit48-categories/pom.xml index 02914f8e89..ef40d2ebc8 100644 --- a/surefire-integration-tests/src/test/resources/junit48-categories/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit48-categories/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/junit48-method-pattern/pom.xml b/surefire-integration-tests/src/test/resources/junit48-method-pattern/pom.xml index fe1690cdd2..d7b99fe627 100644 --- a/surefire-integration-tests/src/test/resources/junit48-method-pattern/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit48-method-pattern/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/junit48-multiple-method-patterns/pom.xml b/surefire-integration-tests/src/test/resources/junit48-multiple-method-patterns/pom.xml index 00ebfa5d88..f6de751f6f 100644 --- a/surefire-integration-tests/src/test/resources/junit48-multiple-method-patterns/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit48-multiple-method-patterns/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/junit48-multiple-methods/pom.xml b/surefire-integration-tests/src/test/resources/junit48-multiple-methods/pom.xml index 83b3044c85..999627b5ce 100644 --- a/surefire-integration-tests/src/test/resources/junit48-multiple-methods/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit48-multiple-methods/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/junit48-single-method/pom.xml b/surefire-integration-tests/src/test/resources/junit48-single-method/pom.xml index ff701a3bfd..3ab223523c 100644 --- a/surefire-integration-tests/src/test/resources/junit48-single-method/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit48-single-method/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/junit48-smartStackTrace/pom.xml b/surefire-integration-tests/src/test/resources/junit48-smartStackTrace/pom.xml index ef0c85487f..eaafcdee60 100644 --- a/surefire-integration-tests/src/test/resources/junit48-smartStackTrace/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit48-smartStackTrace/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/large-test-results/pom.xml b/surefire-integration-tests/src/test/resources/large-test-results/pom.xml index 24a816c885..36caa01070 100644 --- a/surefire-integration-tests/src/test/resources/large-test-results/pom.xml +++ b/surefire-integration-tests/src/test/resources/large-test-results/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/norunnableTests/pom.xml b/surefire-integration-tests/src/test/resources/norunnableTests/pom.xml index cb08ed75c3..cde195f043 100644 --- a/surefire-integration-tests/src/test/resources/norunnableTests/pom.xml +++ b/surefire-integration-tests/src/test/resources/norunnableTests/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/parallel-runtime/pom.xml b/surefire-integration-tests/src/test/resources/parallel-runtime/pom.xml index 560fe35dab..dba4c97ca3 100644 --- a/surefire-integration-tests/src/test/resources/parallel-runtime/pom.xml +++ b/surefire-integration-tests/src/test/resources/parallel-runtime/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire parallel-runtime diff --git a/surefire-integration-tests/src/test/resources/plain-old-java-classpath/pom.xml b/surefire-integration-tests/src/test/resources/plain-old-java-classpath/pom.xml index edf103105b..22ef8a6b31 100644 --- a/surefire-integration-tests/src/test/resources/plain-old-java-classpath/pom.xml +++ b/surefire-integration-tests/src/test/resources/plain-old-java-classpath/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/plexus-conflict/pom.xml b/surefire-integration-tests/src/test/resources/plexus-conflict/pom.xml index f2abf3b85f..19c5486067 100644 --- a/surefire-integration-tests/src/test/resources/plexus-conflict/pom.xml +++ b/surefire-integration-tests/src/test/resources/plexus-conflict/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/pojo-simple/pom.xml b/surefire-integration-tests/src/test/resources/pojo-simple/pom.xml index a97b872eab..ae30de023e 100644 --- a/surefire-integration-tests/src/test/resources/pojo-simple/pom.xml +++ b/surefire-integration-tests/src/test/resources/pojo-simple/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/reporters/pom.xml b/surefire-integration-tests/src/test/resources/reporters/pom.xml index a28409d9c2..8ea3d178d3 100644 --- a/surefire-integration-tests/src/test/resources/reporters/pom.xml +++ b/surefire-integration-tests/src/test/resources/reporters/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire reporters diff --git a/surefire-integration-tests/src/test/resources/result-counting/pom.xml b/surefire-integration-tests/src/test/resources/result-counting/pom.xml index 564deae45a..7e7f262b96 100644 --- a/surefire-integration-tests/src/test/resources/result-counting/pom.xml +++ b/surefire-integration-tests/src/test/resources/result-counting/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 mag junit4-test diff --git a/surefire-integration-tests/src/test/resources/runOrder/pom.xml b/surefire-integration-tests/src/test/resources/runOrder/pom.xml index 1319a58be6..063e82ba23 100644 --- a/surefire-integration-tests/src/test/resources/runOrder/pom.xml +++ b/surefire-integration-tests/src/test/resources/runOrder/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/runorder-parallel/pom.xml b/surefire-integration-tests/src/test/resources/runorder-parallel/pom.xml index f5c967d347..edbc7fa2d0 100644 --- a/surefire-integration-tests/src/test/resources/runorder-parallel/pom.xml +++ b/surefire-integration-tests/src/test/resources/runorder-parallel/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire runorder-parallel diff --git a/surefire-integration-tests/src/test/resources/sibling-aggregator/aggregator/pom.xml b/surefire-integration-tests/src/test/resources/sibling-aggregator/aggregator/pom.xml index b1733c6fbd..eb5f25c4d2 100644 --- a/surefire-integration-tests/src/test/resources/sibling-aggregator/aggregator/pom.xml +++ b/surefire-integration-tests/src/test/resources/sibling-aggregator/aggregator/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire.its.sibling-aggregator diff --git a/surefire-integration-tests/src/test/resources/sibling-aggregator/child1/pom.xml b/surefire-integration-tests/src/test/resources/sibling-aggregator/child1/pom.xml index 500216a9d4..ba34f0a753 100644 --- a/surefire-integration-tests/src/test/resources/sibling-aggregator/child1/pom.xml +++ b/surefire-integration-tests/src/test/resources/sibling-aggregator/child1/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire.its.sibling-aggregator diff --git a/surefire-integration-tests/src/test/resources/sibling-aggregator/child2/pom.xml b/surefire-integration-tests/src/test/resources/sibling-aggregator/child2/pom.xml index 023af1cbae..5ca21cdf3e 100644 --- a/surefire-integration-tests/src/test/resources/sibling-aggregator/child2/pom.xml +++ b/surefire-integration-tests/src/test/resources/sibling-aggregator/child2/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire.its.sibling-aggregator diff --git a/surefire-integration-tests/src/test/resources/small-result-counting/pom.xml b/surefire-integration-tests/src/test/resources/small-result-counting/pom.xml index f40eefcdc0..d48eb9217f 100644 --- a/surefire-integration-tests/src/test/resources/small-result-counting/pom.xml +++ b/surefire-integration-tests/src/test/resources/small-result-counting/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 maven-surefire small-result-counting diff --git a/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml index 1629429f34..5285fb1cd3 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml @@ -19,7 +19,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml index f38b200550..b613fcb22e 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml @@ -19,7 +19,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-1024/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1024/pom.xml index bc281045cc..340c494351 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1024/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1024/pom.xml @@ -19,7 +19,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1028-unable-to-run-single-test/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1028-unable-to-run-single-test/pom.xml index edbfeb39f5..2b7659e82f 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1028-unable-to-run-single-test/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1028-unable-to-run-single-test/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1036-NonFilterableJUnitRunnerWithCategories/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1036-NonFilterableJUnitRunnerWithCategories/pom.xml index 6a036e542b..00ed6182ac 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1036-NonFilterableJUnitRunnerWithCategories/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1036-NonFilterableJUnitRunnerWithCategories/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml index e1331cbbfc..efd19e8fe6 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml @@ -19,7 +19,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1053-system-properties/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1053-system-properties/pom.xml index eeb446bd9b..4c69f8fc99 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1053-system-properties/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1053-system-properties/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1080-parallel-fork-double-test/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1080-parallel-fork-double-test/pom.xml index 5d3eb9374d..86f29f3194 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1080-parallel-fork-double-test/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1080-parallel-fork-double-test/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/pom.xml index ef3b87d021..64e85593db 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1095-npe-in-runlistener/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1095-npe-in-runlistener/pom.xml index b0f79b1dc7..022fddf80e 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1095-npe-in-runlistener/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1095-npe-in-runlistener/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1098-balanced-runorder/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1098-balanced-runorder/pom.xml index e7c4b6f772..08ba73d00b 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1098-balanced-runorder/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1098-balanced-runorder/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1122-parallel-and-flakyTests/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1122-parallel-and-flakyTests/pom.xml index 62ef25134e..479caa317d 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1122-parallel-and-flakyTests/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1122-parallel-and-flakyTests/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml index d9a9a847ba..6a1b46e1b7 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml @@ -21,7 +21,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1144-xml-runtime/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1144-xml-runtime/pom.xml index 799f87e29b..b35d70eb0a 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1144-xml-runtime/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1144-xml-runtime/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-1146-rerunFailingTests-with-Parameterized/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1146-rerunFailingTests-with-Parameterized/pom.xml index 28d042023b..3867dd2d43 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1146-rerunFailingTests-with-Parameterized/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1146-rerunFailingTests-with-Parameterized/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1153-includesAndSpecifiedTest/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1153-includesAndSpecifiedTest/pom.xml index b8b4a03a52..b430563070 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1153-includesAndSpecifiedTest/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1153-includesAndSpecifiedTest/pom.xml @@ -19,7 +19,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1158-remove-info-lines/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1158-remove-info-lines/pom.xml index d7cd094c8e..d93b0473eb 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1158-remove-info-lines/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1158-remove-info-lines/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-1185/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1185/pom.xml index c7fac09670..910c7a84f8 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1185/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1185/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-1211/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1211/pom.xml index d867b3c12d..d8d24f4fe6 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1211/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1211/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-1260-new-tests-pattern/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1260-new-tests-pattern/pom.xml index c6673b808a..5f3df665d3 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1260-new-tests-pattern/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1260-new-tests-pattern/pom.xml @@ -1 +1,60 @@ - 4.0.0 org.apache.maven.surefire it-parent 1.0 ../pom.xml org.apache.maven.plugins.surefire surefire-1260 1.0 http://maven.apache.org tibordigana Tibor Digaňa (tibor17) tibordigana@apache.org PMC Europe/Bratislava junit junit 4.0 test \ No newline at end of file + + + + + 4.0.0 + + + + org.apache.maven.surefire + it-parent + 1.0 + ../pom.xml + + + org.apache.maven.plugins.surefire + surefire-1260 + 1.0 + + http://maven.apache.org + + + + tibordigana + Tibor Diga??a (tibor17) + tibordigana@apache.org + + PMC + + Europe/Bratislava + + + + + + junit + junit + 4.0 + test + + + diff --git a/surefire-integration-tests/src/test/resources/surefire-1265/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1265/pom.xml index a702f30a4d..ec74a49d11 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1265/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1265/pom.xml @@ -19,7 +19,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-1278-group-name-ending/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1278-group-name-ending/pom.xml index 022073d4ee..b1764ba6d1 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1278-group-name-ending/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1278-group-name-ending/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/pom.xml b/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/pom.xml index 5614e35e8f..14f9739aba 100644 --- a/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-146-forkPerTestNoSetup/pom.xml b/surefire-integration-tests/src/test/resources/surefire-146-forkPerTestNoSetup/pom.xml index e97f54172e..b2224565b8 100644 --- a/surefire-integration-tests/src/test/resources/surefire-146-forkPerTestNoSetup/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-146-forkPerTestNoSetup/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/pom.xml b/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/pom.xml index d4f21ef3c0..ff7f25fa45 100644 --- a/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/module1/pom.xml b/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/module1/pom.xml index 9540cf40a3..90ca5c627f 100644 --- a/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/module1/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/module1/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/module2/pom.xml b/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/module2/pom.xml index fa0ea51c5d..2685c1385b 100644 --- a/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/module2/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/module2/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/pom.xml b/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/pom.xml index 5dd20289f4..02f581d2ad 100644 --- a/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-257-rerunningTests/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire-257-rerunningTests surefire-257-rerunningTests diff --git a/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml b/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml index 6677318037..8d555b322b 100644 --- a/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-34-securityManager-success/pom.xml b/surefire-integration-tests/src/test/resources/surefire-34-securityManager-success/pom.xml index 41a6be399f..f01e319678 100644 --- a/surefire-integration-tests/src/test/resources/surefire-34-securityManager-success/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-34-securityManager-success/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-34-securityManager/pom.xml b/surefire-integration-tests/src/test/resources/surefire-34-securityManager/pom.xml index 41a6be399f..f01e319678 100644 --- a/surefire-integration-tests/src/test/resources/surefire-34-securityManager/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-34-securityManager/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-408-manual-provider-selection/pom.xml b/surefire-integration-tests/src/test/resources/surefire-408-manual-provider-selection/pom.xml index adb30d469b..72a1c7b5cb 100644 --- a/surefire-integration-tests/src/test/resources/surefire-408-manual-provider-selection/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-408-manual-provider-selection/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/pom.xml b/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/pom.xml index da095ccb4f..f65975b3df 100644 --- a/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.example surefire-500 diff --git a/surefire-integration-tests/src/test/resources/surefire-510-testClassPath/pom.xml b/surefire-integration-tests/src/test/resources/surefire-510-testClassPath/pom.xml index dcd4c6245a..b6534c4a16 100644 --- a/surefire-integration-tests/src/test/resources/surefire-510-testClassPath/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-510-testClassPath/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/module1/pom.xml b/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/module1/pom.xml index 9b4847c4b8..d173770b54 100644 --- a/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/module1/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/module1/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/pom.xml b/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/pom.xml index d2574fce27..e69ac9df4e 100644 --- a/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/testjar/pom.xml b/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/testjar/pom.xml index f13be52164..7778331030 100644 --- a/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/testjar/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-569-RunTestFromDependencyJars/testjar/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/module1/pom.xml b/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/module1/pom.xml index 4e8f5901de..5b8fd7c33d 100644 --- a/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/module1/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/module1/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/module2/pom.xml b/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/module2/pom.xml index 67ef201a8a..9972a510dd 100644 --- a/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/module2/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/module2/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/pom.xml b/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/pom.xml index d007cf2a68..0bd6b91036 100644 --- a/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-570-multipleReportDirectories/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire-report surefire-570-multipleReportDirectories diff --git a/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/pom.xml b/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/pom.xml index a4531b674c..02a2dc8702 100644 --- a/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire junit4-test diff --git a/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml b/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml index d37d7a361f..d6ed765411 100644 --- a/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire surefire-test diff --git a/surefire-integration-tests/src/test/resources/surefire-628-consoleoutputbeforeandafterclass/pom.xml b/surefire-integration-tests/src/test/resources/surefire-628-consoleoutputbeforeandafterclass/pom.xml index 8a23ac66f5..571e7fb71d 100644 --- a/surefire-integration-tests/src/test/resources/surefire-628-consoleoutputbeforeandafterclass/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-628-consoleoutputbeforeandafterclass/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire junit4-test diff --git a/surefire-integration-tests/src/test/resources/surefire-634-systemPropertiesWarning/pom.xml b/surefire-integration-tests/src/test/resources/surefire-634-systemPropertiesWarning/pom.xml index 44036a7f3c..cc023ec5f0 100644 --- a/surefire-integration-tests/src/test/resources/surefire-634-systemPropertiesWarning/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-634-systemPropertiesWarning/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-649-systemProperties/pom.xml b/surefire-integration-tests/src/test/resources/surefire-649-systemProperties/pom.xml index c07b49add0..378f5fab93 100644 --- a/surefire-integration-tests/src/test/resources/surefire-649-systemProperties/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-649-systemProperties/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-649-systemPropertyVariables/pom.xml b/surefire-integration-tests/src/test/resources/surefire-649-systemPropertyVariables/pom.xml index e22209c700..18b402d0e7 100644 --- a/surefire-integration-tests/src/test/resources/surefire-649-systemPropertyVariables/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-649-systemPropertyVariables/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-673-mockito/pom.xml b/surefire-integration-tests/src/test/resources/surefire-673-mockito/pom.xml index eb38cd7cf7..72eb549e13 100644 --- a/surefire-integration-tests/src/test/resources/surefire-673-mockito/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-673-mockito/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire MockitoTest diff --git a/surefire-integration-tests/src/test/resources/surefire-674-buildFailingWhenErrors/pom.xml b/surefire-integration-tests/src/test/resources/surefire-674-buildFailingWhenErrors/pom.xml index c17f55effb..2b7a8b0285 100644 --- a/surefire-integration-tests/src/test/resources/surefire-674-buildFailingWhenErrors/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-674-buildFailingWhenErrors/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire buildFailingWhenErrors diff --git a/surefire-integration-tests/src/test/resources/surefire-685-commaseparatedIncludes/pom.xml b/surefire-integration-tests/src/test/resources/surefire-685-commaseparatedIncludes/pom.xml index d64b1e767e..5e6d2724d3 100644 --- a/surefire-integration-tests/src/test/resources/surefire-685-commaseparatedIncludes/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-685-commaseparatedIncludes/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/pom.xml b/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/pom.xml index bd4fd1cfc6..9f1872cd0a 100644 --- a/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-697-niceSummary/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/pom.xml b/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/pom.xml index c091594d51..da2299e970 100644 --- a/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-740-comma-truncated/pom.xml b/surefire-integration-tests/src/test/resources/surefire-740-comma-truncated/pom.xml index f6e60a0325..5291cc6fe8 100644 --- a/surefire-integration-tests/src/test/resources/surefire-740-comma-truncated/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-740-comma-truncated/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-772-both-reports/pom.xml b/surefire-integration-tests/src/test/resources/surefire-772-both-reports/pom.xml index dcbbf94fda..6ce429f5f6 100644 --- a/surefire-integration-tests/src/test/resources/surefire-772-both-reports/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-772-both-reports/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-772-no-failsafe-reports/pom.xml b/surefire-integration-tests/src/test/resources/surefire-772-no-failsafe-reports/pom.xml index ed420c84e4..5aa8b9375c 100644 --- a/surefire-integration-tests/src/test/resources/surefire-772-no-failsafe-reports/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-772-no-failsafe-reports/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-772-no-reports/pom.xml b/surefire-integration-tests/src/test/resources/surefire-772-no-reports/pom.xml index 6ff2b8efdf..ab991666f3 100644 --- a/surefire-integration-tests/src/test/resources/surefire-772-no-reports/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-772-no-reports/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-772-no-surefire-reports/pom.xml b/surefire-integration-tests/src/test/resources/surefire-772-no-surefire-reports/pom.xml index bc716f1450..1d8df093ba 100644 --- a/surefire-integration-tests/src/test/resources/surefire-772-no-surefire-reports/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-772-no-surefire-reports/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-772-specified-reports/pom.xml b/surefire-integration-tests/src/test/resources/surefire-772-specified-reports/pom.xml index 01151b9377..c44effd46d 100644 --- a/surefire-integration-tests/src/test/resources/surefire-772-specified-reports/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-772-specified-reports/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-806-specifiedTests-multi/pom.xml b/surefire-integration-tests/src/test/resources/surefire-806-specifiedTests-multi/pom.xml index 856708bb05..7b09393c31 100644 --- a/surefire-integration-tests/src/test/resources/surefire-806-specifiedTests-multi/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-806-specifiedTests-multi/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-806-specifiedTests-single/pom.xml b/surefire-integration-tests/src/test/resources/surefire-806-specifiedTests-single/pom.xml index b7ae5ff1ff..717417f184 100644 --- a/surefire-integration-tests/src/test/resources/surefire-806-specifiedTests-single/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-806-specifiedTests-single/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/pom.xml b/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/pom.xml index ea2ad63203..68ed936d7d 100644 --- a/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/pom.xml b/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/pom.xml index f7eaa72812..f229292887 100644 --- a/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/pom.xml @@ -10,7 +10,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-812-log4j-classloader/pom.xml b/surefire-integration-tests/src/test/resources/surefire-812-log4j-classloader/pom.xml index ea6d1640bd..2da8cc3b28 100644 --- a/surefire-integration-tests/src/test/resources/surefire-812-log4j-classloader/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-812-log4j-classloader/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire log4jClassloader diff --git a/surefire-integration-tests/src/test/resources/surefire-817-system-exit/pom.xml b/surefire-integration-tests/src/test/resources/surefire-817-system-exit/pom.xml index 4809487eee..8a27298bad 100644 --- a/surefire-integration-tests/src/test/resources/surefire-817-system-exit/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-817-system-exit/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml b/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml index 2438abc111..4207278383 100644 --- a/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml b/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml index 92515ef022..ea83f5daec 100644 --- a/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml @@ -10,7 +10,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/pom.xml b/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/pom.xml index 2d80ceaa1b..afabbbe8a9 100644 --- a/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-832-provider-selection/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml index bca3e1e909..fdc17fc92c 100644 --- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/pom.xml b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/pom.xml index 1635a678d0..c6e15fc3c1 100644 --- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/pom.xml b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/pom.xml index 5dea1b0d04..61502c8d52 100644 --- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-930-failsafe-runtests/pom.xml b/surefire-integration-tests/src/test/resources/surefire-930-failsafe-runtests/pom.xml index d783e10559..683628a590 100644 --- a/surefire-integration-tests/src/test/resources/surefire-930-failsafe-runtests/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-930-failsafe-runtests/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins diff --git a/surefire-integration-tests/src/test/resources/surefire-946-killMainProcessInReusableFork/pom.xml b/surefire-integration-tests/src/test/resources/surefire-946-killMainProcessInReusableFork/pom.xml index eb0fe599d9..fa8fd48196 100644 --- a/surefire-integration-tests/src/test/resources/surefire-946-killMainProcessInReusableFork/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-946-killMainProcessInReusableFork/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml index d5e9fbcf8e..fa075ab2d0 100644 --- a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 class-rule-boom-boom diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml index e9f44e3e6e..8eaf1873c1 100644 --- a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 class-rule diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml index be4df33902..711048ee97 100644 --- a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire class-rule-boom diff --git a/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/pom.xml b/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/pom.xml index 705d388533..dd6ec41a7e 100755 --- a/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 encoding-bug diff --git a/surefire-integration-tests/src/test/resources/surefire-985-parameterized-and-categories/pom.xml b/surefire-integration-tests/src/test/resources/surefire-985-parameterized-and-categories/pom.xml index 71d26cd58e..ba90b5b300 100644 --- a/surefire-integration-tests/src/test/resources/surefire-985-parameterized-and-categories/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-985-parameterized-and-categories/pom.xml @@ -11,7 +11,7 @@ License for the ~ specific language governing permissions and limitations ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/surefire-995-categoryInheritance/pom.xml b/surefire-integration-tests/src/test/resources/surefire-995-categoryInheritance/pom.xml index 7245ccbe36..d483c43bbc 100644 --- a/surefire-integration-tests/src/test/resources/surefire-995-categoryInheritance/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-995-categoryInheritance/pom.xml @@ -18,7 +18,7 @@ ~ under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/system-properties/pom.xml b/surefire-integration-tests/src/test/resources/system-properties/pom.xml index 70d056afd0..0fcfb22d50 100644 --- a/surefire-integration-tests/src/test/resources/system-properties/pom.xml +++ b/surefire-integration-tests/src/test/resources/system-properties/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-afterSuiteFailure/pom.xml b/surefire-integration-tests/src/test/resources/testng-afterSuiteFailure/pom.xml index f738827a47..5ad8dbcacb 100644 --- a/surefire-integration-tests/src/test/resources/testng-afterSuiteFailure/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-afterSuiteFailure/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-beforeMethod/pom.xml b/surefire-integration-tests/src/test/resources/testng-beforeMethod/pom.xml index af46b6bcdc..277024a8d0 100644 --- a/surefire-integration-tests/src/test/resources/testng-beforeMethod/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-beforeMethod/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-beforeMethodFailure/pom.xml b/surefire-integration-tests/src/test/resources/testng-beforeMethodFailure/pom.xml index bda724c9b6..f05f3690ed 100644 --- a/surefire-integration-tests/src/test/resources/testng-beforeMethodFailure/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-beforeMethodFailure/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-execute-error/pom.xml b/surefire-integration-tests/src/test/resources/testng-execute-error/pom.xml index ae1a1d1e60..c6809dca11 100644 --- a/surefire-integration-tests/src/test/resources/testng-execute-error/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-execute-error/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-group-thread-parallel/pom.xml b/surefire-integration-tests/src/test/resources/testng-group-thread-parallel/pom.xml index f0ad40c8eb..5cb7c0fb8f 100644 --- a/surefire-integration-tests/src/test/resources/testng-group-thread-parallel/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-group-thread-parallel/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/testng-groups/pom.xml b/surefire-integration-tests/src/test/resources/testng-groups/pom.xml index 5ef5e4fc95..5abccb2b01 100644 --- a/surefire-integration-tests/src/test/resources/testng-groups/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-groups/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-jdk14/pom.xml b/surefire-integration-tests/src/test/resources/testng-jdk14/pom.xml index 5f9dcd89aa..c7bc3c3e53 100644 --- a/surefire-integration-tests/src/test/resources/testng-jdk14/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-jdk14/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-junit-together/pom.xml b/surefire-integration-tests/src/test/resources/testng-junit-together/pom.xml index dac6b9b6cf..295d1cb82d 100644 --- a/surefire-integration-tests/src/test/resources/testng-junit-together/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-junit-together/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-junit4-together/pom.xml b/surefire-integration-tests/src/test/resources/testng-junit4-together/pom.xml index d7700a4a18..afe9f050d6 100644 --- a/surefire-integration-tests/src/test/resources/testng-junit4-together/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-junit4-together/pom.xml @@ -19,7 +19,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml b/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml index 975eff5ece..809c4b7af9 100644 --- a/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-method-pattern-after/pom.xml b/surefire-integration-tests/src/test/resources/testng-method-pattern-after/pom.xml index 4cb27c6f31..760211d673 100644 --- a/surefire-integration-tests/src/test/resources/testng-method-pattern-after/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-method-pattern-after/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml b/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml index 4cb27c6f31..760211d673 100644 --- a/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-method-pattern/pom.xml b/surefire-integration-tests/src/test/resources/testng-method-pattern/pom.xml index 4cb27c6f31..760211d673 100644 --- a/surefire-integration-tests/src/test/resources/testng-method-pattern/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-method-pattern/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-multiple-method-patterns/pom.xml b/surefire-integration-tests/src/test/resources/testng-multiple-method-patterns/pom.xml index f1a554baee..84378e8428 100644 --- a/surefire-integration-tests/src/test/resources/testng-multiple-method-patterns/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-multiple-method-patterns/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-parallel-suites/pom.xml b/surefire-integration-tests/src/test/resources/testng-parallel-suites/pom.xml index d9d0a315ff..c90c6e0724 100644 --- a/surefire-integration-tests/src/test/resources/testng-parallel-suites/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-parallel-suites/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/testng-parallel-with-annotations/pom.xml b/surefire-integration-tests/src/test/resources/testng-parallel-with-annotations/pom.xml index 58c275cc01..ca93853f47 100644 --- a/surefire-integration-tests/src/test/resources/testng-parallel-with-annotations/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-parallel-with-annotations/pom.xml @@ -10,7 +10,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-path with spaces/pom.xml b/surefire-integration-tests/src/test/resources/testng-path with spaces/pom.xml index 88eb6da047..5f2e8e760e 100644 --- a/surefire-integration-tests/src/test/resources/testng-path with spaces/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-path with spaces/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-simple/pom.xml b/surefire-integration-tests/src/test/resources/testng-simple/pom.xml index bad11784f5..2fcdfde050 100644 --- a/surefire-integration-tests/src/test/resources/testng-simple/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-simple/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-single-method-5-14-9/pom.xml b/surefire-integration-tests/src/test/resources/testng-single-method-5-14-9/pom.xml index 7539000ca9..1f84839577 100644 --- a/surefire-integration-tests/src/test/resources/testng-single-method-5-14-9/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-single-method-5-14-9/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-single-method/pom.xml b/surefire-integration-tests/src/test/resources/testng-single-method/pom.xml index 965fc55416..e2fbaa7bcc 100644 --- a/surefire-integration-tests/src/test/resources/testng-single-method/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-single-method/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-succes-percentage/pom.xml b/surefire-integration-tests/src/test/resources/testng-succes-percentage/pom.xml index 1d2cfbd875..4e74bd8a36 100644 --- a/surefire-integration-tests/src/test/resources/testng-succes-percentage/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-succes-percentage/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/testng-suite-xml/pom.xml b/surefire-integration-tests/src/test/resources/testng-suite-xml/pom.xml index f51bb49f62..96438a08ef 100644 --- a/surefire-integration-tests/src/test/resources/testng-suite-xml/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-suite-xml/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml b/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml index 37d77bf583..abdf7a1230 100644 --- a/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml +++ b/surefire-integration-tests/src/test/resources/testng-twoTestCaseSuite/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/timeout-forked/pom.xml b/surefire-integration-tests/src/test/resources/timeout-forked/pom.xml index d1bf628e08..ef9ea09c2f 100644 --- a/surefire-integration-tests/src/test/resources/timeout-forked/pom.xml +++ b/surefire-integration-tests/src/test/resources/timeout-forked/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/unicode-testnames/pom.xml b/surefire-integration-tests/src/test/resources/unicode-testnames/pom.xml index 1056c79212..2a385b5e5f 100644 --- a/surefire-integration-tests/src/test/resources/unicode-testnames/pom.xml +++ b/surefire-integration-tests/src/test/resources/unicode-testnames/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-integration-tests/src/test/resources/webapp/pom.xml b/surefire-integration-tests/src/test/resources/webapp/pom.xml index a9b0c399d3..677763746d 100644 --- a/surefire-integration-tests/src/test/resources/webapp/pom.xml +++ b/surefire-integration-tests/src/test/resources/webapp/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.surefire.its webapp diff --git a/surefire-integration-tests/src/test/resources/working-directory-is-invalid-property/pom.xml b/surefire-integration-tests/src/test/resources/working-directory-is-invalid-property/pom.xml index b079009d9c..40366abe49 100644 --- a/surefire-integration-tests/src/test/resources/working-directory-is-invalid-property/pom.xml +++ b/surefire-integration-tests/src/test/resources/working-directory-is-invalid-property/pom.xml @@ -19,7 +19,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 localhost working-directory-test diff --git a/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml b/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml index 04c7490da6..677f6d3ce6 100644 --- a/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml +++ b/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml @@ -19,7 +19,7 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 localhost working-directory-test diff --git a/surefire-integration-tests/src/test/resources/working-directory/child/pom.xml b/surefire-integration-tests/src/test/resources/working-directory/child/pom.xml index bca882c7d5..bdfbed8c6f 100644 --- a/surefire-integration-tests/src/test/resources/working-directory/child/pom.xml +++ b/surefire-integration-tests/src/test/resources/working-directory/child/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 diff --git a/surefire-integration-tests/src/test/resources/working-directory/pom.xml b/surefire-integration-tests/src/test/resources/working-directory/pom.xml index 80e97b3afb..88d7f46e3a 100644 --- a/surefire-integration-tests/src/test/resources/working-directory/pom.xml +++ b/surefire-integration-tests/src/test/resources/working-directory/pom.xml @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.maven.plugins.surefire diff --git a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLogger.java b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLogger.java index 6baa7e31c1..34a8f83be3 100644 --- a/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLogger.java +++ b/surefire-logger-api/src/main/java/org/apache/maven/plugin/surefire/log/api/ConsoleLogger.java @@ -21,16 +21,13 @@ /** * Allows providers to write console messages on the running maven process. - *

    + *
    * This output is associated with the entire test run and not a specific * test, which means it just goes "straight" to the console "immediately". - *

    - * s*

    - *

    + *
    * This interface is used in org.apache.maven.plugin.surefire.CommonReflector and reflected * via IsolatedClassLoader which can see classes from JRE only. This interface MUST use * JRE types in method signatures, e.g. {@link String} or {@link Throwable}, etc. - *

    */ public interface ConsoleLogger { 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 06f0fcace9..2a17bcba5c 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 @@ -46,8 +46,9 @@ public class JUnit4RunListener protected final RunListener reporter; /** - * This flag is set after a failure has occurred so that a testSucceeded event is not fired. - * This is necessary because JUnit4 always fires a testRunFinished event-- even if there was a failure. + * This flag is set after a failure has occurred so that a {@link RunListener#testSucceeded} event is not fired. + * This is necessary because JUnit4 always fires a {@link org.junit.runner.notification.RunListener#testRunFinished} + * event-- even if there was a failure. */ private final ThreadLocal failureFlag = new InheritableThreadLocal(); diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java index 36096e4333..228ca6d2c7 100644 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java +++ b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java @@ -45,7 +45,7 @@ public FilterFactory( ClassLoader testClassLoader ) } /** - * @return true if non-blank + * @return {@code true} if non-blank * {@link org.apache.maven.surefire.booter.ProviderParameterNames#TESTNG_GROUPS_PROP} and/or * {@link org.apache.maven.surefire.booter.ProviderParameterNames#TESTNG_EXCLUDEDGROUPS_PROP} exists. */ 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 a07caaa234..4051e19fa5 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 @@ -24,7 +24,7 @@ /** * A stacktrace writer that requires at least junit 4.6 to run. Note that we only use this for 4.8 and higher - *

    + *
    * Writes out a specific {@link org.junit.runner.notification.Failure} for * surefire as a stacktrace. * 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 8095dbfd06..56e3e1a615 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 @@ -32,7 +32,7 @@ /** * Handles responses from concurrent junit - *

    + *
    * Stuff to remember about JUnit threading: * parallel=classes; beforeClass/afterClass, constructor and all tests method run on same thread * parallel=methods; beforeClass/afterClass run on main thread, constructor + each test method run on same thread diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCore.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCore.java index 9935d9aa8f..ef1d63f991 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCore.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCore.java @@ -32,7 +32,7 @@ * * @author Tibor Digana (tibor17) * @since 2.19 - * @see https://github.com/junit-team/junit/issues/1186 + * @see JUnit issue 1186 */ class JUnitCore { diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java index 6a7a2488b2..52aec92caa 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java @@ -117,10 +117,11 @@ public boolean isParallelSuites() } /** - * @deprecated Instead use the expression ( {@link #isParallelMethods()} && {@link #isParallelClasses()} ). + * @deprecated Instead use the expression isParallelMethods() && isParallelClasses(). + * @return {@code true} if classes and methods are both parallel */ @Deprecated - @SuppressWarnings( { "unused", "deprecation" } ) + @SuppressWarnings( "unused" ) public boolean isParallelBoth() { return isParallelMethods() && isParallelClasses(); 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 98b87ef5ab..e32e32ce66 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 @@ -32,7 +32,7 @@ /** * Noteworthy things about JUnit4 listening: - *

    + *
    * A class that is annotated with @Ignore will have one invocation of "testSkipped" with source==name * A method that is annotated with @Ignore will have a invocation of testSkipped with source and name distinct * Methods annotated with @Ignore trigger no further events. 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 ef70027abe..7bba28c9d6 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 @@ -29,7 +29,7 @@ /** * Represents the test-state of a single test method that is run. - *

    + *
    * Notes about thread safety: This instance is serially confined to 1-3 threads (construction, test-run, reporting), * without any actual parallel access */ diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ThreadSafe.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ThreadSafe.java index 4f28775c67..2eaf90af94 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ThreadSafe.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ThreadSafe.java @@ -27,7 +27,7 @@ /** * After compiling sources under endorsed junit:4.7, this annotation - * is relocated in {@link org.junit.runner.notification.RunListener.ThreadSafe}. + * is relocated in org.junit.runner.notification.RunListener.ThreadSafe. */ @Documented @Target( ElementType.TYPE ) diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java index 873ccfd275..ec93dba94e 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java @@ -22,7 +22,7 @@ /** * The Balancer controls the maximum of concurrent threads in the current Scheduler(s) and prevents * from own thread resources exhaustion if other group of schedulers share the same pool of threads. - *

    + *
    * If a permit is available, {@link #acquirePermit()} simply returns and a new test is scheduled * by {@link Scheduler#schedule(Runnable)} in the current runner. Otherwise waiting for a release. * One permit is released as soon as the child thread has finished. @@ -36,7 +36,7 @@ public interface Balancer /** * Acquires a permit from this balancer, blocking until one is available. * - * @return true if current thread is NOT interrupted + * @return {@code true} if current thread is NOT interrupted * while waiting for a permit. */ boolean acquirePermit(); diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/BalancerFactory.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/BalancerFactory.java index e4c36e344a..82a9a463b2 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/BalancerFactory.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/BalancerFactory.java @@ -32,6 +32,7 @@ private BalancerFactory() /** * Infinite permits. + * @return Balancer wih infinite permits */ public static Balancer createInfinitePermitsBalancer() { @@ -43,6 +44,7 @@ public static Balancer createInfinitePermitsBalancer() * Fairness guarantees the waiting schedulers to wake up in order they acquired a permit. * * @param concurrency number of permits to acquire when maintaining concurrency on tests + * @return Balancer with given number of permits */ public static Balancer createBalancer( int concurrency ) { @@ -54,6 +56,7 @@ public static Balancer createBalancer( int concurrency ) * Fairness guarantees the waiting schedulers to wake up in order they acquired a permit. * * @param concurrency number of permits to acquire when maintaining concurrency on tests + * @return Balancer with given number of permits */ public static Balancer createBalancerWithFairness( int concurrency ) { diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ExecutionStatus.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ExecutionStatus.java index 2afc012576..07c21c9551 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ExecutionStatus.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ExecutionStatus.java @@ -20,7 +20,7 @@ */ /** - * Status of {@link ParallelComputer ParallelComputer runtime}.

    + * Status of {@link ParallelComputer ParallelComputer runtime}.
    * Used together with shutdown hook. * * @author Tibor Digana (tibor17) diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java index 0b35765c08..92ee18c547 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java @@ -56,6 +56,7 @@ import static org.apache.maven.surefire.junitcore.pc.Type.METHODS; import static org.apache.maven.surefire.junitcore.pc.Type.SUITES; +@SuppressWarnings( { "javadoc", "checkstyle:javadoctype" } ) /** * Executing suites, classes and methods with defined concurrency. In this example the threads which completed * the suites and classes can be reused in parallel methods. @@ -70,9 +71,9 @@ * Note that the type has always at least one thread even if unspecified. The capacity in * {@link ParallelComputerBuilder#useOnePool(int)} must be greater than the number of concurrent suites and classes * altogether. - *

    + *
    * The Computer can be stopped in a separate thread. Pending tests will be interrupted if the argument is - * true. + * {@code true}. *

      * computer.describeStopped(true);
      * 
    diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java index d9e3467a55..e70fc6ff67 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java @@ -30,7 +30,8 @@ /** * An algorithm which configures {@link ParallelComputer} with allocated thread resources by given * {@link org.apache.maven.surefire.junitcore.JUnitCoreParameters}. - * The AbstractSurefireMojo has to provide correct combinations of thread-counts and parallel. + * The {@code AbstractSurefireMojo} has to provide correct combinations of thread-counts and + * configuration parameter {@code parallel}. * * @author Tibor Digana (tibor17) * @see org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder 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 3c21409fb3..cf2b7ac4b6 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 @@ -36,10 +36,10 @@ /** * Schedules tests, controls thread resources, awaiting tests and other schedulers finished, and * a master scheduler can shutdown slaves. - *

    + *
    * The scheduler objects should be first created (and wired) and set in runners * {@link org.junit.runners.ParentRunner#setScheduler(org.junit.runners.model.RunnerScheduler)}. - *

    + *
    * A new instance of scheduling strategy should be passed to the constructor of this scheduler. * * @author Tibor Digana (tibor17) @@ -68,9 +68,13 @@ public class Scheduler /** * Use e.g. parallel classes have own non-shared thread pool, and methods another pool. - *

    + *
    * You can use it with one infinite thread pool shared in strategies across all * suites, class runners, etc. + * + * @param logger console logger + * @param description JUnit description of class + * @param strategy scheduling strategy */ public Scheduler( ConsoleStream logger, Description description, SchedulingStrategy strategy ) { @@ -79,10 +83,10 @@ public Scheduler( ConsoleStream logger, Description description, SchedulingStrat /** * Should be used if schedulers in parallel children and parent use one instance of bounded thread pool. - *

    + *
    * Set this scheduler in a e.g. one suite of classes, then every individual class runner should reference - * {@link Scheduler(ConsoleStream, org.junit.runner.Description, Scheduler, SchedulingStrategy)} - * or {@link Scheduler(ConsoleStream, org.junit.runner.Description, Scheduler, SchedulingStrategy, int)}. + * {@link #Scheduler(ConsoleStream, org.junit.runner.Description, Scheduler, SchedulingStrategy)} + * or {@link #Scheduler(ConsoleStream, org.junit.runner.Description, Scheduler, SchedulingStrategy, int)}. * * @param logger current logger implementation * @param description description of current runner @@ -98,9 +102,9 @@ public Scheduler( ConsoleStream logger, Description description, SchedulingStrat /** * New instances should be used by schedulers with limited concurrency by balancer * against other groups of schedulers. The schedulers share one pool. - *

    - * Unlike in {@link Scheduler(ConsoleStream, org.junit.runner.Description, SchedulingStrategy, int)} which was - * limiting the concurrency of children of a runner where this scheduler was set, this + *
    + * Unlike in {@link #Scheduler(ConsoleStream, org.junit.runner.Description, SchedulingStrategy, int)} which was + * limiting the concurrency of children of a runner where this scheduler was set, {@code this} * balancer is limiting the concurrency of all children in runners having schedulers created by this * constructor. * @@ -140,11 +144,16 @@ public Scheduler( ConsoleStream logger, Description description, Scheduler maste } /** + * @param logger console logger + * @param description JUnit description of class * @param masterScheduler a reference to - * {@link Scheduler(ConsoleStream, org.junit.runner.Description, SchedulingStrategy, int)} - * or {@link Scheduler(ConsoleStream, org.junit.runner.Description, SchedulingStrategy)} - * @see Scheduler(ConsoleStream, org.junit.runner.Description, SchedulingStrategy) - * @see Scheduler(ConsoleStream, org.junit.runner.Description, SchedulingStrategy, int) + * {@link #Scheduler(ConsoleStream, org.junit.runner.Description, SchedulingStrategy, int)} + * or {@link #Scheduler(ConsoleStream, org.junit.runner.Description, SchedulingStrategy)} + * @param strategy scheduling strategy + * @param concurrency determines maximum concurrent children scheduled a time via {@link #schedule(Runnable)} + * + * @see #Scheduler(ConsoleStream, org.junit.runner.Description, SchedulingStrategy) + * @see #Scheduler(ConsoleStream, org.junit.runner.Description, SchedulingStrategy, int) */ public Scheduler( ConsoleStream logger, Description description, Scheduler masterScheduler, SchedulingStrategy strategy, int concurrency ) @@ -157,8 +166,13 @@ public Scheduler( ConsoleStream logger, Description description, Scheduler maste /** * Should be used with individual pools on suites, classes and methods, see * {@link org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder#useSeparatePools()}. - *

    + *
    * Cached thread pool is infinite and can be always shared. + * + * @param logger console logger + * @param description JUnit description of class + * @param masterScheduler parent scheduler + * @param strategy scheduling strategy */ public Scheduler( ConsoleStream logger, Description description, Scheduler masterScheduler, SchedulingStrategy strategy ) @@ -177,7 +191,7 @@ private void setController( Controller masterController ) /** * @param slave a slave scheduler to register - * @return true if successfully registered the slave. + * @return {@code true} if successfully registered the slave. */ private boolean register( Scheduler slave ) { @@ -196,7 +210,7 @@ private boolean register( Scheduler slave ) } /** - * @return true if new tasks can be scheduled. + * @return {@code true} if new tasks can be scheduled. */ private boolean canSchedule() { @@ -226,11 +240,11 @@ protected void logQuietly( String msg ) /** * Attempts to stop all actively executing tasks and immediately returns a collection * of descriptions of those tasks which have started prior to this call. - *

    + *
    * This scheduler and other registered schedulers will stop, see {@link #register(Scheduler)}. * If shutdownNow is set, waiting methods will be interrupted via {@link Thread#interrupt}. * - * @param stopNow if true interrupts waiting test methods + * @param stopNow if {@code true} interrupts waiting test methods * @return collection of descriptions started before shutting down */ protected ShutdownResult describeStopped( boolean stopNow ) @@ -252,7 +266,7 @@ protected ShutdownResult describeStopped( boolean stopNow ) * is finished in * {@link org.junit.runners.Suite#run(org.junit.runner.notification.RunNotifier)} * all the thread-pools created by {@link ParallelComputerBuilder.PC} are already dead. - * See the unit test ParallelComputerBuilder#timeoutAndForcedShutdown(). + * See the unit test {@code ParallelComputerBuilder#timeoutAndForcedShutdown()}. * @param stopNow Interrupting tests by {@link java.util.concurrent.ExecutorService#shutdownNow()} or * {@link java.util.concurrent.Future#cancel(boolean) Future#cancel(true)} or * {@link Thread#interrupt()}. @@ -428,7 +442,7 @@ private Controller( Scheduler slave ) } /** - * @return true if new children can be scheduled. + * @return {@code true} if new children can be scheduled. */ boolean canSchedule() { diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java index 520c3125ff..b3f80ba13b 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java @@ -67,7 +67,7 @@ public static SchedulingStrategy createParallelStrategyUnbounded( ConsoleStream /** * The threadPool passed to this strategy can be shared in other strategies. - *

    + *
    * The call {@link SchedulingStrategy#finished()} is waiting until own tasks have finished. * New tasks will not be scheduled by this call in this strategy. This strategy is not * waiting for other strategies to finish. The {@link org.junit.runners.model.RunnerScheduler#finished()} may diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java index ce337bce66..d310628dec 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java @@ -27,10 +27,10 @@ /** * Specifies the strategy of scheduling whether sequential, or parallel. - * The strategy may use a thread pool shared with other strategies. - *

    + * The strategy may use a thread pool shared with other strategies. + *
    * One instance of strategy can be used just by one {@link Scheduler}. - *

    + *
    * The strategy is scheduling tasks in {@link #schedule(Runnable)} and awaiting them * completed in {@link #finished()}. Both methods should be used in one thread. * @@ -66,8 +66,8 @@ protected SchedulingStrategy( ConsoleStream logger ) * Waiting for scheduled tasks to finish. * New tasks will not be scheduled by calling this method. * - * @return true if successfully stopped the scheduler, else - * false if already stopped (a shared thread + * @return {@code true} if successfully stopped the scheduler, else + * {@code false} if already stopped (a shared thread * pool was shutdown externally). * @throws InterruptedException if interrupted while waiting * for scheduled tasks to finish @@ -78,24 +78,24 @@ protected abstract boolean finished() /** * Stops scheduling new tasks (e.g. by {@link java.util.concurrent.ExecutorService#shutdown()} - * on a private thread pool which cannot be shared with other strategy). + * on a private thread pool which cannot be shared with other strategy). * - * @return true if successfully stopped the scheduler, else - * false if already stopped (a shared thread + * @return {@code true} if successfully stopped the scheduler, else + * {@code false} if already stopped (a shared thread * pool was shutdown externally). * @see java.util.concurrent.ExecutorService#shutdown() */ protected abstract boolean stop(); /** - * Stops scheduling new tasks and interrupts running tasks + * Stops scheduling new tasks and {@code interrupts} running tasks * (e.g. by {@link java.util.concurrent.ExecutorService#shutdownNow()} on a private thread pool - * which cannot be shared with other strategy). - *

    + * which cannot be shared with other strategy). + *
    * This method calls {@link #stop()} by default. * - * @return true if successfully stopped the scheduler, else - * false if already stopped (a shared thread + * @return {@code true} if successfully stopped the scheduler, else + * {@code false} if already stopped (a shared thread * pool was shutdown externally). * @see java.util.concurrent.ExecutorService#shutdownNow() */ @@ -105,7 +105,7 @@ protected boolean stopNow() } /** - * Persistently disables this strategy. Atomically ignores {@link Balancer} to acquire a new permit.

    + * Persistently disables this strategy. Atomically ignores {@link Balancer} to acquire a new permit.
    * The method {@link #canSchedule()} atomically returns {@code false}. * @return {@code true} if {@link #canSchedule()} has return {@code true} on the beginning of this method call. */ @@ -119,13 +119,13 @@ protected void setDefaultShutdownHandler( Scheduler.ShutdownHandler handler ) } /** - * @return true if a thread pool associated with this strategy + * @return {@code true} if a thread pool associated with this strategy * can be shared with other strategies. */ protected abstract boolean hasSharedThreadPool(); /** - * @return true unless stopped, finished or disabled. + * @return {@code true} unless stopped, finished or disabled. */ protected boolean canSchedule() { diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java index a0f5c2da59..8e61fa3cc9 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java @@ -33,8 +33,8 @@ import java.util.concurrent.TimeUnit; /** - * Used to execute tests annotated with {@link net.jcip.annotations.NotThreadSafe}. - *

    + * Used to execute tests annotated with net.jcip.annotations.NotThreadSafe. + *
    * * @author Tibor Digana (tibor17) * @see ParallelComputerBuilder 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 070c457b21..13f49bf038 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 @@ -48,7 +48,7 @@ final class ThreadResourcesBalancer /** * @param numPermits number of permits to acquire when maintaining concurrency on tests. * Must be >0 and < {@link Integer#MAX_VALUE}. - * @param fair true guarantees the waiting schedulers to wake up in order they acquired a permit + * @param fair {@code true} guarantees the waiting schedulers to wake up in order they acquired a permit * @throws IllegalArgumentException if numPermits is not positive number */ ThreadResourcesBalancer( int numPermits, boolean fair ) @@ -65,7 +65,7 @@ final class ThreadResourcesBalancer /** * Acquires a permit from this balancer, blocking until one is available. * - * @return true if current thread is NOT interrupted + * @return {@code true} if current thread is NOT interrupted * while waiting for a permit. */ @Override diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/WrappedRunners.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/WrappedRunners.java index ba45e747dd..707cc35181 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/WrappedRunners.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/WrappedRunners.java @@ -23,7 +23,7 @@ /** * We need to wrap runners in a suite and count children of these runners. - *

    + *
    * Old JUnit versions do not cache children after the first call of * {@link org.junit.runners.ParentRunner#getChildren()}. * Due to performance reasons, the children have to be observed just once. 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 b883d09399..3e139e1fc2 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 @@ -27,15 +27,15 @@ * {@code * TestCase that expose "No tests were executed!" on Test failure using Maven Surefire 2.6-SNAPSHOT * and the JUnit 4.7 Runner. - *

    + *
    * ------------------------------------------------------- * T E S T S * ------------------------------------------------------- - *

    + *
    * Results: - *

    + *
    * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 - *

    + *
    * [INFO] ------------------------------------------------------------------------ * [INFO] BUILD FAILURE * [INFO] ------------------------------------------------------------------------ @@ -46,15 +46,15 @@ * [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.5:test * (default-test) on project xxxxxx: No tests were executed! (Set -DfailIfNoTests=false to * ignore this error.) -> [Help 1] - *

    - *

    + *
    + *
    * * junit * junit * 4.8.1 * test * - *

    + *
    * * org.apache.maven.surefire * surefire-booter @@ -90,7 +90,7 @@ public class MavenSurefireJUnit47RunnerTest * JUnits ParentRunner is responsible for adding the BeforeClass/AfterClass statements to the * statement execution chain. After BeforeClass is executed, a Statement that delegates to the * abstract method: runChild(T child, RunNotifier notifier) is called. As the JavaDoc explains: - * "Subclasses are responsible for making sure that relevant test events are reported through {@code notifier}". + * "Subclasses are responsible for making sure that relevant test events are reported through notifier". * When a @BeforeClass fail, the child that should handle the relevant test events(Started, Failed, Finished) * is never executed. * 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 08e16958e7..1faa78246f 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 @@ -27,15 +27,15 @@ * TestCase that expose "No tests were executed!" on Test failure using Maven Surefire 2.6-SNAPSHOT * and the JUnit 4.8 Runner. * {@code - * *

    + * *
    * ------------------------------------------------------- * T E S T S * ------------------------------------------------------- - *

    + *
    * Results: - *

    + *
    * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 - *

    + *
    * [INFO] ------------------------------------------------------------------------ * [INFO] BUILD FAILURE * [INFO] ------------------------------------------------------------------------ @@ -46,15 +46,15 @@ * [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.5:test * (default-test) on project xxxxxx: No tests were executed! (Set -DfailIfNoTests=false to * ignore this error.) -> [Help 1] - *

    - *

    + *
    + *
    * * junit * junit * 4.8.1 * test * - *

    + *
    * * org.apache.maven.surefire * surefire-booter @@ -90,7 +90,7 @@ public class MavenSurefireJUnit48RunnerTest * JUnits ParentRunner is responsible for adding the BeforeClass/AfterClass statements to the * statement execution chain. After BeforeClass is executed, a Statement that delegates to the * abstract method: runChild(T child, RunNotifier notifier) is called. As the JavaDoc explains: - * "Subclasses are responsible for making sure that relevant test events are reported through {@code notifier}". + * "Subclasses are responsible for making sure that relevant test events are reported through notifier". * When a @BeforeClass fail, the child that should handle the relevant test events(Started, Failed, Finished) * is never executed. * diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java index 3e9ca93d55..eb5534eaeb 100644 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java +++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java @@ -54,7 +54,7 @@ * 4.8.1 * test * - *

    + *
    * * org.apache.maven.surefire * surefire-booter 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 812355f00e..0f1ac1ad58 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 @@ -33,13 +33,13 @@ /** * Tests the factories in SchedulingStrategy. - *

    + *
    * Th point of these tests is to check {@link Task#result} if changed - * from false to true after all scheduled tasks + * from {@code false} to {@code true} after all scheduled tasks * have finished. * The call {@link SchedulingStrategy#finished()} is waiting until the * strategy has finished. - * Then {@link Task#result} should be asserted that is true. + * Then {@link Task#result} should be asserted that is {@code true}. * * @author Tibor Digana (tibor17) * @see SchedulingStrategy 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 d55c079242..2cd2f4893d 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 @@ -30,7 +30,6 @@ * For internal use only * * @author Olivier Lamy - * @noinspection UnusedDeclaration * @since 2.7.3 */ public class MethodSelector diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/Stoppable.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/Stoppable.java index dd172d2007..e4fe304420 100644 --- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/Stoppable.java +++ b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/Stoppable.java @@ -20,7 +20,7 @@ */ /** - * Covers configuration parameter skipAfterFailureCount. + * Covers configuration parameter {@code skipAfterFailureCount}. * * @author Tibor Digana (tibor17) * @since 2.19 diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java index 956a9d9ea2..dd646b6be6 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java @@ -28,7 +28,6 @@ * Just like TestNGReporter, but explicitly implements IResultListener; this interface is new in TestNG 5.5 * * @author Dan Fabulich - * @noinspection UnusedDeclaration */ public class ConfigurationAwareTestNGReporter extends TestNGReporter 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 a8a383754d..14e103a189 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 @@ -51,7 +51,6 @@ /** * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ public class TestNGProvider extends AbstractProvider 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 d7d5ff9462..19cd22d394 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 @@ -40,7 +40,6 @@ * {@link org.apache.maven.surefire.report.RunListener}. * * @author jkuhnert - * @noinspection ThrowableResultOfMethodCallIgnored */ public class TestNGReporter implements ITestListener, ISuiteListener @@ -50,8 +49,8 @@ public class TestNGReporter /** * Constructs a new instance that will listen to * test updates from a {@link org.testng.TestNG} class instance. - *

    - *

    It is assumed that the requisite {@link org.testng.TestNG#addListener(ITestListener)} + *
    + *
    It is assumed that the requisite {@link org.testng.TestNG#addListener(ITestListener)} * method call has already associated with this instance before the test * suite is run. * diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG4751Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG4751Configurator.java index 081b53290b..9955f44f29 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG4751Configurator.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG4751Configurator.java @@ -23,14 +23,14 @@ /** * TestNG 4.7 and 5.1 configurator. - *

    + *
    * Allowed options: * -groups * -excludedgroups * -junit (boolean) * -threadcount (int) * -parallel (boolean) - *

    + *
    * * @author Alex Popescu */ 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 b00378988e..ff164fb388 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 @@ -22,7 +22,7 @@ import org.apache.maven.surefire.testset.TestSetFailedException; /** - * TestNG 5.13 configurator. Changed: "reporterslist" need String instead of List. + * TestNG 5.13 configurator. Changed: "reporterslist" need String instead of List<ReporterConfig>. */ public class TestNG513Configurator extends TestNG510Configurator diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java index 5575ccf035..15a46a81b6 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java @@ -24,7 +24,7 @@ /** * TestNG 5.14.3 configurator. Changed: "reporterslist" replaced by "reporter", - * and "listener" can use String instead of List. + * and "listener" can use String instead of List<Class>. */ public class TestNG5143Configurator extends TestNG5141Configurator diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG52Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG52Configurator.java index 28c802f138..44da34125a 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG52Configurator.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG52Configurator.java @@ -23,14 +23,14 @@ /** * TestNG 5.2 configurator. - *

    + *
    * Allowed options: * -groups * -excludedgroups * -junit (boolean) * -threadcount (int) * -parallel (String) - *

    + *
    * * @author Alex Popescu */ 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 b819298e59..c51aca6cc6 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 @@ -35,13 +35,13 @@ /** * TestNG configurator for 5.3+ versions. TestNG exposes a {@link org.testng.TestNG#configure(java.util.Map)} method. - * All suppported TestNG options are passed in String format, except - * TestNGCommandLineArgs.LISTENER_COMMAND_OPT which is List>Class<, - * TestNGCommandLineArgs.JUNIT_DEF_OPT which is a Boolean, - * TestNGCommandLineArgs.SKIP_FAILED_INVOCATION_COUNT_OPT which is a Boolean, - * TestNGCommandLineArgs.OBJECT_FACTORY_COMMAND_OPT which is a Class, - * TestNGCommandLineArgs.REPORTERS_LIST which is a List>ReporterConfig<. - *

    + * All supported TestNG options are passed in String format, except + * {@link org.testng.TestNGCommandLineArgs#LISTENER_COMMAND_OPT} which is {@link java.util.List List>Class<}, + * {@link org.testng.TestNGCommandLineArgs#JUNIT_DEF_OPT} which is a {@link Boolean}, + * {@link org.testng.TestNGCommandLineArgs#SKIP_FAILED_INVOCATION_COUNT_OPT} which is a {@link Boolean}, + * {@link org.testng.TestNGCommandLineArgs#OBJECT_FACTORY_COMMAND_OPT} which is a {@link Class}, + * {@link org.testng.TestNGCommandLineArgs#REPORTERS_LIST} which is a {@link java.util.List List>ReporterConfig<}. + *
    * Test classes and/or suite files are not passed along as options parameters, but configured separately. * * @author Alex Popescu From 2fbce0045dd02ecd2236dc2bd77903aea0a80e56 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Thu, 4 May 2017 04:43:01 +0200 Subject: [PATCH 087/194] comment for jira SUREFIRE-1366 --- maven-failsafe-plugin/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index 506b3c4871..ff773c7330 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -96,6 +96,12 @@ ${project.build.directory}/generated-sources/jaxb + ../maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd ../maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb org.apache.maven.plugin.failsafe.xmlsummary From 4e993a05460ef72e17a39a6e9edf9e0ef402859f Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 3 May 2017 00:43:31 +0200 Subject: [PATCH 088/194] [SUREFIRE-1364] Report XML should contain system properties of forked JVM --- .../surefire/StartupReportConfiguration.java | 19 +- .../booterclient/ForkConfiguration.java | 2 +- .../surefire/booterclient/ForkStarter.java | 14 +- .../booterclient/output/ForkClient.java | 32 ++- .../surefire/report/StatelessXmlReporter.java | 35 ++- .../surefire/report/TestSetRunListener.java | 9 +- .../surefire/report/WrappedReportEntry.java | 26 ++- .../booterclient/ForkingRunListenerTest.java | 35 ++- .../surefire/booterclient/MockReporter.java | 12 +- .../report/StatelessXmlReporterTest.java | 8 +- .../maven/surefire/JUnit4SuiteTest.java | 4 +- .../surefire/booter/ForkingRunListener.java | 24 +-- .../report/CategorizedReportEntry.java | 20 +- .../maven/surefire/report/RunListener.java | 4 +- .../surefire/report/SimpleReportEntry.java | 36 +++- .../surefire/report/TestSetReportEntry.java | 35 +++ .../surefire/util/internal}/ImmutableMap.java | 9 +- .../surefire/util/internal/ObjectUtils.java | 88 +++++++- .../org/apache/maven/JUnit4SuiteTest.java | 4 +- .../util/internal}/ImmutableMapTest.java | 4 +- .../jiras/Surefire1364SystemPropertiesIT.java | 203 ++++++++++++++++++ .../src/test/resources/surefire-1364/pom.xml | 156 ++++++++++++++ .../src/test/java/FirstTest.java | 30 +++ .../src/test/java/SecondTest.java | 30 +++ .../src/test/java/ThirdTest.java | 30 +++ .../maven/surefire/junit4/MockReporter.java | 5 +- .../maven/surefire/junit/JUnit3Provider.java | 16 +- .../surefire/junit/JUnitTestSetTest.java | 15 +- .../maven/surefire/junit4/JUnit4Provider.java | 4 +- .../junitcore/ClassesParallelRunListener.java | 2 +- .../junitcore/ConcurrentRunListener.java | 5 +- .../junitcore/MethodsParallelRunListener.java | 2 +- .../junitcore/NonConcurrentRunListener.java | 27 ++- .../maven/surefire/junitcore/TestSet.java | 32 ++- .../maven/surefire/testng/TestSuite.java | 8 +- 35 files changed, 819 insertions(+), 166 deletions(-) create mode 100644 surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetReportEntry.java rename {maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util => surefire-api/src/main/java/org/apache/maven/surefire/util/internal}/ImmutableMap.java (94%) rename {maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util => surefire-api/src/test/java/org/apache/maven/surefire/util/internal}/ImmutableMapTest.java (96%) create mode 100644 surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1364/pom.xml create mode 100644 surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/FirstTest.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/SecondTest.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/ThirdTest.java 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 d3cca28a9d..28e7ff04f6 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 @@ -19,13 +19,6 @@ * under the License. */ -import java.io.File; -import java.io.PrintStream; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; - import org.apache.maven.plugin.surefire.report.ConsoleOutputFileReporter; import org.apache.maven.plugin.surefire.report.DirectConsoleOutput; import org.apache.maven.plugin.surefire.report.FileReporter; @@ -35,6 +28,11 @@ import org.apache.maven.plugin.surefire.runorder.StatisticsReporter; import javax.annotation.Nonnull; +import java.io.File; +import java.io.PrintStream; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import static org.apache.maven.plugin.surefire.report.ConsoleReporter.BRIEF; import static org.apache.maven.plugin.surefire.report.ConsoleReporter.PLAIN; @@ -79,8 +77,6 @@ public final class StartupReportConfiguration private final String xsdSchemaLocation; - private final Properties testVmSystemProperties = new Properties(); - private final Map>> testClassMethodRunHistory = new ConcurrentHashMap>>(); @@ -217,11 +213,6 @@ public File getStatisticsFile() return statisticsFile; } - public Properties getTestVmSystemProperties() - { - return testVmSystemProperties; - } - public boolean isTrimStackTrace() { return trimStackTrace; 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 8ff676886e..cd4ae2ba92 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,7 +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.surefire.util.internal.ImmutableMap; import org.apache.maven.plugin.surefire.util.Relocator; import org.apache.maven.shared.utils.StringUtils; import org.apache.maven.surefire.booter.Classpath; 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 7619d0b637..a2a5095c35 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 @@ -57,7 +57,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Map; -import java.util.Properties; import java.util.Queue; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.Callable; @@ -270,8 +269,7 @@ private RunResult run( SurefireProperties effectiveSystemProperties, Map ping = triggerPingTimerForShutdown( builder ); try @@ -347,10 +345,7 @@ public RunResult call() { DefaultReporterFactory reporter = new DefaultReporterFactory( startupReportConfiguration, log ); defaultReporterFactories.add( reporter ); - - Properties vmProps = startupReportConfiguration.getTestVmSystemProperties(); - - ForkClient forkClient = new ForkClient( reporter, vmProps, testProvidingInputStream, log ) + ForkClient forkClient = new ForkClient( reporter, testProvidingInputStream, log ) { @Override protected void stopOnNextTest() @@ -413,9 +408,8 @@ public RunResult call() DefaultReporterFactory forkedReporterFactory = new DefaultReporterFactory( startupReportConfiguration, log ); defaultReporterFactories.add( forkedReporterFactory ); - Properties vmProps = startupReportConfiguration.getTestVmSystemProperties(); - ForkClient forkClient = new ForkClient( forkedReporterFactory, vmProps, - builder.getImmediateCommands(), log ) + ForkClient forkClient = + new ForkClient( forkedReporterFactory, builder.getImmediateCommands(), log ) { @Override protected void stopOnNextTest() 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 b94fba6a89..17da4df093 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 @@ -27,22 +27,26 @@ import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.StackTraceWriter; +import org.apache.maven.surefire.report.TestSetReportEntry; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.StringReader; import java.nio.ByteBuffer; -import java.util.Properties; +import java.util.Collections; +import java.util.Map; 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.atomic.AtomicLong; import static java.lang.Integer.decode; import static java.lang.System.currentTimeMillis; +import static java.util.Collections.unmodifiableMap; import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_BYE; import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_CONSOLE; import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_DEBUG; @@ -83,7 +87,7 @@ public class ForkClient private final DefaultReporterFactory defaultReporterFactory; - private final Properties testVmSystemProperties; + private final Map testVmSystemProperties = new ConcurrentHashMap(); private final NotifiableTestStream notifiableTestStream; @@ -108,11 +112,10 @@ public class ForkClient // prevents from printing same warning private boolean printedErrorStream; - public ForkClient( DefaultReporterFactory defaultReporterFactory, Properties testVmSystemProperties, + public ForkClient( DefaultReporterFactory defaultReporterFactory, NotifiableTestStream notifiableTestStream, ConsoleLogger log ) { this.defaultReporterFactory = defaultReporterFactory; - this.testVmSystemProperties = testVmSystemProperties; this.notifiableTestStream = notifiableTestStream; this.log = log; } @@ -210,7 +213,7 @@ private void processLine( String event ) case BOOTERCODE_TESTSET_COMPLETED: testsInProgress.clear(); - getTestSetReporter().testSetCompleted( createReportEntry( remaining ) ); + getTestSetReporter().testSetCompleted( createReportEntry( remaining, testVmSystemProperties ) ); break; case BOOTERCODE_TEST_STARTING: ReportEntry reportEntry = createReportEntry( remaining ); @@ -254,10 +257,7 @@ private void processLine( String event ) StringBuilder value = new StringBuilder(); unescapeString( key, remaining.substring( 0, keyEnd ) ); unescapeString( value, remaining.substring( keyEnd + 1 ) ); - synchronized ( testVmSystemProperties ) - { - testVmSystemProperties.put( key.toString(), value.toString() ); - } + testVmSystemProperties.put( key.toString(), value.toString() ); break; case BOOTERCODE_STDOUT: writeTestOutput( remaining, true ); @@ -360,7 +360,12 @@ private String createConsoleMessage( String remaining ) return unescape( remaining ); } - private ReportEntry createReportEntry( String untokenized ) + private TestSetReportEntry createReportEntry( String untokenized ) + { + return createReportEntry( untokenized, Collections.emptyMap() ); + } + + private TestSetReportEntry createReportEntry( String untokenized, Map systemProperties ) { StringTokenizer tokens = new StringTokenizer( untokenized, "," ); try @@ -374,7 +379,7 @@ private ReportEntry createReportEntry( String untokenized ) final StackTraceWriter stackTraceWriter = tokens.hasMoreTokens() ? deserializeStackTraceWriter( tokens ) : null; - return reportEntry( source, name, group, stackTraceWriter, elapsed, message ); + return reportEntry( source, name, group, stackTraceWriter, elapsed, message, systemProperties ); } catch ( RuntimeException e ) { @@ -403,6 +408,11 @@ private String unescape( String source ) return stringBuffer.toString(); } + public final Map getTestVmSystemProperties() + { + return unmodifiableMap( testVmSystemProperties ); + } + /** * Used when getting reporters on the plugin side of a fork. * Used by testing purposes only. May not be volatile variable. 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 aa858f26cb..60c6dfe37f 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 @@ -39,7 +39,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Properties; +import java.util.Map.Entry; import java.util.StringTokenizer; import static org.apache.maven.plugin.surefire.report.DefaultReporterFactory.TestResultType; @@ -131,10 +131,10 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat createTestSuiteElement( ppw, testSetReportEntry, testSetStats, testSetReportEntry.elapsedTimeAsString() ); - showProperties( ppw ); + showProperties( ppw, testSetReportEntry.getSystemProperties() ); // Iterate through all the test methods in the test class - for ( Map.Entry> entry : methodRunHistoryMap.entrySet() ) + for ( Entry> entry : methodRunHistoryMap.entrySet() ) { List methodEntryList = entry.getValue(); if ( methodEntryList == null ) @@ -458,31 +458,26 @@ 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, Map systemProperties ) { xmlWriter.startElement( "properties" ); - - Properties systemProperties = System.getProperties(); - - if ( systemProperties != null ) + for ( final Entry entry : systemProperties.entrySet() ) { - for ( final String key : systemProperties.stringPropertyNames() ) - { - String value = systemProperties.getProperty( key ); + final String key = entry.getKey(); + String value = entry.getValue(); - if ( value == null ) - { - value = "null"; - } + if ( value == null ) + { + value = "null"; + } - xmlWriter.startElement( "property" ); + xmlWriter.startElement( "property" ); - xmlWriter.addAttribute( "name", key ); + xmlWriter.addAttribute( "name", key ); - xmlWriter.addAttribute( "value", extraEscape( value, true ) ); + xmlWriter.addAttribute( "value", extraEscape( value, true ) ); - xmlWriter.endElement(); - } + xmlWriter.endElement(); } xmlWriter.endElement(); } 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 eea8a7e33b..e10b8e829b 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 @@ -29,6 +29,7 @@ import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.TestSetReportEntry; import static org.apache.maven.plugin.surefire.report.ReportEntryType.ERROR; import static org.apache.maven.plugin.surefire.report.ReportEntryType.FAILURE; @@ -144,7 +145,7 @@ public void writeTestOutput( byte[] buf, int off, int len, boolean stdout ) } @Override - public void testSetStarting( ReportEntry report ) + public void testSetStarting( TestSetReportEntry report ) { detailsForThis.testSetStart(); consoleReporter.testSetStarting( report ); @@ -158,7 +159,7 @@ public void clearCapture() } @Override - public void testSetCompleted( ReportEntry report ) + public void testSetCompleted( TestSetReportEntry report ) { final WrappedReportEntry wrap = wrapTestSet( report ); final List testResults = @@ -262,11 +263,11 @@ private WrappedReportEntry wrap( ReportEntry other, ReportEntryType reportEntryT return new WrappedReportEntry( other, reportEntryType, estimatedElapsed, testStdOut, testStdErr ); } - private WrappedReportEntry wrapTestSet( ReportEntry other ) + private WrappedReportEntry wrapTestSet( TestSetReportEntry other ) { return new WrappedReportEntry( other, null, other.getElapsed() != null ? other.getElapsed() - : detailsForThis.getElapsedSinceTestSetStart(), testStdOut, testStdErr ); + : detailsForThis.getElapsedSinceTestSetStart(), testStdOut, testStdErr, other.getSystemProperties() ); } public void close() 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 439fdec2e5..402fda0fb3 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 @@ -21,14 +21,19 @@ import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.StackTraceWriter; +import org.apache.maven.surefire.report.TestSetReportEntry; +import java.util.Collections; +import java.util.Map; + +import static java.util.Collections.unmodifiableMap; import static org.apache.maven.surefire.util.internal.StringUtils.NL; /** * @author Kristian Rosenvold */ public class WrappedReportEntry - implements ReportEntry + implements TestSetReportEntry { private final ReportEntry original; @@ -40,15 +45,26 @@ public class WrappedReportEntry private final Utf8RecodingDeferredFileOutputStream stdErr; + private final Map systemProperties; + public WrappedReportEntry( ReportEntry original, ReportEntryType reportEntryType, Integer estimatedElapsed, Utf8RecodingDeferredFileOutputStream stdout, - Utf8RecodingDeferredFileOutputStream stdErr ) + Utf8RecodingDeferredFileOutputStream stdErr, + Map systemProperties ) { this.original = original; this.reportEntryType = reportEntryType; this.elapsed = estimatedElapsed; this.stdout = stdout; this.stdErr = stdErr; + this.systemProperties = unmodifiableMap( systemProperties ); + } + + public WrappedReportEntry( ReportEntry original, ReportEntryType reportEntryType, Integer estimatedElapsed, + Utf8RecodingDeferredFileOutputStream stdout, + Utf8RecodingDeferredFileOutputStream stdErr ) + { + this( original, reportEntryType, estimatedElapsed, stdout, stdErr, Collections.emptyMap() ); } @Override @@ -171,4 +187,10 @@ public String getNameWithGroup() { return original.getNameWithGroup(); } + + @Override + public Map getSystemProperties() + { + return systemProperties; + } } 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 19356f59e4..12b20872c6 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 @@ -34,16 +34,16 @@ import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; import org.apache.maven.surefire.report.StackTraceWriter; +import org.apache.maven.surefire.report.TestSetReportEntry; +import org.hamcrest.MatcherAssert; 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; @@ -94,7 +94,7 @@ public void testSetStarting() throws ReporterException, IOException { final StandardTestRun standardTestRun = new StandardTestRun(); - ReportEntry expected = createDefaultReportEntry(); + TestSetReportEntry expected = createDefaultReportEntry(); standardTestRun.run().testSetStarting( expected ); standardTestRun.assertExpected( MockReporter.SET_STARTING, expected ); } @@ -103,7 +103,7 @@ public void testSetCompleted() throws ReporterException, IOException { final StandardTestRun standardTestRun = new StandardTestRun(); - ReportEntry expected = createDefaultReportEntry(); + TestSetReportEntry expected = createDefaultReportEntry(); standardTestRun.run().testSetCompleted( expected ); standardTestRun.assertExpected( MockReporter.SET_COMPLETED, expected ); } @@ -221,27 +221,24 @@ public void testSystemProperties() createForkingRunListener( defaultChannel ); TestSetMockReporterFactory providerReporterFactory = new TestSetMockReporterFactory(); - final Properties testVmSystemProperties = new Properties(); NullConsoleLogger log = new NullConsoleLogger(); - ForkClient forkStreamClient = new ForkClient( providerReporterFactory, testVmSystemProperties, - new MockNotifiableTestStream(), log ); + ForkClient forkStreamClient = new ForkClient( providerReporterFactory, new MockNotifiableTestStream(), log ); - forkStreamClient.consumeMultiLineContent( content.toString( "utf-8" ) ); + forkStreamClient.consumeMultiLineContent( content.toString( "UTF-8" ) ); - assertThat( testVmSystemProperties.size(), is( greaterThan( 1 ) ) ); + MatcherAssert.assertThat( forkStreamClient.getTestVmSystemProperties().size(), is( greaterThan( 1 ) ) ); } public void testMultipleEntries() throws ReporterException, IOException { - final StandardTestRun standardTestRun = new StandardTestRun(); standardTestRun.run(); reset(); RunListener forkingReporter = createForkingRunListener( defaultChannel ); - ReportEntry reportEntry = createDefaultReportEntry(); + TestSetReportEntry reportEntry = createDefaultReportEntry(); forkingReporter.testSetStarting( reportEntry ); forkingReporter.testStarting( reportEntry ); forkingReporter.testSucceeded( reportEntry ); @@ -249,10 +246,9 @@ public void testMultipleEntries() TestSetMockReporterFactory providerReporterFactory = new TestSetMockReporterFactory(); NullConsoleLogger log = new NullConsoleLogger(); - ForkClient forkStreamClient = new ForkClient( providerReporterFactory, new Properties(), - new MockNotifiableTestStream(), log ); + ForkClient forkStreamClient = new ForkClient( providerReporterFactory, new MockNotifiableTestStream(), log ); - forkStreamClient.consumeMultiLineContent( content.toString( "utf-8" ) ); + forkStreamClient.consumeMultiLineContent( content.toString( "UTF-8" ) ); final MockReporter reporter = (MockReporter) forkStreamClient.getReporter(); final List events = reporter.getEvents(); @@ -276,20 +272,19 @@ public void test2DifferentChannels() .testSkipped( secondExpected ); TestSetMockReporterFactory providerReporterFactory = new TestSetMockReporterFactory(); - Properties vmProps = new Properties(); NotifiableTestStream notifiableTestStream = new MockNotifiableTestStream(); NullConsoleLogger log = new NullConsoleLogger(); - ForkClient forkStreamClient = new ForkClient( providerReporterFactory, vmProps, notifiableTestStream, log ); - forkStreamClient.consumeMultiLineContent( content.toString( "utf-8" ) ); + ForkClient forkStreamClient = new ForkClient( providerReporterFactory, notifiableTestStream, log ); + forkStreamClient.consumeMultiLineContent( content.toString( "UTF-8" ) ); MockReporter reporter = (MockReporter) forkStreamClient.getReporter(); Assert.assertEquals( MockReporter.TEST_STARTING, reporter.getFirstEvent() ); Assert.assertEquals( expected, reporter.getFirstData() ); Assert.assertEquals( 1, reporter.getEvents().size() ); - forkStreamClient = new ForkClient( providerReporterFactory, vmProps, notifiableTestStream, log ); - forkStreamClient.consumeMultiLineContent( anotherContent.toString( "utf-8" ) ); + forkStreamClient = new ForkClient( providerReporterFactory, 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() ); @@ -357,7 +352,7 @@ public void clientReceiveContent() { TestSetMockReporterFactory providerReporterFactory = new TestSetMockReporterFactory(); NullConsoleLogger log = new NullConsoleLogger(); - final ForkClient forkStreamClient = new ForkClient( providerReporterFactory, new Properties(), + final ForkClient forkStreamClient = new ForkClient( providerReporterFactory, new MockNotifiableTestStream(), log ); forkStreamClient.consumeMultiLineContent( content.toString( ) ); reporter = (MockReporter) forkStreamClient.getReporter(); 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 bfc8faf2df..150d44331d 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 @@ -19,13 +19,15 @@ * under the License. */ -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; 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.RunListener; +import org.apache.maven.surefire.report.TestSetReportEntry; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; /** * Internal tests use only. @@ -66,14 +68,14 @@ public class MockReporter private final AtomicInteger testFailed = new AtomicInteger(); @Override - public void testSetStarting( ReportEntry report ) + public void testSetStarting( TestSetReportEntry report ) { events.add( SET_STARTING ); data.add( report ); } @Override - public void testSetCompleted( ReportEntry report ) + public void testSetCompleted( TestSetReportEntry report ) { events.add( SET_COMPLETED ); data.add( report ); 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 c5b7a1e4eb..445eaa826f 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 @@ -38,6 +38,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; +import static org.apache.maven.surefire.util.internal.ObjectUtils.systemProps; import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8; @SuppressWarnings( "ResultOfMethodCallIgnored" ) @@ -90,7 +91,7 @@ public void testFileNameWithoutSuffix() ReportEntry reportEntry = new SimpleReportEntry( getClass().getName(), getClass().getName(), 12 ); WrappedReportEntry testSetReportEntry = - new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null ); + new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null, systemProps() ); stats.testSucceeded( testSetReportEntry ); reporter.testSetCompleted( testSetReportEntry, stats ); @@ -105,7 +106,7 @@ public void testAllFieldsSerialized() { ReportEntry reportEntry = new SimpleReportEntry( getClass().getName(), TEST_ONE, 12 ); WrappedReportEntry testSetReportEntry = - new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null ); + new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null, systemProps() ); expectedReportFile = new File( reportDir, "TEST-" + TEST_ONE + ".xml" ); stats.testSucceeded( testSetReportEntry ); @@ -177,7 +178,7 @@ public void testOutputRerunFlakyFailure() ReportEntry reportEntry = new SimpleReportEntry( getClass().getName(), TEST_ONE, 12 ); WrappedReportEntry testSetReportEntry = - new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null ); + new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null, systemProps() ); expectedReportFile = new File( reportDir, "TEST-" + TEST_ONE + ".xml" ); stats.testSucceeded( testSetReportEntry ); @@ -294,5 +295,4 @@ class Inner { } - } 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 9fb45bfe28..f7cec19fd5 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 @@ -36,7 +36,6 @@ 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; @@ -73,8 +72,7 @@ TestLessInputStreamBuilderTest.class, SPITest.class, SurefireReflectorTest.class, - ImmutableMapTest.class, - SurefireHelperTest.class, + SurefireHelperTest.class } ) @RunWith( Suite.class ) public class JUnit4SuiteTest 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 d2c112b3d2..55395c05df 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,9 +19,6 @@ * under the License. */ -import java.io.PrintStream; -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; @@ -31,9 +28,15 @@ import org.apache.maven.surefire.report.SafeThrowable; import org.apache.maven.surefire.report.SimpleReportEntry; import org.apache.maven.surefire.report.StackTraceWriter; +import org.apache.maven.surefire.report.TestSetReportEntry; + +import java.io.PrintStream; +import java.util.Map.Entry; import static java.lang.Integer.toHexString; import static java.nio.charset.Charset.defaultCharset; +import static org.apache.maven.surefire.util.internal.ObjectUtils.systemProps; +import static org.apache.maven.surefire.util.internal.ObjectUtils.useNonNull; 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; @@ -132,13 +135,13 @@ public ForkingRunListener( PrintStream target, int testSetChannelId, boolean tri } @Override - public void testSetStarting( ReportEntry report ) + public void testSetStarting( TestSetReportEntry report ) { encodeAndWriteToTarget( toString( BOOTERCODE_TESTSET_STARTING, report, testSetChannelId ) ); } @Override - public void testSetCompleted( ReportEntry report ) + public void testSetCompleted( TestSetReportEntry report ) { encodeAndWriteToTarget( toString( BOOTERCODE_TESTSET_COMPLETED, report, testSetChannelId ) ); } @@ -187,15 +190,10 @@ public void testExecutionSkippedByUser() void sendProps() { - Properties systemProperties = System.getProperties(); - - if ( systemProperties != null ) + for ( Entry entry : systemProps().entrySet() ) { - for ( final String key : systemProperties.stringPropertyNames() ) - { - String value = systemProperties.getProperty( key ); - encodeAndWriteToTarget( toPropertyString( key, value == null ? "null" : value ) ); - } + String value = entry.getValue(); + encodeAndWriteToTarget( toPropertyString( entry.getKey(), useNonNull( value, "null" ) ) ); } } 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 c357cbafb4..47b0c48b0e 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 @@ -19,6 +19,9 @@ * under the License. */ +import java.util.Collections; +import java.util.Map; + /** * @author Kristian Rosenvold */ @@ -47,16 +50,23 @@ public CategorizedReportEntry( String source, String name, String group, StackTr public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter, Integer elapsed, String message ) { - super( source, name, stackTraceWriter, elapsed, message ); + this( source, name, group, stackTraceWriter, elapsed, message, Collections.emptyMap() ); + } + + public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter, + Integer elapsed, String message, Map systemProperties ) + { + super( source, name, stackTraceWriter, elapsed, message, systemProperties ); this.group = group; } - public static ReportEntry reportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter, - Integer elapsed, String message ) + public static TestSetReportEntry reportEntry( String source, String name, String group, + StackTraceWriter stackTraceWriter, Integer elapsed, String message, + Map systemProperties ) { return group != null - ? new CategorizedReportEntry( source, name, group, stackTraceWriter, elapsed, message ) - : new SimpleReportEntry( source, name, stackTraceWriter, elapsed, message ); + ? new CategorizedReportEntry( source, name, group, stackTraceWriter, elapsed, message, systemProperties ) + : new SimpleReportEntry( source, name, stackTraceWriter, elapsed, message, systemProperties ); } @Override diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java index 22cda617df..32c0abd1fd 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java @@ -34,7 +34,7 @@ public interface RunListener * @param report the report entry describing the testset * @throws ReporterException When reporting fails */ - void testSetStarting( ReportEntry report ); + void testSetStarting( TestSetReportEntry report ); /** * Indicates end of a given test-set @@ -42,7 +42,7 @@ public interface RunListener * @param report the report entry describing the testset * @throws ReporterException When reporting fails */ - void testSetCompleted( ReportEntry report ); + void testSetCompleted( TestSetReportEntry report ); /** * Event fired when a test is about to start 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 0dd42641ab..1013f397d2 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 @@ -19,12 +19,19 @@ * under the License. */ +import org.apache.maven.surefire.util.internal.ImmutableMap; + +import java.util.Collections; +import java.util.Map; + /** * @author Kristian Rosenvold */ public class SimpleReportEntry - implements ReportEntry + implements TestSetReportEntry { + private final Map systemProperties; + private final String source; private final String name; @@ -45,6 +52,11 @@ public SimpleReportEntry( String source, String name ) this( source, name, null, null ); } + public SimpleReportEntry( String source, String name, Map systemProperties ) + { + this( source, name, null, null, systemProperties ); + } + private SimpleReportEntry( String source, String name, StackTraceWriter stackTraceWriter ) { this( source, name, stackTraceWriter, null ); @@ -57,11 +69,11 @@ public SimpleReportEntry( String source, String name, Integer elapsed ) public SimpleReportEntry( String source, String name, String message ) { - this( source, name, null, null, message ); + this( source, name, null, null, message, Collections.emptyMap() ); } protected SimpleReportEntry( String source, String name, StackTraceWriter stackTraceWriter, Integer elapsed, - String message ) + String message, Map systemProperties ) { if ( source == null ) { @@ -81,13 +93,19 @@ protected SimpleReportEntry( String source, String name, StackTraceWriter stackT this.message = message; this.elapsed = elapsed; - } + this.systemProperties = new ImmutableMap( systemProperties ); + } public SimpleReportEntry( String source, String name, StackTraceWriter stackTraceWriter, Integer elapsed ) { - //noinspection ThrowableResultOfMethodCallIgnored - this( source, name, stackTraceWriter, elapsed, safeGetMessage( stackTraceWriter ) ); + this( source, name, stackTraceWriter, elapsed, Collections.emptyMap() ); + } + + public SimpleReportEntry( String source, String name, StackTraceWriter stackTraceWriter, Integer elapsed, + Map systemProperties ) + { + this( source, name, stackTraceWriter, elapsed, safeGetMessage( stackTraceWriter ), systemProperties ); } public static SimpleReportEntry assumption( String source, String name, String message ) @@ -193,6 +211,12 @@ public String getNameWithGroup() return getName(); } + @Override + public Map getSystemProperties() + { + return systemProperties; + } + private boolean isElapsedTimeEqual( SimpleReportEntry en ) { return elapsed != null ? elapsed.equals( en.elapsed ) : en.elapsed == null; diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetReportEntry.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetReportEntry.java new file mode 100644 index 0000000000..02d8669ea8 --- /dev/null +++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetReportEntry.java @@ -0,0 +1,35 @@ +package org.apache.maven.surefire.report; + +/* + * 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.Map; + +/** + * Describes test-set when started and finished. + * + * @author Tibor Digana (tibor17) + * @see RunListener#testSetStarting(TestSetReportEntry) + * @see RunListener#testSetCompleted(TestSetReportEntry) + * @since 2.20.1 + */ +public interface TestSetReportEntry extends ReportEntry +{ + Map getSystemProperties(); +} diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ImmutableMap.java similarity index 94% rename from maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java rename to surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ImmutableMap.java index 576194dfcf..003d884446 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/ImmutableMap.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ImmutableMap.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.surefire.util; +package org.apache.maven.surefire.util.internal; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -20,14 +20,15 @@ */ import java.util.AbstractMap; -import java.util.Collections; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import static java.util.Collections.unmodifiableSet; + /** * Copies input map in {@link #ImmutableMap(Map) constructor}, and Entries are linked and thread-safe. - * The map is immutable. + * The map is immutable with linear list of entries. * * @param key * @param value @@ -68,7 +69,7 @@ public Set> entrySet() entries.add( node ); node = node.next; } - return Collections.>unmodifiableSet( entries ); + return unmodifiableSet( entries ); } static final class Node 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 996c3be569..bc4fdd953b 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,87 @@ -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 +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.lang.management.ManagementFactory; +import java.util.Map; + +/** + * 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 ); + } + + public static Map systemProps() + { + return ManagementFactory.getRuntimeMXBean().getSystemProperties(); + } +} 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 22378bf5dd..da6e6e42ed 100644 --- a/surefire-api/src/test/java/org/apache/maven/JUnit4SuiteTest.java +++ b/surefire-api/src/test/java/org/apache/maven/JUnit4SuiteTest.java @@ -39,6 +39,7 @@ import org.apache.maven.surefire.util.UrlUtilsTest; import org.apache.maven.surefire.util.internal.ByteBufferTest; import org.apache.maven.surefire.util.internal.ConcurrencyUtilsTest; +import org.apache.maven.surefire.util.internal.ImmutableMapTest; import org.apache.maven.surefire.util.internal.StringUtilsTest; import org.apache.maven.surefire.util.internal.SystemUtilsTest; import org.junit.runner.RunWith; @@ -70,7 +71,8 @@ UrlUtilsTest.class, SpecificTestClassFilterTest.class, FundamentalFilterTest.class, - SystemUtilsTest.class + SystemUtilsTest.class, + ImmutableMapTest.class } ) @RunWith( Suite.class ) public class JUnit4SuiteTest diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ImmutableMapTest.java similarity index 96% rename from maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java rename to surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ImmutableMapTest.java index 8fcf2bb9ca..b104cc35bb 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/ImmutableMapTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ImmutableMapTest.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.surefire.util; +package org.apache.maven.surefire.util.internal; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,7 +19,7 @@ * under the License. */ -import org.apache.maven.plugin.surefire.util.ImmutableMap.Node; +import org.apache.maven.surefire.util.internal.ImmutableMap.Node; import org.junit.Before; import org.junit.Test; diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java new file mode 100644 index 0000000000..d13b0f24ae --- /dev/null +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java @@ -0,0 +1,203 @@ +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.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +/** + * Report XML should contain system properties of forked JVM. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public class Surefire1364SystemPropertiesIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void junit3Forked() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit3" ) + .forkMode( "once" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "" ); + } + + @Test + public void junit3InProcess() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit3" ) + .forkMode( "never" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "" ); + } + + @Test + public void junit4Forked() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .forkMode( "once" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "" ); + } + + @Test + public void junit4InProcess() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .forkMode( "never" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "" ); + } + + @Test + public void junit47Forked() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit47" ) + .forkMode( "once" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "" ); + } + + @Test + public void junit47InProcess() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit47" ) + .forkMode( "never" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "" ); + } + + @Test + public void junit47ForkedParallel() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit47" ) + .forkMode( "once" ) + .parallelClasses() + .threadCount( 2 ) + .disablePerCoreThreadCount() + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "" ); + } + + @Test + public void junit47InProcessParallel() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit47" ) + .forkMode( "never" ) + .parallelClasses() + .threadCount( 2 ) + .disablePerCoreThreadCount() + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "" ); + } + + @Test + public void testNg() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "testng" ) + .forkMode( "once" ) + .executeTest() + .verifyErrorFree( 3 ); + + validator.getSurefireReportsXmlFile( "TEST-TestSuite.xml" ) + .assertContainsText( "" ); + } + + @Test + public void testNgInProcess() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "testng" ) + .forkMode( "never" ) + .executeTest() + .verifyErrorFree( 3 ); + + validator.getSurefireReportsXmlFile( "TEST-TestSuite.xml" ) + .assertContainsText( "" ); + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1364/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1364/pom.xml new file mode 100644 index 0000000000..f93565a1de --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1364/pom.xml @@ -0,0 +1,156 @@ + + + + + 4.0.0 + + + org.apache.maven.surefire + it-parent + 1.0 + + + org.apache.maven.plugins.surefire + surefire-1364 + 1.0 + + + UTF-8 + 1.6 + 1.6 + once + + + + + junit + junit + 4.12 + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + FirstTest.java + SecondTest.java + + + + + org.apache.maven.plugins + maven-surefire-plugin + + ${forkedMode} + + forkedValue${surefire.forkNumber} + + + + + + + + + junit3 + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.surefire + surefire-junit3 + ${surefire.version} + + + + + + + + + junit47 + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.surefire + surefire-junit47 + ${surefire.version} + + + + + + + + + testng + + + org.testng + testng + 6.8.21 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + *.java + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.surefire + surefire-testng + ${surefire.version} + + + + + + + + + diff --git a/surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/FirstTest.java b/surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/FirstTest.java new file mode 100644 index 0000000000..f2a9e66b32 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/FirstTest.java @@ -0,0 +1,30 @@ +/* + * 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 junit.framework.TestCase; +import org.junit.Test; + +public class FirstTest extends TestCase +{ + @Test + public void test() throws InterruptedException + { + Thread.sleep( 100 ); + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/SecondTest.java b/surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/SecondTest.java new file mode 100644 index 0000000000..cfd9b51ed8 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/SecondTest.java @@ -0,0 +1,30 @@ +/* + * 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 junit.framework.TestCase; +import org.junit.Test; + +public class SecondTest extends TestCase +{ + @Test + public void test() throws InterruptedException + { + Thread.sleep( 100 ); + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/ThirdTest.java b/surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/ThirdTest.java new file mode 100644 index 0000000000..f3633d6a23 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1364/src/test/java/ThirdTest.java @@ -0,0 +1,30 @@ +/* + * 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.testng.annotations.Test; + + +public class ThirdTest +{ + @Test + public void test() throws InterruptedException + { + Thread.sleep( 100 ); + } +} \ No newline at end of file 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 12cbb4c2d1..9f3b6ff961 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 @@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.TestSetReportEntry; /** * Internal tests use only. @@ -56,13 +57,13 @@ public MockReporter() } @Override - public void testSetStarting( ReportEntry report ) + public void testSetStarting( TestSetReportEntry report ) { events.add( SET_STARTED ); } @Override - public void testSetCompleted( ReportEntry report ) + public void testSetCompleted( TestSetReportEntry report ) { events.add( SET_COMPLETED ); } 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 adfda35b8b..b8c83e1f8f 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 @@ -25,7 +25,6 @@ import org.apache.maven.surefire.providerapi.ProviderParameters; import org.apache.maven.surefire.report.ConsoleOutputCapture; import org.apache.maven.surefire.report.ConsoleOutputReceiver; -import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.ReporterFactory; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; @@ -36,6 +35,10 @@ import org.apache.maven.surefire.util.ScanResult; import org.apache.maven.surefire.util.TestsToRun; +import java.util.Map; + +import static org.apache.maven.surefire.util.internal.ObjectUtils.systemProps; + /** * @author Kristian Rosenvold */ @@ -95,8 +98,8 @@ else if ( forkTestSet instanceof Class ) { final RunListener reporter = reporterFactory.createReporter(); ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter ); - - final String smClassName = System.getProperty( "surefire.security.manager" ); + final Map systemProperties = systemProps(); + final String smClassName = systemProperties.get( "surefire.security.manager" ); if ( smClassName != null ) { SecurityManager securityManager = @@ -107,7 +110,7 @@ else if ( forkTestSet instanceof Class ) for ( Class clazz : testsToRun ) { SurefireTestSet surefireTestSet = createTestSet( clazz ); - executeTestSet( surefireTestSet, reporter, testClassLoader ); + executeTestSet( surefireTestSet, reporter, testClassLoader, systemProperties ); } } @@ -126,10 +129,11 @@ private SurefireTestSet createTestSet( Class clazz ) : new PojoTestSet( clazz ); } - private void executeTestSet( SurefireTestSet testSet, RunListener reporter, ClassLoader classLoader ) + private void executeTestSet( SurefireTestSet testSet, RunListener reporter, ClassLoader classLoader, + Map systemProperties ) throws TestSetFailedException { - ReportEntry report = new SimpleReportEntry( this.getClass().getName(), testSet.getName() ); + SimpleReportEntry report = new SimpleReportEntry( getClass().getName(), testSet.getName(), systemProperties ); reporter.testSetStarting( report ); 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 359a79f3fe..9c08fd9034 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 @@ -19,16 +19,17 @@ * under the License. */ -import java.util.ArrayList; -import java.util.List; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; import org.apache.maven.surefire.common.junit3.JUnit3Reflector; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.TestSetReportEntry; import org.apache.maven.surefire.testset.TestSetFailedException; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import java.util.ArrayList; +import java.util.List; public class JUnitTestSetTest extends TestCase @@ -64,12 +65,12 @@ public static class SuccessListener private List succeededTests = new ArrayList(); @Override - public void testSetStarting( ReportEntry report ) + public void testSetStarting( TestSetReportEntry report ) { } @Override - public void testSetCompleted( ReportEntry report ) + public void testSetCompleted( TestSetReportEntry report ) { } 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 12842fae6f..ad29224e59 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 @@ -31,7 +31,6 @@ import org.apache.maven.surefire.providerapi.ProviderParameters; import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.PojoStackTraceWriter; -import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.ReporterFactory; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; @@ -66,6 +65,7 @@ import static org.apache.maven.surefire.report.SimpleReportEntry.withException; import static org.apache.maven.surefire.testset.TestListResolver.optionallyWildcardFilter; import static org.apache.maven.surefire.util.TestsToRun.fromClass; +import static org.apache.maven.surefire.util.internal.ObjectUtils.systemProps; import static org.junit.runner.Request.aClass; import static org.junit.runner.Request.method; @@ -232,7 +232,7 @@ public void update( Command command ) private void executeTestSet( Class clazz, RunListener reporter, Notifier notifier ) { - final ReportEntry report = new SimpleReportEntry( getClass().getName(), clazz.getName() ); + final SimpleReportEntry report = new SimpleReportEntry( getClass().getName(), clazz.getName(), systemProps() ); reporter.testSetStarting( report ); try { diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java index e8ac7860c4..52a7ffbab0 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java @@ -40,7 +40,7 @@ public ClassesParallelRunListener( Map classMethodCounts, Repor } @Override - public void checkIfTestSetCanBeReported( TestSet testSetForTest ) + protected void checkIfTestSetCanBeReported( TestSet testSetForTest ) { TestSet currentlyAttached = TestSet.getThreadTestSet(); if ( currentlyAttached != null && currentlyAttached != testSetForTest ) 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 56e3e1a615..27008ee441 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 @@ -26,6 +26,7 @@ import org.apache.maven.surefire.report.ReporterFactory; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.StackTraceWriter; +import org.apache.maven.surefire.report.TestSetReportEntry; import org.apache.maven.surefire.testset.TestSetFailedException; import static org.apache.maven.surefire.junitcore.TestMethod.getThreadTestMethod; @@ -70,12 +71,12 @@ protected RunListener initialValue() } @Override - public void testSetStarting( ReportEntry description ) + public void testSetStarting( TestSetReportEntry description ) { } @Override - public void testSetCompleted( ReportEntry result ) + public void testSetCompleted( TestSetReportEntry result ) { final RunListener reporterManager = getRunListener(); for ( TestSet testSet : classMethodCounts.values() ) diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java index 0e487b069c..b478670e80 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java @@ -44,7 +44,7 @@ public MethodsParallelRunListener( Map classMethodCounts, Repor } @Override - public void checkIfTestSetCanBeReported( TestSet testSetForTest ) + protected void checkIfTestSetCanBeReported( TestSet testSetForTest ) { synchronized ( lock ) { 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 0e5ee776ad..e9897bd477 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 @@ -23,11 +23,17 @@ import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; +import org.apache.maven.surefire.report.TestSetReportEntry; import org.apache.maven.surefire.testset.TestSetFailedException; import org.junit.runner.Description; import org.junit.runner.Result; import org.junit.runner.notification.Failure; +import java.util.Collections; +import java.util.Map; + +import static org.apache.maven.surefire.util.internal.ObjectUtils.systemProps; + /** * A class to be used when there is no JUnit parallelism (methods or/and class). This allow to workaround JUnit * limitation a la Junit4 provider. Specifically, we can redirect properly the output even if we don't have class @@ -60,10 +66,20 @@ protected SimpleReportEntry createReportEntry( Description description ) return new SimpleReportEntry( extractDescriptionClassName( description ), description.getDisplayName() ); } - protected SimpleReportEntry createReportEntryForTestSet( Description description ) + private TestSetReportEntry createReportEntryForTestSet( Description description, Map systemProps ) { String testClassName = extractDescriptionClassName( description ); - return new SimpleReportEntry( testClassName, testClassName ); + return new SimpleReportEntry( testClassName, testClassName, systemProps ); + } + + private TestSetReportEntry createTestSetReportEntryStarted( Description description ) + { + return createReportEntryForTestSet( description, Collections.emptyMap() ); + } + + private TestSetReportEntry createTestSetReportEntryFinished( Description description ) + { + return createReportEntryForTestSet( description, systemProps() ); } @Override @@ -93,10 +109,11 @@ private void finishLastTestSetIfNecessary( Description description ) currentTestSetDescription = description; if ( lastFinishedDescription != null ) { - reporter.testSetCompleted( createReportEntryForTestSet( lastFinishedDescription ) ); + TestSetReportEntry reportEntry = createTestSetReportEntryFinished( lastFinishedDescription ); + reporter.testSetCompleted( reportEntry ); lastFinishedDescription = null; } - reporter.testSetStarting( createReportEntryForTestSet( description ) ); + reporter.testSetStarting( createTestSetReportEntryStarted( description ) ); } } @@ -166,7 +183,7 @@ public void testRunFinished( Result result ) { if ( lastFinishedDescription != null ) { - reporter.testSetCompleted( createReportEntryForTestSet( lastFinishedDescription ) ); + reporter.testSetCompleted( createTestSetReportEntryFinished( lastFinishedDescription ) ); lastFinishedDescription = null; } } diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java index d7bb7220ce..0f05327325 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java @@ -19,17 +19,21 @@ * under the License. */ +import org.apache.maven.surefire.report.ReportEntry; +import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.SimpleReportEntry; +import org.apache.maven.surefire.report.TestSetReportEntry; +import org.junit.runner.Description; + import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.maven.surefire.report.ReportEntry; -import org.apache.maven.surefire.report.RunListener; -import org.apache.maven.surefire.report.SimpleReportEntry; - -import org.junit.runner.Description; +import static org.apache.maven.surefire.util.internal.ObjectUtils.systemProps; /** * * Represents the test-state of a testset that is run. @@ -64,7 +68,7 @@ public void replay( RunListener target ) { try { - ReportEntry report = createReportEntry( null ); + TestSetReportEntry report = createReportEntryStarted(); target.testSetStarting( report ); @@ -87,7 +91,7 @@ public void replay( RunListener target ) int elapsed = (int) ( endTime - startTile ); - report = createReportEntry( elapsed ); + report = createReportEntryCompleted( elapsed ); target.testSetCompleted( report ); } @@ -106,7 +110,17 @@ public TestMethod createThreadAttachedTestMethod( ReportEntry description ) return testMethod; } - private ReportEntry createReportEntry( Integer elapsed ) + private TestSetReportEntry createReportEntryStarted() + { + return createReportEntry( null, Collections.emptyMap() ); + } + + private TestSetReportEntry createReportEntryCompleted( int elapsed ) + { + return createReportEntry( elapsed, systemProps() ); + } + + private TestSetReportEntry createReportEntry( Integer elapsed, Map systemProps ) { final String className = testSetDescription.getClassName(); final boolean isJunit3 = className == null; @@ -120,7 +134,7 @@ private ReportEntry createReportEntry( Integer elapsed ) { classNameToUse = className; } - return new SimpleReportEntry( classNameToUse, classNameToUse, elapsed ); + return new SimpleReportEntry( classNameToUse, classNameToUse, null, elapsed, systemProps ); } public void incrementTestMethodCount() diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestSuite.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestSuite.java index a74ef0d836..ca40f7c764 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestSuite.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestSuite.java @@ -19,13 +19,15 @@ * under the License. */ -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.SimpleReportEntry; +import org.apache.maven.surefire.report.TestSetReportEntry; import java.util.Map; +import static org.apache.maven.surefire.util.internal.ObjectUtils.systemProps; + /** * Abstract class which implements common functions. */ @@ -41,7 +43,7 @@ final String getSuiteName() final void startTestSuite( RunListener reporterManager ) { - ReportEntry report = new SimpleReportEntry( getClass().getName(), getSuiteName() ); + TestSetReportEntry report = new SimpleReportEntry( getClass().getName(), getSuiteName(), systemProps() ); try { @@ -55,7 +57,7 @@ final void startTestSuite( RunListener reporterManager ) final void finishTestSuite( RunListener reporterManager ) { - ReportEntry report = new SimpleReportEntry( getClass().getName(), getSuiteName() ); + SimpleReportEntry report = new SimpleReportEntry( getClass().getName(), getSuiteName(), systemProps() ); reporterManager.testSetCompleted( report ); } } From 5593bf560aa8d8ed900fb146176a39ad5b0e42af Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Thu, 4 May 2017 20:45:28 +0200 Subject: [PATCH 089/194] [SUREFIRE-1264] Some tests can be lost when running in parallel with parameterized tests --- .../internal/TestClassMethodNameUtils.java | 57 +++++++++- .../maven/surefire/its/fixture/TestFile.java | 6 +- ...efire1082ParallelJUnitParameterizedIT.java | 101 +++++++++++++++--- .../java/jiras/surefire1082/Jira1082Test.java | 4 +- .../java/jiras/surefire1082/Jira1264Test.java | 36 +++++++ .../junitcore/JUnitCoreRunListener.java | 49 ++++++--- 6 files changed, 222 insertions(+), 31 deletions(-) create mode 100644 surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/src/test/java/jiras/surefire1082/Jira1264Test.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 index 1a30c72df6..ed7826916e 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,56 @@ -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 +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 +{ + /** + * This pattern is verbatim copy from JUnit's code in class {@code Description}. + * Parsing class and method from junit description would provide identical result to JUnit internal parser. + */ + 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 ) + { + Matcher m = METHOD_CLASS_PATTERN.matcher( displayName ); + return m.matches() ? m.group( 1 ) : 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 61736df46e..cf6ad84616 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 @@ -39,7 +39,6 @@ */ public class TestFile { - private final File file; private final Charset encoding; @@ -148,4 +147,9 @@ public URI toURI() { return file.toURI(); } + + public File getFile() + { + return file; + } } 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 b1d9d4ffda..2669b2f21c 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 @@ -23,17 +23,21 @@ 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.apache.maven.surefire.its.fixture.TestFile; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.junit.Test; +import java.nio.charset.Charset; +import java.util.Collection; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; import static org.hamcrest.core.AnyOf.anyOf; import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.StringContains.containsString; import static org.junit.Assert.assertThat; /** @@ -44,17 +48,29 @@ public class Surefire1082ParallelJUnitParameterizedIT extends SurefireJUnit4IntegrationTestCase { + private static Set printOnlyTestLinesFromConsole( OutputValidator validator ) + throws VerificationException + { + return printOnlyTestLines( validator.loadLogLines() ); + } + + private static Set printOnlyTestLinesFromOutFile( OutputValidator validator ) + throws VerificationException + { + TestFile report = validator.getSurefireReportsFile( "jiras.surefire1082.Jira1082Test-output.txt" ); + report.assertFileExists(); + return printOnlyTestLines( validator.loadFile( report.getFile(), Charset.forName( "UTF-8" ) ) ); + } - private static Set printOnlyTestLines( OutputValidator validator ) + private static Set printOnlyTestLines( Collection logs ) throws VerificationException { - Set log = new TreeSet( validator.loadLogLines() ); - for ( Iterator it = log.iterator(); it.hasNext(); ) + Set log = new TreeSet(); + for ( String line : logs ) { - String line = it.next(); - if ( !line.startsWith( "class jiras.surefire1082." ) ) + if ( line.startsWith( "class jiras.surefire1082." ) ) { - it.remove(); + log.add( line ); } } return log; @@ -65,14 +81,8 @@ private static Matcher> regex( Set r ) return new IsRegex( r ); } - @Test - public void test() - throws VerificationException + private static void assertParallelRun( Set log ) { - OutputValidator validator = unpack().setTestToRun( - "Jira1082Test" ).parallelClasses().useUnlimitedThreads().executeTest().verifyErrorFree( 4 ); - - Set log = printOnlyTestLines( validator ); assertThat( log.size(), is( 4 ) ); Set expectedLogs1 = new TreeSet(); @@ -90,6 +100,71 @@ public void test() assertThat( log, anyOf( regex( expectedLogs1 ), regex( expectedLogs2 ) ) ); } + @Test + public void checkClassesRunParallel() + throws VerificationException + { + OutputValidator validator = unpack().setTestToRun( "Jira1082Test" ) + .parallelClasses() + .useUnlimitedThreads() + .executeTest() + .verifyErrorFree( 4 ); + + validator.getSurefireReportsXmlFile( "TEST-jiras.surefire1082.Jira1082Test.xml" ) + .assertFileExists(); + + validator.assertThatLogLine( containsString( "Running jiras.surefire1082.Jira1082Test" ), is( 1 ) ); + + Set log = printOnlyTestLinesFromConsole( validator ); + assertParallelRun( log ); + } + + @Test + public void checkOutFileClassesRunParallel() + throws VerificationException + { + OutputValidator validator = unpack().redirectToFile( true ) + .setTestToRun( "Jira1082Test" ) + .parallelClasses() + .useUnlimitedThreads() + .executeTest() + .verifyErrorFree( 4 ); + + validator.getSurefireReportsXmlFile( "TEST-jiras.surefire1082.Jira1082Test.xml" ) + .assertFileExists(); + + validator.assertThatLogLine( containsString( "Running jiras.surefire1082.Jira1082Test" ), is( 1 ) ); + + Set log = printOnlyTestLinesFromOutFile( validator ); + assertParallelRun( log ); + } + + @Test + public void shouldRunTwo() throws VerificationException + { + OutputValidator validator = unpack().redirectToFile( true ) + .parallelClasses() + .useUnlimitedThreads() + .executeTest() + .verifyErrorFree( 8 ); + + validator.getSurefireReportsXmlFile( "TEST-jiras.surefire1082.Jira1082Test.xml" ) + .assertFileExists(); + + validator.getSurefireReportsXmlFile( "TEST-jiras.surefire1082.Jira1264Test.xml" ) + .assertFileExists(); + + validator.getSurefireReportsFile( "jiras.surefire1082.Jira1082Test-output.txt" ) + .assertFileExists(); + + validator.getSurefireReportsFile( "jiras.surefire1082.Jira1264Test-output.txt" ) + .assertFileExists(); + + validator.assertThatLogLine( containsString( "Running jiras.surefire1082.Jira1082Test" ), is( 1 ) ); + + validator.assertThatLogLine( containsString( "Running jiras.surefire1082.Jira1264Test" ), is( 1 ) ); + } + private SurefireLauncher unpack() { return unpack( "surefire-1082-parallel-junit-parameterized" ); diff --git a/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/src/test/java/jiras/surefire1082/Jira1082Test.java b/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/src/test/java/jiras/surefire1082/Jira1082Test.java index abf2a58426..e8cef992da 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/src/test/java/jiras/surefire1082/Jira1082Test.java +++ b/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/src/test/java/jiras/surefire1082/Jira1082Test.java @@ -27,9 +27,9 @@ import java.util.concurrent.TimeUnit; @RunWith( Parameterized.class ) -public final class Jira1082Test +public class Jira1082Test { - private int x; + private final int x; public Jira1082Test( int x ) { diff --git a/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/src/test/java/jiras/surefire1082/Jira1264Test.java b/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/src/test/java/jiras/surefire1082/Jira1264Test.java new file mode 100644 index 0000000000..56e7644010 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1082-parallel-junit-parameterized/src/test/java/jiras/surefire1082/Jira1264Test.java @@ -0,0 +1,36 @@ +package jiras.surefire1082; + +/* + * 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 org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +@RunWith( Parameterized.class ) +public final class Jira1264Test extends Jira1082Test +{ + public Jira1264Test( int x ) + { + super( x ); + } +} 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 e32e32ce66..4a187e4c0d 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 @@ -19,16 +19,18 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Map; import org.apache.maven.surefire.common.junit4.JUnit4RunListener; import org.apache.maven.surefire.common.junit48.JUnit46StackTraceWriter; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.StackTraceWriter; - import org.junit.runner.Description; import org.junit.runner.Result; +import org.junit.runner.RunWith; import org.junit.runner.notification.Failure; +import org.junit.runners.Parameterized; + +import java.lang.annotation.Annotation; +import java.util.Map; /** * Noteworthy things about JUnit4 listening: @@ -74,38 +76,57 @@ public void testRunFinished( Result result ) reporter.testSetCompleted( null ); } - private void fillTestCountMap( Description description ) + private void fillTestCountMap( Description testDesc ) { - final ArrayList children = description.getChildren(); + TestSet testSet = new TestSet( testDesc ); + + String itemTestClassName = + isParameterizedRunner( testDesc ) ? testDesc.getClassName() : asSuiteRunner( testDesc, testSet ); - TestSet testSet = new TestSet( description ); + if ( itemTestClassName != null ) + { + classMethodCounts.put( itemTestClassName, testSet ); + } + } + + private String asSuiteRunner( Description description, TestSet testSet ) + { String itemTestClassName = null; - for ( Description item : children ) + for ( Description child : description.getChildren() ) { - if ( !item.isTest() ) + if ( !child.isTest() ) { - fillTestCountMap( item ); + fillTestCountMap( child ); } else { - if ( extractDescriptionMethodName( item ) != null ) + if ( extractDescriptionMethodName( child ) != null ) { testSet.incrementTestMethodCount(); if ( itemTestClassName == null ) { - itemTestClassName = extractDescriptionClassName( item ); + itemTestClassName = extractDescriptionClassName( child ); } } else { - classMethodCounts.put( extractDescriptionClassName( item ), new TestSet( item ) ); + classMethodCounts.put( extractDescriptionClassName( child ), new TestSet( child ) ); } } } - if ( itemTestClassName != null ) + return itemTestClassName; + } + + private static boolean isParameterizedRunner( Description description ) + { + for ( Annotation ann : description.getAnnotations() ) { - classMethodCounts.put( itemTestClassName, testSet ); + if ( ann.annotationType() == RunWith.class ) + { + return Parameterized.class.isAssignableFrom( ( (RunWith) ann ).value() ); + } } + return false; } @Override From 86396d896bfeb614baa1547f16e035316e281049 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Fri, 5 May 2017 00:07:54 +0200 Subject: [PATCH 090/194] [SUREFIRE-1367] System Output and Error should be reported in parallel JUnit tests if Assumption fails. --- .../surefire/util/internal/ByteBuffer.java | 147 ---------------- .../org/apache/maven/JUnit4SuiteTest.java | 2 - .../jiras/Surefire1367AssumptionLogsIT.java | 157 ++++++++++++++++++ .../src/test/resources/surefire-1367/pom.xml | 61 +++++++ .../surefire-1367/src/test/java/ATest.java | 38 +++++ .../surefire-1367/src/test/java/BTest.java | 34 ++++ .../junitcore/ConcurrentRunListener.java | 2 +- .../surefire/junitcore/LogicalStream.java | 52 +++--- .../maven/surefire/junitcore/TestMethod.java | 20 ++- 9 files changed, 330 insertions(+), 183 deletions(-) delete mode 100644 surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java create mode 100644 surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1367/pom.xml create mode 100644 surefire-integration-tests/src/test/resources/surefire-1367/src/test/java/ATest.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1367/src/test/java/BTest.java 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 deleted file mode 100644 index bdd983f2bc..0000000000 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java +++ /dev/null @@ -1,147 +0,0 @@ -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. - */ - -/** - * @author Kristian Rosenvold - */ -public class ByteBuffer -{ - private final byte[] data; - - private int position; - - public ByteBuffer( int length ) - { - this.data = new byte[length]; - } - - public ByteBuffer( byte[] buf, int off, int len ) - { - this.data = new byte[len]; - append( buf, off, len ); - } - - - public void append( char chararcter ) - { - data[position++] = (byte) chararcter; - } - - public void append( byte chararcter ) - { - data[position++] = chararcter; - } - - private static final byte COMMA = (byte) ','; - - public void comma() - { - data[position++] = COMMA; - } - - - public void advance( int i ) - { // Oooh nice break of encapsulation - position += i; - } - - public void append( Integer integer ) - { - toHex( integer ); - } - - /** - * Convert the integer to an unsigned number. - * - * @param i the value - */ - private void toHex( int i ) - { - byte[] buf = new byte[32]; - int charPos = 32; - int radix = 1 << 4; - int mask = radix - 1; - do - { - buf[--charPos] = (byte) DIGITS[i & mask]; - i >>>= 4; - } - while ( i != 0 ); - - append( buf, charPos, ( 32 - charPos ) ); - } - - private static final char[] DIGITS = - { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; - - - public byte[] getData() - { - return data; - } - - public int getlength() - { - return position; - } - - @Override - public String toString() - { - return new String( data, 0, position ); - } - - public static byte[] copy( byte[] src1, int off1, int len1 ) - { - byte[] combined = new byte[len1]; - int pos = 0; - for ( int i = off1; i < off1 + len1; i++ ) - { - combined[pos++] = src1[i]; - } - return combined; - } - - void append( byte[] src1, int off1, int len1 ) - { - for ( int i = off1; i < off1 + len1; i++ ) - { - data[position++] = src1[i]; - } - } - - public static byte[] join( byte[] src1, int off1, int len1, byte[] src2, int off2, int len2 ) - { - byte[] combined = new byte[len1 + len2]; - int pos = 0; - for ( int i = off1; i < off1 + len1; i++ ) - { - combined[pos++] = src1[i]; - } - for ( int i = off2; i < off2 + len2; i++ ) - { - combined[pos++] = src2[i]; - } - return combined; - } - -} 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 da6e6e42ed..dbf46ea482 100644 --- a/surefire-api/src/test/java/org/apache/maven/JUnit4SuiteTest.java +++ b/surefire-api/src/test/java/org/apache/maven/JUnit4SuiteTest.java @@ -37,7 +37,6 @@ import org.apache.maven.surefire.util.ScanResultTest; import org.apache.maven.surefire.util.TestsToRunTest; import org.apache.maven.surefire.util.UrlUtilsTest; -import org.apache.maven.surefire.util.internal.ByteBufferTest; import org.apache.maven.surefire.util.internal.ConcurrencyUtilsTest; import org.apache.maven.surefire.util.internal.ImmutableMapTest; import org.apache.maven.surefire.util.internal.StringUtilsTest; @@ -60,7 +59,6 @@ RunResultTest.class, ResolvedTestTest.class, TestListResolverTest.class, - ByteBufferTest.class, ConcurrencyUtilsTest.class, StringUtilsTest.class, DefaultDirectoryScannerTest.class, diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java new file mode 100644 index 0000000000..48564fb2a8 --- /dev/null +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java @@ -0,0 +1,157 @@ +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.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +import static org.fest.assertions.Assertions.assertThat; + +/** + * @author Tibor Digana (tibor17) + * @see SUREFIRE-1367 + * @since 2.20.1 + */ +public class Surefire1367AssumptionLogsIT + extends SurefireJUnit4IntegrationTestCase +{ + private static final String NL = System.getProperty( "line.separator" ); + + @Test + public void shouldSeeLogsParallelForked() + { + OutputValidator outputValidator = unpack().setForkJvm() + .forkMode( "once" ) + .parallelClassesAndMethods() + .disablePerCoreThreadCount() + .threadCountClasses( 2 ) + .threadCountMethods( 2 ) + .executeTest() + .assertTestSuiteResults( 2, 0, 0, 2 ); + + verifyReportA( outputValidator ); + verifyReportB( outputValidator ); + } + + @Test + public void shouldSeeLogsParallelInPlugin() + { + OutputValidator outputValidator = unpack().setForkJvm() + .forkMode( "never" ) + .parallelClassesAndMethods() + .disablePerCoreThreadCount() + .threadCountClasses( 2 ) + .threadCountMethods( 2 ) + .executeTest() + .assertTestSuiteResults( 2, 0, 0, 2 ); + + verifyReportA( outputValidator ); + verifyReportB( outputValidator ); + } + + @Test + public void shouldSeeLogsForked() + { + OutputValidator outputValidator = unpack().setForkJvm() + .forkMode( "once" ) + .executeTest() + .assertTestSuiteResults( 2, 0, 0, 2 ); + + verifyReportA( outputValidator ); + verifyReportB( outputValidator ); + } + + @Test + public void shouldSeeLogsInPlugin() + { + OutputValidator outputValidator = unpack().setForkJvm() + .forkMode( "never" ) + .executeTest() + .assertTestSuiteResults( 2, 0, 0, 2 ); + + verifyReportA( outputValidator ); + verifyReportB( outputValidator ); + } + + + private SurefireLauncher unpack() + { + return unpack( "/surefire-1367" ); + } + + private void verifyReportA( OutputValidator outputValidator ) + { + String xmlReport = outputValidator.getSurefireReportsXmlFile( "TEST-ATest.xml" ) + .readFileToString(); + + String outputCData = "" + NL + + " "; + + assertThat( xmlReport ) + .contains( outputCData ); + + + String output = outputValidator.getSurefireReportsFile( "ATest-output.txt" ) + .readFileToString(); + + String outputExpected = "Hi" + NL + + NL + + "There!" + NL + + "Hello" + NL + + NL + + "What's up!" + NL; + + assertThat( output ) + .isEqualTo( outputExpected ); + } + + private void verifyReportB( OutputValidator outputValidator ) + { + String xmlReport = outputValidator.getSurefireReportsXmlFile( "TEST-BTest.xml" ) + .readFileToString(); + + String outputCData = ""; + + assertThat( xmlReport ) + .contains( outputCData ); + + + String output = outputValidator.getSurefireReportsFile( "BTest-output.txt" ) + .readFileToString(); + + String outputExpected = "Hey" + NL + + NL + + "you!" + NL; + + assertThat( output ) + .isEqualTo( outputExpected ); + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1367/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1367/pom.xml new file mode 100644 index 0000000000..4bca308b9e --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1367/pom.xml @@ -0,0 +1,61 @@ + + + + 4.0.0 + + + org.apache.maven.surefire + it-parent + 1.0 + ../pom.xml + + + org.apache.maven.plugins.surefire + surefire-1367 + 1.0 + + + UTF-8 + 1.5 + 1.5 + + + + + junit + junit + 4.12 + test + + + + + + + maven-surefire-plugin + + ${forkMode} + true + + + + + diff --git a/surefire-integration-tests/src/test/resources/surefire-1367/src/test/java/ATest.java b/surefire-integration-tests/src/test/resources/surefire-1367/src/test/java/ATest.java new file mode 100644 index 0000000000..df5231e7ec --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1367/src/test/java/ATest.java @@ -0,0 +1,38 @@ +/* + * 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.junit.Assume.assumeTrue; + +public class ATest { + + @Test + public void test() { + System.out.println("Hi"); + System.out.println(); + System.out.println("There!"); + + System.err.println("Hello"); + System.err.println(); + System.err.println("What's up!"); + + assumeTrue( false ); + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1367/src/test/java/BTest.java b/surefire-integration-tests/src/test/resources/surefire-1367/src/test/java/BTest.java new file mode 100644 index 0000000000..bec4da8cd4 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1367/src/test/java/BTest.java @@ -0,0 +1,34 @@ +/* + * 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.junit.Assume.assumeTrue; + +public class BTest { + + @Test + public void test() { + System.out.println("Hey"); + System.out.println(); + System.out.println("you!"); + + assumeTrue( false ); + } +} 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 27008ee441..a4f88dcf91 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 @@ -131,7 +131,7 @@ public void testAssumptionFailure( ReportEntry failure ) final TestMethod testMethod = getOrCreateThreadAttachedTestMethod( failure ); if ( testMethod != null ) { - testMethod.testIgnored( failure ); + testMethod.testAssumption( failure ); testMethod.detachFromCurrentThread(); } } diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java index 41e09b89d1..10895855d9 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java @@ -19,68 +19,62 @@ * under the License. */ -import java.util.Collection; -import java.util.concurrent.ConcurrentLinkedQueue; - import org.apache.maven.surefire.report.ConsoleOutputReceiver; -import org.apache.maven.surefire.util.internal.ByteBuffer; + +import java.util.Arrays; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; /** * A stream-like object that preserves ordering between stdout/stderr */ public final class LogicalStream { - private final Collection output = new ConcurrentLinkedQueue(); + private final Queue output = new ConcurrentLinkedQueue(); - static final class Entry + private static final class Entry { - final boolean stdout; + private final boolean stdout; - final byte[] b; + private final byte[] b; - final int off; + private final int off; - final int len; + private final int len; - Entry( boolean stdout, byte[] b, int off, int len ) + private Entry( boolean stdout, byte[] b, int off, int len ) { this.stdout = stdout; - this.b = ByteBuffer.copy( b, off, len ); + this.b = Arrays.copyOfRange( b, off, off + len ); this.off = 0; this.len = len; } - public void writeDetails( ConsoleOutputReceiver outputReceiver ) + private void writeDetails( ConsoleOutputReceiver outputReceiver ) { outputReceiver.writeTestOutput( b, off, len, stdout ); } - - @Override - public String toString() - { - return new String( b, off, len ); - } - - public boolean isBlankLine() - { - return "\n".equals( toString() ); - } } - public synchronized void write( boolean stdout, byte b[], int off, int len ) + public void write( boolean stdout, byte b[], int off, int len ) { - Entry entry = new Entry( stdout, b, off, len ); - if ( !entry.isBlankLine() ) + if ( !isBlankLine( b, len ) ) { + Entry entry = new Entry( stdout, b, off, len ); output.add( entry ); } } - public synchronized void writeDetails( ConsoleOutputReceiver outputReceiver ) + public void writeDetails( ConsoleOutputReceiver outputReceiver ) { - for ( Entry entry : output ) + for ( Entry entry = output.poll(); entry != null; entry = output.poll() ) { entry.writeDetails( outputReceiver ); } } + + private static boolean isBlankLine( byte[] b, int len ) + { + return b == null || len == 0; + } } 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 7bba28c9d6..1a7dd12e55 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 @@ -52,7 +52,9 @@ class TestMethod private volatile ReportEntry testError; - private volatile ReportEntry ignored; + private volatile ReportEntry testIgnored; + + private volatile ReportEntry testAssumption; TestMethod( ReportEntry description, TestSet testSet ) { @@ -68,7 +70,7 @@ void testFinished() void testIgnored( ReportEntry description ) { - ignored = description; + testIgnored = description; setEndTime(); } @@ -84,6 +86,12 @@ void testError( ReportEntry failure ) setEndTime(); } + void testAssumption( ReportEntry failure ) + { + this.testAssumption = failure; + setEndTime(); + } + private void setEndTime() { this.endTime = System.currentTimeMillis(); @@ -106,9 +114,9 @@ long getEndTime() void replay( RunListener reporter ) { - if ( ignored != null ) + if ( testIgnored != null ) { - reporter.testSkipped( createReportEntry( ignored ) ); + reporter.testSkipped( createReportEntry( testIgnored ) ); } else { @@ -128,6 +136,10 @@ else if ( testError != null ) { reporter.testError( createReportEntry( testError ) ); } + else if ( testAssumption != null ) + { + reporter.testAssumptionFailure( createReportEntry( testAssumption ) ); + } else { reporter.testSucceeded( descriptionReport ); From d6f38165dd5965014f84028d0b5e6ece24e3ebe4 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Fri, 5 May 2017 18:59:10 +0200 Subject: [PATCH 091/194] Obsolete class should be deleted in previous commit. --- .../util/internal/ByteBufferTest.java | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ByteBufferTest.java diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ByteBufferTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ByteBufferTest.java deleted file mode 100644 index 9728330f75..0000000000 --- a/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/ByteBufferTest.java +++ /dev/null @@ -1,48 +0,0 @@ -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 junit.framework.TestCase; - -/** - * @author Kristian Rosenvold - */ -public class ByteBufferTest - extends TestCase -{ - public void testAppend() - throws Exception - { - ByteBuffer byteBuffer = new ByteBuffer( 30 ); - byteBuffer.append( 'C' ); - byteBuffer.append( (byte) 'D' ); - assertEquals( "CD", byteBuffer.toString() ); - - } - - - public void testJoin() - { - byte[] b1 = "ABC".getBytes(); - byte[] b2 = "DE".getBytes(); - final byte[] join = ByteBuffer.join( b1, 0, 3, b2, 0, 2 ); - assertEquals( 5, join.length ); - } -} From 66dec2e586b0d0343f4ce1ae1a91a36bb2856e26 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 13 May 2017 19:07:31 +0200 Subject: [PATCH 092/194] [INFRA-14098] just a test and revert --- .../apache/maven/surefire/util/DefaultDirectoryScannerTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java index 4b24292eb6..c54ba838c9 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java @@ -37,6 +37,7 @@ public class DefaultDirectoryScannerTest public void testLocateTestClasses() throws IOException, TestSetFailedException { + System.out.println( "jdk9path=" + System.getProperty( "jdk9path" ) ); // use target as people can configure ide to compile in an other place than maven File baseDir = new File( new File( "target" ).getCanonicalPath() ); List include = new ArrayList(); From a7e867007699ac0746c6383e107815eb99bf6ee4 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Fri, 26 May 2017 20:51:46 +0200 Subject: [PATCH 093/194] Revert "[INFRA-14098] just a test and revert" This reverts commit 66dec2e586b0d0343f4ce1ae1a91a36bb2856e26. --- .../apache/maven/surefire/util/DefaultDirectoryScannerTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java index c54ba838c9..4b24292eb6 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java @@ -37,7 +37,6 @@ public class DefaultDirectoryScannerTest public void testLocateTestClasses() throws IOException, TestSetFailedException { - System.out.println( "jdk9path=" + System.getProperty( "jdk9path" ) ); // use target as people can configure ide to compile in an other place than maven File baseDir = new File( new File( "target" ).getCanonicalPath() ); List include = new ArrayList(); From 1ca8374d2618fa2667bd4a82c9684a30fba619d9 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 27 May 2017 14:28:05 +0200 Subject: [PATCH 094/194] more unit tests to see streams are properly decoded --- .../TestLessInputStreamBuilderTest.java | 26 +++++++++++++++++-- .../TestProvidingInputStreamTest.java | 22 ++++++++++++++++ .../booter/MasterProcessCommandTest.java | 16 ++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestLessInputStreamBuilderTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestLessInputStreamBuilderTest.java index 6dee0a47c0..5d9b5afb94 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestLessInputStreamBuilderTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestLessInputStreamBuilderTest.java @@ -20,10 +20,12 @@ */ import org.apache.maven.surefire.booter.Command; +import org.apache.maven.surefire.booter.MasterProcessCommand; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import java.io.DataInputStream; import java.io.IOException; import java.util.Iterator; import java.util.NoSuchElementException; @@ -31,12 +33,15 @@ import static org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStream.TestLessInputStreamBuilder; import static org.apache.maven.surefire.booter.Command.NOOP; import static org.apache.maven.surefire.booter.Command.SKIP_SINCE_NEXT_TEST; +import static org.apache.maven.surefire.booter.MasterProcessCommand.BYE_ACK; import static org.apache.maven.surefire.booter.MasterProcessCommand.SHUTDOWN; +import static org.apache.maven.surefire.booter.MasterProcessCommand.decode; import static org.apache.maven.surefire.booter.Shutdown.EXIT; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * Testing cached and immediate commands in {@link TestLessInputStream}. @@ -126,4 +131,21 @@ public void combinedCommands() e.expect( NoSuchElementException.class ); is.nextCommand(); } + + @Test + public void shouldDecodeTwoCommands() + throws IOException + { + TestLessInputStreamBuilder builder = new TestLessInputStreamBuilder(); + TestLessInputStream pluginIs = builder.build(); + builder.getImmediateCommands().acknowledgeByeEventReceived(); + builder.getImmediateCommands().noop(); + DataInputStream is = new DataInputStream( pluginIs ); + Command bye = decode( is ); + assertThat( bye, is( notNullValue() ) ); + assertThat( bye.getCommandType(), is( BYE_ACK ) ); + Command noop = decode( is ); + assertThat( noop, is( notNullValue() ) ); + assertThat( noop.getCommandType(), is( MasterProcessCommand.NOOP ) ); + } } 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 6f25ec3a02..3f94039097 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 @@ -19,15 +19,21 @@ * under the License. */ +import org.apache.maven.surefire.booter.Command; +import org.apache.maven.surefire.booter.MasterProcessCommand; import org.junit.Test; +import java.io.DataInputStream; import java.io.IOException; import java.util.ArrayDeque; import java.util.Queue; import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.FutureTask; import java.util.concurrent.TimeUnit; +import static org.apache.maven.surefire.booter.MasterProcessCommand.BYE_ACK; +import static org.apache.maven.surefire.booter.MasterProcessCommand.decode; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -130,6 +136,22 @@ public void run() assertThat( is.read(), is( (int) 't' ) ); } + @Test + public void shouldDecodeTwoCommands() + throws IOException + { + TestProvidingInputStream pluginIs = new TestProvidingInputStream( new ConcurrentLinkedDeque() ); + pluginIs.acknowledgeByeEventReceived(); + pluginIs.noop(); + DataInputStream is = new DataInputStream( pluginIs ); + Command bye = decode( is ); + assertThat( bye, is( notNullValue() ) ); + assertThat( bye.getCommandType(), is( BYE_ACK ) ); + Command noop = decode( is ); + assertThat( noop, is( notNullValue() ) ); + assertThat( noop.getCommandType(), is( MasterProcessCommand.NOOP ) ); + } + private static void sleep( long millis ) { try diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java index 6e66a18494..19740fdbf5 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java @@ -157,4 +157,20 @@ public void testEncodedDecodedIsSameForRunClass() assertThat( command.getCommandType(), is( RUN_CLASS ) ); assertThat( command.getData(), is( "pkg.Test" ) ); } + + public void testShouldDecodeTwoCommands() throws IOException + { + byte[] cmd1 = BYE_ACK.encode(); + byte[] cmd2 = NOOP.encode(); + byte[] stream = new byte[cmd1.length + cmd2.length]; + System.arraycopy( cmd1, 0, stream, 0, cmd1.length ); + System.arraycopy( cmd2, 0, stream, cmd1.length, cmd2.length ); + DataInputStream is = new DataInputStream( new ByteArrayInputStream( stream ) ); + Command bye = decode( is ); + assertNotNull( bye ); + assertThat( bye.getCommandType(), is( BYE_ACK ) ); + Command noop = decode( is ); + assertNotNull( noop ); + assertThat( noop.getCommandType(), is( NOOP ) ); + } } From 63657b6e754c378ce26f8cc75781f29671187b17 Mon Sep 17 00:00:00 2001 From: Tunaki Date: Sun, 28 May 2017 21:16:46 +0200 Subject: [PATCH 095/194] [SUREFIRE-1375] Fixing build on Windows cmd.exe --- maven-failsafe-plugin/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index ff773c7330..f42e6827bf 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -105,6 +105,10 @@ ../maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd ../maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb org.apache.maven.plugin.failsafe.xmlsummary + + -encoding + ${project.build.sourceEncoding} + From fac376c5f7d1b5ca9b2ec220b39b35397d04326a Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Fri, 2 Jun 2017 07:26:35 +0200 Subject: [PATCH 096/194] [SUREFIRE-1374] std/in stream corrupted error --- .../maven/surefire/booter/ForkedBooter.java | 20 +++++++++++-------- 1 file changed, 12 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 8dabaef23c..1e3863e26c 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 @@ -76,6 +76,7 @@ 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 CommandReader COMMAND_READER = startupMasterProcessReader(); private static volatile ScheduledThreadPoolExecutor jvmTerminator; private static volatile long systemExitTimeoutInSeconds = DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS; @@ -88,8 +89,7 @@ public final class ForkedBooter */ public static void main( String... args ) { - final CommandReader reader = startupMasterProcessReader(); - final ExecutorService pingScheduler = isDebugging() ? null : listenToShutdownCommands( reader ); + final ExecutorService pingScheduler = isDebugging() ? null : listenToShutdownCommands(); final PrintStream originalOut = out; try { @@ -159,7 +159,7 @@ else if ( readTestsFromInputStream ) encode( stringBuilder, stackTraceWriter, false ); encodeAndWriteToOutput( ( (char) BOOTERCODE_ERROR ) + ",0," + stringBuilder + "\n", originalOut ); } - acknowledgedExit( reader, originalOut, pingScheduler ); + acknowledgedExit( originalOut, pingScheduler ); } catch ( Throwable t ) { @@ -202,11 +202,11 @@ private static CommandReader startupMasterProcessReader() return getReader(); } - private static ExecutorService listenToShutdownCommands( CommandReader reader ) + private static ExecutorService listenToShutdownCommands() { - reader.addShutdownListener( createExitHandler() ); + COMMAND_READER.addShutdownListener( createExitHandler() ); AtomicBoolean pingDone = new AtomicBoolean( true ); - reader.addNoopListener( createPingHandler( pingDone ) ); + COMMAND_READER.addNoopListener( createPingHandler( pingDone ) ); Runnable pingJob = createPingJob( pingDone ); ScheduledExecutorService pingScheduler = createPingScheduler(); pingScheduler.scheduleAtFixedRate( pingJob, 0, PING_TIMEOUT_IN_SECONDS, SECONDS ); @@ -275,19 +275,21 @@ private static void encodeAndWriteToOutput( String string, PrintStream out ) private static void kill() { + COMMAND_READER.stop(); Runtime.getRuntime().halt( 1 ); } private static void exit( int returnCode ) { launchLastDitchDaemonShutdownThread( returnCode ); + COMMAND_READER.stop(); System.exit( returnCode ); } - private static void acknowledgedExit( CommandReader reader, PrintStream originalOut, ExecutorService pingScheduler ) + private static void acknowledgedExit( PrintStream originalOut, ExecutorService pingScheduler ) { final Semaphore barrier = new Semaphore( 0 ); - reader.addByeAckListener( new CommandListener() + COMMAND_READER.addByeAckListener( new CommandListener() { @Override public void update( Command command ) @@ -301,6 +303,7 @@ public void update( Command command ) long timeoutMillis = max( systemExitTimeoutInSeconds * ONE_SECOND_IN_MILLIS, ONE_SECOND_IN_MILLIS ); acquireOnePermit( barrier, timeoutMillis ); cancelPingScheduler( pingScheduler ); + COMMAND_READER.stop(); System.exit( 0 ); } @@ -367,6 +370,7 @@ private static void launchLastDitchDaemonShutdownThread( final int returnCode ) @Override public void run() { + COMMAND_READER.stop(); Runtime.getRuntime().halt( returnCode ); } }, systemExitTimeoutInSeconds, SECONDS From 59c065f5d4a5a9c181ef9ce788b31305886e8592 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 3 Jun 2017 08:55:23 +0200 Subject: [PATCH 097/194] [SUREFIRE-1376] "The forked VM terminated without properly saying goodbye" when running Surefire in a very deep project structure on Windows --- .../maven/plugin/surefire/SurefireHelper.java | 33 +++++++++++++++++++ .../booterclient/ForkConfiguration.java | 13 ++++---- .../plugin/surefire/SurefireHelperTest.java | 24 ++++++++++++++ 3 files changed, 63 insertions(+), 7 deletions(-) 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 8bdf75e2b6..cd49249d44 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 @@ -36,6 +36,7 @@ import java.util.List; import static java.util.Collections.unmodifiableList; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; import static org.apache.maven.surefire.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; @@ -55,6 +56,19 @@ public final class SurefireHelper public static final String DUMPSTREAM_FILENAME_FORMATTER = DUMP_FILE_PREFIX + "%d" + DUMPSTREAM_FILE_EXT; + /** + * see sun/nio/fs/WindowsPath
    + * http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/7534523b4174/src/windows/classes/sun/nio/fs/WindowsPath.java#l46 + * https://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath + *
    + *
    + * The maximum path that does not require long path prefix. On Windows
    + * the maximum path is 260 minus 1 (NUL) but for directories it is 260
    + * minus 12 minus 1 (to allow for the creation of a 8.3 file in the
    + * directory). + */ + private static final int MAX_PATH_LENGTH_WINDOWS = 247; + private static final String[] DUMP_FILES_PRINT = { "[date]-jvmRun[N]" + DUMP_FILE_EXT, @@ -165,6 +179,25 @@ else if ( cli.contains( SHOW_ERRORS ) ) } } + /** + * Normalized file path for Windows; otherwise returns {@code path}. + *
    + * http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/7534523b4174/src/windows/classes/sun/nio/fs/WindowsPath.java#l46 + *
    + * https://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath + * + * @param path source path + * @return escaped to platform path + */ + public static String escapeToPlatformPath( String path ) + { + if ( IS_OS_WINDOWS && path.length() > MAX_PATH_LENGTH_WINDOWS ) + { + path = path.startsWith( "\\\\" ) ? "\\\\?\\UNC\\" + path.substring( 2 ) : "\\\\?\\" + path; + } + return path; + } + private static String getFailureBehavior( MavenExecutionRequest request ) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { 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 cd4ae2ba92..2768210630 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,13 +21,13 @@ import org.apache.maven.plugin.surefire.AbstractSurefireMojo; import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline; -import org.apache.maven.surefire.util.internal.ImmutableMap; 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 org.apache.maven.surefire.util.internal.ImmutableMap; import java.io.File; import java.io.FileOutputStream; @@ -41,6 +41,8 @@ import java.util.jar.JarOutputStream; import java.util.jar.Manifest; +import static org.apache.maven.plugin.surefire.SurefireHelper.escapeToPlatformPath; + /** * Configuration for forking tests. * @@ -174,19 +176,16 @@ OutputStreamFlushableCommandline createCommandLine( List classPath, bool if ( useJar ) { - File jarFile; try { - jarFile = createJar( classPath, providerThatHasMainMethod ); + File jarFile = createJar( classPath, providerThatHasMainMethod ); + cli.createArg().setValue( "-jar" ); + cli.createArg().setValue( escapeToPlatformPath( jarFile.getAbsolutePath() ) ); } catch ( IOException e ) { throw new SurefireBooterForkException( "Error creating archive file", e ); } - - cli.createArg().setValue( "-jar" ); - - cli.createArg().setValue( jarFile.getAbsolutePath() ); } else { diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java index b249aca0e2..c00f7f9ecc 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java @@ -26,7 +26,10 @@ import static java.util.Collections.addAll; import static java.util.Collections.singleton; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; +import static org.apache.maven.plugin.surefire.SurefireHelper.escapeToPlatformPath; import static org.fest.assertions.Assertions.assertThat; +import static org.junit.Assume.assumeTrue; /** * Test of {@link SurefireHelper}. @@ -62,4 +65,25 @@ public void testConstants() assertThat( String.format( SurefireHelper.DUMPSTREAM_FILENAME_FORMATTER, 5) ) .endsWith( "-jvmRun5.dumpstream" ); } + + @Test + public void shouldEscapeWindowsPath() + { + assumeTrue( IS_OS_WINDOWS ); + String root = "X:\\path\\to\\project\\"; + String pathToJar = "target\\surefire\\surefirebooter4942721306300108667.jar"; + int projectNameLength = 247 - root.length() - pathToJar.length(); + StringBuilder projectFolder = new StringBuilder(); + for ( int i = 0; i < projectNameLength; i++ ) + { + projectFolder.append( 'x' ); + } + String path = root + projectFolder + "\\" + pathToJar; + String escaped = escapeToPlatformPath( path ); + assertThat( escaped ).isEqualTo( "\\\\?\\" + path ); + + path = root + "\\" + pathToJar; + escaped = escapeToPlatformPath( path ); + assertThat( escaped ).isEqualTo( root + "\\" + pathToJar ); + } } From f1f3b6fab9e6179a9faa7537be49354fa58e7685 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 3 Jun 2017 13:40:12 +0200 Subject: [PATCH 098/194] [SUREFIRE-1380] AbstractCommandStream should flush data if another Thread marks the stream closed, empty shared buffer. --- .../booterclient/lazytestprovider/AbstractCommandStream.java | 1 + 1 file changed, 1 insertion(+) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java index 0bc2036b12..075d92eae5 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java @@ -90,6 +90,7 @@ public int read() { if ( isClosed() ) { + tryFlush(); return -1; } From 9c77aa40d1d4fc3455f6059d06a21341ba593c99 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 4 Jun 2017 23:42:27 +0200 Subject: [PATCH 099/194] [SUREFIRE-1381] Refactoring in AbstractCommandStream and MasterProcessCommand --- .../AbstractCommandStream.java | 21 ++++++------------- .../surefire/booter/MasterProcessCommand.java | 13 +++++++----- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java index 075d92eae5..31b56c4c1f 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/AbstractCommandStream.java @@ -36,7 +36,6 @@ public abstract class AbstractCommandStream { private byte[] currentBuffer; private int currentPos; - private volatile MasterProcessCommand lastCommand; protected abstract boolean isClosed(); @@ -71,12 +70,6 @@ protected final void invalidateInternalBuffer() currentPos = 0; } - @Deprecated - protected final MasterProcessCommand getLastCommand() - { - return lastCommand; - } - /** * Used by single thread in StreamFeeder class. * @@ -94,8 +87,7 @@ public int read() return -1; } - byte[] buffer = currentBuffer; - if ( buffer == null ) + if ( currentBuffer == null ) { tryFlush(); @@ -113,17 +105,16 @@ public int read() } Command cmd = nextCommand(); - lastCommand = cmd.getCommandType(); - buffer = lastCommand.hasDataType() ? lastCommand.encode( cmd.getData() ) : lastCommand.encode(); + MasterProcessCommand cmdType = cmd.getCommandType(); + currentBuffer = cmdType.hasDataType() ? cmdType.encode( cmd.getData() ) : cmdType.encode(); } - int b = buffer[currentPos++] & 0xff; - if ( currentPos == buffer.length ) + int b = currentBuffer[currentPos++] & 0xff; + if ( currentPos == currentBuffer.length ) { - buffer = null; + currentBuffer = null; currentPos = 0; } - currentBuffer = buffer; return b; } } 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 c82c798b9e..5d47212220 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 @@ -84,12 +84,15 @@ public byte[] encode( String data ) throw new IllegalArgumentException( "Data type can be only " + String.class ); } - byte[] dataBytes = fromDataType( data ); - byte[] encoded = new byte[8 + dataBytes.length]; - int command = getId(); - int len = dataBytes.length; + final byte[] dataBytes = fromDataType( data ); + final int len = dataBytes.length; + + final byte[] encoded = new byte[8 + len]; + + final int command = getId(); setCommandAndDataLength( command, len, encoded ); - System.arraycopy( dataBytes, 0, encoded, 8, dataBytes.length ); + System.arraycopy( dataBytes, 0, encoded, 8, len ); + return encoded; } From dd518d2b14e797014ec740360afc3d2c79642b3a Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 6 Jun 2017 07:57:46 +0200 Subject: [PATCH 100/194] Fixed Javadoc after 1376 to successful build. --- .../maven/plugin/surefire/SurefireHelper.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) 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 cd49249d44..dd29cb4f9d 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 @@ -57,15 +57,15 @@ public final class SurefireHelper public static final String DUMPSTREAM_FILENAME_FORMATTER = DUMP_FILE_PREFIX + "%d" + DUMPSTREAM_FILE_EXT; /** - * see sun/nio/fs/WindowsPath
    - * http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/7534523b4174/src/windows/classes/sun/nio/fs/WindowsPath.java#l46 - * https://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath + * The maximum path that does not require long path prefix on Windows.
    + * See {@code sun/nio/fs/WindowsPath} in + * + * OpenJDK + * and MSDN article. *
    - *
    - * The maximum path that does not require long path prefix. On Windows
    - * the maximum path is 260 minus 1 (NUL) but for directories it is 260
    - * minus 12 minus 1 (to allow for the creation of a 8.3 file in the
    - * directory). + * The maximum path is 260 minus 1 (NUL) but for directories it is 260 + * minus 12 minus 1 (to allow for the creation of a 8.3 file in the directory). */ private static final int MAX_PATH_LENGTH_WINDOWS = 247; @@ -180,11 +180,14 @@ else if ( cli.contains( SHOW_ERRORS ) ) } /** - * Normalized file path for Windows; otherwise returns {@code path}. - *
    - * http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/7534523b4174/src/windows/classes/sun/nio/fs/WindowsPath.java#l46 + * Escape file path for Windows when the path is too long; otherwise returns {@code path}. *
    - * https://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath + * See + * sun/nio/fs/WindowsPath for "long path" value explanation (=247), and + * MSDN article + * for detailed escaping strategy explanation: in short, {@code \\?\} prefix for path with drive letter + * or {@code \\?\UNC\} for UNC path. * * @param path source path * @return escaped to platform path From 7176d3c17b438c60e48a525ef96e6812f00bec46 Mon Sep 17 00:00:00 2001 From: Nicola Ferraro Date: Wed, 14 Jun 2017 12:48:06 +0200 Subject: [PATCH 101/194] SUREFIRE-1382: fixing out of memory error --- .../booterclient/output/MultipleFailureException.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 4149ad9c90..060994b27b 100644 --- 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 @@ -42,7 +42,7 @@ boolean hasNestedExceptions() public String getLocalizedMessage() { StringBuilder messages = new StringBuilder(); - for ( Throwable exception = exceptions.peek(); exception != null; exception = exceptions.peek() ) + for ( Throwable exception : exceptions ) { if ( messages.length() != 0 ) { @@ -58,7 +58,7 @@ public String getLocalizedMessage() public String getMessage() { StringBuilder messages = new StringBuilder(); - for ( Throwable exception = exceptions.peek(); exception != null; exception = exceptions.peek() ) + for ( Throwable exception : exceptions ) { if ( messages.length() != 0 ) { From c343cc412b986fd9da839696c709542d03679d68 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 25 Jun 2017 23:16:04 +0200 Subject: [PATCH 102/194] [SUREFIRE-1302] Surefire does not wait long enough for the forked VM and assumes it to be dead --- maven-failsafe-plugin/pom.xml | 17 - maven-surefire-common/pom.xml | 6 + .../surefire/report/FileReporterUtils.java | 11 +- maven-surefire-plugin/pom.xml | 17 - .../src/site/apt/examples/shutdown.apt.vm | 9 + maven-surefire-report-plugin/pom.xml | 4 - pom.xml | 17 +- surefire-api/pom.xml | 10 +- .../maven/surefire/booter/CommandReader.java | 4 +- surefire-booter/pom.xml | 25 +- .../maven/surefire/booter/ForkedBooter.java | 71 +++- .../maven/surefire/booter/PpidChecker.java | 382 ++++++++++++++++++ .../maven/surefire/booter/ProcessInfo.java | 77 ++++ .../surefire/booter/JUnit4SuiteTest.java | 3 +- .../surefire/booter/PpidCheckerTest.java | 204 ++++++++++ ...efire1295AttributeJvmCrashesToTestsIT.java | 6 +- 16 files changed, 793 insertions(+), 70 deletions(-) create mode 100644 surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java create mode 100644 surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java create mode 100644 surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index f42e6827bf..ec48929ec6 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -44,27 +44,10 @@ - - org.apache.maven - maven-plugin-api - org.apache.maven.surefire maven-surefire-common - - org.apache.maven.surefire - surefire-api - - - org.apache.maven.shared - maven-shared-utils - - - org.apache.maven.plugin-tools - maven-plugin-annotations - compile - org.apache.maven.plugins maven-surefire-plugin diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index 4064bc2c8e..e911a4cd53 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -93,6 +93,7 @@ com.google.code.findbugs jsr305 + provided org.apache.maven.shared @@ -192,6 +193,7 @@ org.apache.maven.shared:maven-shared-utils org.apache.maven.shared:maven-common-artifact-filters commons-io:commons-io + org.apache.commons:commons-lang3 @@ -203,6 +205,10 @@ org.apache.commons.io org.apache.maven.surefire.shade.org.apache.commons.io + + org.apache.commons.lang3 + org.apache.maven.surefire.shade.org.apache.commons.lang3 + diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java index 36bc269516..fd33d8ed02 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java @@ -19,6 +19,8 @@ * under the License. */ +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; + /** * Utils class for file-based reporters * @@ -45,13 +47,6 @@ public static String stripIllegalFilenameChars( String original ) private static String getOSSpecificIllegalChars() { - if ( System.getProperty( "os.name" ).toLowerCase().startsWith( "win" ) ) - { - return "\\/:*?\"<>|\0"; - } - else - { - return "/\0"; - } + return IS_OS_WINDOWS ? "\\/:*?\"<>|\0" : "/\0"; } } diff --git a/maven-surefire-plugin/pom.xml b/maven-surefire-plugin/pom.xml index 62ec4a7422..2a186e3489 100644 --- a/maven-surefire-plugin/pom.xml +++ b/maven-surefire-plugin/pom.xml @@ -44,27 +44,10 @@ - - org.apache.maven - maven-plugin-api - org.apache.maven.surefire maven-surefire-common - - org.apache.maven.surefire - surefire-api - - - org.apache.maven - maven-toolchain - - - org.apache.maven.plugin-tools - maven-plugin-annotations - compile - 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 a5468530c3..4c4a0a3df3 100644 --- a/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm +++ b/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm @@ -39,6 +39,15 @@ Shutdown of Forked JVM * Pinging forked JVM + << Since ${thisPlugin} Plugin 2.20.1 ping is platform dependent and fallbacks to old mechanism if platform is + not recognized or native commands fail in Java. >> + + Simply the mechanism checks the <<>> still exists and it is not reused by OS in another application. + If parent (normally Maven) process has died, the forked JVM is killed. + + + << Since ${thisPlugin} Plugin 2.19 the old mechanism is significantly slower: >> + The master process sends NOOP command to a forked JVM every 10 seconds. Forked JVM is waiting for the command every 20 seconds. If the master process is killed (received SIGKILL signal) or shutdown diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml index a4fe7e293a..93a2e803ea 100644 --- a/maven-surefire-report-plugin/pom.xml +++ b/maven-surefire-report-plugin/pom.xml @@ -47,10 +47,6 @@ - - org.apache.maven.surefire - surefire-logger-api - org.apache.maven maven-project diff --git a/pom.xml b/pom.xml index 962a5bf74f..397d5d9dff 100644 --- a/pom.xml +++ b/pom.xml @@ -91,6 +91,9 @@ 2.2.1 3.3 + 3.5 + 2.5 + 0.9 scm:git:https://git-wip-us.apache.org/repos/asf/maven-surefire.git surefire-archives/surefire-LATEST @@ -105,12 +108,12 @@ org.apache.commons commons-lang3 - 3.1 + ${commonsLang3Version} commons-io commons-io - 2.2 + ${commonsIoVersion} org.apache.maven.surefire @@ -215,7 +218,13 @@ org.apache.maven.shared maven-shared-utils - 0.9 + ${mavenSharedUtilsVersion} + + + com.google.code.findbugs + jsr305 + + org.apache.maven.shared @@ -377,7 +386,7 @@ maven-shade-plugin - 1.5 + 3.0.0 maven-plugin-plugin diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml index 7e407d2ba2..96c5be3537 100644 --- a/surefire-api/pom.xml +++ b/surefire-api/pom.xml @@ -40,6 +40,11 @@ org.apache.maven.shared maven-shared-utils + + com.google.code.findbugs + jsr305 + provided + @@ -74,7 +79,6 @@ org.apache.maven.shared:maven-shared-utils - commons-lang:commons-lang @@ -82,10 +86,6 @@ org.apache.maven.shared org.apache.maven.surefire.shade.org.apache.maven.shared - - org.apache.commons.lang - org.apache.maven.surefire.shade.org.apache.commons.lang - 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 ed7d4fadff..c3d80eaf26 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 @@ -438,7 +438,7 @@ public void run() DumpErrorSingleton.getSingleton().dumpStreamException( e, msg ); exitByConfiguration(); - // does not go to finally + // does not go to finally for non-default config: Shutdown.EXIT or Shutdown.KILL } } catch ( IOException e ) @@ -493,7 +493,7 @@ else if ( shutdown.isKill() ) { Runtime.getRuntime().halt( 1 ); } - // else is default: should not happen; otherwise you missed enum case + // else is default: other than Shutdown.DEFAULT should not happen; otherwise you missed enum case } } } diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml index b79cceb381..65802a3425 100644 --- a/surefire-booter/pom.xml +++ b/surefire-booter/pom.xml @@ -36,6 +36,14 @@ org.apache.maven.surefire surefire-api + + org.apache.commons + commons-lang3 + + + commons-io + commons-io + @@ -50,6 +58,7 @@ + -DPpidCheckerTest.args=shouldFindPid true **/JUnit4SuiteTest.java @@ -69,13 +78,23 @@ true - commons-lang:commons-lang + org.apache.commons:commons-lang3 + commons-io:commons-io + org.apache.maven.shared:maven-shared-utils - org.apache.commons.lang - org.apache.maven.surefire.shade.org.apache.commons.lang + org.apache.commons.lang3 + org.apache.maven.surefire.shade.org.apache.commons.lang3 + + + org.apache.commons.io + org.apache.maven.surefire.shade.org.apache.commons.io + + + org.apache.maven.shared.utils + org.apache.maven.surefire.shade.org.apache.maven.shared.utils 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 1e3863e26c..22c2c04078 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 @@ -37,7 +37,9 @@ import java.security.AccessControlException; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.Semaphore; @@ -89,13 +91,15 @@ public final class ForkedBooter */ public static void main( String... args ) { - final ExecutorService pingScheduler = isDebugging() ? null : listenToShutdownCommands(); final PrintStream originalOut = out; + ExecutorService pingScheduler = null; try { final String tmpDir = args[0]; final String dumpFileName = args[1]; final String surefirePropsFileName = args[2]; + PpidChecker.uniqueCommandLineToken = surefirePropsFileName; + pingScheduler = isDebugging() ? null : listenToShutdownCommands(); BooterDeserializer booterDeserializer = new BooterDeserializer( createSurefirePropertiesIfFileExists( tmpDir, surefirePropsFileName ) ); @@ -207,12 +211,51 @@ private static ExecutorService listenToShutdownCommands() COMMAND_READER.addShutdownListener( createExitHandler() ); AtomicBoolean pingDone = new AtomicBoolean( true ); COMMAND_READER.addNoopListener( createPingHandler( pingDone ) ); - Runnable pingJob = createPingJob( pingDone ); ScheduledExecutorService pingScheduler = createPingScheduler(); - pingScheduler.scheduleAtFixedRate( pingJob, 0, PING_TIMEOUT_IN_SECONDS, SECONDS ); + Future checker = pingScheduler.submit( createProcessCheckerJob() ); + pingScheduler.scheduleWithFixedDelay( processCheckerJob( checker ), 0L, 1L, SECONDS ); + pingScheduler.scheduleAtFixedRate( createPingJob( pingDone, checker ), 0L, PING_TIMEOUT_IN_SECONDS, SECONDS ); return pingScheduler; } + private static Runnable processCheckerJob( final Future processChecker ) + { + return new Runnable() + { + @Override + public void run() + { + if ( processChecker.isDone() && !processChecker.isCancelled() ) + { + try + { + PpidChecker checker = processChecker.get(); + if ( checker.canUse() && !checker.isParentProcessAlive() && !processChecker.isCancelled() ) + { + kill(); + } + } + catch ( Exception e ) + { + // nothing to do + } + } + } + }; + } + + private static Callable createProcessCheckerJob() + { + return new Callable() + { + @Override + public PpidChecker call() throws Exception + { + return new PpidChecker(); + } + }; + } + private static CommandListener createPingHandler( final AtomicBoolean pingDone ) { return new CommandListener() @@ -246,13 +289,17 @@ else if ( shutdown.isExit() ) }; } - private static Runnable createPingJob( final AtomicBoolean pingDone ) + private static Runnable createPingJob( final AtomicBoolean pingDone, final Future processChecker ) { return new Runnable() { @Override public void run() { + if ( canUseNewPingMechanism( processChecker ) ) + { + return; + } boolean hasPing = pingDone.getAndSet( false ); if ( !hasPing ) { @@ -262,6 +309,18 @@ public void run() }; } + private static boolean canUseNewPingMechanism( Future processChecker ) + { + try + { + return ( !processChecker.isDone() || processChecker.get().canUse() ) && !processChecker.isCancelled(); + } + catch ( Exception e ) + { + return false; + } + } + private static void encodeAndWriteToOutput( String string, PrintStream out ) { byte[] encodeBytes = encodeStringForForkCommunication( string ); @@ -357,8 +416,8 @@ private static ScheduledExecutorService createPingScheduler() { ThreadFactory threadFactory = newDaemonThreadFactory( "ping-" + PING_TIMEOUT_IN_SECONDS + "s" ); ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor( 1, threadFactory ); - executor.setMaximumPoolSize( 1 ); - executor.prestartCoreThread(); + executor.setKeepAliveTime( 3L, SECONDS ); + executor.setMaximumPoolSize( 3 ); return executor; } diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java new file mode 100644 index 0000000000..665f36df55 --- /dev/null +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java @@ -0,0 +1,382 @@ +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.shared.utils.cli.CommandLineException; +import org.apache.maven.shared.utils.cli.Commandline; +import org.apache.maven.shared.utils.cli.StreamConsumer; + +import java.io.File; +import java.lang.management.ManagementFactory; +import java.util.Locale; +import java.util.StringTokenizer; +import java.util.concurrent.atomic.AtomicReference; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static java.lang.Character.isDigit; +import static java.lang.Long.parseLong; +import static java.util.concurrent.TimeUnit.DAYS; +import static java.util.concurrent.TimeUnit.HOURS; +import static java.util.concurrent.TimeUnit.MINUTES; +import static java.util.regex.Pattern.compile; +import static org.apache.commons.lang3.SystemUtils.IS_OS_UNIX; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; +import static org.apache.maven.shared.utils.cli.CommandLineUtils.executeCommandLine; +import static org.apache.maven.surefire.booter.ProcessInfo.INVALID_PROCESS_INFO; + +/** + * Recognizes PPID. Determines lifetime of parent process. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +final class PpidChecker +{ + private static final String WMIC_CL = "CommandLine"; + + private static final String WMIC_PID = "ProcessId"; + + private static final String WMIC_PPID = "ParentProcessId"; + + private static final String WMIC_CREATION_DATE = "CreationDate"; + + private static final String WINDOWS_CMD = + "wmic process where (ProcessId=%s) get " + WMIC_CREATION_DATE + "," + WMIC_PPID; + + private static final String[] WINDOWS_PID_CMD = + { "wmic", "process", "where", "(Name='java.exe')", "get", WMIC_PID, ",", WMIC_CL }; + + private static final String UNIX_CMD1 = "/usr/bin/ps -o etime= -p $PPID"; + + private static final String UNIX_CMD2 = "/bin/ps -o etime= -p $PPID"; + + /** + * etime is in the form of [[dd-]hh:]mm:ss + */ + static final Pattern UNIX_CMD_OUT_PATTERN = compile( "^(((\\d+)-)?(\\d{2}):)?(\\d{2}):(\\d{2})$" ); + + private static final Pattern NUMBER_PATTERN = compile( "^\\d+$" ); + + static volatile String uniqueCommandLineToken; + + private final ProcessInfo parentProcessInfo; + + PpidChecker() + { + ProcessInfo parentProcess = INVALID_PROCESS_INFO; + if ( IS_OS_WINDOWS ) + { + String pid = pid(); + if ( pid == null && uniqueCommandLineToken != null ) + { + pid = pidOnWindows(); + } + + if ( pid != null ) + { + ProcessInfo currentProcessInfo = windows( pid ); + String ppid = currentProcessInfo.getPPID(); + parentProcess = currentProcessInfo.isValid() ? windows( ppid ) : INVALID_PROCESS_INFO; + } + } + else if ( IS_OS_UNIX ) + { + parentProcess = unix(); + } + parentProcessInfo = parentProcess.isValid() ? parentProcess : INVALID_PROCESS_INFO; + } + + boolean canUse() + { + return parentProcessInfo.isValid(); + } + + @SuppressWarnings( "unchecked" ) + boolean isParentProcessAlive() + { + if ( !canUse() ) + { + throw new IllegalStateException(); + } + + if ( IS_OS_WINDOWS ) + { + ProcessInfo pp = windows( parentProcessInfo.getPID() ); + // let's compare creation time, should be same unless killed or PPID is reused by OS into another process + return pp.isValid() && pp.getTime().compareTo( parentProcessInfo.getTime() ) == 0; + } + else if ( IS_OS_UNIX ) + { + ProcessInfo pp = unix(); + // let's compare elapsed time, should be greater or equal if parent process is the same and still alive + return pp.isValid() && pp.getTime().compareTo( parentProcessInfo.getTime() ) >= 0; + } + + throw new IllegalStateException(); + } + + // https://www.freebsd.org/cgi/man.cgi?ps(1) + // etimes elapsed running time, in decimal integer seconds + + // http://manpages.ubuntu.com/manpages/xenial/man1/ps.1.html + // etimes elapsed time since the process was started, in seconds. + + // http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/9b8c96f96a0f/test/java/lang/ProcessBuilder/Basic.java#L167 + static ProcessInfo unix() + { + Commandline cli = new Commandline(); + cli.getShell().setQuotedArgumentsEnabled( false ); + cli.createArg().setLine( new File( "/usr/bin/ps" ).canExecute() ? UNIX_CMD1 : UNIX_CMD2 ); + final AtomicReference processInfo = new AtomicReference( INVALID_PROCESS_INFO ); + try + { + final int exitCode = executeCommandLine( cli, new StreamConsumer() + { + @Override + public void consumeLine( String line ) + { + if ( processInfo.get().isValid() ) + { + return; + } + line = line.trim(); + if ( !line.isEmpty() ) + { + Matcher matcher = UNIX_CMD_OUT_PATTERN.matcher( line ); + if ( matcher.matches() ) + { + long pidUptime = fromDays( matcher ) + + fromHours( matcher ) + + fromMinutes( matcher ) + + fromSeconds( matcher ); + processInfo.set( ProcessInfo.unixProcessInfo( pidUptime ) ); + } + } + } + }, null + ); + return exitCode == 0 ? processInfo.get() : INVALID_PROCESS_INFO; + } + catch ( CommandLineException e ) + { + return INVALID_PROCESS_INFO; + } + } + + static String pid() + { + String processName = ManagementFactory.getRuntimeMXBean().getName(); + if ( processName != null && processName.contains( "@" ) ) + { + String pid = processName.substring( 0, processName.indexOf( '@' ) ).trim(); + if ( NUMBER_PATTERN.matcher( pid ).matches() ) + { + return pid; + } + } + return null; + } + + static String pidOnWindows() + { + final AtomicReference pid = new AtomicReference(); + Commandline cli = new Commandline(); + cli.getShell().setQuotedArgumentsEnabled( false ); + cli.addArguments( WINDOWS_PID_CMD ); + try + { + final int exitCode = executeCommandLine( cli, new StreamConsumer() + { + private boolean hasHeader; + private boolean isPidFirst; + + @Override + public void consumeLine( String line ) + { + line = line.trim(); + if ( line.isEmpty() ) + { + return; + } + + if ( hasHeader ) + { + if ( line.contains( uniqueCommandLineToken ) ) + { + String extractedPid = + isPidFirst ? extractNumberFromBegin( line ) : extractNumberFromEnd( line ); + pid.set( extractedPid ); + } + } + else + { + StringTokenizer args = new StringTokenizer( line ); + if ( args.countTokens() == 2 ) + { + String arg0 = args.nextToken(); + String arg1 = args.nextToken(); + isPidFirst = WMIC_PID.equals( arg0 ); + hasHeader = WMIC_PID.equals( arg0 ) || WMIC_CL.equals( arg0 ); + hasHeader &= WMIC_PID.equals( arg1 ) || WMIC_CL.equals( arg1 ); + } + } + } + }, null + ); + return exitCode == 0 ? pid.get() : null; + } + catch ( CommandLineException e ) + { + return null; + } + } + + static ProcessInfo windows( final String pid ) + { + Commandline cli = new Commandline(); + cli.getShell().setQuotedArgumentsEnabled( false ); + cli.createArg().setLine( String.format( Locale.ROOT, WINDOWS_CMD, pid ) ); + + final AtomicReference processInfo = new AtomicReference( INVALID_PROCESS_INFO ); + try + { + final int exitCode = executeCommandLine( cli, new StreamConsumer() + { + private boolean hasHeader; + private boolean isStartTimestampFirst; + + @Override + public void consumeLine( String line ) + { + if ( processInfo.get().isValid() ) + { + return; + } + + line = line.trim(); + + if ( line.isEmpty() ) + { + return; + } + + if ( hasHeader ) + { + StringTokenizer args = new StringTokenizer( line ); + if ( args.countTokens() == 2 ) + { + if ( isStartTimestampFirst ) + { + String startTimestamp = args.nextToken(); + String ppid = args.nextToken(); + processInfo.set( ProcessInfo.windowsProcessInfo( pid, startTimestamp, ppid ) ); + } + else + { + String ppid = args.nextToken(); + String startTimestamp = args.nextToken(); + processInfo.set( ProcessInfo.windowsProcessInfo( pid, startTimestamp, ppid ) ); + } + } + } + else + { + StringTokenizer args = new StringTokenizer( line ); + if ( args.countTokens() == 2 ) + { + String arg0 = args.nextToken(); + String arg1 = args.nextToken(); + isStartTimestampFirst = WMIC_CREATION_DATE.equals( arg0 ); + hasHeader = WMIC_CREATION_DATE.equals( arg0 ) || WMIC_PPID.equals( arg0 ); + hasHeader &= WMIC_CREATION_DATE.equals( arg1 ) || WMIC_PPID.equals( arg1 ); + } + } + } + }, null + ); + return exitCode == 0 ? processInfo.get() : INVALID_PROCESS_INFO; + } + catch ( CommandLineException e ) + { + return INVALID_PROCESS_INFO; + } + } + + static long fromDays( Matcher matcher ) + { + String s = matcher.group( 3 ); + return s == null ? 0L : DAYS.toSeconds( parseLong( s ) ); + } + + static long fromHours( Matcher matcher ) + { + String s = matcher.group( 4 ); + return s == null ? 0L : HOURS.toSeconds( parseLong( s ) ); + } + + static long fromMinutes( Matcher matcher ) + { + String s = matcher.group( 5 ); + return s == null ? 0L : MINUTES.toSeconds( parseLong( s ) ); + } + + static long fromSeconds( Matcher matcher ) + { + String s = matcher.group( 6 ); + return s == null ? 0L : parseLong( s ); + } + + static String extractNumberFromBegin( String line ) + { + StringBuilder number = new StringBuilder(); + for ( int i = 0, len = line.length(); i < len; i++ ) + { + char c = line.charAt( i ); + if ( isDigit( c ) ) + { + number.append( c ); + } + else + { + break; + } + } + return number.toString(); + } + + static String extractNumberFromEnd( String line ) + { + StringBuilder number = new StringBuilder(); + for ( int i = line.length() - 1; i >= 0; i-- ) + { + char c = line.charAt( i ); + if ( isDigit( c ) ) + { + number.insert( 0, c ); + } + else + { + break; + } + } + return number.toString(); + } +} diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java new file mode 100644 index 0000000000..a300658b5e --- /dev/null +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java @@ -0,0 +1,77 @@ +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. + */ + +/** + * PID, PPID, elapsed time (Unix) or start time (Windows). + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +final class ProcessInfo +{ + static final ProcessInfo INVALID_PROCESS_INFO = new ProcessInfo( null, null, null ); + + /** + * On Unix we do not get PID due to the command is interested only to etime of PPID: + *
    + *

    /bin/ps -o etime= -p $PPID
    + */ + static ProcessInfo unixProcessInfo( long etime ) + { + return new ProcessInfo( "pid not needed on Unix", etime, null ); + } + + static ProcessInfo windowsProcessInfo( String pid, String startTimestamp, String ppid ) + { + return new ProcessInfo( pid, startTimestamp, ppid ); + } + + private final String pid; + private final Comparable time; + private final String ppid; + + private ProcessInfo( String pid, Comparable time, String ppid ) + { + this.pid = pid; + this.time = time; + this.ppid = ppid; + } + + boolean isValid() + { + return pid != null && time != null; + } + + String getPID() + { + return pid; + } + + Comparable getTime() + { + return time; + } + + String getPPID() + { + return ppid; + } +} diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java index 2bdcf21b3c..b08423fc34 100644 --- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java @@ -34,7 +34,8 @@ ClasspathTest.class, CommandReaderTest.class, PropertiesWrapperTest.class, - SurefireReflectorTest.class + SurefireReflectorTest.class, + PpidCheckerTest.class } ) @RunWith( Suite.class ) public class JUnit4SuiteTest diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java new file mode 100644 index 0000000000..2d49f6283b --- /dev/null +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java @@ -0,0 +1,204 @@ +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.junit.Test; + +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; + +import static org.apache.commons.lang3.SystemUtils.IS_OS_UNIX; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; +import static org.fest.assertions.Assertions.assertThat; +import static org.junit.Assume.assumeTrue; + +/** + * Testing {@link PpidChecker} on a platform. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public class PpidCheckerTest +{ + @Test + public void shouldHavePid() + { + String pid = PpidChecker.pid(); + + assertThat( pid ) + .isNotNull(); + + assertThat( pid ) + .matches( "^\\d+$" ); + } + + @Test + public void shouldHavePpidAsWindows() + { + assumeTrue( IS_OS_WINDOWS ); + + ProcessInfo processInfo = PpidChecker.windows( PpidChecker.pid() ); + + assertThat( processInfo ) + .isNotNull(); + + assertThat( processInfo.getPID() ) + .isNotNull(); + + assertThat( processInfo.getPID() ) + .matches( "^\\d+$" ); + + assertThat( processInfo.getTime() ) + .isNotNull(); + + processInfo = PpidChecker.windows( processInfo.getPID() ); + + assertThat( processInfo.getPID() ) + .isNotNull(); + + assertThat( processInfo.getPID() ) + .matches( "^\\d+$" ); + + assertThat( processInfo.getTime() ) + .isNotNull(); + } + + @Test + public void shouldFindPid() + { + assumeTrue( IS_OS_WINDOWS ); + + PpidChecker.uniqueCommandLineToken = "PpidCheckerTest.args=shouldFindPid"; + String pid = PpidChecker.pidOnWindows(); + + assertThat( pid ) + .isNotNull(); + + assertThat( pid ) + .isEqualTo( PpidChecker.pid() ); + } + + @Test + public void shouldHavePpidAsUnix() + { + assumeTrue( IS_OS_UNIX ); + + ProcessInfo processInfo = PpidChecker.unix(); + + assertThat( processInfo ) + .isNotNull(); + + assertThat( processInfo.getPID() ) + .isNotNull(); + + assertThat( processInfo.getPID() ) + .isEqualTo( "pid not needed on Unix" ); + + assertThat( processInfo.getTime() ) + .isNotNull(); + } + + @Test + public void shouldFindAliveParentProcess() + throws InterruptedException + { + PpidChecker checker = new PpidChecker(); + + assertThat( checker.canUse() ) + .isTrue(); + + TimeUnit.MILLISECONDS.sleep( 100L ); + + assertThat( checker.isParentProcessAlive() ) + .isTrue(); + } + + @Test + public void shouldParseEtime() + { + Matcher m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "38" ); + assertThat( m.matches() ) + .isFalse(); + + m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "05:38" ); + assertThat( m.matches() ) + .isTrue(); + assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 0L ); + assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 0L ); + assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); + assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); + + m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "00:05:38" ); + assertThat( m.matches() ) + .isTrue(); + assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 0L ); + assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 0L ); + assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); + assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); + + m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "01:05:38" ); + assertThat( m.matches() ) + .isTrue(); + assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 0L ); + assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 3600L ); + assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); + assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); + + m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "02-01:05:38" ); + assertThat( m.matches() ) + .isTrue(); + assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 2 * 24 * 3600L ); + assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 3600L ); + assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); + assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); + } + + @Test + public void shouldExtractNumberFromBegin() + { + String num = PpidChecker.extractNumberFromBegin( "123 abc" ); + assertThat( num ) + .isEqualTo( "123" ); + } + + @Test + public void shouldNotExtractNumberFromBegin() + { + String num = PpidChecker.extractNumberFromBegin( " 123 abc" ); + assertThat( num ) + .isEmpty(); + } + + @Test + public void shouldExtractNumberFromEnd() + { + String num = PpidChecker.extractNumberFromEnd( "abc 123" ); + assertThat( num ) + .isEqualTo( "123" ); + } + + @Test + public void shouldNotExtractNumberFromEnd() + { + String num = PpidChecker.extractNumberFromEnd( "abs 123 " ); + assertThat( num ) + .isEmpty(); + } +} 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 1fa88f654d..f051c1cf34 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,8 +27,9 @@ import org.junit.Test; import java.util.Iterator; -import java.util.Locale; +import static org.apache.commons.lang.SystemUtils.IS_OS_LINUX; +import static org.apache.commons.lang.SystemUtils.IS_OS_MAC_OSX; import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; @@ -46,8 +47,7 @@ public class Surefire1295AttributeJvmCrashesToTestsIT @Before public void skipWindows() { - String os = System.getProperty( "os.name" ).toLowerCase( Locale.ROOT ); - assumeTrue( os.equals( "mac os x" ) || os.equals( "linux" ) /*|| os.contains( "windows" )*/ ); + assumeTrue( IS_OS_LINUX || IS_OS_MAC_OSX ); } @Test From 58a4dad81b02dba8ccc0f3fe511e31bfaa914d43 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 26 Jul 2017 04:26:05 +0200 Subject: [PATCH 103/194] Revert "[SUREFIRE-1302] Surefire does not wait long enough for the forked VM and assumes it to be dead" This reverts commit c343cc412b986fd9da839696c709542d03679d68. --- maven-failsafe-plugin/pom.xml | 17 + maven-surefire-common/pom.xml | 6 - .../surefire/report/FileReporterUtils.java | 11 +- maven-surefire-plugin/pom.xml | 17 + .../src/site/apt/examples/shutdown.apt.vm | 9 - maven-surefire-report-plugin/pom.xml | 4 + pom.xml | 17 +- surefire-api/pom.xml | 10 +- .../maven/surefire/booter/CommandReader.java | 4 +- surefire-booter/pom.xml | 25 +- .../maven/surefire/booter/ForkedBooter.java | 71 +--- .../maven/surefire/booter/PpidChecker.java | 382 ------------------ .../maven/surefire/booter/ProcessInfo.java | 77 ---- .../surefire/booter/JUnit4SuiteTest.java | 3 +- .../surefire/booter/PpidCheckerTest.java | 204 ---------- ...efire1295AttributeJvmCrashesToTestsIT.java | 6 +- 16 files changed, 70 insertions(+), 793 deletions(-) delete mode 100644 surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java delete mode 100644 surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java delete mode 100644 surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index ec48929ec6..f42e6827bf 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -44,10 +44,27 @@ + + org.apache.maven + maven-plugin-api + org.apache.maven.surefire maven-surefire-common + + org.apache.maven.surefire + surefire-api + + + org.apache.maven.shared + maven-shared-utils + + + org.apache.maven.plugin-tools + maven-plugin-annotations + compile + org.apache.maven.plugins maven-surefire-plugin diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index e911a4cd53..4064bc2c8e 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -93,7 +93,6 @@ com.google.code.findbugs jsr305 - provided org.apache.maven.shared @@ -193,7 +192,6 @@ org.apache.maven.shared:maven-shared-utils org.apache.maven.shared:maven-common-artifact-filters commons-io:commons-io - org.apache.commons:commons-lang3 @@ -205,10 +203,6 @@ org.apache.commons.io org.apache.maven.surefire.shade.org.apache.commons.io - - org.apache.commons.lang3 - org.apache.maven.surefire.shade.org.apache.commons.lang3 -
    diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java index fd33d8ed02..36bc269516 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java @@ -19,8 +19,6 @@ * under the License. */ -import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; - /** * Utils class for file-based reporters * @@ -47,6 +45,13 @@ public static String stripIllegalFilenameChars( String original ) private static String getOSSpecificIllegalChars() { - return IS_OS_WINDOWS ? "\\/:*?\"<>|\0" : "/\0"; + if ( System.getProperty( "os.name" ).toLowerCase().startsWith( "win" ) ) + { + return "\\/:*?\"<>|\0"; + } + else + { + return "/\0"; + } } } diff --git a/maven-surefire-plugin/pom.xml b/maven-surefire-plugin/pom.xml index 2a186e3489..62ec4a7422 100644 --- a/maven-surefire-plugin/pom.xml +++ b/maven-surefire-plugin/pom.xml @@ -44,10 +44,27 @@ + + org.apache.maven + maven-plugin-api + org.apache.maven.surefire maven-surefire-common + + org.apache.maven.surefire + surefire-api + + + org.apache.maven + maven-toolchain + + + org.apache.maven.plugin-tools + maven-plugin-annotations + compile + 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 4c4a0a3df3..a5468530c3 100644 --- a/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm +++ b/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm @@ -39,15 +39,6 @@ Shutdown of Forked JVM * Pinging forked JVM - << Since ${thisPlugin} Plugin 2.20.1 ping is platform dependent and fallbacks to old mechanism if platform is - not recognized or native commands fail in Java. >> - - Simply the mechanism checks the <<>> still exists and it is not reused by OS in another application. - If parent (normally Maven) process has died, the forked JVM is killed. - - - << Since ${thisPlugin} Plugin 2.19 the old mechanism is significantly slower: >> - The master process sends NOOP command to a forked JVM every 10 seconds. Forked JVM is waiting for the command every 20 seconds. If the master process is killed (received SIGKILL signal) or shutdown diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml index 93a2e803ea..a4fe7e293a 100644 --- a/maven-surefire-report-plugin/pom.xml +++ b/maven-surefire-report-plugin/pom.xml @@ -47,6 +47,10 @@ + + org.apache.maven.surefire + surefire-logger-api + org.apache.maven maven-project diff --git a/pom.xml b/pom.xml index 397d5d9dff..962a5bf74f 100644 --- a/pom.xml +++ b/pom.xml @@ -91,9 +91,6 @@ 2.2.1 3.3 - 3.5 - 2.5 - 0.9 scm:git:https://git-wip-us.apache.org/repos/asf/maven-surefire.git surefire-archives/surefire-LATEST @@ -108,12 +105,12 @@ org.apache.commons commons-lang3 - ${commonsLang3Version} + 3.1 commons-io commons-io - ${commonsIoVersion} + 2.2 org.apache.maven.surefire @@ -218,13 +215,7 @@ org.apache.maven.shared maven-shared-utils - ${mavenSharedUtilsVersion} - - - com.google.code.findbugs - jsr305 - - + 0.9 org.apache.maven.shared @@ -386,7 +377,7 @@
    maven-shade-plugin - 3.0.0 + 1.5 maven-plugin-plugin diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml index 96c5be3537..7e407d2ba2 100644 --- a/surefire-api/pom.xml +++ b/surefire-api/pom.xml @@ -40,11 +40,6 @@ org.apache.maven.shared maven-shared-utils - - com.google.code.findbugs - jsr305 - provided - @@ -79,6 +74,7 @@ org.apache.maven.shared:maven-shared-utils + commons-lang:commons-lang @@ -86,6 +82,10 @@ org.apache.maven.shared org.apache.maven.surefire.shade.org.apache.maven.shared + + org.apache.commons.lang + org.apache.maven.surefire.shade.org.apache.commons.lang + 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 c3d80eaf26..ed7d4fadff 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 @@ -438,7 +438,7 @@ public void run() DumpErrorSingleton.getSingleton().dumpStreamException( e, msg ); exitByConfiguration(); - // does not go to finally for non-default config: Shutdown.EXIT or Shutdown.KILL + // does not go to finally } } catch ( IOException e ) @@ -493,7 +493,7 @@ else if ( shutdown.isKill() ) { Runtime.getRuntime().halt( 1 ); } - // else is default: other than Shutdown.DEFAULT should not happen; otherwise you missed enum case + // else is default: should not happen; otherwise you missed enum case } } } diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml index 65802a3425..b79cceb381 100644 --- a/surefire-booter/pom.xml +++ b/surefire-booter/pom.xml @@ -36,14 +36,6 @@ org.apache.maven.surefire surefire-api - - org.apache.commons - commons-lang3 - - - commons-io - commons-io - @@ -58,7 +50,6 @@ - -DPpidCheckerTest.args=shouldFindPid true **/JUnit4SuiteTest.java @@ -78,23 +69,13 @@ true - org.apache.commons:commons-lang3 - commons-io:commons-io - org.apache.maven.shared:maven-shared-utils + commons-lang:commons-lang - org.apache.commons.lang3 - org.apache.maven.surefire.shade.org.apache.commons.lang3 - - - org.apache.commons.io - org.apache.maven.surefire.shade.org.apache.commons.io - - - org.apache.maven.shared.utils - org.apache.maven.surefire.shade.org.apache.maven.shared.utils + org.apache.commons.lang + org.apache.maven.surefire.shade.org.apache.commons.lang 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 22c2c04078..1e3863e26c 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 @@ -37,9 +37,7 @@ import java.security.AccessControlException; import java.security.AccessController; import java.security.PrivilegedAction; -import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.Semaphore; @@ -91,15 +89,13 @@ public final class ForkedBooter */ public static void main( String... args ) { + final ExecutorService pingScheduler = isDebugging() ? null : listenToShutdownCommands(); final PrintStream originalOut = out; - ExecutorService pingScheduler = null; try { final String tmpDir = args[0]; final String dumpFileName = args[1]; final String surefirePropsFileName = args[2]; - PpidChecker.uniqueCommandLineToken = surefirePropsFileName; - pingScheduler = isDebugging() ? null : listenToShutdownCommands(); BooterDeserializer booterDeserializer = new BooterDeserializer( createSurefirePropertiesIfFileExists( tmpDir, surefirePropsFileName ) ); @@ -211,51 +207,12 @@ private static ExecutorService listenToShutdownCommands() COMMAND_READER.addShutdownListener( createExitHandler() ); AtomicBoolean pingDone = new AtomicBoolean( true ); COMMAND_READER.addNoopListener( createPingHandler( pingDone ) ); + Runnable pingJob = createPingJob( pingDone ); ScheduledExecutorService pingScheduler = createPingScheduler(); - Future checker = pingScheduler.submit( createProcessCheckerJob() ); - pingScheduler.scheduleWithFixedDelay( processCheckerJob( checker ), 0L, 1L, SECONDS ); - pingScheduler.scheduleAtFixedRate( createPingJob( pingDone, checker ), 0L, PING_TIMEOUT_IN_SECONDS, SECONDS ); + pingScheduler.scheduleAtFixedRate( pingJob, 0, PING_TIMEOUT_IN_SECONDS, SECONDS ); return pingScheduler; } - private static Runnable processCheckerJob( final Future processChecker ) - { - return new Runnable() - { - @Override - public void run() - { - if ( processChecker.isDone() && !processChecker.isCancelled() ) - { - try - { - PpidChecker checker = processChecker.get(); - if ( checker.canUse() && !checker.isParentProcessAlive() && !processChecker.isCancelled() ) - { - kill(); - } - } - catch ( Exception e ) - { - // nothing to do - } - } - } - }; - } - - private static Callable createProcessCheckerJob() - { - return new Callable() - { - @Override - public PpidChecker call() throws Exception - { - return new PpidChecker(); - } - }; - } - private static CommandListener createPingHandler( final AtomicBoolean pingDone ) { return new CommandListener() @@ -289,17 +246,13 @@ else if ( shutdown.isExit() ) }; } - private static Runnable createPingJob( final AtomicBoolean pingDone, final Future processChecker ) + private static Runnable createPingJob( final AtomicBoolean pingDone ) { return new Runnable() { @Override public void run() { - if ( canUseNewPingMechanism( processChecker ) ) - { - return; - } boolean hasPing = pingDone.getAndSet( false ); if ( !hasPing ) { @@ -309,18 +262,6 @@ public void run() }; } - private static boolean canUseNewPingMechanism( Future processChecker ) - { - try - { - return ( !processChecker.isDone() || processChecker.get().canUse() ) && !processChecker.isCancelled(); - } - catch ( Exception e ) - { - return false; - } - } - private static void encodeAndWriteToOutput( String string, PrintStream out ) { byte[] encodeBytes = encodeStringForForkCommunication( string ); @@ -416,8 +357,8 @@ private static ScheduledExecutorService createPingScheduler() { ThreadFactory threadFactory = newDaemonThreadFactory( "ping-" + PING_TIMEOUT_IN_SECONDS + "s" ); ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor( 1, threadFactory ); - executor.setKeepAliveTime( 3L, SECONDS ); - executor.setMaximumPoolSize( 3 ); + executor.setMaximumPoolSize( 1 ); + executor.prestartCoreThread(); return executor; } diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java deleted file mode 100644 index 665f36df55..0000000000 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java +++ /dev/null @@ -1,382 +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.shared.utils.cli.CommandLineException; -import org.apache.maven.shared.utils.cli.Commandline; -import org.apache.maven.shared.utils.cli.StreamConsumer; - -import java.io.File; -import java.lang.management.ManagementFactory; -import java.util.Locale; -import java.util.StringTokenizer; -import java.util.concurrent.atomic.AtomicReference; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static java.lang.Character.isDigit; -import static java.lang.Long.parseLong; -import static java.util.concurrent.TimeUnit.DAYS; -import static java.util.concurrent.TimeUnit.HOURS; -import static java.util.concurrent.TimeUnit.MINUTES; -import static java.util.regex.Pattern.compile; -import static org.apache.commons.lang3.SystemUtils.IS_OS_UNIX; -import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; -import static org.apache.maven.shared.utils.cli.CommandLineUtils.executeCommandLine; -import static org.apache.maven.surefire.booter.ProcessInfo.INVALID_PROCESS_INFO; - -/** - * Recognizes PPID. Determines lifetime of parent process. - * - * @author Tibor Digana (tibor17) - * @since 2.20.1 - */ -final class PpidChecker -{ - private static final String WMIC_CL = "CommandLine"; - - private static final String WMIC_PID = "ProcessId"; - - private static final String WMIC_PPID = "ParentProcessId"; - - private static final String WMIC_CREATION_DATE = "CreationDate"; - - private static final String WINDOWS_CMD = - "wmic process where (ProcessId=%s) get " + WMIC_CREATION_DATE + "," + WMIC_PPID; - - private static final String[] WINDOWS_PID_CMD = - { "wmic", "process", "where", "(Name='java.exe')", "get", WMIC_PID, ",", WMIC_CL }; - - private static final String UNIX_CMD1 = "/usr/bin/ps -o etime= -p $PPID"; - - private static final String UNIX_CMD2 = "/bin/ps -o etime= -p $PPID"; - - /** - * etime is in the form of [[dd-]hh:]mm:ss - */ - static final Pattern UNIX_CMD_OUT_PATTERN = compile( "^(((\\d+)-)?(\\d{2}):)?(\\d{2}):(\\d{2})$" ); - - private static final Pattern NUMBER_PATTERN = compile( "^\\d+$" ); - - static volatile String uniqueCommandLineToken; - - private final ProcessInfo parentProcessInfo; - - PpidChecker() - { - ProcessInfo parentProcess = INVALID_PROCESS_INFO; - if ( IS_OS_WINDOWS ) - { - String pid = pid(); - if ( pid == null && uniqueCommandLineToken != null ) - { - pid = pidOnWindows(); - } - - if ( pid != null ) - { - ProcessInfo currentProcessInfo = windows( pid ); - String ppid = currentProcessInfo.getPPID(); - parentProcess = currentProcessInfo.isValid() ? windows( ppid ) : INVALID_PROCESS_INFO; - } - } - else if ( IS_OS_UNIX ) - { - parentProcess = unix(); - } - parentProcessInfo = parentProcess.isValid() ? parentProcess : INVALID_PROCESS_INFO; - } - - boolean canUse() - { - return parentProcessInfo.isValid(); - } - - @SuppressWarnings( "unchecked" ) - boolean isParentProcessAlive() - { - if ( !canUse() ) - { - throw new IllegalStateException(); - } - - if ( IS_OS_WINDOWS ) - { - ProcessInfo pp = windows( parentProcessInfo.getPID() ); - // let's compare creation time, should be same unless killed or PPID is reused by OS into another process - return pp.isValid() && pp.getTime().compareTo( parentProcessInfo.getTime() ) == 0; - } - else if ( IS_OS_UNIX ) - { - ProcessInfo pp = unix(); - // let's compare elapsed time, should be greater or equal if parent process is the same and still alive - return pp.isValid() && pp.getTime().compareTo( parentProcessInfo.getTime() ) >= 0; - } - - throw new IllegalStateException(); - } - - // https://www.freebsd.org/cgi/man.cgi?ps(1) - // etimes elapsed running time, in decimal integer seconds - - // http://manpages.ubuntu.com/manpages/xenial/man1/ps.1.html - // etimes elapsed time since the process was started, in seconds. - - // http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/9b8c96f96a0f/test/java/lang/ProcessBuilder/Basic.java#L167 - static ProcessInfo unix() - { - Commandline cli = new Commandline(); - cli.getShell().setQuotedArgumentsEnabled( false ); - cli.createArg().setLine( new File( "/usr/bin/ps" ).canExecute() ? UNIX_CMD1 : UNIX_CMD2 ); - final AtomicReference processInfo = new AtomicReference( INVALID_PROCESS_INFO ); - try - { - final int exitCode = executeCommandLine( cli, new StreamConsumer() - { - @Override - public void consumeLine( String line ) - { - if ( processInfo.get().isValid() ) - { - return; - } - line = line.trim(); - if ( !line.isEmpty() ) - { - Matcher matcher = UNIX_CMD_OUT_PATTERN.matcher( line ); - if ( matcher.matches() ) - { - long pidUptime = fromDays( matcher ) - + fromHours( matcher ) - + fromMinutes( matcher ) - + fromSeconds( matcher ); - processInfo.set( ProcessInfo.unixProcessInfo( pidUptime ) ); - } - } - } - }, null - ); - return exitCode == 0 ? processInfo.get() : INVALID_PROCESS_INFO; - } - catch ( CommandLineException e ) - { - return INVALID_PROCESS_INFO; - } - } - - static String pid() - { - String processName = ManagementFactory.getRuntimeMXBean().getName(); - if ( processName != null && processName.contains( "@" ) ) - { - String pid = processName.substring( 0, processName.indexOf( '@' ) ).trim(); - if ( NUMBER_PATTERN.matcher( pid ).matches() ) - { - return pid; - } - } - return null; - } - - static String pidOnWindows() - { - final AtomicReference pid = new AtomicReference(); - Commandline cli = new Commandline(); - cli.getShell().setQuotedArgumentsEnabled( false ); - cli.addArguments( WINDOWS_PID_CMD ); - try - { - final int exitCode = executeCommandLine( cli, new StreamConsumer() - { - private boolean hasHeader; - private boolean isPidFirst; - - @Override - public void consumeLine( String line ) - { - line = line.trim(); - if ( line.isEmpty() ) - { - return; - } - - if ( hasHeader ) - { - if ( line.contains( uniqueCommandLineToken ) ) - { - String extractedPid = - isPidFirst ? extractNumberFromBegin( line ) : extractNumberFromEnd( line ); - pid.set( extractedPid ); - } - } - else - { - StringTokenizer args = new StringTokenizer( line ); - if ( args.countTokens() == 2 ) - { - String arg0 = args.nextToken(); - String arg1 = args.nextToken(); - isPidFirst = WMIC_PID.equals( arg0 ); - hasHeader = WMIC_PID.equals( arg0 ) || WMIC_CL.equals( arg0 ); - hasHeader &= WMIC_PID.equals( arg1 ) || WMIC_CL.equals( arg1 ); - } - } - } - }, null - ); - return exitCode == 0 ? pid.get() : null; - } - catch ( CommandLineException e ) - { - return null; - } - } - - static ProcessInfo windows( final String pid ) - { - Commandline cli = new Commandline(); - cli.getShell().setQuotedArgumentsEnabled( false ); - cli.createArg().setLine( String.format( Locale.ROOT, WINDOWS_CMD, pid ) ); - - final AtomicReference processInfo = new AtomicReference( INVALID_PROCESS_INFO ); - try - { - final int exitCode = executeCommandLine( cli, new StreamConsumer() - { - private boolean hasHeader; - private boolean isStartTimestampFirst; - - @Override - public void consumeLine( String line ) - { - if ( processInfo.get().isValid() ) - { - return; - } - - line = line.trim(); - - if ( line.isEmpty() ) - { - return; - } - - if ( hasHeader ) - { - StringTokenizer args = new StringTokenizer( line ); - if ( args.countTokens() == 2 ) - { - if ( isStartTimestampFirst ) - { - String startTimestamp = args.nextToken(); - String ppid = args.nextToken(); - processInfo.set( ProcessInfo.windowsProcessInfo( pid, startTimestamp, ppid ) ); - } - else - { - String ppid = args.nextToken(); - String startTimestamp = args.nextToken(); - processInfo.set( ProcessInfo.windowsProcessInfo( pid, startTimestamp, ppid ) ); - } - } - } - else - { - StringTokenizer args = new StringTokenizer( line ); - if ( args.countTokens() == 2 ) - { - String arg0 = args.nextToken(); - String arg1 = args.nextToken(); - isStartTimestampFirst = WMIC_CREATION_DATE.equals( arg0 ); - hasHeader = WMIC_CREATION_DATE.equals( arg0 ) || WMIC_PPID.equals( arg0 ); - hasHeader &= WMIC_CREATION_DATE.equals( arg1 ) || WMIC_PPID.equals( arg1 ); - } - } - } - }, null - ); - return exitCode == 0 ? processInfo.get() : INVALID_PROCESS_INFO; - } - catch ( CommandLineException e ) - { - return INVALID_PROCESS_INFO; - } - } - - static long fromDays( Matcher matcher ) - { - String s = matcher.group( 3 ); - return s == null ? 0L : DAYS.toSeconds( parseLong( s ) ); - } - - static long fromHours( Matcher matcher ) - { - String s = matcher.group( 4 ); - return s == null ? 0L : HOURS.toSeconds( parseLong( s ) ); - } - - static long fromMinutes( Matcher matcher ) - { - String s = matcher.group( 5 ); - return s == null ? 0L : MINUTES.toSeconds( parseLong( s ) ); - } - - static long fromSeconds( Matcher matcher ) - { - String s = matcher.group( 6 ); - return s == null ? 0L : parseLong( s ); - } - - static String extractNumberFromBegin( String line ) - { - StringBuilder number = new StringBuilder(); - for ( int i = 0, len = line.length(); i < len; i++ ) - { - char c = line.charAt( i ); - if ( isDigit( c ) ) - { - number.append( c ); - } - else - { - break; - } - } - return number.toString(); - } - - static String extractNumberFromEnd( String line ) - { - StringBuilder number = new StringBuilder(); - for ( int i = line.length() - 1; i >= 0; i-- ) - { - char c = line.charAt( i ); - if ( isDigit( c ) ) - { - number.insert( 0, c ); - } - else - { - break; - } - } - return number.toString(); - } -} diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java deleted file mode 100644 index a300658b5e..0000000000 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java +++ /dev/null @@ -1,77 +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. - */ - -/** - * PID, PPID, elapsed time (Unix) or start time (Windows). - * - * @author Tibor Digana (tibor17) - * @since 2.20.1 - */ -final class ProcessInfo -{ - static final ProcessInfo INVALID_PROCESS_INFO = new ProcessInfo( null, null, null ); - - /** - * On Unix we do not get PID due to the command is interested only to etime of PPID: - *
    - *
    /bin/ps -o etime= -p $PPID
    - */ - static ProcessInfo unixProcessInfo( long etime ) - { - return new ProcessInfo( "pid not needed on Unix", etime, null ); - } - - static ProcessInfo windowsProcessInfo( String pid, String startTimestamp, String ppid ) - { - return new ProcessInfo( pid, startTimestamp, ppid ); - } - - private final String pid; - private final Comparable time; - private final String ppid; - - private ProcessInfo( String pid, Comparable time, String ppid ) - { - this.pid = pid; - this.time = time; - this.ppid = ppid; - } - - boolean isValid() - { - return pid != null && time != null; - } - - String getPID() - { - return pid; - } - - Comparable getTime() - { - return time; - } - - String getPPID() - { - return ppid; - } -} diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java index b08423fc34..2bdcf21b3c 100644 --- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java @@ -34,8 +34,7 @@ ClasspathTest.class, CommandReaderTest.class, PropertiesWrapperTest.class, - SurefireReflectorTest.class, - PpidCheckerTest.class + SurefireReflectorTest.class } ) @RunWith( Suite.class ) public class JUnit4SuiteTest diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java deleted file mode 100644 index 2d49f6283b..0000000000 --- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java +++ /dev/null @@ -1,204 +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.junit.Test; - -import java.util.concurrent.TimeUnit; -import java.util.regex.Matcher; - -import static org.apache.commons.lang3.SystemUtils.IS_OS_UNIX; -import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; -import static org.fest.assertions.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; - -/** - * Testing {@link PpidChecker} on a platform. - * - * @author Tibor Digana (tibor17) - * @since 2.20.1 - */ -public class PpidCheckerTest -{ - @Test - public void shouldHavePid() - { - String pid = PpidChecker.pid(); - - assertThat( pid ) - .isNotNull(); - - assertThat( pid ) - .matches( "^\\d+$" ); - } - - @Test - public void shouldHavePpidAsWindows() - { - assumeTrue( IS_OS_WINDOWS ); - - ProcessInfo processInfo = PpidChecker.windows( PpidChecker.pid() ); - - assertThat( processInfo ) - .isNotNull(); - - assertThat( processInfo.getPID() ) - .isNotNull(); - - assertThat( processInfo.getPID() ) - .matches( "^\\d+$" ); - - assertThat( processInfo.getTime() ) - .isNotNull(); - - processInfo = PpidChecker.windows( processInfo.getPID() ); - - assertThat( processInfo.getPID() ) - .isNotNull(); - - assertThat( processInfo.getPID() ) - .matches( "^\\d+$" ); - - assertThat( processInfo.getTime() ) - .isNotNull(); - } - - @Test - public void shouldFindPid() - { - assumeTrue( IS_OS_WINDOWS ); - - PpidChecker.uniqueCommandLineToken = "PpidCheckerTest.args=shouldFindPid"; - String pid = PpidChecker.pidOnWindows(); - - assertThat( pid ) - .isNotNull(); - - assertThat( pid ) - .isEqualTo( PpidChecker.pid() ); - } - - @Test - public void shouldHavePpidAsUnix() - { - assumeTrue( IS_OS_UNIX ); - - ProcessInfo processInfo = PpidChecker.unix(); - - assertThat( processInfo ) - .isNotNull(); - - assertThat( processInfo.getPID() ) - .isNotNull(); - - assertThat( processInfo.getPID() ) - .isEqualTo( "pid not needed on Unix" ); - - assertThat( processInfo.getTime() ) - .isNotNull(); - } - - @Test - public void shouldFindAliveParentProcess() - throws InterruptedException - { - PpidChecker checker = new PpidChecker(); - - assertThat( checker.canUse() ) - .isTrue(); - - TimeUnit.MILLISECONDS.sleep( 100L ); - - assertThat( checker.isParentProcessAlive() ) - .isTrue(); - } - - @Test - public void shouldParseEtime() - { - Matcher m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "38" ); - assertThat( m.matches() ) - .isFalse(); - - m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "05:38" ); - assertThat( m.matches() ) - .isTrue(); - assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 0L ); - assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 0L ); - assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); - assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); - - m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "00:05:38" ); - assertThat( m.matches() ) - .isTrue(); - assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 0L ); - assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 0L ); - assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); - assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); - - m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "01:05:38" ); - assertThat( m.matches() ) - .isTrue(); - assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 0L ); - assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 3600L ); - assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); - assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); - - m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "02-01:05:38" ); - assertThat( m.matches() ) - .isTrue(); - assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 2 * 24 * 3600L ); - assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 3600L ); - assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); - assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); - } - - @Test - public void shouldExtractNumberFromBegin() - { - String num = PpidChecker.extractNumberFromBegin( "123 abc" ); - assertThat( num ) - .isEqualTo( "123" ); - } - - @Test - public void shouldNotExtractNumberFromBegin() - { - String num = PpidChecker.extractNumberFromBegin( " 123 abc" ); - assertThat( num ) - .isEmpty(); - } - - @Test - public void shouldExtractNumberFromEnd() - { - String num = PpidChecker.extractNumberFromEnd( "abc 123" ); - assertThat( num ) - .isEqualTo( "123" ); - } - - @Test - public void shouldNotExtractNumberFromEnd() - { - String num = PpidChecker.extractNumberFromEnd( "abs 123 " ); - assertThat( num ) - .isEmpty(); - } -} 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 f051c1cf34..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 @@ -27,9 +27,8 @@ import org.junit.Test; import java.util.Iterator; +import java.util.Locale; -import static org.apache.commons.lang.SystemUtils.IS_OS_LINUX; -import static org.apache.commons.lang.SystemUtils.IS_OS_MAC_OSX; import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; @@ -47,7 +46,8 @@ public class Surefire1295AttributeJvmCrashesToTestsIT @Before public void skipWindows() { - assumeTrue( IS_OS_LINUX || IS_OS_MAC_OSX ); + String os = System.getProperty( "os.name" ).toLowerCase( Locale.ROOT ); + assumeTrue( os.equals( "mac os x" ) || os.equals( "linux" ) /*|| os.contains( "windows" )*/ ); } @Test From f1f4718e519bdee7ab53b91b34714adce3e39c34 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 26 Jul 2017 08:17:08 +0200 Subject: [PATCH 104/194] [SUREFIRE-1302] Surefire does not wait long enough for the forked VM and assumes it to be dead --- maven-failsafe-plugin/pom.xml | 17 - maven-surefire-common/pom.xml | 11 +- .../plugin/surefire/AbstractSurefireMojo.java | 14 +- .../plugin/surefire/SurefireProperties.java | 8 + .../booterclient/BooterSerializer.java | 6 +- .../booterclient/ForkConfiguration.java | 10 +- .../surefire/booterclient/ForkStarter.java | 6 +- .../surefire/booterclient/Platform.java | 70 +++ .../surefire/report/FileReporterUtils.java | 11 +- ...DeserializerProviderConfigurationTest.java | 3 +- ...rDeserializerStartupConfigurationTest.java | 3 +- .../booterclient/ForkConfigurationTest.java | 2 +- .../report/DefaultReporterFactoryTest.java | 2 + maven-surefire-plugin/pom.xml | 17 - .../src/site/apt/examples/shutdown.apt.vm | 27 +- maven-surefire-report-plugin/pom.xml | 4 - pom.xml | 19 +- surefire-api/pom.xml | 11 +- .../maven/surefire/booter/CommandReader.java | 4 +- .../maven/surefire/util/ReflectionUtils.java | 61 ++- .../surefire/util/internal/SystemUtils.java | 99 ---- .../org/apache/maven/JUnit4SuiteTest.java | 6 +- .../surefire/util/ReflectionUtilsTest.java | 114 +++++ .../util/internal/SystemUtilsTest.java | 98 ---- surefire-booter/pom.xml | 47 +- .../surefire/booter/BooterConstants.java | 1 + .../surefire/booter/BooterDeserializer.java | 8 + .../maven/surefire/booter/Classpath.java | 2 - .../maven/surefire/booter/ForkedBooter.java | 433 ++++++++++-------- .../maven/surefire/booter/PpidChecker.java | 295 ++++++++++++ .../maven/surefire/booter/ProcessInfo.java | 109 +++++ .../surefire/booter/PropertiesWrapper.java | 6 + .../maven/surefire/booter/SystemUtils.java | 181 ++++++++ .../surefire/booter/JUnit4SuiteTest.java | 4 +- .../surefire/booter/NewClassLoaderRunner.java | 67 ++- .../surefire/booter/PpidCheckerTest.java | 144 ++++++ .../surefire/booter/SystemUtilsTest.java | 131 ++++++ ...efire1295AttributeJvmCrashesToTestsIT.java | 6 +- 38 files changed, 1571 insertions(+), 486 deletions(-) create mode 100644 maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/Platform.java delete 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/ReflectionUtilsTest.java delete mode 100644 surefire-api/src/test/java/org/apache/maven/surefire/util/internal/SystemUtilsTest.java create mode 100644 surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java create mode 100644 surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java create mode 100644 surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java create mode 100644 surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java create mode 100644 surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index f42e6827bf..ec48929ec6 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -44,27 +44,10 @@ - - org.apache.maven - maven-plugin-api - org.apache.maven.surefire maven-surefire-common - - org.apache.maven.surefire - surefire-api - - - org.apache.maven.shared - maven-shared-utils - - - org.apache.maven.plugin-tools - maven-plugin-annotations - compile - org.apache.maven.plugins maven-surefire-plugin diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index 4064bc2c8e..ae050c75b1 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -44,7 +44,6 @@ org.apache.maven.plugin-tools maven-plugin-annotations - compile org.apache.maven.surefire @@ -93,6 +92,7 @@ com.google.code.findbugs jsr305 + provided org.apache.maven.shared @@ -160,13 +160,11 @@ maven-surefire-plugin + ${test.jre}/bin/java true **/JUnit4SuiteTest.java - - org.fusesource.jansi:jansi - @@ -192,6 +190,7 @@ org.apache.maven.shared:maven-shared-utils org.apache.maven.shared:maven-common-artifact-filters commons-io:commons-io + org.apache.commons:commons-lang3 @@ -203,6 +202,10 @@ org.apache.commons.io org.apache.maven.surefire.shade.org.apache.commons.io + + org.apache.commons.lang3 + org.apache.maven.surefire.shade.org.apache.commons.lang3 + 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 551d9800af..b3df567dae 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 @@ -43,6 +43,7 @@ import org.apache.maven.plugin.surefire.booterclient.ChecksumCalculator; import org.apache.maven.plugin.surefire.booterclient.ForkConfiguration; import org.apache.maven.plugin.surefire.booterclient.ForkStarter; +import org.apache.maven.plugin.surefire.booterclient.Platform; 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; @@ -114,6 +115,8 @@ public abstract class AbstractSurefireMojo extends AbstractMojo implements SurefireExecutionParameters { + private static final Platform PLATFORM = new Platform(); + private final ProviderDetector providerDetector = new ProviderDetector(); /** @@ -1623,13 +1626,14 @@ StartupConfiguration createStartupConfiguration( ProviderInfo provider, Classpath providerClasspath = ClasspathCache.getCachedClassPath( providerName ); if ( providerClasspath == null ) { + // todo: 100 milli seconds, try to fetch List within classpath asynchronously providerClasspath = provider.getProviderClasspath(); ClasspathCache.setCachedClasspath( providerName, providerClasspath ); } Artifact surefireArtifact = getCommonArtifact(); - Classpath inprocClassPath = providerClasspath. - addClassPathElementUrl( surefireArtifact.getFile().getAbsolutePath() ) - .addClassPathElementUrl( getApiArtifact().getFile().getAbsolutePath() ); + Classpath inprocClassPath = + providerClasspath.addClassPathElementUrl( surefireArtifact.getFile().getAbsolutePath() ) + .addClassPathElementUrl( getApiArtifact().getFile().getAbsolutePath() ); final Classpath testClasspath = generateTestClasspath(); @@ -1926,7 +1930,6 @@ private InPluginVMSurefireStarter createInprocessStarter( ProviderInfo provider, ProviderConfiguration providerConfiguration = createProviderConfiguration( runOrderParameters ); return new InPluginVMSurefireStarter( startupConfiguration, providerConfiguration, startupReportConfiguration, consoleLogger ); - } protected ForkConfiguration getForkConfiguration() @@ -1937,6 +1940,7 @@ protected ForkConfiguration getForkConfiguration() Artifact shadeFire = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-shadefire" ); + // todo: 150 milli seconds, try to fetch List within classpath asynchronously final Classpath bootClasspathConfiguration = getArtifactClasspath( shadeFire != null ? shadeFire : surefireBooterArtifact ); @@ -1945,7 +1949,7 @@ protected ForkConfiguration getForkConfiguration() getWorkingDirectory() != null ? getWorkingDirectory() : getBasedir(), getProject().getModel().getProperties(), getArgLine(), getEnvironmentVariables(), getConsoleLogger().isDebugEnabled(), - getEffectiveForkCount(), reuseForks ); + getEffectiveForkCount(), reuseForks, PLATFORM ); } private void convertDeprecatedForkMode() 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 fd2b4fb42b..6609e617bf 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 @@ -193,6 +193,14 @@ public void setProperty( String key, Boolean aBoolean ) } } + public void setProperty( String key, Long value ) + { + if ( value != null ) + { + setProperty( key, value.toString() ); + } + } + public void addList( List items, String propertyPrefix ) { if ( items != null && !items.isEmpty() ) 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 0299525570..591e89c813 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 @@ -70,12 +70,14 @@ class BooterSerializer * Does not modify sourceProperties */ File serialize( KeyValueSource sourceProperties, ProviderConfiguration booterConfiguration, - StartupConfiguration providerConfiguration, Object testSet, boolean readTestsFromInStream ) + StartupConfiguration providerConfiguration, Object testSet, boolean readTestsFromInStream, + Long pid ) throws IOException { - SurefireProperties properties = new SurefireProperties( sourceProperties ); + properties.setProperty( PLUGIN_PID, pid ); + ClasspathConfiguration cp = providerConfiguration.getClasspathConfiguration(); properties.setClasspath( ClasspathConfiguration.CLASSPATH, cp.getTestClasspath() ); properties.setClasspath( ClasspathConfiguration.SUREFIRE_CLASSPATH, cp.getProviderClasspath() ); 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 2768210630..1c7626ec52 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 @@ -82,11 +82,13 @@ public class ForkConfiguration private final String debugLine; + private final Platform pluginPlatform; + @SuppressWarnings( "checkstyle:parameternumber" ) public ForkConfiguration( Classpath bootClasspathConfiguration, File tmpDir, String debugLine, String jvmExecutable, File workingDirectory, Properties modelProperties, String argLine, Map environmentVariables, boolean debugEnabled, int forkCount, - boolean reuseForks ) + boolean reuseForks, Platform pluginPlatform ) { this.bootClasspathConfiguration = bootClasspathConfiguration; this.tempDirectory = tmpDir; @@ -99,6 +101,7 @@ public ForkConfiguration( Classpath bootClasspathConfiguration, File tmpDir, Str this.debug = debugEnabled; this.forkCount = forkCount; this.reuseForks = reuseForks; + this.pluginPlatform = pluginPlatform; } public Classpath getBootClasspath() @@ -339,6 +342,11 @@ public boolean isReuseForks() return reuseForks; } + public Platform getPluginPlatform() + { + return pluginPlatform; + } + private static String stripNewLines( String argLine ) { return argLine.replace( "\n", " " ).replace( "\r", " " ); 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 a2a5095c35..2d828554e0 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 @@ -550,7 +550,11 @@ private RunResult fork( Object testSet, KeyValueSource providerProperties, ForkC BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration ); surefireProperties = booterSerializer.serialize( providerProperties, providerConfiguration, - startupConfiguration, testSet, readTestsFromInStream ); + startupConfiguration, testSet, + readTestsFromInStream, + forkConfiguration.getPluginPlatform().getPid() ); + + log.debug( "Determined Maven Process ID " + forkConfiguration.getPluginPlatform().getPid() ); if ( effectiveSystemProperties != null ) { diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/Platform.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/Platform.java new file mode 100644 index 0000000000..10b16dc63d --- /dev/null +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/Platform.java @@ -0,0 +1,70 @@ +package org.apache.maven.plugin.surefire.booterclient; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.booter.SystemUtils; + +import java.util.concurrent.Callable; +import java.util.concurrent.FutureTask; +import java.util.concurrent.RunnableFuture; + +import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDaemonThread; + +/** + * Loads platform specifics. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public final class Platform +{ + private final RunnableFuture pidJob; + + public Platform() + { + // the job may take 50 or 80 ms + pidJob = new FutureTask( pidJob() ); + newDaemonThread( pidJob ).start(); + } + + public Long getPid() + { + try + { + return pidJob.get(); + } + catch ( Exception e ) + { + return null; + } + } + + private static Callable pidJob() + { + return new Callable() + { + @Override + public Long call() throws Exception + { + return SystemUtils.pid(); + } + }; + } +} diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java index 36bc269516..fd33d8ed02 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java @@ -19,6 +19,8 @@ * under the License. */ +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; + /** * Utils class for file-based reporters * @@ -45,13 +47,6 @@ public static String stripIllegalFilenameChars( String original ) private static String getOSSpecificIllegalChars() { - if ( System.getProperty( "os.name" ).toLowerCase().startsWith( "win" ) ) - { - return "\\/:*?\"<>|\0"; - } - else - { - return "/\0"; - } + return IS_OS_WINDOWS ? "\\/:*?\"<>|\0" : "/\0"; } } diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java index 6759367a17..5d970d8410 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java @@ -220,8 +220,9 @@ private ProviderConfiguration saveAndReload( ProviderConfiguration booterConfigu test = "aTest"; } final File propsTest = booterSerializer.serialize( props, booterConfiguration, testProviderConfiguration, test, - readTestsFromInStream ); + readTestsFromInStream, 51L ); BooterDeserializer booterDeserializer = new BooterDeserializer( new FileInputStream( propsTest ) ); + assertEquals( 51L, (Object) booterDeserializer.getPluginPid() ); return booterDeserializer.deserialize(); } diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java index 1ca20d2a33..0cb292caef 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java @@ -124,8 +124,9 @@ private StartupConfiguration saveAndReload( StartupConfiguration startupConfigur BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration ); String aTest = "aTest"; final File propsTest = - booterSerializer.serialize( props, getProviderConfiguration(), startupConfiguration, aTest, false ); + booterSerializer.serialize( props, getProviderConfiguration(), startupConfiguration, aTest, false, null ); BooterDeserializer booterDeserializer = new BooterDeserializer( new FileInputStream( propsTest ) ); + assertNull( booterDeserializer.getPluginPid() ); return booterDeserializer.getProviderConfiguration(); } diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java index 4f62670175..1e09d6f0a3 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java @@ -162,7 +162,7 @@ public static ForkConfiguration getForkConfiguration( String argLine, String jvm throws IOException { return new ForkConfiguration( Classpath.emptyClasspath(), null, null, jvm, cwd, new Properties(), argLine, null, - false, 1, false ); + false, 1, false, new Platform() ); } // based on http://stackoverflow.com/questions/2591083/getting-version-of-java-in-runtime 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 a6076dece5..67f66d6b16 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 @@ -27,6 +27,7 @@ import org.apache.maven.plugin.surefire.StartupReportConfiguration; import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; +import org.apache.maven.shared.utils.logging.MessageUtils; import org.apache.maven.surefire.report.RunStatistics; import org.apache.maven.surefire.report.SafeThrowable; import org.apache.maven.surefire.report.StackTraceWriter; @@ -61,6 +62,7 @@ public class DefaultReporterFactoryTest public void testMergeTestHistoryResult() { + MessageUtils.setColorEnabled( false ); File reportsDirectory = new File("target"); StartupReportConfiguration reportConfig = new StartupReportConfiguration( true, true, "PLAIN", false, false, reportsDirectory, false, null, diff --git a/maven-surefire-plugin/pom.xml b/maven-surefire-plugin/pom.xml index 62ec4a7422..2a186e3489 100644 --- a/maven-surefire-plugin/pom.xml +++ b/maven-surefire-plugin/pom.xml @@ -44,27 +44,10 @@ - - org.apache.maven - maven-plugin-api - org.apache.maven.surefire maven-surefire-common - - org.apache.maven.surefire - surefire-api - - - org.apache.maven - maven-toolchain - - - org.apache.maven.plugin-tools - maven-plugin-annotations - compile - 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 a5468530c3..7a7b59e11b 100644 --- a/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm +++ b/maven-surefire-plugin/src/site/apt/examples/shutdown.apt.vm @@ -39,8 +39,33 @@ Shutdown of Forked JVM * Pinging forked JVM + << Since ${thisPlugin} Plugin 2.20.1 ping is platform dependent and fallbacks to old mechanism if PID of Maven + process or platform is not recognized, native commands fail in Java. >> + + Simply the mechanism checks the <<< Maven PID >>> is still alive and it is not reused by OS in another application. + If Maven process has died, the forked JVM is killed. + + << Implementation: >> The <<< Maven PID >>> is determined by: + + * Java 9 call <<< ProcessHandle.current().pid() >>>, or + + * resolving PID from <<< /proc/self/stat >>> on Linux and <<< /proc/curproc/status >>> on BSD, or + + * the JMX call <<< ManagementFactory.getRuntimeMXBean().getName() >>>. + + [] + + On Unix like systems the process' uptime is determined by native command <<< (/usr)/bin/ps -o etime= -p [PID] >>>. + + On Windows the start time is determined using <<< wmic process where (ProcessId=[PID]) get CreationDate >>> + in the forked JVM. + + + << Since ${thisPlugin} Plugin 2.19 the old mechanism is significantly slower: >> + The master process sends NOOP command to a forked JVM every 10 seconds. - Forked JVM is waiting for the command every 20 seconds. + Forked JVM is waiting for the command every 20 seconds (changed to 30 seconds since version 2.20.1, see + {{{https://issues.apache.org/jira/browse/SUREFIRE-1302}SUREFIRE-1302}}). If the master process is killed (received SIGKILL signal) or shutdown (pressed CTRL+C, received SIGTERM signal), forked JVM is killed after timing out waiting period. diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml index a4fe7e293a..93a2e803ea 100644 --- a/maven-surefire-report-plugin/pom.xml +++ b/maven-surefire-report-plugin/pom.xml @@ -47,10 +47,6 @@ - - org.apache.maven.surefire - surefire-logger-api - org.apache.maven maven-project diff --git a/pom.xml b/pom.xml index 962a5bf74f..6ba5602125 100644 --- a/pom.xml +++ b/pom.xml @@ -91,8 +91,13 @@ 2.2.1 3.3 + 3.5 + 2.5 + 0.9 scm:git:https://git-wip-us.apache.org/repos/asf/maven-surefire.git surefire-archives/surefire-LATEST + + ${java.home}/.. @@ -105,12 +110,12 @@ org.apache.commons commons-lang3 - 3.1 + ${commonsLang3Version} commons-io commons-io - 2.2 + ${commonsIoVersion} org.apache.maven.surefire @@ -215,7 +220,13 @@ org.apache.maven.shared maven-shared-utils - 0.9 + ${mavenSharedUtilsVersion} + + + com.google.code.findbugs + jsr305 + + org.apache.maven.shared @@ -377,7 +388,7 @@ maven-shade-plugin - 1.5 + 3.0.0 maven-plugin-plugin diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml index 7e407d2ba2..ec5c66457b 100644 --- a/surefire-api/pom.xml +++ b/surefire-api/pom.xml @@ -40,6 +40,11 @@ org.apache.maven.shared maven-shared-utils + + com.google.code.findbugs + jsr305 + provided + @@ -47,6 +52,7 @@ maven-surefire-plugin + ${test.jre}/bin/java true **/JUnit4SuiteTest.java @@ -74,7 +80,6 @@ org.apache.maven.shared:maven-shared-utils - commons-lang:commons-lang @@ -82,10 +87,6 @@ org.apache.maven.shared org.apache.maven.surefire.shade.org.apache.maven.shared - - org.apache.commons.lang - org.apache.maven.surefire.shade.org.apache.commons.lang - 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 ed7d4fadff..c3d80eaf26 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 @@ -438,7 +438,7 @@ public void run() DumpErrorSingleton.getSingleton().dumpStreamException( e, msg ); exitByConfiguration(); - // does not go to finally + // does not go to finally for non-default config: Shutdown.EXIT or Shutdown.KILL } } catch ( IOException e ) @@ -493,7 +493,7 @@ else if ( shutdown.isKill() ) { Runtime.getRuntime().halt( 1 ); } - // else is default: should not happen; otherwise you missed enum case + // else is default: other than Shutdown.DEFAULT should not happen; otherwise you missed enum case } } } diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java index 6844dda3eb..1be4e06cd2 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java @@ -28,10 +28,6 @@ */ public final class ReflectionUtils { - private static final Class[] NO_ARGS = new Class[0]; - - private static final Object[] NO_ARGS_VALUES = new Object[0]; - private ReflectionUtils() { throw new IllegalStateException( "no instantiable constructor" ); @@ -68,8 +64,8 @@ public static Method tryGetMethod( Class clazz, String methodName, Class.. public static Object invokeGetter( Object instance, String methodName ) { - final Method method = getMethod( instance, methodName, NO_ARGS ); - return invokeMethodWithArray( instance, method, NO_ARGS_VALUES ); + final Method method = getMethod( instance, methodName ); + return invokeMethodWithArray( instance, method ); } public static Constructor getConstructor( Class clazz, Class... arguments ) @@ -245,4 +241,57 @@ public static Class loadClass( ClassLoader classLoader, String className ) throw new SurefireReflectionException( e ); } } + + /** + * Invoker of public static no-argument method. + * + * @param clazz class on which public static no-argument {@code methodName} is invoked + * @param methodName public static no-argument method to be called + * @return value returned by {@code methodName} + * @throws RuntimeException if no such method found + * @throws SurefireReflectionException if the method could not be called or threw an exception + */ + public static Object invokeStaticMethod( Class clazz, String methodName ) + { + Method method = getMethod( clazz, methodName ); + return invokeMethodWithArray( null, method ); + } + + /** + * Method chain invoker. + * + * @param classesChain classes to invoke on method chain + * @param noArgMethodNames chain of public methods to call + * @param fallback returned value if a chain could not be invoked due to an error + * @return successfully returned value from the last method call; {@code fallback} otherwise + * @throws IllegalArgumentException if {@code classes} and {@code noArgMethodNames} have different array length + */ + public static Object invokeMethodChain( Class[] classesChain, String[] noArgMethodNames, Object fallback ) + { + if ( classesChain.length != noArgMethodNames.length ) + { + throw new IllegalArgumentException( "arrays must have the same length" ); + } + Object obj = null; + try + { + for ( int i = 0, len = noArgMethodNames.length; i < len; i++ ) + { + if ( i == 0 ) + { + obj = invokeStaticMethod( classesChain[i], noArgMethodNames[i] ); + } + else + { + Method method = getMethod( classesChain[i], noArgMethodNames[i] ); + obj = invokeMethodWithArray( obj, method ); + } + } + return obj; + } + catch ( RuntimeException e ) + { + return fallback; + } + } } 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 deleted file mode 100644 index 7881b5d841..0000000000 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/SystemUtils.java +++ /dev/null @@ -1,99 +0,0 @@ -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 dbf46ea482..66cca64b82 100644 --- a/surefire-api/src/test/java/org/apache/maven/JUnit4SuiteTest.java +++ b/surefire-api/src/test/java/org/apache/maven/JUnit4SuiteTest.java @@ -32,6 +32,7 @@ import org.apache.maven.surefire.testset.ResolvedTestTest; import org.apache.maven.surefire.testset.TestListResolverTest; import org.apache.maven.surefire.util.DefaultDirectoryScannerTest; +import org.apache.maven.surefire.util.ReflectionUtilsTest; import org.apache.maven.surefire.util.RunOrderCalculatorTest; import org.apache.maven.surefire.util.RunOrderTest; import org.apache.maven.surefire.util.ScanResultTest; @@ -40,7 +41,6 @@ import org.apache.maven.surefire.util.internal.ConcurrencyUtilsTest; import org.apache.maven.surefire.util.internal.ImmutableMapTest; 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; @@ -69,8 +69,8 @@ UrlUtilsTest.class, SpecificTestClassFilterTest.class, FundamentalFilterTest.class, - SystemUtilsTest.class, - ImmutableMapTest.class + ImmutableMapTest.class, + ReflectionUtilsTest.class } ) @RunWith( Suite.class ) public class JUnit4SuiteTest diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java new file mode 100644 index 0000000000..41f97020bf --- /dev/null +++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java @@ -0,0 +1,114 @@ +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 org.junit.Test; + +import static org.fest.assertions.Assertions.assertThat; + +/** + * Unit test for {@link ReflectionUtils}. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public class ReflectionUtilsTest +{ + @Test(expected = RuntimeException.class) + public void shouldNotInvokeStaticMethod() + { + ReflectionUtils.invokeStaticMethod( ReflectionUtilsTest.class, "notCallable" ); + } + + @Test + public void shouldInvokeStaticMethod() + { + Object o = ReflectionUtils.invokeStaticMethod( ReflectionUtilsTest.class, "callable" ); + assertThat( o ) + .isEqualTo( 3L ); + } + + @Test + public void shouldInvokeMethodChain() + { + Class[] classes1 = { A.class, A.class }; + String[] chain = { "current", "pid" }; + Object o = ReflectionUtils.invokeMethodChain( classes1, chain, null ); + assertThat( o ) + .isEqualTo( 3L ); + + Class[] classes2 = { A.class, A.class, B.class }; + String[] longChain = { "current", "createB", "pid" }; + o = ReflectionUtils.invokeMethodChain( classes2, longChain, null ); + assertThat( o ) + .isEqualTo( 1L ); + } + + @Test + public void shouldInvokeFallbackOnMethodChain() + { + Class[] classes1 = { A.class, A.class }; + String[] chain = { "current", "abc" }; + Object o = ReflectionUtils.invokeMethodChain( classes1, chain, 5L ); + assertThat( o ) + .isEqualTo( 5L ); + + Class[] classes2 = { A.class, B.class, B.class }; + String[] longChain = { "current", "createB", "abc" }; + o = ReflectionUtils.invokeMethodChain( classes2, longChain, 6L ); + assertThat( o ) + .isEqualTo( 6L ); + } + + private static void notCallable() + { + } + + public static long callable() + { + return 3L; + } + + public static class A + { + public static A current() + { + return new A(); + } + + public long pid() + { + return 3L; + } + + public B createB() + { + return new B(); + } + } + + public static class B + { + public long pid() + { + return 1L; + } + } +} 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 deleted file mode 100644 index bbd9b3c750..0000000000 --- a/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/SystemUtilsTest.java +++ /dev/null @@ -1,98 +0,0 @@ -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/pom.xml b/surefire-booter/pom.xml index b79cceb381..8fdaf7e982 100644 --- a/surefire-booter/pom.xml +++ b/surefire-booter/pom.xml @@ -35,11 +35,46 @@ org.apache.maven.surefire surefire-api + + + org.apache.maven.shared + maven-shared-utils + + + + + org.apache.maven.shared + maven-shared-utils + test + + + org.apache.commons + commons-lang3 + + + commons-io + commons-io + + maven-dependency-plugin + + + build-test-classpath + generate-sources + + build-classpath + + + test + target/test-classpath/cp.txt + + + + maven-surefire-plugin @@ -50,6 +85,7 @@ + ${test.jre}/bin/java true **/JUnit4SuiteTest.java @@ -69,13 +105,18 @@ true - commons-lang:commons-lang + org.apache.commons:commons-lang3 + commons-io:commons-io - org.apache.commons.lang - org.apache.maven.surefire.shade.org.apache.commons.lang + org.apache.commons.lang3 + org.apache.maven.surefire.shade.org.apache.commons.lang3 + + + org.apache.commons.io + org.apache.maven.surefire.shade.org.apache.commons.io diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java index c21edf802c..3551910aa6 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java @@ -56,4 +56,5 @@ private BooterConstants() public static final String FAIL_FAST_COUNT = "failFastCount"; public static final String SHUTDOWN = "shutdown"; public static final String SYSTEM_EXIT_TIMEOUT = "systemExitTimeout"; + public static final String PLUGIN_PID = "pluginPid"; } diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java index 8fa760b6bb..75aad1f527 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java @@ -58,6 +58,14 @@ public BooterDeserializer( InputStream inputStream ) properties = SystemPropertyManager.loadProperties( inputStream ); } + /** + * @return PID of Maven process where plugin is executed; or null if PID could not be determined. + */ + public Long getPluginPid() + { + return properties.getLongProperty( PLUGIN_PID ); + } + public ProviderConfiguration deserialize() { final File reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) ); 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 531e7a1c09..609be0fa22 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.internal.SystemUtils; - import java.io.File; import java.net.MalformedURLException; import java.net.URL; 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 1e3863e26c..d00abc55c2 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 @@ -22,7 +22,6 @@ 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; @@ -30,6 +29,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.lang.management.ManagementFactory; @@ -37,7 +37,6 @@ 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; import java.util.concurrent.Semaphore; @@ -45,14 +44,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import static java.lang.Math.max; -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.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; -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; import static org.apache.maven.surefire.booter.ForkingRunListener.encode; @@ -73,107 +67,91 @@ */ 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 CommandReader COMMAND_READER = startupMasterProcessReader(); + private static final long DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS = 30L; + private static final long PING_TIMEOUT_IN_SECONDS = 30L; + private static final long ONE_SECOND_IN_MILLIS = 1000L; - private static volatile ScheduledThreadPoolExecutor jvmTerminator; - private static volatile long systemExitTimeoutInSeconds = DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS; + private final CommandReader commandReader = CommandReader.getReader(); + private final PrintStream originalOut = System.out; - /** - * This method is invoked when Surefire is forked - this method parses and organizes the arguments passed to it and - * then calls the Surefire class' run method.
    The system exit code will be 1 if an exception is thrown. - * - * @param args Commandline arguments - */ - public static void main( String... args ) - { - final ExecutorService pingScheduler = isDebugging() ? null : listenToShutdownCommands(); - final PrintStream originalOut = out; - try - { - final String tmpDir = args[0]; - final String dumpFileName = args[1]; - final String surefirePropsFileName = args[2]; + private volatile long systemExitTimeoutInSeconds = DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS; + private volatile PingScheduler pingScheduler; - BooterDeserializer booterDeserializer = - new BooterDeserializer( createSurefirePropertiesIfFileExists( tmpDir, surefirePropsFileName ) ); - if ( args.length > 3 ) - { - final String effectiveSystemPropertiesFileName = args[3]; - setSystemProperties( new File( tmpDir, effectiveSystemPropertiesFileName ) ); - } + private ScheduledThreadPoolExecutor jvmTerminator; + private ProviderConfiguration providerConfiguration; + private StartupConfiguration startupConfiguration; + private Object testSet; - final ProviderConfiguration providerConfiguration = booterDeserializer.deserialize(); - DumpErrorSingleton.getSingleton().init( dumpFileName, providerConfiguration.getReporterConfiguration() ); + private void setupBooter( String tmpDir, String dumpFileName, String surefirePropsFileName, + String effectiveSystemPropertiesFileName ) + throws IOException, SurefireExecutionException + { + BooterDeserializer booterDeserializer = + new BooterDeserializer( createSurefirePropertiesIfFileExists( tmpDir, surefirePropsFileName ) ); + // todo: print PID in debug console logger in version 2.20.2 + pingScheduler = isDebugging() ? null : listenToShutdownCommands( booterDeserializer.getPluginPid() ); + setSystemProperties( new File( tmpDir, effectiveSystemPropertiesFileName ) ); - final StartupConfiguration startupConfiguration = booterDeserializer.getProviderConfiguration(); - systemExitTimeoutInSeconds = - providerConfiguration.systemExitTimeout( DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS ); - final TypeEncodedValue forkedTestSet = providerConfiguration.getTestForFork(); - final boolean readTestsFromInputStream = providerConfiguration.isReadTestsFromInStream(); + providerConfiguration = booterDeserializer.deserialize(); + DumpErrorSingleton.getSingleton().init( dumpFileName, providerConfiguration.getReporterConfiguration() ); - final ClasspathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration(); - if ( startupConfiguration.isManifestOnlyJarRequestedAndUsable() ) - { - classpathConfiguration.trickClassPathWhenManifestOnlyClasspath(); - } + startupConfiguration = booterDeserializer.getProviderConfiguration(); + systemExitTimeoutInSeconds = + providerConfiguration.systemExitTimeout( DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS ); - final ClassLoader classLoader = currentThread().getContextClassLoader(); - classLoader.setDefaultAssertionStatus( classpathConfiguration.isEnableAssertions() ); - startupConfiguration.writeSurefireTestClasspathProperty(); + ClasspathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration(); + if ( startupConfiguration.isManifestOnlyJarRequestedAndUsable() ) + { + classpathConfiguration.trickClassPathWhenManifestOnlyClasspath(); + } - final Object testSet; - if ( forkedTestSet != null ) - { - testSet = forkedTestSet.getDecodedValue( classLoader ); - } - else if ( readTestsFromInputStream ) - { - testSet = new LazyTestsToRun( originalOut ); - } - else - { - testSet = null; - } + ClassLoader classLoader = currentThread().getContextClassLoader(); + classLoader.setDefaultAssertionStatus( classpathConfiguration.isEnableAssertions() ); + startupConfiguration.writeSurefireTestClasspathProperty(); + testSet = createTestSet( providerConfiguration.getTestForFork(), + providerConfiguration.isReadTestsFromInStream(), classLoader ); + } - try - { - runSuitesInProcess( testSet, startupConfiguration, providerConfiguration, originalOut ); - } - catch ( InvocationTargetException t ) - { - DumpErrorSingleton.getSingleton().dumpException( t ); - StackTraceWriter stackTraceWriter = + private void execute() + { + try + { + runSuitesInProcess(); + } + catch ( InvocationTargetException t ) + { + DumpErrorSingleton.getSingleton().dumpException( t ); + StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter( "test subsystem", "no method", t.getTargetException() ); - StringBuilder stringBuilder = new StringBuilder(); - encode( stringBuilder, stackTraceWriter, false ); - encodeAndWriteToOutput( ( (char) BOOTERCODE_ERROR ) + ",0," + stringBuilder + "\n" , originalOut ); - } - catch ( Throwable t ) - { - DumpErrorSingleton.getSingleton().dumpException( t ); - StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter( "test subsystem", "no method", t ); - StringBuilder stringBuilder = new StringBuilder(); - encode( stringBuilder, stackTraceWriter, false ); - encodeAndWriteToOutput( ( (char) BOOTERCODE_ERROR ) + ",0," + stringBuilder + "\n", originalOut ); - } - acknowledgedExit( originalOut, pingScheduler ); + StringBuilder stringBuilder = new StringBuilder(); + encode( stringBuilder, stackTraceWriter, false ); + encodeAndWriteToOutput( ( (char) BOOTERCODE_ERROR ) + ",0," + stringBuilder + "\n" ); } catch ( Throwable t ) { 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 ); - cancelPingScheduler( pingScheduler ); - // noinspection ProhibitedExceptionThrown,CallToSystemExit - exit( 1 ); + StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter( "test subsystem", "no method", t ); + StringBuilder stringBuilder = new StringBuilder(); + encode( stringBuilder, stackTraceWriter, false ); + encodeAndWriteToOutput( ( (char) BOOTERCODE_ERROR ) + ",0," + stringBuilder + "\n" ); } + acknowledgedExit(); } - private static void cancelPingScheduler( final ExecutorService pingScheduler ) + private Object createTestSet( TypeEncodedValue forkedTestSet, boolean readTestsFromCommandReader, ClassLoader cl ) + { + if ( forkedTestSet != null ) + { + return forkedTestSet.getDecodedValue( cl ); + } + else if ( readTestsFromCommandReader ) + { + return new LazyTestsToRun( originalOut ); + } + return null; + } + + private void cancelPingScheduler() { if ( pingScheduler != null ) { @@ -197,23 +175,52 @@ public Object run() } } - private static CommandReader startupMasterProcessReader() + private PingScheduler listenToShutdownCommands( Long pluginPid ) { - return getReader(); + commandReader.addShutdownListener( createExitHandler() ); + AtomicBoolean pingDone = new AtomicBoolean( true ); + commandReader.addNoopListener( createPingHandler( pingDone ) ); + + PingScheduler pingMechanisms = new PingScheduler( createPingScheduler(), + pluginPid == null ? null : new PpidChecker( pluginPid ) ); + if ( pingMechanisms.pluginProcessChecker != null ) + { + Runnable checkerJob = processCheckerJob( pingMechanisms ); + pingMechanisms.pingScheduler.scheduleWithFixedDelay( checkerJob, 0L, 1L, SECONDS ); + } + Runnable pingJob = createPingJob( pingDone, pingMechanisms.pluginProcessChecker ); + pingMechanisms.pingScheduler.scheduleAtFixedRate( pingJob, 0L, PING_TIMEOUT_IN_SECONDS, SECONDS ); + + return pingMechanisms; } - private static ExecutorService listenToShutdownCommands() + private Runnable processCheckerJob( final PingScheduler pingMechanism ) { - COMMAND_READER.addShutdownListener( createExitHandler() ); - AtomicBoolean pingDone = new AtomicBoolean( true ); - COMMAND_READER.addNoopListener( createPingHandler( pingDone ) ); - Runnable pingJob = createPingJob( pingDone ); - ScheduledExecutorService pingScheduler = createPingScheduler(); - pingScheduler.scheduleAtFixedRate( pingJob, 0, PING_TIMEOUT_IN_SECONDS, SECONDS ); - return pingScheduler; + return new Runnable() + { + @Override + public void run() + { + try + { + if ( pingMechanism.pluginProcessChecker.canUse() + && !pingMechanism.pluginProcessChecker.isProcessAlive() + && !pingMechanism.pingScheduler.isShutdown() ) + { + DumpErrorSingleton.getSingleton().dumpText( "Killing self fork JVM. Maven process died." ); + kill(); + } + } + catch ( Exception e ) + { + DumpErrorSingleton.getSingleton() + .dumpText( "System.exit() or native command error interrupted process checker." ); + } + } + }; } - private static CommandListener createPingHandler( final AtomicBoolean pingDone ) + private CommandListener createPingHandler( final AtomicBoolean pingDone ) { return new CommandListener() { @@ -225,7 +232,7 @@ public void update( Command command ) }; } - private static CommandListener createExitHandler() + private CommandListener createExitHandler() { return new CommandListener() { @@ -235,10 +242,15 @@ public void update( Command command ) Shutdown shutdown = command.toShutdownData(); if ( shutdown.isKill() ) { + DumpErrorSingleton.getSingleton() + .dumpText( "Killing self fork JVM. Received SHUTDOWN command from Maven shutdown hook." ); kill(); } else if ( shutdown.isExit() ) { + cancelPingScheduler(); + DumpErrorSingleton.getSingleton() + .dumpText( "Exiting self fork JVM. Received SHUTDOWN command from Maven shutdown hook." ); exit( 1 ); } // else refers to shutdown=testset, but not used now, keeping reader open @@ -246,98 +258,89 @@ else if ( shutdown.isExit() ) }; } - private static Runnable createPingJob( final AtomicBoolean pingDone ) + private Runnable createPingJob( final AtomicBoolean pingDone, final PpidChecker pluginProcessChecker ) { return new Runnable() { @Override public void run() { - boolean hasPing = pingDone.getAndSet( false ); - if ( !hasPing ) + if ( !canUseNewPingMechanism( pluginProcessChecker ) ) { - kill(); + boolean hasPing = pingDone.getAndSet( false ); + if ( !hasPing ) + { + DumpErrorSingleton.getSingleton().dumpText( "Killing self fork JVM. PING timeout elapsed." ); + kill(); + } } } }; } - private static void encodeAndWriteToOutput( String string, PrintStream out ) + private void encodeAndWriteToOutput( String string ) { byte[] encodeBytes = encodeStringForForkCommunication( string ); //noinspection SynchronizationOnLocalVariableOrMethodParameter - synchronized ( out ) + synchronized ( originalOut ) { - out.write( encodeBytes, 0, encodeBytes.length ); - out.flush(); + originalOut.write( encodeBytes, 0, encodeBytes.length ); + originalOut.flush(); } } - private static void kill() + private void kill() + { + kill( 1 ); + } + + private void kill( int returnCode ) { - COMMAND_READER.stop(); - Runtime.getRuntime().halt( 1 ); + commandReader.stop(); + Runtime.getRuntime().halt( returnCode ); } - private static void exit( int returnCode ) + private void exit( int returnCode ) { launchLastDitchDaemonShutdownThread( returnCode ); - COMMAND_READER.stop(); System.exit( returnCode ); } - private static void acknowledgedExit( PrintStream originalOut, ExecutorService pingScheduler ) + private void acknowledgedExit() { final Semaphore barrier = new Semaphore( 0 ); - COMMAND_READER.addByeAckListener( new CommandListener() - { - @Override - public void update( Command command ) - { - barrier.release(); - } - } + commandReader.addByeAckListener( new CommandListener() + { + @Override + public void update( Command command ) + { + barrier.release(); + } + } ); - encodeAndWriteToOutput( ( (char) BOOTERCODE_BYE ) + ",0,BYE!\n", originalOut ); + encodeAndWriteToOutput( ( (char) BOOTERCODE_BYE ) + ",0,BYE!\n" ); launchLastDitchDaemonShutdownThread( 0 ); long timeoutMillis = max( systemExitTimeoutInSeconds * ONE_SECOND_IN_MILLIS, ONE_SECOND_IN_MILLIS ); acquireOnePermit( barrier, timeoutMillis ); - cancelPingScheduler( pingScheduler ); - COMMAND_READER.stop(); + cancelPingScheduler(); + commandReader.stop(); System.exit( 0 ); } - private static boolean acquireOnePermit( Semaphore barrier, long timeoutMillis ) - { - try - { - return barrier.tryAcquire( timeoutMillis, MILLISECONDS ); - } - catch ( InterruptedException e ) - { - return true; - } - } - - private static RunResult runSuitesInProcess( Object testSet, StartupConfiguration startupConfiguration, - ProviderConfiguration providerConfiguration, - PrintStream originalSystemOut ) + private RunResult runSuitesInProcess() throws SurefireExecutionException, TestSetFailedException, InvocationTargetException { - final ReporterFactory factory = createForkingReporterFactory( providerConfiguration, originalSystemOut ); - - return invokeProviderInSameClassLoader( testSet, factory, providerConfiguration, true, startupConfiguration, - false ); + ForkingReporterFactory factory = createForkingReporterFactory(); + return invokeProviderInSameClassLoader( factory ); } - private static ReporterFactory createForkingReporterFactory( ProviderConfiguration providerConfiguration, - PrintStream originalSystemOut ) + private ForkingReporterFactory createForkingReporterFactory() { final boolean trimStackTrace = providerConfiguration.getReporterConfiguration().isTrimStackTrace(); - return new ForkingReporterFactory( trimStackTrace, originalSystemOut ); + return new ForkingReporterFactory( trimStackTrace, originalOut ); } - private static synchronized ScheduledThreadPoolExecutor getJvmTerminator() + private synchronized ScheduledThreadPoolExecutor getJvmTerminator() { if ( jvmTerminator == null ) { @@ -345,71 +348,34 @@ private static synchronized ScheduledThreadPoolExecutor getJvmTerminator() newDaemonThreadFactory( "last-ditch-daemon-shutdown-thread-" + systemExitTimeoutInSeconds + "s" ); jvmTerminator = new ScheduledThreadPoolExecutor( 1, threadFactory ); jvmTerminator.setMaximumPoolSize( 1 ); - return jvmTerminator; - } - else - { - return jvmTerminator; } - } - - private static ScheduledExecutorService createPingScheduler() - { - ThreadFactory threadFactory = newDaemonThreadFactory( "ping-" + PING_TIMEOUT_IN_SECONDS + "s" ); - ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor( 1, threadFactory ); - executor.setMaximumPoolSize( 1 ); - executor.prestartCoreThread(); - return executor; + return jvmTerminator; } @SuppressWarnings( "checkstyle:emptyblock" ) - private static void launchLastDitchDaemonShutdownThread( final int returnCode ) + private void launchLastDitchDaemonShutdownThread( final int returnCode ) { getJvmTerminator().schedule( new Runnable() { @Override public void run() { - COMMAND_READER.stop(); - Runtime.getRuntime().halt( returnCode ); + kill( returnCode ); } }, systemExitTimeoutInSeconds, SECONDS ); } - private static RunResult invokeProviderInSameClassLoader( Object testSet, Object factory, - ProviderConfiguration providerConfig, - boolean insideFork, - StartupConfiguration startupConfig, - boolean restoreStreams ) + private RunResult invokeProviderInSameClassLoader( ForkingReporterFactory factory ) throws TestSetFailedException, InvocationTargetException { - final PrintStream orgSystemOut = out; - final PrintStream orgSystemErr = err; - // Note that System.out/System.err are also read in the "ReporterConfiguration" instantiation - // in createProvider below. These are the same values as here. - - try - { - return createProviderInCurrentClassloader( startupConfig, insideFork, providerConfig, factory ) - .invoke( testSet ); - } - finally - { - if ( restoreStreams && System.getSecurityManager() == null ) - { - setOut( orgSystemOut ); - setErr( orgSystemErr ); - } - } + return createProviderInCurrentClassloader( factory ) + .invoke( testSet ); } - private static SurefireProvider createProviderInCurrentClassloader( StartupConfiguration startupConfiguration, - boolean isInsideFork, - ProviderConfiguration providerConfiguration, - Object reporterManagerFactory ) + private SurefireProvider createProviderInCurrentClassloader( ForkingReporterFactory reporterManagerFactory ) { - BaseProviderFactory bpf = new BaseProviderFactory( (ReporterFactory) reporterManagerFactory, isInsideFork ); + BaseProviderFactory bpf = new BaseProviderFactory( reporterManagerFactory, true ); bpf.setTestRequest( providerConfiguration.getTestSuiteDefinition() ); bpf.setReporterConfiguration( providerConfiguration.getReporterConfiguration() ); ClassLoader classLoader = currentThread().getContextClassLoader(); @@ -426,6 +392,55 @@ private static SurefireProvider createProviderInCurrentClassloader( StartupConfi return (SurefireProvider) instantiateOneArg( classLoader, providerClass, ProviderParameters.class, bpf ); } + /** + * This method is invoked when Surefire is forked - this method parses and organizes the arguments passed to it and + * then calls the Surefire class' run method.
    The system exit code will be 1 if an exception is thrown. + * + * @param args Commandline arguments + */ + public static void main( String... args ) + { + ForkedBooter booter = new ForkedBooter(); + try + { + booter.setupBooter( args[0], args[1], args[2], args.length > 3 ? args[3] : null ); + booter.execute(); + } + catch ( Throwable t ) + { + DumpErrorSingleton.getSingleton().dumpException( t ); + t.printStackTrace(); + booter.cancelPingScheduler(); + booter.exit( 1 ); + } + } + + private static boolean canUseNewPingMechanism( PpidChecker pluginProcessChecker ) + { + return pluginProcessChecker != null && pluginProcessChecker.canUse(); + } + + private static boolean acquireOnePermit( Semaphore barrier, long timeoutMillis ) + { + try + { + return barrier.tryAcquire( timeoutMillis, MILLISECONDS ); + } + catch ( InterruptedException e ) + { + return true; + } + } + + private static ScheduledExecutorService createPingScheduler() + { + ThreadFactory threadFactory = newDaemonThreadFactory( "ping-" + PING_TIMEOUT_IN_SECONDS + "s" ); + ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor( 1, threadFactory ); + executor.setKeepAliveTime( 3L, SECONDS ); + executor.setMaximumPoolSize( 2 ); + return executor; + } + private static InputStream createSurefirePropertiesIfFileExists( String tmpDir, String propFileName ) throws FileNotFoundException { @@ -444,4 +459,30 @@ private static boolean isDebugging() } return false; } + + private static class PingScheduler + { + private final ScheduledExecutorService pingScheduler; + private final PpidChecker pluginProcessChecker; + + PingScheduler( ScheduledExecutorService pingScheduler, PpidChecker pluginProcessChecker ) + { + this.pingScheduler = pingScheduler; + this.pluginProcessChecker = pluginProcessChecker; + } + + void shutdown() + { + pingScheduler.shutdown(); + if ( pluginProcessChecker != null ) + { + pluginProcessChecker.destroyActiveCommands(); + } + } + + boolean isShutdown() + { + return pingScheduler.isShutdown(); + } + } } diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java new file mode 100644 index 0000000000..f7eb1dfa5d --- /dev/null +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java @@ -0,0 +1,295 @@ +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 java.io.File; +import java.io.IOException; +import java.util.Queue; +import java.util.Scanner; +import java.util.StringTokenizer; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static java.lang.Long.parseLong; +import static java.util.concurrent.TimeUnit.DAYS; +import static java.util.concurrent.TimeUnit.HOURS; +import static java.util.concurrent.TimeUnit.MINUTES; +import static java.util.regex.Pattern.compile; +import static org.apache.commons.io.IOUtils.closeQuietly; +import static org.apache.commons.lang3.SystemUtils.IS_OS_UNIX; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; +import static org.apache.maven.surefire.booter.ProcessInfo.ERR_PROCESS_INFO; +import static org.apache.maven.surefire.booter.ProcessInfo.INVALID_PROCESS_INFO; + +/** + * Recognizes PID of Plugin process and determines lifetime. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +final class PpidChecker +{ + private static final String WMIC_CREATION_DATE = "CreationDate"; + + private final Queue destroyableCommands = new ConcurrentLinkedQueue(); + + /** + * The etime is in the form of [[dd-]hh:]mm:ss on Unix like systems. + */ + static final Pattern UNIX_CMD_OUT_PATTERN = compile( "^(((\\d+)-)?(\\d{2}):)?(\\d{2}):(\\d{2})$" ); + + private final long pluginPid; + + private volatile ProcessInfo pluginProcessInfo; + private volatile boolean stopped; + + PpidChecker( long pluginPid ) + { + this.pluginPid = pluginPid; + } + + boolean canUse() + { + return pluginProcessInfo == null + ? IS_OS_WINDOWS || IS_OS_UNIX + : pluginProcessInfo.isValid() && !pluginProcessInfo.isError(); + } + + /** + * This method can be called only after {@link #canUse()} has returned {@code true}. + * + * @return {@code true} if parent process is alive; {@code false} otherwise + * @throws IllegalStateException if {@link #canUse()} returns {@code false} + * or the object has been {@link #destroyActiveCommands() destroyed} + */ + @SuppressWarnings( "unchecked" ) + boolean isProcessAlive() + { + if ( !canUse() ) + { + throw new IllegalStateException( "irrelevant to call isProcessAlive()" ); + } + + if ( IS_OS_WINDOWS ) + { + ProcessInfo previousPluginProcessInfo = pluginProcessInfo; + pluginProcessInfo = windows(); + if ( isStopped() || pluginProcessInfo.isError() ) + { + throw new IllegalStateException( "error to read process" ); + } + // let's compare creation time, should be same unless killed or PID is reused by OS into another process + return pluginProcessInfo.isValid() + && ( previousPluginProcessInfo == null + || pluginProcessInfo.isTimeEqualTo( previousPluginProcessInfo ) ); + } + else if ( IS_OS_UNIX ) + { + ProcessInfo previousPluginProcessInfo = pluginProcessInfo; + pluginProcessInfo = unix(); + if ( isStopped() || pluginProcessInfo.isError() ) + { + throw new IllegalStateException( "error to read process" ); + } + // let's compare elapsed time, should be greater or equal if parent process is the same and still alive + return pluginProcessInfo.isValid() + && ( previousPluginProcessInfo == null + || pluginProcessInfo.isTimeEqualTo( previousPluginProcessInfo ) + || pluginProcessInfo.isTimeAfter( previousPluginProcessInfo ) ); + } + + throw new IllegalStateException(); + } + + // https://www.freebsd.org/cgi/man.cgi?ps(1) + // etimes elapsed running time, in decimal integer seconds + + // http://manpages.ubuntu.com/manpages/xenial/man1/ps.1.html + // etimes elapsed time since the process was started, in seconds. + + // http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/9b8c96f96a0f/test/java/lang/ProcessBuilder/Basic.java#L167 + ProcessInfo unix() + { + ProcessInfoConsumer reader = new ProcessInfoConsumer() + { + @Override + ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo ) + { + if ( !previousProcessInfo.isValid() ) + { + Matcher matcher = UNIX_CMD_OUT_PATTERN.matcher( line ); + if ( matcher.matches() ) + { + long pidUptime = fromDays( matcher ) + + fromHours( matcher ) + + fromMinutes( matcher ) + + fromSeconds( matcher ); + return ProcessInfo.unixProcessInfo( pluginPid, pidUptime ); + } + } + return previousProcessInfo; + } + }; + + return reader.execute( "/bin/sh", "-c", unixPathToPS() + " -o etime= -p " + pluginPid ); + } + + ProcessInfo windows() + { + ProcessInfoConsumer reader = new ProcessInfoConsumer() + { + private boolean hasHeader; + + @Override + ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo ) + { + if ( !previousProcessInfo.isValid() ) + { + StringTokenizer args = new StringTokenizer( line ); + if ( args.countTokens() == 1 ) + { + if ( hasHeader ) + { + String startTimestamp = args.nextToken(); + return ProcessInfo.windowsProcessInfo( pluginPid, startTimestamp ); + } + else + { + hasHeader = WMIC_CREATION_DATE.equals( args.nextToken() ); + } + } + } + return previousProcessInfo; + } + }; + String pid = String.valueOf( pluginPid ); + return reader.execute( "CMD", "/A", "/X", "/C", + "wmic process where (ProcessId=" + pid + ") get " + WMIC_CREATION_DATE + ); + } + + void destroyActiveCommands() + { + stopped = true; + for ( Process p = destroyableCommands.poll(); p != null; p = destroyableCommands.poll() ) + { + p.destroy(); + } + } + + private boolean isStopped() + { + return stopped; + } + + static String unixPathToPS() + { + return new File( "/usr/bin/ps" ).canExecute() ? "/usr/bin/ps" : "/bin/ps"; + } + + static long fromDays( Matcher matcher ) + { + String s = matcher.group( 3 ); + return s == null ? 0L : DAYS.toSeconds( parseLong( s ) ); + } + + static long fromHours( Matcher matcher ) + { + String s = matcher.group( 4 ); + return s == null ? 0L : HOURS.toSeconds( parseLong( s ) ); + } + + static long fromMinutes( Matcher matcher ) + { + String s = matcher.group( 5 ); + return s == null ? 0L : MINUTES.toSeconds( parseLong( s ) ); + } + + static long fromSeconds( Matcher matcher ) + { + String s = matcher.group( 6 ); + return s == null ? 0L : parseLong( s ); + } + + private static void checkValid( Scanner scanner ) + throws IOException + { + IOException exception = scanner.ioException(); + if ( exception != null ) + { + throw exception; + } + } + + /** + * Reads standard output from {@link Process}. + *
    + * The artifact maven-shared-utils has non-daemon Threads which is an issue in Surefire to satisfy System.exit. + * This implementation is taylor made without using any Thread. + * It's easy to destroy Process from other Thread. + */ + private abstract class ProcessInfoConsumer + { + abstract ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo ); + + ProcessInfo execute( String... command ) + { + ProcessBuilder processBuilder = new ProcessBuilder( command ); + processBuilder.redirectErrorStream( true ); + Process process = null; + ProcessInfo processInfo = INVALID_PROCESS_INFO; + try + { + process = processBuilder.start(); + destroyableCommands.add( process ); + Scanner scanner = new Scanner( process.getInputStream() ); + while ( scanner.hasNextLine() ) + { + String line = scanner.nextLine().trim(); + processInfo = consumeLine( line, processInfo ); + } + checkValid( scanner ); + int exitCode = process.waitFor(); + return exitCode == 0 ? processInfo : INVALID_PROCESS_INFO; + } + catch ( IOException e ) + { + return ERR_PROCESS_INFO; + } + catch ( InterruptedException e ) + { + return ERR_PROCESS_INFO; + } + finally + { + if ( process != null ) + { + destroyableCommands.remove( process ); + process.destroy(); + closeQuietly( process.getInputStream() ); + closeQuietly( process.getErrorStream() ); + closeQuietly( process.getOutputStream() ); + } + } + } + } + +} diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java new file mode 100644 index 0000000000..212e221990 --- /dev/null +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProcessInfo.java @@ -0,0 +1,109 @@ +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 static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull; + +/** + * Immutable object which encapsulates PID and elapsed time (Unix) or start time (Windows). + *
    + * Methods + * ({@link #getPID()}, {@link #getTime()}, {@link #isTimeAfter(ProcessInfo)}, {@link #isTimeEqualTo(ProcessInfo)}) + * throw {@link IllegalStateException} + * if {@link #isValid()} returns {@code false} or {@link #isError()} returns {@code true}. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +final class ProcessInfo +{ + static final ProcessInfo INVALID_PROCESS_INFO = new ProcessInfo( null, null ); + static final ProcessInfo ERR_PROCESS_INFO = new ProcessInfo( null, null ); + + /** + * On Unix we do not get PID due to the command is interested only to etime of PPID: + *
    + *
    /bin/ps -o etime= -p 123
    + */ + static ProcessInfo unixProcessInfo( long pid, long etime ) + { + return new ProcessInfo( pid, etime ); + } + + static ProcessInfo windowsProcessInfo( long pid, String startTimestamp ) + { + return new ProcessInfo( pid, requireNonNull( startTimestamp, "startTimestamp is NULL" ) ); + } + + private final Long pid; + private final Comparable time; + + private ProcessInfo( Long pid, Comparable time ) + { + this.pid = pid; + this.time = time; + } + + boolean isValid() + { + return this != INVALID_PROCESS_INFO; + } + + boolean isError() + { + return this == ERR_PROCESS_INFO; + } + + long getPID() + { + checkValid(); + return pid; + } + + Comparable getTime() + { + checkValid(); + return time; + } + + @SuppressWarnings( "unchecked" ) + boolean isTimeEqualTo( ProcessInfo that ) + { + checkValid(); + that.checkValid(); + return this.time.compareTo( that.time ) == 0; + } + + @SuppressWarnings( "unchecked" ) + boolean isTimeAfter( ProcessInfo that ) + { + checkValid(); + that.checkValid(); + return this.time.compareTo( that.time ) > 0; + } + + private void checkValid() + { + if ( !isValid() || isError() ) + { + throw new IllegalStateException( "invalid process info" ); + } + } +} 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 41b48500e1..d94be7136b 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 @@ -70,6 +70,12 @@ public int getIntProperty( String propertyName ) return Integer.parseInt( properties.get( propertyName ) ); } + public Long getLongProperty( String propertyName ) + { + String number = getProperty( propertyName ); + return number == null ? null : Long.parseLong( number ); + } + public File getFileProperty( String key ) { final String property = getProperty( key ); diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java new file mode 100644 index 0000000000..ccdb6e6d2e --- /dev/null +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java @@ -0,0 +1,181 @@ +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.util.ReflectionUtils; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.lang.management.ManagementFactory; +import java.lang.reflect.Method; + +import static java.lang.Thread.currentThread; +import static org.apache.commons.lang3.JavaVersion.JAVA_9; +import static org.apache.commons.lang3.JavaVersion.JAVA_RECENT; +import static org.apache.commons.lang3.SystemUtils.IS_OS_FREE_BSD; +import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX; +import static org.apache.commons.lang3.SystemUtils.IS_OS_NET_BSD; +import static org.apache.commons.lang3.SystemUtils.IS_OS_OPEN_BSD; +import static org.apache.maven.surefire.util.ReflectionUtils.invokeMethodChain; +import static org.apache.maven.surefire.util.ReflectionUtils.tryLoadClass; + +/** + * JDK 9 support. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public final class SystemUtils +{ + private static final int PROC_STATUS_PID_FIRST_CHARS = 20; + + public SystemUtils() + { + throw new IllegalStateException( "no instantiable constructor" ); + } + + public static ClassLoader platformClassLoader() + { + if ( JAVA_RECENT.atLeast( JAVA_9 ) ) + { + return reflectClassLoader( ClassLoader.class, "getPlatformClassLoader" ); + } + return null; + } + + public static Long pid() + { + if ( JAVA_RECENT.atLeast( JAVA_9 ) ) + { + Long pid = pidOnJava9(); + if ( pid != null ) + { + return pid; + } + } + + if ( IS_OS_LINUX ) + { + try + { + return pidStatusOnLinux(); + } + catch ( Exception e ) + { + // examine PID via JMX + } + } + else if ( IS_OS_FREE_BSD || IS_OS_NET_BSD || IS_OS_OPEN_BSD ) + { + try + { + return pidStatusOnBSD(); + } + catch ( Exception e ) + { + // examine PID via JMX + } + } + + return pidOnJMX(); + } + + static Long pidOnJMX() + { + String processName = ManagementFactory.getRuntimeMXBean().getName(); + if ( processName.contains( "@" ) ) + { + String pid = processName.substring( 0, processName.indexOf( '@' ) ).trim(); + try + { + return Long.parseLong( pid ); + } + catch ( NumberFormatException e ) + { + return null; + } + } + + return null; + } + + static Long pidStatusOnLinux() throws Exception + { + FileReader input = new FileReader( "/proc/self/stat" ); + try + { + // Reading and encoding 20 characters is bit faster than whole line. + // size of (long) = 19, + 1 space + char[] buffer = new char[PROC_STATUS_PID_FIRST_CHARS]; + String startLine = new String( buffer, 0, input.read( buffer ) ); + return Long.parseLong( startLine.substring( 0, startLine.indexOf( ' ' ) ) ); + } + finally + { + input.close(); + } + } + + /** + * The process status. This file is read-only and returns a single + * line containing multiple space-separated fields. + * See procfs status + * + * @return current PID + * @throws Exception if could not read /proc/curproc/status + */ + static Long pidStatusOnBSD() throws Exception + { + BufferedReader input = new BufferedReader( new FileReader( "/proc/curproc/status" ) ); + try + { + String line = input.readLine(); + int i1 = 1 + line.indexOf( ' ' ); + int i2 = line.indexOf( ' ', i1 ); + return Long.parseLong( line.substring( i1, i2 ) ); + } + finally + { + input.close(); + } + } + + static Long pidOnJava9() + { + ClassLoader classLoader = currentThread().getContextClassLoader(); + Class processHandle = tryLoadClass( classLoader, "java.lang.ProcessHandle" ); + Class[] classesChain = { processHandle, processHandle }; + String[] methodChain = { "current", "pid" }; + return (Long) invokeMethodChain( classesChain, methodChain, null ); + } + + 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; + } + } +} diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java index 2bdcf21b3c..f073a8b003 100644 --- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java @@ -34,7 +34,9 @@ ClasspathTest.class, CommandReaderTest.class, PropertiesWrapperTest.class, - SurefireReflectorTest.class + SurefireReflectorTest.class, + PpidCheckerTest.class, + SystemUtilsTest.class } ) @RunWith( Suite.class ) public class JUnit4SuiteTest diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java index 4342ec7e95..4cf9424a56 100644 --- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java @@ -34,10 +34,19 @@ import org.junit.runners.model.Statement; import org.junit.runners.model.TestClass; +import java.io.File; +import java.io.IOException; import java.lang.annotation.Annotation; +import java.net.MalformedURLException; +import java.net.URL; import java.net.URLClassLoader; +import java.util.Collection; +import java.util.HashSet; import java.util.List; +import static java.io.File.pathSeparator; +import static org.apache.commons.io.FileUtils.readFileToString; + /** * JUnit runner testing methods in a separate class loader. * @@ -185,7 +194,63 @@ public static class TestClassLoader { public TestClassLoader() { - super( ( (URLClassLoader) Thread.currentThread().getContextClassLoader() ).getURLs(), null ); + super( toClassPath(), null ); + } + + /** + * Compliant with Java 9 or prior version of JRE. + * + * @return classpath + */ + private static URL[] toClassPath() + { + try + { + Collection cp = toPathList(); // if Maven run + if ( cp.isEmpty() ) + { + // if IDE + cp = toPathList( System.getProperty( "java.class.path" ) ); + } + return cp.toArray( new URL[cp.size()] ); + } + catch ( IOException e ) + { + return new URL[0]; + } + } + + private static Collection toPathList( String path ) throws MalformedURLException + { + Collection classPath = new HashSet(); + for ( String file : path.split( pathSeparator ) ) + { + classPath.add( new File( file ).toURL() ); + } + return classPath; + } + + private static Collection toPathList() + { + Collection classPath = new HashSet(); + try + { + String[] files = readFileToString( new File( "target/test-classpath/cp.txt" ) ).split( pathSeparator ); + for ( String file : files ) + { + File f = new File( file ); + File dir = f.getParentFile(); + classPath.add( ( dir.getName().equals( "target" ) ? new File( dir, "classes" ) : f ).toURL() ); + } + classPath.add( new File( "target/classes" ).toURL() ); + classPath.add( new File( "target/test-classes" ).toURL() ); + } + catch ( IOException e ) + { + // turn to java.class.path + classPath.clear(); + } + return classPath; } } } diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java new file mode 100644 index 0000000000..b0153ac5a1 --- /dev/null +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java @@ -0,0 +1,144 @@ +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.junit.Test; + +import java.lang.management.ManagementFactory; +import java.util.regex.Matcher; + +import static org.apache.commons.lang3.SystemUtils.IS_OS_UNIX; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; +import static org.fest.assertions.Assertions.assertThat; +import static org.junit.Assume.assumeTrue; + +/** + * Testing {@link PpidChecker} on a platform. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public class PpidCheckerTest +{ + @Test + public void shouldHavePpidAsWindows() + { + assumeTrue( IS_OS_WINDOWS ); + + long expectedPid = Long.parseLong( ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim() ); + + PpidChecker checker = new PpidChecker( expectedPid ); + ProcessInfo processInfo = checker.windows(); + + assertThat( processInfo ) + .isNotNull(); + + assertThat( checker.canUse() ) + .isTrue(); + + assertThat( checker.isProcessAlive() ) + .isTrue(); + + assertThat( processInfo.getPID() ) + .isEqualTo( expectedPid ); + + assertThat( processInfo.getTime() ) + .isNotNull(); + } + + @Test + public void shouldHavePpidAsUnix() + { + assumeTrue( IS_OS_UNIX ); + + long expectedPid = Long.parseLong( ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim() ); + + PpidChecker checker = new PpidChecker( expectedPid ); + ProcessInfo processInfo = checker.unix(); + + assertThat( processInfo ) + .isNotNull(); + + assertThat( checker.canUse() ) + .isTrue(); + + assertThat( checker.isProcessAlive() ) + .isTrue(); + + assertThat( processInfo.getPID() ) + .isEqualTo( expectedPid ); + + assertThat( processInfo.getTime() ) + .isNotNull(); + } + + @Test + public void shouldNotFindSuchPID() + { + PpidChecker checker = new PpidChecker( 1000000L ); + assertThat( checker.canUse() ) + .isTrue(); + + boolean isAlive = checker.isProcessAlive(); + + assertThat( isAlive ) + .isFalse(); + } + + @Test + public void shouldParseEtime() + { + Matcher m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "38" ); + assertThat( m.matches() ) + .isFalse(); + + m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "05:38" ); + assertThat( m.matches() ) + .isTrue(); + assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 0L ); + assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 0L ); + assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); + assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); + + m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "00:05:38" ); + assertThat( m.matches() ) + .isTrue(); + assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 0L ); + assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 0L ); + assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); + assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); + + m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "01:05:38" ); + assertThat( m.matches() ) + .isTrue(); + assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 0L ); + assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 3600L ); + assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); + assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); + + m = PpidChecker.UNIX_CMD_OUT_PATTERN.matcher( "02-01:05:38" ); + assertThat( m.matches() ) + .isTrue(); + assertThat( PpidChecker.fromDays( m ) ).isEqualTo( 2 * 24 * 3600L ); + assertThat( PpidChecker.fromHours( m ) ).isEqualTo( 3600L ); + assertThat( PpidChecker.fromMinutes( m ) ).isEqualTo( 300L ); + assertThat( PpidChecker.fromSeconds( m ) ).isEqualTo( 38L ); + } +} diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java new file mode 100644 index 0000000000..12aff99faf --- /dev/null +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java @@ -0,0 +1,131 @@ +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.junit.Test; + +import java.lang.management.ManagementFactory; + +import static org.apache.commons.lang3.JavaVersion.JAVA_9; +import static org.apache.commons.lang3.JavaVersion.JAVA_RECENT; +import static org.apache.commons.lang3.SystemUtils.IS_OS_FREE_BSD; +import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX; +import static org.apache.commons.lang3.SystemUtils.IS_OS_NET_BSD; +import static org.apache.commons.lang3.SystemUtils.IS_OS_OPEN_BSD; +import static org.fest.assertions.Assertions.assertThat; +import static org.junit.Assume.assumeTrue; + +/** + * Test of {@link SystemUtils}. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public class SystemUtilsTest +{ + @Test + public void shouldBePlatformClassLoader() + { + ClassLoader cl = SystemUtils.platformClassLoader(); + if ( JAVA_RECENT.atLeast( JAVA_9 ) ) + { + assertThat( cl ).isNotNull(); + } + else + { + assertThat( cl ).isNull(); + } + } + + @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() ); + } + + @Test + public void shouldBePidOnJigsaw() + { + assumeTrue( JAVA_RECENT.atLeast( JAVA_9 ) ); + + Long actualPid = SystemUtils.pidOnJava9(); + String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); + + assertThat( actualPid + "" ) + .isEqualTo( expectedPid ); + } + + @Test + public void shouldBePidStatusOnLinux() throws Exception + { + assumeTrue( IS_OS_LINUX ); + + Long actualPid = SystemUtils.pidStatusOnLinux(); + String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); + + assertThat( actualPid + "" ) + .isEqualTo( expectedPid ); + } + + @Test + public void shouldBePidStatusOnBSD() throws Exception + { + assumeTrue( IS_OS_FREE_BSD || IS_OS_NET_BSD || IS_OS_OPEN_BSD ); + + Long actualPid = SystemUtils.pidStatusOnBSD(); + String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); + + assertThat( actualPid + "" ) + .isEqualTo( expectedPid ); + } + + @Test + public void shouldBePidOnJMX() + { + Long actualPid = SystemUtils.pidOnJMX(); + String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); + + assertThat( actualPid + "" ) + .isEqualTo( expectedPid ); + } + + @Test + public void shouldBePid() + { + Long actualPid = SystemUtils.pid(); + String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); + + assertThat( actualPid + "" ) + .isEqualTo( expectedPid ); + } + + public static ClassLoader getPlatformClassLoader() + { + return ClassLoader.getSystemClassLoader(); + } +} 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 1fa88f654d..f051c1cf34 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,8 +27,9 @@ import org.junit.Test; import java.util.Iterator; -import java.util.Locale; +import static org.apache.commons.lang.SystemUtils.IS_OS_LINUX; +import static org.apache.commons.lang.SystemUtils.IS_OS_MAC_OSX; import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; @@ -46,8 +47,7 @@ public class Surefire1295AttributeJvmCrashesToTestsIT @Before public void skipWindows() { - String os = System.getProperty( "os.name" ).toLowerCase( Locale.ROOT ); - assumeTrue( os.equals( "mac os x" ) || os.equals( "linux" ) /*|| os.contains( "windows" )*/ ); + assumeTrue( IS_OS_LINUX || IS_OS_MAC_OSX ); } @Test From 1b0aa38f1138aa51846287180865e7b5b96f2f36 Mon Sep 17 00:00:00 2001 From: Steffen Gebert Date: Fri, 14 Jul 2017 16:08:13 +0200 Subject: [PATCH 105/194] Fix typo in docs --- .../org/apache/maven/plugin/failsafe/IntegrationTestMojo.java | 2 +- .../java/org/apache/maven/plugin/surefire/SurefirePlugin.java | 2 +- 2 files changed, 2 insertions(+), 2 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 a336e281f8..28b2859c7b 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 @@ -134,7 +134,7 @@ public class IntegrationTestMojo private boolean useFile; /** - * Set this to "true" to cause a failure if the none of the tests specified in -Dtest=... are run. Defaults to + * Set this to "true" to cause a failure if none of the tests specified in -Dtest=... are run. Defaults to * "true". * * @since 2.12 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 c93d2c9a19..452cb81549 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 @@ -111,7 +111,7 @@ public class SurefirePlugin private boolean useFile; /** - * Set this to "true" to cause a failure if the none of the tests specified in -Dtest=... are run. Defaults to + * Set this to "true" to cause a failure if none of the tests specified in -Dtest=... are run. Defaults to * "true". * * @since 2.12 From 26527d10c4835c254f8d7d2efb2227a30697f674 Mon Sep 17 00:00:00 2001 From: Andrew Cohen Date: Sun, 16 Jul 2017 11:48:31 -0400 Subject: [PATCH 106/194] SUREFIRE-1391: Eliminate redundant call to process systemPropertyVariables in the calculation of effective properties Signed-off-by: Andrew Cohen --- .../org/apache/maven/plugin/surefire/SurefireProperties.java | 1 - 1 file changed, 1 deletion(-) 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 6609e617bf..8d080b75ea 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 @@ -147,7 +147,6 @@ static SurefireProperties calculateEffectiveProperties( Properties systemPropert result.copyPropertiesFrom( props ); - copyProperties( result, systemPropertyVariables ); copyProperties( result, systemPropertyVariables ); // We used to take all of our system properties and dump them in with the From 413be0d6b7232fe6ef6255492099fb0fb4f3bf24 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 1 Aug 2017 09:37:48 +0200 Subject: [PATCH 107/194] [SUREFIRE-1400] Windows surefire boot directory should appear in system default temporary-directory --- .../plugin/surefire/AbstractSurefireMojo.java | 93 ++++++++++++- .../surefire/AbstractSurefireMojoTest.java | 125 ++++++++++++++++++ .../maven/surefire/JUnit4SuiteTest.java | 4 +- .../maven/surefire/util/ReflectionUtils.java | 29 +++- .../surefire/util/ReflectionUtilsTest.java | 6 +- surefire-integration-tests/pom.xml | 2 + .../maven/surefire/its/LongWindowsPathIT.java | 88 ++++++++++++ .../its/fixture/HelperAssertions.java | 13 +- .../test/resources/long-windows-path/pom.xml | 57 ++++++++ .../test/java/longwindowspath/BasicTest.java | 36 +++++ .../java/jiras/surefre855/bundle/FooIT.java | 32 +---- .../java/jiras/surefire855/jar/FooIT.java | 34 +---- .../java/jiras/surefire855/war/FooIT.java | 32 +---- 13 files changed, 447 insertions(+), 104 deletions(-) create mode 100644 maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java create mode 100644 surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/LongWindowsPathIT.java create mode 100644 surefire-integration-tests/src/test/resources/long-windows-path/pom.xml create mode 100644 surefire-integration-tests/src/test/resources/long-windows-path/src/test/java/longwindowspath/BasicTest.java 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 b3df567dae..f2e5bfbc41 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 @@ -76,12 +76,14 @@ import org.apache.maven.surefire.testset.TestSetFailedException; import org.apache.maven.surefire.util.DefaultScanResult; import org.apache.maven.surefire.util.RunOrder; +import org.apache.maven.surefire.util.SurefireReflectionException; import org.apache.maven.toolchain.Toolchain; import org.apache.maven.toolchain.ToolchainManager; import javax.annotation.Nonnull; import java.io.File; import java.io.IOException; +import java.lang.reflect.Array; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -98,12 +100,18 @@ import java.util.concurrent.ConcurrentHashMap; import static java.lang.Thread.currentThread; +import static org.apache.commons.lang3.JavaVersion.JAVA_1_7; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; +import static org.apache.commons.lang3.SystemUtils.isJavaVersionAtLeast; 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; import static org.apache.maven.surefire.suite.RunResult.failure; import static org.apache.maven.surefire.suite.RunResult.noTestsRun; +import static org.apache.maven.surefire.util.ReflectionUtils.invokeGetter; +import static org.apache.maven.surefire.util.ReflectionUtils.invokeStaticMethod; +import static org.apache.maven.surefire.util.ReflectionUtils.tryLoadClass; /** * Abstract base class for running tests using Surefire. @@ -117,6 +125,8 @@ public abstract class AbstractSurefireMojo { private static final Platform PLATFORM = new Platform(); + private static final File SYSTEM_TMP_DIR = new File( System.getProperty( "java.io.tmpdir" ) ); + private final ProviderDetector providerDetector = new ProviderDetector(); /** @@ -342,7 +352,12 @@ public abstract class AbstractSurefireMojo private String forkMode; /** - * Relative path to project.build.directory containing internal Surefire temporary files. + * Relative path to temporary-surefire-boot directory containing internal Surefire temporary files. + *
    + * The temporary-surefire-boot directory is project.build.directory on most platforms or + * system default temporary-directory specified by the system property {@code java.io.tmpdir} + * on Windows (see SUREFIRE-1400). + *
    * It is deleted after the test set has completed. * * @since 2.20 @@ -1935,8 +1950,6 @@ private InPluginVMSurefireStarter createInprocessStarter( ProviderInfo provider, protected ForkConfiguration getForkConfiguration() { File tmpDir = getSurefireTempDir(); - //noinspection ResultOfMethodCallIgnored - tmpDir.mkdirs(); Artifact shadeFire = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-shadefire" ); @@ -2061,9 +2074,9 @@ private Artifact getSurefireBooterArtifact() * * @return A file pointing to the location of surefire's own temp files */ - private File getSurefireTempDir() + File getSurefireTempDir() { - return new File( getProjectBuildDirectory(), getTempDir() ); + return IS_OS_WINDOWS ? createSurefireBootDirectoryInTemp() : createSurefireBootDirectoryInBuild(); } /** @@ -2829,6 +2842,76 @@ private ProviderInfo findByName( String providerClassName ) } } + File createSurefireBootDirectoryInBuild() + { + File tmp = new File( getProjectBuildDirectory(), getTempDir() ); + //noinspection ResultOfMethodCallIgnored + tmp.mkdirs(); + return tmp; + } + + // todo use Java7 java.nio.file.Files.createTempDirectory() + File createSurefireBootDirectoryInTemp() + { + if ( isJavaVersionAtLeast( JAVA_1_7 ) ) + { + try + { + return new File( SYSTEM_TMP_DIR, createTmpDirectoryNameWithJava7( getTempDir() ) ); + } + catch ( IOException e ) + { + return createSurefireBootDirectoryInBuild(); + } + } + else + { + try + { + File tmp = File.createTempFile( getTempDir(), null ); + //noinspection ResultOfMethodCallIgnored + return tmp.mkdirs() ? tmp : createSurefireBootDirectoryInBuild(); + } + catch ( IOException e ) + { + return createSurefireBootDirectoryInBuild(); + } + } + } + + /** + * Reflection call of java.nio.file.Files.createTempDirectory( "surefire" ). + * @return Java 7 NIO Path + */ + static Object createTmpDirectoryWithJava7( String directoryPrefix ) + throws IOException + { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + Class filesType = tryLoadClass( classLoader, "java.nio.file.Files" ); + Class fileAttributeType = tryLoadClass( classLoader, "java.nio.file.attribute.FileAttribute" ); + Object attrs = Array.newInstance( fileAttributeType, 0 ); + try + { + return invokeStaticMethod( filesType, "createTempDirectory", + new Class[]{ String.class, attrs.getClass() }, + new Object[]{ directoryPrefix, attrs } ); + } + catch ( SurefireReflectionException e ) + { + Throwable cause = e.getCause(); + throw cause instanceof IOException ? (IOException) cause : new IOException( cause ); + } + } + + static String createTmpDirectoryNameWithJava7( String directoryPrefix ) + throws IOException + { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + Class pathType = tryLoadClass( classLoader, "java.nio.file.Path" ); + Object path = createTmpDirectoryWithJava7( directoryPrefix ); + return invokeGetter( pathType, path, "getFileName" ).toString(); + } + @Override public List getExcludes() { diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java new file mode 100644 index 0000000000..a44bea40b6 --- /dev/null +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java @@ -0,0 +1,125 @@ +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 org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; + +import static org.apache.commons.lang3.JavaVersion.JAVA_1_7; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; +import static org.apache.commons.lang3.SystemUtils.isJavaVersionAtLeast; +import static org.fest.assertions.Assertions.assertThat; +import static org.junit.Assume.assumeTrue; +import static org.mockito.Mockito.when; + +/** + * Test for {@link AbstractSurefireMojo}. + */ +@RunWith( MockitoJUnitRunner.class ) +public class AbstractSurefireMojoTest +{ + @Mock + private AbstractSurefireMojo mojo; + + @Test + public void shouldHaveTmpDirectory() throws IOException + { + assumeTrue( isJavaVersionAtLeast( JAVA_1_7 ) ); + + Path path = (Path) AbstractSurefireMojo.createTmpDirectoryWithJava7( "surefire" ); + + assertThat( path ) + .isNotNull(); + + assertThat( path.startsWith( System.getProperty( "java.io.tmpdir" ) ) ) + .isTrue(); + + String dir = path.getName( path.getNameCount() - 1 ).toString(); + + assertThat( dir ) + .startsWith( "surefire" ); + + assertThat( dir ) + .matches( "^surefire[\\d]+$" ); + } + + @Test + public void shouldHaveTmpDirectoryName() throws IOException + { + assumeTrue( isJavaVersionAtLeast( JAVA_1_7 ) ); + + String dir = AbstractSurefireMojo.createTmpDirectoryNameWithJava7( "surefire" ); + + assertThat( dir ) + .isNotNull(); + + assertThat( dir ) + .startsWith( "surefire" ); + + assertThat( dir ) + .matches( "^surefire[\\d]+$" ); + } + + @Test + public void shouldExistTmpDirectory() + { + when( mojo.getTempDir() ).thenReturn( "surefireX" ); + when( mojo.getProjectBuildDirectory() ).thenReturn( new File( System.getProperty( "user.dir" ), "target" ) ); + when( mojo.createSurefireBootDirectoryInTemp() ).thenCallRealMethod(); + when( mojo.createSurefireBootDirectoryInBuild() ).thenCallRealMethod(); + when( mojo.getSurefireTempDir() ).thenCallRealMethod(); + + File tmp = mojo.createSurefireBootDirectoryInTemp(); + assertThat( tmp ).isNotNull(); + assertThat( tmp ).exists(); + assertThat( tmp.getAbsolutePath() ) + .startsWith( System.getProperty( "java.io.tmpdir" ) ); + assertThat( tmp.getName() ) + .startsWith( "surefireX" ); + + tmp = mojo.createSurefireBootDirectoryInBuild(); + assertThat( tmp ).isNotNull(); + assertThat( tmp ).exists(); + assertThat( tmp.getAbsolutePath() ).startsWith( System.getProperty( "user.dir" ) ); + assertThat( tmp.getName() ).isEqualTo( "surefireX" ); + + tmp = mojo.getSurefireTempDir(); + assertThat( tmp ).isNotNull(); + assertThat( tmp ).exists(); + assertThat( tmp.getAbsolutePath() ) + .startsWith( IS_OS_WINDOWS ? System.getProperty( "java.io.tmpdir" ) : System.getProperty( "user.dir" ) ); + if ( IS_OS_WINDOWS ) + { + assertThat( tmp.getName() ) + .startsWith( "surefireX" ); + } + else + { + assertThat( tmp.getName() ) + .isEqualTo( "surefireX" ); + } + } +} 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 f7cec19fd5..aec256dc4c 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.AbstractSurefireMojoTest; import org.apache.maven.plugin.surefire.SurefireHelperTest; import org.apache.maven.plugin.surefire.SurefireReflectorTest; import org.apache.maven.plugin.surefire.SurefirePropertiesTest; @@ -72,7 +73,8 @@ TestLessInputStreamBuilderTest.class, SPITest.class, SurefireReflectorTest.class, - SurefireHelperTest.class + SurefireHelperTest.class, + AbstractSurefireMojoTest.class } ) @RunWith( Suite.class ) public class JUnit4SuiteTest diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java index 1be4e06cd2..49f8f096e0 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java @@ -28,6 +28,9 @@ */ public final class ReflectionUtils { + private static final Class[] EMPTY_CLASS_ARRAY = new Class[0]; + private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; + private ReflectionUtils() { throw new IllegalStateException( "no instantiable constructor" ); @@ -64,7 +67,12 @@ public static Method tryGetMethod( Class clazz, String methodName, Class.. public static Object invokeGetter( Object instance, String methodName ) { - final Method method = getMethod( instance, methodName ); + return invokeGetter( instance.getClass(), instance, methodName ); + } + + public static Object invokeGetter( Class instanceType, Object instance, String methodName ) + { + Method method = getMethod( instanceType, methodName ); return invokeMethodWithArray( instance, method ); } @@ -247,14 +255,22 @@ public static Class loadClass( ClassLoader classLoader, String className ) * * @param clazz class on which public static no-argument {@code methodName} is invoked * @param methodName public static no-argument method to be called + * @param parameterTypes method parameter types + * @param parameters method parameters * @return value returned by {@code methodName} * @throws RuntimeException if no such method found - * @throws SurefireReflectionException if the method could not be called or threw an exception + * @throws SurefireReflectionException if the method could not be called or threw an exception. + * It has original cause Exception. */ - public static Object invokeStaticMethod( Class clazz, String methodName ) + public static Object invokeStaticMethod( Class clazz, String methodName, + Class[] parameterTypes, Object[] parameters ) { - Method method = getMethod( clazz, methodName ); - return invokeMethodWithArray( null, method ); + if ( parameterTypes.length != parameters.length ) + { + throw new IllegalArgumentException( "arguments length do not match" ); + } + Method method = getMethod( clazz, methodName, parameterTypes ); + return invokeMethodWithArray( null, method, parameters ); } /** @@ -279,7 +295,8 @@ public static Object invokeMethodChain( Class[] classesChain, String[] noArgM { if ( i == 0 ) { - obj = invokeStaticMethod( classesChain[i], noArgMethodNames[i] ); + obj = invokeStaticMethod( classesChain[i], noArgMethodNames[i], + EMPTY_CLASS_ARRAY, EMPTY_OBJECT_ARRAY ); } else { diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java index 41f97020bf..5440d6eab0 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java @@ -34,13 +34,15 @@ public class ReflectionUtilsTest @Test(expected = RuntimeException.class) public void shouldNotInvokeStaticMethod() { - ReflectionUtils.invokeStaticMethod( ReflectionUtilsTest.class, "notCallable" ); + ReflectionUtils.invokeStaticMethod( ReflectionUtilsTest.class, "notCallable", + new Class[0], new Object[0] ); } @Test public void shouldInvokeStaticMethod() { - Object o = ReflectionUtils.invokeStaticMethod( ReflectionUtilsTest.class, "callable" ); + Object o = ReflectionUtils.invokeStaticMethod( ReflectionUtilsTest.class, "callable", + new Class[0], new Object[0] ); assertThat( o ) .isEqualTo( 3L ); } diff --git a/surefire-integration-tests/pom.xml b/surefire-integration-tests/pom.xml index 267cedadd7..d9142de6d7 100644 --- a/surefire-integration-tests/pom.xml +++ b/surefire-integration-tests/pom.xml @@ -37,6 +37,8 @@ false 5 false + 1.7 + 1.7 diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/LongWindowsPathIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/LongWindowsPathIT.java new file mode 100644 index 0000000000..62808358a2 --- /dev/null +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/LongWindowsPathIT.java @@ -0,0 +1,88 @@ +package org.apache.maven.surefire.its; + +/* + * 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.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.IOException; + +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; +import static org.fest.assertions.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assume.assumeTrue; + +/** + * Testing long path of base.dir where Windows CLI crashes. + *
    + * Integration test for SUREFIRE-1400. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public class LongWindowsPathIT + extends SurefireJUnit4IntegrationTestCase +{ + private static final String PROJECT_DIR = "long-windows-path"; + private static final String LONG_PATH = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + + // the IT engine crashes using long path + private static final String LONG_DIR = LONG_PATH + LONG_PATH + LONG_PATH; + + @Test + public void shouldRunInSystemTmp() throws Exception + { + assumeTrue( IS_OS_WINDOWS ); + + OutputValidator validator = unpack().setForkJvm() + .showErrorStackTraces() + .executeTest() + .verifyErrorFreeLog(); + + validator.assertThatLogLine( containsString( "SUREFIRE-1400 user.dir=" ), is( 1 ) ) + .assertThatLogLine( containsString( "SUREFIRE-1400 surefire.real.class.path=" ), is( 1 ) ); + + for ( String line : validator.loadLogLines() ) + { + if ( line.contains( "SUREFIRE-1400 user.dir=" ) ) + { + File buildDir = new File( System.getProperty( "user.dir" ), "target" ); + File itBaseDir = new File( buildDir, "LongWindowsPathIT_shouldRunInSystemTmp" ); + + assertThat( line ) + .contains( itBaseDir.getAbsolutePath() ); + } + else if ( line.contains( "SUREFIRE-1400 surefire.real.class.path=" ) ) + { + assertThat( line ) + .contains( System.getProperty( "java.io.tmpdir" ) ); + } + } + } + + private SurefireLauncher unpack() throws IOException + { + return unpack( PROJECT_DIR/*, "_" + LONG_DIR*/ ); + } +} diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java index 98edcfb398..17e52a664e 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java @@ -18,11 +18,6 @@ * under the License. */ -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - import org.apache.commons.lang3.JavaVersion; import org.apache.commons.lang3.SystemUtils; import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; @@ -30,12 +25,14 @@ import org.apache.maven.plugins.surefire.report.ReportTestSuite; import org.apache.maven.plugins.surefire.report.SurefireReportParser; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertTrue; import static org.apache.commons.lang3.SystemUtils.JAVA_SPECIFICATION_VERSION; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.is; -import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeTrue; @SuppressWarnings( { "JavaDoc" } ) diff --git a/surefire-integration-tests/src/test/resources/long-windows-path/pom.xml b/surefire-integration-tests/src/test/resources/long-windows-path/pom.xml new file mode 100644 index 0000000000..c65948cd8e --- /dev/null +++ b/surefire-integration-tests/src/test/resources/long-windows-path/pom.xml @@ -0,0 +1,57 @@ + + + + + 4.0.0 + + + org.apache.maven.surefire + it-parent + 1.0 + ../pom.xml + + + org.apache.maven.plugins.surefire + long-windows-path + 1.0 + + + + junit + junit + 4.12 + test + + + + + + + maven-surefire-plugin + + once + + + + + + diff --git a/surefire-integration-tests/src/test/resources/long-windows-path/src/test/java/longwindowspath/BasicTest.java b/surefire-integration-tests/src/test/resources/long-windows-path/src/test/java/longwindowspath/BasicTest.java new file mode 100644 index 0000000000..bd9cf36d40 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/long-windows-path/src/test/java/longwindowspath/BasicTest.java @@ -0,0 +1,36 @@ +package longwindowspath; + +/* + * 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 BasicTest +{ + @Test + public void test() + { + System.out.println( "SUREFIRE-1400 user.dir=" + + System.getProperty( "user.dir" ) ); + + System.out.println( "SUREFIRE-1400 surefire.real.class.path=" + + System.getProperty( "surefire.real.class.path" ) ); + } + +} diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/src/test/java/jiras/surefre855/bundle/FooIT.java b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/src/test/java/jiras/surefre855/bundle/FooIT.java index aeb666df3c..e5cbffa255 100644 --- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/src/test/java/jiras/surefre855/bundle/FooIT.java +++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-bundle/src/test/java/jiras/surefre855/bundle/FooIT.java @@ -46,7 +46,8 @@ public final class FooIT private static File surefireDir() throws IOException { - return new File( "target/surefire" ).getCanonicalFile(); + String bootPath = System.getProperty( "surefire.real.class.path" ); + return bootPath == null ? null : new File( bootPath ).getParentFile(); } private static File[] surefireProviderProperties() @@ -68,25 +69,6 @@ public boolean accept( File pathname ) } ); } - private static File[] surefireBooterJar() - throws IOException - { - return surefireDir().listFiles( new FileFilter() - { - public boolean accept( File pathname ) - { - try - { - return isSurefireBooter( pathname ); - } - catch ( IOException e ) - { - return false; - } - } - } ); - } - /** * See BooterSerializer#serialize(). */ @@ -110,9 +92,9 @@ private static boolean isSurefireBooter( File pathname ) private static String manifestClassPath( Class clazz ) throws IOException { - File[] booters = surefireBooterJar(); - assertThat( booters, is( arrayWithSize( 1 ) ) ); - File booter = booters[0]; + File booter = new File( System.getProperty( "surefire.real.class.path" ) ); + assertThat( booter ).exists(); + assertThat( booter ).isFile(); JarFile jarFile = new JarFile( booter ); try { @@ -158,10 +140,6 @@ public void test() assertThat( classPath, not( containsString( "/target/classes" ) ) ); assertThat( classPath, containsString( "/target/" + ARTIFACT_FILE_NAME ) ); - File surefireDir = new File( "target/surefire" ).getCanonicalFile(); - System.out.println( "SUREFIRE DIR:" ); - System.out.println( surefireDir ); - File[] descriptors = surefireProviderProperties(); assertThat( descriptors ).hasSize( 1 ); assertThat( descriptors ).doesNotContainNull(); diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/src/test/java/jiras/surefire855/jar/FooIT.java b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/src/test/java/jiras/surefire855/jar/FooIT.java index 606985af78..39b87490c1 100644 --- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/src/test/java/jiras/surefire855/jar/FooIT.java +++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-jar/src/test/java/jiras/surefire855/jar/FooIT.java @@ -47,7 +47,8 @@ public final class FooIT private static File surefireDir() throws IOException { - return new File( "target/surefire" ).getCanonicalFile(); + String bootPath = System.getProperty( "surefire.real.class.path" ); + return bootPath == null ? null : new File( bootPath ).getParentFile(); } private static File[] surefireProviderProperties() @@ -69,25 +70,6 @@ public boolean accept( File pathname ) } ); } - private static File[] surefireBooterJar() - throws IOException - { - return surefireDir().listFiles( new FileFilter() - { - public boolean accept( File pathname ) - { - try - { - return isSurefireBooter( pathname ); - } - catch ( IOException e ) - { - return false; - } - } - } ); - } - /** * See BooterSerializer#serialize(). */ @@ -111,9 +93,9 @@ private static boolean isSurefireBooter( File pathname ) private static String manifestClassPath( Class clazz ) throws IOException { - File[] booters = surefireBooterJar(); - assertThat( booters, is( arrayWithSize( 1 ) ) ); - File booter = booters[0]; + File booter = new File( System.getProperty( "surefire.real.class.path" ) ); + assertThat( booter ).exists(); + assertThat( booter ).isFile(); JarFile jarFile = new JarFile( booter ); try { @@ -161,10 +143,6 @@ public void shouldBeJarWithForking() assertThat( classPath, not( containsString( "/target/classes" ) ) ); assertThat( classPath, containsString( "/target/" + ARTIFACT_FILE_NAME ) ); - File surefireDir = new File( "target/surefire" ).getCanonicalFile(); - System.out.println( "SUREFIRE DIR:" ); - System.out.println( surefireDir ); - File[] descriptors = surefireProviderProperties(); assertThat( descriptors ).hasSize( 1 ); assertThat( descriptors ).doesNotContainNull(); @@ -187,7 +165,7 @@ public void jarShouldExistWhenNotForking() { assumeThat( System.getProperty( "forkMode" ), is( "never" ) ); - assertThat( surefireDir() ).doesNotExist(); + assertThat( surefireDir() ).isNull(); assertThat( new File( "target/" + ARTIFACT_FILE_NAME ).getCanonicalFile() ).isFile(); } diff --git a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/src/test/java/jiras/surefire855/war/FooIT.java b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/src/test/java/jiras/surefire855/war/FooIT.java index f15bd15a5c..95eb8c3f54 100644 --- a/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/src/test/java/jiras/surefire855/war/FooIT.java +++ b/surefire-integration-tests/src/test/resources/surefire-855-failsafe-use-war/src/test/java/jiras/surefire855/war/FooIT.java @@ -44,7 +44,8 @@ public final class FooIT private static File surefireDir() throws IOException { - return new File( "target/surefire" ).getCanonicalFile(); + String bootPath = System.getProperty( "surefire.real.class.path" ); + return bootPath == null ? null : new File( bootPath ).getParentFile(); } private static File[] surefireProviderProperties() @@ -66,25 +67,6 @@ public boolean accept( File pathname ) } ); } - private static File[] surefireBooterJar() - throws IOException - { - return surefireDir().listFiles( new FileFilter() - { - public boolean accept( File pathname ) - { - try - { - return isSurefireBooter( pathname ); - } - catch ( IOException e ) - { - return false; - } - } - } ); - } - /** * See BooterSerializer#serialize(). */ @@ -108,9 +90,9 @@ private static boolean isSurefireBooter( File pathname ) private static String manifestClassPath( Class clazz ) throws IOException { - File[] booters = surefireBooterJar(); - assertThat( booters, is( arrayWithSize( 1 ) ) ); - File booter = booters[0]; + File booter = new File( System.getProperty( "surefire.real.class.path" ) ); + assertThat( booter ).exists(); + assertThat( booter ).isFile(); JarFile jarFile = new JarFile( booter ); try { @@ -155,10 +137,6 @@ public void test() assertThat( classPath, containsString( "/target/classes" ) ); - File surefireDir = new File( "target/surefire" ).getCanonicalFile(); - System.out.println( "SUREFIRE DIR:" ); - System.out.println( surefireDir ); - File[] descriptors = surefireProviderProperties(); assertThat( descriptors ).hasSize( 1 ); assertThat( descriptors ).doesNotContainNull(); From 3d42cf9a6d3c3fca786e3586eb3d76a80269959a Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 6 Aug 2017 13:16:31 +0200 Subject: [PATCH 108/194] Investigating ASF Jenkins fails https://builds.apache.org/job/maven-surefire-windows/1310/ --- .../java/org/apache/maven/surefire/its/ConsoleOutputIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java index e01d798e5a..12fbb49df8 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java @@ -47,7 +47,7 @@ public void properNewlinesAndEncodingWithDefaultEncodings() public void properNewlinesAndEncodingWithDifferentEncoding() { final OutputValidator outputValidator = - unpack( "/consoleOutput" ).forkOnce().argLine( "-Dfile.encoding=UTF-16" ).executeTest(); + unpack( "/consoleOutput" ).forkOnce()/*.argLine( "-Dfile.encoding=UTF-16" )*/.executeTest(); validate( outputValidator, true ); } From 3abe25f433257d97687f3dfb6ebd63dd61b0f3de Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 6 Aug 2017 14:00:15 +0200 Subject: [PATCH 109/194] Investigating ASF Jenkins fails https://builds.apache.org/job/maven-surefire-windows/1310/ --- .../maven/surefire/booter/PpidChecker.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java index f7eb1dfa5d..1292f17509 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.Charset; import java.util.Queue; import java.util.Scanner; import java.util.StringTokenizer; @@ -128,7 +129,7 @@ else if ( IS_OS_UNIX ) // http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/9b8c96f96a0f/test/java/lang/ProcessBuilder/Basic.java#L167 ProcessInfo unix() { - ProcessInfoConsumer reader = new ProcessInfoConsumer() + ProcessInfoConsumer reader = new ProcessInfoConsumer( Charset.defaultCharset().name() ) { @Override ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo ) @@ -154,7 +155,7 @@ ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo ) ProcessInfo windows() { - ProcessInfoConsumer reader = new ProcessInfoConsumer() + ProcessInfoConsumer reader = new ProcessInfoConsumer( Charset.defaultCharset().name() ) // Windows-1252 { private boolean hasHeader; @@ -248,6 +249,13 @@ private static void checkValid( Scanner scanner ) */ private abstract class ProcessInfoConsumer { + private final String charset; + + ProcessInfoConsumer( String charset ) + { + this.charset = charset; + } + abstract ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo ); ProcessInfo execute( String... command ) @@ -260,7 +268,7 @@ ProcessInfo execute( String... command ) { process = processBuilder.start(); destroyableCommands.add( process ); - Scanner scanner = new Scanner( process.getInputStream() ); + Scanner scanner = new Scanner( process.getInputStream(), charset ); while ( scanner.hasNextLine() ) { String line = scanner.nextLine().trim(); @@ -272,10 +280,12 @@ ProcessInfo execute( String... command ) } catch ( IOException e ) { + DumpErrorSingleton.getSingleton().dumpException( e ); return ERR_PROCESS_INFO; } catch ( InterruptedException e ) { + DumpErrorSingleton.getSingleton().dumpException( e ); return ERR_PROCESS_INFO; } finally From 962640171da0bab929d20a7aadf3d152134c6a39 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 6 Aug 2017 16:20:04 +0200 Subject: [PATCH 110/194] Investigating ASF Jenkins fails https://builds.apache.org/job/maven-surefire-windows/1310/ --- .../main/java/org/apache/maven/surefire/booter/PpidChecker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java index 1292f17509..7c2758455b 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java @@ -155,7 +155,7 @@ ProcessInfo consumeLine( String line, ProcessInfo previousProcessInfo ) ProcessInfo windows() { - ProcessInfoConsumer reader = new ProcessInfoConsumer( Charset.defaultCharset().name() ) // Windows-1252 + ProcessInfoConsumer reader = new ProcessInfoConsumer( "US-ASCII" ) { private boolean hasHeader; From 2b6926abdbc7f8ea3ad86a2364e6c26bc51775fb Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 6 Aug 2017 17:33:39 +0200 Subject: [PATCH 111/194] Investigating ASF Jenkins fails https://builds.apache.org/job/maven-surefire-windows/1310/ --- .../java/org/apache/maven/surefire/its/ConsoleOutputIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java index 12fbb49df8..e01d798e5a 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java @@ -47,7 +47,7 @@ public void properNewlinesAndEncodingWithDefaultEncodings() public void properNewlinesAndEncodingWithDifferentEncoding() { final OutputValidator outputValidator = - unpack( "/consoleOutput" ).forkOnce()/*.argLine( "-Dfile.encoding=UTF-16" )*/.executeTest(); + unpack( "/consoleOutput" ).forkOnce().argLine( "-Dfile.encoding=UTF-16" ).executeTest(); validate( outputValidator, true ); } From 1a65d61dd18147e905bbba1911534a07bfa03eed Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 7 Aug 2017 12:23:43 +0200 Subject: [PATCH 112/194] [SUREFIRE-1404] Package of ServiceLoader was changed in version 2.20 and documentation uses package providerapi --- .../plugin/surefire/booterclient/ProviderDetector.java | 2 +- .../maven/surefire/{spi => providerapi}/ServiceLoader.java | 7 +++++-- .../test/java/org/apache/maven/surefire/spi/SPITest.java | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) rename maven-surefire-common/src/main/java/org/apache/maven/surefire/{spi => providerapi}/ServiceLoader.java (94%) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ProviderDetector.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ProviderDetector.java index 3460e3ec50..fce3d4642b 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ProviderDetector.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ProviderDetector.java @@ -19,7 +19,7 @@ * under the License. */ -import org.apache.maven.surefire.spi.ServiceLoader; +import org.apache.maven.surefire.providerapi.ServiceLoader; import javax.annotation.Nonnull; import java.io.IOException; 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/providerapi/ServiceLoader.java similarity index 94% rename from maven-surefire-common/src/main/java/org/apache/maven/surefire/spi/ServiceLoader.java rename to maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ServiceLoader.java index 1deae7ca80..8753ff16cd 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/providerapi/ServiceLoader.java @@ -1,4 +1,4 @@ -package org.apache.maven.surefire.spi; +package org.apache.maven.surefire.providerapi; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -36,7 +36,10 @@ import static org.apache.maven.surefire.util.ReflectionUtils.getConstructor; /** - * SPI loader for Java 1.5. + * SPI loader for Surefire/Failsafe should use {@link Thread#getContextClassLoader() current ClassLoader}. + *
    + * The {@link java.util.ServiceLoader} embedded in JVM uses + * {@link ClassLoader#getSystemClassLoader() System ClassLoader} and cannot be used in Surefire/Failsafe. * * @since 2.20 */ 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 2d8cc9f30d..2d00799e09 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 @@ -20,6 +20,7 @@ */ import org.apache.maven.plugin.surefire.booterclient.ProviderDetector; +import org.apache.maven.surefire.providerapi.ServiceLoader; import org.junit.Test; import java.io.IOException; From 578ada73b724151f0cbce3b6ae39e55d242ef430 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 7 Aug 2017 12:43:17 +0200 Subject: [PATCH 113/194] [SUREFIRE-1403] [Jigsaw] [Java 9] add "--add-modules ALL-SYSTEM" to forked CLI argument --- README.md | 18 +- maven-failsafe-plugin/pom.xml | 38 +- .../plugin/failsafe/IntegrationTestMojo.java | 32 +- .../maven/plugin/failsafe/VerifyMojo.java | 7 +- .../util/FailsafeSummaryXmlUtils.java | 112 ++++-- .../maven/plugin/failsafe/util/JAXB.java | 104 ------ .../failsafe/MarshallerUnmarshallerTest.java | 46 +-- .../maven/plugin/failsafe/RunResultTest.java | 17 +- .../plugin/failsafe/failsafe-summary.xml | 2 +- maven-surefire-common/pom.xml | 2 +- .../plugin/surefire/AbstractSurefireMojo.java | 72 +++- .../maven/plugin/surefire/JdkAttributes.java | 48 +++ .../booterclient/ForkConfiguration.java | 72 ++-- .../surefire/report/StatelessXmlReporter.java | 4 +- ...DeserializerProviderConfigurationTest.java | 2 +- ...rDeserializerStartupConfigurationTest.java | 2 +- .../booterclient/ForkConfigurationTest.java | 65 ++-- maven-surefire-plugin/pom.xml | 27 +- .../src/site/markdown/java9.md | 92 +++++ .../site/resources/xsd/failsafe-summary.xjb | 31 -- maven-surefire-plugin/src/site/site.xml | 1 + pom.xml | 32 +- surefire-api/pom.xml | 2 +- surefire-booter/pom.xml | 8 +- .../maven/surefire/booter/SystemUtils.java | 143 +++++++- .../surefire/booter/SystemUtilsTest.java | 330 ++++++++++++++---- .../src/test/resources/jdk/bin/java | 0 .../src/test/resources/jdk/jre/bin/java | 0 .../src/test/resources/jdk8-IBM/release | 1 + .../src/test/resources/jdk8-oracle/release | 1 + .../src/test/resources/jdk9-oracle/release | 1 + surefire-integration-tests/pom.xml | 4 +- .../maven/surefire/its/AbstractJigsawIT.java | 113 ++++++ .../maven/surefire/its/Java9FullApiIT.java | 95 +++++ .../its/jiras/Surefire1265Java9IT.java | 17 +- .../src/test/resources/java9-full-api/pom.xml | 122 +++++++ .../java9-full-api/src/test/java/J9IT.java | 39 +++ .../java9-full-api/src/test/java/J9Test.java | 39 +++ surefire-setup-integration-tests/pom.xml | 28 +- .../src/main/resources/toolchains.xml | 35 ++ 40 files changed, 1355 insertions(+), 449 deletions(-) delete mode 100644 maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/JAXB.java create mode 100644 maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/JdkAttributes.java create mode 100644 maven-surefire-plugin/src/site/markdown/java9.md delete mode 100644 maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb create mode 100644 surefire-booter/src/test/resources/jdk/bin/java create mode 100644 surefire-booter/src/test/resources/jdk/jre/bin/java create mode 100644 surefire-booter/src/test/resources/jdk8-IBM/release create mode 100644 surefire-booter/src/test/resources/jdk8-oracle/release create mode 100644 surefire-booter/src/test/resources/jdk9-oracle/release create mode 100644 surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java create mode 100644 surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Java9FullApiIT.java create mode 100644 surefire-integration-tests/src/test/resources/java9-full-api/pom.xml create mode 100644 surefire-integration-tests/src/test/resources/java9-full-api/src/test/java/J9IT.java create mode 100644 surefire-integration-tests/src/test/resources/java9-full-api/src/test/java/J9Test.java create mode 100644 surefire-setup-integration-tests/src/main/resources/toolchains.xml diff --git a/README.md b/README.md index e7b4b07530..20fef40b7b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [JIRA Change Log] -[![tag](http://img.shields.io/github/tag/apache/maven-surefire.svg)](https://github.com/apache/maven-surefire/releases) +[![tag](http://img.shields.io/github/tag/apache/maven-surefire.svg)](https://github.com/apache/maven-surefire/releases/tag/surefire-2.20) Usage of [maven-surefire-plugin], [maven-failsafe-plugin], [maven-surefire-report-plugin]. @@ -20,16 +20,20 @@ Usage of [maven-surefire-plugin], [maven-failsafe-plugin], [maven-surefire-repor [![dependencies](https://www.versioneye.com/java/org.apache.maven.plugins:maven-surefire-plugin/badge.svg?style=plastic)](https://builds.apache.org/job/maven-surefire/depgraph-view/) Maven 2.2.1 Plugin API -[![license](http://img.shields.io/:license-apache-red.svg?style=plastic)](http://www.apache.org/licenses/LICENSE-2.0.html) [![coverage](https://img.shields.io/jenkins/c/https/builds.apache.org/maven-surefire.svg?style=plastic)](https://builds.apache.org/job/maven-surefire/jacoco/) [![tests](https://img.shields.io/jenkins/t/https/builds.apache.org/maven-surefire.svg?style=plastic)](https://builds.apache.org/job/maven-surefire/lastBuild/testReport/) [![Build Status](https://builds.apache.org/job/maven-surefire/badge/icon?style=plastic)](https://builds.apache.org/job/maven-surefire) [![Build Status](https://builds.apache.org/job/maven-surefire-windows/badge/icon?style=plastic)](https://builds.apache.org/job/maven-surefire-windows) [![Build Status](https://builds.apache.org/job/maven-surefire-mvn-2.2.1/badge/icon?style=plastic)](https://builds.apache.org/job/maven-surefire-mvn-2.2.1) +[![license](http://img.shields.io/:license-apache-red.svg?style=plastic)](http://www.apache.org/licenses/LICENSE-2.0.html) [![coverage](https://img.shields.io/jenkins/c/https/builds.apache.org/maven-surefire.svg?style=plastic)](https://builds.apache.org/job/maven-surefire/jacoco/) [![tests](https://img.shields.io/jenkins/t/https/builds.apache.org/maven-surefire.svg?style=plastic)](https://builds.apache.org/job/maven-surefire/lastBuild/testReport/) [![Build Status](https://builds.apache.org/job/maven-surefire/badge/icon?style=plastic)](https://builds.apache.org/job/maven-surefire) [![Build Status](https://builds.apache.org/job/maven-surefire-windows/badge/icon?style=plastic)](https://builds.apache.org/job/maven-surefire-windows) # Development Information -Surefire needs to use Maven 3.1.0+ and JDK 1.6+ to be built. -But in order to run IT tests, you can do: -* In order to run tests for a release check during the vote the following memory requirements are needed: - $ export MAVEN_OPTS="-Xmx768m -XX:MaxPermSize=1g -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true" -* $ mvn install site site:stage -P reporting,run-its +In order to build Surefire project use **Maven 3.1.0+** and **JDK 1.8**. +But in order to run IT tests, you can do: + +* In order to run tests for a release check during the vote the following memory requirements are needed: + **(on Linux/Unix)** *export MAVEN_OPTS="-Xmx768m -XX:MaxMetaspaceSize=864m -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true"* + **(on Windows)** *set MAVEN_OPTS="-Xmx768m -XX:MaxMetaspaceSize=864m -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true"* +* In order to run the build with **JDK 9** **on Windows** (**on Linux/Unix modify system property jdk.home**): + *mvn install site site:stage -P reporting,run-its "-Djdk.home=e:\Program Files\Java\jdk9\"* + Deploying web site ------------------ diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index ec48929ec6..f4b2c09a5a 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -65,39 +65,6 @@ - - org.apache.cxf - cxf-xjc-plugin - 3.1.0 - - - generate-failsafe-summary - - xsdtojava - - - ${project.build.directory}/generated-sources/jaxb - - - - ../maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xsd - ../maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb - org.apache.maven.plugin.failsafe.xmlsummary - - -encoding - ${project.build.sourceEncoding} - - - - - - - org.apache.maven.plugins maven-plugin-plugin @@ -211,6 +178,7 @@ org.apache.maven.shared:maven-shared-utils + commons-io:commons-io @@ -218,6 +186,10 @@ org.apache.maven.shared org.apache.maven.surefire.shade.org.apache.maven.shared + + org.apache.commons.io + org.apache.maven.surefire.shade.org.apache.commons.io + 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 28b2859c7b..723a4a1e06 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 @@ -27,10 +27,8 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; -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; @@ -40,7 +38,6 @@ import java.util.Locale; import static org.apache.maven.plugin.failsafe.util.FailsafeSummaryXmlUtils.writeSummary; -import static org.apache.maven.shared.utils.ReaderFactory.FILE_ENCODING; /** * Run integration tests using Surefire. @@ -258,6 +255,9 @@ public class IntegrationTestMojo /** * The character encoding scheme to be applied. + * Deprecated since 2.20.1 and used encoding UTF-8 in failsafe-summary.xml. + * + * @deprecated since of 2.20.1 */ @Parameter( property = "encoding", defaultValue = "${project.reporting.outputEncoding}" ) private String encoding; @@ -390,13 +390,9 @@ protected void handleSummary( RunResult summary, Exception firstForkException ) try { Object token = getPluginContext().get( FAILSAFE_IN_PROGRESS_CONTEXT_KEY ); - writeSummary( summary, summaryFile, token != null, toCharset( getEncodingOrDefault() ) ); - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + writeSummary( summary, summaryFile, token != null ); } - catch ( JAXBException e ) + catch ( Exception e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -404,24 +400,6 @@ protected void handleSummary( RunResult summary, Exception firstForkException ) getPluginContext().put( FAILSAFE_IN_PROGRESS_CONTEXT_KEY, FAILSAFE_IN_PROGRESS_CONTEXT_KEY ); } - 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}." - ); - return FILE_ENCODING; - } - else - { - return encoding; - } - } - private boolean isJarArtifact( File artifactFile ) { return artifactFile != null && artifactFile.isFile() && artifactFile.getName().toLowerCase().endsWith( ".jar" ); 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 04cc72c5f9..3075a6fbb6 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 @@ -34,7 +34,6 @@ 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; @@ -145,7 +144,9 @@ public class VerifyMojo /** * The character encoding scheme to be applied. + * Deprecated since 2.20.1 and used encoding UTF-8 in failsafe-summary.xml. * + * @deprecated since of 2.20.1 * @noinspection UnusedDeclaration */ @Parameter( property = "encoding", defaultValue = "${project.reporting.outputEncoding}" ) @@ -184,7 +185,7 @@ public void execute() } } } - catch ( JAXBException e ) + catch ( Exception e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -208,7 +209,7 @@ private PluginConsoleLogger getConsoleLogger() return consoleLogger; } - private RunResult readSummary( File summaryFile ) throws JAXBException + private RunResult readSummary( File summaryFile ) throws Exception { return FailsafeSummaryXmlUtils.toRunResult( summaryFile ); } diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java index 1f3f64df5d..d06da13b38 100644 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java +++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/FailsafeSummaryXmlUtils.java @@ -19,16 +19,26 @@ * under the License. */ -import org.apache.maven.plugin.failsafe.xmlsummary.ErrorType; -import org.apache.maven.plugin.failsafe.xmlsummary.FailsafeSummary; +import org.apache.commons.io.IOUtils; import org.apache.maven.surefire.suite.RunResult; +import org.w3c.dom.Node; +import org.xml.sax.InputSource; -import javax.xml.bind.JAXBException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathFactory; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; -import java.nio.charset.Charset; +import java.util.Locale; +import static java.lang.Boolean.parseBoolean; +import static java.lang.Integer.parseInt; +import static org.apache.commons.lang3.StringEscapeUtils.escapeXml10; +import static org.apache.commons.lang3.StringEscapeUtils.unescapeXml; import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8; +import static org.apache.maven.surefire.util.internal.StringUtils.isBlank; /** * @author Tibor Digana (tibor17) @@ -36,46 +46,86 @@ */ public final class FailsafeSummaryXmlUtils { + private static final String FAILSAFE_SUMMARY_XML_SCHEMA_LOCATION = + "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/failsafe-summary.xsd"; + + private static final String FAILSAFE_SUMMARY_XML_NIL_ATTR = + " xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""; + + private static final String FAILSAFE_SUMMARY_XML_TEMPLATE = + "\n" + + "\n" + + " %d\n" + + " %d\n" + + " %d\n" + + " %d\n" + + " %s\n" + + ""; + private FailsafeSummaryXmlUtils() { throw new IllegalStateException( "No instantiable constructor." ); } - public static RunResult toRunResult( File failsafeSummaryXml ) throws JAXBException + public static RunResult toRunResult( File failsafeSummaryXml ) throws Exception { - FailsafeSummary failsafeSummary = JAXB.unmarshal( failsafeSummaryXml, FailsafeSummary.class ); + XPathFactory xpathFactory = XPathFactory.newInstance(); + XPath xpath = xpathFactory.newXPath(); - return new RunResult( failsafeSummary.getCompleted(), failsafeSummary.getErrors(), - failsafeSummary.getFailures(), failsafeSummary.getSkipped(), - failsafeSummary.getFailureMessage(), failsafeSummary.isTimeout() - ); + FileInputStream is = new FileInputStream( failsafeSummaryXml ); + + try + { + Node root = (Node) xpath.evaluate( "/", new InputSource( is ), XPathConstants.NODE ); + + String completed = xpath.evaluate( "/failsafe-summary/completed", root ); + String errors = xpath.evaluate( "/failsafe-summary/errors", root ); + String failures = xpath.evaluate( "/failsafe-summary/failures", root ); + String skipped = xpath.evaluate( "/failsafe-summary/skipped", root ); + String failureMessage = xpath.evaluate( "/failsafe-summary/failureMessage", root ); + String timeout = xpath.evaluate( "/failsafe-summary/@timeout", root ); + + return new RunResult( parseInt( completed ), parseInt( errors ), parseInt( failures ), parseInt( skipped ), + isBlank( failureMessage ) ? null : unescapeXml( failureMessage ), + parseBoolean( timeout ) + ); + } + finally + { + is.close(); + } } public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml ) - throws JAXBException, IOException + throws IOException { - fromRunResultToFile( fromRunResult, toFailsafeSummaryXml, UTF_8 ); - } + String failure = fromRunResult.getFailure(); + String xml = String.format( Locale.ROOT, FAILSAFE_SUMMARY_XML_TEMPLATE, + fromRunResult.getFailsafeCode(), + String.valueOf( fromRunResult.isTimeout() ), + fromRunResult.getCompletedCount(), + fromRunResult.getErrors(), + fromRunResult.getFailures(), + fromRunResult.getSkipped(), + isBlank( failure ) ? FAILSAFE_SUMMARY_XML_NIL_ATTR : "", + isBlank( failure ) ? "" : escapeXml10( failure ) + ); - 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() ); - Integer errorCode = fromRunResult.getFailsafeCode(); - summary.setResult( errorCode == null ? null : ErrorType.fromValue( String.valueOf( errorCode ) ) ); - - JAXB.marshal( summary, encoding, toFailsafeSummaryXml ); + FileOutputStream os = new FileOutputStream( toFailsafeSummaryXml ); + try + { + IOUtils.write( xml, os, UTF_8 ); + } + finally + { + os.close(); + } } - public static void writeSummary( RunResult mergedSummary, File mergedSummaryFile, boolean inProgress, - Charset encoding ) - throws IOException, JAXBException + public static void writeSummary( RunResult mergedSummary, File mergedSummaryFile, boolean inProgress ) + throws Exception { if ( !mergedSummaryFile.getParentFile().isDirectory() ) { @@ -89,6 +139,6 @@ public static void writeSummary( RunResult mergedSummary, File mergedSummaryFile mergedSummary = mergedSummary.aggregate( runResult ); } - fromRunResultToFile( mergedSummary, mergedSummaryFile, encoding ); + fromRunResultToFile( mergedSummary, mergedSummaryFile ); } } diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/JAXB.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/JAXB.java deleted file mode 100644 index ac51292f38..0000000000 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/util/JAXB.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.apache.maven.plugin.failsafe.util; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import javax.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.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(); - } - - @SuppressWarnings( "unchecked" ) - public static void marshal( T bean, Charset encoding, File destination ) throws JAXBException, IOException - { - Class type = (Class) bean.getClass(); - JAXBElement rootElement = buildJaxbElement( bean, type ); - 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 ); - 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() ); - } - } -} 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 8d5d32f139..96708a8a59 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 @@ -19,14 +19,12 @@ * under the License. */ -import org.apache.maven.plugin.failsafe.util.JAXB; -import org.apache.maven.plugin.failsafe.xmlsummary.FailsafeSummary; +import org.apache.maven.plugin.failsafe.util.FailsafeSummaryXmlUtils; +import org.apache.maven.surefire.suite.RunResult; import org.junit.Test; import java.io.File; -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 @@ -35,9 +33,9 @@ public class MarshallerUnmarshallerTest 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 ); + RunResult summary = FailsafeSummaryXmlUtils.toRunResult( xml ); - assertThat( summary.getCompleted() ) + assertThat( summary.getCompletedCount() ) .isEqualTo( 7 ); assertThat( summary.getErrors() ) @@ -49,14 +47,14 @@ public void shouldUnmarshallExistingXmlFile() throws Exception assertThat( summary.getSkipped() ) .isEqualTo( 3 ); - assertThat( summary.getFailureMessage() ) + assertThat( summary.getFailure() ) .contains( "There was an error in the forked processtest " + "subsystem#no method RuntimeException Hi There!" ); - assertThat( summary.getFailureMessage() ) + assertThat( summary.getFailure() ) .contains( "There was an error in the forked processtest " - + "subsystem#no method RuntimeException Hi There!" + + "subsystem#no method RuntimeException Hi There! $&>>" + "\n\tat org.apache.maven.plugin.surefire.booterclient.ForkStarter" + ".awaitResultsDone(ForkStarter.java:489)" ); @@ -65,23 +63,17 @@ public void shouldUnmarshallExistingXmlFile() throws Exception @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)" - ); + RunResult expected = + new RunResult( 7, 1, 2, 3, 2, + "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)", true ); File xml = File.createTempFile( "failsafe-summary", ".xml" ); - JAXB.marshal( expected, UTF_8, xml ); + FailsafeSummaryXmlUtils.writeSummary( expected, xml, false ); - FailsafeSummary actual = JAXB.unmarshal( xml, FailsafeSummary.class ); + RunResult actual = FailsafeSummaryXmlUtils.toRunResult( xml ); assertThat( actual.getFailures() ) .isEqualTo( expected.getFailures() ); @@ -89,8 +81,8 @@ public void shouldMarshallAndUnmarshallSameXml() throws Exception assertThat( actual.isTimeout() ) .isEqualTo( expected.isTimeout() ); - assertThat( actual.getCompleted() ) - .isEqualTo( expected.getCompleted() ); + assertThat( actual.getCompletedCount() ) + .isEqualTo( expected.getCompletedCount() ); assertThat( actual.getErrors() ) .isEqualTo( expected.getErrors() ); @@ -101,7 +93,7 @@ public void shouldMarshallAndUnmarshallSameXml() throws Exception assertThat( actual.getSkipped() ) .isEqualTo( expected.getSkipped() ); - assertThat( actual.getFailureMessage() ) - .isEqualTo( expected.getFailureMessage() ); + assertThat( actual.getFailure() ) + .isEqualTo( expected.getFailure() ); } } 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 f7b62b64ac..5e75ebfa33 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 @@ -23,12 +23,9 @@ 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; /** @@ -61,35 +58,35 @@ public void testAggregatedValues() @Test public void testSerialization() - throws IOException, JAXBException + throws Exception { writeReadCheck( getSimpleAggregate() ); } @Test public void testFailures() - throws IOException, JAXBException + throws Exception { writeReadCheck( new RunResult( 0, 1, 2, 3, "stacktraceHere", false ) ); } @Test public void testSkipped() - throws IOException, JAXBException + throws Exception { writeReadCheck( new RunResult( 3, 2, 1, 0, null, true ) ); } @Test public void testAppendSerialization() - throws IOException, JAXBException + throws Exception { 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 ); + FailsafeSummaryXmlUtils.writeSummary( simpleAggregate, summary, false ); + FailsafeSummaryXmlUtils.writeSummary( additional, summary, true ); RunResult actual = FailsafeSummaryXmlUtils.toRunResult( summary ); //noinspection ResultOfMethodCallIgnored summary.delete(); @@ -132,7 +129,7 @@ public void shouldAcceptAliasCharset() } private void writeReadCheck( RunResult expected ) - throws IOException, JAXBException + throws Exception { File tmp = File.createTempFile( "test", "xml" ); FailsafeSummaryXmlUtils.fromRunResultToFile( expected, tmp ); 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 index b1fe1f9f21..2b15bca782 100644 --- 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 @@ -1 +1 @@ - 7 1 2 3 \ No newline at end of file + 7 1 2 3 \ No newline at end of file diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index ae050c75b1..121609b9da 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -160,7 +160,7 @@ maven-surefire-plugin - ${test.jre}/bin/java + ${jdk.home}/bin/java true **/JUnit4SuiteTest.java 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 f2e5bfbc41..047f7a44ba 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 @@ -77,6 +77,7 @@ import org.apache.maven.surefire.util.DefaultScanResult; import org.apache.maven.surefire.util.RunOrder; import org.apache.maven.surefire.util.SurefireReflectionException; +import org.apache.maven.toolchain.DefaultToolchain; import org.apache.maven.toolchain.Toolchain; import org.apache.maven.toolchain.ToolchainManager; @@ -100,13 +101,21 @@ import java.util.concurrent.ConcurrentHashMap; import static java.lang.Thread.currentThread; +import static java.util.Collections.singletonMap; import static org.apache.commons.lang3.JavaVersion.JAVA_1_7; +import static org.apache.commons.lang3.JavaVersion.JAVA_9; +import static org.apache.commons.lang3.JavaVersion.JAVA_RECENT; import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS; import static org.apache.commons.lang3.SystemUtils.isJavaVersionAtLeast; import static org.apache.maven.shared.utils.StringUtils.capitalizeFirstLetter; import static org.apache.maven.shared.utils.StringUtils.isEmpty; import static org.apache.maven.shared.utils.StringUtils.isNotBlank; +import static org.apache.maven.shared.utils.StringUtils.isNotEmpty; import static org.apache.maven.shared.utils.StringUtils.split; +import static org.apache.maven.surefire.booter.SystemUtils.endsWithJavaPath; +import static org.apache.maven.surefire.booter.SystemUtils.isJava9AtLeast; +import static org.apache.maven.surefire.booter.SystemUtils.toJdkHomeFromJvmExec; +import static org.apache.maven.surefire.booter.SystemUtils.toJdkVersionFromReleaseFile; import static org.apache.maven.surefire.suite.RunResult.failure; import static org.apache.maven.surefire.suite.RunResult.noTestsRun; import static org.apache.maven.surefire.util.ReflectionUtils.invokeGetter; @@ -123,6 +132,10 @@ public abstract class AbstractSurefireMojo extends AbstractMojo implements SurefireExecutionParameters { + private static final Map JAVA_9_MATCHER_OLD_NOTATION = singletonMap( "version", "[1.9,)" ); + + private static final Map JAVA_9_MATCHER = singletonMap( "version", "[9,)" ); + private static final Platform PLATFORM = new Platform(); private static final File SYSTEM_TMP_DIR = new File( System.getProperty( "java.io.tmpdir" ) ); @@ -895,7 +908,7 @@ boolean verifyParameters() getConsoleLogger().info( "Toolchain in maven-" + getPluginName() + "-plugin: " + toolchain ); if ( jvmToUse != null ) { - getConsoleLogger().warning( "Toolchains are ignored, 'executable' parameter is set to " + jvmToUse ); + getConsoleLogger().warning( "Toolchains are ignored, 'jvm' parameter is set to " + jvmToUse ); } } @@ -1947,7 +1960,7 @@ private InPluginVMSurefireStarter createInprocessStarter( ProviderInfo provider, startupReportConfiguration, consoleLogger ); } - protected ForkConfiguration getForkConfiguration() + private ForkConfiguration getForkConfiguration() throws MojoFailureException { File tmpDir = getSurefireTempDir(); @@ -2038,24 +2051,59 @@ private String getEffectiveDebugForkedProcess() return debugForkedProcess; } - private String getEffectiveJvm() + private JdkAttributes getEffectiveJvm() throws MojoFailureException { - String jvmToUse = getJvm(); - if ( toolchain != null && jvmToUse == null ) + if ( isNotEmpty( jvm ) ) { - jvmToUse = toolchain.findTool( "java" ); //NOI18N + File pathToJava = new File( jvm ).getAbsoluteFile(); + if ( !endsWithJavaPath( pathToJava.getPath() ) ) + { + throw new MojoFailureException( "Given path does not end with java executor \"" + + pathToJava.getPath() + "\"." ); + } + + if ( !( pathToJava.isFile() + || "java".equals( pathToJava.getName() ) && pathToJava.getParentFile().isDirectory() ) ) + { + throw new MojoFailureException( "Given path to java executor does not exist \"" + + pathToJava.getPath() + "\"." ); + } + + File jdkHome = toJdkHomeFromJvmExec( pathToJava.getPath() ); + Double version = jdkHome == null ? null : toJdkVersionFromReleaseFile( jdkHome ); + boolean javaVersion9 = version == null ? isJava9AtLeast( pathToJava.getPath() ) : isJava9AtLeast( version ); + return new JdkAttributes( pathToJava.getPath(), javaVersion9 ); } - if ( isEmpty( jvmToUse ) ) + if ( toolchain != null ) { - // 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"; - getConsoleLogger().debug( "Using JVM: " + jvmToUse ); + String jvmToUse = toolchain.findTool( "java" ); + if ( isNotEmpty( jvmToUse ) ) + { + boolean javaVersion9 = false; + + if ( toolchain instanceof DefaultToolchain ) + { + DefaultToolchain defaultToolchain = (DefaultToolchain) toolchain; + javaVersion9 = defaultToolchain.matchesRequirements( JAVA_9_MATCHER ) + || defaultToolchain.matchesRequirements( JAVA_9_MATCHER_OLD_NOTATION ); + } + + if ( !javaVersion9 ) + { + javaVersion9 = isJava9AtLeast( jvmToUse ); + } + + return new JdkAttributes( jvmToUse, javaVersion9 ); + } } - return jvmToUse; - } + // use the same JVM as the one used to run Maven (the "java.home" one) + String jvmToUse = System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java"; + getConsoleLogger().debug( "Using JVM: " + jvmToUse + " with Java version " + JAVA_RECENT.toString() ); + return new JdkAttributes( jvmToUse, isJavaVersionAtLeast( JAVA_9 ) ); + } private Artifact getSurefireBooterArtifact() { diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/JdkAttributes.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/JdkAttributes.java new file mode 100644 index 0000000000..65b12548a7 --- /dev/null +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/JdkAttributes.java @@ -0,0 +1,48 @@ +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 static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull; + +/** + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public final class JdkAttributes +{ + private final String jvmExecutable; + private final boolean java9AtLeast; + + public JdkAttributes( String jvmExecutable, boolean java9AtLeast ) + { + this.jvmExecutable = requireNonNull( jvmExecutable, "null path to java executable" ); + this.java9AtLeast = java9AtLeast; + } + + public String getJvmExecutable() + { + return jvmExecutable; + } + + public boolean isJava9AtLeast() + { + return java9AtLeast; + } +} 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 1c7626ec52..b3b925188d 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 @@ -20,9 +20,9 @@ */ import org.apache.maven.plugin.surefire.AbstractSurefireMojo; +import org.apache.maven.plugin.surefire.JdkAttributes; 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; @@ -42,6 +42,7 @@ import java.util.jar.Manifest; import static org.apache.maven.plugin.surefire.SurefireHelper.escapeToPlatformPath; +import static org.apache.maven.shared.utils.StringUtils.join; /** * Configuration for forking tests. @@ -66,7 +67,7 @@ public class ForkConfiguration private final Classpath bootClasspathConfiguration; - private final String jvmExecutable; + private final JdkAttributes jdk; private final Properties modelProperties; @@ -86,14 +87,14 @@ public class ForkConfiguration @SuppressWarnings( "checkstyle:parameternumber" ) public ForkConfiguration( Classpath bootClasspathConfiguration, File tmpDir, String debugLine, - String jvmExecutable, File workingDirectory, Properties modelProperties, String argLine, + JdkAttributes jdk, File workingDirectory, Properties modelProperties, String argLine, Map environmentVariables, boolean debugEnabled, int forkCount, boolean reuseForks, Platform pluginPlatform ) { this.bootClasspathConfiguration = bootClasspathConfiguration; this.tempDirectory = tmpDir; this.debugLine = debugLine; - this.jvmExecutable = jvmExecutable; + this.jdk = jdk; this.workingDirectory = workingDirectory; this.modelProperties = modelProperties; this.argLine = argLine; @@ -131,24 +132,25 @@ else if ( forkMode.equals( FORK_NEVER ) || forkMode.equals( FORK_ONCE ) } /** - * @param classPath cla the classpath arguments - * @param startupConfiguration The startup configuration + * @param classPath cli the classpath arguments + * @param config The startup configuration * @param threadNumber the thread number, to be the replacement in the argLine @return A commandline * @return CommandLine able to flush entire command going to be sent to forked JVM * @throws org.apache.maven.surefire.booter.SurefireBooterForkException * when unable to perform the fork */ - public OutputStreamFlushableCommandline createCommandLine( List classPath, - StartupConfiguration startupConfiguration, + public OutputStreamFlushableCommandline createCommandLine( List classPath, StartupConfiguration config, int threadNumber ) - throws SurefireBooterForkException + throws SurefireBooterForkException { - return createCommandLine( classPath, - startupConfiguration.getClassLoaderConfiguration() - .isManifestOnlyJarRequestedAndUsable(), - startupConfiguration.isShadefire(), startupConfiguration.isProviderMainClass() - ? startupConfiguration.getActualClassName() - : ForkedBooter.class.getName(), threadNumber ); + boolean useJar = config.getClassLoaderConfiguration().isManifestOnlyJarRequestedAndUsable(); + + boolean shadefire = config.isShadefire(); + + String providerThatHasMainMethod = + config.isProviderMainClass() ? config.getActualClassName() : ForkedBooter.class.getName(); + + return createCommandLine( classPath, useJar, shadefire, providerThatHasMainMethod, threadNumber ); } OutputStreamFlushableCommandline createCommandLine( List classPath, boolean useJar, boolean shadefire, @@ -157,13 +159,26 @@ OutputStreamFlushableCommandline createCommandLine( List classPath, bool { OutputStreamFlushableCommandline cli = new OutputStreamFlushableCommandline(); - cli.setExecutable( jvmExecutable ); + cli.setExecutable( jdk.getJvmExecutable() ); + + String jvmArgLine = + replaceThreadNumberPlaceholder( stripNewLines( replacePropertyExpressions() ), threadNumber ); + + if ( jdk.isJava9AtLeast() && !jvmArgLine.contains( "--add-modules" ) ) + { + if ( jvmArgLine.isEmpty() ) + { + jvmArgLine = "--add-modules ALL-SYSTEM"; + } + else + { + jvmArgLine = "--add-modules ALL-SYSTEM " + jvmArgLine; + } + } - if ( argLine != null ) + if ( !jvmArgLine.isEmpty() ) { - cli.createArg().setLine( - replaceThreadNumberPlaceholder( stripNewLines( replacePropertyExpressions( argLine ) ), - threadNumber ) ); + cli.createArg().setLine( jvmArgLine ); } for ( Map.Entry entry : environmentVariables.entrySet() ) @@ -192,7 +207,7 @@ OutputStreamFlushableCommandline createCommandLine( List classPath, bool } else { - cli.addEnvironment( "CLASSPATH", StringUtils.join( classPath.iterator(), File.pathSeparator ) ); + cli.addEnvironment( "CLASSPATH", join( classPath.iterator(), File.pathSeparator ) ); final String forkedBooter = providerThatHasMainMethod != null ? providerThatHasMainMethod : ForkedBooter.class.getName(); @@ -235,11 +250,18 @@ private String replaceThreadNumberPlaceholder( String argLine, int threadNumber * * This allows other plugins to modify or set properties with the changes getting picked up by surefire. */ - private String replacePropertyExpressions( String argLine ) + private String replacePropertyExpressions() { if ( argLine == null ) { - return null; + return ""; + } + + String resolvedArgLine = argLine.trim(); + + if ( resolvedArgLine.isEmpty() ) + { + return ""; } for ( final String key : modelProperties.stringPropertyNames() ) @@ -247,11 +269,11 @@ private String replacePropertyExpressions( String argLine ) String field = "@{" + key + "}"; if ( argLine.contains( field ) ) { - argLine = argLine.replace( field, modelProperties.getProperty( key, "" ) ); + resolvedArgLine = resolvedArgLine.replace( field, modelProperties.getProperty( key, "" ) ); } } - return argLine; + return resolvedArgLine; } /** 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 60c6dfe37f..629778bd03 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 @@ -19,7 +19,6 @@ * under the License. */ -import org.apache.maven.shared.utils.io.IOUtil; import org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter; import org.apache.maven.shared.utils.xml.XMLWriter; import org.apache.maven.surefire.report.ReportEntry; @@ -42,6 +41,7 @@ import java.util.Map.Entry; import java.util.StringTokenizer; +import static org.apache.commons.io.IOUtils.closeQuietly; 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; @@ -239,7 +239,7 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat } finally { - IOUtil.close( fw ); + closeQuietly( fw ); } } diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java index 5d970d8410..26b8be7ab1 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java @@ -207,7 +207,7 @@ private ProviderConfiguration saveAndReload( ProviderConfiguration booterConfigu boolean readTestsFromInStream ) throws IOException { - final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration( null, null ); + final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration( (String) null ); PropertiesWrapper props = new PropertiesWrapper( new HashMap() ); BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration ); Object test; diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java index 0cb292caef..035add0f4a 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java @@ -119,7 +119,7 @@ private StartupConfiguration getReloadedStartupConfiguration() private StartupConfiguration saveAndReload( StartupConfiguration startupConfiguration ) throws IOException { - final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration( null, null ); + final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration( (String) null ); PropertiesWrapper props = new PropertiesWrapper( new HashMap() ); BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration ); String aTest = "aTest"; diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java index 1e09d6f0a3..b49e16478c 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java @@ -19,29 +19,32 @@ * under the License. */ -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.Properties; - import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.SystemUtils; +import org.apache.maven.plugin.surefire.JdkAttributes; import org.apache.maven.shared.utils.StringUtils; import org.apache.maven.shared.utils.cli.Commandline; import org.apache.maven.surefire.booter.Classpath; import org.apache.maven.surefire.booter.SurefireBooterForkException; +import org.junit.Test; -import junit.framework.TestCase; +import java.io.File; +import java.io.IOException; +import java.util.Collections; +import java.util.Properties; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; public class ForkConfigurationTest - extends TestCase { - + @Test public void testCreateCommandLine_UseSystemClassLoaderForkOnce_ShouldConstructManifestOnlyJar() throws IOException, SurefireBooterForkException { - ForkConfiguration config = getForkConfiguration( null, "java" ); + ForkConfiguration config = getForkConfiguration( (String) null ); File cpElement = getTempClasspathFile(); Commandline cli = @@ -51,12 +54,13 @@ public void testCreateCommandLine_UseSystemClassLoaderForkOnce_ShouldConstructMa assertTrue( line.contains( "-jar" ) ); } + @Test public void testArglineWithNewline() throws IOException, SurefireBooterForkException { // SUREFIRE-657 File cpElement = getTempClasspathFile(); - ForkConfiguration forkConfiguration = getForkConfiguration( "abc\ndef", null ); + ForkConfiguration forkConfiguration = getForkConfiguration( "abc\ndef" ); final Commandline commandLine = forkConfiguration.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), false, false, @@ -64,18 +68,19 @@ public void testArglineWithNewline() assertTrue( commandLine.toString().contains( "abc def" ) ); } + @Test public void testCurrentWorkingDirectoryPropagationIncludingForkNumberExpansion() throws IOException, SurefireBooterForkException { // SUREFIRE-1136 File baseDir = new File( FileUtils.getTempDirectory(), "SUREFIRE-1136-" + RandomStringUtils.randomAlphabetic( 3 ) ); - baseDir.mkdirs(); + assertTrue( baseDir.mkdirs() ); baseDir.deleteOnExit(); File cwd = new File( baseDir, "fork_${surefire.forkNumber}" ); - ForkConfiguration config = getForkConfiguration( null, "java", cwd.getCanonicalFile() ); + ForkConfiguration config = getForkConfiguration( null, cwd.getCanonicalFile() ); Commandline commandLine = config.createCommandLine( Collections.emptyList(), true, false, null, 1 ); File forkDirectory = new File( baseDir, "fork_1" ); @@ -84,20 +89,21 @@ public void testCurrentWorkingDirectoryPropagationIncludingForkNumberExpansion() commandLine.getShell().getWorkingDirectory().getCanonicalPath() ) ); } + @Test public void testExceptionWhenCurrentDirectoryIsNotRealDirectory() throws IOException, SurefireBooterForkException { // SUREFIRE-1136 File baseDir = new File( FileUtils.getTempDirectory(), "SUREFIRE-1136-" + RandomStringUtils.randomAlphabetic( 3 ) ); - baseDir.mkdirs(); + assertTrue( baseDir.mkdirs() ); baseDir.deleteOnExit(); File cwd = new File( baseDir, "cwd.txt" ); FileUtils.touch( cwd ); cwd.deleteOnExit(); - ForkConfiguration config = getForkConfiguration( null, "java", cwd.getCanonicalFile() ); + ForkConfiguration config = getForkConfiguration( null, cwd.getCanonicalFile() ); try { @@ -114,19 +120,20 @@ public void testExceptionWhenCurrentDirectoryIsNotRealDirectory() fail(); } + @Test public void testExceptionWhenCurrentDirectoryCannotBeCreated() throws IOException, SurefireBooterForkException { // SUREFIRE-1136 File baseDir = new File( FileUtils.getTempDirectory(), "SUREFIRE-1136-" + RandomStringUtils.randomAlphabetic( 3 ) ); - baseDir.mkdirs(); + assertTrue( baseDir.mkdirs() ); baseDir.deleteOnExit(); // NULL is invalid for JDK starting from 1.7.60 - https://github.com/openjdk-mirror/jdk/commit/e5389115f3634d25d101e2dcc71f120d4fd9f72f // ? character is invalid on Windows, seems to be imposable to create invalid directory using Java on Linux File cwd = new File( baseDir, "?\u0000InvalidDirectoryName" ); - ForkConfiguration config = getForkConfiguration( null, "java", cwd.getAbsoluteFile() ); + ForkConfiguration config = getForkConfiguration( null, cwd.getAbsoluteFile() ); try { @@ -152,17 +159,31 @@ private File getTempClasspathFile() return cpElement; } - public static ForkConfiguration getForkConfiguration( String argLine, String jvm ) + public static ForkConfiguration getForkConfiguration( File javaExec ) + throws IOException + { + return getForkConfiguration( null, javaExec.getAbsolutePath(), new File( "." ).getCanonicalFile() ); + } + + public static ForkConfiguration getForkConfiguration( String argLine ) throws IOException { - return getForkConfiguration( argLine, jvm, new File( "." ).getCanonicalFile() ); + File jvm = new File( new File( System.getProperty( "java.home" ), "bin" ), "java" ); + return getForkConfiguration( argLine, jvm.getAbsolutePath(), new File( "." ).getCanonicalFile() ); + } + + public static ForkConfiguration getForkConfiguration( String argLine, File cwd ) + throws IOException + { + File jvm = new File( new File( System.getProperty( "java.home" ), "bin" ), "java" ); + return getForkConfiguration( argLine, jvm.getAbsolutePath(), cwd ); } - public static ForkConfiguration getForkConfiguration( String argLine, String jvm, File cwd ) + private static ForkConfiguration getForkConfiguration( String argLine, String jvm, File cwd ) throws IOException { - return new ForkConfiguration( Classpath.emptyClasspath(), null, null, jvm, cwd, new Properties(), argLine, null, - false, 1, false, new Platform() ); + return new ForkConfiguration( Classpath.emptyClasspath(), null, null, new JdkAttributes( jvm, false ), + cwd, new Properties(), argLine, null, false, 1, false, new Platform() ); } // based on http://stackoverflow.com/questions/2591083/getting-version-of-java-in-runtime @@ -170,6 +191,6 @@ private boolean isJavaVersionAtLeast( int major, int update ) { String[] javaVersionElements = System.getProperty( "java.runtime.version" ).split( "\\.|_|-b" ); return Integer.valueOf( javaVersionElements[1] ) >= major - && Integer.valueOf( javaVersionElements[4] ) >= update; + && Integer.valueOf( javaVersionElements[3] ) >= update; } } diff --git a/maven-surefire-plugin/pom.xml b/maven-surefire-plugin/pom.xml index 2a186e3489..96a1720e8b 100644 --- a/maven-surefire-plugin/pom.xml +++ b/maven-surefire-plugin/pom.xml @@ -86,6 +86,7 @@ maven-assembly-plugin + 2.6 build-site @@ -103,32 +104,6 @@ - - org.apache.maven.plugins - maven-shade-plugin - - - package - - shade - - - true - - - org.apache.maven.shared:maven-shared-utils - - - - - org.apache.maven.shared - org.apache.maven.surefire.shade.org.apache.maven.shared - - - - - - diff --git a/maven-surefire-plugin/src/site/markdown/java9.md b/maven-surefire-plugin/src/site/markdown/java9.md new file mode 100644 index 0000000000..96bc9a8e90 --- /dev/null +++ b/maven-surefire-plugin/src/site/markdown/java9.md @@ -0,0 +1,92 @@ + + +Java 9 in JAVA_HOME +======================== + + $ export JAVA_HOME=/path/to/jdk9 + $ mvn test + +The plugin will automatically add `--add-modules ALL-SYSTEM` on JVM argument in CLI (unless already specified by user) +and all Java 9 API is provided to run your tests. + + +Java 9 in configuration of plugin +======================== + +The plugin provides you with configuration parameter `jvm` which can point to path of executable Java in JDK, e.g.: + + + /path/to/jdk9/bin/java + + +Now you can run the build with tests on the top of Java 9. + + +Maven Toolchains with JDK 9 +======================== + +This is an example on Windows to run unit tests with custom path to Toolchain **(-t ...)**. + + $ mvn -t D:\.m2\toolchains.xml test + +Without **(-t ...)** the Toolchain should be located in **${user.home}/.m2/toolchains.xml**. + +The content of **toolchains.xml** would become as follows however multiple different JDKs can be specified. + + + + jdk + + 9 + oracle + jdk9 + + + /path/to/jdk9 + + + + +Your POM should specify the plugin which activates only particular JDK in *toolchains.xml* which specifies version **9**: + + + org.apache.maven.plugins + maven-toolchains-plugin + 1.1 + + + validate + + toolchain + + + + + + + 9 + + + + + +Now you can run the build with tests on the top of Java 9. diff --git a/maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb b/maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb deleted file mode 100644 index 1e076d3150..0000000000 --- a/maven-surefire-plugin/src/site/resources/xsd/failsafe-summary.xjb +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - diff --git a/maven-surefire-plugin/src/site/site.xml b/maven-surefire-plugin/src/site/site.xml index 7e8d49cf76..2d2e95ac36 100644 --- a/maven-surefire-plugin/src/site/site.xml +++ b/maven-surefire-plugin/src/site/site.xml @@ -56,6 +56,7 @@ + diff --git a/pom.xml b/pom.xml index 6ba5602125..0f64b4aab4 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,7 @@ scm:git:https://git-wip-us.apache.org/repos/asf/maven-surefire.git surefire-archives/surefire-LATEST - ${java.home}/.. + ${java.home}/.. @@ -217,6 +217,11 @@ maven-toolchain ${mavenVersion} + + org.apache.maven + maven-settings + ${mavenVersion} + org.apache.maven.shared maven-shared-utils @@ -244,6 +249,22 @@ + + org.powermock + powermock-mockito-release-full + 1.6.4 + full + + + org.hamcrest + hamcrest-core + + + junit + junit + + + junit junit @@ -399,12 +420,12 @@
    maven-invoker-plugin - 2.0.0 + 3.0.1 org.jacoco jacoco-maven-plugin - 0.7.8 + 0.7.9 **/failsafe/* @@ -420,6 +441,7 @@ org.apache.maven.plugins maven-enforcer-plugin + 3.0.0-M1 enforce-java @@ -429,7 +451,9 @@ - [1.8.0,) + + + [1.8, 1.9) diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml index ec5c66457b..7b29c6d626 100644 --- a/surefire-api/pom.xml +++ b/surefire-api/pom.xml @@ -52,7 +52,7 @@ maven-surefire-plugin - ${test.jre}/bin/java + ${jdk.home}/bin/java true **/JUnit4SuiteTest.java diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml index 8fdaf7e982..b564fa471f 100644 --- a/surefire-booter/pom.xml +++ b/surefire-booter/pom.xml @@ -55,6 +55,12 @@ commons-io commons-io + + org.powermock + powermock-mockito-release-full + full + test + @@ -85,7 +91,7 @@ - ${test.jre}/bin/java + ${jdk.home}/bin/java true **/JUnit4SuiteTest.java diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java index ccdb6e6d2e..3a53ddf31d 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java @@ -22,19 +22,29 @@ import org.apache.maven.surefire.util.ReflectionUtils; import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; import java.lang.management.ManagementFactory; import java.lang.reflect.Method; +import java.util.Properties; +import java.util.StringTokenizer; import static java.lang.Thread.currentThread; +import static org.apache.commons.io.IOUtils.closeQuietly; import static org.apache.commons.lang3.JavaVersion.JAVA_9; import static org.apache.commons.lang3.JavaVersion.JAVA_RECENT; +import static org.apache.commons.lang3.StringUtils.isNumeric; import static org.apache.commons.lang3.SystemUtils.IS_OS_FREE_BSD; import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX; import static org.apache.commons.lang3.SystemUtils.IS_OS_NET_BSD; import static org.apache.commons.lang3.SystemUtils.IS_OS_OPEN_BSD; +import static org.apache.commons.lang3.SystemUtils.isJavaVersionAtLeast; import static org.apache.maven.surefire.util.ReflectionUtils.invokeMethodChain; import static org.apache.maven.surefire.util.ReflectionUtils.tryLoadClass; +import static org.apache.maven.surefire.util.internal.ObjectUtils.requireNonNull; /** * JDK 9 support. @@ -44,13 +54,144 @@ */ public final class SystemUtils { + private static final double JIGSAW_JAVA_VERSION = 9.0d; + private static final int PROC_STATUS_PID_FIRST_CHARS = 20; - public SystemUtils() + private SystemUtils() { throw new IllegalStateException( "no instantiable constructor" ); } + /** + * @param jvmExecPath e.g. /jdk/bin/java, /jdk/jre/bin/java + * @return {@code true} if {@code jvmExecPath} is path to java binary executor + */ + public static boolean endsWithJavaPath( String jvmExecPath ) + { + File javaExec = new File( jvmExecPath ).getAbsoluteFile(); + File bin = javaExec.getParentFile(); + String exec = javaExec.getName(); + return exec.startsWith( "java" ) && bin != null && bin.getName().equals( "bin" ); + } + + /** + * If {@code jvmExecutable} is /jdk/bin/java (since jdk9) or /jdk/jre/bin/java (prior to jdk9) + * then the absolute path to JDK home is returned /jdk. + *
    + * Null is returned if {@code jvmExecutable} is incorrect. + * + * @param jvmExecutable /jdk/bin/java* or /jdk/jre/bin/java* + * @return path to jdk directory; or null if wrong path or directory layout of JDK installation. + */ + public static File toJdkHomeFromJvmExec( String jvmExecutable ) + { + File bin = new File( jvmExecutable ).getAbsoluteFile().getParentFile(); + if ( "bin".equals( bin.getName() ) ) + { + File parent = bin.getParentFile(); + if ( "jre".equals( parent.getName() ) ) + { + File jdk = parent.getParentFile(); + return new File( jdk, "bin" ).isDirectory() ? jdk : null; + } + return parent; + } + return null; + } + + /** + * If system property java.home is /jdk (since jdk9) or /jdk/jre (prior to jdk9) then + * the absolute path to + * JDK home is returned /jdk. + * + * @return path to JDK + */ + public static File toJdkHomeFromJre() + { + return toJdkHomeFromJre( System.getProperty( "java.home" ) ); + } + + /** + * If {@code jreHome} is /jdk (since jdk9) or /jdk/jre (prior to jdk9) then + * the absolute path to JDK home is returned /jdk. + *
    + * JRE home directory {@code jreHome} must be taken from system property java.home. + * + * @param jreHome path to /jdk or /jdk/jre + * @return path to JDK + */ + static File toJdkHomeFromJre( String jreHome ) + { + File pathToJreOrJdk = new File( jreHome ).getAbsoluteFile(); + return "jre".equals( pathToJreOrJdk.getName() ) ? pathToJreOrJdk.getParentFile() : pathToJreOrJdk; + } + + public static Double toJdkVersionFromReleaseFile( File jdkHome ) + { + File release = new File( requireNonNull( jdkHome ).getAbsoluteFile(), "release" ); + if ( !release.isFile() ) + { + return null; + } + InputStream is = null; + try + { + Properties properties = new Properties(); + is = new FileInputStream( release ); + properties.load( is ); + String javaVersion = properties.getProperty( "JAVA_VERSION" ).replace( "\"", "" ); + StringTokenizer versions = new StringTokenizer( javaVersion, "._" ); + + if ( versions.countTokens() == 1 ) + { + javaVersion = versions.nextToken(); + } + else if ( versions.countTokens() >= 2 ) + { + String majorVersion = versions.nextToken(); + String minorVersion = versions.nextToken(); + javaVersion = isNumeric( minorVersion ) ? majorVersion + "." + minorVersion : majorVersion; + } + else + { + return null; + } + + return Double.valueOf( javaVersion ); + } + catch ( IOException e ) + { + return null; + } + finally + { + closeQuietly( is ); + } + } + + public static boolean isJava9AtLeast( String jvmExecutablePath ) + { + File externalJavaHome = toJdkHomeFromJvmExec( jvmExecutablePath ); + File thisJavaHome = toJdkHomeFromJre(); + if ( thisJavaHome.equals( externalJavaHome ) ) + { + return isBuiltInJava9AtLeast(); + } + Double releaseFileVersion = externalJavaHome == null ? null : toJdkVersionFromReleaseFile( externalJavaHome ); + return SystemUtils.isJava9AtLeast( releaseFileVersion ); + } + + static boolean isBuiltInJava9AtLeast() + { + return isJavaVersionAtLeast( JAVA_9 ); + } + + public static boolean isJava9AtLeast( Double version ) + { + return version != null && version >= JIGSAW_JAVA_VERSION; + } + public static ClassLoader platformClassLoader() { if ( JAVA_RECENT.atLeast( JAVA_9 ) ) diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java index 12aff99faf..1917cbb99c 100644 --- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java @@ -19,10 +19,19 @@ * under the License. */ +import org.junit.Ignore; import org.junit.Test; +import org.junit.experimental.runners.Enclosed; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import java.io.File; +import java.io.IOException; import java.lang.management.ManagementFactory; +import static java.io.File.separator; import static org.apache.commons.lang3.JavaVersion.JAVA_9; import static org.apache.commons.lang3.JavaVersion.JAVA_RECENT; import static org.apache.commons.lang3.SystemUtils.IS_OS_FREE_BSD; @@ -30,7 +39,14 @@ import static org.apache.commons.lang3.SystemUtils.IS_OS_NET_BSD; import static org.apache.commons.lang3.SystemUtils.IS_OS_OPEN_BSD; import static org.fest.assertions.Assertions.assertThat; +import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyDouble; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.when; +import static org.powermock.api.mockito.PowerMockito.mockStatic; +import static org.powermock.api.mockito.PowerMockito.verifyStatic; /** * Test of {@link SystemUtils}. @@ -38,94 +54,280 @@ * @author Tibor Digana (tibor17) * @since 2.20.1 */ +@RunWith( Enclosed.class ) public class SystemUtilsTest { - @Test - public void shouldBePlatformClassLoader() + public static class PlainUnitTests { - ClassLoader cl = SystemUtils.platformClassLoader(); - if ( JAVA_RECENT.atLeast( JAVA_9 ) ) + + @Test + public void shouldParseProprietaryReleaseFile() throws IOException + { + String classes = new File( "." ).getCanonicalPath() + separator + "target" + separator + "test-classes"; + + File path = new File( classes, "jdk8-IBM" + separator + "bin" + separator + "java" ); + assertThat( SystemUtils.isJava9AtLeast( path.getAbsolutePath() ) ).isFalse(); + + path = new File( classes, "jdk8-oracle" + separator + "bin" + separator + "java" ); + assertThat( SystemUtils.isJava9AtLeast( path.getAbsolutePath() ) ).isFalse(); + + path = new File( classes, "jdk9-oracle" + separator + "bin" + separator + "java" ); + assertThat( SystemUtils.isJava9AtLeast( path.getAbsolutePath() ) ).isTrue(); + } + + @Test + public void incorrectJdkPath() throws IOException + { + File jre = new File( System.getProperty( "java.home" ) ); + File jdk = jre.getParentFile(); + File incorrect = jdk.getParentFile(); + assertThat( SystemUtils.isJava9AtLeast( incorrect.getAbsolutePath() ) ).isFalse(); + } + + @Test + public void shouldHaveJavaPath() + { + String javaPath = System.getProperty( "java.home" ) + separator + "bin" + separator + "java"; + assertThat( SystemUtils.endsWithJavaPath( javaPath ) ).isTrue(); + } + + @Test + public void shouldNotHaveJavaPath() + { + assertThat( SystemUtils.endsWithJavaPath( "/jdk" ) ).isFalse(); + } + + @Test + public void shouldNotExtractJdkHomeFromJavaExec() + { + File pathToJdk = SystemUtils.toJdkHomeFromJvmExec( "/jdk/binx/java" ); + assertThat( pathToJdk ).isNull(); + } + + @Test + public void shouldExtractJdkHomeFromJavaExec() + { + File pathToJdk = SystemUtils.toJdkHomeFromJvmExec( "/jdk/bin/java" ); + assertThat( pathToJdk ).isEqualTo( new File( "/jdk" ).getAbsoluteFile() ); + } + + @Test + public void shouldNotExtractJdkHomeFromJreExec() throws IOException + { + String classes = new File( "." ).getCanonicalPath() + separator + "target" + separator + "test-classes"; + File jdk = new File( classes, "jdk" ); + String pathToJreExec = jdk.getAbsolutePath() + separator + "jre" + separator + "binx" + separator + "java"; + File pathToJdk = SystemUtils.toJdkHomeFromJvmExec( pathToJreExec ); + assertThat( pathToJdk ).isNull(); + } + + @Test + public void shouldExtractJdkHomeFromJreExec() throws IOException + { + String classes = new File( "." ).getCanonicalPath() + separator + "target" + separator + "test-classes"; + File jdk = new File( classes, "jdk" ); + String pathToJreExec = jdk.getAbsolutePath() + separator + "jre" + separator + "bin" + separator + "java"; + File pathToJdk = SystemUtils.toJdkHomeFromJvmExec( pathToJreExec ); + assertThat( pathToJdk ).isEqualTo( jdk ); + } + + @Test + public void shouldExtractJdkHomeFromJre() + { + File pathToJdk = SystemUtils.toJdkHomeFromJre( "/jdk/jre" ); + assertThat( pathToJdk ).isEqualTo( new File( "/jdk" ).getAbsoluteFile() ); + } + + @Test + public void shouldExtractJdkHomeFromJdk() { - assertThat( cl ).isNotNull(); + File pathToJdk = SystemUtils.toJdkHomeFromJre( "/jdk/" ); + assertThat( pathToJdk ).isEqualTo( new File( "/jdk" ).getAbsoluteFile() ); } - else + + @Test + public void shouldExtractJdkHomeFromRealPath() { + File pathToJdk = SystemUtils.toJdkHomeFromJre(); + + if ( JAVA_RECENT.atLeast( JAVA_9 ) ) + { + File realJdkHome = new File( System.getProperty( "java.home" ) ).getAbsoluteFile(); + assertThat( realJdkHome ).isDirectory(); + assertThat( realJdkHome.getName() ).isNotEqualTo( "jre" ); + assertThat( pathToJdk ).isEqualTo( realJdkHome ); + } + else + { + File realJreHome = new File( System.getProperty( "java.home" ) ).getAbsoluteFile(); + assertThat( realJreHome ).isDirectory(); + assertThat( realJreHome.getName() ).isEqualTo( "jre" ); + File realJdkHome = realJreHome.getParentFile(); + assertThat( pathToJdk ).isEqualTo( realJdkHome ); + } + } + + @Test + public void shouldBeJavaVersion() + { + assertThat( SystemUtils.isJava9AtLeast( (Double) null ) ).isFalse(); + assertThat( SystemUtils.isJava9AtLeast( 1.8d ) ).isFalse(); + assertThat( SystemUtils.isJava9AtLeast( 9.0d ) ).isTrue(); + } + + @Test + public void shouldBePlatformClassLoader() + { + ClassLoader cl = SystemUtils.platformClassLoader(); + if ( JAVA_RECENT.atLeast( JAVA_9 ) ) + { + assertThat( cl ).isNotNull(); + } + else + { + assertThat( cl ).isNull(); + } + } + + @Test + public void shouldNotFindClassLoader() + { + ClassLoader cl = SystemUtils.reflectClassLoader( getClass(), "_getPlatformClassLoader_" ); assertThat( cl ).isNull(); } - } - @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() ); + } - @Test - public void shouldFindClassLoader() - { - ClassLoader cl = SystemUtils.reflectClassLoader( getClass(), "getPlatformClassLoader" ); - assertThat( cl ).isSameAs( ClassLoader.getSystemClassLoader() ); - } + @Test + public void shouldBePidOnJigsaw() + { + assumeTrue( JAVA_RECENT.atLeast( JAVA_9 ) ); - @Test - public void shouldBePidOnJigsaw() - { - assumeTrue( JAVA_RECENT.atLeast( JAVA_9 ) ); + Long actualPid = SystemUtils.pidOnJava9(); + String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); - Long actualPid = SystemUtils.pidOnJava9(); - String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); + assertThat( actualPid + "" ) + .isEqualTo( expectedPid ); + } - assertThat( actualPid + "" ) - .isEqualTo( expectedPid ); - } + @Test + public void shouldBePidStatusOnLinux() throws Exception + { + assumeTrue( IS_OS_LINUX ); - @Test - public void shouldBePidStatusOnLinux() throws Exception - { - assumeTrue( IS_OS_LINUX ); + Long actualPid = SystemUtils.pidStatusOnLinux(); + String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); - Long actualPid = SystemUtils.pidStatusOnLinux(); - String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); + assertThat( actualPid + "" ) + .isEqualTo( expectedPid ); + } - assertThat( actualPid + "" ) - .isEqualTo( expectedPid ); - } + @Test + public void shouldBePidStatusOnBSD() throws Exception + { + assumeTrue( IS_OS_FREE_BSD || IS_OS_NET_BSD || IS_OS_OPEN_BSD ); - @Test - public void shouldBePidStatusOnBSD() throws Exception - { - assumeTrue( IS_OS_FREE_BSD || IS_OS_NET_BSD || IS_OS_OPEN_BSD ); + Long actualPid = SystemUtils.pidStatusOnBSD(); + String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); - Long actualPid = SystemUtils.pidStatusOnBSD(); - String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); + assertThat( actualPid + "" ) + .isEqualTo( expectedPid ); + } - assertThat( actualPid + "" ) - .isEqualTo( expectedPid ); - } + @Test + public void shouldBePidOnJMX() + { + Long actualPid = SystemUtils.pidOnJMX(); + String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); - @Test - public void shouldBePidOnJMX() - { - Long actualPid = SystemUtils.pidOnJMX(); - String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); + assertThat( actualPid + "" ) + .isEqualTo( expectedPid ); + } - assertThat( actualPid + "" ) - .isEqualTo( expectedPid ); - } + @Test + public void shouldBePid() + { + Long actualPid = SystemUtils.pid(); + String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); - @Test - public void shouldBePid() - { - Long actualPid = SystemUtils.pid(); - String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim(); + assertThat( actualPid + "" ) + .isEqualTo( expectedPid ); + } + + public static ClassLoader getPlatformClassLoader() + { + return ClassLoader.getSystemClassLoader(); + } - assertThat( actualPid + "" ) - .isEqualTo( expectedPid ); } - public static ClassLoader getPlatformClassLoader() + @RunWith( PowerMockRunner.class ) + @PrepareForTest( SystemUtils.class ) + // todo check PowerMock is compliant with Java 9 + @Ignore( value = "use this test after issue is fixed https://github.com/powermock/powermock/issues/783") + public static class MockTest { - return ClassLoader.getSystemClassLoader(); + + @Test + public void shouldBeDifferentJdk9() throws IOException + { + testIsJava9AtLeast( new File( System.getProperty( "java.home" ) ) ); + } + + @Test + public void shouldBeSameJdk9() throws IOException + { + assumeFalse( JAVA_RECENT.atLeast( JAVA_9 ) ); + testIsJava9AtLeast( new File( System.getProperty( "java.home" ) ).getParentFile() ); + } + + private static void testIsJava9AtLeast( File pathInJdk ) throws IOException + { + File path = new File( pathInJdk, "bin" + separator + "java" ); + + mockStatic( SystemUtils.class ); + + when( SystemUtils.isJava9AtLeast( anyString() ) ) + .thenCallRealMethod(); + + when( SystemUtils.toJdkHomeFromJvmExec( anyString() ) ) + .thenCallRealMethod(); + + when( SystemUtils.toJdkHomeFromJre() ) + .thenCallRealMethod(); + + when( SystemUtils.toJdkHomeFromJre( anyString() ) ) + .thenCallRealMethod(); + + when( SystemUtils.isBuiltInJava9AtLeast() ) + .thenCallRealMethod(); + + when( SystemUtils.toJdkVersionFromReleaseFile( any( File.class ) ) ) + .thenCallRealMethod(); + + when( SystemUtils.isJava9AtLeast( anyDouble() ) ) + .thenCallRealMethod(); + + if ( JAVA_RECENT.atLeast( JAVA_9 ) ) + { + assertThat( SystemUtils.isJava9AtLeast( path.getAbsolutePath() ) ).isTrue(); + } + else + { + assertThat( SystemUtils.isJava9AtLeast( path.getAbsolutePath() ) ).isFalse(); + } + + verifyStatic( Mockito.times( 0 ) ); + SystemUtils.toJdkVersionFromReleaseFile( any( File.class ) ); + + verifyStatic( Mockito.times( 1 ) ); + SystemUtils.isBuiltInJava9AtLeast(); + } + } -} +} \ No newline at end of file diff --git a/surefire-booter/src/test/resources/jdk/bin/java b/surefire-booter/src/test/resources/jdk/bin/java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/surefire-booter/src/test/resources/jdk/jre/bin/java b/surefire-booter/src/test/resources/jdk/jre/bin/java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/surefire-booter/src/test/resources/jdk8-IBM/release b/surefire-booter/src/test/resources/jdk8-IBM/release new file mode 100644 index 0000000000..f8baa302ac --- /dev/null +++ b/surefire-booter/src/test/resources/jdk8-IBM/release @@ -0,0 +1 @@ +JAVA_VERSION="1.8.0" diff --git a/surefire-booter/src/test/resources/jdk8-oracle/release b/surefire-booter/src/test/resources/jdk8-oracle/release new file mode 100644 index 0000000000..567277b3a8 --- /dev/null +++ b/surefire-booter/src/test/resources/jdk8-oracle/release @@ -0,0 +1 @@ +JAVA_VERSION="1.8.0_141" diff --git a/surefire-booter/src/test/resources/jdk9-oracle/release b/surefire-booter/src/test/resources/jdk9-oracle/release new file mode 100644 index 0000000000..afcc747061 --- /dev/null +++ b/surefire-booter/src/test/resources/jdk9-oracle/release @@ -0,0 +1 @@ +JAVA_VERSION="9" diff --git a/surefire-integration-tests/pom.xml b/surefire-integration-tests/pom.xml index d9142de6d7..4ea01b4f9b 100644 --- a/surefire-integration-tests/pom.xml +++ b/surefire-integration-tests/pom.xml @@ -55,7 +55,6 @@ org.apache.maven maven-settings - 2.0.6 test @@ -109,12 +108,15 @@ ${maven.home} ${project.basedir}/../surefire-setup-integration-tests/target/private/it-settings.xml + ${project.basedir}/../surefire-setup-integration-tests/target/private/toolchains.xml + ${project.basedir}/../surefire-setup-integration-tests/target/it-repo ${project.build.directory} ${settings.localRepository} ${useInterpolatedSettings} ${project.build.testOutputDirectory} ${verifier.forkMode} + ${jdk.home} false
    diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java new file mode 100644 index 0000000000..c2d0173f60 --- /dev/null +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java @@ -0,0 +1,113 @@ +package org.apache.maven.surefire.its; + +/* + * 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 java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +import java.util.StringTokenizer; + +import static org.apache.commons.lang3.JavaVersion.JAVA_9; +import static org.apache.commons.lang3.JavaVersion.JAVA_RECENT; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +/** + * Abstract test class for Jigsaw tests. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public abstract class AbstractJigsawIT + extends SurefireJUnit4IntegrationTestCase +{ + protected static final String JDK_HOME_KEY = "jdk.home"; + protected static final String JDK_HOME = System.getProperty( JDK_HOME_KEY ); + private static final double JIGSAW_JAVA_VERSION = 9.0d; + + protected abstract String getProjectDirectoryName(); + + protected SurefireLauncher assumeJigsaw() throws IOException + { + assumeTrue( "There's no JDK 9 provided.", + JAVA_RECENT.atLeast( JAVA_9 ) || JDK_HOME != null && isExtJava9AtLeast() ); + // fail( JDK_HOME_KEY + " was provided with value " + JDK_HOME + " but it is not Jigsaw Java 9." ); + + SurefireLauncher launcher = unpack(); + + if ( JDK_HOME != null ) + { + launcher.setLauncherJavaHome( JDK_HOME ); + } + + return launcher; + } + + protected SurefireLauncher assumeJava9Property() throws IOException + { + assumeTrue( "There's no JDK 9 provided.", JDK_HOME != null && isExtJava9AtLeast() ); + return unpack(); + } + + private SurefireLauncher unpack() + { + return unpack( getProjectDirectoryName() ); + } + + private static boolean isExtJava9AtLeast() throws IOException + { + File release = new File( JDK_HOME, "release" ); + + if ( !release.isFile() ) + { + fail( JDK_HOME_KEY + " was provided with value " + JDK_HOME + " but file does not exist " + + JDK_HOME + File.separator + "release" + ); + } + + Properties properties = new Properties(); + try ( InputStream is = new FileInputStream( release ) ) + { + properties.load( is ); + } + String javaVersion = properties.getProperty( "JAVA_VERSION" ).replace( "\"", "" ); + StringTokenizer versions = new StringTokenizer( javaVersion, "._" ); + + if ( versions.countTokens() == 1 ) + { + javaVersion = versions.nextToken(); + } + else if ( versions.countTokens() >= 2 ) + { + javaVersion = versions.nextToken() + "." + versions.nextToken(); + } + else + { + fail( "unexpected java version format" ); + } + + return Double.valueOf( javaVersion ) >= JIGSAW_JAVA_VERSION; + } +} diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Java9FullApiIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Java9FullApiIT.java new file mode 100644 index 0000000000..b1bea128ad --- /dev/null +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Java9FullApiIT.java @@ -0,0 +1,95 @@ +package org.apache.maven.surefire.its; + +/* + * 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.OutputValidator; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; + +/** + * Running Surefire on the top of JDK 9 and should be able to load + * classes of multiple different Jigsaw modules without error. + * + * @author Tibor Digana (tibor17) + * @since 2.20.1 + */ +public class Java9FullApiIT + extends AbstractJigsawIT +{ + + @Test + public void shouldLoadMultipleJavaModules_JavaHome() throws IOException + { + OutputValidator validator = assumeJigsaw() + .setForkJvm() + .debugLogging() + .execute( "verify" ) + .verifyErrorFree( 2 ); + + validator.verifyTextInLog( "loaded class java.sql.SQLException" ) + .verifyTextInLog( "loaded class javax.xml.ws.Holder" ) + .verifyTextInLog( "loaded class javax.xml.bind.JAXBException" ) + .verifyTextInLog( "loaded class org.omg.CORBA.BAD_INV_ORDER" ) + .verifyTextInLog( "java.specification.version=9" ); + } + + @Test + public void shouldLoadMultipleJavaModules_JvmParameter() throws IOException + { + OutputValidator validator = assumeJava9Property() + .setForkJvm() + .debugLogging() + .sysProp( JDK_HOME_KEY, new File( JDK_HOME ).getCanonicalPath() ) + .execute( "verify" ) + .verifyErrorFree( 2 ); + + validator.verifyTextInLog( "loaded class java.sql.SQLException" ) + .verifyTextInLog( "loaded class javax.xml.ws.Holder" ) + .verifyTextInLog( "loaded class javax.xml.bind.JAXBException" ) + .verifyTextInLog( "loaded class org.omg.CORBA.BAD_INV_ORDER" ) + .verifyTextInLog( "java.specification.version=9" ); + } + + @Test + public void shouldLoadMultipleJavaModules_ToolchainsXML() throws IOException + { + OutputValidator validator = assumeJava9Property() + .setForkJvm() + .activateProfile( "use-toolchains" ) + .addGoal( "--toolchains" ) + .addGoal( System.getProperty( "maven.toolchains.file" ) ) + .execute( "verify" ) + .verifyErrorFree( 2 ); + + validator.verifyTextInLog( "loaded class java.sql.SQLException" ) + .verifyTextInLog( "loaded class javax.xml.ws.Holder" ) + .verifyTextInLog( "loaded class javax.xml.bind.JAXBException" ) + .verifyTextInLog( "loaded class org.omg.CORBA.BAD_INV_ORDER" ) + .verifyTextInLog( "java.specification.version=9" ); + } + + @Override + protected String getProjectDirectoryName() + { + return "java9-full-api"; + } +} 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 index 9e06e8e11b..2e92805e48 100644 --- 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 @@ -19,11 +19,10 @@ * under the License. */ -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.apache.maven.surefire.its.AbstractJigsawIT; import org.junit.Test; -import static org.junit.Assume.assumeTrue; +import java.io.IOException; @SuppressWarnings( { "javadoc", "checkstyle:javadoctype" } ) /** @@ -40,19 +39,19 @@ * @since 2.20.1 */ public class Surefire1265Java9IT - extends SurefireJUnit4IntegrationTestCase + extends AbstractJigsawIT { @Test - public void shouldRunInPluginJava9() + public void shouldRunInPluginJava9() throws IOException { - assumeTrue( System.getProperty( "java.specification.version" ).compareTo( "1.8" ) > 0 ); - unpack() + assumeJigsaw() .executeTest() .verifyErrorFree( 2 ); } - private SurefireLauncher unpack() + @Override + protected String getProjectDirectoryName() { - return unpack( "/surefire-1265" ); + return "/surefire-1265"; } } diff --git a/surefire-integration-tests/src/test/resources/java9-full-api/pom.xml b/surefire-integration-tests/src/test/resources/java9-full-api/pom.xml new file mode 100644 index 0000000000..7d9026ea7c --- /dev/null +++ b/surefire-integration-tests/src/test/resources/java9-full-api/pom.xml @@ -0,0 +1,122 @@ + + + + + 4.0.0 + + + org.apache.maven.surefire + it-parent + 1.0 + ../pom.xml + + + java9-full-api + + + 1.6 + 1.6 + + + + + + maven-surefire-plugin + + once + + + + maven-failsafe-plugin + + + + integration-test + verify + + + + + once + + + + + + + + junit + junit + 4.12 + test + + + + + + use-jvm-config-paramater + + + jdk.home + + + + + + maven-surefire-plugin + + ${jdk.home}/bin/java + + + + + + + use-toolchains + + + + org.apache.maven.plugins + maven-toolchains-plugin + 1.1 + + + validate + + toolchain + + + + + + + 9 + + + + + + + + + + diff --git a/surefire-integration-tests/src/test/resources/java9-full-api/src/test/java/J9IT.java b/surefire-integration-tests/src/test/resources/java9-full-api/src/test/java/J9IT.java new file mode 100644 index 0000000000..9daf55d134 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/java9-full-api/src/test/java/J9IT.java @@ -0,0 +1,39 @@ +/* + * 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 J9IT +{ + @Test + public void testMiscellaneousAPI() throws java.sql.SQLException + { + System.out.println( "loaded class " + java.sql.SQLException.class.getName() ); + System.out.println( "loaded class " + javax.xml.ws.Holder.class.getName() ); + System.out.println( "loaded class " + javax.xml.bind.JAXBException.class.getName() ); + System.out.println( "loaded class " + org.omg.CORBA.BAD_INV_ORDER.class.getName() ); + System.out.println( "loaded class " + javax.xml.xpath.XPath.class.getName() ); + System.out.println( "java.specification.version=" + System.getProperty( "java.specification.version" ) ); + } + + @Test + public void test_corba_mod() throws org.omg.CORBA.BAD_INV_ORDER + { + } +} diff --git a/surefire-integration-tests/src/test/resources/java9-full-api/src/test/java/J9Test.java b/surefire-integration-tests/src/test/resources/java9-full-api/src/test/java/J9Test.java new file mode 100644 index 0000000000..6745d5ff49 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/java9-full-api/src/test/java/J9Test.java @@ -0,0 +1,39 @@ +/* + * 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 J9Test +{ + @Test + public void testMiscellaneousAPI() throws java.sql.SQLException + { + System.out.println( "loaded class " + java.sql.SQLException.class.getName() ); + System.out.println( "loaded class " + javax.xml.ws.Holder.class.getName() ); + System.out.println( "loaded class " + javax.xml.bind.JAXBException.class.getName() ); + System.out.println( "loaded class " + org.omg.CORBA.BAD_INV_ORDER.class.getName() ); + System.out.println( "loaded class " + javax.xml.xpath.XPath.class.getName() ); + System.out.println( "java.specification.version=" + System.getProperty( "java.specification.version" ) ); + } + + @Test + public void test_corba_mod() throws org.omg.CORBA.BAD_INV_ORDER + { + } +} diff --git a/surefire-setup-integration-tests/pom.xml b/surefire-setup-integration-tests/pom.xml index fde80ae269..ff2ddbfa47 100644 --- a/surefire-setup-integration-tests/pom.xml +++ b/surefire-setup-integration-tests/pom.xml @@ -89,7 +89,7 @@ org.apache.maven maven-settings - 2.0.6 + ${mavenVersion} test @@ -106,6 +106,23 @@ + + + src/main/resources + ${project.build.outputDirectory} + + toolchains.xml + + + + src/main/resources + true + ${project.build.directory}/private + + toolchains.xml + + + maven-help-plugin @@ -127,11 +144,9 @@ maven-invoker-plugin - - org.apache.maven.surefire:surefire-testng-utils:${project.version} - ${project.build.directory}/it-repo + org.apache.maven.surefire:surefire-testng-utils:${project.version} org.testng:testng:4.7:jar:jdk15 org.testng:testng:5.0.2:jar:jdk15 org.testng:testng:5.1:jar:jdk15 @@ -173,6 +188,7 @@ junit:junit:4.8.1 junit:junit:4.8.2 junit:junit:4.11 + junit:junit:4.12 junit:junit-dep:4.8 junit:junit-dep:4.7 junit:junit-dep:4.4 @@ -184,7 +200,11 @@ org.codehaus.plexus:plexus-utils:1.5.8 org.codehaus.plexus:plexus-utils:1.5.15 org.mockito:mockito-core:1.8.5 + org.powermock:powermock-mockito-release-full:1.6.4:jar:full org.codehaus.plexus:plexus-interpolation:1.12 + org.hamcrest:hamcrest-core:1.3 + org.hamcrest:hamcrest-library:1.3 + org.easytesting:fest-assert:1.4 diff --git a/surefire-setup-integration-tests/src/main/resources/toolchains.xml b/surefire-setup-integration-tests/src/main/resources/toolchains.xml new file mode 100644 index 0000000000..f9f1d66d1b --- /dev/null +++ b/surefire-setup-integration-tests/src/main/resources/toolchains.xml @@ -0,0 +1,35 @@ + + + + + + jdk + + jdk9 + 9 + oracle + + + ${jdk.home} + + + From 0eeec810df1424b9e1d3cf5f6cd6cb22482e615a Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 15 Aug 2017 16:15:25 +0200 Subject: [PATCH 114/194] fixed build --- maven-failsafe-plugin/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index f4b2c09a5a..4233139f71 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -179,6 +179,7 @@ org.apache.maven.shared:maven-shared-utils commons-io:commons-io + org.apache.commons:commons-lang3 @@ -190,6 +191,10 @@ org.apache.commons.io org.apache.maven.surefire.shade.org.apache.commons.io + + org.apache.commons.lang3 + org.apache.maven.surefire.shade.org.apache.commons.lang3 +
    From f9691d8d0942fd6cc8cbcab13cfa83a6be2639ea Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 15 Aug 2017 23:57:34 +0200 Subject: [PATCH 115/194] Jenkinsfile --- Jenkinsfile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cbac90d221..e1fefe7abd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,15 +5,18 @@ pipeline { stages { stage('Unix Build') { tools { - maven 'Maven 3.3.9' - jdk 'JDK 1.8.0_102' + maven 'Maven 3.5.0' + jdk 'JDK 1.8.0_144' } steps { - sh 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,embedded,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084' + sh 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=$JDK_9_B181_HOME' + } + stage('JaCoCo') { + jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { success { - junit '**/target/surefire-reports/**/*.xml,**/target/failsafe-reports/**/*.xml' + junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' } } } @@ -22,15 +25,18 @@ pipeline { label env.WIN_LABEL } tools { - maven 'Maven 3.3.9 (Windows)' + maven 'Maven 3.5.0 (Windows)' jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,embedded,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084' + bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=$JDK_9_B181_HOME' + } + stage('JaCoCo') { + jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { success { - junit '**/target/surefire-reports/**/*.xml,**/target/failsafe-reports/**/*.xml' + junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' } } } From 24f38627d182b10a6fd37166ac371776da3f3979 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 16 Aug 2017 00:03:35 +0200 Subject: [PATCH 116/194] Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e1fefe7abd..386eb92e2b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ pipeline { steps { sh 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=$JDK_9_B181_HOME' } - stage('JaCoCo') { + steps { jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -29,9 +29,9 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=$JDK_9_B181_HOME' + bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=%JDK_9_B181_HOME%' } - stage('JaCoCo') { + steps { jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { From 9e6a838f6f94212321d926101d642db27fdbac3a Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 16 Aug 2017 00:06:10 +0200 Subject: [PATCH 117/194] Jenkinsfile --- Jenkinsfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 386eb92e2b..2bc93a49f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,8 +10,6 @@ pipeline { } steps { sh 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=$JDK_9_B181_HOME' - } - steps { jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -30,8 +28,6 @@ pipeline { } steps { bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=%JDK_9_B181_HOME%' - } - steps { jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { From 5f70c371c6be09d5599b713490d9d1a77b3f809f Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 16 Aug 2017 00:42:22 +0200 Subject: [PATCH 118/194] Jenkinsfile --- Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2bc93a49f8..cfbe39474f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,9 @@ pipeline { } stages { stage('Unix Build') { + agent { + label env.NIX_LABEL + } tools { maven 'Maven 3.5.0' jdk 'JDK 1.8.0_144' @@ -13,7 +16,7 @@ pipeline { jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { - success { + always { junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' } } @@ -31,7 +34,7 @@ pipeline { jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { - success { + always { junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' } } From 3433f7f6f0e90842662809db9689612c6e330752 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 16 Aug 2017 01:20:17 +0200 Subject: [PATCH 119/194] Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cfbe39474f..755012514b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,7 @@ pipeline { jdk 'JDK 1.8.0_144' } steps { - sh 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=$JDK_9_B181_HOME' + sh 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=${env.JDK_9_B181_HOME}' jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -30,7 +30,7 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=%JDK_9_B181_HOME%' + bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=${env.JDK_9_B181_HOME}' jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { From 75bf01691e4a622c9ff68b861948377bf559c5d2 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 16 Aug 2017 01:30:54 +0200 Subject: [PATCH 120/194] Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 755012514b..db33ea1f8c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,7 @@ pipeline { jdk 'JDK 1.8.0_144' } steps { - sh 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=${env.JDK_9_B181_HOME}' + sh 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 "-Djdk.home=env.JDK_9_B181_HOME"' jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -30,7 +30,7 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=${env.JDK_9_B181_HOME}' + bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 "-Djdk.home=env.JDK_9_B181_HOME"' jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { From 08406add2f327048dffc0e6a7a034dc08af918c3 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 16 Aug 2017 01:45:29 +0200 Subject: [PATCH 121/194] Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index db33ea1f8c..66798b07f4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,7 @@ pipeline { jdk 'JDK 1.8.0_144' } steps { - sh 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 "-Djdk.home=env.JDK_9_B181_HOME"' + sh "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${env.JDK_9_B181_HOME}\\\"" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -30,7 +30,7 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat 'mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 "-Djdk.home=env.JDK_9_B181_HOME"' + bat "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${env.JDK_9_B181_HOME}\\\"" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { From 8d686d4d08705f232c3561e4fc7d543665d787f5 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 16 Aug 2017 02:15:35 +0200 Subject: [PATCH 122/194] Jenkinsfile --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 66798b07f4..8349577724 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,8 @@ pipeline { jdk 'JDK 1.8.0_144' } steps { - sh "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${env.JDK_9_B181_HOME}\\\"" + sh "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" + // \\\"-Djdk.home=${env.JDK_9_B181_HOME}\\\" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -30,7 +31,8 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${env.JDK_9_B181_HOME}\\\"" + bat "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" + // \\\"-Djdk.home=${env.JDK_9_B181_HOME}\\\" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { From cf90e5c1534f586b0dfc24d9b76664a2ea61aace Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 16 Aug 2017 21:58:48 +0200 Subject: [PATCH 123/194] Jenkinsfile --- Jenkinsfile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8349577724..335fa08704 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,9 +11,11 @@ pipeline { maven 'Maven 3.5.0' jdk 'JDK 1.8.0_144' } + environment { + JDK_9_HOME = tool('JDK_9_B181_HOME') + } steps { - sh "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" - // \\\"-Djdk.home=${env.JDK_9_B181_HOME}\\\" + sh "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${env.JDK_9_HOME}\\\"" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -31,8 +33,7 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" - // \\\"-Djdk.home=${env.JDK_9_B181_HOME}\\\" + bat "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${env.JDK_9_HOME}\\\"" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -42,4 +43,8 @@ pipeline { } } } + options { + buildDiscarder(logRotator(numToKeepStr:'3')) + timeout(time: 3, unit: 'HOURS') + } } From 0635d25e9d273c48196c1c9cb40eefc38393daba Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 21 Aug 2017 09:31:42 +0200 Subject: [PATCH 124/194] [Agreed with Oracle] [SUREFIRE-1403] [Jigsaw] [Java 9] add "--add-modules ALL-SYSTEM" to forked CLI argument --- .../maven/plugin/surefire/booterclient/ForkConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 b3b925188d..c962424756 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 @@ -168,11 +168,11 @@ OutputStreamFlushableCommandline createCommandLine( List classPath, bool { if ( jvmArgLine.isEmpty() ) { - jvmArgLine = "--add-modules ALL-SYSTEM"; + jvmArgLine = "--add-modules java.se.ee"; } else { - jvmArgLine = "--add-modules ALL-SYSTEM " + jvmArgLine; + jvmArgLine = "--add-modules java.se.ee " + jvmArgLine; } } From b61da31c81f2983cd4d381b62eb7d5fe4e0b67a7 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 21 Aug 2017 17:00:20 +0200 Subject: [PATCH 125/194] Jenkinsfile --- Jenkinsfile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 335fa08704..aee923e7b3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,11 +11,8 @@ pipeline { maven 'Maven 3.5.0' jdk 'JDK 1.8.0_144' } - environment { - JDK_9_HOME = tool('JDK_9_B181_HOME') - } steps { - sh "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${env.JDK_9_HOME}\\\"" + sh "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -33,7 +30,7 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${env.JDK_9_HOME}\\\"" + bat "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { From cbbc3194128fe476fa723c0842cf593bf3afcf13 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 21 Aug 2017 17:12:44 +0200 Subject: [PATCH 126/194] Jenkinsfile --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index aee923e7b3..602a8b9fad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,5 @@ pipeline { - agent { - label env.NIX_LABEL - } + agent none stages { stage('Unix Build') { agent { From 854c0772d2877b18e641918c83438e09fb074bdf Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 22 Aug 2017 03:35:09 +0200 Subject: [PATCH 127/194] Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 602a8b9fad..37991fc976 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { jdk 'JDK 1.8.0_144' } steps { - sh "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" + sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -28,7 +28,7 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat "mvn clean install jacoco:report -B -U -e -fae -V -Prun-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" + bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -40,6 +40,6 @@ pipeline { } options { buildDiscarder(logRotator(numToKeepStr:'3')) - timeout(time: 3, unit: 'HOURS') + timeout(time: 10, unit: 'HOURS') } } From 500a728073958bb23928eb8a64882d8a43a69616 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 22 Aug 2017 05:55:34 +0200 Subject: [PATCH 128/194] Jenkinsfile --- Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 37991fc976..218f16044f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,6 +10,7 @@ pipeline { jdk 'JDK 1.8.0_144' } steps { + checkout scm sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } @@ -28,7 +29,10 @@ pipeline { jdk 'JDK 1.8_121 (Windows Only)' } steps { - bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" + checkout scm + withEnv(["J9_HOME=${tool('JDK 9 b181')}"]) { + bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=%J9_HOME%" + } jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { From a5389cdc00082aa850f197b11776e6c84ee7806e Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 22 Aug 2017 08:42:32 +0200 Subject: [PATCH 129/194] Jenkinsfile --- Jenkinsfile | 76 ++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 218f16044f..0255a1cdc8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,45 +1,45 @@ pipeline { agent none stages { - stage('Unix Build') { - agent { - label env.NIX_LABEL - } - tools { - maven 'Maven 3.5.0' - jdk 'JDK 1.8.0_144' - } - steps { - checkout scm - sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" - jacoco changeBuildStatus: false, execPattern: '**/*.exec' - } - post { - always { - junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' + stage('Platforms') { + parallel( + 'Unix Build': { + node("${env.NIX_LABEL}") { + tools { + maven 'Maven 3.5.0' + jdk 'JDK 1.8.0_144' + } + steps { + checkout scm + sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" + jacoco changeBuildStatus: false, execPattern: '**/*.exec' + } + post { + always { + junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' + } + } + } + }, + 'Windows Build': { + node("${env.WIN_LABEL}") { + tools { + maven 'Maven 3.5.0 (Windows)' + jdk 'JDK 1.8_121 (Windows Only)' + } + steps { + checkout scm + bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 + jacoco changeBuildStatus: false, execPattern: '**/*.exec' + } + post { + always { + junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' + } + } + } } - } - } - stage('Windows Build') { - agent { - label env.WIN_LABEL - } - tools { - maven 'Maven 3.5.0 (Windows)' - jdk 'JDK 1.8_121 (Windows Only)' - } - steps { - checkout scm - withEnv(["J9_HOME=${tool('JDK 9 b181')}"]) { - bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 -Djdk.home=%J9_HOME%" - } - jacoco changeBuildStatus: false, execPattern: '**/*.exec' - } - post { - always { - junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' - } - } + ) } } options { From 514d042290ac9ee6d49d8848a338f979cb77fe6f Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 22 Aug 2017 08:44:18 +0200 Subject: [PATCH 130/194] Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0255a1cdc8..bbbfe9b11f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,7 +29,7 @@ pipeline { } steps { checkout scm - bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 + bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { From a93857e2dfd7bba7e17637bd69382ab9262169d8 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 22 Aug 2017 08:47:23 +0200 Subject: [PATCH 131/194] Jenkinsfile --- Jenkinsfile | 68 +++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bbbfe9b11f..22f053c7a6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,44 +2,46 @@ pipeline { agent none stages { stage('Platforms') { - parallel( - 'Unix Build': { - node("${env.NIX_LABEL}") { - tools { - maven 'Maven 3.5.0' - jdk 'JDK 1.8.0_144' - } - steps { - checkout scm - sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" - jacoco changeBuildStatus: false, execPattern: '**/*.exec' - } - post { - always { - junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' + steps { + parallel( + 'Unix Build': { + node("${env.NIX_LABEL}") { + tools { + maven 'Maven 3.5.0' + jdk 'JDK 1.8.0_144' + } + steps { + checkout scm + sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" + jacoco changeBuildStatus: false, execPattern: '**/*.exec' + } + post { + always { + junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' + } } } - } - }, - 'Windows Build': { - node("${env.WIN_LABEL}") { - tools { - maven 'Maven 3.5.0 (Windows)' - jdk 'JDK 1.8_121 (Windows Only)' - } - steps { - checkout scm - bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" - jacoco changeBuildStatus: false, execPattern: '**/*.exec' - } - post { - always { - junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' + }, + 'Windows Build': { + node("${env.WIN_LABEL}") { + tools { + maven 'Maven 3.5.0 (Windows)' + jdk 'JDK 1.8_121 (Windows Only)' + } + steps { + checkout scm + bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" + jacoco changeBuildStatus: false, execPattern: '**/*.exec' + } + post { + always { + junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' + } } } } - } - ) + ) + } } } options { From 200d286870b27063f700a1049ef1016cde8a490e Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 22 Aug 2017 09:00:22 +0200 Subject: [PATCH 132/194] Jenkinsfile --- Jenkinsfile | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 22f053c7a6..fa97b838ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,13 +6,11 @@ pipeline { parallel( 'Unix Build': { node("${env.NIX_LABEL}") { - tools { - maven 'Maven 3.5.0' - jdk 'JDK 1.8.0_144' - } steps { checkout scm - sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" + withEnv(["JAVA_HOME=${tool('JDK 1.8.0_144')}", "PATH+MAVEN=${tool('Maven 3.5.0')}/bin:${env.JAVA_HOME}/bin"]) { + sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" + } jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { @@ -24,13 +22,11 @@ pipeline { }, 'Windows Build': { node("${env.WIN_LABEL}") { - tools { - maven 'Maven 3.5.0 (Windows)' - jdk 'JDK 1.8_121 (Windows Only)' - } steps { checkout scm - bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" + withEnv(["JAVA_HOME=${tool('JDK 1.8_121 (Windows Only)')}", "PATH+MAVEN=${tool('Maven 3.5.0 (Windows)')}\\bin;${env.JAVA_HOME}\\bin"]) { + bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" + } jacoco changeBuildStatus: false, execPattern: '**/*.exec' } post { From 0399d7dd8bc2583ecc642ce5baa81992157cb23a Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 22 Aug 2017 09:10:05 +0200 Subject: [PATCH 133/194] Jenkinsfile --- Jenkinsfile | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fa97b838ad..15d459203d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,40 +6,35 @@ pipeline { parallel( 'Unix Build': { node("${env.NIX_LABEL}") { - steps { + stage('Unix') { checkout scm withEnv(["JAVA_HOME=${tool('JDK 1.8.0_144')}", "PATH+MAVEN=${tool('Maven 3.5.0')}/bin:${env.JAVA_HOME}/bin"]) { sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" } jacoco changeBuildStatus: false, execPattern: '**/*.exec' } - post { - always { - junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' - } - } } }, 'Windows Build': { node("${env.WIN_LABEL}") { - steps { + stage('Windows') { checkout scm withEnv(["JAVA_HOME=${tool('JDK 1.8_121 (Windows Only)')}", "PATH+MAVEN=${tool('Maven 3.5.0 (Windows)')}\\bin;${env.JAVA_HOME}\\bin"]) { bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" } jacoco changeBuildStatus: false, execPattern: '**/*.exec' } - post { - always { - junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' - } - } } } ) } } } + post { + always { + junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' + } + } options { buildDiscarder(logRotator(numToKeepStr:'3')) timeout(time: 10, unit: 'HOURS') From ea34d6a683a7516af4f820f1bcf01ba3da77b4c6 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Tue, 22 Aug 2017 09:31:29 +0200 Subject: [PATCH 134/194] Jenkinsfile --- Jenkinsfile | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 15d459203d..3740ec1917 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,24 +6,20 @@ pipeline { parallel( 'Unix Build': { node("${env.NIX_LABEL}") { - stage('Unix') { - checkout scm - withEnv(["JAVA_HOME=${tool('JDK 1.8.0_144')}", "PATH+MAVEN=${tool('Maven 3.5.0')}/bin:${env.JAVA_HOME}/bin"]) { - sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" - } - jacoco changeBuildStatus: false, execPattern: '**/*.exec' + checkout scm + withEnv(["JAVA_HOME=${tool('JDK 1.8.0_144')}", "PATH+MAVEN=${tool('Maven 3.5.0')}/bin:${env.JAVA_HOME}/bin"]) { + sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" } + jacoco changeBuildStatus: false, execPattern: '**/*.exec' } }, 'Windows Build': { node("${env.WIN_LABEL}") { - stage('Windows') { - checkout scm - withEnv(["JAVA_HOME=${tool('JDK 1.8_121 (Windows Only)')}", "PATH+MAVEN=${tool('Maven 3.5.0 (Windows)')}\\bin;${env.JAVA_HOME}\\bin"]) { - bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" - } - jacoco changeBuildStatus: false, execPattern: '**/*.exec' + checkout scm + withEnv(["JAVA_HOME=${tool('JDK 1.8_121 (Windows Only)')}", "PATH+MAVEN=${tool('Maven 3.5.0 (Windows)')}\\bin;${env.JAVA_HOME}\\bin"]) { + bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" } + jacoco changeBuildStatus: false, execPattern: '**/*.exec' } } ) From 0330f7bc9692498e207bafc0f306cf34d43b6883 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Wed, 23 Aug 2017 13:41:26 +0200 Subject: [PATCH 135/194] Jenkinsfile Working --- Jenkinsfile | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3740ec1917..fac148d46f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,36 +1,31 @@ pipeline { agent none stages { - stage('Platforms') { + stage('Parallel Unix and Windows Build') { steps { - parallel( - 'Unix Build': { - node("${env.NIX_LABEL}") { - checkout scm - withEnv(["JAVA_HOME=${tool('JDK 1.8.0_144')}", "PATH+MAVEN=${tool('Maven 3.5.0')}/bin:${env.JAVA_HOME}/bin"]) { - sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" - } - jacoco changeBuildStatus: false, execPattern: '**/*.exec' + parallel unix: { + node("${env.NIX_LABEL}") { + checkout scm + withEnv(["JAVA_HOME=${tool('JDK 1.8.0_144')}", "PATH+MAVEN=${tool('Maven 3.5.0')}/bin:${env.JAVA_HOME}/bin"]) { + sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" } - }, - 'Windows Build': { - node("${env.WIN_LABEL}") { - checkout scm - withEnv(["JAVA_HOME=${tool('JDK 1.8_121 (Windows Only)')}", "PATH+MAVEN=${tool('Maven 3.5.0 (Windows)')}\\bin;${env.JAVA_HOME}\\bin"]) { - bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" - } - jacoco changeBuildStatus: false, execPattern: '**/*.exec' + jacoco changeBuildStatus: false, execPattern: '**/*.exec' + junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' + } + }, + windows: { + node("${env.WIN_LABEL}") { + checkout scm + withEnv(["JAVA_HOME=${tool('JDK 1.8_121 (Windows Only)')}", "PATH+MAVEN=${tool('Maven 3.5.0 (Windows)')}\\bin;${env.JAVA_HOME}\\bin"]) { + bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" } + jacoco changeBuildStatus: false, execPattern: '**/*.exec' + junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' } - ) + } } } } - post { - always { - junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' - } - } options { buildDiscarder(logRotator(numToKeepStr:'3')) timeout(time: 10, unit: 'HOURS') From 99cd4f65f5f04ed8c98f446850f5f8bd7b98fc64 Mon Sep 17 00:00:00 2001 From: Jonathan Bell Date: Mon, 24 Jul 2017 23:43:36 -0400 Subject: [PATCH 136/194] [SUREFIRE-1396] Provider class path is incorrect for custom provider in Failsafe --- .../plugin/failsafe/IntegrationTestMojo.java | 9 +++ .../plugin/surefire/AbstractSurefireMojo.java | 6 +- .../maven/plugin/surefire/SurefirePlugin.java | 9 +++ ...Surefire1396CustomProviderClassPathIT.java | 52 +++++++++++++ .../pom.xml | 47 +++++++++++ .../testprovider/ClassPathTestProvider.java | 63 +++++++++++++++ ...aven.surefire.providerapi.SurefireProvider | 1 + .../pom.xml | 77 +++++++++++++++++++ .../test/java/pluggableproviders/EmptyIT.java | 26 +++++++ .../java/pluggableproviders/EmptyTest.java | 26 +++++++ 10 files changed, 313 insertions(+), 3 deletions(-) create mode 100644 surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/pom.xml create mode 100644 surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/src/main/java/org/apache/maven/surefire/testprovider/ClassPathTestProvider.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider create mode 100644 surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/pom.xml create mode 100644 surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/src/test/java/pluggableproviders/EmptyIT.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/src/test/java/pluggableproviders/EmptyTest.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 723a4a1e06..3474b164c8 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,6 +19,7 @@ * under the License. */ +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.surefire.AbstractSurefireMojo; @@ -36,6 +37,7 @@ import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.Map; import static org.apache.maven.plugin.failsafe.util.FailsafeSummaryXmlUtils.writeSummary; @@ -442,6 +444,13 @@ protected String getReportSchemaLocation() return "https://maven.apache.org/surefire/maven-failsafe-plugin/xsd/failsafe-test-report.xsd"; } + @Override + protected Artifact getMojoArtifact() + { + final Map pluginArtifactMap = getPluginArtifactMap(); + return pluginArtifactMap.get( "org.apache.maven.plugins:maven-failsafe-plugin" ); + } + @Override public boolean isSkipTests() { 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 047f7a44ba..29b44021dc 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 @@ -790,6 +790,8 @@ protected abstract void handleSummary( RunResult summary, Exception firstForkExc protected abstract String getReportSchemaLocation(); + protected abstract Artifact getMojoArtifact(); + private String getDefaultExcludes() { return "**/*$*"; @@ -2815,9 +2817,7 @@ public void addProviderProperties() throws MojoExecutionException public Classpath getProviderClasspath() throws ArtifactResolutionException, ArtifactNotFoundException { - final Map pluginArtifactMap = getPluginArtifactMap(); - Artifact plugin = pluginArtifactMap.get( "org.apache.maven.plugins:maven-surefire-plugin" ); - return dependencyResolver.addProviderToClasspath( pluginArtifactMap, plugin ); + return dependencyResolver.addProviderToClasspath( pluginArtifactMap, getMojoArtifact() ); } } 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 452cb81549..6873ad0d5e 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 @@ -23,6 +23,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -376,6 +378,13 @@ protected String getReportSchemaLocation() return "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd"; } + @Override + protected Artifact getMojoArtifact() + { + final Map pluginArtifactMap = getPluginArtifactMap(); + return pluginArtifactMap.get( "org.apache.maven.plugins:maven-surefire-plugin" ); + } + // now for the implementation of the field accessors @Override diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java new file mode 100644 index 0000000000..4a276882ff --- /dev/null +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java @@ -0,0 +1,52 @@ +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.SurefireJUnit4IntegrationTestCase; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Jonathan Bell + */ +public class Surefire1396CustomProviderClassPathIT + extends SurefireJUnit4IntegrationTestCase +{ + @BeforeClass + public static void installProvider() + throws VerificationException + { + unpack( Surefire1396CustomProviderClassPathIT.class, "surefire-1396-pluggableproviders-classpath-provider", "prov" ).executeInstall(); + } + + @Test + public void pluggableProviderClasspathCorrect() + throws Exception + { + unpack( "surefire-1396-pluggableproviders-classpath" ) + .setForkJvm() + .maven() + .showExceptionMessages() + .debugLogging() + .executeVerify() + .verifyErrorFreeLog(); + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/pom.xml new file mode 100644 index 0000000000..5d6da34f21 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/pom.xml @@ -0,0 +1,47 @@ + + + + 4.0.0 + + org.apache.maven.plugins.surefire + surefire-test-classpath-provider + 1.0-SNAPSHOT + Test provider + + + + org.apache.maven.surefire + surefire-api + ${surefire.version} + + + + + + + src/main/resources/META-INF + META-INF + + + + + + diff --git a/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/src/main/java/org/apache/maven/surefire/testprovider/ClassPathTestProvider.java b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/src/main/java/org/apache/maven/surefire/testprovider/ClassPathTestProvider.java new file mode 100644 index 0000000000..eeea39773b --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/src/main/java/org/apache/maven/surefire/testprovider/ClassPathTestProvider.java @@ -0,0 +1,63 @@ +package org.apache.maven.surefire.testprovider; + +/* + * 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.lang.reflect.InvocationTargetException; +import java.util.LinkedList; +import java.util.Map.Entry; + +import org.apache.maven.surefire.providerapi.AbstractProvider; +import org.apache.maven.surefire.providerapi.ProviderParameters; +import org.apache.maven.surefire.report.ReporterException; +import org.apache.maven.surefire.suite.RunResult; +import org.apache.maven.surefire.testset.TestSetFailedException; + +/** + * @author Jonathan Bell + */ +public class ClassPathTestProvider + extends AbstractProvider +{ + boolean hasSLF4J; // SLF4J is not being included in our deps, so if it's in the classpath, that's a problem... + + public ClassPathTestProvider( ProviderParameters params ) + { + for ( Entry propEntry : params.getProviderProperties().entrySet() ) + { + if ( propEntry.getKey().startsWith( "surefireClassPathUrl" ) && propEntry.getValue().contains( "slf4j" ) ) + hasSLF4J = true; + } + } + + public Iterable> getSuites() + { + LinkedList> ret = new LinkedList>(); + return ret; + } + + public RunResult invoke( Object arg0 ) + throws TestSetFailedException, ReporterException, InvocationTargetException + { + if ( hasSLF4J ) + throw new TestSetFailedException( "SLF4J was found on the boot classpath" ); + return new RunResult( 1, 0, 0, 0 ); + } + +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider new file mode 100644 index 0000000000..fd31063882 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath-provider/src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider @@ -0,0 +1 @@ +org.apache.maven.surefire.testprovider.ClassPathTestProvider diff --git a/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/pom.xml new file mode 100644 index 0000000000..1c441a83ac --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/pom.xml @@ -0,0 +1,77 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.surefire + pluggableproviders-classpath + 1.0-SNAPSHOT + pluggableproviders-classpath-test + + + + junit + junit + 4.8.1 + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + + org.apache.maven.plugins.surefire + surefire-test-classpath-provider + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${surefire.version} + + + + integration-test + verify + + + + + + org.apache.maven.plugins.surefire + surefire-test-classpath-provider + 1.0-SNAPSHOT + + + + + + + diff --git a/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/src/test/java/pluggableproviders/EmptyIT.java b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/src/test/java/pluggableproviders/EmptyIT.java new file mode 100644 index 0000000000..f7e2a7f611 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/src/test/java/pluggableproviders/EmptyIT.java @@ -0,0 +1,26 @@ +package pluggableproviders; + +/* + * 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. + */ + + +public class EmptyIT +{ + +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/src/test/java/pluggableproviders/EmptyTest.java b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/src/test/java/pluggableproviders/EmptyTest.java new file mode 100644 index 0000000000..4ac75c796b --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1396-pluggableproviders-classpath/src/test/java/pluggableproviders/EmptyTest.java @@ -0,0 +1,26 @@ +package pluggableproviders; + +/* + * 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. + */ + + +public class EmptyTest +{ + +} From c8724dd2f992625c355e4817a6b7995d3e88fdb4 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 28 Aug 2017 21:41:56 +0200 Subject: [PATCH 137/194] [SUREFIRE-1264] Some tests can be lost when running in parallel with parameterized tests --- .../internal/TestClassMethodNameUtils.java | 2 +- .../surefire/its/jiras/Surefire1264IT.java | 58 +++++ ...fire621TestCountingJunit3InParallelIT.java | 65 ++++- .../src/test/resources/surefire-1264/pom.xml | 52 ++++ .../core/surefireJunitTests/ATest.java | 33 +++ .../core/surefireJunitTests/BTest.java | 33 +++ .../core/surefireJunitTests/BaseTest.java | 52 ++++ .../core/surefireJunitTests/CTest.java | 33 +++ .../core/surefireJunitTests/DTest.java | 33 +++ .../pom.xml | 225 +++++++++++++++--- .../it/java/mho/JUnit4AdapterSuiteTest.java | 39 +++ .../common/junit4/JUnit4RunListener.java | 57 +++-- .../maven/surefire/junit4/MockReporter.java | 5 +- .../junitcore/ConcurrentRunListener.java | 2 +- .../junitcore/JUnitCoreRunListener.java | 63 ++--- .../maven/surefire/junitcore/TestSet.java | 22 +- .../junitcore/JUnitCoreRunListenerTest.java | 40 +++- .../surefire/junitcore/TestMethodTest.java | 5 +- 18 files changed, 701 insertions(+), 118 deletions(-) create mode 100644 surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1264/pom.xml create mode 100644 surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/ATest.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/BTest.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/BaseTest.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/CTest.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/DTest.java create mode 100644 surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/JUnit4AdapterSuiteTest.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 index ed7826916e..23e72e1011 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 @@ -51,6 +51,6 @@ public static String extractClassName( String displayName ) public static String extractMethodName( String displayName ) { Matcher m = METHOD_CLASS_PATTERN.matcher( displayName ); - return m.matches() ? m.group( 1 ) : null; + return m.matches() ? m.group( 1 ) : displayName; } } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java new file mode 100644 index 0000000000..bd9af176d3 --- /dev/null +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java @@ -0,0 +1,58 @@ +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.junit.Test; + +/** + * @author Tibor Digana (tibor17) + * @see SUREFIRE-1264 + * @since 2.20.1 + */ +public class Surefire1264IT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void positiveTests() + { + unpack( "surefire-1264" ) + .setForkJvm() + .parallelAll() + .useUnlimitedThreads() + .sysProp( "canFail", "false" ) + .executeTest() + .assertTestSuiteResults( 16, 0, 0, 0 ); + } + + @Test + public void negativeTests() + { + unpack( "surefire-1264" ) + .setForkJvm() + .parallelAll() + .useUnlimitedThreads() + .sysProp( "canFail", "true" ) + .mavenTestFailureIgnore( true ) + .executeTest() + .assertTestSuiteResults( 16, 0, 16, 0 ); + } +} diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire621TestCountingJunit3InParallelIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire621TestCountingJunit3InParallelIT.java index d67de4f945..a47b9d8952 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire621TestCountingJunit3InParallelIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire621TestCountingJunit3InParallelIT.java @@ -23,17 +23,76 @@ import org.junit.Test; /** - * SUREFIRE-621 Asserts proper test counts when running junit 3 tests in parallel + * SUREFIRE-621 Asserts proper test counts when running junit 3 tests in parallel
    + * SUREFIRE-1264 Some tests can be lost when running in parallel with parameterized tests
    + *
    + * Removed decision making with JUnit3 in {@code TestSet} class during Jira activity of SUREFIRE-1264 + * which results in one hot spot where the test class is determined (see JUnitCoreRunListener#fillTestCountMap()). * * @author Kristian Rosenvold + * @author Tibor Digana (tibor17) */ public class Surefire621TestCountingJunit3InParallelIT extends SurefireJUnit4IntegrationTestCase { + /** + * SUREFIRE-1264 + */ + @Test + public void testJunit3AllParallelBuildResultCount() + { + unpack( "surefire-621-testCounting-junit3-in-parallel" ) + .activateProfile( "all-parallel-junit3-testcases" ) + .execute( "integration-test" ) + .assertTestSuiteResults( 6, 0, 0, 0 ); + } + + /** + * SUREFIRE-621 + */ @Test public void testJunit3ParallelBuildResultCount() { - unpack( "surefire-621-testCounting-junit3-in-parallel" ).failNever().execute( - "install" ).assertTestSuiteResults( 6, 0, 0, 0 ); + unpack( "surefire-621-testCounting-junit3-in-parallel" ) + .failNever() + .activateProfile( "parallel-junit3-testcases" ) + .execute( "install" ) + .assertTestSuiteResults( 6, 0, 0, 0 ); + } + + /** + * SUREFIRE-1264 + */ + @Test + public void testJunit3BuildResultCount() + { + unpack( "surefire-621-testCounting-junit3-in-parallel" ) + .activateProfile( "junit3-testcases" ) + .execute( "integration-test" ) + .assertTestSuiteResults( 6, 0, 0, 0 ); + } + + /** + * SUREFIRE-1264 + */ + @Test + public void testJunit3ParallelSuiteBuildResultCount() + { + unpack( "surefire-621-testCounting-junit3-in-parallel" ) + .activateProfile( "parallel-junit3-testsuite" ) + .execute( "integration-test" ) + .assertTestSuiteResults( 6, 0, 0, 0 ); + } + + /** + * SUREFIRE-1264 + */ + @Test + public void testJunit3SuiteBuildResultCount() + { + unpack( "surefire-621-testCounting-junit3-in-parallel" ) + .activateProfile( "junit3-testsuite" ) + .execute( "integration-test" ) + .assertTestSuiteResults( 6, 0, 0, 0 ); } } \ No newline at end of file diff --git a/surefire-integration-tests/src/test/resources/surefire-1264/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1264/pom.xml new file mode 100644 index 0000000000..320401d232 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1264/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + + org.apache.maven.surefire + it-parent + 1.0 + ../pom.xml + + + com.appnexus.viewability.core.surefireJunitTests + main + 1.0.0 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + 2 + all + balanced + once + + ${canFail} + + + + + org.apache.maven.surefire + surefire-junit47 + ${surefire.version} + + + + + + + + + + junit + junit + 4.12 + test + + + diff --git a/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/ATest.java b/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/ATest.java new file mode 100644 index 0000000000..18c129e596 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/ATest.java @@ -0,0 +1,33 @@ +package com.appnexus.viewability.core.surefireJunitTests; + +import org.junit.Assert; +import org.junit.Test; + +public class ATest + extends BaseTest +{ + public ATest( String param ) + { + super( param ); + } + + @Test + public void methodA1() throws InterruptedException + { + sleep( 10 ); + if ( Boolean.getBoolean( "canFail" ) ) + { + Assert.fail( "Failing test: ATest.methodA1[" + param + "]" ); + } + } + + @Test + public void methodA2() throws InterruptedException + { + sleep( 10 ); + if ( Boolean.getBoolean( "canFail" ) ) + { + Assert.fail( "Failing test: ATest.methodA2[" + param + "]" ); + } + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/BTest.java b/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/BTest.java new file mode 100644 index 0000000000..3ebf05c048 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/BTest.java @@ -0,0 +1,33 @@ +package com.appnexus.viewability.core.surefireJunitTests; + +import org.junit.Assert; +import org.junit.Test; + +public class BTest + extends BaseTest +{ + public BTest( String param ) + { + super( param ); + } + + @Test + public void methodB1() throws InterruptedException + { + sleep( 10 ); + if ( Boolean.getBoolean( "canFail" ) ) + { + Assert.fail( "Failing test: BTest.methodB1[" + param + "]" ); + } + } + + @Test + public void methodB2() throws InterruptedException + { + sleep( 10 ); + if ( Boolean.getBoolean( "canFail" ) ) + { + Assert.fail( "Failing test: BTest.methodB2[" + param + "]" ); + } + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/BaseTest.java b/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/BaseTest.java new file mode 100644 index 0000000000..bff40778f8 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/BaseTest.java @@ -0,0 +1,52 @@ +package com.appnexus.viewability.core.surefireJunitTests; + +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.Collection; + +import org.junit.Rule; +import org.junit.rules.TestName; +import org.junit.runner.RunWith; + + +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + + +@RunWith( Parameterized.class ) +public abstract class BaseTest +{ + protected final String param; + + public BaseTest( String param ) + { + this.param = param; + } + + @Rule + public TestName testName = new TestName(); + + @Parameters( name = "{0}" ) + public static Collection< String > parameterList() throws Exception + { + Collection< String > c = new ConcurrentLinkedQueue< String >(); + c.add( "p0" ); + c.add( "p1" ); + + return c; + } + + public void sleep( int time ) + { + System.err.println( "Start: " + this.getClass().getSimpleName() + "." + testName.getMethodName() ); + try + { + Thread.sleep( time * 100 ); + } + catch ( InterruptedException e ) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.err.println( "End: " + this.getClass().getSimpleName() + "." + testName.getMethodName() ); + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/CTest.java b/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/CTest.java new file mode 100644 index 0000000000..3adb4ab43c --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/CTest.java @@ -0,0 +1,33 @@ +package com.appnexus.viewability.core.surefireJunitTests; + +import org.junit.Assert; +import org.junit.Test; + +public class CTest + extends BaseTest +{ + public CTest( String param ) + { + super( param ); + } + + @Test + public void methodC1() throws InterruptedException + { + sleep( 1 ); + if ( Boolean.getBoolean( "canFail" ) ) + { + Assert.fail( "Failing test: CTest.methodC1[" + param + "]" ); + } + } + + @Test + public void methodC2() throws InterruptedException + { + sleep( 1 ); + if ( Boolean.getBoolean( "canFail" ) ) + { + Assert.fail( "Failing test: CTest.methodC2[" + param + "]" ); + } + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/DTest.java b/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/DTest.java new file mode 100644 index 0000000000..38ed7b7630 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-1264/src/test/java/com/appnexus/viewability/core/surefireJunitTests/DTest.java @@ -0,0 +1,33 @@ +package com.appnexus.viewability.core.surefireJunitTests; + +import org.junit.Assert; +import org.junit.Test; + +public class DTest + extends BaseTest +{ + public DTest( String param ) + { + super( param ); + } + + @Test + public void methodC1() throws InterruptedException + { + sleep( 1 ); + if ( Boolean.getBoolean( "canFail" ) ) + { + Assert.fail( "Failing test: DTest.methodD1[" + param + "]" ); + } + } + + @Test + public void methodC2() throws InterruptedException + { + sleep( 1 ); + if ( Boolean.getBoolean( "canFail" ) ) + { + Assert.fail( "Failing test: DTest.methodD2[" + param + "]" ); + } + } +} diff --git a/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml b/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml index d6ed765411..ef9e6f355d 100644 --- a/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml @@ -8,7 +8,7 @@ junit-test http://maven.apache.org - 4.8.1 + 4.8.1 @@ -29,38 +29,197 @@ 1.5
    - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - true - classes - 10 - - - - surefire-it - integration-test - - test - - - false - - true - - **/MySuiteTest1.java - **/MySuiteTest2.java - **/MySuiteTest3.java - - - - once - - - -
    + + + + all-parallel-junit3-testcases + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + true + all + 10 + false + + + + surefire-it + integration-test + + test + + + false + true + + **/MySuiteTest1.java + **/MySuiteTest2.java + **/MySuiteTest3.java + + once + + + + + + + + + parallel-junit3-testcases + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + true + classes + 10 + + + + surefire-it + integration-test + + test + + + false + true + + **/MySuiteTest1.java + **/MySuiteTest2.java + **/MySuiteTest3.java + + once + + + + + + + + + junit3-testcases + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + true + + + + surefire-it + integration-test + + test + + + false + true + + **/MySuiteTest1.java + **/MySuiteTest2.java + **/MySuiteTest3.java + + once + + + + + + org.apache.maven.surefire + surefire-junit47 + ${surefire.version} + + + + + + + + parallel-junit3-testsuite + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + true + all + 10 + false + + + + surefire-it + integration-test + + test + + + false + true + + JUnit4AdapterSuiteTest + + once + + + + + + + + + junit3-testsuite + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + true + + + + surefire-it + integration-test + + test + + + false + true + + JUnit4AdapterSuiteTest + + once + + + + + + org.apache.maven.surefire + surefire-junit47 + ${surefire.version} + + + + + + + diff --git a/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/JUnit4AdapterSuiteTest.java b/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/JUnit4AdapterSuiteTest.java new file mode 100644 index 0000000000..47c2d75c58 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/JUnit4AdapterSuiteTest.java @@ -0,0 +1,39 @@ +package mho; + +/* + * 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 junit.framework.JUnit4TestAdapter; +import junit.framework.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@Suite.SuiteClasses( { + MySuiteTest1.class, + MySuiteTest2.class, + MySuiteTest3.class +} ) +@RunWith( Suite.class ) +public class JUnit4AdapterSuiteTest +{ + public static Test suite() + { + return new JUnit4TestAdapter( JUnit4AdapterSuiteTest.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 2a17bcba5c..7eec8569fc 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 @@ -86,8 +86,14 @@ public void testIgnored( Description description ) public void testStarted( Description description ) throws Exception { - reporter.testStarting( createReportEntry( description ) ); - failureFlag.remove(); + try + { + reporter.testStarting( createReportEntry( description ) ); + } + finally + { + failureFlag.remove(); + } } /** @@ -100,34 +106,47 @@ public void testStarted( Description description ) public void testFailure( Failure failure ) throws Exception { - String testHeader = failure.getTestHeader(); - if ( isInsaneJunitNullString( testHeader ) ) + try { - testHeader = "Failure when constructing test"; - } + String testHeader = failure.getTestHeader(); + if ( isInsaneJunitNullString( testHeader ) ) + { + testHeader = "Failure when constructing test"; + } - ReportEntry report = - withException( getClassName( failure.getDescription() ), testHeader, createStackTraceWriter( failure ) ); + String testClassName = getClassName( failure.getDescription() ); + StackTraceWriter stackTrace = createStackTraceWriter( failure ); - if ( failure.getException() instanceof AssertionError ) - { - reporter.testFailed( report ); + ReportEntry report = withException( testClassName, testHeader, stackTrace ); + + if ( failure.getException() instanceof AssertionError ) + { + reporter.testFailed( report ); + } + else + { + reporter.testError( report ); + } } - else + finally { - reporter.testError( report ); + failureFlag.set( true ); } - - failureFlag.set( true ); } @SuppressWarnings( "UnusedDeclaration" ) public void testAssumptionFailure( Failure failure ) { - Description desc = failure.getDescription(); - String test = getClassName( desc ); - reporter.testAssumptionFailure( assumption( test, desc.getDisplayName(), failure.getMessage() ) ); - failureFlag.set( true ); + try + { + Description desc = failure.getDescription(); + String test = getClassName( desc ); + reporter.testAssumptionFailure( assumption( test, desc.getDisplayName(), failure.getMessage() ) ); + } + finally + { + failureFlag.set( true ); + } } /** 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 9f3b6ff961..7561da71e7 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 @@ -79,7 +79,6 @@ public void testSucceeded( ReportEntry report ) { events.add( TEST_COMPLETED ); testSucceeded.incrementAndGet(); - } @Override @@ -126,4 +125,8 @@ public void testAssumptionFailure( ReportEntry report ) { } + public boolean containsNotification( String event ) + { + return events.contains( event ); + } } 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 a4f88dcf91..f687c38dac 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 @@ -184,7 +184,7 @@ private TestMethod getOrCreateThreadAttachedTestMethod( ReportEntry description protected abstract void checkIfTestSetCanBeReported( TestSet testSetForTest ); - TestSet getTestSet( ReportEntry description ) + private TestSet getTestSet( ReportEntry description ) { return classMethodCounts.get( description.getSourceName() ); } 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 4a187e4c0d..ae00fdbbaa 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 @@ -25,11 +25,8 @@ import org.apache.maven.surefire.report.StackTraceWriter; import org.junit.runner.Description; import org.junit.runner.Result; -import org.junit.runner.RunWith; import org.junit.runner.notification.Failure; -import org.junit.runners.Parameterized; -import java.lang.annotation.Annotation; import java.util.Map; /** @@ -73,60 +70,52 @@ public void testRunStarted( Description description ) public void testRunFinished( Result result ) throws Exception { - reporter.testSetCompleted( null ); + try + { + reporter.testSetCompleted( null ); + } + finally + { + classMethodCounts.clear(); + } } private void fillTestCountMap( Description testDesc ) { - TestSet testSet = new TestSet( testDesc ); - - String itemTestClassName = - isParameterizedRunner( testDesc ) ? testDesc.getClassName() : asSuiteRunner( testDesc, testSet ); - - if ( itemTestClassName != null ) + for ( Description child : testDesc.getChildren() ) { - classMethodCounts.put( itemTestClassName, testSet ); + if ( !asTestLeaf( child ) ) + { + fillTestCountMap( child ); + } } } - private String asSuiteRunner( Description description, TestSet testSet ) + private boolean asTestLeaf( Description description ) { - String itemTestClassName = null; - for ( Description child : description.getChildren() ) + if ( description.isTest() ) { - if ( !child.isTest() ) + final String testClassName = extractDescriptionClassName( description ); + if ( testClassName != null ) { - fillTestCountMap( child ); - } - else - { - if ( extractDescriptionMethodName( child ) != null ) + final TestSet testSet; + if ( classMethodCounts.containsKey( testClassName ) ) { - testSet.incrementTestMethodCount(); - if ( itemTestClassName == null ) - { - itemTestClassName = extractDescriptionClassName( child ); - } + testSet = classMethodCounts.get( testClassName ); } else { - classMethodCounts.put( extractDescriptionClassName( child ), new TestSet( child ) ); + testSet = new TestSet( testClassName ); + classMethodCounts.put( testClassName, testSet ); } + testSet.incrementTestMethodCount(); } + return true; } - return itemTestClassName; - } - - private static boolean isParameterizedRunner( Description description ) - { - for ( Annotation ann : description.getAnnotations() ) + else { - if ( ann.annotationType() == RunWith.class ) - { - return Parameterized.class.isAssignableFrom( ( (RunWith) ann ).value() ); - } + return false; } - return false; } @Override diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java index 0f05327325..9371b51912 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java @@ -23,11 +23,9 @@ import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; import org.apache.maven.surefire.report.TestSetReportEntry; -import org.junit.runner.Description; import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; @@ -42,7 +40,7 @@ public class TestSet { private static final InheritableThreadLocal TEST_SET = new InheritableThreadLocal(); - private final Description testSetDescription; + private final String testClassName; private final Collection testMethods = new ConcurrentLinkedQueue(); @@ -57,9 +55,9 @@ public class TestSet private volatile boolean allScheduled; - public TestSet( Description testSetDescription ) + public TestSet( String testClassName ) { - this.testSetDescription = testSetDescription; + this.testClassName = testClassName; } public void replay( RunListener target ) @@ -122,19 +120,7 @@ private TestSetReportEntry createReportEntryCompleted( int elapsed ) private TestSetReportEntry createReportEntry( Integer elapsed, Map systemProps ) { - final String className = testSetDescription.getClassName(); - final boolean isJunit3 = className == null; - final String classNameToUse; - if ( isJunit3 ) - { - List children = testSetDescription.getChildren(); - classNameToUse = children.isEmpty() ? testSetDescription.toString() : children.get( 0 ).getClassName(); - } - else - { - classNameToUse = className; - } - return new SimpleReportEntry( classNameToUse, classNameToUse, null, elapsed, systemProps ); + return new SimpleReportEntry( testClassName, testClassName, null, elapsed, systemProps ); } public void incrementTestMethodCount() diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java index 9d3d4c11ac..c5b6c896f8 100644 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java +++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java @@ -33,6 +33,9 @@ import org.junit.runner.Result; import org.junit.runner.notification.RunListener; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; + /** * @author Kristian Rosenvold */ @@ -81,7 +84,6 @@ public void testStateForClassesWithNoChildren() assertEquals( 2, classMethodCounts.size() ); Iterator iterator = classMethodCounts.values().iterator(); assertFalse(iterator.next().equals( iterator.next() )); - } public void testTestClassNotLoadableFromJUnitClassLoader() @@ -104,6 +106,42 @@ public void testTestClassNotLoadableFromJUnitClassLoader() assertNotNull( testSet ); } + public void testNonEmptyTestRunStarted() throws Exception + { + Description aggregator = Description.createSuiteDescription( "null" ); + Description suite = Description.createSuiteDescription( "some.junit.Test" ); + suite.addChild( Description.createSuiteDescription( "testMethodA(some.junit.Test)" ) ); + suite.addChild( Description.createSuiteDescription( "testMethodB(some.junit.Test)" ) ); + suite.addChild( Description.createSuiteDescription( "testMethod(another.junit.Test)" ) ); + aggregator.addChild( suite ); + Map classMethodCounts = new HashMap(); + JUnitCoreRunListener listener = new JUnitCoreRunListener( new MockReporter(), classMethodCounts ); + listener.testRunStarted( aggregator ); + assertThat( classMethodCounts.keySet(), hasSize( 2 ) ); + assertThat( classMethodCounts.keySet(), containsInAnyOrder( "some.junit.Test", "another.junit.Test" ) ); + TestSet testSet = classMethodCounts.get( "some.junit.Test" ); + MockReporter reporter = new MockReporter(); + testSet.replay( reporter ); + assertTrue( reporter.containsNotification( MockReporter.SET_STARTED ) ); + assertTrue( reporter.containsNotification( MockReporter.SET_COMPLETED ) ); + listener.testRunFinished( null ); + assertThat( classMethodCounts.keySet(), empty() ); + } + + public void testEmptySuiteTestRunStarted() throws Exception + { + Description aggregator = Description.createSuiteDescription( "null" ); + Description suite = Description.createSuiteDescription( "some.junit.TestSuite" ); + aggregator.addChild( suite ); + Map classMethodCounts = new HashMap(); + JUnitCoreRunListener listener = new JUnitCoreRunListener( new MockReporter(), classMethodCounts ); + listener.testRunStarted( aggregator ); + assertThat( classMethodCounts.keySet(), hasSize( 1 ) ); + assertThat( classMethodCounts.keySet(), contains( "some.junit.TestSuite" ) ); + listener.testRunFinished( null ); + assertThat( classMethodCounts.keySet(), empty() ); + } + public static class STest1 { @Test diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestMethodTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestMethodTest.java index efb40b3cd2..cb503585f4 100644 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestMethodTest.java +++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestMethodTest.java @@ -23,7 +23,6 @@ import org.apache.maven.surefire.report.SimpleReportEntry; import junit.framework.TestCase; -import org.junit.runner.Description; /** * @author Kristian Rosenvold @@ -32,11 +31,9 @@ public class TestMethodTest extends TestCase { public void testTestFailure() - throws Exception { ReportEntry reportEntry = new SimpleReportEntry( "a", "b" ); - TestMethod testMethod = new TestMethod( reportEntry, new TestSet( - Description.createTestDescription( TestMethodTest.class, "testeEthodTest" ) ) ); + TestMethod testMethod = new TestMethod( reportEntry, new TestSet( TestMethodTest.class.getName() ) ); testMethod.testFailure( reportEntry ); final int elapsed = testMethod.getElapsed(); assertTrue( elapsed >= 0 ); From be6d658d0b00b0fbd0fbbc719f96a46992293b56 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 2 Sep 2017 02:37:38 +0200 Subject: [PATCH 138/194] Jenkinsfile JaCoCo --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fac148d46f..568075fcd5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { withEnv(["JAVA_HOME=${tool('JDK 1.8.0_144')}", "PATH+MAVEN=${tool('Maven 3.5.0')}/bin:${env.JAVA_HOME}/bin"]) { sh "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084 \\\"-Djdk.home=${tool('JDK 9 b181')}\\\"" } - jacoco changeBuildStatus: false, execPattern: '**/*.exec' + jacoco changeBuildStatus: false, execPattern: '**/*.exec', sourcePattern: '**/src/main/java', exclusionPattern: 'pkg/*.class,plexusConflict/*.class,**/surefire570/**/*.class,siblingAggregator/*.class,surefire257/*.class,surefire979/*.class,org/apache/maven/surefire/crb/*.class,org/apache/maven/plugins/surefire/selfdestruct/*.class,org/apache/maven/plugins/surefire/dumppid/*.class,org/apache/maven/plugin/surefire/*.class,org/apache/maven/plugin/failsafe/*.class,jiras/**/*.class,org/apache/maven/surefire/testng/*.class,org/apache/maven/surefire/testprovider/*.class,**/test/*.class,**/org/apache/maven/surefire/group/parse/*.class' junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' } }, @@ -19,7 +19,7 @@ pipeline { withEnv(["JAVA_HOME=${tool('JDK 1.8_121 (Windows Only)')}", "PATH+MAVEN=${tool('Maven 3.5.0 (Windows)')}\\bin;${env.JAVA_HOME}\\bin"]) { bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" } - jacoco changeBuildStatus: false, execPattern: '**/*.exec' + jacoco changeBuildStatus: false, execPattern: '**/*.exec', sourcePattern: '**/src/main/java', exclusionPattern: 'pkg/*.class,plexusConflict/*.class,**/surefire570/**/*.class,siblingAggregator/*.class,surefire257/*.class,surefire979/*.class,org/apache/maven/surefire/crb/*.class,org/apache/maven/plugins/surefire/selfdestruct/*.class,org/apache/maven/plugins/surefire/dumppid/*.class,org/apache/maven/plugin/surefire/*.class,org/apache/maven/plugin/failsafe/*.class,jiras/**/*.class,org/apache/maven/surefire/testng/*.class,org/apache/maven/surefire/testprovider/*.class,**/test/*.class,**/org/apache/maven/surefire/group/parse/*.class' junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' } } From 7af0a0a23ae5a35f4157b83dc2b2b129537537c3 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 3 Sep 2017 02:44:23 +0200 Subject: [PATCH 139/194] README.md updated to new Jenkins Pipeline and Jenkinsfile --- Jenkinsfile | 2 -- README.md | 13 +++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 568075fcd5..b3ace123d2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,8 +19,6 @@ pipeline { withEnv(["JAVA_HOME=${tool('JDK 1.8_121 (Windows Only)')}", "PATH+MAVEN=${tool('Maven 3.5.0 (Windows)')}\\bin;${env.JAVA_HOME}\\bin"]) { bat "mvn clean install jacoco:report -B -U -e -fae -V -P run-its,jenkins -Dsurefire.useFile=false -Dfailsafe.useFile=false -Dintegration-test-port=8084" } - jacoco changeBuildStatus: false, execPattern: '**/*.exec', sourcePattern: '**/src/main/java', exclusionPattern: 'pkg/*.class,plexusConflict/*.class,**/surefire570/**/*.class,siblingAggregator/*.class,surefire257/*.class,surefire979/*.class,org/apache/maven/surefire/crb/*.class,org/apache/maven/plugins/surefire/selfdestruct/*.class,org/apache/maven/plugins/surefire/dumppid/*.class,org/apache/maven/plugin/surefire/*.class,org/apache/maven/plugin/failsafe/*.class,jiras/**/*.class,org/apache/maven/surefire/testng/*.class,org/apache/maven/surefire/testprovider/*.class,**/test/*.class,**/org/apache/maven/surefire/group/parse/*.class' - junit healthScaleFactor: 0.0, allowEmptyResults: true, keepLongStdio: true, testResults: '**/surefire-integration-tests/target/failsafe-reports/**/*.xml,**/surefire-integration-tests/target/surefire-reports/**/*.xml,**/maven-*/target/surefire-reports/**/*.xml,**/surefire-*/target/surefire-reports/**/*.xml,**/common-*/target/surefire-reports/**/*.xml' } } } diff --git a/README.md b/README.md index 20fef40b7b..2361f5d012 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ [![Built with Maven](http://maven.apache.org/images/logos/maven-feather.png)](https://maven.apache.org/surefire/) [![CI](https://img.shields.io/badge/CI-Jenkins-red.svg?style=flat-square)](https://jenkins-ci.org/) +[![forks](https://img.shields.io/github/forks/apache/maven-surefire.svg?style=social&label=Fork)](https://github.com/apache/maven-surefire/) + +# The Maven Community + [![chat](https://www.irccloud.com/invite-svg?channel=maven&hostname=irc.freenode.net&port=6697&ssl=1)](https://maven.apache.org/community.html) [Join us @ irc://freenode/maven] or [Webchat with us @channel maven] # Release Notes @@ -8,8 +12,6 @@ [JIRA Change Log] -[![tag](http://img.shields.io/github/tag/apache/maven-surefire.svg)](https://github.com/apache/maven-surefire/releases/tag/surefire-2.20) - Usage of [maven-surefire-plugin], [maven-failsafe-plugin], [maven-surefire-report-plugin]. # Project Documentation @@ -20,7 +22,7 @@ Usage of [maven-surefire-plugin], [maven-failsafe-plugin], [maven-surefire-repor [![dependencies](https://www.versioneye.com/java/org.apache.maven.plugins:maven-surefire-plugin/badge.svg?style=plastic)](https://builds.apache.org/job/maven-surefire/depgraph-view/) Maven 2.2.1 Plugin API -[![license](http://img.shields.io/:license-apache-red.svg?style=plastic)](http://www.apache.org/licenses/LICENSE-2.0.html) [![coverage](https://img.shields.io/jenkins/c/https/builds.apache.org/maven-surefire.svg?style=plastic)](https://builds.apache.org/job/maven-surefire/jacoco/) [![tests](https://img.shields.io/jenkins/t/https/builds.apache.org/maven-surefire.svg?style=plastic)](https://builds.apache.org/job/maven-surefire/lastBuild/testReport/) [![Build Status](https://builds.apache.org/job/maven-surefire/badge/icon?style=plastic)](https://builds.apache.org/job/maven-surefire) [![Build Status](https://builds.apache.org/job/maven-surefire-windows/badge/icon?style=plastic)](https://builds.apache.org/job/maven-surefire-windows) +[![license](http://img.shields.io/:license-apache-red.svg?style=plastic)](http://www.apache.org/licenses/LICENSE-2.0.html) [![tests](https://img.shields.io/jenkins/t/https/builds.apache.org/view/M-R/view/Maven/job/maven-surefire-pipeline/job/master.svg?style=plastic)](https://builds.apache.org/view/M-R/view/Maven/job/maven-surefire-pipeline/job/master/lastBuild/testReport/) [![Build Status](https://builds.apache.org/view/M-R/view/Maven/job/maven-surefire-pipeline/job/master/badge/icon?style=plastic)](https://builds.apache.org/view/M-R/view/Maven/job/maven-surefire-pipeline/job/master/) # Development Information @@ -34,10 +36,9 @@ But in order to run IT tests, you can do: * In order to run the build with **JDK 9** **on Windows** (**on Linux/Unix modify system property jdk.home**): *mvn install site site:stage -P reporting,run-its "-Djdk.home=e:\Program Files\Java\jdk9\"* -Deploying web site ------------------- +### Deploying web site -see http://maven.apache.org/developers/website/deploy-component-reference-documentation.html +See http://maven.apache.org/developers/website/deploy-component-reference-documentation.html [Join us @ irc://freenode/maven]: https://www.irccloud.com/invite?channel=maven&hostname=irc.freenode.net&port=6697&ssl=1 [Webchat with us @channel maven]: http://webchat.freenode.net/?channels=%23maven From 100f696029a53d57dbacd0f3962f3c305891588c Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sun, 3 Sep 2017 20:44:04 +0200 Subject: [PATCH 140/194] [Agreed with Oracle] [SUREFIRE-1403] [DOC] [Jigsaw] [Java 9] add "--add-modules ALL-SYSTEM" to forked CLI argument --- maven-surefire-plugin/src/site/markdown/java9.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-surefire-plugin/src/site/markdown/java9.md b/maven-surefire-plugin/src/site/markdown/java9.md index 96bc9a8e90..e0f758f3f0 100644 --- a/maven-surefire-plugin/src/site/markdown/java9.md +++ b/maven-surefire-plugin/src/site/markdown/java9.md @@ -23,7 +23,7 @@ Java 9 in JAVA_HOME $ export JAVA_HOME=/path/to/jdk9 $ mvn test -The plugin will automatically add `--add-modules ALL-SYSTEM` on JVM argument in CLI (unless already specified by user) +The plugin will automatically add `--add-modules java.se.ee` on JVM argument in CLI (unless already specified by user) and all Java 9 API is provided to run your tests. From 67c06d5876dcabc037de9b5f4cc226beeedcb379 Mon Sep 17 00:00:00 2001 From: Fedor Bobin Date: Tue, 12 Jul 2016 15:10:37 +0300 Subject: [PATCH 141/194] [SUREFIRE-1409] Parallel runner should not drop away runners that have zero children. --- .../junitcore/pc/ParallelComputerBuilder.java | 5 +- .../pc/ParallelComputerBuilderTest.java | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+), 4 deletions(-) mode change 100644 => 100755 surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java mode change 100644 => 100755 surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java old mode 100644 new mode 100755 index 92ee18c547..fd0cab3ad2 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java @@ -429,10 +429,7 @@ private WrappedRunners wrapRunners( Collection runners ) { int children = countChildren( runner ); childrenCounter += children; - if ( children != 0 ) - { - runs.add( runner ); - } + runs.add( runner ); } } return runs.isEmpty() ? new WrappedRunners() : new WrappedRunners( createSuite( runs ), childrenCounter ); 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 old mode 100644 new mode 100755 index bef7bafa4e..212e157e7f --- 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 @@ -33,7 +33,10 @@ import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.RunWith; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.ParentRunner; import org.junit.runners.Suite; +import org.junit.runners.model.InitializationError; import java.util.ArrayList; import java.util.Arrays; @@ -42,6 +45,7 @@ import java.util.Comparator; import java.util.Date; import java.util.Iterator; +import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.TimeUnit; @@ -104,6 +108,15 @@ public void beforeTest() throws InterruptedException { Thread.sleep( 50L ); } + @Test + public void testsWithoutChildrenShouldAlsoBeRun() + { + ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder( logger ); + ParallelComputerBuilder.PC computer = ( ParallelComputerBuilder.PC ) parallelComputerBuilder.buildComputer(); + Result result = new JUnitCore().run( computer, TestWithoutPrecalculatedChildren.class ); + assertThat( result.getRunCount(), is( 1 ) ); + } + @Test public void parallelMethodsReuseOneOrTwoThreads() { @@ -689,6 +702,61 @@ public static class TestSuite { } + public static class Test2 + { + @Test + public void test() + { + + } + } + + @RunWith( ReportOneTestAtRuntimeRunner.class ) + public static class TestWithoutPrecalculatedChildren {} + + public static class ReportOneTestAtRuntimeRunner + extends ParentRunner + { + private final Class testClass; + private final Description suiteDescription; + private Description myTestMethodDescr; + + public ReportOneTestAtRuntimeRunner( Class testClass ) throws InitializationError + { + super( Object.class ); + this.testClass = testClass; + suiteDescription = Description.createSuiteDescription( testClass ); + myTestMethodDescr = Description.createTestDescription( testClass, "my_test" ); +// suiteDescription.addChild(myTestMethodDescr); // let it be not known at start time + } + + protected List getChildren() + { + throw new UnsupportedOperationException( "workflow from ParentRunner not supported" ); + } + + protected Description describeChild( Object child ) + { + throw new UnsupportedOperationException( "workflow from ParentRunner not supported" ); + } + + protected void runChild( Object child, RunNotifier notifier ) + { + throw new UnsupportedOperationException( "workflow from ParentRunner not supported" ); + } + + public Description getDescription() + { + return suiteDescription; + } + + public void run( RunNotifier notifier ) + { + notifier.fireTestStarted( myTestMethodDescr ); + notifier.fireTestFinished( Description.createTestDescription( testClass, "my_test" ) ); + } + } + @NotThreadSafe public static class NotThreadSafeTest1 { From ead22a3d399a5fd608ebae90a079644ab786eae8 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 9 Sep 2017 11:46:17 +0200 Subject: [PATCH 142/194] [SUREFIRE-1410] Add FAQ and improve Warning message when native stream in forked JVM is corrupted --- .../surefire/booterclient/ForkStarter.java | 15 ++++--- .../booterclient/output/ForkClient.java | 44 ++++++++++++++----- .../booterclient/ForkingRunListenerTest.java | 14 +++--- maven-surefire-plugin/src/site/fml/faq.fml | 19 ++++++++ 4 files changed, 70 insertions(+), 22 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 2d828554e0..3efbd57319 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 @@ -69,6 +69,7 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import static java.lang.StrictMath.min; @@ -269,7 +270,8 @@ private RunResult run( SurefireProperties effectiveSystemProperties, Map ping = triggerPingTimerForShutdown( builder ); try @@ -334,7 +336,8 @@ private RunResult runSuitesForkOnceMultiple( final SurefireProperties effectiveS addShutDownHook( shutdown ); int failFastCount = providerConfiguration.getSkipAfterFailureCount(); final AtomicInteger notifyStreamsToSkipTestsJustNow = new AtomicInteger( failFastCount ); - Collection> results = new ArrayList>( forkCount ); + final Collection> results = new ArrayList>( forkCount ); + final AtomicBoolean printedErrorStream = new AtomicBoolean(); for ( final TestProvidingInputStream testProvidingInputStream : testStreams ) { Callable pf = new Callable() @@ -345,7 +348,8 @@ public RunResult call() { DefaultReporterFactory reporter = new DefaultReporterFactory( startupReportConfiguration, log ); defaultReporterFactories.add( reporter ); - ForkClient forkClient = new ForkClient( reporter, testProvidingInputStream, log ) + ForkClient forkClient = new ForkClient( reporter, testProvidingInputStream, log, + forkConfiguration.isDebug(), printedErrorStream ) { @Override protected void stopOnNextTest() @@ -397,6 +401,7 @@ private RunResult runSuitesForkPerTestSet( final SurefireProperties effectiveSys addShutDownHook( shutdown ); int failFastCount = providerConfiguration.getSkipAfterFailureCount(); final AtomicInteger notifyStreamsToSkipTestsJustNow = new AtomicInteger( failFastCount ); + final AtomicBoolean printedErrorStream = new AtomicBoolean(); for ( final Object testSet : getSuitesIterator() ) { Callable pf = new Callable() @@ -408,8 +413,8 @@ public RunResult call() DefaultReporterFactory forkedReporterFactory = new DefaultReporterFactory( startupReportConfiguration, log ); defaultReporterFactories.add( forkedReporterFactory ); - ForkClient forkClient = - new ForkClient( forkedReporterFactory, builder.getImmediateCommands(), log ) + ForkClient forkClient = new ForkClient( forkedReporterFactory, builder.getImmediateCommands(), + log, forkConfiguration.isDebug(), printedErrorStream ) { @Override protected void stopOnNextTest() 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 17da4df093..bebc949163 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 @@ -42,6 +42,7 @@ import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import static java.lang.Integer.decode; @@ -101,23 +102,35 @@ public class ForkClient private final ConsoleLogger log; + private final boolean debug; + + /** + * prevents from printing same warning + */ + private final AtomicBoolean printedErrorStream; + + /** + * Used by single Thread started by {@link ThreadedStreamConsumer} and therefore does not need to be volatile. + */ private RunListener testSetReporter; + /** + * Written by one Thread and read by another: Main Thread and ForkStarter's Thread. + */ private volatile boolean saidGoodBye; private volatile StackTraceWriter errorInFork; private volatile int forkNumber; - // prevents from printing same warning - private boolean printedErrorStream; - - public ForkClient( DefaultReporterFactory defaultReporterFactory, - NotifiableTestStream notifiableTestStream, ConsoleLogger log ) + public ForkClient( DefaultReporterFactory defaultReporterFactory, NotifiableTestStream notifiableTestStream, + ConsoleLogger log, boolean debug, AtomicBoolean printedErrorStream ) { this.defaultReporterFactory = defaultReporterFactory; this.notifiableTestStream = notifiableTestStream; this.log = log; + this.debug = debug; + this.printedErrorStream = printedErrorStream; } protected void stopOnNextTest() @@ -304,18 +317,27 @@ private void logStreamWarning( Throwable e, String event ) { 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 = + String msg = "Corrupted STDOUT by directly writing to native stream in forked JVM " + forkNumber + "."; + + InPluginProcessDumpSingleton util = InPluginProcessDumpSingleton.getSingleton(); + File dump = e == null ? util.dumpText( msg + " Stream '" + event + "'.", defaultReporterFactory, forkNumber ) : util.dumpException( e, msg + " Stream '" + event + "'.", defaultReporterFactory, forkNumber ); - if ( !printedErrorStream ) + if ( printedErrorStream.compareAndSet( false, true ) ) { - printedErrorStream = true; - log.warning( msg + " See the dump file " + dump.getAbsolutePath() ); + log.warning( msg + " See FAQ web page and the dump file " + dump.getAbsolutePath() ); } + + if ( debug && event != null ) + { + log.debug( event ); + } + } + else if ( debug ) + { + log.debug( event ); } else { 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 12b20872c6..f7406ded67 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 @@ -222,7 +222,8 @@ public void testSystemProperties() TestSetMockReporterFactory providerReporterFactory = new TestSetMockReporterFactory(); NullConsoleLogger log = new NullConsoleLogger(); - ForkClient forkStreamClient = new ForkClient( providerReporterFactory, new MockNotifiableTestStream(), log ); + ForkClient forkStreamClient = + new ForkClient( providerReporterFactory, new MockNotifiableTestStream(), log, false, null ); forkStreamClient.consumeMultiLineContent( content.toString( "UTF-8" ) ); @@ -246,7 +247,8 @@ public void testMultipleEntries() TestSetMockReporterFactory providerReporterFactory = new TestSetMockReporterFactory(); NullConsoleLogger log = new NullConsoleLogger(); - ForkClient forkStreamClient = new ForkClient( providerReporterFactory, new MockNotifiableTestStream(), log ); + ForkClient forkStreamClient = + new ForkClient( providerReporterFactory, new MockNotifiableTestStream(), log, false, null ); forkStreamClient.consumeMultiLineContent( content.toString( "UTF-8" ) ); @@ -275,7 +277,7 @@ public void test2DifferentChannels() NotifiableTestStream notifiableTestStream = new MockNotifiableTestStream(); NullConsoleLogger log = new NullConsoleLogger(); - ForkClient forkStreamClient = new ForkClient( providerReporterFactory, notifiableTestStream, log ); + ForkClient forkStreamClient = new ForkClient( providerReporterFactory, notifiableTestStream, log, false, null ); forkStreamClient.consumeMultiLineContent( content.toString( "UTF-8" ) ); MockReporter reporter = (MockReporter) forkStreamClient.getReporter(); @@ -283,7 +285,7 @@ public void test2DifferentChannels() Assert.assertEquals( expected, reporter.getFirstData() ); Assert.assertEquals( 1, reporter.getEvents().size() ); - forkStreamClient = new ForkClient( providerReporterFactory, notifiableTestStream, log ); + forkStreamClient = new ForkClient( providerReporterFactory, notifiableTestStream, log, false, null ); forkStreamClient.consumeMultiLineContent( anotherContent.toString( "UTF-8" ) ); MockReporter reporter2 = (MockReporter) forkStreamClient.getReporter(); Assert.assertEquals( MockReporter.TEST_SKIPPED, reporter2.getFirstEvent() ); @@ -352,8 +354,8 @@ public void clientReceiveContent() { TestSetMockReporterFactory providerReporterFactory = new TestSetMockReporterFactory(); NullConsoleLogger log = new NullConsoleLogger(); - final ForkClient forkStreamClient = new ForkClient( providerReporterFactory, - new MockNotifiableTestStream(), log ); + final ForkClient forkStreamClient = + new ForkClient( providerReporterFactory, new MockNotifiableTestStream(), log, false, null ); forkStreamClient.consumeMultiLineContent( content.toString( ) ); reporter = (MockReporter) forkStreamClient.getReporter(); } diff --git a/maven-surefire-plugin/src/site/fml/faq.fml b/maven-surefire-plugin/src/site/fml/faq.fml index bc39ddc7af..b73dde63b2 100644 --- a/maven-surefire-plugin/src/site/fml/faq.fml +++ b/maven-surefire-plugin/src/site/fml/faq.fml @@ -137,5 +137,24 @@ under the License.

    + + Corrupted STDOUT by directly writing to native stream in forked JVM + +

    + If your tests use native library which prints to STDOUT this warning message appears because the library + corrupted the channel used by the plugin in order to transmit events with test status back to Maven process. + It would be even worse if you override the Java stream by System.setOut because the stream is also + supposed to be corrupted but the Maven will never see the tests finished and build may hang. +
    + This warning message appears if you use FileDescriptor.out or JVM prints GC summary. +
    + In that case the warning is printed + "Corrupted STDOUT by directly writing to native stream in forked JVM", and a dump file can be found + in Reports directory. +
    + If debug level is enabled then messages of corrupted stream appear in the console. +

    +
    +
    From 8a63486f8efc721d0003cb5685e590a98369704a Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 9 Sep 2017 13:20:46 +0200 Subject: [PATCH 143/194] [SUREFIRE-1411] Improve calls String.length == 0 to Java 1.6 call String.isEmpty --- .../maven/plugin/surefire/AbstractSurefireMojo.java | 4 ++-- .../plugin/surefire/report/StatelessXmlReporter.java | 4 ++-- .../plugin/surefire/report/WrappedReportEntry.java | 2 +- .../maven/plugin/surefire/util/FileScanner.java | 6 +++--- .../maven/surefire/booter/ForkingRunListener.java | 2 +- .../maven/surefire/testset/TestListResolver.java | 12 ++++++------ .../maven/surefire/util/internal/StringUtils.java | 2 +- .../org/apache/maven/surefire/booter/Classpath.java | 2 +- .../maven/surefire/booter/TypeEncodedValue.java | 3 +-- .../surefire/group/match/SingleGroupMatcher.java | 2 +- .../maven/surefire/its/fixture/SurefireLauncher.java | 2 +- .../maven/surefire/common/junit48/RequestedTest.java | 2 +- .../maven/surefire/junitcore/JUnitCoreWrapper.java | 2 +- .../testng/utils/GroupMatcherMethodSelector.java | 4 ++-- 14 files changed, 24 insertions(+), 25 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 29b44021dc..88b223a914 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 @@ -1307,7 +1307,7 @@ private void convertGroupParameters() protected boolean isAnyConcurrencySelected() { - return this.getParallel() != null && this.getParallel().trim().length() > 0; + return getParallel() != null && !getParallel().trim().isEmpty(); } protected boolean isAnyGroupsSelected() @@ -1869,7 +1869,7 @@ public TestListResolver getSpecificTests() if ( item != null ) { item = item.trim(); - if ( item.length() != 0 ) + if ( !item.isEmpty() ) { result.add( item ); } 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 629778bd03..7a7681f884 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 @@ -333,7 +333,7 @@ private static void startTestElement( XMLWriter ppw, WrappedReportEntry report, } if ( report.getSourceName() != null ) { - if ( reportNameSuffix != null && reportNameSuffix.length() > 0 ) + if ( reportNameSuffix != null && !reportNameSuffix.isEmpty() ) { ppw.addAttribute( "classname", report.getSourceName() + "(" + reportNameSuffix + ")" ); } @@ -379,7 +379,7 @@ private static void getTestProblems( OutputStreamWriter outputStreamWriter, XMLW String stackTrace = report.getStackTrace( trimStackTrace ); - if ( report.getMessage() != null && report.getMessage().length() > 0 ) + if ( report.getMessage() != null && !report.getMessage().isEmpty() ) { ppw.addAttribute( "message", extraEscape( report.getMessage(), true ) ); } 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 402fda0fb3..4565099dfa 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 @@ -147,7 +147,7 @@ public String getReportName() public String getReportName( String suffix ) { - return suffix != null && suffix.length() > 0 ? getReportName() + "(" + suffix + ")" : getReportName(); + return suffix != null && !suffix.isEmpty() ? getReportName() + "(" + suffix + ")" : getReportName(); } public String getOutput( boolean trimStackTrace ) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/FileScanner.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/FileScanner.java index 6636f2979e..8f4f0fdd2c 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/FileScanner.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/FileScanner.java @@ -62,7 +62,7 @@ private void scan( Collection scannedJavaClassNames, for ( File fileOrDir : filesAndDirs ) { String name = fileOrDir.getName(); - if ( name.length() != 0 ) + if ( !name.isEmpty() ) { if ( fileOrDir.isFile() ) { @@ -74,7 +74,7 @@ private void scan( Collection scannedJavaClassNames, if ( filter.shouldRun( toFile( path, simpleClassName ), null ) ) { String fullyQualifiedClassName = - pAckage.length() == 0 ? simpleClassName : pAckage + '.' + simpleClassName; + pAckage.isEmpty() ? simpleClassName : pAckage + '.' + simpleClassName; scannedJavaClassNames.add( fullyQualifiedClassName ); } } @@ -122,7 +122,7 @@ private static String toPath( String... subDirectories ) private String toFile( String path, String fileNameWithoutExtension ) { String pathWithoutExtension = - path.length() == 0 ? fileNameWithoutExtension : path + '/' + fileNameWithoutExtension; + path.isEmpty() ? fileNameWithoutExtension : path + '/' + fileNameWithoutExtension; return pathWithoutExtension + ext; } } 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 55395c05df..7eb7fa85aa 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 @@ -369,7 +369,7 @@ private String encode( String source ) private static void nullableEncoding( StringBuilder stringBuilder, String source ) { - if ( source == null || source.length() == 0 ) + if ( source == null || source.isEmpty() ) { stringBuilder.append( "null" ); } 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 359ac942a7..b860c3b47f 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 @@ -74,7 +74,7 @@ public TestListResolver( Collection tests ) for ( String request : split( csvTests, "," ) ) { request = request.trim(); - if ( request.length() != 0 && !request.equals( "!" ) ) + if ( !request.isEmpty() && !request.equals( "!" ) ) { resolveTestRequest( request, patterns, includedFilters, excludedFilters ); } @@ -319,7 +319,7 @@ public static String toClassFileName( String fullyQualifiedTestClass ) static String removeExclamationMark( String s ) { - return s.length() != 0 && s.charAt( 0 ) == '!' ? s.substring( 1 ) : s; + return !s.isEmpty() && s.charAt( 0 ) == '!' ? s.substring( 1 ) : s; } private static void updatedFilters( boolean isExcluded, ResolvedTest test, IncludedExcludedPatterns patterns, @@ -344,7 +344,7 @@ private static String aggregatedTest( String testPrefix, Set tests for ( ResolvedTest test : tests ) { String readableTest = test.toString(); - if ( readableTest.length() != 0 ) + if ( !readableTest.isEmpty() ) { if ( aggregatedTest.length() != 0 ) { @@ -367,7 +367,7 @@ private static Collection mergeIncludedAndExcludedTests( Collection elements ) for ( String element : elements ) { element = element.trim(); - if ( element.length() != 0 ) + if ( !element.isEmpty() ) { newCp.add( element ); } 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 b5ad18fd60..00ad2e92a1 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 @@ -53,8 +53,7 @@ public Object getDecodedValue() public Object getDecodedValue( ClassLoader classLoader ) { - // todo: use jdk6 switch case - if ( type.trim().length() == 0 ) + if ( type.trim().isEmpty() ) { return null; } 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 72fc801244..65181faeb7 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 @@ -111,7 +111,7 @@ public boolean enabled( String... cats ) { for ( String cat : cats ) { - if ( cat == null || cat.trim().length() < 1 ) + if ( cat == null || cat.trim().isEmpty() ) { continue; } 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 e2356f4347..163aaac85a 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 @@ -70,7 +70,7 @@ public void reset() public SurefireLauncher setInProcessJavaHome() { String javaHome = System.getenv( "JAVA_HOME" ); - if ( javaHome != null && javaHome.length() > 0 ) + if ( javaHome != null && !javaHome.isEmpty() ) { try { diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/RequestedTest.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/RequestedTest.java index 0eca3876a0..52c2d52852 100644 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/RequestedTest.java +++ b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/RequestedTest.java @@ -59,7 +59,7 @@ public boolean shouldRun( Description description ) public String describe() { String description = test.toString(); - return description.length() == 0 ? "*" : description; + return description.isEmpty() ? "*" : description; } @Override diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java index 2abfa58032..656d55bcfb 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java @@ -140,7 +140,7 @@ private void createRequestAndRun( Filter filter, Computer computer, JUnitCore ju if ( computer instanceof ParallelComputer ) { String timeoutMessage = ( (ParallelComputer) computer ).describeElapsedTimeout(); - if ( timeoutMessage.length() != 0 ) + if ( !timeoutMessage.isEmpty() ) { throw new TestSetFailedException( timeoutMessage ); } 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 0017b54efe..e801b0612b 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 @@ -79,7 +79,7 @@ public static void setGroups( String groups, String excludedGroups ) { AndGroupMatcher matcher = new AndGroupMatcher(); GroupMatcher in = null; - if ( groups != null && groups.trim().length() > 0 ) + if ( groups != null && !groups.trim().isEmpty() ) { in = new GroupMatcherParser( groups ).parse(); } @@ -90,7 +90,7 @@ public static void setGroups( String groups, String excludedGroups ) } GroupMatcher ex = null; - if ( excludedGroups != null && excludedGroups.trim().length() > 0 ) + if ( excludedGroups != null && !excludedGroups.trim().isEmpty() ) { ex = new GroupMatcherParser( excludedGroups ).parse(); } From a7acb6aa7a02de24e6fac12be03c18c8b490c0bb Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Sat, 9 Sep 2017 13:24:47 +0200 Subject: [PATCH 144/194] Apache Jenkins CI URL https://builds.apache.org/view/M-R/view/Maven/job/maven-surefire-pipeline/job/master/ --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0f64b4aab4..7288c7b505 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ Jenkins - https://builds.apache.org/job/maven-surefire/ + https://builds.apache.org/view/M-R/view/Maven/job/maven-surefire-pipeline/job/master/ From e08f79ffa425fac52f218d5314b941b493042b8e Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 00:05:57 +0200 Subject: [PATCH 145/194] added two transitive dependencies shaded in Failsafe from Common --- maven-failsafe-plugin/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index 4233139f71..9c7a7a91bf 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -56,6 +56,14 @@ zip site-source + + org.apache.commons + commons-lang3 + + + commons-io + commons-io + org.mockito mockito-core From b8eb673627e5d73d0e3d0dfdd639f257e10536ea Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:06:18 +0200 Subject: [PATCH 146/194] [SUREFIRE-1412] Findbugs plugin fails - Update maven-parent to Version 30 and downgrade maven-site-plugin --- pom.xml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 7288c7b505..9e8b0830f3 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ maven-parent org.apache.maven - 26 + 30 ../pom/maven/pom.xml @@ -86,8 +86,6 @@ - 1.6 - 1.6 2.2.1 3.3 @@ -435,6 +433,11 @@
    + + org.apache.maven.plugins + maven-site-plugin + 3.4 + From c8e42d05c8fb0a5b3ac8b14d33cac7ac196bbd60 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:16:22 +0200 Subject: [PATCH 147/194] [SUREFIRE-1413] Javadoc - unknown TAG @noinspection --- .../apache/maven/plugin/failsafe/VerifyMojo.java | 5 ----- .../report/AbstractSurefireReportMojo.java | 14 -------------- .../surefire/report/FailsafeReportMojo.java | 8 +------- .../surefire/report/SurefireReportMojo.java | 6 ------ .../booter/DirectoryScannerParametersAware.java | 1 - .../surefire/booter/ProviderPropertiesAware.java | 1 - .../booter/ReporterConfigurationAware.java | 1 - .../surefire/booter/RunOrderParametersAware.java | 1 - .../surefire/booter/SurefireClassLoadersAware.java | 1 - .../maven/surefire/booter/SurefireReflector.java | 4 ---- .../surefire/booter/TestArtifactInfoAware.java | 1 - .../maven/surefire/booter/TestRequestAware.java | 1 - .../java/org/apache/maven/surefire/booter/Foo.java | 3 +-- .../common/junit3/JUnit3TestCheckerTest.java | 6 ------ 14 files changed, 2 insertions(+), 51 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 3075a6fbb6..b96acb1450 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 @@ -119,16 +119,12 @@ public class VerifyMojo /** * The summary file to read integration test results from. - * - * @noinspection UnusedDeclaration */ @Parameter( defaultValue = "${project.build.directory}/failsafe-reports/failsafe-summary.xml", required = true ) private File summaryFile; /** * Additional summary files to read integration test results from. - * - * @noinspection UnusedDeclaration, MismatchedReadAndWriteOfArray * @since 2.6 */ @Parameter @@ -147,7 +143,6 @@ public class VerifyMojo * Deprecated since 2.20.1 and used encoding UTF-8 in failsafe-summary.xml. * * @deprecated since of 2.20.1 - * @noinspection UnusedDeclaration */ @Parameter( property = "encoding", defaultValue = "${project.reporting.outputEncoding}" ) private String encoding; 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 a3538b72b8..ab27b18260 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 @@ -48,16 +48,12 @@ public abstract class AbstractSurefireReportMojo /** * If set to false, only failures are shown. - * - * @noinspection UnusedDeclaration */ @Parameter( defaultValue = "true", required = true, property = "showSuccess" ) private boolean showSuccess; /** * Directories containing the XML Report files that will be parsed and rendered to HTML format. - * - * @noinspection UnusedDeclaration */ @Parameter private File[] reportsDirectories; @@ -65,8 +61,6 @@ public abstract class AbstractSurefireReportMojo /** * (Deprecated, use reportsDirectories) This directory contains the XML Report files that will be parsed and * rendered to HTML format. - * - * @noinspection UnusedDeclaration */ @Deprecated @Parameter @@ -74,32 +68,24 @@ public abstract class AbstractSurefireReportMojo /** * The projects in the reactor for aggregation report. - * - * @noinspection MismatchedQueryAndUpdateOfCollection, UnusedDeclaration */ @Parameter( defaultValue = "${reactorProjects}", readonly = true ) private List reactorProjects; /** * Location of the Xrefs to link. - * - * @noinspection UnusedDeclaration */ @Parameter( defaultValue = "${project.reporting.outputDirectory}/xref-test" ) private File xrefLocation; /** * Whether to link the XRef if found. - * - * @noinspection UnusedDeclaration */ @Parameter( defaultValue = "true", property = "linkXRef" ) private boolean linkXRef; /** * Whether to build an aggregated report at the root, or build individual reports. - * - * @noinspection UnusedDeclaration */ @Parameter( defaultValue = "false", property = "aggregate" ) private boolean aggregate; 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 c306305ecb..c8fca02fdc 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 @@ -43,17 +43,13 @@ public class FailsafeReportMojo /** * The filename to use for the report. - * - * @noinspection UnusedDeclaration */ @Parameter( defaultValue = "failsafe-report", property = "outputName", required = true ) private String outputName; /** * If set to true the failsafe report will be generated even when there are no failsafe result files. - * Defaults to {@code false} to preserve legacy behaviour pre 2.10 - * - * @noinspection UnusedDeclaration + * Defaults to {@code false} to preserve legacy behaviour pre 2.10. * @since 2.11 */ @Parameter( defaultValue = "false", property = "alwaysGenerateFailsafeReport" ) @@ -61,8 +57,6 @@ public class FailsafeReportMojo /** * If set to true the failsafe report generation will be skipped. - * - * @noinspection UnusedDeclaration * @since 2.11 */ @Parameter( defaultValue = "false", property = "skipFailsafeReport" ) 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 e535a24d42..906feb9455 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 @@ -40,8 +40,6 @@ public class SurefireReportMojo /** * The filename to use for the report. - * - * @noinspection UnusedDeclaration */ @Parameter( defaultValue = "surefire-report", property = "outputName", required = true ) private String outputName; @@ -49,8 +47,6 @@ public class SurefireReportMojo /** * If set to true the surefire report will be generated even when there are no surefire result files. * Defaults to {@code true} to preserve legacy behaviour pre 2.10. - * - * @noinspection UnusedDeclaration * @since 2.11 */ @Parameter( defaultValue = "true", property = "alwaysGenerateSurefireReport" ) @@ -58,8 +54,6 @@ public class SurefireReportMojo /** * If set to true the surefire report generation will be skipped. - * - * @noinspection UnusedDeclaration * @since 2.11 */ @Parameter( defaultValue = "false", property = "skipSurefireReport" ) diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/DirectoryScannerParametersAware.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DirectoryScannerParametersAware.java index 54ff6caf70..cefeb33ccb 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/DirectoryScannerParametersAware.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/DirectoryScannerParametersAware.java @@ -23,7 +23,6 @@ /** * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ interface DirectoryScannerParametersAware { diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderPropertiesAware.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderPropertiesAware.java index 373e925c55..caedb988a4 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderPropertiesAware.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderPropertiesAware.java @@ -23,7 +23,6 @@ /** * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ interface ProviderPropertiesAware { diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ReporterConfigurationAware.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ReporterConfigurationAware.java index 0359636ebf..8c65be3f9c 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ReporterConfigurationAware.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ReporterConfigurationAware.java @@ -23,7 +23,6 @@ /** * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ interface ReporterConfigurationAware { diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/RunOrderParametersAware.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/RunOrderParametersAware.java index 370c6a6a10..3bee07d699 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/RunOrderParametersAware.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/RunOrderParametersAware.java @@ -23,7 +23,6 @@ /** * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ interface RunOrderParametersAware { diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireClassLoadersAware.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireClassLoadersAware.java index 351bb51ae0..c2f5d99c5e 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireClassLoadersAware.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireClassLoadersAware.java @@ -21,7 +21,6 @@ /** * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ interface SurefireClassLoadersAware { 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 4c88179049..097a3fa7a4 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 @@ -152,9 +152,6 @@ public Object convertIfRunResult( Object result ) } - /** - * @noinspection UnusedDeclaration - */ class ClassLoaderProxy implements InvocationHandler { @@ -162,7 +159,6 @@ class ClassLoaderProxy /** * @param delegate a target - * @noinspection UnusedDeclaration */ public ClassLoaderProxy( Object delegate ) { diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/TestArtifactInfoAware.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/TestArtifactInfoAware.java index 2b7065e3f8..98980615e7 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/TestArtifactInfoAware.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/TestArtifactInfoAware.java @@ -23,7 +23,6 @@ /** * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ interface TestArtifactInfoAware { diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/TestRequestAware.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/TestRequestAware.java index d2d6d298a3..3e98b92c38 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/TestRequestAware.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/TestRequestAware.java @@ -23,7 +23,6 @@ /** * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ interface TestRequestAware { 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 911c96982f..ccb01e3573 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 @@ -61,8 +61,7 @@ public void setDirectoryScannerParameters( DirectoryScannerParameters directoryS /** - * @return true if it has been callsed - * @noinspection UnusedDeclaration + * @return true if it has been called */ public Boolean isCalled() { 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 e0ae2e7faa..2397e8b025 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 @@ -121,9 +121,6 @@ public void run( TestResult testResult ) public static class NotValidTest { - /** - * @noinspection UnusedDeclaration - */ public void testSomething() { } @@ -132,9 +129,6 @@ public void testSomething() public abstract static class BaseClassWithTest extends TestCase { - /** - * @noinspection UnusedDeclaration - */ public void testWeAreAlsoATest() { } From b1ff126659b76b03ec0aa5770db23ad416b42b0e Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:08 +0200 Subject: [PATCH 148/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9e8b0830f3..25d72b1a7d 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 pom Apache 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.1_vote-1 jira From 78b563c461bd62f802f7bb7b5ec7696cc18853b0 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:09 +0200 Subject: [PATCH 149/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-logger-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-logger-api/pom.xml b/surefire-logger-api/pom.xml index a80af6e784..74fef2dedf 100644 --- a/surefire-logger-api/pom.xml +++ b/surefire-logger-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 surefire-logger-api From c5ec2b1eb45507339a46942e1f86594ef7e9af67 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:09 +0200 Subject: [PATCH 150/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-shadefire/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-shadefire/pom.xml b/surefire-shadefire/pom.xml index b061467ce3..a4a82f5ba3 100644 --- a/surefire-shadefire/pom.xml +++ b/surefire-shadefire/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 surefire-shadefire From b773abde055c61e2c24a068736bd7010a0b8d278 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:10 +0200 Subject: [PATCH 151/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml index 7b29c6d626..fbb71d3050 100644 --- a/surefire-api/pom.xml +++ b/surefire-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 surefire-api From b694aa26254b4f7075219dc28a38d6ddef415fb4 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:10 +0200 Subject: [PATCH 152/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-booter/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml index b564fa471f..d16b02c95d 100644 --- a/surefire-booter/pom.xml +++ b/surefire-booter/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 surefire-booter From 18768877f47e5cec5f0e08c74cb4f797bce77cbb Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:10 +0200 Subject: [PATCH 153/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-grouper/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-grouper/pom.xml b/surefire-grouper/pom.xml index b38803498c..3ce69329ef 100644 --- a/surefire-grouper/pom.xml +++ b/surefire-grouper/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 surefire-grouper From 822f77e28dc297d6727bb9206a3e455e28974868 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:11 +0200 Subject: [PATCH 154/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-providers/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/pom.xml b/surefire-providers/pom.xml index 9ed020deee..bb5e6aed25 100644 --- a/surefire-providers/pom.xml +++ b/surefire-providers/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 surefire-providers From 52001bdd8000d6de80a6d83f6785b1b724fd5216 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:11 +0200 Subject: [PATCH 155/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-providers/common-junit3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/common-junit3/pom.xml b/surefire-providers/common-junit3/pom.xml index 1584af85b8..6c8c7d4c37 100644 --- a/surefire-providers/common-junit3/pom.xml +++ b/surefire-providers/common-junit3/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.21-SNAPSHOT + 2.20.1 common-junit3 From d2ad61070db87d2cd5ef298d1f855b0dd33bcdf1 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:11 +0200 Subject: [PATCH 156/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-providers/common-java5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/common-java5/pom.xml b/surefire-providers/common-java5/pom.xml index 39373b03f8..a2e40b01a2 100644 --- a/surefire-providers/common-java5/pom.xml +++ b/surefire-providers/common-java5/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.21-SNAPSHOT + 2.20.1 common-java5 From ea5eddecd73d8c6211c25334071e936650e56275 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:12 +0200 Subject: [PATCH 157/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-providers/common-junit4/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/common-junit4/pom.xml b/surefire-providers/common-junit4/pom.xml index 4e70b4560c..f6e03d00dd 100644 --- a/surefire-providers/common-junit4/pom.xml +++ b/surefire-providers/common-junit4/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.21-SNAPSHOT + 2.20.1 common-junit4 From 5015a70937fb1dae28d791b43147928609b9e5fe Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:12 +0200 Subject: [PATCH 158/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-providers/common-junit48/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/common-junit48/pom.xml b/surefire-providers/common-junit48/pom.xml index 020e413609..e87a9a9b93 100644 --- a/surefire-providers/common-junit48/pom.xml +++ b/surefire-providers/common-junit48/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.21-SNAPSHOT + 2.20.1 common-junit48 From 4fdcfdcf2c21441f180e65684ccd8a8659a8d5e3 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:13 +0200 Subject: [PATCH 159/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-providers/surefire-junit3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/surefire-junit3/pom.xml b/surefire-providers/surefire-junit3/pom.xml index 1bfaf6b6b6..61d9edb195 100644 --- a/surefire-providers/surefire-junit3/pom.xml +++ b/surefire-providers/surefire-junit3/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.21-SNAPSHOT + 2.20.1 surefire-junit3 From 51f534c1859c915b4c7cbdf06ec89565ba8bcb02 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:13 +0200 Subject: [PATCH 160/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-providers/surefire-junit4/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/surefire-junit4/pom.xml b/surefire-providers/surefire-junit4/pom.xml index f5e35fe92c..6ed665adbe 100644 --- a/surefire-providers/surefire-junit4/pom.xml +++ b/surefire-providers/surefire-junit4/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.21-SNAPSHOT + 2.20.1 surefire-junit4 From 654df725dbeef98c613e8cf50f1ef1795e8031f4 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:13 +0200 Subject: [PATCH 161/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- maven-surefire-common/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index 121609b9da..dd6fc27bca 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 maven-surefire-common From ce53b8973396d761c4d290eb4fdde2693fb1c4d2 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:14 +0200 Subject: [PATCH 162/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-providers/surefire-junit47/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml index 9f1fa0fc92..efc195c800 100644 --- a/surefire-providers/surefire-junit47/pom.xml +++ b/surefire-providers/surefire-junit47/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.21-SNAPSHOT + 2.20.1 surefire-junit47 From 6bf475a0bf207ced9529ce867df12c447933428b Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:14 +0200 Subject: [PATCH 163/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-providers/surefire-testng-utils/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/surefire-testng-utils/pom.xml b/surefire-providers/surefire-testng-utils/pom.xml index bc5c2d3f05..d50c6b5a19 100644 --- a/surefire-providers/surefire-testng-utils/pom.xml +++ b/surefire-providers/surefire-testng-utils/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.21-SNAPSHOT + 2.20.1 surefire-testng-utils From 6912aa304e8491d75d70030f6fab5f49c9f62e31 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:14 +0200 Subject: [PATCH 164/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-providers/surefire-testng/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/surefire-testng/pom.xml b/surefire-providers/surefire-testng/pom.xml index fe293c07e1..c91790f06f 100644 --- a/surefire-providers/surefire-testng/pom.xml +++ b/surefire-providers/surefire-testng/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.21-SNAPSHOT + 2.20.1 surefire-testng From 8da9b4fe7dca9089b7ee18aa0250f63211467007 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:15 +0200 Subject: [PATCH 165/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-report-parser/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-report-parser/pom.xml b/surefire-report-parser/pom.xml index 648b0c2087..fd13918e77 100644 --- a/surefire-report-parser/pom.xml +++ b/surefire-report-parser/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 surefire-report-parser From d061099cba078d525a9701c9f5fa56008c92b84d Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:15 +0200 Subject: [PATCH 166/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- maven-surefire-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-surefire-plugin/pom.xml b/maven-surefire-plugin/pom.xml index 96a1720e8b..f4b9594b2a 100644 --- a/maven-surefire-plugin/pom.xml +++ b/maven-surefire-plugin/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 org.apache.maven.plugins From e6fc4b48851ca86338a4d7d174cb2aea3d76d982 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:15 +0200 Subject: [PATCH 167/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- maven-failsafe-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index 9c7a7a91bf..5525183d2d 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 org.apache.maven.plugins From 259a0430789c8646dfb6dac50b6daae1d7cd5856 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:16 +0200 Subject: [PATCH 168/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- maven-surefire-report-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml index 93a2e803ea..097c8dc5e9 100644 --- a/maven-surefire-report-plugin/pom.xml +++ b/maven-surefire-report-plugin/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 org.apache.maven.plugins From e4eb4acb9ee98bebe9c6c2faa3fdec98519a5f54 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:16 +0200 Subject: [PATCH 169/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-setup-integration-tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-setup-integration-tests/pom.xml b/surefire-setup-integration-tests/pom.xml index ff2ddbfa47..77bcd27883 100644 --- a/surefire-setup-integration-tests/pom.xml +++ b/surefire-setup-integration-tests/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 surefire-setup-integration-tests From bf6bd2205bdc225bc93db4be2032dff0d26a4410 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:16 +0200 Subject: [PATCH 170/194] [maven-release-plugin] prepare release surefire-2.20.1_vote-1 --- surefire-integration-tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-integration-tests/pom.xml b/surefire-integration-tests/pom.xml index 4ea01b4f9b..0623dbeaec 100644 --- a/surefire-integration-tests/pom.xml +++ b/surefire-integration-tests/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.21-SNAPSHOT + 2.20.1 surefire-integration-tests From 8867f4621a25b131e80d4d0ca67b85cf5791cfa5 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:27 +0200 Subject: [PATCH 171/194] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 25d72b1a7d..0042378bca 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT pom Apache 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.1_vote-1 + HEAD jira From 1a8ff4fd0866c9c9292c1fea0eedf47c043155be Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:28 +0200 Subject: [PATCH 172/194] [maven-release-plugin] prepare for next development iteration --- surefire-logger-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-logger-api/pom.xml b/surefire-logger-api/pom.xml index 74fef2dedf..efbc85b0a7 100644 --- a/surefire-logger-api/pom.xml +++ b/surefire-logger-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT surefire-logger-api From 83fee80b4d7400d62a40eda2843a02344bd5c4c0 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:28 +0200 Subject: [PATCH 173/194] [maven-release-plugin] prepare for next development iteration --- surefire-shadefire/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-shadefire/pom.xml b/surefire-shadefire/pom.xml index a4a82f5ba3..e6624090cf 100644 --- a/surefire-shadefire/pom.xml +++ b/surefire-shadefire/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT surefire-shadefire From 6f2a8d56836d2f37d908f5951b6504dcffa7a658 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:28 +0200 Subject: [PATCH 174/194] [maven-release-plugin] prepare for next development iteration --- surefire-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml index fbb71d3050..00ef758275 100644 --- a/surefire-api/pom.xml +++ b/surefire-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT surefire-api From 60d73249afd266855fd1cd88a53cf405d933da62 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:29 +0200 Subject: [PATCH 175/194] [maven-release-plugin] prepare for next development iteration --- surefire-booter/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml index d16b02c95d..d20fbddde3 100644 --- a/surefire-booter/pom.xml +++ b/surefire-booter/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT surefire-booter From 23af117d2963e27737cf3a8b708e9434e27068d3 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:29 +0200 Subject: [PATCH 176/194] [maven-release-plugin] prepare for next development iteration --- surefire-grouper/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-grouper/pom.xml b/surefire-grouper/pom.xml index 3ce69329ef..80f19ff348 100644 --- a/surefire-grouper/pom.xml +++ b/surefire-grouper/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT surefire-grouper From 91ad9e841192ca1e56eb973682f83d7a628408bc Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:30 +0200 Subject: [PATCH 177/194] [maven-release-plugin] prepare for next development iteration --- surefire-providers/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/pom.xml b/surefire-providers/pom.xml index bb5e6aed25..65ae76f3b6 100644 --- a/surefire-providers/pom.xml +++ b/surefire-providers/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT surefire-providers From b3bd39487587506173bcdfd89a488071905e7ad0 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:30 +0200 Subject: [PATCH 178/194] [maven-release-plugin] prepare for next development iteration --- surefire-providers/common-junit3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/common-junit3/pom.xml b/surefire-providers/common-junit3/pom.xml index 6c8c7d4c37..37339fb67f 100644 --- a/surefire-providers/common-junit3/pom.xml +++ b/surefire-providers/common-junit3/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.20.1 + 2.21.0-SNAPSHOT common-junit3 From 0aa73e567916cfc4a165ffb7d237b746f782d30a Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:30 +0200 Subject: [PATCH 179/194] [maven-release-plugin] prepare for next development iteration --- surefire-providers/common-java5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/common-java5/pom.xml b/surefire-providers/common-java5/pom.xml index a2e40b01a2..50be920501 100644 --- a/surefire-providers/common-java5/pom.xml +++ b/surefire-providers/common-java5/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.20.1 + 2.21.0-SNAPSHOT common-java5 From 7fe6c8b038e6a72bdf5c2b517d9ebb66ff0647fa Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:31 +0200 Subject: [PATCH 180/194] [maven-release-plugin] prepare for next development iteration --- surefire-providers/common-junit4/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/common-junit4/pom.xml b/surefire-providers/common-junit4/pom.xml index f6e03d00dd..b7621fef68 100644 --- a/surefire-providers/common-junit4/pom.xml +++ b/surefire-providers/common-junit4/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.20.1 + 2.21.0-SNAPSHOT common-junit4 From b147a95c853c2c8f070f96b853dfe987d6e5ee07 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:31 +0200 Subject: [PATCH 181/194] [maven-release-plugin] prepare for next development iteration --- surefire-providers/common-junit48/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/common-junit48/pom.xml b/surefire-providers/common-junit48/pom.xml index e87a9a9b93..06151e8a02 100644 --- a/surefire-providers/common-junit48/pom.xml +++ b/surefire-providers/common-junit48/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.20.1 + 2.21.0-SNAPSHOT common-junit48 From 773ec3bb1a4f9c49de9e4a2f0beefeb0b54a75ae Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:31 +0200 Subject: [PATCH 182/194] [maven-release-plugin] prepare for next development iteration --- surefire-providers/surefire-junit3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/surefire-junit3/pom.xml b/surefire-providers/surefire-junit3/pom.xml index 61d9edb195..2e906da903 100644 --- a/surefire-providers/surefire-junit3/pom.xml +++ b/surefire-providers/surefire-junit3/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.20.1 + 2.21.0-SNAPSHOT surefire-junit3 From 6bff10f3405c755608b9632085ab105381597178 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:32 +0200 Subject: [PATCH 183/194] [maven-release-plugin] prepare for next development iteration --- surefire-providers/surefire-junit4/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/surefire-junit4/pom.xml b/surefire-providers/surefire-junit4/pom.xml index 6ed665adbe..870f13c12b 100644 --- a/surefire-providers/surefire-junit4/pom.xml +++ b/surefire-providers/surefire-junit4/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.20.1 + 2.21.0-SNAPSHOT surefire-junit4 From 41390c3ba82fee72f46c0039278b972d62a7fc07 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:32 +0200 Subject: [PATCH 184/194] [maven-release-plugin] prepare for next development iteration --- maven-surefire-common/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index dd6fc27bca..1bcd7c55c0 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT maven-surefire-common From b1d3470114ab299110329115876d1c7664e5ab29 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:32 +0200 Subject: [PATCH 185/194] [maven-release-plugin] prepare for next development iteration --- surefire-providers/surefire-junit47/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml index efc195c800..a630c58561 100644 --- a/surefire-providers/surefire-junit47/pom.xml +++ b/surefire-providers/surefire-junit47/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.20.1 + 2.21.0-SNAPSHOT surefire-junit47 From f77d91eaca99bcfd4c9efcc1ea8065c0b6cdfb64 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:33 +0200 Subject: [PATCH 186/194] [maven-release-plugin] prepare for next development iteration --- surefire-providers/surefire-testng-utils/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/surefire-testng-utils/pom.xml b/surefire-providers/surefire-testng-utils/pom.xml index d50c6b5a19..66df28ec14 100644 --- a/surefire-providers/surefire-testng-utils/pom.xml +++ b/surefire-providers/surefire-testng-utils/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.20.1 + 2.21.0-SNAPSHOT surefire-testng-utils From 707a6796280e686e6c255d1517f9ea639d8c0985 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:33 +0200 Subject: [PATCH 187/194] [maven-release-plugin] prepare for next development iteration --- surefire-providers/surefire-testng/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-providers/surefire-testng/pom.xml b/surefire-providers/surefire-testng/pom.xml index c91790f06f..22fcc158ff 100644 --- a/surefire-providers/surefire-testng/pom.xml +++ b/surefire-providers/surefire-testng/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 2.20.1 + 2.21.0-SNAPSHOT surefire-testng From 6f4997b32416eae62c671b371665812de5e26fd1 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:33 +0200 Subject: [PATCH 188/194] [maven-release-plugin] prepare for next development iteration --- surefire-report-parser/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-report-parser/pom.xml b/surefire-report-parser/pom.xml index fd13918e77..60d570f51c 100644 --- a/surefire-report-parser/pom.xml +++ b/surefire-report-parser/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT surefire-report-parser From 39159383bf390e8ef1f98206b3877f9c31599de6 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:34 +0200 Subject: [PATCH 189/194] [maven-release-plugin] prepare for next development iteration --- maven-surefire-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-surefire-plugin/pom.xml b/maven-surefire-plugin/pom.xml index f4b9594b2a..0faecf60ec 100644 --- a/maven-surefire-plugin/pom.xml +++ b/maven-surefire-plugin/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT org.apache.maven.plugins From 256156e97bf98f83472605ddf3c55eb6cc65d613 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:34 +0200 Subject: [PATCH 190/194] [maven-release-plugin] prepare for next development iteration --- maven-failsafe-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index 5525183d2d..ace323190a 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT org.apache.maven.plugins From aa1c66ab7aa5514c8befe922343512f9a8bd8551 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:34 +0200 Subject: [PATCH 191/194] [maven-release-plugin] prepare for next development iteration --- maven-surefire-report-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml index 097c8dc5e9..9cdd56948e 100644 --- a/maven-surefire-report-plugin/pom.xml +++ b/maven-surefire-report-plugin/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT org.apache.maven.plugins From 31d68d9b461c80717560ac48c216e3c1e750ab48 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:35 +0200 Subject: [PATCH 192/194] [maven-release-plugin] prepare for next development iteration --- surefire-setup-integration-tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-setup-integration-tests/pom.xml b/surefire-setup-integration-tests/pom.xml index 77bcd27883..5a784ce309 100644 --- a/surefire-setup-integration-tests/pom.xml +++ b/surefire-setup-integration-tests/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT surefire-setup-integration-tests From 28168c82e1c25449390b5ffa744f395d7b899c82 Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Mon, 11 Sep 2017 03:28:35 +0200 Subject: [PATCH 193/194] [maven-release-plugin] prepare for next development iteration --- surefire-integration-tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surefire-integration-tests/pom.xml b/surefire-integration-tests/pom.xml index 0623dbeaec..4187d5f9b2 100644 --- a/surefire-integration-tests/pom.xml +++ b/surefire-integration-tests/pom.xml @@ -24,7 +24,7 @@ org.apache.maven.surefire surefire - 2.20.1 + 2.21.0-SNAPSHOT surefire-integration-tests From 5aed84309465e0e4f81585b117086fe4e29e112c Mon Sep 17 00:00:00 2001 From: Tibor17 Date: Fri, 15 Sep 2017 17:04:14 +0200 Subject: [PATCH 194/194] [maven-release-plugin] commitByProject=true --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 0042378bca..4f0bf58123 100644 --- a/pom.xml +++ b/pom.xml @@ -403,6 +403,7 @@ true clean install + true