diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml
index 9683e3bb27..5008055108 100644
--- a/.github/workflows/maven-verify.yml
+++ b/.github/workflows/maven-verify.yml
@@ -31,7 +31,7 @@ jobs:
ff-goal: 'clean install site site:stage -P reporting -nsu'
ff-site-goal: '-v'
verify-goal: 'clean install -nsu -P run-its'
- verify-fail-fast: false
+ verify-fail-fast: true
failure-upload-path: |
surefire-its/target/*/log.txt
surefire-its/target/**/surefire-reports/*
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index ed8758f5eb..cdca61c2a6 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -17,281 +17,281 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
- 4.0.0
+ 4.0.0
+
+
+ org.apache.maven.surefire
+ surefire
+ 3.0.0-M10-SNAPSHOT
+
-
- org.apache.maven.surefire
- surefire
- 3.0.0-M10-SNAPSHOT
-
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ maven-plugin
- org.apache.maven.plugins
- maven-failsafe-plugin
- maven-plugin
+ Maven Failsafe Plugin
+ Maven Failsafe MOJO in maven-failsafe-plugin.
- Maven Failsafe Plugin
- Maven Failsafe MOJO in maven-failsafe-plugin.
+
+ ${mavenVersion}
+
-
- ${mavenVersion}
-
+
+ Failsafe
+ Surefire
+ 8184
+ 8185
+
-
- Failsafe
- Surefire
- 8184
- 8185
-
+
+
+ org.apache.maven.surefire
+ maven-surefire-common
+ ${project.version}
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${project.version}
+ site-source
+ zip
+ provided
+
+
+ org.apache.maven
+ maven-plugin-api
+ provided
+
+
+ org.apache.maven
+ maven-core
+ provided
+
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ provided
+
+
+ org.mockito
+ mockito-core
+ test
+
+
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+ jacoco.agent
+
+
+
+ jacoco-agent
+
+ prepare-agent
+
+
+
+
+
+ maven-surefire-plugin
+
+ ${jvm.args.tests} ${jacoco.agent}
+
+ **/JUnit4SuiteTest.java
+
+
+
+
org.apache.maven.surefire
- maven-surefire-common
- ${project.version}
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${project.version}
- provided
- zip
- site-source
-
-
- org.apache.maven
- maven-plugin-api
- provided
-
-
- org.apache.maven
- maven-core
- provided
-
-
- org.apache.maven.plugin-tools
- maven-plugin-annotations
- provided
-
-
- org.mockito
- mockito-core
- test
-
-
+ surefire-shadefire
+ 3.0.0-M7
+
+
+
+
+
+ maven-dependency-plugin
+
+
+ site-site
+
+ unpack-dependencies
+
+ pre-site
+
+ maven-surefire-plugin
+ provided
+ zip
+ site-source
+ ${project.build.directory}/source-site
+ true
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+
+ copy-resources
+
+ pre-site
+
+ ${basedir}/../target/source-site
+
+
+ ${basedir}/../src/site
+ false
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ generate-test-report
+
+ run
+
+ pre-site
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+
+ ${project.build.directory}/source-site
+
+
+
+
-
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+
+
+
+
+
+
+ ci
+
+
+ enableCiProfile
+ true
+
+
+
-
- org.apache.maven.plugins
- maven-plugin-plugin
-
-
- org.jacoco
- jacoco-maven-plugin
-
-
- jacoco-agent
-
- prepare-agent
-
-
-
-
- jacoco.agent
-
-
-
- maven-surefire-plugin
-
-
- org.apache.maven.surefire
- surefire-shadefire
- 3.0.0-M7
-
-
+
+ maven-docck-plugin
+ 1.1
+
+
+
+ check
+
+
+
+
+
+
+
+
+ run-its
+
+ verify
+
+
+ org.apache.maven.plugins
+ maven-invoker-plugin
+
+
+ pre-its
+
+ install
+
+ pre-integration-test
- ${jvm.args.tests} ${jacoco.agent}
-
- **/JUnit4SuiteTest.java
-
+ ${skipTests}
-
-
- maven-dependency-plugin
-
-
- site-site
- pre-site
-
- unpack-dependencies
-
-
- maven-surefire-plugin
- provided
- zip
- site-source
- ${project.build.directory}/source-site
- true
-
-
-
-
-
- maven-resources-plugin
-
-
- copy-resources
- pre-site
-
- copy-resources
-
-
- ${basedir}/../target/source-site
-
-
- ${basedir}/../src/site
- false
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-antrun-plugin
-
-
- generate-test-report
- pre-site
-
- run
-
-
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-site-plugin
+
+
+ integration-test
+
+ run
+
- ${project.build.directory}/source-site
+ src/it
+ ${project.build.directory}/it
+
+ verify
+ -nsu
+
+
+ */pom.xml
+
+ verify
+ src/it/settings.xml
+ ${skipTests}
+ true
+
+ ${failsafe-integration-test-port}
+ ${failsafe-integration-test-stop-port}
+
+ true
-
+
+
+
-
-
-
+
+
+
+ reporting
+
-
- org.apache.maven.plugins
- maven-plugin-plugin
-
+
+ org.apache.maven.plugins
+ maven-changes-plugin
+
+ false
+
+
+
+
+ jira-report
+
+
+
+
-
-
-
-
- ci
-
-
- enableCiProfile
- true
-
-
-
-
-
- maven-docck-plugin
- 1.1
-
-
-
- check
-
-
-
-
-
-
-
-
- run-its
-
- verify
-
-
- org.apache.maven.plugins
- maven-invoker-plugin
-
-
- pre-its
- pre-integration-test
-
- install
-
-
- ${skipTests}
-
-
-
- integration-test
-
- run
-
-
- src/it
- ${project.build.directory}/it
-
- verify
- -nsu
-
-
- */pom.xml
-
- verify
- src/it/settings.xml
- ${skipTests}
- true
-
- ${failsafe-integration-test-port}
- ${failsafe-integration-test-stop-port}
-
- true
-
-
-
-
-
-
-
-
- reporting
-
-
-
- org.apache.maven.plugins
- maven-changes-plugin
-
- false
-
-
-
-
- jira-report
-
-
-
-
-
-
-
-
+
+
+
diff --git a/maven-failsafe-plugin/src/it/jetty-war-test-failing/src/test/java/basic/BasicIT.java b/maven-failsafe-plugin/src/it/jetty-war-test-failing/src/test/java/basic/BasicIT.java
index c271570157..b7891e1c93 100644
--- a/maven-failsafe-plugin/src/it/jetty-war-test-failing/src/test/java/basic/BasicIT.java
+++ b/maven-failsafe-plugin/src/it/jetty-war-test-failing/src/test/java/basic/BasicIT.java
@@ -1,5 +1,3 @@
-package basic;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@
* "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
+ * 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
@@ -19,6 +17,8 @@
* under the License.
*/
+package basic;
+
import java.io.IOException;
import java.util.Properties;
diff --git a/maven-failsafe-plugin/src/it/jetty-war-test-passing/src/test/java/basic/BasicIT.java b/maven-failsafe-plugin/src/it/jetty-war-test-passing/src/test/java/basic/BasicIT.java
index ab903640e8..1c8b4ccbe8 100644
--- a/maven-failsafe-plugin/src/it/jetty-war-test-passing/src/test/java/basic/BasicIT.java
+++ b/maven-failsafe-plugin/src/it/jetty-war-test-passing/src/test/java/basic/BasicIT.java
@@ -1,5 +1,3 @@
-package basic;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@
* "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
+ * 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
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package basic;
import java.io.IOException;
import java.util.Properties;
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 b673b96b56..1d3d54da4e 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
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
package org.apache.maven.plugin.failsafe;
/*
@@ -19,6 +37,12 @@
* 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;
@@ -27,14 +51,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.surefire.extensions.ForkNodeFactory;
import org.apache.maven.surefire.api.suite.RunResult;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
+import org.apache.maven.surefire.extensions.ForkNodeFactory;
import static org.apache.maven.plugin.failsafe.util.FailsafeSummaryXmlUtils.writeSummary;
@@ -44,11 +62,13 @@
* @author Jason van Zyl
* @author Stephen Connolly
*/
-@Mojo( name = "integration-test", requiresProject = true, requiresDependencyResolution = ResolutionScope.TEST,
- defaultPhase = LifecyclePhase.INTEGRATION_TEST, threadSafe = true )
-public class IntegrationTestMojo
- extends AbstractSurefireMojo
-{
+@Mojo(
+ name = "integration-test",
+ requiresProject = true,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ defaultPhase = LifecyclePhase.INTEGRATION_TEST,
+ threadSafe = true)
+public class IntegrationTestMojo extends AbstractSurefireMojo {
private static final String FAILSAFE_IN_PROGRESS_CONTEXT_KEY = "failsafe-in-progress";
@@ -60,7 +80,7 @@ public class IntegrationTestMojo
@Parameter
private File classesDirectory;
- @Parameter( defaultValue = "${project.build.outputDirectory}", readonly = true, required = true )
+ @Parameter(defaultValue = "${project.build.outputDirectory}", readonly = true, required = true)
private File defaultClassesDirectory;
/**
@@ -69,16 +89,16 @@ public class IntegrationTestMojo
*
* @since 2.4.3-alpha-2
*/
- @Parameter( property = "skipITs" )
+ @Parameter(property = "skipITs")
private boolean skipITs;
/**
* Base directory where all reports are written to.
*/
- @Parameter( defaultValue = "${project.build.directory}/failsafe-reports" )
+ @Parameter(defaultValue = "${project.build.directory}/failsafe-reports")
private File reportsDirectory;
- @SuppressWarnings( "checkstyle:linelength" )
+ @SuppressWarnings("checkstyle:linelength")
/**
* 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
@@ -101,32 +121,32 @@ public class IntegrationTestMojo
* 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" )
+ @Parameter(property = "it.test")
private String test;
/**
* The summary file to write integration test results to.
*/
- @Parameter( defaultValue = "${project.build.directory}/failsafe-reports/failsafe-summary.xml", required = true )
+ @Parameter(defaultValue = "${project.build.directory}/failsafe-reports/failsafe-summary.xml", required = true)
private File summaryFile;
/**
* Option to print summary of test suites or just print the test cases that have errors.
*/
- @Parameter( property = "failsafe.printSummary", defaultValue = "true" )
+ @Parameter(property = "failsafe.printSummary", defaultValue = "true")
private boolean printSummary;
/**
* Selects the formatting for the test report to be generated. Can be set as "brief" or "plain".
* Only applies to the output format of the output files (target/surefire-reports/testName.txt)
*/
- @Parameter( property = "failsafe.reportFormat", defaultValue = "brief" )
+ @Parameter(property = "failsafe.reportFormat", defaultValue = "brief")
private String reportFormat;
/**
* Option to generate a file test report or just output the test report to the console.
*/
- @Parameter( property = "failsafe.useFile", defaultValue = "true" )
+ @Parameter(property = "failsafe.useFile", defaultValue = "true")
private boolean useFile;
/**
@@ -137,7 +157,7 @@ public class IntegrationTestMojo
* @deprecated Since 3.0.0-M8, use "failsafe.failIfNoSpecifiedTests" instead.
*/
@Deprecated
- @Parameter( property = "it.failIfNoSpecifiedTests", defaultValue = "true" )
+ @Parameter(property = "it.failIfNoSpecifiedTests", defaultValue = "true")
private boolean failIfNoSpecifiedTestsDeprecated;
/**
@@ -147,7 +167,7 @@ public class IntegrationTestMojo
*
* @since 3.0.0-M8
*/
- @Parameter( property = "failsafe.failIfNoSpecifiedTests", defaultValue = "true" )
+ @Parameter(property = "failsafe.failIfNoSpecifiedTests", defaultValue = "true")
private boolean failIfNoSpecifiedTests;
/**
@@ -158,7 +178,7 @@ public class IntegrationTestMojo
*
* @since 2.4
*/
- @Parameter( property = "maven.failsafe.debug" )
+ @Parameter(property = "maven.failsafe.debug")
private String debugForkedProcess;
/**
@@ -167,7 +187,7 @@ public class IntegrationTestMojo
*
* @since 2.4
*/
- @Parameter( property = "failsafe.timeout" )
+ @Parameter(property = "failsafe.timeout")
private int forkedProcessTimeoutInSeconds;
/**
@@ -179,7 +199,7 @@ public class IntegrationTestMojo
*
* @since 2.20
*/
- @Parameter( property = "failsafe.exitTimeout", defaultValue = "30" )
+ @Parameter(property = "failsafe.exitTimeout", defaultValue = "30")
private int forkedProcessExitTimeoutInSeconds;
/**
@@ -192,7 +212,7 @@ public class IntegrationTestMojo
*
* @since 2.16
*/
- @Parameter( property = "failsafe.parallel.timeout" )
+ @Parameter(property = "failsafe.parallel.timeout")
private double parallelTestsTimeoutInSeconds;
/**
@@ -206,10 +226,10 @@ public class IntegrationTestMojo
*
* @since 2.16
*/
- @Parameter( property = "failsafe.parallel.forcedTimeout" )
+ @Parameter(property = "failsafe.parallel.forcedTimeout")
private double parallelTestsTimeoutForcedInSeconds;
- @SuppressWarnings( "checkstyle:linelength" )
+ @SuppressWarnings("checkstyle:linelength")
/**
* 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
@@ -237,7 +257,7 @@ public class IntegrationTestMojo
* to the POM property ${project.build.testOutputDirectory}
, typically
* {@literal src/test/java}
unless overridden.
*/
- @Parameter( property = "failsafe.includes" )
+ @Parameter(property = "failsafe.includes")
// TODO use regex for fully qualified class names in 3.0 and change the filtering abilities
private List includes;
@@ -265,7 +285,7 @@ public class IntegrationTestMojo
* to the POM property ${project.build.testOutputDirectory}
, typically
* {@literal src/test/java}
unless overridden.
*/
- @Parameter( property = "failsafe.excludes" )
+ @Parameter(property = "failsafe.excludes")
// TODO use regex for fully qualified class names in 3.0 and change the filtering abilities
private List excludes;
@@ -276,7 +296,7 @@ public class IntegrationTestMojo
*
* @since 2.3
*/
- @Parameter( property = "failsafe.useSystemClassLoader", defaultValue = "true" )
+ @Parameter(property = "failsafe.useSystemClassLoader", defaultValue = "true")
private boolean useSystemClassLoader;
/**
@@ -290,7 +310,7 @@ public class IntegrationTestMojo
*
* @since 2.4.3
*/
- @Parameter( property = "failsafe.useManifestOnlyJar", defaultValue = "true" )
+ @Parameter(property = "failsafe.useManifestOnlyJar", defaultValue = "true")
private boolean useManifestOnlyJar;
/**
@@ -300,7 +320,7 @@ public class IntegrationTestMojo
*
* @since 3.0.0-M1
*/
- @Parameter( property = "encoding", defaultValue = "${project.reporting.outputEncoding}" )
+ @Parameter(property = "encoding", defaultValue = "${project.reporting.outputEncoding}")
private String encoding;
/**
@@ -309,7 +329,7 @@ public class IntegrationTestMojo
* they fail. If a failing test passes in any of those reruns, it will be marked as pass and reported as a "flake".
* However, all the failing attempts will be recorded.
*/
- @Parameter( property = "failsafe.rerunFailingTestsCount", defaultValue = "0" )
+ @Parameter(property = "failsafe.rerunFailingTestsCount", defaultValue = "0")
private int rerunFailingTestsCount;
/**
@@ -321,7 +341,7 @@ public class IntegrationTestMojo
*
* @since 2.2
*/
- @Parameter( property = "failsafe.suiteXmlFiles" )
+ @Parameter(property = "failsafe.suiteXmlFiles")
private File[] suiteXmlFiles;
/**
@@ -348,7 +368,7 @@ public class IntegrationTestMojo
*
* @since 2.7
*/
- @Parameter( property = "failsafe.runOrder", defaultValue = "filesystem" )
+ @Parameter(property = "failsafe.runOrder", defaultValue = "filesystem")
private String runOrder;
/**
@@ -364,7 +384,7 @@ public class IntegrationTestMojo
*
* @since 3.0.0-M6
*/
- @Parameter( property = "failsafe.runOrder.random.seed" )
+ @Parameter(property = "failsafe.runOrder.random.seed")
private Long runOrderRandomSeed;
/**
@@ -384,7 +404,7 @@ public class IntegrationTestMojo
*
* @since 2.13
*/
- @Parameter( property = "failsafe.includesFile" )
+ @Parameter(property = "failsafe.includesFile")
private File includesFile;
/**
@@ -404,7 +424,7 @@ public class IntegrationTestMojo
*
* @since 2.13
*/
- @Parameter( property = "failsafe.excludesFile" )
+ @Parameter(property = "failsafe.excludesFile")
private File excludesFile;
/**
@@ -418,7 +438,7 @@ public class IntegrationTestMojo
*
* @since 2.19
*/
- @Parameter( property = "failsafe.skipAfterFailureCount", defaultValue = "0" )
+ @Parameter(property = "failsafe.skipAfterFailureCount", defaultValue = "0")
private int skipAfterFailureCount;
/**
@@ -438,7 +458,7 @@ public class IntegrationTestMojo
*
* @since 2.19
*/
- @Parameter( property = "failsafe.shutdown", defaultValue = "exit" )
+ @Parameter(property = "failsafe.shutdown", defaultValue = "exit")
private String shutdown;
/**
@@ -449,7 +469,7 @@ public class IntegrationTestMojo
*
* @since 3.0.0-M2
*/
- @Parameter( property = "failsafe.useModulePath", defaultValue = "true" )
+ @Parameter(property = "failsafe.useModulePath", defaultValue = "true")
private boolean useModulePath;
/**
@@ -464,7 +484,7 @@ public class IntegrationTestMojo
*
* @since 3.0.0-M5
*/
- @Parameter( property = "failsafe.forkNode" )
+ @Parameter(property = "failsafe.forkNode")
private ForkNodeFactory forkNode;
/**
@@ -480,7 +500,7 @@ public class IntegrationTestMojo
*
* @since 3.0.0-M4
*/
- @Parameter( property = "failsafe.excludedEnvironmentVariables" )
+ @Parameter(property = "failsafe.excludedEnvironmentVariables")
private String[] excludedEnvironmentVariables;
/**
@@ -521,10 +541,10 @@ public class IntegrationTestMojo
*
* @since 3.0.0-M4
*/
- @Parameter( property = "failsafe.enableProcessChecker" )
+ @Parameter(property = "failsafe.enableProcessChecker")
private String enableProcessChecker;
- @Parameter( property = "failsafe.systemPropertiesFile" )
+ @Parameter(property = "failsafe.systemPropertiesFile")
private File systemPropertiesFile;
/**
@@ -532,7 +552,7 @@ public class IntegrationTestMojo
*
* @since 3.0.0-M6
*/
- @Parameter( property = "failsafe.includeJUnit5Engines" )
+ @Parameter(property = "failsafe.includeJUnit5Engines")
private String[] includeJUnit5Engines;
/**
@@ -540,152 +560,127 @@ public class IntegrationTestMojo
*
* @since 3.0.0-M6
*/
- @Parameter( property = "failsafe.excludeJUnit5Engines" )
+ @Parameter(property = "failsafe.excludeJUnit5Engines")
private String[] excludeJUnit5Engines;
@Override
- protected int getRerunFailingTestsCount()
- {
+ protected int getRerunFailingTestsCount() {
return rerunFailingTestsCount;
}
@Override
- @SuppressWarnings( "unchecked" )
- protected void handleSummary( RunResult summary, Exception firstForkException )
- throws MojoExecutionException, MojoFailureException
- {
+ @SuppressWarnings("unchecked")
+ protected void handleSummary(RunResult summary, Exception firstForkException)
+ throws MojoExecutionException, MojoFailureException {
File summaryFile = getSummaryFile();
- if ( !summaryFile.getParentFile().isDirectory() )
- {
+ if (!summaryFile.getParentFile().isDirectory()) {
//noinspection ResultOfMethodCallIgnored
summaryFile.getParentFile().mkdirs();
}
- try
- {
- Object token = getPluginContext().get( FAILSAFE_IN_PROGRESS_CONTEXT_KEY );
- writeSummary( summary, summaryFile, token != null );
- }
- catch ( Exception e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
+ try {
+ Object token = getPluginContext().get(FAILSAFE_IN_PROGRESS_CONTEXT_KEY);
+ writeSummary(summary, summaryFile, token != null);
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage(), e);
}
- getPluginContext().put( FAILSAFE_IN_PROGRESS_CONTEXT_KEY, FAILSAFE_IN_PROGRESS_CONTEXT_KEY );
+ getPluginContext().put(FAILSAFE_IN_PROGRESS_CONTEXT_KEY, FAILSAFE_IN_PROGRESS_CONTEXT_KEY);
}
- private boolean isJarArtifact( File artifactFile )
- {
- return artifactFile != null && artifactFile.isFile() && artifactFile.getName().toLowerCase().endsWith( ".jar" );
+ private boolean isJarArtifact(File artifactFile) {
+ return artifactFile != null
+ && artifactFile.isFile()
+ && artifactFile.getName().toLowerCase().endsWith(".jar");
}
- private static File toAbsoluteCanonical( File f )
- {
- try
- {
+ private static File toAbsoluteCanonical(File f) {
+ try {
return f == null ? null : f.getAbsoluteFile().getCanonicalFile();
- }
- catch ( IOException e )
- {
- throw new IllegalStateException( e.getLocalizedMessage(), e );
+ } catch (IOException e) {
+ throw new IllegalStateException(e.getLocalizedMessage(), e);
}
}
@Override
- @SuppressWarnings( "deprecation" )
- protected boolean isSkipExecution()
- {
+ @SuppressWarnings("deprecation")
+ protected boolean isSkipExecution() {
return isSkip() || isSkipTests() || isSkipITs() || isSkipExec();
}
@Override
- protected String getPluginName()
- {
+ protected String getPluginName() {
return "failsafe";
}
@Override
- protected String[] getDefaultIncludes()
- {
- return new String[]{ "**/IT*.java", "**/*IT.java", "**/*ITCase.java" };
+ protected String[] getDefaultIncludes() {
+ return new String[] {"**/IT*.java", "**/*IT.java", "**/*ITCase.java"};
}
@Override
- protected String getReportSchemaLocation()
- {
+ protected String getReportSchemaLocation() {
return "https://maven.apache.org/surefire/maven-failsafe-plugin/xsd/failsafe-test-report-3.0.xsd";
}
@Override
- public boolean isSkipTests()
- {
+ public boolean isSkipTests() {
return skipTests;
}
@Override
@Deprecated
- public void setSkipTests( boolean skipTests )
- {
+ public void setSkipTests(boolean skipTests) {
this.skipTests = skipTests;
}
- public boolean isSkipITs()
- {
+ public boolean isSkipITs() {
return skipITs;
}
- public void setSkipITs( boolean skipITs )
- {
+ public void setSkipITs(boolean skipITs) {
this.skipITs = skipITs;
}
@Override
@Deprecated
- public boolean isSkipExec()
- {
+ public boolean isSkipExec() {
return skipExec;
}
@Override
@Deprecated
- public void setSkipExec( boolean skipExec )
- {
+ public void setSkipExec(boolean skipExec) {
this.skipExec = skipExec;
}
@Override
- public boolean isSkip()
- {
+ public boolean isSkip() {
return skip;
}
@Override
- public void setSkip( boolean skip )
- {
+ public void setSkip(boolean skip) {
this.skip = skip;
}
@Override
- public File getBasedir()
- {
+ public File getBasedir() {
return basedir;
}
@Override
- public void setBasedir( File basedir )
- {
+ public void setBasedir(File basedir) {
this.basedir = basedir;
}
@Override
- public File getTestClassesDirectory()
- {
+ public File getTestClassesDirectory() {
return testClassesDirectory;
}
@Override
- public void setTestClassesDirectory( File testClassesDirectory )
- {
+ public void setTestClassesDirectory(File testClassesDirectory) {
this.testClassesDirectory = testClassesDirectory;
}
@@ -695,392 +690,328 @@ public void setTestClassesDirectory( File testClassesDirectory )
* used instead. See the resolution of {@link #getClassLoaderConfiguration() ClassLoaderConfiguration}.
*/
@Override
- public File getMainBuildPath()
- {
+ public File getMainBuildPath() {
File artifact = getProject().getArtifact().getFile();
boolean isDefaultClsDir = classesDirectory == null;
- return isDefaultClsDir ? ( isJarArtifact( artifact ) ? artifact : defaultClassesDirectory ) : classesDirectory;
+ return isDefaultClsDir ? (isJarArtifact(artifact) ? artifact : defaultClassesDirectory) : classesDirectory;
}
@Override
- public void setMainBuildPath( File mainBuildPath )
- {
- classesDirectory = toAbsoluteCanonical( mainBuildPath );
+ public void setMainBuildPath(File mainBuildPath) {
+ classesDirectory = toAbsoluteCanonical(mainBuildPath);
}
- public void setDefaultClassesDirectory( File defaultClassesDirectory )
- {
- this.defaultClassesDirectory = toAbsoluteCanonical( defaultClassesDirectory );
+ public void setDefaultClassesDirectory(File defaultClassesDirectory) {
+ this.defaultClassesDirectory = toAbsoluteCanonical(defaultClassesDirectory);
}
@Override
- public File getReportsDirectory()
- {
+ public File getReportsDirectory() {
return reportsDirectory;
}
@Override
- public void setReportsDirectory( File reportsDirectory )
- {
+ public void setReportsDirectory(File reportsDirectory) {
this.reportsDirectory = reportsDirectory;
}
@Override
- public String getTest()
- {
+ public String getTest() {
return test;
}
@Override
- public void setTest( String test )
- {
+ public void setTest(String test) {
this.test = test;
}
- public File getSummaryFile()
- {
+ public File getSummaryFile() {
return summaryFile;
}
- public void setSummaryFile( File summaryFile )
- {
+ public void setSummaryFile(File summaryFile) {
this.summaryFile = summaryFile;
}
@Override
- public boolean isPrintSummary()
- {
+ public boolean isPrintSummary() {
return printSummary;
}
@Override
- public void setPrintSummary( boolean printSummary )
- {
+ public void setPrintSummary(boolean printSummary) {
this.printSummary = printSummary;
}
@Override
- public String getReportFormat()
- {
+ public String getReportFormat() {
return reportFormat;
}
@Override
- public void setReportFormat( String reportFormat )
- {
+ public void setReportFormat(String reportFormat) {
this.reportFormat = reportFormat;
}
@Override
- public boolean isUseFile()
- {
+ public boolean isUseFile() {
return useFile;
}
@Override
- public void setUseFile( boolean useFile )
- {
+ public void setUseFile(boolean useFile) {
this.useFile = useFile;
}
@Override
- public String getDebugForkedProcess()
- {
+ public String getDebugForkedProcess() {
return debugForkedProcess;
}
@Override
- public void setDebugForkedProcess( String debugForkedProcess )
- {
+ public void setDebugForkedProcess(String debugForkedProcess) {
this.debugForkedProcess = debugForkedProcess;
}
@Override
- public int getForkedProcessTimeoutInSeconds()
- {
+ public int getForkedProcessTimeoutInSeconds() {
return forkedProcessTimeoutInSeconds;
}
@Override
- public void setForkedProcessTimeoutInSeconds( int forkedProcessTimeoutInSeconds )
- {
+ public void setForkedProcessTimeoutInSeconds(int forkedProcessTimeoutInSeconds) {
this.forkedProcessTimeoutInSeconds = forkedProcessTimeoutInSeconds;
}
@Override
- public int getForkedProcessExitTimeoutInSeconds()
- {
+ public int getForkedProcessExitTimeoutInSeconds() {
return forkedProcessExitTimeoutInSeconds;
}
@Override
- public void setForkedProcessExitTimeoutInSeconds( int forkedProcessExitTimeoutInSeconds )
- {
+ public void setForkedProcessExitTimeoutInSeconds(int forkedProcessExitTimeoutInSeconds) {
this.forkedProcessExitTimeoutInSeconds = forkedProcessExitTimeoutInSeconds;
}
@Override
- public double getParallelTestsTimeoutInSeconds()
- {
+ public double getParallelTestsTimeoutInSeconds() {
return parallelTestsTimeoutInSeconds;
}
@Override
- public void setParallelTestsTimeoutInSeconds( double parallelTestsTimeoutInSeconds )
- {
+ public void setParallelTestsTimeoutInSeconds(double parallelTestsTimeoutInSeconds) {
this.parallelTestsTimeoutInSeconds = parallelTestsTimeoutInSeconds;
}
@Override
- public double getParallelTestsTimeoutForcedInSeconds()
- {
+ public double getParallelTestsTimeoutForcedInSeconds() {
return parallelTestsTimeoutForcedInSeconds;
}
@Override
- public void setParallelTestsTimeoutForcedInSeconds( double parallelTestsTimeoutForcedInSeconds )
- {
+ public void setParallelTestsTimeoutForcedInSeconds(double parallelTestsTimeoutForcedInSeconds) {
this.parallelTestsTimeoutForcedInSeconds = parallelTestsTimeoutForcedInSeconds;
}
@Override
- public boolean isUseSystemClassLoader()
- {
+ public boolean isUseSystemClassLoader() {
return useSystemClassLoader;
}
@Override
- public void setUseSystemClassLoader( boolean useSystemClassLoader )
- {
+ public void setUseSystemClassLoader(boolean useSystemClassLoader) {
this.useSystemClassLoader = useSystemClassLoader;
}
@Override
- public boolean isUseManifestOnlyJar()
- {
+ public boolean isUseManifestOnlyJar() {
return useManifestOnlyJar;
}
@Override
- public void setUseManifestOnlyJar( boolean useManifestOnlyJar )
- {
+ public void setUseManifestOnlyJar(boolean useManifestOnlyJar) {
this.useManifestOnlyJar = useManifestOnlyJar;
}
@Override
- public String getEncoding()
- {
+ public String getEncoding() {
return encoding;
}
@Override
- public void setEncoding( String encoding )
- {
+ public void setEncoding(String encoding) {
this.encoding = encoding;
}
// the following will be refactored out once the common code is all in one place
- public boolean isTestFailureIgnore()
- {
+ public boolean isTestFailureIgnore() {
return true; // ignore
}
- public void setTestFailureIgnore( boolean testFailureIgnore )
- {
+ public void setTestFailureIgnore(boolean testFailureIgnore) {
// ignore
}
@Override
- protected void addPluginSpecificChecksumItems( ChecksumCalculator checksum )
- {
- checksum.add( skipITs );
- checksum.add( summaryFile );
+ protected void addPluginSpecificChecksumItems(ChecksumCalculator checksum) {
+ checksum.add(skipITs);
+ checksum.add(summaryFile);
}
@Override
- public File getSystemPropertiesFile()
- {
+ public File getSystemPropertiesFile() {
return systemPropertiesFile;
}
@Override
- public void setSystemPropertiesFile( File systemPropertiesFile )
- {
+ public void setSystemPropertiesFile(File systemPropertiesFile) {
this.systemPropertiesFile = systemPropertiesFile;
}
@Override
- @SuppressWarnings( "deprecation" )
- public boolean getFailIfNoSpecifiedTests()
- {
- if ( !failIfNoSpecifiedTestsDeprecated )
- {
- getConsoleLogger().warning( "Use " + getPluginName()
- + ".failIfNoSpecifiedTests property instead of obsolete it.failIfNoSpecifiedTests." );
+ @SuppressWarnings("deprecation")
+ public boolean getFailIfNoSpecifiedTests() {
+ if (!failIfNoSpecifiedTestsDeprecated) {
+ getConsoleLogger()
+ .warning("Use " + getPluginName()
+ + ".failIfNoSpecifiedTests property instead of obsolete it.failIfNoSpecifiedTests.");
}
// since both have default "true", assuming that any "false" is set by user on purpose
return failIfNoSpecifiedTests && failIfNoSpecifiedTestsDeprecated;
}
@Override
- public void setFailIfNoSpecifiedTests( boolean failIfNoSpecifiedTests )
- {
+ public void setFailIfNoSpecifiedTests(boolean failIfNoSpecifiedTests) {
this.failIfNoSpecifiedTests = failIfNoSpecifiedTests;
}
@Override
- public int getSkipAfterFailureCount()
- {
+ public int getSkipAfterFailureCount() {
return skipAfterFailureCount;
}
@Override
- public String getShutdown()
- {
+ public String getShutdown() {
return shutdown;
}
@Override
- public List getIncludes()
- {
+ public List getIncludes() {
return includes;
}
@Override
- public void setIncludes( List includes )
- {
+ public void setIncludes(List includes) {
this.includes = includes;
}
@Override
- public List getExcludes()
- {
+ public List getExcludes() {
return excludes;
}
@Override
- public void setExcludes( List excludes )
- {
+ public void setExcludes(List excludes) {
this.excludes = excludes;
}
@Override
- public File[] getSuiteXmlFiles()
- {
+ public File[] getSuiteXmlFiles() {
return suiteXmlFiles.clone();
}
@Override
- @SuppressWarnings( "UnusedDeclaration" )
- public void setSuiteXmlFiles( File[] suiteXmlFiles )
- {
+ @SuppressWarnings("UnusedDeclaration")
+ public void setSuiteXmlFiles(File[] suiteXmlFiles) {
this.suiteXmlFiles = suiteXmlFiles.clone();
}
@Override
- public String getRunOrder()
- {
+ public String getRunOrder() {
return runOrder;
}
@Override
- @SuppressWarnings( "UnusedDeclaration" )
- public void setRunOrder( String runOrder )
- {
+ @SuppressWarnings("UnusedDeclaration")
+ public void setRunOrder(String runOrder) {
this.runOrder = runOrder;
}
@Override
- public Long getRunOrderRandomSeed()
- {
+ public Long getRunOrderRandomSeed() {
return runOrderRandomSeed;
}
@Override
- public void setRunOrderRandomSeed( Long runOrderRandomSeed )
- {
+ public void setRunOrderRandomSeed(Long runOrderRandomSeed) {
this.runOrderRandomSeed = runOrderRandomSeed;
}
@Override
- public File getIncludesFile()
- {
+ public File getIncludesFile() {
return includesFile;
}
@Override
- public File getExcludesFile()
- {
+ public File getExcludesFile() {
return excludesFile;
}
@Override
- protected boolean useModulePath()
- {
+ protected boolean useModulePath() {
return useModulePath;
}
@Override
- protected void setUseModulePath( boolean useModulePath )
- {
+ protected void setUseModulePath(boolean useModulePath) {
this.useModulePath = useModulePath;
}
@Override
- protected final List suiteXmlFiles()
- {
- return hasSuiteXmlFiles() ? Arrays.asList( suiteXmlFiles ) : Collections.emptyList();
+ protected final List suiteXmlFiles() {
+ return hasSuiteXmlFiles() ? Arrays.asList(suiteXmlFiles) : Collections.emptyList();
}
@Override
- protected final boolean hasSuiteXmlFiles()
- {
+ protected final boolean hasSuiteXmlFiles() {
return suiteXmlFiles != null && suiteXmlFiles.length != 0;
}
@Override
- protected final ForkNodeFactory getForkNode()
- {
+ protected final ForkNodeFactory getForkNode() {
return forkNode;
}
@Override
- protected final String[] getExcludedEnvironmentVariables()
- {
+ protected final String[] getExcludedEnvironmentVariables() {
return excludedEnvironmentVariables == null ? new String[0] : excludedEnvironmentVariables;
}
- void setExcludedEnvironmentVariables( String[] excludedEnvironmentVariables )
- {
+ void setExcludedEnvironmentVariables(String[] excludedEnvironmentVariables) {
this.excludedEnvironmentVariables = excludedEnvironmentVariables;
}
@Override
- protected final String getEnableProcessChecker()
- {
+ protected final String getEnableProcessChecker() {
return enableProcessChecker;
}
- public String[] getIncludeJUnit5Engines()
- {
+ public String[] getIncludeJUnit5Engines() {
return includeJUnit5Engines;
}
- @SuppressWarnings( "UnusedDeclaration" )
- public void setIncludeJUnit5Engines( String[] includeJUnit5Engines )
- {
+ @SuppressWarnings("UnusedDeclaration")
+ public void setIncludeJUnit5Engines(String[] includeJUnit5Engines) {
this.includeJUnit5Engines = includeJUnit5Engines;
}
- public String[] getExcludeJUnit5Engines()
- {
+ public String[] getExcludeJUnit5Engines() {
return excludeJUnit5Engines;
}
- @SuppressWarnings( "UnusedDeclaration" )
- public void setExcludeJUnit5Engines( String[] excludeJUnit5Engines )
- {
+ @SuppressWarnings("UnusedDeclaration")
+ public void setExcludeJUnit5Engines(String[] excludeJUnit5Engines) {
this.excludeJUnit5Engines = excludeJUnit5Engines;
}
}
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 0dd1529d94..25045636f5 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
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
package org.apache.maven.plugin.failsafe;
/*
@@ -19,6 +37,9 @@
* under the License.
*/
+import java.io.File;
+import java.util.Collection;
+
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -36,12 +57,9 @@
import org.apache.maven.surefire.booter.SurefireBooterForkException;
import org.codehaus.plexus.logging.Logger;
-import java.io.File;
-import java.util.Collection;
-
import static org.apache.maven.plugin.surefire.SurefireHelper.reportExecution;
-import static org.apache.maven.surefire.shared.utils.StringUtils.capitalizeFirstLetter;
import static org.apache.maven.surefire.api.suite.RunResult.noTestsRun;
+import static org.apache.maven.surefire.shared.utils.StringUtils.capitalizeFirstLetter;
/**
* Verify integration tests ran using Surefire.
@@ -49,12 +67,9 @@
* @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
-{
+@SuppressWarnings("unused")
+@Mojo(name = "verify", defaultPhase = LifecyclePhase.VERIFY, requiresProject = true, threadSafe = true)
+public class VerifyMojo extends AbstractMojo implements SurefireReportParameters {
/**
* Set this to 'true' to skip running tests, but still compile them. Its use is NOT RECOMMENDED, but quite
@@ -62,7 +77,7 @@ public class VerifyMojo
*
* @since 2.4
*/
- @Parameter( property = "skipTests" )
+ @Parameter(property = "skipTests")
private boolean skipTests;
/**
@@ -71,7 +86,7 @@ public class VerifyMojo
*
* @since 2.4.3-alpha-2
*/
- @Parameter( property = "skipITs" )
+ @Parameter(property = "skipITs")
private boolean skipITs;
/**
@@ -81,7 +96,7 @@ public class VerifyMojo
* @deprecated Use -DskipTests instead.
*/
@Deprecated
- @Parameter( property = "maven.test.skip.exec" )
+ @Parameter(property = "maven.test.skip.exec")
private boolean skipExec;
/**
@@ -89,40 +104,40 @@ public class VerifyMojo
* 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.
*/
- @Parameter( property = "maven.test.skip", defaultValue = "false" )
+ @Parameter(property = "maven.test.skip", defaultValue = "false")
private boolean skip;
/**
* Set this to true to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on
* occasion.
*/
- @Parameter( property = "maven.test.failure.ignore", defaultValue = "false" )
+ @Parameter(property = "maven.test.failure.ignore", defaultValue = "false")
private boolean testFailureIgnore;
/**
* The base directory of the project being tested. This can be obtained in your unit test by
* System.getProperty("basedir").
*/
- @Parameter( defaultValue = "${basedir}" )
+ @Parameter(defaultValue = "${basedir}")
private File basedir;
/**
* The directory containing generated test classes of the project being tested.
* This will be included at the beginning the test classpath.
*/
- @Parameter( defaultValue = "${project.build.testOutputDirectory}" )
+ @Parameter(defaultValue = "${project.build.testOutputDirectory}")
private File testClassesDirectory;
/**
* Base directory where all reports are written to.
*/
- @Parameter( defaultValue = "${project.build.directory}/failsafe-reports" )
+ @Parameter(defaultValue = "${project.build.directory}/failsafe-reports")
private File reportsDirectory;
/**
* The summary file to read integration test results from.
*/
- @Parameter( defaultValue = "${project.build.directory}/failsafe-reports/failsafe-summary.xml", required = true )
+ @Parameter(defaultValue = "${project.build.directory}/failsafe-reports/failsafe-summary.xml", required = true)
private File summaryFile;
/**
@@ -137,16 +152,16 @@ public class VerifyMojo
*
* @since 2.4
*/
- @Parameter( property = "failIfNoTests", defaultValue = "false" )
+ @Parameter(property = "failIfNoTests", defaultValue = "false")
private boolean failIfNoTests;
/**
* Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches
* this threshold. Set to 0 to allow an unlimited number of flakes.
- *
+ *
* @since 3.0.0-M6
*/
- @Parameter( property = "failsafe.failOnFlakeCount", defaultValue = "0" )
+ @Parameter(property = "failsafe.failOnFlakeCount", defaultValue = "0")
private int failOnFlakeCount;
/**
@@ -155,13 +170,13 @@ public class VerifyMojo
*
* @deprecated since of 2.20.1
*/
- @Parameter( property = "encoding", defaultValue = "${project.reporting.outputEncoding}" )
+ @Parameter(property = "encoding", defaultValue = "${project.reporting.outputEncoding}")
private String encoding;
/**
* The current build session instance.
*/
- @Parameter( defaultValue = "${session}", readonly = true )
+ @Parameter(defaultValue = "${session}", readonly = true)
private MavenSession session;
@Component
@@ -172,278 +187,222 @@ public class VerifyMojo
private volatile PluginConsoleLogger consoleLogger;
@Override
- public void execute()
- throws MojoExecutionException, MojoFailureException
- {
+ public void execute() throws MojoExecutionException, MojoFailureException {
cli = commandLineOptions();
- if ( verifyParameters() )
- {
- logDebugOrCliShowErrors( capitalizeFirstLetter( getPluginName() )
- + " report directory: " + getReportsDirectory() );
+ if (verifyParameters()) {
+ logDebugOrCliShowErrors(
+ capitalizeFirstLetter(getPluginName()) + " report directory: " + getReportsDirectory());
RunResult summary;
- try
- {
- summary = existsSummaryFile() ? readSummary( summaryFile ) : noTestsRun();
-
- if ( existsSummaryFiles() )
- {
- for ( final File summaryFile : summaryFiles )
- {
- summary = summary.aggregate( readSummary( summaryFile ) );
+ try {
+ summary = existsSummaryFile() ? readSummary(summaryFile) : noTestsRun();
+
+ if (existsSummaryFiles()) {
+ for (final File summaryFile : summaryFiles) {
+ summary = summary.aggregate(readSummary(summaryFile));
}
}
- }
- catch ( Exception e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage(), e);
}
- reportExecution( this, summary, getConsoleLogger(), getBooterForkException( summary ) );
+ reportExecution(this, summary, getConsoleLogger(), getBooterForkException(summary));
}
}
- private Exception getBooterForkException( RunResult summary )
- {
- String firstForkExceptionFailureMessage =
- String.format( "%s: " , SurefireBooterForkException.class.getName() );
- if ( summary.getFailure() != null && summary.getFailure().contains( firstForkExceptionFailureMessage ) )
- {
+ private Exception getBooterForkException(RunResult summary) {
+ String firstForkExceptionFailureMessage = String.format("%s: ", SurefireBooterForkException.class.getName());
+ if (summary.getFailure() != null && summary.getFailure().contains(firstForkExceptionFailureMessage)) {
return new SurefireBooterForkException(
- summary.getFailure().substring( firstForkExceptionFailureMessage.length() ) );
+ summary.getFailure().substring(firstForkExceptionFailureMessage.length()));
}
return null;
}
- void setLogger( Logger logger )
- {
+ void setLogger(Logger logger) {
this.logger = logger;
}
- private PluginConsoleLogger getConsoleLogger()
- {
- if ( consoleLogger == null )
- {
- synchronized ( this )
- {
- if ( consoleLogger == null )
- {
- consoleLogger = new PluginConsoleLogger( logger );
+ private PluginConsoleLogger getConsoleLogger() {
+ if (consoleLogger == null) {
+ synchronized (this) {
+ if (consoleLogger == null) {
+ consoleLogger = new PluginConsoleLogger(logger);
}
}
}
return consoleLogger;
}
- private RunResult readSummary( File summaryFile ) throws Exception
- {
- return FailsafeSummaryXmlUtils.toRunResult( summaryFile );
+ private RunResult readSummary(File summaryFile) throws Exception {
+ return FailsafeSummaryXmlUtils.toRunResult(summaryFile);
}
- protected boolean verifyParameters()
- throws MojoFailureException
- {
- if ( isSkip() || isSkipTests() || isSkipITs() || isSkipExec() )
- {
- getConsoleLogger().info( "Tests are skipped." );
+ protected boolean verifyParameters() throws MojoFailureException {
+ if (isSkip() || isSkipTests() || isSkipITs() || isSkipExec()) {
+ getConsoleLogger().info("Tests are skipped.");
return false;
}
- if ( !getTestClassesDirectory().exists() )
- {
- if ( getFailIfNoTests() )
- {
- throw new MojoFailureException( "No tests to run!" );
+ if (!getTestClassesDirectory().exists()) {
+ if (getFailIfNoTests()) {
+ throw new MojoFailureException("No tests to run!");
}
}
- if ( !existsSummary() )
- {
- getConsoleLogger().info( "No tests to run." );
+ if (!existsSummary()) {
+ getConsoleLogger().info("No tests to run.");
return false;
}
- if ( failOnFlakeCount < 0 )
- {
- throw new MojoFailureException( "Parameter \"failOnFlakeCount\" should not be negative." );
+ if (failOnFlakeCount < 0) {
+ throw new MojoFailureException("Parameter \"failOnFlakeCount\" should not be negative.");
}
return true;
}
- protected String getPluginName()
- {
+ protected String getPluginName() {
return "failsafe";
}
- protected String[] getDefaultIncludes()
- {
+ protected String[] getDefaultIncludes() {
return null;
}
@Override
- public boolean isSkipTests()
- {
+ public boolean isSkipTests() {
return skipTests;
}
@Override
- public void setSkipTests( boolean skipTests )
- {
+ public void setSkipTests(boolean skipTests) {
this.skipTests = skipTests;
}
- public boolean isSkipITs()
- {
+ public boolean isSkipITs() {
return skipITs;
}
- public void setSkipITs( boolean skipITs )
- {
+ public void setSkipITs(boolean skipITs) {
this.skipITs = skipITs;
}
@Override
@Deprecated
- public boolean isSkipExec()
- {
+ public boolean isSkipExec() {
return skipExec;
}
@Override
@Deprecated
- public void setSkipExec( boolean skipExec )
- {
+ public void setSkipExec(boolean skipExec) {
this.skipExec = skipExec;
}
@Override
- public boolean isSkip()
- {
+ public boolean isSkip() {
return skip;
}
@Override
- public void setSkip( boolean skip )
- {
+ public void setSkip(boolean skip) {
this.skip = skip;
}
@Override
- public boolean isTestFailureIgnore()
- {
+ public boolean isTestFailureIgnore() {
return testFailureIgnore;
}
@Override
- public void setTestFailureIgnore( boolean testFailureIgnore )
- {
+ public void setTestFailureIgnore(boolean testFailureIgnore) {
this.testFailureIgnore = testFailureIgnore;
}
@Override
- public File getBasedir()
- {
+ public File getBasedir() {
return basedir;
}
@Override
- public void setBasedir( File basedir )
- {
+ public void setBasedir(File basedir) {
this.basedir = basedir;
}
@Override
- public File getTestClassesDirectory()
- {
+ public File getTestClassesDirectory() {
return testClassesDirectory;
}
@Override
- public void setTestClassesDirectory( File testClassesDirectory )
- {
+ public void setTestClassesDirectory(File testClassesDirectory) {
this.testClassesDirectory = testClassesDirectory;
}
@Override
- public File getReportsDirectory()
- {
+ public File getReportsDirectory() {
return reportsDirectory;
}
@Override
- public void setReportsDirectory( File reportsDirectory )
- {
+ public void setReportsDirectory(File reportsDirectory) {
this.reportsDirectory = reportsDirectory;
}
- public File getSummaryFile()
- {
+ public File getSummaryFile() {
return summaryFile;
}
- public void setSummaryFile( File summaryFile )
- {
+ public void setSummaryFile(File summaryFile) {
this.summaryFile = summaryFile;
}
@Override
- public boolean getFailIfNoTests()
- {
+ public boolean getFailIfNoTests() {
return failIfNoTests;
}
@Override
- public void setFailIfNoTests( boolean failIfNoTests )
- {
+ public void setFailIfNoTests(boolean failIfNoTests) {
this.failIfNoTests = failIfNoTests;
}
@Override
- public int getFailOnFlakeCount()
- {
+ public int getFailOnFlakeCount() {
return failOnFlakeCount;
}
@Override
- public void setFailOnFlakeCount( int failOnFlakeCount )
- {
+ public void setFailOnFlakeCount(int failOnFlakeCount) {
this.failOnFlakeCount = failOnFlakeCount;
}
- public MavenSession getSession()
- {
+ public MavenSession getSession() {
return session;
}
- public void setSession( MavenSession session )
- {
+ public void setSession(MavenSession session) {
this.session = session;
}
- private boolean existsSummaryFile()
- {
+ private boolean existsSummaryFile() {
return summaryFile != null && summaryFile.isFile();
}
- private boolean existsSummaryFiles()
- {
+ private boolean existsSummaryFiles() {
return summaryFiles != null && summaryFiles.length != 0;
}
- private boolean existsSummary()
- {
+ private boolean existsSummary() {
return existsSummaryFile() || existsSummaryFiles();
}
- private Collection commandLineOptions()
- {
- return SurefireHelper.commandLineOptions( session, getConsoleLogger() );
+ private Collection commandLineOptions() {
+ return SurefireHelper.commandLineOptions(session, getConsoleLogger());
}
- private void logDebugOrCliShowErrors( String s )
- {
- SurefireHelper.logDebugOrCliShowErrors( s, getConsoleLogger(), cli );
+ private void logDebugOrCliShowErrors(String s) {
+ SurefireHelper.logDebugOrCliShowErrors(s, getConsoleLogger(), cli);
}
-
}
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 03e340ca73..27cd052fd7 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
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
package org.apache.maven.plugin.failsafe.util;
/*
@@ -19,13 +37,9 @@
* under the License.
*/
-import org.apache.maven.surefire.shared.io.IOUtils;
-import org.apache.maven.surefire.api.suite.RunResult;
-import org.w3c.dom.Node;
-import org.xml.sax.InputSource;
-
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -34,6 +48,11 @@
import java.io.Reader;
import java.util.Locale;
+import org.apache.maven.surefire.api.suite.RunResult;
+import org.apache.maven.surefire.shared.io.IOUtils;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
import static java.lang.Boolean.parseBoolean;
import static java.lang.Integer.parseInt;
import static java.lang.String.format;
@@ -47,92 +66,85 @@
* @author Tibor Digana (tibor17)
* @since 2.20
*/
-public final class FailsafeSummaryXmlUtils
-{
+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 MESSAGE_NIL_ELEMENT =
"";
- private static final String MESSAGE_ELEMENT =
- "%s";
-
- 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." );
+ private static final String MESSAGE_ELEMENT = "%s";
+
+ 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 Exception
- {
+ public static RunResult toRunResult(File failsafeSummaryXml) throws Exception {
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
- try ( Reader reader = new InputStreamReader( new FileInputStream( failsafeSummaryXml ), UTF_8 ) )
- {
- Node root = ( Node ) xpath.evaluate( "/", new InputSource( reader ), 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 )
- );
+ try (Reader reader = new InputStreamReader(new FileInputStream(failsafeSummaryXml), UTF_8)) {
+ Node root = (Node) xpath.evaluate("/", new InputSource(reader), 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));
}
}
- public static void fromRunResultToFile( RunResult fromRunResult, File toFailsafeSummaryXml )
- throws IOException
- {
+ public static void fromRunResultToFile(RunResult fromRunResult, File toFailsafeSummaryXml) throws IOException {
String failure = fromRunResult.getFailure();
- String msg = isBlank( failure ) ? MESSAGE_NIL_ELEMENT : format( MESSAGE_ELEMENT, escapeXml10( failure ) );
- String xml = format( Locale.ROOT, FAILSAFE_SUMMARY_XML_TEMPLATE,
+ String msg = isBlank(failure) ? MESSAGE_NIL_ELEMENT : format(MESSAGE_ELEMENT, escapeXml10(failure));
+ String xml = format(
+ Locale.ROOT,
+ FAILSAFE_SUMMARY_XML_TEMPLATE,
fromRunResult.getFailsafeCode(),
- String.valueOf( fromRunResult.isTimeout() ),
+ String.valueOf(fromRunResult.isTimeout()),
fromRunResult.getCompletedCount(),
fromRunResult.getErrors(),
fromRunResult.getFailures(),
fromRunResult.getSkipped(),
- msg );
+ msg);
- try ( FileOutputStream os = new FileOutputStream( toFailsafeSummaryXml ) )
- {
- IOUtils.write( xml, os, UTF_8 );
+ try (FileOutputStream os = new FileOutputStream(toFailsafeSummaryXml)) {
+ IOUtils.write(xml, os, UTF_8);
}
}
- public static void writeSummary( RunResult mergedSummary, File mergedSummaryFile, boolean inProgress )
- throws Exception
- {
- if ( !mergedSummaryFile.getParentFile().isDirectory() )
- {
+ public static void writeSummary(RunResult mergedSummary, File mergedSummaryFile, boolean inProgress)
+ throws Exception {
+ if (!mergedSummaryFile.getParentFile().isDirectory()) {
//noinspection ResultOfMethodCallIgnored
mergedSummaryFile.getParentFile().mkdirs();
}
- if ( mergedSummaryFile.exists() && inProgress )
- {
- RunResult runResult = toRunResult( mergedSummaryFile );
- mergedSummary = mergedSummary.aggregate( runResult );
+ if (mergedSummaryFile.exists() && inProgress) {
+ RunResult runResult = toRunResult(mergedSummaryFile);
+ mergedSummary = mergedSummary.aggregate(runResult);
}
- fromRunResultToFile( mergedSummary, mergedSummaryFile );
+ fromRunResultToFile(mergedSummary, mergedSummaryFile);
}
}
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 2553369d69..d57a0c922e 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,3 +1,21 @@
+/*
+ * 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.
+ */
package org.apache.maven.plugin.failsafe;
/*
@@ -19,6 +37,9 @@
* under the License.
*/
+import java.io.File;
+import java.io.IOException;
+
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
@@ -26,9 +47,6 @@
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.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -37,80 +55,67 @@
/**
* @since 2.20
*/
-public class IntegrationTestMojoTest
-{
+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();
+ 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 = new IntegrationTestMojo();
- MavenProject project = mock( MavenProject.class );
- when( project.getArtifact() ).thenReturn( artifact );
- mojo.setProject( project );
+ MavenProject project = mock(MavenProject.class);
+ when(project.getArtifact()).thenReturn(artifact);
+ mojo.setProject(project);
}
@Test
- public void shouldBeJar()
- {
- mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
+ public void shouldBeJar() {
+ mojo.setDefaultClassesDirectory(new File("./target/classes"));
File binaries = mojo.getMainBuildPath();
- assertThat( binaries.getName() ).isEqualTo( "a-1.0.jar" );
+ assertThat(binaries.getName()).isEqualTo("a-1.0.jar");
}
@Test
- public void shouldBeAnotherJar()
- {
- mojo.setMainBuildPath( new File( "./target/another-1.0.jar" ) );
- mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
+ public void shouldBeAnotherJar() {
+ mojo.setMainBuildPath(new File("./target/another-1.0.jar"));
+ mojo.setDefaultClassesDirectory(new File("./target/classes"));
File binaries = mojo.getMainBuildPath();
- assertThat( binaries.getName() ).isEqualTo( "another-1.0.jar" );
+ assertThat(binaries.getName()).isEqualTo("another-1.0.jar");
}
@Test
- public void shouldBeClasses()
- {
- mojo.setMainBuildPath( new File( "./target/classes" ) );
- mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
+ public void shouldBeClasses() {
+ mojo.setMainBuildPath(new File("./target/classes"));
+ mojo.setDefaultClassesDirectory(new File("./target/classes"));
File binaries = mojo.getMainBuildPath();
- assertThat( binaries.getName() ).isEqualTo( "classes" );
+ assertThat(binaries.getName()).isEqualTo("classes");
}
@Test
- public void shouldGetNullEnv()
- {
- assertThat( mojo.getExcludedEnvironmentVariables() )
- .hasSize( 0 );
+ public void shouldGetNullEnv() {
+ assertThat(mojo.getExcludedEnvironmentVariables()).hasSize(0);
}
@Test
- public void shouldGetEnv()
- {
- mojo.setExcludedEnvironmentVariables( new String[] { "ABC", "KLM" } );
- assertThat( mojo.getExcludedEnvironmentVariables() )
- .hasSize( 2 )
- .contains( "ABC", "KLM" );
+ public void shouldGetEnv() {
+ mojo.setExcludedEnvironmentVariables(new String[] {"ABC", "KLM"});
+ assertThat(mojo.getExcludedEnvironmentVariables()).hasSize(2).contains("ABC", "KLM");
}
@Test
- public void testShouldGetPropertyFile()
- {
- mojo.setSystemPropertiesFile( new File( "testShouldGetPropertyFile" ) );
- assertThat( mojo.getSystemPropertiesFile() )
- .isEqualTo( new File( "testShouldGetPropertyFile" ) );
+ public void testShouldGetPropertyFile() {
+ mojo.setSystemPropertiesFile(new File("testShouldGetPropertyFile"));
+ assertThat(mojo.getSystemPropertiesFile()).isEqualTo(new File("testShouldGetPropertyFile"));
}
@Test
- public void shouldHaveJUnit5EnginesFilter()
- {
- mojo.setIncludeJUnit5Engines( new String[] { "e1", "e2" } );
- assertThat( mojo.getIncludeJUnit5Engines() ).isEqualTo( new String[] { "e1", "e2" } );
+ public void shouldHaveJUnit5EnginesFilter() {
+ mojo.setIncludeJUnit5Engines(new String[] {"e1", "e2"});
+ assertThat(mojo.getIncludeJUnit5Engines()).isEqualTo(new String[] {"e1", "e2"});
- mojo.setExcludeJUnit5Engines( new String[] { "e1", "e2" } );
- assertThat( mojo.getExcludeJUnit5Engines() ).isEqualTo( new String[] { "e1", "e2" } );
+ mojo.setExcludeJUnit5Engines(new String[] {"e1", "e2"});
+ assertThat(mojo.getExcludeJUnit5Engines()).isEqualTo(new String[] {"e1", "e2"});
}
}
diff --git a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/JUnit4SuiteTest.java b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/JUnit4SuiteTest.java
index 186803a0d3..9f08295c7c 100644
--- a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/JUnit4SuiteTest.java
+++ b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/JUnit4SuiteTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
package org.apache.maven.plugin.failsafe;
/*
@@ -31,17 +49,15 @@
* @author Tibor Digana (tibor17)
* @since 2.21.0
*/
-@SuiteClasses( {
- IntegrationTestMojoTest.class,
- MarshallerUnmarshallerTest.class,
- RunResultTest.class,
- VerifyMojoTest.class
-} )
-@RunWith( Suite.class )
-public class JUnit4SuiteTest
-{
- public static Test suite()
- {
- return new JUnit4TestAdapter( JUnit4SuiteTest.class );
+@SuiteClasses({
+ IntegrationTestMojoTest.class,
+ MarshallerUnmarshallerTest.class,
+ RunResultTest.class,
+ VerifyMojoTest.class
+})
+@RunWith(Suite.class)
+public class JUnit4SuiteTest {
+ public static Test suite() {
+ return new JUnit4TestAdapter(JUnit4SuiteTest.class);
}
}
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 20979fd194..5a266e2e6d 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,3 +1,21 @@
+/*
+ * 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.
+ */
package org.apache.maven.plugin.failsafe;
/*
@@ -19,85 +37,74 @@
* under the License.
*/
+import java.io.File;
+
import org.apache.maven.plugin.failsafe.util.FailsafeSummaryXmlUtils;
import org.apache.maven.surefire.api.suite.RunResult;
import org.apache.maven.surefire.api.util.SureFireFileManager;
import org.junit.Test;
-import java.io.File;
-
import static org.assertj.core.api.Assertions.assertThat;
/**
*
*/
-public class MarshallerUnmarshallerTest
-{
+public class MarshallerUnmarshallerTest {
@Test
- public void shouldUnmarshallExistingXmlFile() throws Exception
- {
- File xml = new File( "target/test-classes/org/apache/maven/plugin/failsafe/failsafe-summary.xml" );
- RunResult summary = FailsafeSummaryXmlUtils.toRunResult( xml );
-
- assertThat( summary.getCompletedCount() )
- .isEqualTo( 7 );
-
- assertThat( summary.getErrors() )
- .isEqualTo( 1 );
-
- assertThat( summary.getFailures() )
- .isEqualTo( 2 );
-
- assertThat( summary.getSkipped() )
- .isEqualTo( 3 );
-
- assertThat( summary.getFailure() )
- .contains( "There was an error in the forked processtest "
- + "subsystem#no method RuntimeException Hi There!"
- );
-
- assertThat( summary.getFailure() )
- .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)"
- );
+ public void shouldUnmarshallExistingXmlFile() throws Exception {
+ File xml = new File("target/test-classes/org/apache/maven/plugin/failsafe/failsafe-summary.xml");
+ RunResult summary = FailsafeSummaryXmlUtils.toRunResult(xml);
+
+ assertThat(summary.getCompletedCount()).isEqualTo(7);
+
+ assertThat(summary.getErrors()).isEqualTo(1);
+
+ assertThat(summary.getFailures()).isEqualTo(2);
+
+ assertThat(summary.getSkipped()).isEqualTo(3);
+
+ assertThat(summary.getFailure())
+ .contains("There was an error in the forked processtest "
+ + "subsystem#no method RuntimeException Hi There!");
+
+ assertThat(summary.getFailure())
+ .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)");
}
@Test
- public void shouldMarshallAndUnmarshallSameXml() throws Exception
- {
- 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 );
+ public void shouldMarshallAndUnmarshallSameXml() throws Exception {
+ 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 = SureFireFileManager.createTempFile( "failsafe-summary", ".xml" );
- FailsafeSummaryXmlUtils.writeSummary( expected, xml, false );
+ File xml = SureFireFileManager.createTempFile("failsafe-summary", ".xml");
+ FailsafeSummaryXmlUtils.writeSummary(expected, xml, false);
- RunResult actual = FailsafeSummaryXmlUtils.toRunResult( xml );
+ RunResult actual = FailsafeSummaryXmlUtils.toRunResult(xml);
- assertThat( actual.getFailures() )
- .isEqualTo( expected.getFailures() );
+ assertThat(actual.getFailures()).isEqualTo(expected.getFailures());
- assertThat( actual.isTimeout() )
- .isEqualTo( expected.isTimeout() );
+ assertThat(actual.isTimeout()).isEqualTo(expected.isTimeout());
- assertThat( actual.getCompletedCount() )
- .isEqualTo( expected.getCompletedCount() );
+ assertThat(actual.getCompletedCount()).isEqualTo(expected.getCompletedCount());
- assertThat( actual.getErrors() )
- .isEqualTo( expected.getErrors() );
+ assertThat(actual.getErrors()).isEqualTo(expected.getErrors());
- assertThat( actual.getFailures() )
- .isEqualTo( expected.getFailures() );
+ assertThat(actual.getFailures()).isEqualTo(expected.getFailures());
- assertThat( actual.getSkipped() )
- .isEqualTo( expected.getSkipped() );
+ assertThat(actual.getSkipped()).isEqualTo(expected.getSkipped());
- assertThat( actual.getFailure() )
- .isEqualTo( expected.getFailure() );
+ 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 14f7d1762f..b395f4ce84 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,3 +1,21 @@
+/*
+ * 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.
+ */
package org.apache.maven.plugin.failsafe;
/*
@@ -19,124 +37,97 @@
* under the License.
*/
+import java.io.File;
+
import org.apache.maven.plugin.failsafe.util.FailsafeSummaryXmlUtils;
import org.apache.maven.surefire.api.suite.RunResult;
import org.apache.maven.surefire.api.util.SureFireFileManager;
import org.junit.Test;
-import java.io.File;
-
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Tibor Digana (tibor17)
* @since 2.20
*/
-@SuppressWarnings( "checkstyle:magicnumber" )
-public class RunResultTest
-{
+@SuppressWarnings("checkstyle:magicnumber")
+public class RunResultTest {
@Test
- public void testAggregatedValues()
- {
+ public void testAggregatedValues() {
RunResult simple = getSimpleAggregate();
- assertThat( simple.getCompletedCount() )
- .isEqualTo( 20 );
+ assertThat(simple.getCompletedCount()).isEqualTo(20);
- assertThat( simple.getErrors() )
- .isEqualTo( 3 );
+ assertThat(simple.getErrors()).isEqualTo(3);
- assertThat( simple.getFailures() )
- .isEqualTo( 7 );
+ assertThat(simple.getFailures()).isEqualTo(7);
- assertThat( simple.getSkipped() )
- .isEqualTo( 4 );
+ assertThat(simple.getSkipped()).isEqualTo(4);
- assertThat( simple.getFlakes() )
- .isEqualTo( 2 );
+ assertThat(simple.getFlakes()).isEqualTo(2);
}
@Test
- public void testSerialization()
- throws Exception
- {
- writeReadCheck( getSimpleAggregate() );
+ public void testSerialization() throws Exception {
+ writeReadCheck(getSimpleAggregate());
}
@Test
- public void testFailures()
- throws Exception
- {
- writeReadCheck( new RunResult( 0, 1, 2, 3, "stacktraceHere", false ) );
+ public void testFailures() throws Exception {
+ writeReadCheck(new RunResult(0, 1, 2, 3, "stacktraceHere", false));
}
@Test
- public void testSkipped()
- throws Exception
- {
- writeReadCheck( new RunResult( 3, 2, 1, 0, null, true ) );
+ public void testSkipped() throws Exception {
+ writeReadCheck(new RunResult(3, 2, 1, 0, null, true));
}
@Test
- public void testAppendSerialization()
- throws Exception
- {
+ public void testAppendSerialization() throws Exception {
RunResult simpleAggregate = getSimpleAggregate();
- RunResult additional = new RunResult( 2, 1, 2, 2, "msg " + ( (char) 0x0E01 ), true );
+ RunResult additional = new RunResult(2, 1, 2, 2, "msg " + ((char) 0x0E01), true);
- File summary = SureFireFileManager.createTempFile( "failsafe", "test" );
- FailsafeSummaryXmlUtils.writeSummary( simpleAggregate, summary, false );
- FailsafeSummaryXmlUtils.writeSummary( additional, summary, true );
- RunResult actual = FailsafeSummaryXmlUtils.toRunResult( summary );
+ File summary = SureFireFileManager.createTempFile("failsafe", "test");
+ FailsafeSummaryXmlUtils.writeSummary(simpleAggregate, summary, false);
+ FailsafeSummaryXmlUtils.writeSummary(additional, summary, true);
+ RunResult actual = FailsafeSummaryXmlUtils.toRunResult(summary);
//noinspection ResultOfMethodCallIgnored
summary.delete();
- RunResult expected = simpleAggregate.aggregate( additional );
+ RunResult expected = simpleAggregate.aggregate(additional);
- assertThat( expected.getCompletedCount() )
- .isEqualTo( 22 );
+ assertThat(expected.getCompletedCount()).isEqualTo(22);
- assertThat( expected.getErrors() )
- .isEqualTo( 4 );
+ assertThat(expected.getErrors()).isEqualTo(4);
- assertThat( expected.getFailures() )
- .isEqualTo( 9 );
+ assertThat(expected.getFailures()).isEqualTo(9);
- assertThat( expected.getSkipped() )
- .isEqualTo( 6 );
+ assertThat(expected.getSkipped()).isEqualTo(6);
- assertThat( expected.getFlakes() )
- .isEqualTo( 2 );
+ assertThat(expected.getFlakes()).isEqualTo(2);
- assertThat( expected.getFailure() )
- .isEqualTo( "msg " + ( (char) 0x0E01 ) );
+ assertThat(expected.getFailure()).isEqualTo("msg " + ((char) 0x0E01));
- assertThat( expected.isTimeout() )
- .isTrue();
+ assertThat(expected.isTimeout()).isTrue();
- assertThat( actual )
- .isEqualTo( expected );
+ assertThat(actual).isEqualTo(expected);
}
- private void writeReadCheck( RunResult expected )
- throws Exception
- {
- File tmp = SureFireFileManager.createTempFile( "test", "xml" );
- FailsafeSummaryXmlUtils.fromRunResultToFile( expected, tmp );
+ private void writeReadCheck(RunResult expected) throws Exception {
+ File tmp = SureFireFileManager.createTempFile("test", "xml");
+ FailsafeSummaryXmlUtils.fromRunResultToFile(expected, tmp);
- RunResult actual = FailsafeSummaryXmlUtils.toRunResult( tmp );
+ RunResult actual = FailsafeSummaryXmlUtils.toRunResult(tmp);
//noinspection ResultOfMethodCallIgnored
tmp.delete();
- assertThat( actual )
- .isEqualTo( expected );
+ 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 );
+ 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-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/VerifyMojoTest.java b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/VerifyMojoTest.java
index 37bd3b733f..91422956be 100644
--- a/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/VerifyMojoTest.java
+++ b/maven-failsafe-plugin/src/test/java/org/apache/maven/plugin/failsafe/VerifyMojoTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
package org.apache.maven.plugin.failsafe;
/*
@@ -19,9 +37,6 @@
* under the License.
*/
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URL;
@@ -37,72 +52,68 @@
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
/**
*/
-public class VerifyMojoTest
-{
+public class VerifyMojoTest {
private VerifyMojo mojo;
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
@Before
- public void init() throws UnsupportedEncodingException
- {
+ public void init() throws UnsupportedEncodingException {
mojo = new VerifyMojo();
- mojo.setTestClassesDirectory( tempFolder.getRoot() );
- mojo.setReportsDirectory( getTestBaseDir() );
+ mojo.setTestClassesDirectory(tempFolder.getRoot());
+ mojo.setReportsDirectory(getTestBaseDir());
}
- private void setupExecuteMocks()
- {
- Logger logger = mock( Logger.class );
- when( logger.isErrorEnabled() ).thenReturn( true );
- when( logger.isWarnEnabled() ).thenReturn( true );
- when( logger.isInfoEnabled() ).thenReturn( true );
- when( logger.isDebugEnabled() ).thenReturn( false );
- mojo.setLogger( logger );
+ private void setupExecuteMocks() {
+ Logger logger = mock(Logger.class);
+ when(logger.isErrorEnabled()).thenReturn(true);
+ when(logger.isWarnEnabled()).thenReturn(true);
+ when(logger.isInfoEnabled()).thenReturn(true);
+ when(logger.isDebugEnabled()).thenReturn(false);
+ mojo.setLogger(logger);
- MavenSession session = mock( MavenSession.class );
- MavenExecutionRequest request = mock ( MavenExecutionRequest.class );
- when( request.isShowErrors() ).thenReturn( true );
- when( request.getReactorFailureBehavior() ).thenReturn( null );
- when( session.getRequest() ).thenReturn( request );
- mojo.setSession( session );
+ MavenSession session = mock(MavenSession.class);
+ MavenExecutionRequest request = mock(MavenExecutionRequest.class);
+ when(request.isShowErrors()).thenReturn(true);
+ when(request.getReactorFailureBehavior()).thenReturn(null);
+ when(session.getRequest()).thenReturn(request);
+ mojo.setSession(session);
}
- private File getTestBaseDir()
- throws UnsupportedEncodingException
- {
- URL resource = getClass().getResource( "/verify-mojo" );
+ private File getTestBaseDir() throws UnsupportedEncodingException {
+ URL resource = getClass().getResource("/verify-mojo");
// URLDecoder.decode necessary for JDK 1.5+, where spaces are escaped to %20
- return new File( URLDecoder.decode( resource.getPath(), "UTF-8" ) ).getAbsoluteFile();
+ return new File(URLDecoder.decode(resource.getPath(), "UTF-8")).getAbsoluteFile();
}
- @Test( expected = MojoExecutionException.class )
- public void executeForForkError() throws MojoExecutionException, MojoFailureException, UnsupportedEncodingException
- {
+ @Test(expected = MojoExecutionException.class)
+ public void executeForForkError()
+ throws MojoExecutionException, MojoFailureException, UnsupportedEncodingException {
setupExecuteMocks();
- mojo.setSummaryFile( new File( getTestBaseDir(), "failsafe-summary-booter-fork-error.xml" ) );
+ mojo.setSummaryFile(new File(getTestBaseDir(), "failsafe-summary-booter-fork-error.xml"));
mojo.execute();
}
- @Test( expected = MojoExecutionException.class )
- public void executeForForkErrorTestFailureIgnore() throws MojoExecutionException, MojoFailureException,
- UnsupportedEncodingException
- {
+ @Test(expected = MojoExecutionException.class)
+ public void executeForForkErrorTestFailureIgnore()
+ throws MojoExecutionException, MojoFailureException, UnsupportedEncodingException {
setupExecuteMocks();
- mojo.setSummaryFile( new File( getTestBaseDir(), "failsafe-summary-booter-fork-error.xml" ) );
- mojo.setTestFailureIgnore( true );
+ mojo.setSummaryFile(new File(getTestBaseDir(), "failsafe-summary-booter-fork-error.xml"));
+ mojo.setTestFailureIgnore(true);
mojo.execute();
}
@Test
- public void executeForPassingTests() throws MojoExecutionException, MojoFailureException,
- UnsupportedEncodingException
- {
+ public void executeForPassingTests()
+ throws MojoExecutionException, MojoFailureException, UnsupportedEncodingException {
setupExecuteMocks();
- mojo.setSummaryFile( new File( getTestBaseDir(), "failsafe-summary-success.xml" ) );
+ mojo.setSummaryFile(new File(getTestBaseDir(), "failsafe-summary-success.xml"));
mojo.execute();
}
}
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index 100cc3da37..82abed6148 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -17,149 +17,149 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
- 4.0.0
+ 4.0.0
-
- org.apache.maven.surefire
- surefire
- 3.0.0-M10-SNAPSHOT
-
+
+ org.apache.maven.surefire
+ surefire
+ 3.0.0-M10-SNAPSHOT
+
- maven-surefire-common
+ maven-surefire-common
- Maven Surefire Common
- API used in Surefire and Failsafe MOJO.
+ Maven Surefire Common
+ API used in Surefire and Failsafe MOJO.
-
-
- org.apache.maven.surefire
- surefire-api
- ${project.version}
-
-
- org.apache.maven.surefire
- surefire-extensions-api
- ${project.version}
-
-
- org.apache.maven.surefire
- surefire-booter
- ${project.version}
-
-
- org.apache.maven
- maven-core
- provided
-
-
- org.apache.maven.plugin-tools
- maven-plugin-annotations
- provided
-
-
- org.apache.maven.shared
- maven-common-artifact-filters
-
-
- org.codehaus.plexus
- plexus-java
-
-
- org.fusesource.jansi
- jansi
- provided
-
-
- org.apache.maven.surefire
- surefire-shared-utils
- ${surefire-shared-utils.version}
-
-
- com.google.code.findbugs
- jsr305
- provided
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-core
- test
-
-
- org.powermock
- powermock-module-junit4
- test
-
-
- org.powermock
- powermock-api-mockito2
- test
-
-
- org.jacoco
- org.jacoco.agent
- runtime
- test
-
-
+
+
+ org.apache.maven.surefire
+ surefire-api
+ ${project.version}
+
+
+ org.apache.maven.surefire
+ surefire-extensions-api
+ ${project.version}
+
+
+ org.apache.maven.surefire
+ surefire-booter
+ ${project.version}
+
+
+ org.apache.maven
+ maven-core
+ provided
+
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ provided
+
+
+ org.apache.maven.shared
+ maven-common-artifact-filters
+
+
+ org.codehaus.plexus
+ plexus-java
+
+
+ org.fusesource.jansi
+ jansi
+ provided
+
+
+ org.apache.maven.surefire
+ surefire-shared-utils
+ ${surefire-shared-utils.version}
+
+
+ com.google.code.findbugs
+ jsr305
+ provided
+
+
+ org.mockito
+ mockito-core
+ test
+
+
+ org.powermock
+ powermock-core
+ test
+
+
+ org.powermock
+ powermock-module-junit4
+ test
+
+
+ org.powermock
+ powermock-api-mockito2
+ test
+
+
+ org.jacoco
+ org.jacoco.agent
+ runtime
+ test
+
+
-
-
-
- org.jacoco
- jacoco-maven-plugin
-
-
- jacoco-instrumentation
-
- instrument
-
-
-
- restore-classes
-
- restore-instrumented-classes
-
-
-
-
-
- maven-surefire-plugin
-
-
- org.apache.maven.surefire
- surefire-shadefire
- 3.0.0-M7
-
-
-
- ${jvm.args.tests}
-
- **/JUnit4SuiteTest.java
-
-
- ${project.build.directory}/jacoco.exec
-
-
-
-
- org.codehaus.plexus
- plexus-component-metadata
- 2.1.1
-
-
-
- generate-metadata
-
-
-
-
-
-
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ jacoco-instrumentation
+
+ instrument
+
+
+
+ restore-classes
+
+ restore-instrumented-classes
+
+
+
+
+
+ maven-surefire-plugin
+
+ ${jvm.args.tests}
+
+ **/JUnit4SuiteTest.java
+
+
+ ${project.build.directory}/jacoco.exec
+
+
+
+
+ org.apache.maven.surefire
+ surefire-shadefire
+ 3.0.0-M7
+
+
+
+
+
+ org.codehaus.plexus
+ plexus-component-metadata
+ 2.1.1
+
+
+
+ generate-metadata
+
+
+
+
+
+
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 30709011fb..2c0365627b 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
@@ -1,6 +1,3 @@
-// CHECKSTYLE_OFF: FileLength|RegexpHeader
-package org.apache.maven.plugin.surefire;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -10,7 +7,7 @@
* "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
+ * 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
@@ -19,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugin.surefire;
import javax.annotation.Nonnull;
@@ -164,12 +162,9 @@
* @author Stephen Connolly
* @version $Id: SurefirePlugin.java 945065 2010-05-17 10:26:22Z stephenc $
*/
-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,)" );
+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 final ClasspathCache classpathCache = new ClasspathCache();
@@ -192,7 +187,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.12
*/
- @Parameter( defaultValue = "${plugin}", readonly = true, required = true )
+ @Parameter(defaultValue = "${plugin}", readonly = true, required = true)
private PluginDescriptor pluginDescriptor;
/**
@@ -203,7 +198,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.4
*/
- @Parameter( property = "skipTests", defaultValue = "false" )
+ @Parameter(property = "skipTests", defaultValue = "false")
protected boolean skipTests;
/**
@@ -213,7 +208,7 @@ public abstract class AbstractSurefireMojo
* @deprecated Use skipTests instead.
*/
@Deprecated
- @Parameter( property = "maven.test.skip.exec" )
+ @Parameter(property = "maven.test.skip.exec")
protected boolean skipExec;
/**
@@ -221,27 +216,27 @@ public abstract class AbstractSurefireMojo
* the "maven.test.skip" property, because maven.test.skip disables both running the tests and compiling the tests.
* Consider using the {@code skipTests} parameter instead.
*/
- @Parameter( property = "maven.test.skip", defaultValue = "false" )
+ @Parameter(property = "maven.test.skip", defaultValue = "false")
protected boolean skip;
/**
* The Maven Project Object.
*/
- @Parameter( defaultValue = "${project}", required = true, readonly = true )
+ @Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject project;
/**
* The base directory of the project being tested. This can be obtained in your integration test via
* System.getProperty("basedir").
*/
- @Parameter( defaultValue = "${basedir}", readonly = true, required = true )
+ @Parameter(defaultValue = "${basedir}", readonly = true, required = true)
protected File basedir;
/**
* The directory containing generated test classes of the project being tested. This will be included at the
* beginning of the test classpath. *
*/
- @Parameter( defaultValue = "${project.build.testOutputDirectory}" )
+ @Parameter(defaultValue = "${project.build.testOutputDirectory}")
protected File testClassesDirectory;
/**
@@ -250,7 +245,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.6
*/
- @Parameter( property = "maven.test.dependency.excludes" )
+ @Parameter(property = "maven.test.dependency.excludes")
private String[] classpathDependencyExcludes;
/**
@@ -267,7 +262,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.6
*/
- @Parameter( defaultValue = "" )
+ @Parameter(defaultValue = "")
private String classpathDependencyScopeExclude;
/**
@@ -275,7 +270,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.4
*/
- @Parameter( property = "maven.test.additionalClasspath" )
+ @Parameter(property = "maven.test.additionalClasspath")
private String[] additionalClasspathElements;
/**
@@ -284,14 +279,14 @@ public abstract class AbstractSurefireMojo
*
* @since 2.2
*/
- @Parameter( defaultValue = "${project.build.testSourceDirectory}" )
+ @Parameter(defaultValue = "${project.build.testSourceDirectory}")
private File testSourceDirectory;
/**
* ArtifactRepository of the localRepository. To obtain the directory of localRepository in unit tests use
* System.getProperty("localRepository").
*/
- @Parameter( defaultValue = "${localRepository}", required = true, readonly = true )
+ @Parameter(defaultValue = "${localRepository}", required = true, readonly = true)
private ArtifactRepository localRepository;
/**
@@ -323,13 +318,13 @@ public abstract class AbstractSurefireMojo
/**
* Map of plugin artifacts.
*/
- @Parameter( property = "plugin.artifactMap", required = true, readonly = true )
+ @Parameter(property = "plugin.artifactMap", required = true, readonly = true)
private Map pluginArtifactMap;
/**
* Map of project artifacts.
*/
- @Parameter( property = "project.artifactMap", readonly = true, required = true )
+ @Parameter(property = "project.artifactMap", readonly = true, required = true)
private Map projectArtifactMap;
/**
@@ -338,7 +333,7 @@ public abstract class AbstractSurefireMojo
* File TEST-testClassName-reportNameSuffix.xml has changed attributes 'testsuite'--'name'
* and 'testcase'--'classname' - reportNameSuffix is added to the attribute value.
*/
- @Parameter( property = "surefire.reportNameSuffix", defaultValue = "" )
+ @Parameter(property = "surefire.reportNameSuffix", defaultValue = "")
private String reportNameSuffix;
/**
@@ -347,7 +342,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.3
*/
- @Parameter( property = "maven.test.redirectTestOutputToFile", defaultValue = "false" )
+ @Parameter(property = "maven.test.redirectTestOutputToFile", defaultValue = "false")
private boolean redirectTestOutputToFile;
/**
@@ -355,7 +350,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.4
*/
- @Parameter( property = "failIfNoTests", defaultValue = "false" )
+ @Parameter(property = "failIfNoTests", defaultValue = "false")
private boolean failIfNoTests;
/**
@@ -369,7 +364,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.20
*/
- @Parameter( property = "tempDir", defaultValue = "surefire" )
+ @Parameter(property = "tempDir", defaultValue = "surefire")
private String tempDir;
/**
@@ -379,7 +374,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.1
*/
- @Parameter( property = "jvm" )
+ @Parameter(property = "jvm")
private String jvm;
/**
@@ -398,7 +393,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.1
*/
- @Parameter( property = "argLine" )
+ @Parameter(property = "argLine")
private String argLine;
/**
@@ -414,7 +409,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.1.3
*/
- @Parameter( property = "basedir" )
+ @Parameter(property = "basedir")
private File workingDirectory;
/**
@@ -425,7 +420,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.1
*/
- @Parameter( property = "childDelegation", defaultValue = "false" )
+ @Parameter(property = "childDelegation", defaultValue = "false")
private boolean childDelegation;
/**
@@ -441,7 +436,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.2
*/
- @Parameter( property = "groups" )
+ @Parameter(property = "groups")
private String groups;
/**
@@ -457,7 +452,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.2
*/
- @Parameter( property = "excludedGroups" )
+ @Parameter(property = "excludedGroups")
private String excludedGroups;
/**
@@ -465,7 +460,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.3.1
*/
- @Parameter( property = "junitArtifactName", defaultValue = "junit:junit" )
+ @Parameter(property = "junitArtifactName", defaultValue = "junit:junit")
private String junitArtifactName;
/**
@@ -473,7 +468,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.3.1
*/
- @Parameter( property = "testNGArtifactName", defaultValue = "org.testng:testng" )
+ @Parameter(property = "testNGArtifactName", defaultValue = "org.testng:testng")
private String testNGArtifactName;
/**
@@ -482,7 +477,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.2
*/
- @Parameter( property = "threadCount" )
+ @Parameter(property = "threadCount")
private int threadCount;
/**
@@ -500,7 +495,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.14
*/
- @Parameter( property = "forkCount", defaultValue = "1" )
+ @Parameter(property = "forkCount", defaultValue = "1")
private String forkCount;
/**
@@ -509,8 +504,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.13
*/
-
- @Parameter( property = "reuseForks", defaultValue = "true" )
+ @Parameter(property = "reuseForks", defaultValue = "true")
private boolean reuseForks;
/**
@@ -519,7 +513,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.5
*/
- @Parameter( property = "perCoreThreadCount", defaultValue = "true" )
+ @Parameter(property = "perCoreThreadCount", defaultValue = "true")
private boolean perCoreThreadCount;
/**
@@ -529,7 +523,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.5
*/
- @Parameter( property = "useUnlimitedThreads", defaultValue = "false" )
+ @Parameter(property = "useUnlimitedThreads", defaultValue = "false")
private boolean useUnlimitedThreads;
/**
@@ -555,7 +549,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.2
*/
- @Parameter( property = "parallel" )
+ @Parameter(property = "parallel")
private String parallel;
/**
@@ -566,7 +560,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.17
*/
- @Parameter( property = "parallelOptimized", defaultValue = "true" )
+ @Parameter(property = "parallelOptimized", defaultValue = "true")
private boolean parallelOptimized;
/**
@@ -585,7 +579,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.16
*/
- @Parameter( property = "threadCountSuites", defaultValue = "0" )
+ @Parameter(property = "threadCountSuites", defaultValue = "0")
private int threadCountSuites;
/**
@@ -608,7 +602,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.16
*/
- @Parameter( property = "threadCountClasses", defaultValue = "0" )
+ @Parameter(property = "threadCountClasses", defaultValue = "0")
private int threadCountClasses;
/**
@@ -630,7 +624,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.16
*/
- @Parameter( property = "threadCountMethods", defaultValue = "0" )
+ @Parameter(property = "threadCountMethods", defaultValue = "0")
private int threadCountMethods;
/**
@@ -638,7 +632,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.2
*/
- @Parameter( property = "trimStackTrace", defaultValue = "false" )
+ @Parameter(property = "trimStackTrace", defaultValue = "false")
private boolean trimStackTrace;
/**
@@ -646,10 +640,10 @@ public abstract class AbstractSurefireMojo
*
* @since 2.2
*/
- @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true )
+ @Parameter(defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true)
private List remoteRepositories;
- @Parameter( defaultValue = "${project.remoteArtifactRepositories}", required = true, readonly = true )
+ @Parameter(defaultValue = "${project.remoteArtifactRepositories}", required = true, readonly = true)
private List projectRemoteRepositories;
/**
@@ -659,7 +653,7 @@ public abstract class AbstractSurefireMojo
* @since 2.2
*/
@Deprecated // todo make readonly to handle system property
- @Parameter( property = "disableXmlReport", defaultValue = "false" )
+ @Parameter(property = "disableXmlReport", defaultValue = "false")
private boolean disableXmlReport;
/**
@@ -668,13 +662,13 @@ public abstract class AbstractSurefireMojo
*
* @since 2.3.1
*/
- @Parameter( property = "enableAssertions", defaultValue = "true" )
+ @Parameter(property = "enableAssertions", defaultValue = "true")
private boolean enableAssertions;
/**
* The current build session instance.
*/
- @Parameter( defaultValue = "${session}", required = true, readonly = true )
+ @Parameter(defaultValue = "${session}", required = true, readonly = true)
private MavenSession session;
@Component
@@ -685,20 +679,20 @@ public abstract class AbstractSurefireMojo
*
* @since 2.5
*/
- @Parameter( property = "objectFactory" )
+ @Parameter(property = "objectFactory")
private String objectFactory;
/**
* Parallel Maven Execution.
*/
- @Parameter( defaultValue = "${session.parallel}", readonly = true )
+ @Parameter(defaultValue = "${session.parallel}", readonly = true)
private Boolean parallelMavenExecution;
/**
* Read-only parameter with value of Maven property project.build.directory.
* @since 2.20
*/
- @Parameter( defaultValue = "${project.build.directory}", readonly = true, required = true )
+ @Parameter(defaultValue = "${project.build.directory}", readonly = true, required = true)
private File projectBuildDirectory;
/**
@@ -729,7 +723,7 @@ public abstract class AbstractSurefireMojo
*
* @since 2.15
*/
- @Parameter( property = "dependenciesToScan" )
+ @Parameter(property = "dependenciesToScan")
private String[] dependenciesToScan;
/**
@@ -800,7 +794,7 @@ public abstract class AbstractSurefireMojo
public abstract File getIncludesFile();
@Override
- public abstract void setIncludes( List includes );
+ public abstract void setIncludes(List includes);
public abstract File getExcludesFile();
@@ -821,18 +815,18 @@ public abstract class AbstractSurefireMojo
public abstract File[] getSuiteXmlFiles();
- public abstract void setSuiteXmlFiles( File[] suiteXmlFiles );
+ public abstract void setSuiteXmlFiles(File[] suiteXmlFiles);
public abstract String getRunOrder();
- public abstract void setRunOrder( String runOrder );
+ public abstract void setRunOrder(String runOrder);
public abstract Long getRunOrderRandomSeed();
- public abstract void setRunOrderRandomSeed( Long runOrderRandomSeed );
+ public abstract void setRunOrderRandomSeed(Long runOrderRandomSeed);
- protected abstract void handleSummary( RunResult summary, Exception firstForkException )
- throws MojoExecutionException, MojoFailureException;
+ protected abstract void handleSummary(RunResult summary, Exception firstForkException)
+ throws MojoExecutionException, MojoFailureException;
protected abstract boolean isSkipExecution();
@@ -842,7 +836,7 @@ protected abstract void handleSummary( RunResult summary, Exception firstForkExc
protected abstract boolean useModulePath();
- protected abstract void setUseModulePath( boolean useModulePath );
+ protected abstract void setUseModulePath(boolean useModulePath);
protected abstract String getEnableProcessChecker();
@@ -853,13 +847,11 @@ protected abstract void handleSummary( RunResult summary, Exception firstForkExc
*
* @return non-null plugin artifact
*/
- protected Artifact getMojoArtifact()
- {
+ protected Artifact getMojoArtifact() {
return getPluginDescriptor().getPluginArtifact();
}
- private String getDefaultExcludes()
- {
+ private String getDefaultExcludes() {
return "**/*$*";
}
@@ -874,233 +866,186 @@ private String getDefaultExcludes()
private volatile PluginConsoleLogger consoleLogger;
@Override
- public void execute()
- throws MojoExecutionException, MojoFailureException
- {
+ public void execute() throws MojoExecutionException, MojoFailureException {
cli = commandLineOptions();
// Stuff that should have been final
setupStuff();
- Platform platform = PLATFORM.withJdkExecAttributesForTests( getEffectiveJvm() );
- Thread shutdownThread = new Thread( platform::setShutdownState );
- addShutDownHook( shutdownThread );
- try
- {
- if ( verifyParameters() && !hasExecutedBefore() )
- {
+ Platform platform = PLATFORM.withJdkExecAttributesForTests(getEffectiveJvm());
+ Thread shutdownThread = new Thread(platform::setShutdownState);
+ addShutDownHook(shutdownThread);
+ try {
+ if (verifyParameters() && !hasExecutedBefore()) {
DefaultScanResult scan = scanForTestClasses();
- if ( !hasSuiteXmlFiles() && scan.isEmpty() )
- {
- switch ( getEffectiveFailIfNoTests() )
- {
+ if (!hasSuiteXmlFiles() && scan.isEmpty()) {
+ switch (getEffectiveFailIfNoTests()) {
case COULD_NOT_RUN_DEFAULT_TESTS:
throw new MojoFailureException(
- "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" );
+ "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)");
case COULD_NOT_RUN_SPECIFIED_TESTS:
- throw new MojoFailureException( "No tests matching pattern \""
- + getSpecificTests().toString()
- + "\" were executed! (Set "
- + "-D" + getPluginName()
- + ".failIfNoSpecifiedTests=false to ignore this error.)" );
+ throw new MojoFailureException("No tests matching pattern \""
+ + getSpecificTests().toString()
+ + "\" were executed! (Set "
+ + "-D" + getPluginName()
+ + ".failIfNoSpecifiedTests=false to ignore this error.)");
default:
- handleSummary( noTestsRun(), null );
+ handleSummary(noTestsRun(), null);
return;
}
}
logReportsDirectory();
- executeAfterPreconditionsChecked( scan, platform );
+ executeAfterPreconditionsChecked(scan, platform);
}
- }
- finally
- {
+ } finally {
platform.clearShutdownState();
- removeShutdownHook( shutdownThread );
+ removeShutdownHook(shutdownThread);
}
}
- void setLogger( Logger logger )
- {
+ void setLogger(Logger logger) {
this.logger = logger;
}
@Nonnull
- protected final PluginConsoleLogger getConsoleLogger()
- {
- if ( consoleLogger == null )
- {
- synchronized ( this )
- {
- if ( consoleLogger == null )
- {
- consoleLogger = new PluginConsoleLogger( logger );
+ protected final PluginConsoleLogger getConsoleLogger() {
+ if (consoleLogger == null) {
+ synchronized (this) {
+ if (consoleLogger == null) {
+ consoleLogger = new PluginConsoleLogger(logger);
}
}
}
return consoleLogger;
}
- private static Toolchain getToolchainMaven33x( Class toolchainManagerType,
- T toolchainManager,
- MavenSession session,
- Map toolchainArgs )
- throws MojoFailureException
- {
+ private static Toolchain getToolchainMaven33x(
+ Class toolchainManagerType, T toolchainManager, MavenSession session, Map toolchainArgs)
+ throws MojoFailureException {
Method getToolchainsMethod =
- tryGetMethod( toolchainManagerType, "getToolchains", MavenSession.class, String.class, Map.class );
- if ( getToolchainsMethod != null )
- {
+ tryGetMethod(toolchainManagerType, "getToolchains", MavenSession.class, String.class, Map.class);
+ if (getToolchainsMethod != null) {
//noinspection unchecked
- List tcs = invokeMethodWithArray( toolchainManager,
- getToolchainsMethod, session, "jdk", toolchainArgs );
- if ( tcs.isEmpty() )
- {
+ List tcs =
+ invokeMethodWithArray(toolchainManager, getToolchainsMethod, session, "jdk", toolchainArgs);
+ if (tcs.isEmpty()) {
throw new MojoFailureException(
- "Requested toolchain specification did not match any configured toolchain: " + toolchainArgs );
+ "Requested toolchain specification did not match any configured toolchain: " + toolchainArgs);
}
- return tcs.get( 0 );
+ return tcs.get(0);
}
return null;
}
- //TODO remove the part with ToolchainManager lookup once we depend on
- //3.0.9 (have it as prerequisite). Define as regular component field then.
- private Toolchain getToolchain() throws MojoFailureException
- {
+ // TODO remove the part with ToolchainManager lookup once we depend on
+ // 3.0.9 (have it as prerequisite). Define as regular component field then.
+ private Toolchain getToolchain() throws MojoFailureException {
Toolchain tc = null;
- if ( getJdkToolchain() != null )
- {
- tc = getToolchainMaven33x( ToolchainManager.class, getToolchainManager(), getSession(), getJdkToolchain() );
+ if (getJdkToolchain() != null) {
+ tc = getToolchainMaven33x(ToolchainManager.class, getToolchainManager(), getSession(), getJdkToolchain());
}
- if ( tc == null )
- {
- tc = getToolchainManager().getToolchainFromBuildContext( "jdk", getSession() );
+ if (tc == null) {
+ tc = getToolchainManager().getToolchainFromBuildContext("jdk", getSession());
}
return tc;
}
- private void setupStuff() throws MojoFailureException
- {
- surefireDependencyResolver = new SurefireDependencyResolver( getRepositorySystem(),
- getConsoleLogger(), getLocalRepository(),
+ private void setupStuff() throws MojoFailureException {
+ surefireDependencyResolver = new SurefireDependencyResolver(
+ getRepositorySystem(),
+ getConsoleLogger(),
+ getLocalRepository(),
getRemoteRepositories(),
getProjectRemoteRepositories(),
resolutionErrorHandler,
getPluginName(),
- getSession().isOffline() );
+ getSession().isOffline());
- if ( getBooterArtifact() == null )
- {
- throw new RuntimeException( "Unable to locate surefire-booter in the list of plugin artifacts" );
+ if (getBooterArtifact() == null) {
+ throw new RuntimeException("Unable to locate surefire-booter in the list of plugin artifacts");
}
- if ( getToolchainManager() != null )
- {
+ if (getToolchainManager() != null) {
toolchain = getToolchain();
}
}
@Nonnull
- private DefaultScanResult scanForTestClasses()
- throws MojoFailureException
- {
+ private DefaultScanResult scanForTestClasses() throws MojoFailureException {
DefaultScanResult scan = scanDirectories();
DefaultScanResult scanDeps = scanDependencies();
- return scan.append( scanDeps );
+ return scan.append(scanDeps);
}
- private DefaultScanResult scanDirectories()
- throws MojoFailureException
- {
- DirectoryScanner scanner = new DirectoryScanner( getTestClassesDirectory(), getIncludedAndExcludedTests() );
+ private DefaultScanResult scanDirectories() throws MojoFailureException {
+ DirectoryScanner scanner = new DirectoryScanner(getTestClassesDirectory(), getIncludedAndExcludedTests());
return scanner.scan();
}
- List getProjectTestArtifacts()
- {
+ List getProjectTestArtifacts() {
return project.getTestArtifacts();
}
- DefaultScanResult scanDependencies() throws MojoFailureException
- {
- if ( getDependenciesToScan() == null )
- {
+ DefaultScanResult scanDependencies() throws MojoFailureException {
+ if (getDependenciesToScan() == null) {
return null;
- }
- else
- {
- try
- {
+ } else {
+ try {
DefaultScanResult result = null;
- List dependenciesToScan =
- filter( getProjectTestArtifacts(), asList( getDependenciesToScan() ) );
+ List dependenciesToScan = filter(getProjectTestArtifacts(), asList(getDependenciesToScan()));
- for ( Artifact artifact : dependenciesToScan )
- {
+ for (Artifact artifact : dependenciesToScan) {
String type = artifact.getType();
File out = artifact.getFile();
- if ( out == null || !out.exists()
- || !( "jar".equals( type ) || out.isDirectory() || out.getName().endsWith( ".jar" ) ) )
- {
+ if (out == null
+ || !out.exists()
+ || !("jar".equals(type)
+ || out.isDirectory()
+ || out.getName().endsWith(".jar"))) {
continue;
}
- if ( out.isFile() )
- {
+ if (out.isFile()) {
DependencyScanner scanner =
- new DependencyScanner( singletonList( out ), getIncludedAndExcludedTests() );
- result = result == null ? scanner.scan() : result.append( scanner.scan() );
- }
- else if ( out.isDirectory() )
- {
- DirectoryScanner scanner =
- new DirectoryScanner( out, getIncludedAndExcludedTests() );
- result = result == null ? scanner.scan() : result.append( scanner.scan() );
+ new DependencyScanner(singletonList(out), getIncludedAndExcludedTests());
+ result = result == null ? scanner.scan() : result.append(scanner.scan());
+ } else if (out.isDirectory()) {
+ DirectoryScanner scanner = new DirectoryScanner(out, getIncludedAndExcludedTests());
+ result = result == null ? scanner.scan() : result.append(scanner.scan());
}
}
return result;
- }
- catch ( Exception e )
- {
- throw new MojoFailureException( e.getLocalizedMessage(), e );
+ } catch (Exception e) {
+ throw new MojoFailureException(e.getLocalizedMessage(), e);
}
}
}
- boolean verifyParameters()
- throws MojoFailureException, MojoExecutionException
- {
- setProperties( new SurefireProperties( getProperties() ) );
- if ( isSkipExecution() )
- {
- getConsoleLogger().info( "Tests are skipped." );
+ boolean verifyParameters() throws MojoFailureException, MojoExecutionException {
+ setProperties(new SurefireProperties(getProperties()));
+ if (isSkipExecution()) {
+ getConsoleLogger().info("Tests are skipped.");
return false;
}
String jvmToUse = getJvm();
- if ( toolchain != null )
- {
- getConsoleLogger().info( "Toolchain in maven-" + getPluginName() + "-plugin: " + toolchain );
- if ( jvmToUse != null )
- {
- getConsoleLogger().warning( "Toolchains are ignored, 'jvm' parameter is set to " + jvmToUse );
+ if (toolchain != null) {
+ getConsoleLogger().info("Toolchain in maven-" + getPluginName() + "-plugin: " + toolchain);
+ if (jvmToUse != null) {
+ getConsoleLogger().warning("Toolchains are ignored, 'jvm' parameter is set to " + jvmToUse);
}
}
- if ( !getTestClassesDirectory().exists()
- && ( getDependenciesToScan() == null || getDependenciesToScan().length == 0 ) )
- {
- if ( getFailIfNoTests() )
- {
- throw new MojoFailureException( "No tests to run!" );
+ if (!getTestClassesDirectory().exists()
+ && (getDependenciesToScan() == null || getDependenciesToScan().length == 0)) {
+ if (getFailIfNoTests()) {
+ throw new MojoFailureException("No tests to run!");
}
- getConsoleLogger().info( "No tests to run." );
- }
- else
- {
+ getConsoleLogger().info("No tests to run.");
+ } else {
ensureEnableProcessChecker();
ensureWorkingDirectoryExists();
ensureParallelRunningCompatibility();
@@ -1117,465 +1062,381 @@ boolean verifyParameters()
return true;
}
- private void warnIfForkCountIsZero()
- {
- if ( "0".equals( getForkCount() ) )
- {
- getConsoleLogger().warning( "The parameter forkCount should likely not be 0. Forking a JVM for tests "
- + "improves test accuracy. Ensure to have a >= 1." );
+ private void warnIfForkCountIsZero() {
+ if ("0".equals(getForkCount())) {
+ getConsoleLogger()
+ .warning("The parameter forkCount should likely not be 0. Forking a JVM for tests "
+ + "improves test accuracy. Ensure to have a >= 1.");
}
}
- private void executeAfterPreconditionsChecked( @Nonnull DefaultScanResult scanResult, @Nonnull Platform platform )
- throws MojoExecutionException, MojoFailureException
- {
+ private void executeAfterPreconditionsChecked(@Nonnull DefaultScanResult scanResult, @Nonnull Platform platform)
+ throws MojoExecutionException, MojoFailureException {
TestClassPath testClasspath = generateTestClasspath();
- List providers = createProviders( testClasspath );
- ResolvePathResultWrapper wrapper = findModuleDescriptor( platform.getJdkExecAttributesForTests().getJdkHome() );
+ List providers = createProviders(testClasspath);
+ ResolvePathResultWrapper wrapper =
+ findModuleDescriptor(platform.getJdkExecAttributesForTests().getJdkHome());
RunResult current = noTestsRun();
Exception firstForkException = null;
- for ( ProviderInfo provider : providers )
- {
- try
- {
- current =
- current.aggregate( executeProvider( provider, scanResult, testClasspath, platform, wrapper ) );
- }
- catch ( SurefireBooterForkException | SurefireExecutionException | TestSetFailedException e )
- {
- if ( firstForkException == null )
- {
+ for (ProviderInfo provider : providers) {
+ try {
+ current = current.aggregate(executeProvider(provider, scanResult, testClasspath, platform, wrapper));
+ } catch (SurefireBooterForkException | SurefireExecutionException | TestSetFailedException e) {
+ if (firstForkException == null) {
firstForkException = e;
}
}
}
- if ( firstForkException != null )
- {
- current = failure( current, firstForkException );
+ if (firstForkException != null) {
+ current = failure(current, firstForkException);
}
- handleSummary( current, firstForkException );
+ handleSummary(current, firstForkException);
}
- protected List createProviders( TestClassPath testClasspath )
- throws MojoExecutionException
- {
+ protected List createProviders(TestClassPath testClasspath) throws MojoExecutionException {
Artifact junitDepArtifact = getJunitDepArtifact();
- return providerDetector.resolve( new DynamicProviderInfo( null ),
- new JUnitPlatformProviderInfo( getJUnitPlatformRunnerArtifact(), getJUnit5Artifact(), testClasspath ),
- new TestNgProviderInfo( getTestNgArtifact() ),
- new JUnitCoreProviderInfo( getJunitArtifact(), junitDepArtifact ),
- new JUnit4ProviderInfo( getJunitArtifact(), junitDepArtifact ),
- new JUnit3ProviderInfo() );
+ return providerDetector.resolve(
+ new DynamicProviderInfo(null),
+ new JUnitPlatformProviderInfo(getJUnitPlatformRunnerArtifact(), getJUnit5Artifact(), testClasspath),
+ new TestNgProviderInfo(getTestNgArtifact()),
+ new JUnitCoreProviderInfo(getJunitArtifact(), junitDepArtifact),
+ new JUnit4ProviderInfo(getJunitArtifact(), junitDepArtifact),
+ new JUnit3ProviderInfo());
}
- private SurefireProperties setupProperties()
- {
+ private SurefireProperties setupProperties() {
SurefireProperties sysProps = null;
- try
- {
- sysProps = SurefireProperties.loadProperties( getSystemPropertiesFile() );
- }
- catch ( IOException e )
- {
+ try {
+ sysProps = SurefireProperties.loadProperties(getSystemPropertiesFile());
+ } catch (IOException e) {
String msg = "The file '" + getSystemPropertiesFile().getAbsolutePath() + "' can't be read.";
- if ( getConsoleLogger().isDebugEnabled() )
- {
- getConsoleLogger().debug( msg, e );
- }
- else
- {
- getConsoleLogger().warning( msg );
- }
- }
-
- SurefireProperties result =
- SurefireProperties.calculateEffectiveProperties( getSystemProperties(), getSystemPropertyVariables(),
- getUserProperties(), sysProps );
-
- result.setProperty( "basedir", getBasedir().getAbsolutePath() );
- result.setProperty( "localRepository", getLocalRepository().getBasedir() );
- if ( isForking() )
- {
- for ( Object o : result.propertiesThatCannotBeSetASystemProperties() )
- {
- if ( getArgLine() == null || !getArgLine().contains( "-D" + o + "=" ) )
- {
- getConsoleLogger().warning( o + " cannot be set as system property, use -D"
- + o + "=... instead"
- );
+ if (getConsoleLogger().isDebugEnabled()) {
+ getConsoleLogger().debug(msg, e);
+ } else {
+ getConsoleLogger().warning(msg);
+ }
+ }
+
+ SurefireProperties result = SurefireProperties.calculateEffectiveProperties(
+ getSystemProperties(), getSystemPropertyVariables(), getUserProperties(), sysProps);
+
+ result.setProperty("basedir", getBasedir().getAbsolutePath());
+ result.setProperty("localRepository", getLocalRepository().getBasedir());
+ if (isForking()) {
+ for (Object o : result.propertiesThatCannotBeSetASystemProperties()) {
+ if (getArgLine() == null || !getArgLine().contains("-D" + o + "=")) {
+ getConsoleLogger()
+ .warning(o + " cannot be set as system property, use -D" + o
+ + "=... instead");
}
}
- for ( Object systemPropertyMatchingArgLine : systemPropertiesMatchingArgLine( result ) )
- {
+ for (Object systemPropertyMatchingArgLine : systemPropertiesMatchingArgLine(result)) {
getConsoleLogger()
- .warning( "The system property "
- + systemPropertyMatchingArgLine
- + " is configured twice! "
- + "The property appears in and any of , "
- + " or user property."
- );
+ .warning("The system property "
+ + systemPropertyMatchingArgLine
+ + " is configured twice! "
+ + "The property appears in and any of , "
+ + " or user property.");
}
- }
- else
- {
- result.setProperty( "user.dir", getWorkingDirectory().getAbsolutePath() );
+ } else {
+ result.setProperty("user.dir", getWorkingDirectory().getAbsolutePath());
}
- if ( getConsoleLogger().isDebugEnabled() )
- {
- showToLog( result, getConsoleLogger() );
+ if (getConsoleLogger().isDebugEnabled()) {
+ showToLog(result, getConsoleLogger());
}
return result;
}
- private Set