diff --git a/surefire-its/src/test/resources/testng-suite-xml/src/test-data/testng1.xml b/.mvn/extensions.xml similarity index 70% rename from surefire-its/src/test/resources/testng-suite-xml/src/test-data/testng1.xml rename to .mvn/extensions.xml index ac62eca7d1..b384bb06c2 100644 --- a/surefire-its/src/test/resources/testng-suite-xml/src/test-data/testng1.xml +++ b/.mvn/extensions.xml @@ -16,15 +16,15 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - - - - - - - - - - - \ No newline at end of file + + + eu.maveniverse.maven.mimir + extension3 + 0.10.4 + + + org.apache.maven.extensions + maven-build-cache-extension + 1.2.1 + + diff --git a/.mvn/maven-build-cache-config.xml b/.mvn/maven-build-cache-config.xml new file mode 100644 index 0000000000..fd052fa060 --- /dev/null +++ b/.mvn/maven-build-cache-config.xml @@ -0,0 +1,92 @@ + + + + true + + + + + + {*.java,*.xml,*.properties,*.mod,*.adoc} + + *Jenkinsfile* + ./idea/* + + + + + + + systemPropertyVariables + + + + + + + + + + + install + + + + + deploy + + + + + build + push + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Jenkinsfile b/Jenkinsfile index a495ff3b55..34af498edb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -213,7 +213,6 @@ static def sourcesPatternCsv() { '**/surefire-booter/src/main/java,' + '**/surefire-extensions-api/src/main/java,' + '**/surefire-extensions-spi/src/main/java,' + - '**/surefire-grouper/src/main/java,' + '**/surefire-its/src/main/java,' + '**/surefire-logger-api/src/main/java,' + '**/surefire-providers/**/src/main/java,' + @@ -230,7 +229,6 @@ static def classPatternCsv() { '**/surefire-booter/target/classes,' + '**/surefire-extensions-api/target/classes,' + '**/surefire-extensions-spi/target/classes,' + - '**/surefire-grouper/target/classes,' + '**/surefire-its/target/classes,' + '**/surefire-logger-api/target/classes,' + '**/surefire-providers/**/target/classes,' + @@ -245,7 +243,6 @@ static def testReportsPatternCsv() { '**/maven-surefire-report-plugin/target/surefire-reports/*.xml,' + '**/surefire-api/target/surefire-reports/*.xml,' + '**/surefire-booter/target/surefire-reports/*.xml,' + - '**/surefire-grouper/target/surefire-reports/*.xml,' + '**/surefire-its/target/surefire-reports/*.xml,' + '**/surefire-logger-api/target/surefire-reports/*.xml,' + '**/surefire-providers/**/target/surefire-reports/*.xml,' + diff --git a/README.md b/README.md index 93aa021d36..38d51bc4a4 100644 --- a/README.md +++ b/README.md @@ -70,16 +70,11 @@ Build the Surefire project using **Maven 3.6.3+** and **JDK 8+**. ``` mvn install -P ide-development -f surefire-shared-utils/pom.xml ``` - * Build module `surefire-grouper` in order to generate and compile sources into `target/generated-sources/javacc` using this Maven command: - ``` - mvn compile -f surefire-grouper/pom.xml - ``` + * In Eclipse, select _File > Import ... > Maven Project_ * Select all projects (poms) except `surefire-shared-utils`, enter profile `ide-development` in _Advanced -> Profiles_ - * Check module `surefire-grouper` has source folder `target/generated-sources/javacc`. - If not, add it manually in the module's project properties * In IntelliJ, select _Maven > Profiles_ and check `ide-development` ### Deploying web site diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index 4d83c69dda..5407449a3d 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT org.apache.maven.plugins diff --git a/maven-failsafe-plugin/src/it/jetty-war-test-failing/pom.xml b/maven-failsafe-plugin/src/it/jetty-war-test-failing/pom.xml index 4ba78cdaf9..e539e4747d 100644 --- a/maven-failsafe-plugin/src/it/jetty-war-test-failing/pom.xml +++ b/maven-failsafe-plugin/src/it/jetty-war-test-failing/pom.xml @@ -36,7 +36,7 @@ junit junit - 3.8.2 + 4.13.2 test diff --git a/maven-failsafe-plugin/src/it/jetty-war-test-passing/pom.xml b/maven-failsafe-plugin/src/it/jetty-war-test-passing/pom.xml index c159eec72f..b7bdd56c6c 100644 --- a/maven-failsafe-plugin/src/it/jetty-war-test-passing/pom.xml +++ b/maven-failsafe-plugin/src/it/jetty-war-test-passing/pom.xml @@ -36,7 +36,7 @@ junit junit - 3.8.2 + 4.13.2 test diff --git a/maven-failsafe-plugin/src/it/multiple-summaries-failing/pom.xml b/maven-failsafe-plugin/src/it/multiple-summaries-failing/pom.xml index caef8e1af5..856c255f67 100644 --- a/maven-failsafe-plugin/src/it/multiple-summaries-failing/pom.xml +++ b/maven-failsafe-plugin/src/it/multiple-summaries-failing/pom.xml @@ -35,7 +35,7 @@ junit junit - 3.8.2 + 4.13.2 test diff --git a/maven-failsafe-plugin/src/it/multiple-summaries/pom.xml b/maven-failsafe-plugin/src/it/multiple-summaries/pom.xml index 5381e07506..a247741395 100644 --- a/maven-failsafe-plugin/src/it/multiple-summaries/pom.xml +++ b/maven-failsafe-plugin/src/it/multiple-summaries/pom.xml @@ -35,7 +35,7 @@ junit junit - 3.8.2 + 4.13.2 test diff --git a/maven-failsafe-plugin/src/it/working-directory/pom.xml b/maven-failsafe-plugin/src/it/working-directory/pom.xml index 0277c22251..699161eb0d 100644 --- a/maven-failsafe-plugin/src/it/working-directory/pom.xml +++ b/maven-failsafe-plugin/src/it/working-directory/pom.xml @@ -35,7 +35,7 @@ junit junit - 3.8.2 + 4.13.2 test 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 a15301ef46..df688f7156 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 @@ -20,8 +20,6 @@ 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; @@ -86,13 +84,12 @@ public class IntegrationTestMojo extends AbstractSurefireMojo { * **{@literal /}${it.test}.java, so you can just type {@code -Dit.test=MyIT} to run * a single test file called "foo/MyIT.java". The test patterns prefixed with a ! will be excluded. *
- * This parameter overrides the parameter {@code includes} and {@code excludes}, and the TestNG parameter - * {@code suiteXmlFiles}. + * This parameter overrides the parameter {@code includes} and {@code excludes}. *
* Since 2.7.3 You can execute a limited number of methods in the test with adding #myMethod or * #my*ethod. E.g. type {@code -Dit.test=MyIT#myMethod} supported for junit 4.x and TestNg. *
- * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): + * Since 2.19 a complex syntax is supported in one parameter: *
"-Dit.test=???IT, !Unstable*, pkg{@literal /}**{@literal /}Ci*leIT.java, *IT#test*One+testTwo?????, #fast*+slowTest"
* or e.g. *
@@ -231,7 +228,6 @@ public class IntegrationTestMojo extends AbstractSurefireMojo { * {@literal }%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg{@literal /}**{@literal /}*Fast*.java{@literal } * *
- * This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified.
*
* Notice that these values are relative to the directory containing generated test classes of the project * being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults @@ -252,8 +248,6 @@ public class IntegrationTestMojo extends AbstractSurefireMojo { * * (which excludes all inner classes). *
- * This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified. - *
* Each exclude item may also contain a comma-separated sub-list of items, which will be treated as multiple * {@literal } entries.
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): @@ -314,6 +308,7 @@ public class IntegrationTestMojo extends AbstractSurefireMojo { private int rerunFailingTestsCount; /** + * @deprecated not supported after 3.6.0, please use groups or Junit suite support * (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that * {@code suiteXmlFiles} is incompatible with several other parameters of this plugin, like * {@code includes} and {@code excludes}.
@@ -898,17 +893,6 @@ public void setExcludes(List excludes) { this.excludes = excludes; } - @Override - public File[] getSuiteXmlFiles() { - return suiteXmlFiles.clone(); - } - - @Override - @SuppressWarnings("UnusedDeclaration") - public void setSuiteXmlFiles(File[] suiteXmlFiles) { - this.suiteXmlFiles = suiteXmlFiles.clone(); - } - @Override public String getRunOrder() { return runOrder; @@ -950,16 +934,6 @@ protected void setUseModulePath(boolean useModulePath) { this.useModulePath = useModulePath; } - @Override - protected final List suiteXmlFiles() { - return hasSuiteXmlFiles() ? Arrays.asList(suiteXmlFiles) : Collections.emptyList(); - } - - @Override - protected final boolean hasSuiteXmlFiles() { - return suiteXmlFiles != null && suiteXmlFiles.length != 0; - } - @Override protected final ForkNodeFactory getForkNode() { return forkNode; 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 e53f4073e5..7eda1023c5 100644 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java +++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java @@ -161,14 +161,14 @@ public class VerifyMojo extends AbstractMojo implements SurefireReportParameters @Parameter(defaultValue = "${session}", readonly = true) private MavenSession session; - private final Logger logger; + private Logger logger = LoggerFactory.getLogger(getClass()); private Collection cli; - private volatile PluginConsoleLogger consoleLogger; + private volatile PluginConsoleLogger consoleLogger = new PluginConsoleLogger(logger); public VerifyMojo() { - this.logger = LoggerFactory.getLogger(getClass()); + // } public VerifyMojo(Logger logger) { diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index 960ab78b93..23a6d9816a 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT maven-surefire-common @@ -178,6 +178,12 @@ + + + true + src/main/resources + + org.jacoco 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 f7ffb6581a..da2ab555ea 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 @@ -22,11 +22,11 @@ import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.math.BigDecimal; import java.nio.file.Files; import java.text.ChoiceFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; @@ -51,7 +51,7 @@ import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; -import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.ComparableVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; @@ -111,6 +111,7 @@ import org.apache.maven.surefire.providerapi.ProviderDetector; import org.apache.maven.surefire.providerapi.ProviderInfo; import org.apache.maven.surefire.providerapi.ProviderRequirements; +import org.apache.maven.surefire.shared.utils.StringUtils; import org.apache.maven.surefire.shared.utils.io.FileUtils; import org.apache.maven.toolchain.DefaultToolchain; import org.apache.maven.toolchain.Toolchain; @@ -139,6 +140,7 @@ import static org.apache.maven.plugin.surefire.util.DependencyScanner.filter; import static org.apache.maven.surefire.api.booter.ProviderParameterNames.EXCLUDE_JUNIT5_ENGINES_PROP; import static org.apache.maven.surefire.api.booter.ProviderParameterNames.INCLUDE_JUNIT5_ENGINES_PROP; +import static org.apache.maven.surefire.api.booter.ProviderParameterNames.JUNIT_VINTAGE_DETECTED; import static org.apache.maven.surefire.api.suite.RunResult.failure; import static org.apache.maven.surefire.api.suite.RunResult.noTestsRun; import static org.apache.maven.surefire.booter.Classpath.emptyClasspath; @@ -496,7 +498,6 @@ public abstract class AbstractSurefireMojo extends AbstractMojo implements Suref * in test run, if specified.
* For JUnit4 tests, this parameter forces the use of the 4.7 provider. For JUnit5 tests, this parameter forces * the use of the JUnit platform provider.
- * This parameter is ignored if the {@code suiteXmlFiles} parameter is specified.
* Since version 2.18.1 and JUnit 4.12, the {@code @Category} annotation type is automatically inherited from * superclasses, see {@code @java.lang.annotation.Inherited}. Make sure that test class inheritance still makes * sense together with {@code @Category} annotation of the JUnit 4.12 or higher appeared in superclass. @@ -512,7 +513,6 @@ public abstract class AbstractSurefireMojo extends AbstractMojo implements Suref * run.
* For JUnit4, this parameter forces the use of the 4.7 provider. For JUnit5, this parameter forces the use of the * JUnit platform provider.
- * This parameter is ignored if the {@code suiteXmlFiles} parameter is specified.
* Since version 2.18.1 and JUnit 4.12, the {@code @Category} annotation type is automatically inherited from * superclasses, see {@code @java.lang.annotation.Inherited}. Make sure that test class inheritance still makes * sense together with {@code @Category} annotation of the JUnit 4.12 or higher appeared in superclass. @@ -747,6 +747,8 @@ public abstract class AbstractSurefireMojo extends AbstractMojo implements Suref private Logger logger = LoggerFactory.getLogger(getClass()); + private PluginConsoleLogger consoleLogger = new PluginConsoleLogger(logger); + /** * (TestNG only) Define the factory class used to create all test instances. * @@ -865,25 +867,8 @@ public abstract class AbstractSurefireMojo extends AbstractMojo implements Suref public abstract File getExcludesFile(); - /** - * Calls {@link #getSuiteXmlFiles()} as {@link List list}. - * Never returns null. - * - * @return list of TestNG suite XML files provided by MOJO - */ - protected abstract List suiteXmlFiles(); - - /** - * @return {@code true} if {@link #getSuiteXmlFiles() suite-xml files array} is not empty. - */ - protected abstract boolean hasSuiteXmlFiles(); - protected abstract String[] getExcludedEnvironmentVariables(); - public abstract File[] getSuiteXmlFiles(); - - public abstract void setSuiteXmlFiles(File[] suiteXmlFiles); - public abstract String getRunOrder(); public abstract void setRunOrder(String runOrder); @@ -931,8 +916,6 @@ private String getDefaultExcludes() { private List cli; - private volatile PluginConsoleLogger consoleLogger; - @Override public void execute() throws MojoExecutionException, MojoFailureException { if (isSkipExecution()) { @@ -949,7 +932,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { try { if (verifyParameters() && !hasExecutedBefore()) { DefaultScanResult scan = scanForTestClasses(); - if (!hasSuiteXmlFiles() && scan.isEmpty()) { + if (scan.isEmpty()) { switch (getEffectiveFailIfNoTests()) { case COULD_NOT_RUN_DEFAULT_TESTS: throw new MojoFailureException( @@ -976,21 +959,19 @@ public void execute() throws MojoExecutionException, MojoFailureException { void setLogger(Logger logger) { this.logger = logger; + this.consoleLogger = new PluginConsoleLogger(logger); } void setSurefireDependencyResolver(SurefireDependencyResolver surefireDependencyResolver) { this.surefireDependencyResolver = surefireDependencyResolver; } + SurefireDependencyResolver getSurefireDependencyResolver() { + return surefireDependencyResolver; + } + @Nonnull protected final PluginConsoleLogger getConsoleLogger() { - if (consoleLogger == null) { - synchronized (this) { - if (consoleLogger == null) { - consoleLogger = new PluginConsoleLogger(logger); - } - } - } return consoleLogger; } @@ -1103,7 +1084,6 @@ boolean verifyParameters() throws MojoFailureException, MojoExecutionException { warnIfDefunctGroupsCombinations(); warnIfRerunClashes(); warnIfWrongShutdownValue(); - warnIfNotApplicableSkipAfterFailureCount(); warnIfIllegalTempDir(); warnIfForkCountIsZero(); warnIfIllegalFailOnFlakeCount(); @@ -1122,6 +1102,7 @@ private void warnIfForkCountIsZero() { private void executeAfterPreconditionsChecked(@Nonnull DefaultScanResult scanResult, @Nonnull Platform platform) throws MojoExecutionException, MojoFailureException { + TestClassPath testClasspath = generateTestClasspath(); List providers = createProviders(testClasspath); ResolvePathResultWrapper wrapper = @@ -1148,16 +1129,34 @@ private void executeAfterPreconditionsChecked(@Nonnull DefaultScanResult scanRes } 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(), + new JUnitPlatformProviderInfo( + getJUnitPlatformRunnerArtifact(), + getJUnit5Artifact(), + testClasspath, + getJunitArtifact(), + getBooterArtifact(), + surefireDependencyResolver, + session, + project, + pluginDescriptor, + pluginArtifactMap, + consoleLogger, + getTestNgArtifact()), new JUnitPlatformProviderShadefireInfo( - getJUnitPlatformRunnerArtifact(), getJUnit5Artifact(), testClasspath)); + getJUnitPlatformRunnerArtifact(), + getJUnit5Artifact(), + testClasspath, + getJunitArtifact(), + getBooterArtifact(), + surefireDependencyResolver, + session, + project, + pluginDescriptor, + pluginArtifactMap, + consoleLogger, + getTestNgArtifact())); } SurefireProperties setupProperties() { @@ -1440,70 +1439,16 @@ private void convertTestNGParameters() throws MojoExecutionException { Artifact testNgArtifact = getTestNgArtifact(); if (testNgArtifact != null) { - DefaultArtifactVersion defaultArtifactVersion = new DefaultArtifactVersion(testNgArtifact.getVersion()); - getProperties() - .setProperty( - "testng.configurator", getConfiguratorName(defaultArtifactVersion, getConsoleLogger())); - } - } - - private static String getConfiguratorName(ArtifactVersion version, PluginConsoleLogger log) - throws MojoExecutionException { - try { - VersionRange range = VersionRange.createFromVersionSpec("[4.7,5.2)"); - if (range.containsVersion(version)) { - return "org.apache.maven.surefire.testng.conf.TestNG4751Configurator"; - } - range = VersionRange.createFromVersionSpec("[5.2,5.3)"); - if (range.containsVersion(version)) { - return "org.apache.maven.surefire.testng.conf.TestNG52Configurator"; - } - range = VersionRange.createFromVersionSpec("[5.3,5.10)"); - if (range.containsVersion(version)) { - return "org.apache.maven.surefire.testng.conf.TestNGMapConfigurator"; - } - range = VersionRange.createFromVersionSpec("[5.10,5.13)"); - if (range.containsVersion(version)) { - return "org.apache.maven.surefire.testng.conf.TestNG510Configurator"; - } - range = VersionRange.createFromVersionSpec("[5.13,5.14.1)"); - if (range.containsVersion(version)) { - return "org.apache.maven.surefire.testng.conf.TestNG513Configurator"; - } - range = VersionRange.createFromVersionSpec("[5.14.1,5.14.3)"); - if (range.containsVersion(version)) { - log.warning("The 'reporter' or 'listener' may not work properly in TestNG 5.14.1 and 5.14.2."); - return "org.apache.maven.surefire.testng.conf.TestNG5141Configurator"; - } - range = VersionRange.createFromVersionSpec("[5.14.3,6.0)"); - if (range.containsVersion(version)) { - if (version.equals(new DefaultArtifactVersion("[5.14.3,5.14.5]"))) { - throw new MojoExecutionException("TestNG 5.14.3-5.14.5 is not supported. " - + "System dependency org.testng:guice missed path."); - } - return "org.apache.maven.surefire.testng.conf.TestNG5143Configurator"; - } - range = VersionRange.createFromVersionSpec("[6.0,7.4.0)"); - if (range.containsVersion(version)) { - return "org.apache.maven.surefire.testng.conf.TestNG60Configurator"; - } - range = VersionRange.createFromVersionSpec("[7.4.0,)"); - if (range.containsVersion(version)) { - return "org.apache.maven.surefire.testng.conf.TestNG740Configurator"; - } - - throw new MojoExecutionException("Unknown TestNG version " + version); - } catch (InvalidVersionSpecificationException invsex) { - throw new MojoExecutionException("Bug in plugin. Please report it with the attached stacktrace", invsex); + getProperties().setProperty("testng.version", testNgArtifact.getVersion()); } } private void convertGroupParameters() { if (this.getExcludedGroups() != null) { - getProperties().setProperty(ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP, this.getExcludedGroups()); + getProperties().setProperty(ProviderParameterNames.EXCLUDEDGROUPS_PROP, this.getExcludedGroups()); } if (this.getGroups() != null) { - getProperties().setProperty(ProviderParameterNames.TESTNG_GROUPS_PROP, this.getGroups()); + getProperties().setProperty(ProviderParameterNames.GROUPS_PROP, this.getGroups()); } } @@ -1518,14 +1463,7 @@ private void convertJunitEngineParameters() { } private static String join(String[] array) { - StringBuilder stringBuilder = new StringBuilder(); - for (int i = 0, length = array.length; i < length; i++) { - stringBuilder.append(array[i]); - if (i < length - 1) { - stringBuilder.append(','); - } - } - return stringBuilder.toString(); + return String.join(",", array); } protected boolean isAnyConcurrencySelected() { @@ -1540,7 +1478,7 @@ protected boolean isAnyGroupsSelected() { * Converts old JUnit configuration parameters over to new properties based configuration * method. (if any are defined the old way) */ - private void convertJunitCoreParameters() throws MojoExecutionException { + void convertJunitCoreParameters() throws MojoFailureException { checkThreadCountEntity(getThreadCountSuites(), "suites"); checkThreadCountEntity(getThreadCountClasses(), "classes"); checkThreadCountEntity(getThreadCountMethods(), "methods"); @@ -1551,10 +1489,39 @@ private void convertJunitCoreParameters() throws MojoExecutionException { checkNonForkedThreads(parallel); } - getProperties().setProperty(ProviderParameterNames.PARALLEL_PROP, usedParallel); + getProperties() + .setProperty( + "junit.vintage.execution.parallel.enabled", Boolean.toString(!"none".equals(usedParallel))); if (this.getThreadCount() > 0) { - getProperties().setProperty(ProviderParameterNames.THREADCOUNT_PROP, Integer.toString(getThreadCount())); + getProperties() + .setProperty("junit.vintage.execution.parallel.pool-size", Integer.toString(getThreadCount())); + } + if ("classes".equals(parallel) || "both".equals(parallel)) { + getProperties().setProperty("junit.vintage.execution.parallel.classes", "true"); + } + if ("methods".equals(parallel) || "both".equals(parallel)) { + getProperties().setProperty("junit.vintage.execution.parallel.methods", "true"); } + + if ("methods".equals(parallel) + || "tests".equals(parallel) + || "classes".equals(parallel) + || "instances".equals(parallel)) { + getProperties().setProperty("testng.parallel", parallel); + } + + if (threadCount > 0) { + getProperties().setProperty("testng.threadCount", Integer.toString(threadCount)); + } + + if (groups != null) { + getProperties().setProperty("testng.groups", groups); + } + + if (excludedGroups != null) { + getProperties().setProperty("testng.excludedGroups", excludedGroups); + } + getProperties().setProperty("perCoreThreadCount", Boolean.toString(getPerCoreThreadCount())); getProperties().setProperty("useUnlimitedThreads", Boolean.toString(getUseUnlimitedThreads())); getProperties() @@ -1577,10 +1544,15 @@ private void convertJunitCoreParameters() throws MojoExecutionException { .setProperty( ProviderParameterNames.ENABLE_OUT_ERR_ELEMENTS_PROP, Boolean.toString(isEnableOutErrElements())); - getProperties() - .setProperty( - ProviderParameterNames.ENABLE_PROPERTIES_ELEMENT_PROP, - Boolean.toString(isEnablePropertiesElement())); + if (!getIncludedScanList().isEmpty()) { // && getJunitArtifact() != null) { + getProperties() + .setProperty(ProviderParameterNames.INCLUDES_SCAN_LIST, String.join(",", getIncludedScanList())); + } + + if (!getExcludedScanList().isEmpty()) { // && getJunitArtifact() != null) { + getProperties() + .setProperty(ProviderParameterNames.EXCLUDES_SCAN_LIST, String.join(",", getExcludedScanList())); + } String message = "parallel='" + usedParallel + '\'' + ", perCoreThreadCount=" + getPerCoreThreadCount() @@ -1596,26 +1568,18 @@ private void convertJunitCoreParameters() throws MojoExecutionException { logDebugOrCliShowErrors(message); } - private void checkNonForkedThreads(String parallel) throws MojoExecutionException { + private void checkNonForkedThreads(String parallel) throws MojoFailureException { if ("suites".equals(parallel)) { if (!(getUseUnlimitedThreads() || getThreadCount() > 0 ^ getThreadCountSuites() > 0)) { - throw new MojoExecutionException( + throw new MojoFailureException( "Use threadCount or threadCountSuites > 0 or useUnlimitedThreads=true for parallel='suites'"); } setThreadCountClasses(0); setThreadCountMethods(0); } else if ("classes".equals(parallel)) { - if (!(getUseUnlimitedThreads() || getThreadCount() > 0 ^ getThreadCountClasses() > 0)) { - throw new MojoExecutionException( - "Use threadCount or threadCountClasses > 0 or useUnlimitedThreads=true for parallel='classes'"); - } setThreadCountSuites(0); setThreadCountMethods(0); } else if ("methods".equals(parallel)) { - if (!(getUseUnlimitedThreads() || getThreadCount() > 0 ^ getThreadCountMethods() > 0)) { - throw new MojoExecutionException( - "Use threadCount or threadCountMethods > 0 or useUnlimitedThreads=true for parallel='methods'"); - } setThreadCountSuites(0); setThreadCountClasses(0); } else if ("suitesAndClasses".equals(parallel)) { @@ -1634,7 +1598,7 @@ && getThreadCountSuites() > 0 && getThreadCount() > getThreadCountSuites() && getThreadCountClasses() == 0 && getThreadCountMethods() == 0)) { - throw new MojoExecutionException("Use useUnlimitedThreads=true, " + throw new MojoFailureException("Use useUnlimitedThreads=true, " + "or only threadCount > 0, " + "or (threadCountSuites > 0 and threadCountClasses > 0), " + "or (threadCount > 0 and threadCountSuites > 0 and threadCountClasses > 0) " @@ -1658,7 +1622,7 @@ && getThreadCountSuites() > 0 && getThreadCount() > getThreadCountSuites() && getThreadCountClasses() == 0 && getThreadCountMethods() == 0)) { - throw new MojoExecutionException("Use useUnlimitedThreads=true, " + throw new MojoFailureException("Use useUnlimitedThreads=true, " + "or only threadCount > 0, " + "or (threadCountSuites > 0 and threadCountMethods > 0), " + "or (threadCount > 0 and threadCountSuites > 0 and threadCountMethods > 0), " @@ -1682,7 +1646,7 @@ && getThreadCountClasses() > 0 && getThreadCount() > getThreadCountClasses() && getThreadCountSuites() == 0 && getThreadCountMethods() == 0)) { - throw new MojoExecutionException("Use useUnlimitedThreads=true, " + throw new MojoFailureException("Use useUnlimitedThreads=true, " + "or only threadCount > 0, " + "or (threadCountClasses > 0 and threadCountMethods > 0), " + "or (threadCount > 0 and threadCountClasses > 0 and threadCountMethods > 0), " @@ -1699,7 +1663,7 @@ && getThreadCountSuites() > 0 && getThreadCountClasses() > 0 && getThreadCountMethods() == 0 && getThreadCount() > (getThreadCountSuites() + getThreadCountClasses()))) { - throw new MojoExecutionException("Use useUnlimitedThreads=true, " + throw new MojoFailureException("Use useUnlimitedThreads=true, " + "or only threadCount > 0, " + "or (threadCountSuites > 0 and threadCountClasses > 0 and threadCountMethods > 0), " + "or every thread-count is specified, " @@ -1708,7 +1672,7 @@ && getThreadCount() > (getThreadCountSuites() + getThreadCountClasses()))) { + "for parallel='all'"); } } else { - throw new MojoExecutionException("Illegal parallel='" + parallel + "'"); + throw new MojoFailureException("Illegal parallel='" + parallel + "'"); } } @@ -1719,9 +1683,9 @@ && getThreadCountClasses() == 0 && getThreadCountMethods() == 0; } - private static void checkThreadCountEntity(int count, String entity) throws MojoExecutionException { + private static void checkThreadCountEntity(int count, String entity) throws MojoFailureException { if (count < 0) { - throw new MojoExecutionException("parallel maven execution does not allow negative thread-count" + entity); + throw new MojoFailureException("parallel maven execution does not allow negative thread-count" + entity); } } @@ -1765,29 +1729,20 @@ private ProviderConfiguration createProviderConfiguration(RunOrderParameters run final boolean isTestNg = testNgArtifact != null; final TestArtifactInfo testNg = isTestNg ? new TestArtifactInfo(testNgArtifact.getVersion(), testNgArtifact.getClassifier()) : null; - final TestRequest testSuiteDefinition = new TestRequest( - suiteXmlFiles(), getTestSourceDirectory(), getSpecificTests(), getRerunFailingTestsCount()); + final TestRequest testSuiteDefinition = + new TestRequest(getTestSourceDirectory(), getSpecificTests(), getRerunFailingTestsCount()); - final boolean actualFailIfNoTests; - DirectoryScannerParameters directoryScannerParameters = null; - if (hasSuiteXmlFiles() && !isSpecificTestSpecified()) { - actualFailIfNoTests = getFailIfNoTests(); - if (!isTestNg) { - throw new MojoExecutionException("suiteXmlFiles is configured, but there is no TestNG dependency"); - } - } else { - // @todo remove these three params and use DirectoryScannerParameters to pass into DirectoryScanner only - // @todo or remove it in next major version :: 3.0 - // @todo remove deprecated methods in ProviderParameters => included|excluded|specificTests not needed here + // @todo remove these three params and use DirectoryScannerParameters to pass into DirectoryScanner only + // @todo or remove it in next major version :: 3.0 + // @todo remove deprecated methods in ProviderParameters => included|excluded|specificTests not needed here - List actualIncludes = getIncludeList(); // Collections.emptyList(); behaves same - List actualExcludes = getExcludeList(); // Collections.emptyList(); behaves same - // Collections.emptyList(); behaves same - List specificTests = Collections.emptyList(); + List actualIncludes = getIncludeList(); // Collections.emptyList(); behaves same + List actualExcludes = getExcludeList(); // Collections.emptyList(); behaves same + // Collections.emptyList(); behaves same + List specificTests = Collections.emptyList(); - directoryScannerParameters = new DirectoryScannerParameters( - getTestClassesDirectory(), actualIncludes, actualExcludes, specificTests, getRunOrder()); - } + DirectoryScannerParameters directoryScannerParameters = new DirectoryScannerParameters( + getTestClassesDirectory(), actualIncludes, actualExcludes, specificTests, getRunOrder()); Map providerProperties = toStringProperties(getProperties()); @@ -1854,7 +1809,8 @@ private StartupConfiguration newStartupConfigWithClasspath( @Nonnull ProviderInfo providerInfo, @Nonnull TestClassPath testClasspathWrapper) throws MojoExecutionException { - Classpath testClasspath = testClasspathWrapper.toClasspath(); + Classpath testClasspath = + providerInfo.decorateTestClassPath(testClasspathWrapper).toClasspath(); Set providerArtifacts = providerInfo.getProviderClasspath(); String providerName = providerInfo.getProviderName(); Classpath providerClasspath = classpathCache.getCachedClassPath(providerName); @@ -2049,7 +2005,7 @@ private Artifact getLoggerApiArtifact() { return getPluginArtifactMap().get("org.apache.maven.surefire:surefire-logger-api"); } - private Artifact getBooterArtifact() { + Artifact getBooterArtifact() { return getPluginArtifactMap().get("org.apache.maven.surefire:surefire-booter"); } @@ -2255,11 +2211,15 @@ private Artifact getTestNgArtifact() throws MojoExecutionException { String projectArtifactName = projectArtifact.getGroupId() + ":" + projectArtifact.getArtifactId(); if (artifact != null) { - VersionRange range = createVersionRange(); - if (!range.containsVersion(new DefaultArtifactVersion(artifact.getVersion()))) { - throw new MojoExecutionException( - "TestNG support requires version 4.7 or above. You have declared version " - + artifact.getVersion()); + try { + VersionRange range = VersionRange.createFromVersionSpec("[6.14.3,)"); + if (!range.containsVersion(new DefaultArtifactVersion(artifact.getVersion()))) { + throw new MojoExecutionException( + "TestNG support requires version 6.14.3 or above. You have declared version " + + artifact.getVersion()); + } + } catch (InvalidVersionSpecificationException e) { + throw new MojoExecutionException("Unable to parse version of TestNG: " + artifact.getVersion(), e); } } else if (projectArtifactName.equals(getTestNGArtifactName())) { artifact = projectArtifact; @@ -2268,14 +2228,6 @@ private Artifact getTestNgArtifact() throws MojoExecutionException { return artifact; } - private VersionRange createVersionRange() { - try { - return VersionRange.createFromVersionSpec("[4.7,)"); - } catch (InvalidVersionSpecificationException e) { - throw new RuntimeException(e); - } - } - private Artifact getJunitArtifact() { Artifact artifact = getProjectArtifactMap().get(getJunitArtifactName()); Artifact projectArtifact = project.getArtifact(); @@ -2288,10 +2240,6 @@ private Artifact getJunitArtifact() { return artifact; } - private Artifact getJunitDepArtifact() { - return getProjectArtifactMap().get("junit:junit-dep"); - } - private Artifact getJUnitPlatformRunnerArtifact() { return getProjectArtifactMap().get("org.junit.platform:junit-platform-runner"); } @@ -2612,7 +2560,6 @@ private String getConfigChecksum() { checksum.add(getExcludedGroups()); checksum.add(getIncludeJUnit5Engines()); checksum.add(getExcludeJUnit5Engines()); - checksum.add(getSuiteXmlFiles()); checksum.add(getJunitArtifact()); checksum.add(getTestNGArtifactName()); checksum.add(getThreadCount()); @@ -2674,7 +2621,7 @@ protected ClassLoaderConfiguration getClassLoaderConfiguration() { * @return the classpath elements * @throws MojoFailureException */ - private TestClassPath generateTestClasspath() throws MojoFailureException { + private TestClassPath generateTestClasspath(ArtifactFilter... dependencyFilters) throws MojoFailureException { Set classpathArtifacts = getProject().getArtifacts(); if (getClasspathDependencyScopeExclude() != null @@ -2689,11 +2636,19 @@ private TestClassPath generateTestClasspath() throws MojoFailureException { classpathArtifacts = filterArtifacts(classpathArtifacts, dependencyFilter); } + if (dependencyFilters != null) { + for (ArtifactFilter dependencyFilter : dependencyFilters) { + if (dependencyFilter != null) { + classpathArtifacts = filterArtifacts(classpathArtifacts, dependencyFilter); + } + } + } + Map dependencyConflictIdsProjectArtifacts = classpathArtifacts.stream() .collect(Collectors.toMap(Artifact::getDependencyConflictId, Function.identity())); Set additionalClasspathElements = new LinkedHashSet<>(); if (getAdditionalClasspathElements() != null) { - Arrays.stream(getAdditionalClasspathElements()).forEach(additionalClasspathElements::add); + additionalClasspathElements.addAll(asList(getAdditionalClasspathElements())); } if (additionalClasspathDependencies != null && !additionalClasspathDependencies.isEmpty()) { Collection additionalArtifacts = resolveDependencies(additionalClasspathDependencies); @@ -2785,6 +2740,7 @@ private void showArray(T[] array, String setting) { } private Classpath getArtifactClasspath(Artifact surefireArtifact) throws MojoExecutionException { + Classpath existing = classpathCache.getCachedClassPath(surefireArtifact.getArtifactId()); if (existing == null) { List items = new ArrayList<>(); @@ -2847,20 +2803,16 @@ private List commandLineOptions() { } private void warnIfDefunctGroupsCombinations() throws MojoFailureException, MojoExecutionException { + Artifact junitArtifact = getJunitArtifact(); if (isAnyGroupsSelected()) { if (getTestNgArtifact() == null) { - Artifact junitArtifact = getJunitArtifact(); boolean junit47Compatible = isJunit47Compatible(junitArtifact); boolean junit5PlatformCompatible = getJUnit5Artifact() != null; if (!junit47Compatible && !junit5PlatformCompatible) { - if (junitArtifact != null) { - throw new MojoFailureException("groups/excludedGroups are specified but JUnit version on " - + "classpath is too old to support groups. " - + "Check your dependency:tree to see if your project " - + "is picking up an old junit version"); - } - throw new MojoFailureException("groups/excludedGroups require TestNG, JUnit48+ or JUnit 5 " - + "(a specific engine required on classpath) on project test classpath"); + throw new MojoFailureException("groups/excludedGroups are specified but JUnit version on " + + "classpath is too old to support groups. " + + "Check your dependency:tree to see if your project " + + "is picking up an old junit version"); } } } @@ -2882,42 +2834,6 @@ private void warnIfWrongShutdownValue() throws MojoFailureException { } } - private void warnIfNotApplicableSkipAfterFailureCount() throws MojoFailureException { - int skipAfterFailureCount = getSkipAfterFailureCount(); - - if (skipAfterFailureCount < 0) { - throw new MojoFailureException("Parameter \"skipAfterFailureCount\" should not be negative."); - } else if (skipAfterFailureCount > 0) { - try { - Artifact testng = getTestNgArtifact(); - if (testng != null) { - VersionRange range = VersionRange.createFromVersionSpec("[5.10,)"); - if (!range.containsVersion(new DefaultArtifactVersion(testng.getVersion()))) { - throw new MojoFailureException( - "Parameter \"skipAfterFailureCount\" expects TestNG Version 5.10 or higher. " - + "java.lang.NoClassDefFoundError: org/testng/IInvokedMethodListener"); - } - } else { - // TestNG is dependent on JUnit - Artifact junit = getJunitArtifact(); - if (junit != null) { - VersionRange range = VersionRange.createFromVersionSpec("[4.0,)"); - if (!range.containsVersion(new DefaultArtifactVersion(junit.getVersion()))) { - throw new MojoFailureException( - "Parameter \"skipAfterFailureCount\" expects JUnit Version 4.0 or higher. " - + "java.lang.NoSuchMethodError: " - + "org.junit.runner.notification.RunNotifier.pleaseStop()V"); - } - } - } - } catch (MojoExecutionException e) { - throw new MojoFailureException(e.getLocalizedMessage()); - } catch (InvalidVersionSpecificationException e) { - throw new RuntimeException(e); - } - } - } - private void warnIfIllegalTempDir() throws MojoFailureException { if (isEmpty(getTempDir())) { throw new MojoFailureException("Parameter 'tempDir' should not be blank string."); @@ -2937,50 +2853,25 @@ private void printDefaultSeedIfNecessary() { } } - final class TestNgProviderInfo implements ProviderInfo { - private final Artifact testNgArtifact; - - TestNgProviderInfo(Artifact testNgArtifact) { - this.testNgArtifact = testNgArtifact; - } - - @Override - @Nonnull - public String getProviderName() { - return "org.apache.maven.surefire.testng.TestNGProvider"; - } - - @Override - public boolean isApplicable() { - return testNgArtifact != null; - } - - @Override - public void addProviderProperties() throws MojoExecutionException { - convertTestNGParameters(); - } + /** + * Provides the Provider information for manually configured providers. + */ + final class DynamicProviderInfo implements ConfigurableProviderInfo { + final String providerName; - @Nonnull - @Override - public List getJpmsArguments(@Nonnull ProviderRequirements forkRequirements) { - return emptyList(); + DynamicProviderInfo(String providerName) { + this.providerName = providerName; } @Override - @Nonnull - public Set getProviderClasspath() throws MojoExecutionException { - Artifact surefireArtifact = getBooterArtifact(); - String version = surefireArtifact.getBaseVersion(); - return surefireDependencyResolver.getProviderClasspath( - session.getRepositorySession(), project.getRemotePluginRepositories(), "surefire-testng", version); + public ProviderInfo instantiate(String providerName) { + return new DynamicProviderInfo(providerName); } - } - final class JUnit3ProviderInfo implements ProviderInfo { @Override @Nonnull public String getProviderName() { - return "org.apache.maven.surefire.junit.JUnit3Provider"; + return providerName; } @Override @@ -2989,49 +2880,16 @@ public boolean isApplicable() { } @Override - public void addProviderProperties() {} - - @Nonnull - @Override - public List getJpmsArguments(@Nonnull ProviderRequirements forkRequirements) { - return emptyList(); - } - - @Override - @Nonnull - public Set getProviderClasspath() throws MojoExecutionException { - // add the JUnit provider as default - it doesn't require JUnit to be present, - // since it supports POJO tests. - String version = getBooterArtifact().getBaseVersion(); - return surefireDependencyResolver.getProviderClasspath( - session.getRepositorySession(), project.getRemotePluginRepositories(), "surefire-junit3", version); - } - } - - final class JUnit4ProviderInfo implements ProviderInfo { - private final Artifact junitArtifact; - - private final Artifact junitDepArtifact; - - JUnit4ProviderInfo(Artifact junitArtifact, Artifact junitDepArtifact) { - this.junitArtifact = junitArtifact; - this.junitDepArtifact = junitDepArtifact; - } - - @Override - @Nonnull - public String getProviderName() { - return "org.apache.maven.surefire.junit4.JUnit4Provider"; - } - - @Override - public boolean isApplicable() { - return junitDepArtifact != null || isAnyJunit4(junitArtifact); + public void addProviderProperties() throws MojoExecutionException { + // Ok this is a bit lazy. + try { + convertJunitCoreParameters(); + convertTestNGParameters(); + } catch (MojoFailureException e) { + throw new MojoExecutionException(e.getMessage(), e); + } } - @Override - public void addProviderProperties() {} - @Nonnull @Override public List getJpmsArguments(@Nonnull ProviderRequirements forkRequirements) { @@ -3041,13 +2899,18 @@ public List getJpmsArguments(@Nonnull ProviderRequirements forkRequire @Override @Nonnull public Set getProviderClasspath() throws MojoExecutionException { - String version = getBooterArtifact().getBaseVersion(); - return surefireDependencyResolver.getProviderClasspath( - session.getRepositorySession(), project.getRemotePluginRepositories(), "surefire-junit4", version); + Plugin plugin = getPluginDescriptor().getPlugin(); + Map providerArtifacts = surefireDependencyResolver.resolvePluginDependencies( + session.getRepositorySession(), + project.getRemotePluginRepositories(), + plugin, + getPluginArtifactMap()); + return new LinkedHashSet<>(providerArtifacts.values()); } } class JUnitPlatformProviderInfo implements ProviderInfo { + private static final String PROVIDER_DEP_GID = "org.junit.platform"; private static final String PROVIDER_DEP_AID = "junit-platform-launcher"; @@ -3055,13 +2918,53 @@ class JUnitPlatformProviderInfo implements ProviderInfo { private final Artifact junitPlatformArtifact; private final TestClassPath testClasspath; + private final Artifact junitArtifact; + private final Artifact booterArtifact; + private final Artifact testNgArtifact; + private final SurefireDependencyResolver surefireDependencyResolver; + private final MavenSession session; + private final MavenProject project; + private final PluginDescriptor pluginDescriptor; + private final Map pluginArtifactMap; + private final ConsoleLogger consoleLogger; + private ProviderInfo.Engine engine = ProviderInfo.Engine.JUNIT_PLATFORM; + + @SuppressWarnings("checkstyle:parameternumber") JUnitPlatformProviderInfo( Artifact junitPlatformRunnerArtifact, Artifact junitPlatformArtifact, - @Nonnull TestClassPath testClasspath) { + @Nonnull TestClassPath testClasspath, + Artifact junitArtifact, + Artifact booterArtifact, + SurefireDependencyResolver surefireDependencyResolver, + MavenSession session, + MavenProject project, + PluginDescriptor pluginDescriptor, + Map pluginArtifactMap, + ConsoleLogger consoleLogger, + Artifact testNgArtifact) { + this.session = session; + this.project = project; + this.pluginDescriptor = pluginDescriptor; + this.pluginArtifactMap = pluginArtifactMap; + this.consoleLogger = consoleLogger; this.junitPlatformRunnerArtifact = junitPlatformRunnerArtifact; this.junitPlatformArtifact = junitPlatformArtifact; this.testClasspath = testClasspath; + this.junitArtifact = junitArtifact; + this.booterArtifact = booterArtifact; + this.testNgArtifact = testNgArtifact; + // JUnit 4.12+ is required by JUnit 5.3+ + // JUnit 4.13+ is required by JUnit 5.8+ + // JUnit 4.13.2 is required by JUnit 5.9+ + // JUnit 4.13.3 is required by JUnit 5.10+ + // JUnit 4.13.4 is required by JUnit 5.12+ + // https://junit.org/junit5/docs/current/user-guide/#dependency-metadata + + if (isAnyJunit4(junitArtifact)) { + this.engine = Engine.JUNIT4; + } + this.surefireDependencyResolver = surefireDependencyResolver; } @Override @@ -3076,26 +2979,42 @@ protected String getProviderArtifactName() { @Override public boolean isApplicable() { - return junitPlatformRunnerArtifact == null && junitPlatformArtifact != null; + return (junitPlatformRunnerArtifact == null && junitPlatformArtifact != null) + || (isAnyJunit4(junitArtifact)) + || testNgArtifact != null; } @Override - public void addProviderProperties() { - convertGroupParameters(); - convertJunitEngineParameters(); + public void addProviderProperties() throws MojoExecutionException { + try { + convertJunitEngineParameters(); + convertGroupParameters(); + convertJunitCoreParameters(); + } catch (MojoFailureException e) { + throw new MojoExecutionException(e.getMessage(), e); + } + // FIXME look at duplicate parameters to remove + if (testNgArtifact != null) { + convertTestNGParameters(); + } } @Nonnull @Override public List getJpmsArguments(@Nonnull ProviderRequirements forkRequirements) { boolean hasTestDescriptor = forkRequirements.isModularPath() && forkRequirements.hasTestModuleDescriptor(); - return hasTestDescriptor ? getJpmsArgs() : Collections.emptyList(); + return hasTestDescriptor ? getJpmsArgs() : Collections.emptyList(); } @Override @Nonnull public Set getProviderClasspath() throws MojoExecutionException { - String surefireVersion = getBooterArtifact().getBaseVersion(); + if (junitArtifact != null && !isWithinVersionSpec(junitArtifact, "[4.12,)")) { + throw new MojoExecutionException(String.format( + "The used JUnit Version %s is not supported anymore. Please update to version 4.12+", + junitArtifact.getVersion())); + } + String surefireVersion = booterArtifact.getBaseVersion(); Map providerArtifacts = surefireDependencyResolver.getProviderClasspathAsMap( session.getRepositorySession(), project.getRemotePluginRepositories(), @@ -3103,44 +3022,80 @@ public Set getProviderClasspath() throws MojoExecutionException { surefireVersion); Map testDeps = testClasspath.getTestDependencies(); - Plugin plugin = getPluginDescriptor().getPlugin(); + Plugin plugin = pluginDescriptor.getPlugin(); Map pluginDeps = surefireDependencyResolver.resolvePluginDependencies( - session.getRepositorySession(), - project.getRemotePluginRepositories(), - plugin, - getPluginArtifactMap()); + session.getRepositorySession(), project.getRemotePluginRepositories(), plugin, pluginArtifactMap); + + String defaultJunitVersion = getDefaultJunitVersion(); + + String engineGroupId = "org.junit.jupiter"; + String engineArtifactId = "junit-jupiter-engine"; + String engineCoordinates = engineGroupId + ":" + engineArtifactId; + String api = "org.junit.jupiter:junit-jupiter-api"; + // FIXME this default version should be aligned with the junit-platform-version property from pom + String engineVersion = testDeps.get(api) == null + ? defaultJunitVersion + : testDeps.get(api).getBaseVersion(); + consoleLogger.debug( + "Test dependencies contain " + api + ". Resolving " + engineCoordinates + ":" + engineVersion); if (hasDependencyPlatformEngine(pluginDeps)) { providerArtifacts.putAll(pluginDeps); } else { - String engineVersion = null; if (hasDependencyJupiterAPI(testDeps) - && !testDeps.containsKey("org.junit.jupiter:junit-jupiter-engine")) { - String engineGroupId = "org.junit.jupiter"; - String engineArtifactId = "junit-jupiter-engine"; - String engineCoordinates = engineGroupId + ":" + engineArtifactId; - String api = "org.junit.jupiter:junit-jupiter-api"; - engineVersion = testDeps.get(api).getBaseVersion(); - getConsoleLogger() - .debug("Test dependencies contain " + api + ". Resolving " + engineCoordinates + ":" - + engineVersion); + && engineVersion != null + && !testDeps.containsKey(engineGroupId + ":" + engineArtifactId)) { addEngineByApi(engineGroupId, engineArtifactId, engineVersion, providerArtifacts); } - if ((testDeps.containsKey("junit:junit") || testDeps.containsKey("junit:junit-dep")) - && !testDeps.containsKey("org.junit.vintage:junit-vintage-engine")) { - String engineGroupId = "org.junit.vintage"; - String engineArtifactId = "junit-vintage-engine"; - String engineCoordinates = engineGroupId + ":" + engineArtifactId; - - if (engineVersion != null) { - getConsoleLogger() - .debug("Test dependencies contain JUnit4. Resolving " + engineCoordinates + ":" - + engineVersion); - addEngineByApi(engineGroupId, engineArtifactId, engineVersion, providerArtifacts); + if (isWithinVersionSpec(junitArtifact, "[4.0,4.11]")) { + String message = "Surefire is not compatible with JUnit 4.11 or older. Project version is " + + junitArtifact.getBaseVersion(); + consoleLogger.error(message); + throw new MojoExecutionException(message); + } + } + + // need to check there is at least one test engine in the classpath + String junit = (String) getProperties().get("junit"); + boolean runJunit = Boolean.parseBoolean(StringUtils.isEmpty(junit) ? "true" : junit); + if (StringUtils.isNotEmpty(junit) && !runJunit) { + consoleLogger.debug("System property 'junit' is explicity set to '" + junit + "'"); + } else { + if (testDeps.containsKey("junit:junit") + && !testDeps.containsKey("org.junit.vintage:junit-vintage-engine") + && !pluginDeps.containsKey("org.junit.vintage:junit-vintage-engine")) { + getProperties().setProperty(JUNIT_VINTAGE_DETECTED, "true"); + if (!hasDependencyPlatformEngine(providerArtifacts)) { + // TODO exclude transitive deps (hamcrest etc...) + if (engineVersion != null) { + consoleLogger.debug("Test dependencies contain JUnit4. Resolving " + engineCoordinates + ":" + + engineVersion); + addEngineByApi(engineGroupId, engineArtifactId, engineVersion, providerArtifacts); + } else { + addEngineByApi(engineGroupId, engineArtifactId, engineVersion, providerArtifacts); + } } + // add org.junit.vintage:junit-vintage-engine + addEngineByApi("org.junit.vintage", "junit-vintage-engine", engineVersion, providerArtifacts); } } + if (testNgArtifact != null) { + // FIXME support only from TestNG 6.14.3 + // FIXME check if already present as plugin dependency or project dependency + String junitSupportGroupId = "org.junit.support"; + String testNgEngineArtifactId = "testng-engine"; + String testNgEngineCoordinates = junitSupportGroupId + ":" + testNgEngineArtifactId; + // FIXME configurable? + // or picked from test dependencies + String version = "1.0.6"; + consoleLogger.debug("TestNG is present. Resolving " + testNgEngineCoordinates + ":" + version); + addEngineByApi(junitSupportGroupId, testNgEngineArtifactId, version, providerArtifacts); + } + + if (!hasDependencyPlatformEngine(providerArtifacts)) { + addEngineByApi(engineGroupId, engineArtifactId, engineVersion, providerArtifacts); + } narrowDependencies(providerArtifacts, testDeps); alignProviderVersions(providerArtifacts); @@ -3170,7 +3125,31 @@ private void addEngineByApi( throws MojoExecutionException { for (Artifact dep : resolve(engineGroupId, engineArtifactId, engineVersion, null, "jar")) { String key = dep.getGroupId() + ":" + dep.getArtifactId(); - providerArtifacts.put(key, dep); + Artifact removed = providerArtifacts.put(key, dep); + if (removed != null) { + consoleLogger.debug("Replaced provider dependency " + key + " " + removed + " with " + dep); + ComparableVersion removedVersion = new ComparableVersion(removed.getVersion()); + ComparableVersion depVersion = new ComparableVersion(dep.getVersion()); + // keep the highest version + if (removedVersion.compareTo(depVersion) > 0) { + providerArtifacts.put(key, removed); + consoleLogger.debug("Kept higher version " + key + " " + removed); + } + } + } + } + + private String getDefaultJunitVersion() { + try (InputStream inputStream = Thread.currentThread() + .getContextClassLoader() + .getResourceAsStream("surefire.junit.version.properties")) { + Properties junitProperties = new Properties(); + junitProperties.load(inputStream); + return junitProperties.getProperty("junit.version"); + } catch (Exception e) { + consoleLogger.warning( + "Could not load default JUnit version from junit.version.properties use default 5.14.1"); + return "5.14.1"; } } @@ -3180,6 +3159,9 @@ private void narrowDependencies( } protected void alignProviderVersions(Map providerArtifacts) throws MojoExecutionException { + if (junitPlatformArtifact == null) { + return; + } String version = junitPlatformArtifact.getBaseVersion(); for (Artifact launcherArtifact : resolve(PROVIDER_DEP_GID, PROVIDER_DEP_AID, version, null, "jar")) { String key = launcherArtifact.getGroupId() + ":" + launcherArtifact.getArtifactId(); @@ -3189,13 +3171,19 @@ protected void alignProviderVersions(Map providerArtifacts) th } } - private Set resolve(String g, String a, String v, String c, String t) throws MojoExecutionException { - ArtifactHandler handler = junitPlatformArtifact.getArtifactHandler(); - Artifact artifact = new DefaultArtifact(g, a, v, null, t, c, handler); - getConsoleLogger().debug("Resolving artifact " + g + ":" + a + ":" + v); + private Set resolve(String groupId, String artifactId, String version, String classifier, String type) + throws MojoExecutionException { + // FIXME will be different with 3 and testng + ArtifactHandler handler = junitPlatformArtifact != null + ? junitPlatformArtifact.getArtifactHandler() + : junitArtifact != null + ? junitArtifact.getArtifactHandler() + : testNgArtifact != null ? testNgArtifact.getArtifactHandler() : null; + Artifact artifact = new DefaultArtifact(groupId, artifactId, version, null, type, classifier, handler); + consoleLogger.debug("Resolving artifact " + groupId + ":" + artifactId + ":" + version); Set r = surefireDependencyResolver.resolveArtifacts( session.getRepositorySession(), project.getRemoteProjectRepositories(), artifact); - getConsoleLogger().debug("Resolved artifact " + g + ":" + a + ":" + v + " to " + r); + consoleLogger.debug("Resolved artifact " + groupId + ":" + artifactId + ":" + version + " to " + r); return r; } @@ -3204,23 +3192,42 @@ private boolean hasDependencyJupiterAPI(Map dependencies) { } private boolean hasDependencyPlatformEngine(Map dependencies) { - for (Entry dependency : dependencies.entrySet()) { - if (dependency.getKey().equals("org.junit.platform:junit-platform-engine")) { - return true; - } - } - - return false; + return dependencies.entrySet().stream() + .anyMatch(stringArtifactEntry -> + stringArtifactEntry.getKey().equals("org.junit.platform:junit-platform-engine")); } } + // TODO why an enclosing class on the top do we real need this shading?? + @SuppressWarnings("checkstyle:parameternumber") final class JUnitPlatformProviderShadefireInfo extends JUnitPlatformProviderInfo { JUnitPlatformProviderShadefireInfo( Artifact junitPlatformRunnerArtifact, Artifact junitPlatformArtifact, - @Nonnull TestClassPath testClasspath) { - super(junitPlatformRunnerArtifact, junitPlatformArtifact, testClasspath); + @Nonnull TestClassPath testClasspath, + Artifact junitArtifact, + Artifact booterArtifact, + SurefireDependencyResolver surefireDependencyResolver, + MavenSession session, + MavenProject project, + PluginDescriptor pluginDescriptor, + Map pluginArtifactMap, + ConsoleLogger consoleLogger, + Artifact testNgArtifact) { + super( + junitPlatformRunnerArtifact, + junitPlatformArtifact, + testClasspath, + junitArtifact, + booterArtifact, + surefireDependencyResolver, + session, + project, + pluginDescriptor, + pluginArtifactMap, + consoleLogger, + testNgArtifact); } @Override @@ -3249,107 +3256,6 @@ protected void alignProviderVersions(Map providerArtifacts) th } } - final class JUnitCoreProviderInfo implements ProviderInfo { - private final Artifact junitArtifact; - - private final Artifact junitDepArtifact; - - JUnitCoreProviderInfo(Artifact junitArtifact, Artifact junitDepArtifact) { - this.junitArtifact = junitArtifact; - this.junitDepArtifact = junitDepArtifact; - } - - @Override - @Nonnull - public String getProviderName() { - return "org.apache.maven.surefire.junitcore.JUnitCoreProvider"; - } - - private boolean is47CompatibleJunitDep() { - return isJunit47Compatible(junitDepArtifact); - } - - @Override - public boolean isApplicable() { - final boolean isJunitArtifact47 = isAnyJunit4(junitArtifact) && isJunit47Compatible(junitArtifact); - final boolean isAny47ProvidersForces = isAnyConcurrencySelected() || isAnyGroupsSelected(); - return isAny47ProvidersForces && (isJunitArtifact47 || is47CompatibleJunitDep()); - } - - @Override - public void addProviderProperties() throws MojoExecutionException { - convertJunitCoreParameters(); - convertGroupParameters(); - convertJunitEngineParameters(); - } - - @Nonnull - @Override - public List getJpmsArguments(@Nonnull ProviderRequirements forkRequirements) { - return emptyList(); - } - - @Override - @Nonnull - public Set getProviderClasspath() throws MojoExecutionException { - String version = getBooterArtifact().getBaseVersion(); - return surefireDependencyResolver.getProviderClasspath( - session.getRepositorySession(), project.getRemotePluginRepositories(), "surefire-junit47", version); - } - } - - /** - * Provides the Provider information for manually configured providers. - */ - final class DynamicProviderInfo implements ConfigurableProviderInfo { - final String providerName; - - DynamicProviderInfo(String providerName) { - this.providerName = providerName; - } - - @Override - public ProviderInfo instantiate(String providerName) { - return new DynamicProviderInfo(providerName); - } - - @Override - @Nonnull - public String getProviderName() { - return providerName; - } - - @Override - public boolean isApplicable() { - return true; - } - - @Override - public void addProviderProperties() throws MojoExecutionException { - // Ok this is a bit lazy. - convertJunitCoreParameters(); - convertTestNGParameters(); - } - - @Nonnull - @Override - public List getJpmsArguments(@Nonnull ProviderRequirements forkRequirements) { - return emptyList(); - } - - @Override - @Nonnull - public Set getProviderClasspath() throws MojoExecutionException { - Plugin plugin = getPluginDescriptor().getPlugin(); - Map providerArtifacts = surefireDependencyResolver.resolvePluginDependencies( - session.getRepositorySession(), - project.getRemotePluginRepositories(), - plugin, - getPluginArtifactMap()); - return new LinkedHashSet<>(providerArtifacts.values()); - } - } - File createSurefireBootDirectoryInBuild() { File tmp = new File(getProjectBuildDirectory(), getTempDir()); //noinspection ResultOfMethodCallIgnored diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java index 46739e347c..23a922797b 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java @@ -59,6 +59,8 @@ import static org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec; /** + * Internal component used by the surefire plugin. Not a public API. + * not guaranteed to remain unchanged across surefire plugin versions. * Does dependency resolution and artifact handling for the surefire plugin. * * @author Stephen Connolly @@ -66,24 +68,12 @@ */ @Named @Singleton -class SurefireDependencyResolver { +public class SurefireDependencyResolver { static final String PROVIDER_GROUP_ID = "org.apache.maven.surefire"; private static final String[] PROVIDER_CLASSPATH_ORDER = { - "surefire-junit3", - "surefire-junit4", - "surefire-junit47", - "surefire-testng", - "surefire-junit-platform", - "surefire-api", - "surefire-logger-api", - "surefire-shared-utils", - "common-java5", - "common-junit3", - "common-junit4", - "common-junit48", - "common-testng-utils" + "surefire-junit-platform", "surefire-api", "surefire-logger-api", "surefire-shared-utils", "common-java5" }; private final RepositorySystem repositorySystem; @@ -93,7 +83,7 @@ class SurefireDependencyResolver { this.repositorySystem = repositorySystem; } - static boolean isWithinVersionSpec(@Nullable Artifact artifact, @Nonnull String versionSpec) { + public static boolean isWithinVersionSpec(@Nullable Artifact artifact, @Nonnull String versionSpec) { if (artifact == null) { return false; } @@ -151,17 +141,12 @@ private Set resolveDependencies( org.eclipse.aether.graph.Dependency dependency) throws MojoExecutionException { - try { - List results = resolveDependencies( - session, repositories, dependency, DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME)); - return results.stream() - .map(ArtifactResult::getArtifact) - .map(RepositoryUtils::toArtifact) - .collect(Collectors.toCollection(LinkedHashSet::new)); - - } catch (DependencyResolutionException e) { - throw new MojoExecutionException(e.getMessage(), e); - } + List results = resolveDependencies( + session, repositories, dependency, DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME)); + return results.stream() + .map(ArtifactResult::getArtifact) + .map(RepositoryUtils::toArtifact) + .collect(Collectors.toCollection(LinkedHashSet::new)); } private List resolveDependencies( @@ -169,17 +154,22 @@ private List resolveDependencies( List repositories, org.eclipse.aether.graph.Dependency dependency, DependencyFilter dependencyFilter) - throws DependencyResolutionException { + throws MojoExecutionException { - // use a collect request without a root in order to not resolve optional dependencies - CollectRequest collectRequest = new CollectRequest(Collections.singletonList(dependency), null, repositories); + try { + // use a collect request without a root in order to not resolve optional dependencies + CollectRequest collectRequest = + new CollectRequest(Collections.singletonList(dependency), null, repositories); - DependencyRequest request = new DependencyRequest(); - request.setCollectRequest(collectRequest); - request.setFilter(dependencyFilter); + DependencyRequest request = new DependencyRequest(); + request.setCollectRequest(collectRequest); + request.setFilter(dependencyFilter); - DependencyResult dependencyResult = repositorySystem.resolveDependencies(session, request); - return dependencyResult.getArtifactResults(); + DependencyResult dependencyResult = repositorySystem.resolveDependencies(session, request); + return dependencyResult.getArtifactResults(); + } catch (DependencyResolutionException e) { + throw new MojoExecutionException(e.getMessage(), e); + } } @Nonnull @@ -189,6 +179,7 @@ Set getProviderClasspath( String providerArtifactId, String providerVersion) throws MojoExecutionException { + Dependency provider = toProviderDependency(providerArtifactId, providerVersion); org.eclipse.aether.graph.Dependency dependency = diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java index d86910342b..f5ae2c5e7a 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java @@ -30,7 +30,11 @@ import static java.util.Collections.addAll; import static org.apache.maven.surefire.shared.utils.StringUtils.split; -final class TestClassPath { +/** + * this class is part of internal implementation and should not be used. + * There is mot guarantee about backward compatibility. + */ +public final class TestClassPath { private final Iterable artifacts; private final File classesDirectory; private final File testClassesDirectory; @@ -77,4 +81,20 @@ Classpath toClasspath() { return new Classpath(classpath); } + + public Iterable getArtifacts() { + return artifacts; + } + + public File getClassesDirectory() { + return classesDirectory; + } + + public File getTestClassesDirectory() { + return testClassesDirectory; + } + + public Iterable getAdditionalClasspathElements() { + return additionalClasspathElements; + } } diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java index 2dbc27b300..a454999c0d 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java @@ -20,7 +20,6 @@ import java.io.File; import java.io.IOException; -import java.util.Collections; import java.util.List; import org.apache.maven.plugin.surefire.SurefireProperties; @@ -69,7 +68,6 @@ import static org.apache.maven.surefire.booter.BooterConstants.TESTARTIFACT_CLASSIFIER; import static org.apache.maven.surefire.booter.BooterConstants.TESTARTIFACT_VERSION; import static org.apache.maven.surefire.booter.BooterConstants.TEST_CLASSES_DIRECTORY; -import static org.apache.maven.surefire.booter.BooterConstants.TEST_SUITE_XML_FILES; import static org.apache.maven.surefire.booter.BooterConstants.USEMANIFESTONLYJAR; import static org.apache.maven.surefire.booter.BooterConstants.USESYSTEMCLASSLOADER; import static org.apache.maven.surefire.booter.SystemPropertyManager.writePropertiesFile; @@ -133,11 +131,6 @@ File serialize( TestRequest testSuiteDefinition = providerConfiguration.getTestSuiteDefinition(); if (testSuiteDefinition != null) { properties.setProperty(SOURCE_DIRECTORY, testSuiteDefinition.getTestSourceDirectory()); - if (testSet instanceof File) { - properties.addList(Collections.singletonList((File) testSet), TEST_SUITE_XML_FILES); - } else { - properties.addList(testSuiteDefinition.getSuiteXmlFiles(), TEST_SUITE_XML_FILES); - } TestListResolver testFilter = testSuiteDefinition.getTestListResolver(); properties.setProperty(REQUESTEDTEST, testFilter == null ? "" : testFilter.getPluginParameterTest()); int rerunFailingTestsCount = testSuiteDefinition.getRerunFailingTestsCount(); diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java index c612861eb8..fab3a2b670 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java @@ -61,7 +61,6 @@ import org.apache.maven.surefire.api.provider.SurefireProvider; import org.apache.maven.surefire.api.report.StackTraceWriter; import org.apache.maven.surefire.api.suite.RunResult; -import org.apache.maven.surefire.api.testset.TestRequest; import org.apache.maven.surefire.api.util.DefaultScanResult; import org.apache.maven.surefire.booter.AbstractPathConfiguration; import org.apache.maven.surefire.booter.PropertiesWrapper; @@ -302,9 +301,7 @@ private boolean isForkOnce() { } private boolean hasSuiteXmlFiles() { - TestRequest testSuiteDefinition = providerConfiguration.getTestSuiteDefinition(); - return testSuiteDefinition != null - && !testSuiteDefinition.getSuiteXmlFiles().isEmpty(); + return providerConfiguration.getTestSuiteDefinition() != null; } @SuppressWarnings("checkstyle:magicnumber") diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/Commandline.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/Commandline.java index 651e80ca3f..1d20b9b68f 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/Commandline.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/Commandline.java @@ -18,16 +18,13 @@ */ package org.apache.maven.plugin.surefire.booterclient.lazytestprovider; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; -import java.util.Properties; import java.util.Set; import java.util.concurrent.ConcurrentLinkedDeque; -import org.apache.maven.surefire.shared.utils.cli.CommandLineUtils; - -import static java.util.Collections.addAll; - /** * A {@link org.apache.maven.surefire.shared.utils.cli.Commandline} implementation. * @@ -46,8 +43,8 @@ public Commandline() { public Commandline(String[] excludedEnvironmentVariables) { this.excludedEnvironmentVariables = new ConcurrentLinkedDeque<>(); - addedEnvironmentVariables = new HashSet<>(); - addAll(this.excludedEnvironmentVariables, excludedEnvironmentVariables); + this.addedEnvironmentVariables = new HashSet<>(); + Collections.addAll(this.excludedEnvironmentVariables, excludedEnvironmentVariables); } @Override @@ -57,13 +54,18 @@ public void addEnvironment(String name, String value) { } @Override - public final void addSystemEnvironment() { - Properties systemEnvVars = CommandLineUtils.getSystemEnvVars(); - - for (String key : systemEnvVars.stringPropertyNames()) { - if (!addedEnvironmentVariables.contains(key) && !excludedEnvironmentVariables.contains(key)) { - addEnvironment(key, systemEnvVars.getProperty(key)); - } - } + public String[] getEnvironmentVariables() { + String[] envs = super.getEnvironmentVariables(); + Set result = new HashSet<>(Arrays.asList(envs)); + result.addAll(addedEnvironmentVariables); + return excludedEnvironmentVariables.isEmpty() + ? result.toArray(new String[0]) + : result.stream() + .filter(env -> { + String varName = + env != null && env.contains("=") ? env.substring(0, env.indexOf('=')) : env; + return !excludedEnvironmentVariables.contains(varName); + }) + .toArray(String[]::new); } } diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java index 15640eb6c4..837adc2e20 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/log/PluginConsoleLogger.java @@ -22,6 +22,9 @@ import org.slf4j.Logger; /** + * + * TODO remove this as thread safety should be handled by the underlying logging framework no need to add complexity + * * Wrapper logger of miscellaneous implementations of {@link Logger}. * * This instance is synchronized. The logger operations are mutually exclusive to standard out, standard err and console diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/FileScanner.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/FileScanner.java index 48d72f2303..29e19bfbb8 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/FileScanner.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/FileScanner.java @@ -83,7 +83,7 @@ private void scan( private static String toJavaPackage(String... subDirectories) { StringBuilder pkg = new StringBuilder(); for (int i = 0; i < subDirectories.length; i++) { - if (i > 0 && i < subDirectories.length) { + if (i > 0) { pkg.append('.'); } pkg.append(subDirectories[i]); @@ -94,7 +94,7 @@ private static String toJavaPackage(String... subDirectories) { private static String toPath(String... subDirectories) { StringBuilder pkg = new StringBuilder(); for (int i = 0; i < subDirectories.length; i++) { - if (i > 0 && i < subDirectories.length) { + if (i > 0) { pkg.append('/'); } pkg.append(subDirectories[i]); diff --git a/maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ProviderInfo.java b/maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ProviderInfo.java index 52c68fdefd..4d6957aa2f 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ProviderInfo.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ProviderInfo.java @@ -25,11 +25,22 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.surefire.TestClassPath; + +import static org.apache.maven.plugin.surefire.SurefireDependencyResolver.isWithinVersionSpec; /** * @author Kristian Rosenvold */ public interface ProviderInfo { + + enum Engine { + JUNIT3, + JUNIT4, + TESTNG, + JUNIT_PLATFORM + } + @Nonnull String getProviderName(); @@ -42,4 +53,13 @@ public interface ProviderInfo { @Nonnull List getJpmsArguments(@Nonnull ProviderRequirements forkRequirements); + + default boolean isAnyJunit4(Artifact artifact) { + return isWithinVersionSpec(artifact, "[4.12,)"); + } + + default TestClassPath decorateTestClassPath(TestClassPath testClasspath) throws MojoExecutionException { + // no op + return testClasspath; + } } diff --git a/maven-surefire-common/src/main/resources/surefire.junit.version.properties b/maven-surefire-common/src/main/resources/surefire.junit.version.properties new file mode 100644 index 0000000000..9a2d190157 --- /dev/null +++ b/maven-surefire-common/src/main/resources/surefire.junit.version.properties @@ -0,0 +1,19 @@ +#/* +# * 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. +# */ +junit.version=${junit.version} diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java index 39007de0de..4cf51a60ff 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java @@ -452,22 +452,6 @@ public void testAllProviderInfo() { assertThat(providerInfo.getProviderName()).isEqualTo("custom.Provider"); assertThat(providerInfo.getJpmsArguments(providerRequirements)).isEmpty(); - providerInfo = mojo.newJUnit3ProviderInfo(); - assertThat(providerInfo.getProviderName()).isEqualTo("org.apache.maven.surefire.junit.JUnit3Provider"); - assertThat(providerInfo.getJpmsArguments(providerRequirements)).isEmpty(); - - providerInfo = mojo.newJUnit4ProviderInfo(); - assertThat(providerInfo.getProviderName()).isEqualTo("org.apache.maven.surefire.junit4.JUnit4Provider"); - assertThat(providerInfo.getJpmsArguments(providerRequirements)).isEmpty(); - - providerInfo = mojo.newJUnit47ProviderInfo(); - assertThat(providerInfo.getProviderName()).isEqualTo("org.apache.maven.surefire.junitcore.JUnitCoreProvider"); - assertThat(providerInfo.getJpmsArguments(providerRequirements)).isEmpty(); - - providerInfo = mojo.newTestNgProviderInfo(); - assertThat(providerInfo.getProviderName()).isEqualTo("org.apache.maven.surefire.testng.TestNGProvider"); - assertThat(providerInfo.getJpmsArguments(providerRequirements)).isEmpty(); - providerInfo = mojo.newJUnitPlatformProviderInfo(); assertThat(providerInfo.getProviderName()) .isEqualTo("org.apache.maven.surefire.junitplatform.JUnitPlatformProvider"); @@ -521,24 +505,9 @@ ProviderInfo newDynamicProviderInfo() { return new DynamicProviderInfo("custom.Provider"); } - ProviderInfo newJUnit3ProviderInfo() { - return new JUnit3ProviderInfo(); - } - - ProviderInfo newJUnit4ProviderInfo() { - return new JUnit4ProviderInfo(null, null); - } - - ProviderInfo newJUnit47ProviderInfo() { - return new JUnitCoreProviderInfo(null, null); - } - - ProviderInfo newTestNgProviderInfo() { - return new TestNgProviderInfo(null); - } - ProviderInfo newJUnitPlatformProviderInfo() { - return new JUnitPlatformProviderInfo(null, null, null); + return new JUnitPlatformProviderInfo( + null, null, null, null, null, null, null, null, null, null, null, null); } @Override @@ -747,29 +716,11 @@ public File getExcludesFile() { return null; } - @Override - protected List suiteXmlFiles() { - return null; - } - - @Override - protected boolean hasSuiteXmlFiles() { - return false; - } - @Override protected String[] getExcludedEnvironmentVariables() { return new String[0]; } - @Override - public File[] getSuiteXmlFiles() { - return new File[0]; - } - - @Override - public void setSuiteXmlFiles(File[] suiteXmlFiles) {} - @Override public String getRunOrder() { return null; diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJunitCoreProvidersInfoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJunitCoreProvidersInfoTest.java deleted file mode 100644 index 34da1018f5..0000000000 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJunitCoreProvidersInfoTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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.surefire; - -import java.util.Arrays; -import java.util.Collection; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.surefire.providerapi.ProviderInfo; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -/** - * Testing JUnitCoreProviderInfo applicable behavior. - */ -@RunWith(Parameterized.class) -public class AbstractSurefireMojoJunitCoreProvidersInfoTest { - private final Artifact junitArtifact; - private final Artifact junitDepArtifact; - private final boolean isParallel; - private final boolean hasGroups; - - private final boolean isApplicable; - - @Parameterized.Parameters(name = "{index}: junit={0}, junitDep={1}, parallel={2}, groups={3} then isApplicable={4}") - public static Collection data() { - return Arrays.asList(new Object[][] { - // junit and junitDep are null - {null, null, false, false, false}, - {null, null, true, false, false}, - {null, null, false, true, false}, - {null, null, true, true, false}, - - // only junit artifact - // without parallel and groups - {"4.5", null, false, false, false}, - {"4.7", null, false, false, false}, - - // with parallel - {"4.5", null, true, false, false}, - {"4.7", null, true, false, true}, - - // with groups - {"4.5", null, false, true, false}, - {"4.7", null, false, true, true}, - - // only junitDep artifact - // without parallel and groups - {null, "4.5", false, false, false}, - {null, "4.7", false, false, false}, - - // with parallel - {null, "4.5", true, false, false}, - {null, "4.7", true, false, true}, - - // with groups - {null, "4.5", false, true, false}, - {null, "4.7", false, true, true} - }); - } - - public AbstractSurefireMojoJunitCoreProvidersInfoTest( - String junitVersion, String junitDepVersion, boolean isParallel, boolean hasGroups, boolean isApplicable) { - this.junitArtifact = junitVersion != null ? aArtifact(junitVersion) : null; - this.junitDepArtifact = junitDepVersion != null ? aArtifact(junitDepVersion) : null; - this.isParallel = isParallel; - this.hasGroups = hasGroups; - this.isApplicable = isApplicable; - } - - private Artifact aArtifact(String version) { - return new DefaultArtifact("test", "test", version, "test", "jar", "", null); - } - - @Test - public void test() { - AbstractSurefireMojo mojo = spy(AbstractSurefireMojo.class); - - when(mojo.isAnyConcurrencySelected()).thenReturn(isParallel); - when(mojo.isAnyGroupsSelected()).thenReturn(hasGroups); - - ProviderInfo providerInfo = mojo.new JUnitCoreProviderInfo(junitArtifact, junitDepArtifact); - - assertThat(providerInfo.isApplicable()).isEqualTo(isApplicable); - } -} diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoProvidersInfoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoProvidersInfoTest.java index cf6d0cd0f2..ee0af8b660 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoProvidersInfoTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoProvidersInfoTest.java @@ -39,41 +39,20 @@ public class AbstractSurefireMojoProvidersInfoTest { @Spy private AbstractSurefireMojo mojo; - @Test - public void defaultProviderAreAlwaysAvailable() { - ProviderInfo providerInfo = mojo.new JUnit3ProviderInfo(); - assertThat(providerInfo.isApplicable()).isTrue(); - } - @Test public void dynamicProviderAreAlwaysApplicable() { ProviderInfo providerInfo = mojo.new DynamicProviderInfo("test"); assertThat(providerInfo.isApplicable()).isTrue(); } - @Test - public void testNgProviderApplicable() { - Artifact testNg = mock(Artifact.class); - ProviderInfo providerInfo = mojo.new TestNgProviderInfo(testNg); - - assertThat(providerInfo.isApplicable()).isTrue(); - - // no interaction with artifact only reference are checked - verifyNoMoreInteractions(testNg); - } - - @Test - public void testNgProviderNotApplicable() { - ProviderInfo providerInfo = mojo.new TestNgProviderInfo(null); - assertThat(providerInfo.isApplicable()).isFalse(); - } - // surefire-junit-platform @Test public void jUnitPlatformProviderApplicable() { Artifact junitPlatform = mock(Artifact.class); - ProviderInfo providerInfo = mojo.new JUnitPlatformProviderInfo(null, junitPlatform, aTestClassPath()); + ProviderInfo providerInfo = mojo + .new JUnitPlatformProviderInfo( + null, junitPlatform, aTestClassPath(), null, null, null, null, null, null, null, null, null); assertThat(providerInfo.isApplicable()).isTrue(); @@ -83,7 +62,9 @@ public void jUnitPlatformProviderApplicable() { @Test public void jUnitPlatformProviderNotApplicable() { - ProviderInfo providerInfo = mojo.new JUnitPlatformProviderInfo(null, null, aTestClassPath()); + ProviderInfo providerInfo = mojo + .new JUnitPlatformProviderInfo( + null, null, aTestClassPath(), null, null, null, null, null, null, null, null, null); assertThat(providerInfo.isApplicable()).isFalse(); } @@ -91,8 +72,20 @@ public void jUnitPlatformProviderNotApplicable() { public void jUnitPlatformProviderNotApplicableForPlatformRunner() { // not applicable if junit-platform-runner is on classpath Artifact junitPlatformRunnerArtifact = mock(Artifact.class); - ProviderInfo providerInfo = - mojo.new JUnitPlatformProviderInfo(junitPlatformRunnerArtifact, null, aTestClassPath()); + ProviderInfo providerInfo = mojo + .new JUnitPlatformProviderInfo( + junitPlatformRunnerArtifact, + null, + aTestClassPath(), + null, + null, + null, + null, + null, + null, + null, + null, + null); assertThat(providerInfo.isApplicable()).isFalse(); // no interaction with artifact only reference are checked @@ -103,54 +96,45 @@ public void jUnitPlatformProviderNotApplicableForPlatformRunner() { @Test public void jUnit4ProviderNullArtifacts() { - ProviderInfo providerInfo = mojo.new JUnit4ProviderInfo(null, null); + ProviderInfo providerInfo = mojo + .new JUnitPlatformProviderInfo( + null, null, aTestClassPath(), null, null, null, null, null, null, null, null, null); assertThat(providerInfo.isApplicable()).isFalse(); } @Test - public void jUnit4ProviderOnlyJunitDepArtifact() { - Artifact junitDep = mock(Artifact.class); - ProviderInfo providerInfo = mojo.new JUnit4ProviderInfo(null, junitDep); - - assertThat(providerInfo.isApplicable()).isTrue(); - - // no interaction with artifact only reference are checked - verifyNoMoreInteractions(junitDep); - } - - @Test - public void jUnit4ProviderJunit3WithJDepArtifact() { + public void jUnit4ProviderJunit3AsDependencyArtifact() { Artifact junit = aArtifact("3.8.1"); - Artifact junitDep = mock(Artifact.class); - - ProviderInfo providerInfo = mojo.new JUnit4ProviderInfo(junit, junitDep); - - // ??? only existing for junitDep in any version is checked - assertThat(providerInfo.isApplicable()).isTrue(); - - // no interaction with artifact only reference are checked - verifyNoMoreInteractions(junitDep); + ProviderInfo providerInfo = mojo + .new JUnitPlatformProviderInfo( + null, null, aTestClassPath(), junit, null, null, null, null, null, null, null, null); + assertThat(providerInfo.isApplicable()).isFalse(); } @Test - public void jUnit4ProviderJunit3AsDependencyArtifact() { + public void jUnit4ProviderJunit45AsDependencyArtifact() { Artifact junit = aArtifact("3.8.1"); - ProviderInfo providerInfo = mojo.new JUnit4ProviderInfo(junit, null); + ProviderInfo providerInfo = mojo + .new JUnitPlatformProviderInfo( + null, null, aTestClassPath(), junit, null, null, null, null, null, null, null, null); assertThat(providerInfo.isApplicable()).isFalse(); } @Test - public void jUnit4ProviderJunit45AsDependencyArtifact() { - Artifact junit = aArtifact("4.5"); - ProviderInfo providerInfo = mojo.new JUnit4ProviderInfo(junit, null); - assertThat(providerInfo.isApplicable()).isTrue(); + public void jUnit4ProviderJunit47AsDependencyArtifact() { + Artifact junit = aArtifact("3.8.1"); + ProviderInfo providerInfo = mojo + .new JUnitPlatformProviderInfo( + null, null, aTestClassPath(), junit, null, null, null, null, null, null, null, null); + assertThat(providerInfo.isApplicable()).isFalse(); } @Test - public void jUnit4ProviderJunit47AsDependencyArtifact() { - Artifact junit = aArtifact("4.7"); - ProviderInfo providerInfo = mojo.new JUnit4ProviderInfo(junit, null); - // ??? it is ok for 4.7 ??? + public void jUnit4ProviderJunit413AsDependencyArtifact() { + Artifact junit = aArtifact("4.13"); + ProviderInfo providerInfo = mojo + .new JUnitPlatformProviderInfo( + null, null, aTestClassPath(), junit, null, null, null, null, null, null, null, null); assertThat(providerInfo.isApplicable()).isTrue(); } diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java index c2967b534a..acb5bf9da4 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java @@ -19,10 +19,10 @@ package org.apache.maven.plugin.surefire; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.UncheckedIOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -49,7 +49,6 @@ import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.plugin.surefire.AbstractSurefireMojo.JUnitPlatformProviderInfo; import org.apache.maven.plugin.surefire.booterclient.Platform; import org.apache.maven.plugin.surefire.log.PluginConsoleLogger; import org.apache.maven.project.MavenProject; @@ -73,7 +72,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -99,6 +97,7 @@ import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS; import static org.assertj.core.api.Assertions.assertThat; import static org.codehaus.plexus.languages.java.jpms.ModuleNameSource.MODULEDESCRIPTOR; +import static org.junit.Assert.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -120,8 +119,6 @@ @PrepareForTest(AbstractSurefireMojo.class) @PowerMockIgnore({"org.jacoco.agent.rt.*", "com.vladium.emma.rt.*"}) public class AbstractSurefireMojoTest { - @Rule - public final ExpectedException e = ExpectedException.none(); @Rule public final TemporaryFolder tempFolder = new TemporaryFolder(); @@ -135,6 +132,8 @@ public class AbstractSurefireMojoTest { public void setupMojo() { Artifact mojoArtifact = mojo.getMojoArtifact(); + mojo.setProperties(new Properties()); + mojo.setPluginArtifactMap(new LinkedHashMap<>()); mojo.getPluginArtifactMap().put(mojoArtifact.getGroupId() + ":" + mojoArtifact.getArtifactId(), mojoArtifact); Artifact forkedBooter = new DefaultArtifact( @@ -533,6 +532,7 @@ public void shouldHaveStartupConfigForNonModularClasspath() throws Exception { ProviderInfo providerInfo = mock(ProviderInfo.class); when(providerInfo.getProviderName()).thenReturn("org.asf.Provider"); when(providerInfo.getProviderClasspath()).thenReturn(providerArtifacts); + when(providerInfo.decorateTestClassPath(any())).thenReturn(testClasspath); StartupConfiguration conf = invokeMethod( mojo, "newStartupConfigWithClasspath", classLoaderConfiguration, providerInfo, testClasspath); @@ -582,6 +582,9 @@ public void providerClasspathCachingIsNotSharedAcrossMojoInstances() throws Exce provider.setFile(mockFile("original-test-provider.jar")); Set providerClasspath = singleton(provider); when(providerInfo.getProviderClasspath()).thenReturn(providerClasspath); + TestClassPath testClassPath = + new TestClassPath(providerClasspath, new File("target"), new File("target"), Collections.emptyList()); + when(providerInfo.decorateTestClassPath(any())).thenReturn(testClassPath); StartupConfiguration startupConfiguration = startupConfigurationForProvider(providerInfo); assertThat(startupConfiguration @@ -610,7 +613,7 @@ private StartupConfiguration startupConfigurationForProvider(ProviderInfo provid File classesDir = mockFile("classes"); File testClassesDir = mockFile("test-classes"); TestClassPath testClassPath = - new TestClassPath(new ArrayList(), classesDir, testClassesDir, Collections.emptyList()); + new TestClassPath(new ArrayList<>(), classesDir, testClassesDir, Collections.emptyList()); Artifact common = new DefaultArtifact( "org.apache.maven.surefire", @@ -715,14 +718,14 @@ public void shouldCreateStartupConfigWithModularPath() throws Exception { File testClassesDirectory = new File(baseDir, "mock-dir"); mojo.setTestClassesDirectory(testClassesDirectory); TestClassPath testClassPath = new TestClassPath( - Collections.emptySet(), classesDirectory, testClassesDirectory, Collections.emptyList()); + Collections.emptySet(), classesDirectory, testClassesDirectory, Collections.emptyList()); ProviderInfo providerInfo = mock(ProviderInfo.class); when(providerInfo.getProviderName()).thenReturn("provider mock"); - when(providerInfo.getProviderClasspath()).thenReturn(Collections.emptySet()); + when(providerInfo.getProviderClasspath()).thenReturn(Collections.emptySet()); DefaultScanResult defaultScanResult = mock(DefaultScanResult.class); - when(defaultScanResult.getClasses()).thenReturn(Collections.emptyList()); + when(defaultScanResult.getClasses()).thenReturn(Collections.emptyList()); Path pathToModularDescriptor = Paths.get(baseDir, "src", "test", "resources", "org", "apache", "maven", "plugin", "surefire"); @@ -933,7 +936,7 @@ public void shouldSmartlyResolveJUnit5ProviderWithJUnit4() throws Exception { assertThat(junitPlatformArtifact.getArtifactId()).isEqualTo("junit-platform-engine"); assertThat(junitPlatformArtifact.getVersion()).isEqualTo("1.4.0"); - JUnitPlatformProviderInfo prov = + AbstractSurefireMojo.JUnitPlatformProviderInfo prov = mojo.createJUnitPlatformProviderInfo(junitPlatformArtifact, testClasspathWrapper); assertThat(prov.isApplicable()).isTrue(); @@ -1052,7 +1055,7 @@ public void shouldSmartlyResolveJUnit5ProviderWithVintage() throws Exception { testClasspathOpentest4j, testClasspathCommons); - setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[testArtifacts.size()])); + setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[0])); File classesDirectory = new File("target/classes"); @@ -1076,14 +1079,14 @@ public void shouldSmartlyResolveJUnit5ProviderWithVintage() throws Exception { mojo.setPluginDescriptor(pluginDescriptor); Plugin p = mock(Plugin.class); when(pluginDescriptor.getPlugin()).thenReturn(p); - when(p.getDependencies()).thenReturn(Collections.emptyList()); + when(p.getDependencies()).thenReturn(Collections.emptyList()); Artifact junitPlatformArtifact = invokeMethod(mojo, "getJUnit5Artifact"); assertThat(junitPlatformArtifact.getGroupId()).isEqualTo("org.junit.platform"); assertThat(junitPlatformArtifact.getArtifactId()).isEqualTo("junit-platform-commons"); assertThat(junitPlatformArtifact.getVersion()).isEqualTo("1.4.0"); - JUnitPlatformProviderInfo prov = + AbstractSurefireMojo.JUnitPlatformProviderInfo prov = mojo.createJUnitPlatformProviderInfo(junitPlatformArtifact, testClasspathWrapper); assertThat(prov.isApplicable()).isTrue(); @@ -1143,7 +1146,7 @@ public void shouldSmartlyResolveJUnit5ProviderWithJUnit5Commons() throws Excepti Collection testArtifacts = asList(testClasspathSomeTestArtifact, testClasspathApiguardian, testClasspathCommons); - setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[testArtifacts.size()])); + setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[0])); File classesDirectory = new File("target/classes"); @@ -1169,14 +1172,14 @@ public void shouldSmartlyResolveJUnit5ProviderWithJUnit5Commons() throws Excepti mojo.setPluginDescriptor(pluginDescriptor); Plugin p = mock(Plugin.class); when(pluginDescriptor.getPlugin()).thenReturn(p); - when(p.getDependencies()).thenReturn(Collections.emptyList()); + when(p.getDependencies()).thenReturn(Collections.emptyList()); Artifact junitPlatformArtifact = invokeMethod(mojo, "getJUnit5Artifact"); assertThat(junitPlatformArtifact.getGroupId()).isEqualTo("org.junit.platform"); assertThat(junitPlatformArtifact.getArtifactId()).isEqualTo("junit-platform-commons"); assertThat(junitPlatformArtifact.getVersion()).isEqualTo("1.4.0"); - JUnitPlatformProviderInfo prov = + AbstractSurefireMojo.JUnitPlatformProviderInfo prov = mojo.createJUnitPlatformProviderInfo(junitPlatformArtifact, testClasspathWrapper); assertThat(prov.isApplicable()).isTrue(); @@ -1257,7 +1260,7 @@ public void shouldSmartlyResolveJUnit5ProviderWithJUnit5Engine() throws Exceptio testClasspathCommons, testClasspathOpentest4j); - setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[testArtifacts.size()])); + setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[0])); File classesDirectory = new File("target/classes"); @@ -1284,7 +1287,7 @@ public void shouldSmartlyResolveJUnit5ProviderWithJUnit5Engine() throws Exceptio assertThat(junitPlatformArtifact.getArtifactId()).isEqualTo("junit-platform-commons"); assertThat(junitPlatformArtifact.getVersion()).isEqualTo("1.4.0"); - JUnitPlatformProviderInfo prov = + AbstractSurefireMojo.JUnitPlatformProviderInfo prov = mojo.createJUnitPlatformProviderInfo(junitPlatformArtifact, testClasspathWrapper); assertThat(prov.isApplicable()).isTrue(); @@ -1365,7 +1368,7 @@ public void shouldSmartlyResolveJUnit5ProviderWithJupiterApi() throws Exception testClasspathCommons, testClasspathOpentest4j); - setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[testArtifacts.size()])); + setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[0])); File classesDirectory = new File("target/classes"); @@ -1410,14 +1413,14 @@ public void shouldSmartlyResolveJUnit5ProviderWithJupiterApi() throws Exception mojo.setPluginDescriptor(pluginDescriptor); Plugin p = mock(Plugin.class); when(pluginDescriptor.getPlugin()).thenReturn(p); - when(p.getDependencies()).thenReturn(Collections.emptyList()); + when(p.getDependencies()).thenReturn(Collections.emptyList()); Artifact junitPlatformArtifact = invokeMethod(mojo, "getJUnit5Artifact"); assertThat(junitPlatformArtifact.getGroupId()).isEqualTo("org.junit.platform"); assertThat(junitPlatformArtifact.getArtifactId()).isEqualTo("junit-platform-commons"); assertThat(junitPlatformArtifact.getVersion()).isEqualTo("1.4.0"); - JUnitPlatformProviderInfo prov = + AbstractSurefireMojo.JUnitPlatformProviderInfo prov = mojo.createJUnitPlatformProviderInfo(junitPlatformArtifact, testClasspathWrapper); assertThat(prov.isApplicable()).isTrue(); @@ -1530,7 +1533,7 @@ public void shouldSmartlyResolveJUnit5ProviderWithJupiterEngine() throws Excepti testClasspathCommons, testClasspathOpentest4j); - setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[testArtifacts.size()])); + setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[0])); File classesDirectory = new File("target/classes"); @@ -1555,7 +1558,7 @@ public void shouldSmartlyResolveJUnit5ProviderWithJupiterEngine() throws Excepti assertThat(junitPlatformArtifact.getArtifactId()).isEqualTo("junit-platform-commons"); assertThat(junitPlatformArtifact.getVersion()).isEqualTo("1.4.0"); - JUnitPlatformProviderInfo prov = + AbstractSurefireMojo.JUnitPlatformProviderInfo prov = mojo.createJUnitPlatformProviderInfo(junitPlatformArtifact, testClasspathWrapper); assertThat(prov.isApplicable()).isTrue(); @@ -1713,7 +1716,7 @@ public void shouldSmartlyResolveJUnit5ProviderWithJupiterEngineInPluginDependenc testClasspathCommons, testClasspathOpentest4j); - setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[testArtifacts.size()])); + setProjectDepedenciesToMojo(testArtifacts.toArray(new Artifact[0])); File classesDirectory = new File("target/classes"); @@ -1749,11 +1752,6 @@ public void shouldSmartlyResolveJUnit5ProviderWithJupiterEngineInPluginDependenc assertThat(junitPlatformArtifact.getArtifactId()).isEqualTo("junit-platform-engine"); assertThat(junitPlatformArtifact.getVersion()).isEqualTo("1.4.0"); - JUnitPlatformProviderInfo prov = - mojo.createJUnitPlatformProviderInfo(junitPlatformArtifact, testClasspathWrapper); - - assertThat(prov.isApplicable()).isTrue(); - PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class); mojo.setPluginDescriptor(pluginDescriptor); Plugin p = mock(Plugin.class); @@ -1761,6 +1759,11 @@ public void shouldSmartlyResolveJUnit5ProviderWithJupiterEngineInPluginDependenc List directPluginDependencies = toDependencies(pluginDepJupiterEngine); when(p.getDependencies()).thenReturn(directPluginDependencies); + AbstractSurefireMojo.JUnitPlatformProviderInfo prov = + mojo.createJUnitPlatformProviderInfo(junitPlatformArtifact, testClasspathWrapper); + + assertThat(prov.isApplicable()).isTrue(); + Artifact surefireProvider = new DefaultArtifact( "org.apache.maven.surefire", "surefire-junit-platform", surefireVersion, null, "jar", "", null); Artifact java5 = new DefaultArtifact( @@ -1883,6 +1886,7 @@ private static Set createSurefireProviderResolutionResult(VersionRange @Test public void shouldVerifyConfigParameters() throws Exception { + Mojo mojo = new Mojo() { @Override public File getTestClassesDirectory() { @@ -1895,9 +1899,9 @@ protected String getEnableProcessChecker() { } }; - e.expect(MojoFailureException.class); - e.expectMessage("Unexpected value 'fake' in the configuration parameter 'enableProcessChecker'."); - mojo.verifyParameters(); + MojoFailureException m = assertThrows(MojoFailureException.class, mojo::verifyParameters); + assertThat(m.getMessage()) + .isEqualTo("Unexpected value 'fake' in the configuration parameter 'enableProcessChecker'."); } private void setProjectDepedenciesToMojo(Artifact... deps) { @@ -1944,7 +1948,19 @@ public static class Mojo extends AbstractSurefireMojo implements SurefireReportP private JUnitPlatformProviderInfo createJUnitPlatformProviderInfo( Artifact junitPlatformArtifact, TestClassPath testClasspathWrapper) { - return new JUnitPlatformProviderInfo(null, junitPlatformArtifact, testClasspathWrapper); + return new JUnitPlatformProviderInfo( + null, + junitPlatformArtifact, + testClasspathWrapper, + null, + getBooterArtifact(), + getSurefireDependencyResolver(), + mock(MavenSession.class), + mock(MavenProject.class), + getPluginDescriptor(), + getPluginArtifactMap(), + getConsoleLogger(), + null); } void setProjectTestArtifacts(List projectTestArtifacts) { @@ -2195,29 +2211,11 @@ public File getExcludesFile() { return excludesFile; } - @Override - protected List suiteXmlFiles() { - return null; - } - - @Override - protected boolean hasSuiteXmlFiles() { - return false; - } - @Override protected String[] getExcludedEnvironmentVariables() { return new String[0]; } - @Override - public File[] getSuiteXmlFiles() { - return new File[0]; - } - - @Override - public void setSuiteXmlFiles(File[] suiteXmlFiles) {} - @Override public String getRunOrder() { return null; @@ -2352,8 +2350,9 @@ public void shouldNotPerformMethodFilteringOnIncludes() throws Exception { plugin.setProjectTestArtifacts(singletonList(testDeps)); plugin.setDependenciesToScan(new String[] {"g:a"}); - e.expectMessage("Method filter prohibited in includes|excludes parameter: AnotherTest#method "); - plugin.scanDependencies(); + Exception e = assertThrows(Exception.class, plugin::scanDependencies); + assertThat(e.getMessage()) + .isEqualTo("Method filter prohibited in includes|excludes parameter: AnotherTest#method "); } @Test @@ -2493,7 +2492,7 @@ public File getSystemPropertiesFile() { systemProperties.put("userProperties1", "source2"); try { File propertiesFile = tempFolder.newFile(); - try (OutputStream outputStream = new FileOutputStream(propertiesFile)) { + try (OutputStream outputStream = Files.newOutputStream(propertiesFile.toPath())) { systemProperties.store(outputStream, "comments"); } return propertiesFile; diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java index 0f952d76ea..53e613a1fc 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java @@ -19,7 +19,7 @@ package org.apache.maven.plugin.surefire; import java.io.File; -import java.io.FileOutputStream; +import java.nio.file.Files; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -174,7 +174,7 @@ public void scanDependenciesShouldReturnClassWithExistingTestJAR() throws Except File artifactFile = SureFireFileManager.createTempFile("surefire", ".jar"); testDeps.setFile(artifactFile); - try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(artifactFile))) { + try (ZipOutputStream os = new ZipOutputStream(Files.newOutputStream(artifactFile.toPath()))) { os.putNextEntry(new ZipEntry("pkg/")); os.closeEntry(); os.putNextEntry(new ZipEntry("pkg/MyTest.class")); @@ -203,7 +203,7 @@ public void scanDependenciesShouldReturnNullWithEmptyTestJAR() throws Exception File artifactFile = SureFireFileManager.createTempFile("surefire", ".jar"); testDeps.setFile(artifactFile); - try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(artifactFile))) { + try (ZipOutputStream os = new ZipOutputStream(Files.newOutputStream(artifactFile.toPath()))) { os.putNextEntry(new ZipEntry("pkg/")); os.closeEntry(); os.finish(); @@ -268,7 +268,7 @@ public void scanMultipleDependencies() throws Exception { Artifact testDep2 = new DefaultArtifact("g", "a", version, "test", "jar", null, handler); File artifactFile2 = SureFireFileManager.createTempFile("surefire", ".jar"); testDep2.setFile(artifactFile2); - try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(artifactFile2))) { + try (ZipOutputStream os = new ZipOutputStream(Files.newOutputStream(artifactFile2.toPath()))) { os.putNextEntry(new ZipEntry("pkg/")); os.closeEntry(); os.putNextEntry(new ZipEntry("pkg/MyTest.class")); @@ -506,29 +506,11 @@ public File getExcludesFile() { return null; } - @Override - protected List suiteXmlFiles() { - return null; - } - - @Override - protected boolean hasSuiteXmlFiles() { - return false; - } - @Override protected String[] getExcludedEnvironmentVariables() { return new String[0]; } - @Override - public File[] getSuiteXmlFiles() { - return new File[0]; - } - - @Override - public void setSuiteXmlFiles(File[] suiteXmlFiles) {} - @Override public String getRunOrder() { return null; diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java index 0069e00d53..6529e5830c 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java @@ -143,10 +143,6 @@ public void testTestRequest() throws IOException { ProviderConfiguration reloaded = getReloadedProviderConfiguration(); TestRequest testSuiteDefinition = reloaded.getTestSuiteDefinition(); - List suiteXmlFiles = testSuiteDefinition.getSuiteXmlFiles(); - File[] expected = getSuiteXmlFiles(); - Assert.assertEquals(expected[0], suiteXmlFiles.get(0)); - Assert.assertEquals(expected[1], suiteXmlFiles.get(1)); Assert.assertEquals(getTestSourceDirectory(), testSuiteDefinition.getTestSourceDirectory()); TestListResolver resolver = testSuiteDefinition.getTestListResolver(); Assert.assertNotNull(resolver); @@ -239,7 +235,6 @@ private ProviderConfiguration getTestProviderConfiguration( File cwd = new File("."); ReporterConfiguration reporterConfiguration = new ReporterConfiguration(cwd, true); TestRequest testSuiteDefinition = new TestRequest( - getSuiteXmlFileStrings(), getTestSourceDirectory(), new TestListResolver(USER_REQUESTED_TEST + "#aUserRequestedTestMethod"), RERUN_FAILING_TEST_COUNT); @@ -274,10 +269,6 @@ private File getTestSourceDirectory() { return new File("TestSrc"); } - private File[] getSuiteXmlFiles() { - return new File[] {new File("A1"), new File("A2")}; - } - private List getSuiteXmlFileStrings() { return Arrays.asList("A1", "A2"); } diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java index 78183944f9..6eaaabd40c 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java @@ -175,13 +175,11 @@ private StartupConfiguration saveAndReload(StartupConfiguration startupConfigura private ProviderConfiguration getProviderConfiguration() { File cwd = new File("."); - DirectoryScannerParameters directoryScannerParameters = new DirectoryScannerParameters( - cwd, new ArrayList(), new ArrayList(), new ArrayList(), "hourly"); + DirectoryScannerParameters directoryScannerParameters = + new DirectoryScannerParameters(cwd, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), "hourly"); ReporterConfiguration reporterConfiguration = new ReporterConfiguration(cwd, true); TestRequest testSuiteDefinition = new TestRequest( - Arrays.asList(getSuiteXmlFileStrings()), - getTestSourceDirectory(), - new TestListResolver("aUserRequestedTest#aUserRequestedTestMethod")); + getTestSourceDirectory(), new TestListResolver("aUserRequestedTest#aUserRequestedTestMethod"), 0); RunOrderParameters runOrderParameters = new RunOrderParameters(RunOrder.DEFAULT, null); return new ProviderConfiguration( diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/CommandlineTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/CommandlineTest.java index 2ebcd3e859..fb43709954 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/CommandlineTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/CommandlineTest.java @@ -19,7 +19,6 @@ package org.apache.maven.plugin.surefire.booterclient.lazytestprovider; import org.apache.maven.surefire.shared.utils.cli.CommandLineException; -import org.assertj.core.api.Condition; import org.junit.Test; import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS; @@ -34,13 +33,13 @@ public void shouldGetEnvironmentVariables() { Commandline cli = new Commandline(); String[] env = cli.getEnvironmentVariables(); - assertThat(env).doesNotHaveDuplicates().satisfies(new ContainsAnyStartsWith("JAVA_HOME=")); + assertThat(env).doesNotHaveDuplicates().anyMatch(s -> s != null && s.startsWith("JAVA_HOME")); String[] excluded = {"JAVA_HOME"}; cli = new Commandline(excluded); env = cli.getEnvironmentVariables(); - assertThat(env).doesNotHaveDuplicates().satisfies(new NotContainsAnyStartsWith("JAVA_HOME=")); + assertThat(env).doesNotHaveDuplicates().allMatch(s -> s != null && !s.startsWith("JAVA_HOME")); } @Test @@ -50,40 +49,4 @@ public void shouldExecute() throws CommandLineException { cli.getShell().setExecutable(IS_OS_WINDOWS ? "dir" : "ls"); cli.execute(); } - - private static final class ContainsAnyStartsWith extends Condition { - private final String expected; - - ContainsAnyStartsWith(String expected) { - this.expected = expected; - } - - @Override - public boolean matches(Object[] values) { - boolean matches = false; - for (Object value : values) { - assertThat(value).isInstanceOf(String.class); - matches |= ((String) value).startsWith(expected); - } - return matches; - } - } - - private static final class NotContainsAnyStartsWith extends Condition { - private final String expected; - - NotContainsAnyStartsWith(String expected) { - this.expected = expected; - } - - @Override - public boolean matches(Object[] values) { - boolean matches = false; - for (Object value : values) { - assertThat(value).isInstanceOf(String.class); - matches |= ((String) value).startsWith(expected); - } - return !matches; - } - } } diff --git a/maven-surefire-plugin/pom.xml b/maven-surefire-plugin/pom.xml index 110ab68a7c..8c05895fe8 100644 --- a/maven-surefire-plugin/pom.xml +++ b/maven-surefire-plugin/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT org.apache.maven.plugins diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefireMojo.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefireMojo.java index 07406c557f..d268031b21 100644 --- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefireMojo.java +++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefireMojo.java @@ -19,8 +19,6 @@ package org.apache.maven.plugin.surefire; import java.io.File; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.apache.maven.plugin.MojoExecutionException; @@ -74,13 +72,12 @@ public class SurefireMojo extends AbstractSurefireMojo implements SurefireReport * **{@literal /}${test}.java, so you can just type {@code -Dtest=MyTest} to run a single test called * "foo/MyTest.java". The test patterns prefixed with a ! will be excluded. *
- * This parameter overrides the parameter {@code includes}, {@code excludes}, and the TestNG parameter - * {@code suiteXmlFiles}. + * This parameter overrides the parameter {@code includes}, {@code excludes}. *
* Since 2.7.3, you can execute a limited number of methods in the test by adding #myMethod or * #my*ethod. For example, {@code -Dtest=MyTest#myMethod}. This is supported for junit 4.x and TestNg.
*
- * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): + * Since 2.19 a complex syntax is supported in one parameter: *
"-Dtest=???Test, !Unstable*, pkg{@literal /}**{@literal /}Ci*leTest.java, *Test#test*One+testTwo?????, #fast*+slowTest"
* or e.g. *
"-Dtest=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyTest.class#one.*|two.*], %regex[#fast.*|slow.*]"
@@ -201,7 +198,6 @@ public class SurefireMojo extends AbstractSurefireMojo implements SurefireReport * {@literal }%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg{@literal /}**{@literal /}*Fast*.java{@literal } * *
- * This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified.
*
* Notice that these values are relative to the directory containing generated test classes of the project * being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults @@ -222,8 +218,6 @@ public class SurefireMojo extends AbstractSurefireMojo implements SurefireReport * * (which excludes all inner classes). *
- * This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified. - *
* Each exclude item may also contain a comma-separated sub-list of items, which will be treated as multiple * {@literal } entries.
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): @@ -293,6 +287,7 @@ public class SurefireMojo extends AbstractSurefireMojo implements SurefireReport private int failOnFlakeCount; /** + * @deprecated not supported after 3.6.0, please use groups or Junit suite support * (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that * {@code suiteXmlFiles} is incompatible with several other parameters of this plugin, like * {@code includes} and {@code excludes}.
@@ -819,17 +814,6 @@ public void setExcludes(List excludes) { this.excludes = excludes; } - @Override - public File[] getSuiteXmlFiles() { - return suiteXmlFiles.clone(); - } - - @Override - @SuppressWarnings("UnusedDeclaration") - public void setSuiteXmlFiles(File[] suiteXmlFiles) { - this.suiteXmlFiles = suiteXmlFiles.clone(); - } - @Override public String getRunOrder() { return runOrder; @@ -871,16 +855,6 @@ protected void setUseModulePath(boolean useModulePath) { this.useModulePath = useModulePath; } - @Override - protected final List suiteXmlFiles() { - return hasSuiteXmlFiles() ? Arrays.asList(suiteXmlFiles) : Collections.emptyList(); - } - - @Override - protected final boolean hasSuiteXmlFiles() { - return suiteXmlFiles != null && suiteXmlFiles.length != 0; - } - @Override protected final String[] getExcludedEnvironmentVariables() { return excludedEnvironmentVariables == null ? new String[0] : excludedEnvironmentVariables; diff --git a/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm b/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm index 7cdbf4a36e..57c8de1202 100644 --- a/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm +++ b/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm @@ -335,49 +335,6 @@ public class TestSuite { Port numbers and file names are other examples of resources for which it may be hard or undesired to be shared among concurrent test executions. - -* Isolating report directories across forks - - You may run multiple TestNG suites in parallel fork JVM processes. In that case - one can see that each process has created XML report file with same name - overriding one each other. In order to prevent from this, you may want to change - report directory for each Suite XML. Since of Version 2.22.1 you can parameterize - <<>> with placeholder <<<$\{surefire.forkNumber\}>>>. - -+---+ -[...] - - [...] - - org.testng - testng - 5.7 - jdk15 - - [...] - -[...] - - - [...] - - ${project.groupId} - ${project.artifactId} - ${project.version} - - 2 - false - target/surefire-reports-${surefire.forkNumber} - - src/test/resources/Suite1.xml - src/test/resources/Suite2.xml - - - - [...] - - -+---+ * Combining forkCount and parallel diff --git a/maven-surefire-plugin/src/site/apt/examples/junit.apt.vm b/maven-surefire-plugin/src/site/apt/examples/junit.apt.vm index e6788074f9..446b61ebbe 100644 --- a/maven-surefire-plugin/src/site/apt/examples/junit.apt.vm +++ b/maven-surefire-plugin/src/site/apt/examples/junit.apt.vm @@ -198,36 +198,6 @@ else Since JUnit 4.12 thread safe listener class should be annotated by <<>> which avoids unnecessary locks in JUnit. - -* Using a Security Manager (JUnit3 only) - - As long as <<>> is not 0 and you use JUnit3, you can run your tests with a Java security manager enabled. - The class name of the security manager must be sent as a system property variable to the JUnit3 provider. - - The JDK 17 deprecated the class <<>> and the security manager is not fully supported - since JDK 18. The JUnit3 provider fails with enabled system property <>> in JDK 18+. - - JUnit4 uses mechanisms internally that are not compatible with the tested - security managers and thus this means of configuring a security manager with JUnit4 is not supported - by Surefire. - -+---+ - -[...] - - ${project.groupId} - ${project.artifactId} - ${project.version} - - - java.lang.SecurityManager - - - -[...] - -+---+ - * Using a Security Manager (All providers) Alternatively you can define a policy file that allows all providers to run with Surefire diff --git a/maven-surefire-plugin/src/site/apt/examples/pojo-test.apt.vm b/maven-surefire-plugin/src/site/apt/examples/pojo-test.apt.vm deleted file mode 100644 index 7daf0124f3..0000000000 --- a/maven-surefire-plugin/src/site/apt/examples/pojo-test.apt.vm +++ /dev/null @@ -1,49 +0,0 @@ - ------ - Using POJO Tests - ------ - Christian Gruber - ------ - May 2008 - ------ - - ~~ 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. - - ~~ NOTE: For help with the syntax of this file, see: - ~~ http://maven.apache.org/doxia/references/apt-format.html - -Using POJO Tests - - POJO tests look very much like JUnit or TestNG tests, though they do not - require dependencies on these artifacts. A test class should be named - <<<**/*Test>>> and should contain <<>> methods which will each be - executed by Surefire. - - Validating assertions can be done using the JDK 1.4 <<>> keyword. - Simultaneous test execution is not possible with POJO tests. - - Fixtures can be setup before and after each <<>> method by implementing - a set-up and a tear-down methods. These methods must match the following signatures - to be recognized and executed before and after each test method: - -+---+ -public void setUp(); -public void tearDown(); -+---+ - - These fixture methods can also throw any exception and will still be valid. - diff --git a/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm index 5704d8d2de..758676ab40 100644 --- a/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm +++ b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm @@ -59,30 +59,6 @@ Using TestNG If you'd like to use a different naming scheme, you can change the <<>> parameter, as discussed in the {{{./inclusion-exclusion.html}Inclusions and Exclusions of Tests}} example. -* Using Suite XML Files - - Another alternative is to use TestNG suite XML files. This allows flexible configuration of the tests to be run. - These files are created in the normal way, and then added to the ${thisPlugin} Plugin configuration: - -+---+ - - [...] - - ${project.groupId} - ${project.artifactId} - ${project.version} - - - testng.xml - - - - [...] - -+---+ - - This configuration will override the includes and excludes patterns and run all tests in the suite files. - * Specifying Test Parameters Your TestNG test can accept parameters with the <<<@Parameters>>> annotation. You can also pass parameters from Maven @@ -177,32 +153,7 @@ Using TestNG [...]
+---+ - - You can run suites in parallel. - -+---+ - - [...] - - ${project.groupId} - ${project.artifactId} - ${project.version} - - - src/test/resources/testng1.xml - src/test/resources/testng2.xml - - - - suitethreadpoolsize - 2 - - - - - [...] - -+---+ + See also {{{./fork-options-and-parallel-execution.html}Fork Options and Parallel Test Execution}}. @@ -343,62 +294,6 @@ Using TestNG +---+ -* Running 'testnames' in test tag - - Only tests defined in a <<>> tag matching one of these names will be run. - In this example two tests run out of 7; namely and . - The test does not match any test in . - -+---+ - - [...] - - ${project.groupId} - ${project.artifactId} - ${project.version} - - [...] - - src/test/resources/suite.xml - - - - testnames - a-t1,a-t3 - - - [...] - - - [...] - -+---+ - - - The test suite 'suite.xml' : - -+---+ - - - - - - - - - - - - - - - - - - -+---+ - - * Running TestNG and JUnit Tests To run TestNG and JUnit 4.x in the current Maven project, you need diff --git a/maven-surefire-plugin/src/site/site.xml b/maven-surefire-plugin/src/site/site.xml index 17b92a0d80..0b368effe6 100644 --- a/maven-surefire-plugin/src/site/site.xml +++ b/maven-surefire-plugin/src/site/site.xml @@ -42,7 +42,6 @@ - diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml index 9d4bc74fe6..5ca48fd70e 100644 --- a/maven-surefire-report-plugin/pom.xml +++ b/maven-surefire-report-plugin/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT org.apache.maven.plugins diff --git a/pom.xml b/pom.xml index b5f0854c21..cda02f35ea 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT pom Apache Maven Surefire @@ -54,7 +54,6 @@ surefire-extensions-api surefire-extensions-spi surefire-booter - surefire-grouper surefire-providers surefire-shadefire maven-surefire-common @@ -95,7 +94,7 @@ 2.20.0 1.5.0 - 3.3.4 + 3.4.2 2.0.9 0.8.13 5.11 @@ -105,8 +104,9 @@ ${javaVersion} ${jvm9ArgsTests} -Xms32m -Xmx144m -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true - 2025-09-10T02:02:34Z + 2025-10-10T08:50:35Z 1.7.36 + 5.14.1 @@ -118,6 +118,14 @@ test
+ + org.junit + junit-bom + ${junit.version} + pom + import + + org.slf4j slf4j-api diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml index e30d328119..9a7e9b9932 100644 --- a/surefire-api/pom.xml +++ b/surefire-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-api diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/booter/ProviderParameterNames.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/booter/ProviderParameterNames.java index b657888d28..03db2d0cc7 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/api/booter/ProviderParameterNames.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/booter/ProviderParameterNames.java @@ -22,9 +22,9 @@ * @author Kristian Rosenvold */ public class ProviderParameterNames { - public static final String TESTNG_EXCLUDEDGROUPS_PROP = "excludegroups"; + public static final String EXCLUDEDGROUPS_PROP = "excludegroups"; - public static final String TESTNG_GROUPS_PROP = "groups"; + public static final String GROUPS_PROP = "groups"; public static final String INCLUDE_JUNIT5_ENGINES_PROP = "includejunit5engines"; @@ -48,5 +48,9 @@ public class ProviderParameterNames { public static final String ENABLE_OUT_ERR_ELEMENTS_PROP = "enableouterrelements"; - public static final String ENABLE_PROPERTIES_ELEMENT_PROP = "enablepropertieselement"; + public static final String JUNIT_VINTAGE_DETECTED = "junit.vintage.engine.detected"; + + public static final String INCLUDES_SCAN_LIST = "junit.includes.scan.list"; + + public static final String EXCLUDES_SCAN_LIST = "junit.excludes.scan.list"; } diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestListResolver.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestListResolver.java index ab8938dc2e..55609db63a 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestListResolver.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestListResolver.java @@ -155,13 +155,8 @@ public boolean shouldRun(String testClass, String methodName) { } public TestFilter or(final TestListResolver another) { - return new TestFilter() { - @Override - public boolean shouldRun(String testClass, String methodName) { - return TestListResolver.this.shouldRun(testClass, methodName) - || another.shouldRun(testClass, methodName); - } - }; + return (testClass, methodName) -> + TestListResolver.this.shouldRun(testClass, methodName) || another.shouldRun(testClass, methodName); } public boolean shouldRun(Class testClass, String methodName) { diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestRequest.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestRequest.java index e5fe6814cf..7cb4ae8c6f 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestRequest.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestRequest.java @@ -19,8 +19,6 @@ package org.apache.maven.surefire.api.testset; import java.io.File; -import java.util.ArrayList; -import java.util.List; /** * Information about the requested test. @@ -28,7 +26,6 @@ * @author Kristian Rosenvold */ public class TestRequest { - private final List suiteXmlFiles; private final File testSourceDirectory; @@ -36,27 +33,12 @@ public class TestRequest { private final int rerunFailingTestsCount; - public TestRequest(List suiteXmlFiles, File testSourceDirectory, TestListResolver requestedTests) { - this(createFiles(suiteXmlFiles), testSourceDirectory, requestedTests, 0); - } - - public TestRequest( - List suiteXmlFiles, File testSourceDirectory, TestListResolver requestedTests, int rerunFailingTestsCount) { - this.suiteXmlFiles = createFiles(suiteXmlFiles); + public TestRequest(File testSourceDirectory, TestListResolver requestedTests, int rerunFailingTestsCount) { this.testSourceDirectory = testSourceDirectory; this.requestedTests = requestedTests; this.rerunFailingTestsCount = rerunFailingTestsCount; } - /** - * Represents suitexmlfiles that define the test-run request - * - * @return A list of java.io.File objects. - */ - public List getSuiteXmlFiles() { - return suiteXmlFiles; - } - /** * Test source directory, normally ${project.build.testSourceDirectory} * @@ -83,17 +65,4 @@ public TestListResolver getTestListResolver() { public int getRerunFailingTestsCount() { return rerunFailingTestsCount; } - - private static List createFiles(List suiteXmlFiles) { - if (suiteXmlFiles != null) { - List files = new ArrayList<>(); - Object element; - for (Object suiteXmlFile : suiteXmlFiles) { - element = suiteXmlFile; - files.add(element instanceof String ? new File((String) element) : (File) element); - } - return files; - } - return null; - } } diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml index c24bb7e360..1e69a7b53e 100644 --- a/surefire-booter/pom.xml +++ b/surefire-booter/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-booter diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java index b736bd7496..255862d6d9 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java @@ -42,7 +42,6 @@ private BooterConstants() {} public static final String RUN_ORDER = "runOrder"; public static final String RUN_ORDER_RANDOM_SEED = "runOrderRandomSeed"; public static final String RUN_STATISTICS_FILE = "runStatisticsFile"; - public static final String TEST_SUITE_XML_FILES = "testSuiteXmlFiles"; public static final String PROVIDER_CONFIGURATION = "providerConfiguration"; public static final String FORKTESTSET = "forkTestSet"; public static final String FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM = "preferTestsFromInStream"; diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java index 8cf0e84bab..b8de5d44dd 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java @@ -94,7 +94,6 @@ public ProviderConfiguration deserialize() { final List includes = properties.getStringList(INCLUDES_PROPERTY_PREFIX); final List specificTests = properties.getStringList(SPECIFIC_TEST_PROPERTY_PREFIX); - final List testSuiteXmlFiles = properties.getStringList(TEST_SUITE_XML_FILES); final File testClassesDirectory = properties.getFileProperty(TEST_CLASSES_DIRECTORY); final String runOrder = properties.getProperty(RUN_ORDER); final Long runOrderRandomSeed = properties.getLongProperty(RUN_ORDER_RANDOM_SEED); @@ -109,8 +108,8 @@ public ProviderConfiguration deserialize() { runOrder, runStatisticsFile == null ? null : new File(runStatisticsFile), runOrderRandomSeed); TestArtifactInfo testNg = new TestArtifactInfo(testNgVersion, testArtifactClassifier); - TestRequest testSuiteDefinition = new TestRequest( - testSuiteXmlFiles, sourceDirectory, new TestListResolver(requestedTest), rerunFailingTestsCount); + TestRequest testSuiteDefinition = + new TestRequest(sourceDirectory, new TestListResolver(requestedTest), rerunFailingTestsCount); ReporterConfiguration reporterConfiguration = new ReporterConfiguration(reportsDirectory, properties.getBooleanProperty(ISTRIMSTACKTRACE)); diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java index 90d2279416..c0121a7f9b 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java @@ -117,11 +117,10 @@ private Object createTestRequest(TestRequest suiteDefinition) { return null; } else { Object resolver = createTestListResolver(suiteDefinition.getTestListResolver()); - Class[] arguments = {List.class, File.class, testListResolver, int.class}; + Class[] arguments = {File.class, testListResolver, int.class}; Constructor constructor = getConstructor(testRequest, arguments); return newInstance( constructor, - suiteDefinition.getSuiteXmlFiles(), suiteDefinition.getTestSourceDirectory(), resolver, suiteDefinition.getRerunFailingTestsCount()); diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java index 9e92e36197..65bc627a6e 100644 --- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java @@ -138,10 +138,8 @@ public void testTestSuiteDefinition() { SurefireReflector surefireReflector = getReflector(); Object foo = getFoo(); - TestRequest testSuiteDefinition = new TestRequest( - asList(new File("file1"), new File("file2")), - new File("TestSOurce"), - new TestListResolver("aUserRequestedTest#aMethodRequested")); + TestRequest testSuiteDefinition = + new TestRequest(new File("TestSOurce"), new TestListResolver("aUserRequestedTest#aMethodRequested"), 0); surefireReflector.setTestSuiteDefinition(foo, testSuiteDefinition); assertTrue(isCalled(foo)); assertNotNull(((Foo) foo).getTestRequest()); @@ -318,20 +316,6 @@ public void testSetSystemExitTimeout() { assertEquals(booterParams.getSystemExitTimeout(), (Integer) 60); } - public void testSetTestSuiteDefinitionAware() { - SurefireReflector reflector = - new SurefireReflector(Thread.currentThread().getContextClassLoader()); - Foo booterParams = (Foo) getFoo(); - TestRequest request = new TestRequest(Collections.emptyList(), null, null); - reflector.setTestSuiteDefinitionAware(booterParams, request); - assertTrue(booterParams.isCalled()); - assertNotNull(booterParams.getTestRequest()); - assertTrue(booterParams.getTestRequest().getSuiteXmlFiles().isEmpty()); - assertNull(booterParams.getTestRequest().getTestSourceDirectory()); - assertNull(booterParams.getTestRequest().getTestListResolver()); - assertEquals(booterParams.getTestRequest().getRerunFailingTestsCount(), 0); - } - public void testSetProviderPropertiesAware() { SurefireReflector reflector = new SurefireReflector(Thread.currentThread().getContextClassLoader()); diff --git a/surefire-extensions-api/pom.xml b/surefire-extensions-api/pom.xml index 01cbbe618c..16a00b0992 100644 --- a/surefire-extensions-api/pom.xml +++ b/surefire-extensions-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-extensions-api diff --git a/surefire-extensions-spi/pom.xml b/surefire-extensions-spi/pom.xml index 2d72e78567..76a151a0df 100644 --- a/surefire-extensions-spi/pom.xml +++ b/surefire-extensions-spi/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-extensions-spi diff --git a/surefire-grouper/pom.xml b/surefire-grouper/pom.xml deleted file mode 100644 index 8bcbbcd5c5..0000000000 --- a/surefire-grouper/pom.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - 4.0.0 - - - org.apache.maven.surefire - surefire - 3.5.5-SNAPSHOT - - - surefire-grouper - - Maven Surefire Test-Grouping Support - Maven Surefire Test-Grouping Support - - - - junit - junit - test - - - org.junit.vintage - junit-vintage-engine - test - - - - - - - org.javacc.plugin - javacc-maven-plugin - 3.0.3 - - - net.java.dev.javacc - javacc - 7.0.13 - - - - - javacc - - javacc - - - - - - org.jacoco - jacoco-maven-plugin - - jacoco.agent - - - - jacoco-agent - - prepare-agent - - - - - - maven-surefire-plugin - - ${jvm.args.tests} ${jacoco.agent} - - - - org.apache.maven.surefire - surefire-shadefire - - 3.5.2 - - - - - maven-jar-plugin - - - - org.apache.maven.surefire.group.parse.GroupMatcherParser - - - - - - - diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java deleted file mode 100644 index e50a328c60..0000000000 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.surefire.group.match; - -import java.util.Collection; - -/** - * AND group matcher - * - */ -public class AndGroupMatcher extends JoinGroupMatcher { - - public AndGroupMatcher(GroupMatcher... matchers) { - for (GroupMatcher matcher : matchers) { - addMatcher(matcher); - } - } - - public AndGroupMatcher(Collection matchers) { - for (GroupMatcher matcher : matchers) { - addMatcher(matcher); - } - } - - @Override - public boolean enabled(Class... cats) { - for (GroupMatcher matcher : getMatchers()) { - boolean result = matcher.enabled(cats); - if (!result) { - return false; - } - } - - return true; - } - - @Override - public boolean enabled(String... cats) { - for (GroupMatcher matcher : getMatchers()) { - boolean result = matcher.enabled(cats); - if (!result) { - return false; - } - } - - return true; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - for (GroupMatcher matcher : getMatchers()) { - if (sb.length() > 0) { - sb.append(" AND "); - } - sb.append(matcher); - } - - return sb.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result; - for (GroupMatcher matcher : getMatchers()) { - result += matcher.hashCode(); - } - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - AndGroupMatcher other = (AndGroupMatcher) obj; - return getMatchers().equals(other.getMatchers()); - } -} diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java deleted file mode 100644 index a5b2caef94..0000000000 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.surefire.group.match; - -/** - * Group Matcher - * - */ -public interface GroupMatcher { - - void loadGroupClasses(ClassLoader cloader); - - boolean enabled(Class... cats); - - boolean enabled(String... cats); -} diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java deleted file mode 100644 index a75933ffd7..0000000000 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.surefire.group.match; - -/** - * Inverse group matcher - * - */ -public class InverseGroupMatcher implements GroupMatcher { - - private final GroupMatcher matcher; - - public InverseGroupMatcher(GroupMatcher matcher) { - this.matcher = matcher; - } - - @Override - public boolean enabled(Class... cats) { - return cats == null || !matcher.enabled(cats); - } - - @Override - public boolean enabled(String... cats) { - return cats == null || !matcher.enabled(cats); - } - - @Override - public String toString() { - return "NOT " + matcher; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (matcher == null ? 0 : matcher.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj == null || getClass() != obj.getClass()) { - return false; - } - InverseGroupMatcher other = (InverseGroupMatcher) obj; - if (matcher == null) { - if (other.matcher != null) { - return false; - } - } else if (!matcher.equals(other.matcher)) { - return false; - } - return true; - } - - @Override - public void loadGroupClasses(ClassLoader cloader) { - matcher.loadGroupClasses(cloader); - } -} diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java deleted file mode 100644 index 4180e0e166..0000000000 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.surefire.group.match; - -import java.util.HashSet; -import java.util.Set; - -/** - * Joins several group matchers - * - */ -public abstract class JoinGroupMatcher implements GroupMatcher { - - Set matchers = new HashSet<>(); - - public final boolean addMatcher(GroupMatcher matcher) { - return matchers.add(matcher); - } - - protected final Set getMatchers() { - return matchers; - } - - @Override - public void loadGroupClasses(ClassLoader cloader) { - for (GroupMatcher matcher : matchers) { - matcher.loadGroupClasses(cloader); - } - } -} diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java deleted file mode 100644 index 92dddbadc3..0000000000 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.surefire.group.match; - -import java.util.Collection; - -/** - * OR group matcher - * - */ -public class OrGroupMatcher extends JoinGroupMatcher { - - public OrGroupMatcher(GroupMatcher... matchers) { - for (GroupMatcher matcher : matchers) { - addMatcher(matcher); - } - } - - public OrGroupMatcher(Collection matchers) { - for (GroupMatcher matcher : matchers) { - addMatcher(matcher); - } - } - - @Override - public boolean enabled(Class... cats) { - for (GroupMatcher matcher : getMatchers()) { - boolean result = matcher.enabled(cats); - if (result) { - return true; - } - } - - return false; - } - - @Override - public boolean enabled(String... cats) { - for (GroupMatcher matcher : getMatchers()) { - boolean result = matcher.enabled(cats); - if (result) { - return true; - } - } - - return false; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - for (GroupMatcher matcher : getMatchers()) { - if (sb.length() > 0) { - sb.append(" OR "); - } - sb.append(matcher); - } - - return sb.toString(); - } - - @Override - public int hashCode() { - final int prime = 37; - int result = 1; - result = prime * result; - for (GroupMatcher matcher : getMatchers()) { - result += matcher.hashCode(); - } - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - AndGroupMatcher other = (AndGroupMatcher) obj; - return getMatchers().equals(other.getMatchers()); - } -} diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java deleted file mode 100644 index 750cbd0662..0000000000 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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.surefire.group.match; - -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -/** - * Single group matcher - * - */ -public class SingleGroupMatcher implements GroupMatcher { - private final String enabled; - private final Pattern pattern; - - private Class enabledClass; - - public SingleGroupMatcher(String enabled) { - this.enabled = enabled.endsWith(".class") ? enabled.substring(0, enabled.length() - 6) : enabled; - Pattern p; - try { - p = Pattern.compile(enabled); - } catch (PatternSyntaxException e) { - p = null; - } - pattern = p; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + enabled.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - SingleGroupMatcher other = (SingleGroupMatcher) obj; - return enabled.equals(other.enabled); - } - - @Override - public String toString() { - return "*" + enabled; - } - - @Override - public boolean enabled(Class... cats) { - if (cats != null) { - for (Class cls : cats) { - if (enabledClass != null && enabledClass.isAssignableFrom(cls)) { - return true; - } - - String name = cls.getName(); - if (name.endsWith(enabled)) { - return true; - } - } - } - - return false; - } - - @Override - public boolean enabled(String... cats) { - for (String cat : cats) { - if (cat == null || cat.trim().isEmpty()) { - continue; - } - - if (cat.equals(enabled)) { - return true; - } - - if (pattern != null && pattern.matcher(cat).matches()) { - return true; - } - } - - return false; - } - - @Override - public void loadGroupClasses(ClassLoader classLoader) { - try { - enabledClass = classLoader.loadClass(enabled); - } catch (ClassNotFoundException e) { - // class is not available at runtime, for instance this would happen in reactor projects - // in which not all modules have the required class on the classpath/module path - System.out.println("[WARNING] Couldn't load group class '" + enabled + "' in Surefire|Failsafe plugin. " - + "The group class is ignored!"); - } - } -} diff --git a/surefire-grouper/src/main/javacc/category-expression.jj b/surefire-grouper/src/main/javacc/category-expression.jj deleted file mode 100644 index 955ed4f1d2..0000000000 --- a/surefire-grouper/src/main/javacc/category-expression.jj +++ /dev/null @@ -1,199 +0,0 @@ -options { - DEBUG_PARSER = false; - DEBUG_LOOKAHEAD = false; - DEBUG_TOKEN_MANAGER = false; - LOOKAHEAD=3; - FORCE_LA_CHECK=true; - STATIC = false; -} - -PARSER_BEGIN(GroupMatcherParser) -package org.apache.maven.surefire.group.parse; - -import org.apache.maven.surefire.group.match.*; -import java.io.*; - -public class GroupMatcherParser -{ - public static void main( String[] args ) - throws Exception - { - BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) ); - while( true ) - { - try - { - System.out.print( "Enter expression: " ); - String expr = reader.readLine(); - GroupMatcherParser parser = new GroupMatcherParser( expr ); - GroupMatcher matcher = parser.parse(); - System.out.println( matcher ); - } - catch ( ParseException e ) - { - e.printStackTrace(); - } - } - } - - public GroupMatcherParser( String expression ) - { - this( (Reader)(new StringReader( expression ) ) ); - } - - private GroupMatcher getMatcher( Op op, GroupMatcher...matchers ) - { - GroupMatcher matcher = null; - if ( Op.AND == op ) - { - matcher = new AndGroupMatcher( matchers ); - } - else - { - matcher = new OrGroupMatcher( matchers ); - } - - return matcher; - } - - public enum Op - { - AND, OR; - } -} - -PARSER_END(GroupMatcherParser) - -SKIP : -{ - " " -| "\t" -| "\r" -| "\n" -} - -TOKEN: -{ - -| -| -| -| -| -| -| -| -| -| -} - -GroupMatcher parse() : -{GroupMatcher matcher = null;} -{ - matcher=expr() - { - return matcher; - } -} - -GroupMatcher expr() : -{ -GroupMatcher matcher=null; -} -{ -( - matcher=igroup() -| matcher=group() -) - {return matcher;} -} - -GroupMatcher igroup() : -{ -GroupMatcher lhs=null; -GroupMatcher rhs=null; -Op op=null; -} -{ - (lhs=value() (op=op() rhs=expr())?) - { - GroupMatcher matcher = lhs; - if ( op != null ) - { - matcher = getMatcher( op, lhs, rhs ); - } - - return matcher; - } -} - -GroupMatcher group() : -{ -boolean inverted=false; -GroupMatcher lhs=null; -GroupMatcher rhs=null; -Op op=null; -} -{ - (not() - { - inverted=true; - } - )? - - lhs=expr() - ( - op=op() - rhs=expr() - )? - - { - GroupMatcher matcher = lhs; - if ( op != null ) - { - matcher = getMatcher( op, lhs, rhs ); - } - - return inverted ? new InverseGroupMatcher( matcher ) : matcher; - } -} - -GroupMatcher value() : -{ -boolean inverted=false; -Token val=null; -} -{ -( not() - {inverted=true;} -)? - val= - { - GroupMatcher m = new SingleGroupMatcher( val.image ); - return inverted ? new InverseGroupMatcher( m ) : m; - } -} - -Op op() : -{Op o=null;} -{ -( - - {o=Op.AND;} -| - {o=Op.OR;} -| - {o=Op.AND;} -| - {o=Op.OR;} -| - {o=Op.OR;} -) - {return o;} -} - -void not() : -{} -{ - | -} diff --git a/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/AndGroupMatcherTest.java b/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/AndGroupMatcherTest.java deleted file mode 100644 index 1ff75d3453..0000000000 --- a/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/AndGroupMatcherTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.surefire.group.match; - -import junit.framework.TestCase; - -/** - * - */ -public class AndGroupMatcherTest extends TestCase { - - public void testDontMatchOneInGroup() { - AndGroupMatcher matcher = new AndGroupMatcher( - new SingleGroupMatcher(SingleGroupMatcher.class.getName()), - new SingleGroupMatcher(InverseGroupMatcher.class.getName())); - - assertFalse(matcher.enabled(InverseGroupMatcher.class, AndGroupMatcher.class)); - } - - public void testMatchBothInGroup() { - AndGroupMatcher matcher = new AndGroupMatcher( - new SingleGroupMatcher(SingleGroupMatcher.class.getName()), - new SingleGroupMatcher(InverseGroupMatcher.class.getName())); - - assertTrue(matcher.enabled(InverseGroupMatcher.class, SingleGroupMatcher.class)); - } - - public void testDontMatchAnyInGroup() { - AndGroupMatcher matcher = new AndGroupMatcher( - new SingleGroupMatcher(SingleGroupMatcher.class.getName()), - new SingleGroupMatcher(InverseGroupMatcher.class.getName())); - - assertFalse(matcher.enabled(OrGroupMatcher.class, AndGroupMatcher.class)); - } -} diff --git a/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/InverseGroupMatcherTest.java b/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/InverseGroupMatcherTest.java deleted file mode 100644 index c60bb2ea81..0000000000 --- a/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/InverseGroupMatcherTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.surefire.group.match; - -import junit.framework.TestCase; - -/** - * - */ -public class InverseGroupMatcherTest extends TestCase { - - public void testInvertSingleMatcher() { - InverseGroupMatcher matcher = - new InverseGroupMatcher(new SingleGroupMatcher(InverseGroupMatcher.class.getName())); - assertFalse(matcher.enabled(InverseGroupMatcher.class)); - } -} diff --git a/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/OrGroupMatcherTest.java b/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/OrGroupMatcherTest.java deleted file mode 100644 index 2e8183a468..0000000000 --- a/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/OrGroupMatcherTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.surefire.group.match; - -import junit.framework.TestCase; - -/** - * - */ -public class OrGroupMatcherTest extends TestCase { - - public void testMatchOneInOredGroup() { - OrGroupMatcher matcher = new OrGroupMatcher( - new SingleGroupMatcher(SingleGroupMatcher.class.getName()), - new SingleGroupMatcher(InverseGroupMatcher.class.getName())); - - assertTrue(matcher.enabled(InverseGroupMatcher.class, AndGroupMatcher.class)); - } - - public void testMatchBothInOredGroup() { - OrGroupMatcher matcher = new OrGroupMatcher( - new SingleGroupMatcher(SingleGroupMatcher.class.getName()), - new SingleGroupMatcher(InverseGroupMatcher.class.getName())); - - assertTrue(matcher.enabled(InverseGroupMatcher.class, SingleGroupMatcher.class)); - } - - public void testMatchNoneInOredGroup() { - OrGroupMatcher matcher = new OrGroupMatcher( - new SingleGroupMatcher(SingleGroupMatcher.class.getName()), - new SingleGroupMatcher(InverseGroupMatcher.class.getName())); - - assertFalse(matcher.enabled(OrGroupMatcher.class, AndGroupMatcher.class)); - } -} diff --git a/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/SingleGroupMatcherTest.java b/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/SingleGroupMatcherTest.java deleted file mode 100644 index 34dcbac9c4..0000000000 --- a/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/SingleGroupMatcherTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.surefire.group.match; - -import junit.framework.TestCase; - -/** - * - */ -public class SingleGroupMatcherTest extends TestCase { - - public void testMatchExactClassName() { - SingleGroupMatcher matcher = new SingleGroupMatcher(SingleGroupMatcher.class.getName()); - assertTrue(matcher.enabled(SingleGroupMatcher.class)); - } - - public void testMatchLoadedClass() { - SingleGroupMatcher matcher = new SingleGroupMatcher(SingleGroupMatcher.class.getName()); - matcher.loadGroupClasses(Thread.currentThread().getContextClassLoader()); - assertTrue(matcher.enabled(SingleGroupMatcher.class)); - } - - public void testMatchUnknownClass() { - SingleGroupMatcher matcher = new SingleGroupMatcher("BadClass"); - matcher.loadGroupClasses(Thread.currentThread().getContextClassLoader()); - assertTrue(matcher.enabled("BadClass")); - } - - public void testMatchClassNameWithoutPackage() { - SingleGroupMatcher matcher = new SingleGroupMatcher(SingleGroupMatcher.class.getSimpleName()); - assertTrue(matcher.enabled(SingleGroupMatcher.class)); - } -} diff --git a/surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java b/surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java deleted file mode 100644 index 248d061a5a..0000000000 --- a/surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.surefire.group.parse; - -import junit.framework.TestCase; -import org.apache.maven.surefire.group.match.AndGroupMatcher; -import org.apache.maven.surefire.group.match.GroupMatcher; -import org.apache.maven.surefire.group.match.InverseGroupMatcher; -import org.apache.maven.surefire.group.match.OrGroupMatcher; -import org.apache.maven.surefire.group.match.SingleGroupMatcher; - -/** - * - */ -public class GroupMatcherParserTest extends TestCase { - - public void testParseSingleClass() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser(GroupMatcherParser.class.getName()).parse(); - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof SingleGroupMatcher); - assertTrue(matcher.enabled(GroupMatcherParser.class)); - } - - public void testParseInvertedSingleClass() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser("NOT " + GroupMatcherParser.class.getName()).parse(); - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof InverseGroupMatcher); - assertFalse(matcher.enabled(GroupMatcherParser.class)); - } - - public void testParseBareANDedPair() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser( - GroupMatcherParser.class.getName() + " AND " + SingleGroupMatcher.class.getName()) - .parse(); - - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof AndGroupMatcher); - assertFalse(matcher.enabled(GroupMatcherParser.class)); - assertTrue(matcher.enabled(GroupMatcherParser.class, SingleGroupMatcher.class)); - } - - public void testParseBareORedPair() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser( - GroupMatcherParser.class.getName() + " OR " + SingleGroupMatcher.class.getName()) - .parse(); - - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof OrGroupMatcher); - assertTrue(matcher.enabled(GroupMatcherParser.class)); - assertTrue(matcher.enabled(GroupMatcherParser.class, SingleGroupMatcher.class)); - } - - public void testBareCommaSeparatedORedPair() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser( - GroupMatcherParser.class.getName() + ", " + SingleGroupMatcher.class.getName()) - .parse(); - - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof OrGroupMatcher); - assertTrue(matcher.enabled(GroupMatcherParser.class)); - assertTrue(matcher.enabled(GroupMatcherParser.class, SingleGroupMatcher.class)); - } - - public void testParseGroupedANDedPair() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser( - "(" + GroupMatcherParser.class.getName() + " AND " + SingleGroupMatcher.class.getName() + ")") - .parse(); - - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof AndGroupMatcher); - assertFalse(matcher.enabled(GroupMatcherParser.class)); - assertTrue(matcher.enabled(GroupMatcherParser.class, SingleGroupMatcher.class)); - } - - public void testParseGroupedORedPair() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser( - "(" + GroupMatcherParser.class.getName() + " OR " + SingleGroupMatcher.class.getName() + ")") - .parse(); - - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof OrGroupMatcher); - assertTrue(matcher.enabled(GroupMatcherParser.class)); - assertTrue(matcher.enabled(GroupMatcherParser.class, SingleGroupMatcher.class)); - } - - public void testParseInvertedGroupedANDedPair() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser("NOT (" + GroupMatcherParser.class.getName() + " AND " - + SingleGroupMatcher.class.getName() + ")") - .parse(); - - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof InverseGroupMatcher); - assertTrue(matcher.enabled(GroupMatcherParser.class)); - assertFalse(matcher.enabled(GroupMatcherParser.class, SingleGroupMatcher.class)); - } - - public void testParseInvertedGroupedORedPair() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser("NOT (" + GroupMatcherParser.class.getName() + " OR " - + SingleGroupMatcher.class.getName() + ")") - .parse(); - - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof InverseGroupMatcher); - assertFalse(matcher.enabled(GroupMatcherParser.class)); - assertFalse(matcher.enabled(GroupMatcherParser.class, SingleGroupMatcher.class)); - } - - public void testSingleMatchWhenDotClassAppended() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser(SingleGroupMatcher.class.getName() + ".class").parse(); - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof SingleGroupMatcher); - assertTrue(matcher.enabled(SingleGroupMatcher.class)); - } - - public void testSingleMatchWithOnlyClassSimpleName() throws ParseException { - GroupMatcher matcher = new GroupMatcherParser(SingleGroupMatcher.class.getSimpleName()).parse(); - assertTrue("Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof SingleGroupMatcher); - assertTrue(matcher.enabled(SingleGroupMatcher.class)); - } -} diff --git a/surefire-its/pom.xml b/surefire-its/pom.xml index 95eef334f9..4b8b264dff 100644 --- a/surefire-its/pom.xml +++ b/surefire-its/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-its @@ -39,6 +39,10 @@ true true true + false + false + false + 5 @@ -46,13 +50,13 @@ org.apache.maven.surefire surefire-report-parser ${project.version} - test + runtime org.apache.maven.surefire surefire-logger-api ${project.version} - test + runtime org.apache.maven.shared @@ -159,6 +163,7 @@ maven-surefire-plugin + 3.5.4 **/*Test.java @@ -172,7 +177,7 @@ org.apache.maven.surefire surefire-shadefire - 3.5.2 + 3.5.4 @@ -207,15 +212,21 @@ maven-failsafe-plugin - 3.5.2 + 3.5.4 + + junit.vintage.execution.parallel.enabled=${junit.vintage.execution.parallel.enabled} + junit.vintage.execution.parallel.classes=${junit.vintage.execution.parallel.classes} + junit.vintage.execution.parallel.methods=${junit.vintage.execution.parallel.methods} + junit.vintage.execution.parallel.pool-size=${junit.vintage.execution.parallel.pool} + ${skipTests} alphabetical ${its.forkCount} ${its.threadCount} false - -server -Xmx64m -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true + -Xmx64m -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true @@ -228,6 +239,7 @@ ${jacoco-it.agent} true + 3600 kill @@ -245,9 +257,13 @@ apache.ci - 0.4C + 1 1 1 + true + true + false + 5 diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java index 9352409548..7ca24498a2 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java @@ -23,7 +23,7 @@ import org.apache.maven.surefire.its.fixture.MavenLauncher; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -39,7 +39,7 @@ * @since 2.19 */ @RunWith(Parameterized.class) -public abstract class AbstractFailFastIT extends SurefireJUnit4IntegrationTestCase { +public abstract class AbstractFailFastIT extends SurefireJUnitIntegrationTestCase { private static final String LEGACY_FORK_NODE = "org.apache.maven.plugin.surefire.extensions.LegacyForkNodeFactory"; private static final String SUREFIRE_FORK_NODE = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractTestCaseIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractTestCaseIT.java index cb88bde13f..2d353a2a70 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractTestCaseIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractTestCaseIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -28,7 +28,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class AbstractTestCaseIT extends SurefireJUnit4IntegrationTestCase { +public class AbstractTestCaseIT extends SurefireJUnitIntegrationTestCase { @Test public void abstractTestCase() { unpack("/default-configuration-abstract").executeTest().verifyErrorFree(1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractTestMultipleMethodPatterns.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractTestMultipleMethodPatterns.java index 28b88414b9..f03221304d 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractTestMultipleMethodPatterns.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractTestMultipleMethodPatterns.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.Settings; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,7 +28,7 @@ import static org.apache.maven.surefire.its.fixture.Configuration.INCLUDES_EXCLUDES_FILE; import static org.apache.maven.surefire.its.fixture.Configuration.INCLUDES_FILE; import static org.apache.maven.surefire.its.fixture.Configuration.TEST; -import static org.apache.maven.surefire.its.fixture.TestFramework.JUNIT47; +import static org.apache.maven.surefire.its.fixture.TestFramework.JUNIT4; import static org.apache.maven.surefire.its.fixture.TestFramework.TestNG; import static org.hamcrest.core.AnyOf.anyOf; import static org.hamcrest.core.Is.is; @@ -37,7 +37,7 @@ /** * Test project using multiple method patterns, including wildcards in class and method names. */ -public abstract class AbstractTestMultipleMethodPatterns extends SurefireJUnit4IntegrationTestCase { +public abstract class AbstractTestMultipleMethodPatterns extends SurefireJUnitIntegrationTestCase { private static final String CSV_DELIMITER_SHORT = ","; private static final String CSV_DELIMITER_LONG = ", "; private static final String NOT_DELIMITER = "!"; @@ -102,7 +102,7 @@ public void simpleNameTest() { @Test public void simpleNameTestAsParallel() { - assumeThat(getSettings().getFramework(), anyOf(is(JUNIT47), is(TestNG))); + assumeThat(getSettings().getFramework(), anyOf(is(JUNIT4), is(TestNG))); prepare("TestTwo") .parallel("classes") .useUnlimitedThreads() @@ -326,7 +326,7 @@ public void shouldMatchMultiplePatterns() { @Test public void shouldMatchMultiplePatternsAsParallel() { - assumeThat(getSettings().getFramework(), anyOf(is(JUNIT47), is(TestNG))); + assumeThat(getSettings().getFramework(), anyOf(is(JUNIT4), is(TestNG))); assumeThat(getSettings().getConfiguration(), is(TEST)); String test = "jiras/surefire745/BasicTest#testSuccessOne+testSuccessTwo" // 2 + ',' + "jiras/**/TestTwo" // 2 @@ -356,7 +356,7 @@ public void shouldMatchMultiplePatternsComplex() { @Test public void shouldMatchMultiplePatternsComplexAsParallel() { - assumeThat(getSettings().getFramework(), anyOf(is(JUNIT47), is(TestNG))); + assumeThat(getSettings().getFramework(), anyOf(is(JUNIT4), is(TestNG))); assumeThat(getSettings().getConfiguration(), is(TEST)); String test = "**/BasicTest#testSuccessOne+testSuccessTwo" // 2 + ',' + "jiras/**/TestTwo" // 2 diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AdditionalClasspathIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AdditionalClasspathIT.java index 27398d6acb..058a5ae6d8 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/AdditionalClasspathIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AdditionalClasspathIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,7 +27,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class AdditionalClasspathIT extends SurefireJUnit4IntegrationTestCase { +public class AdditionalClasspathIT extends SurefireJUnitIntegrationTestCase { @Test public void additionalClasspathElements() { unpack("/additional-classpath").executeTest().verifyErrorFree(2); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java index 920f1da1d6..18d4d5ee48 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java @@ -22,7 +22,7 @@ import org.apache.maven.surefire.its.fixture.IntegrationTestSuiteResults; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -36,7 +36,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class AggregateReportIT extends SurefireJUnit4IntegrationTestCase { +public class AggregateReportIT extends SurefireJUnitIntegrationTestCase { @Test public void aggregateReport() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ArchUnitIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ArchUnitIT.java index f95d3397db..0632600599 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ArchUnitIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ArchUnitIT.java @@ -21,7 +21,7 @@ import javax.xml.transform.Source; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.hamcrest.collection.IsIterableWithSize; import org.junit.Before; @@ -37,7 +37,7 @@ * */ @SuppressWarnings("checkstyle:magicnumber") -public class ArchUnitIT extends SurefireJUnit4IntegrationTestCase { +public class ArchUnitIT extends SurefireJUnitIntegrationTestCase { @Before public void setUp() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLineIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLineIT.java index 044d50c4af..bd94a42ea7 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLineIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLineIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,7 +27,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class ArgLineIT extends SurefireJUnit4IntegrationTestCase { +public class ArgLineIT extends SurefireJUnitIntegrationTestCase { @Test public void argLine() { unpack("/argLine-parameter").executeTest().verifyErrorFree(1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLinePropertiesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLinePropertiesIT.java index 02deda8612..e97331afb4 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLinePropertiesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLinePropertiesIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,7 +27,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class ArgLinePropertiesIT extends SurefireJUnit4IntegrationTestCase { +public class ArgLinePropertiesIT extends SurefireJUnitIntegrationTestCase { @Test public void argLine() { unpack("/argLine-properties").executeTest().verifyErrorFree(4); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AssumptionFailureReportIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AssumptionFailureReportIT.java index c0e665543a..07bf426405 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/AssumptionFailureReportIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AssumptionFailureReportIT.java @@ -19,14 +19,14 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; /** * */ -public class AssumptionFailureReportIT extends SurefireJUnit4IntegrationTestCase { +public class AssumptionFailureReportIT extends SurefireJUnitIntegrationTestCase { @Test public void testWriteSkippedMessageToReport() { final OutputValidator outputValidator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java index 76563b5ce3..33a4e5d206 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -32,7 +32,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class CheckSingleTestIT extends SurefireJUnit4IntegrationTestCase { +public class CheckSingleTestIT extends SurefireJUnitIntegrationTestCase { @Test public void singleTest() { unpack().setTestToRun("BasicTest").executeTest().verifyErrorFree(1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsForkCountIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsForkCountIT.java index 4f781755f4..8041a8c6c3 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsForkCountIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsForkCountIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,7 +28,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class CheckTestFailIfNoTestsForkCountIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestFailIfNoTestsForkCountIT extends SurefireJUnitIntegrationTestCase { @Test public void failIfNoTestsForkAlways() { unpack().forkAlways().failIfNoTests(true).maven().withFailure().executeTest(); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsIT.java index fd6809d243..dea09a0453 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -32,7 +32,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class CheckTestFailIfNoTestsIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestFailIfNoTestsIT extends SurefireJUnitIntegrationTestCase { private SurefireLauncher unpack() { return unpack("/default-configuration-noTests"); } @@ -54,7 +54,7 @@ public void dontFailIfNoTests() { public void jUnit48CategoriesFailWhenNoTests() { unpack().failIfNoTests(false) .activateProfile("junit47") - .setJUnitVersion("4.8.1") + .setJUnitVersion("4.12") .executeTest() .verifyErrorFreeLog(); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java index 40ff3fcce8..fb3f358809 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java @@ -18,13 +18,13 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** */ @SuppressWarnings("checkstyle:magicnumber") -public class CheckTestNg740ParallelIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestNg740ParallelIT extends SurefireJUnitIntegrationTestCase { @Test public void withTestNG740AndParallelSet() { unpack("testng-740-parallel").executeTest().assertTestSuiteResults(2, 0, 0, 0); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java index c58e7af6d7..ba837ab739 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,14 +27,13 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class CheckTestNgBeforeMethodFailureIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestNgBeforeMethodFailureIT extends SurefireJUnitIntegrationTestCase { @Test public void testNgBeforeMethodFailure() { unpack("/testng-beforeMethodFailure") .maven() - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .withFailure() .executeTest() .assertTestSuiteResults(2, 0, 1, 1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java index 355b3c26c2..7925acd613 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,12 +27,11 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class CheckTestNgBeforeMethodIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestNgBeforeMethodIT extends SurefireJUnitIntegrationTestCase { @Test public void testNgBeforeMethod() { unpack("/testng-beforeMethod") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .executeTest() .verifyErrorFree(1); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomObjectFactoryIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomObjectFactoryIT.java index c018e05769..fa161f0c0b 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomObjectFactoryIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomObjectFactoryIT.java @@ -20,7 +20,7 @@ import java.io.File; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -31,7 +31,7 @@ * * @author Orien Madgwick */ -public class CheckTestNgCustomObjectFactoryIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestNgCustomObjectFactoryIT extends SurefireJUnitIntegrationTestCase { @Test public void testTestNgListenerReporter() throws Exception { File baseDir = unpack().executeTest() diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomTestRunnerFactoryIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomTestRunnerFactoryIT.java deleted file mode 100644 index 1284b14261..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomTestRunnerFactoryIT.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.surefire.its; - -import java.io.File; -import java.io.IOException; - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Test TestNG with custom test runner factory defined. - * - * @author Orien Madgwick - */ -public class CheckTestNgCustomTestRunnerFactoryIT extends SurefireJUnit4IntegrationTestCase { - @Test - public void testTestNgListenerReporter() throws IOException { - File baseDir = unpack().executeTest() - .verifyErrorFreeLog() - .assertTestSuiteResults(1, 0, 0, 0) - .getBaseDir(); - - baseDir = baseDir.getCanonicalFile(); - - File targetDir = new File(baseDir, "target"); - assertThat(targetDir).isDirectory(); - assertThat(new File(targetDir, "testrunnerfactory-output.txt")).isFile(); - } - - private SurefireLauncher unpack() { - return unpack("/testng-testRunnerFactory"); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java index 0beebe029a..1ae94bee29 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java @@ -22,7 +22,7 @@ import java.io.FilenameFilter; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static java.util.Objects.requireNonNull; @@ -35,13 +35,12 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class CheckTestNgExecuteErrorIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestNgExecuteErrorIT extends SurefireJUnitIntegrationTestCase { @Test public void executionError() { OutputValidator outputValidator = unpack("/testng-execute-error") .maven() - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .showErrorStackTraces() .withFailure() .executeTest() diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java index 1ac917ba96..af8b7e7975 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,12 +27,11 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class CheckTestNgGroupThreadParallelIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestNgGroupThreadParallelIT extends SurefireJUnitIntegrationTestCase { @Test public void testNgGroupThreadParallel() { unpack("testng-group-thread-parallel") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .executeTest() .verifyErrorFree(3); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgJdk14IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgJdk14IT.java deleted file mode 100644 index 8604e82aa5..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgJdk14IT.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.surefire.its; - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.junit.Test; - -/** - * Test TestNG running in the JDK 1.4 JavaDoc style - * - * @author Dan Fabulich - */ -public class CheckTestNgJdk14IT extends SurefireJUnit4IntegrationTestCase { - - @Test - public void testNgJdk14() { - unpack("/testng-jdk14").executeTest().verifyErrorFree(1); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java index 47ee26294e..5562283b8f 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java @@ -21,13 +21,12 @@ import java.util.Arrays; import java.util.Collection; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaMaxVersion; import static org.junit.runners.Parameterized.Parameter; import static org.junit.runners.Parameterized.Parameters; @@ -39,36 +38,10 @@ */ @RunWith(Parameterized.class) @SuppressWarnings({"checkstyle:magicnumber", "checkstyle:linelength"}) -public class CheckTestNgListenerReporterIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestNgListenerReporterIT extends SurefireJUnitIntegrationTestCase { @Parameters(name = "{index}: TestNG {0}") public static Collection data() { return Arrays.asList(new Object[][] { - {"5.6", "jdk15"}, // First TestNG version with reporter support - {"5.7", "jdk15"}, // default version from pom of the test case - {"5.10", "jdk15"}, - {"5.13", null}, // "reporterslist" param becomes String instead of List - // "listener" param becomes String instead of List - - // configure(Map) in 5.14.1 and 5.14.2 is transforming List into a String with a space as separator. - // Then configure(CommandLineArgs) splits this String into a List with , or ; as separator => fail. - // If we used configure(CommandLineArgs), we would not have the problem with white spaces. - // { "5.14.1", null, "1.5" }, // "listener" param becomes List instead of String - // Fails: Issue with 5.14.1 and 5.14.2 => join with , split with "," - // TODO will work with "configure(CommandLineArgs)" - // { "5.14.2", null, "1.5" }, // ReporterConfig is not available - - // { "5.14.3", null, "1.5" }, // TestNG uses "reporter" instead of "reporterslist" - // Both String or List are possible for "listener" - // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI - // ClassNotFoundException: com.beust.jcommander.ParameterException - - // { "5.14.4", null, "1.5" }, { "5.14.5", null, "1.5" }, // Fails: not able to test due to system dependency - // org.testng:guice missed the path and use to break CI - // ClassNotFoundException: com.beust.jcommander.ParameterException - - {"5.14.6", null}, // Usage of org.testng:guice removed - {"5.14.9", null}, // Latest 5.14.x TestNG version - {"6.0", null}, {"6.14.3", null}, {"7.0.0", null} // Currently latest TestNG version }); @@ -84,19 +57,10 @@ public static Collection data() { @Test public void testNgListenerReporter() { - if (version.equals("5.13")) { - // only 5.13 uses Google Guice, reflection which breaks jdk 16+ - // module java.base does not "opens java.lang" to unnamed module @209c0b14 - assumeJavaMaxVersion(15); - } final SurefireLauncher launcher = unpack("testng-listener-reporter", "_" + version).sysProp("testNgVersion", version); - if (classifier != null) { - launcher.sysProp("testNgClassifier", "jdk15"); - } - launcher.executeTest() .assertTestSuiteResults(1, 0, 0, 0) .getTargetFile("resultlistener-output.txt") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenersIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenersIT.java deleted file mode 100644 index 8e570a704a..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenersIT.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.surefire.its; - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.junit.Test; - -/** - * Test annotation-based TestNG listener - */ -public class CheckTestNgListenersIT extends SurefireJUnit4IntegrationTestCase { - @Test - public void testNgListenerReporter() { - unpack("testng-listeners").mavenTestFailureIgnore(true).executeTest().assertTestSuiteResults(1, 0, 1, 0); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java index ae3b434109..fa746dc500 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,12 +26,11 @@ * * @author Dan Fabulich */ -public class CheckTestNgPathWithSpacesIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestNgPathWithSpacesIT extends SurefireJUnitIntegrationTestCase { @Test public void testWithSpaces() { unpack("testng-path with spaces") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .executeTest() .verifyErrorFree(1); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java index 3b364e3068..3c21c31eab 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.hamcrest.Matchers.containsString; @@ -29,12 +29,11 @@ * * @author Dan Fabulich */ -public class CheckTestNgReportTestIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestNgReportTestIT extends SurefireJUnitIntegrationTestCase { @Test public void testNgReport() { unpack("/testng-simple") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .addSurefireReportGoal() .executeCurrentGoals() .verifyErrorFree(3) @@ -45,8 +44,7 @@ public void testNgReport() { @Test public void shouldNotBeVerbose() throws Exception { unpack("/testng-simple") - .sysProp("testNgVersion", "5.10") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .executeTest() .verifyErrorFreeLog() .assertThatLogLine(containsString("[Parser] Running:"), is(0)); @@ -55,8 +53,7 @@ public void shouldNotBeVerbose() throws Exception { @Test public void shouldBeVerbose() throws Exception { unpack("/testng-simple") - .sysProp("testNgVersion", "5.10") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .sysProp("surefire.testng.verbose", "10") .executeTest() .verifyErrorFreeLog() diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java deleted file mode 100644 index 8e3cf116e7..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.surefire.its; - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.junit.Test; - -/** - * Use -Dtest to run a single TestNG test, overriding the suite XML parameter. - * - * @author Dan Fabulich - */ -public class CheckTestNgSuiteXmlSingleIT extends SurefireJUnit4IntegrationTestCase { - @Test - public void testNgSuite() { - unpack("/testng-twoTestCaseSuite") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") - .setTestToRun("TestNGTestTwo") - .executeTest() - .verifyErrorFree(1); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java index f008e7ee15..04db47fcf2 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java @@ -23,7 +23,7 @@ import org.apache.maven.plugins.surefire.report.ReportTestSuite; import org.apache.maven.surefire.its.fixture.HelperAssertions; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -38,7 +38,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class CheckTestNgVersionsIT extends SurefireJUnit4IntegrationTestCase { +public class CheckTestNgVersionsIT extends SurefireJUnitIntegrationTestCase { // TestNG 7.6 and above needs JDK11 @Test @@ -53,12 +53,22 @@ public void test6143() { @Test public void test69136() { - runTestNgTestWithRunOrder("6.9.13.6"); + unpack("testng-simple") + .sysProp("testNgVersion", "6.9.13.6") + .maven() + .withFailure() + .executeTest() + .verifyTextInLog("TestNG support requires version 6.14.3 or above"); } @Test public void test6821() { - runTestNgTestWithRunOrder("6.8.21"); + unpack("testng-simple") + .sysProp("testNgVersion", "6.8.21") + .maven() + .withFailure() + .executeTest() + .verifyTextInLog("TestNG support requires version 6.14.3 or above"); } private void runTestNgTestWithRunOrder(String version) { @@ -76,10 +86,6 @@ private void runTestNgTest(String version, String classifier) { private void runTestNgTest(String version, String classifier, boolean validateRunOrder) { final SurefireLauncher launcher = unpack("testng-simple").sysProp("testNgVersion", version); - if (classifier != null) { - launcher.sysProp("testNgClassifier", classifier); - } - final OutputValidator outputValidator = launcher.executeTest(); outputValidator.assertTestSuiteResults(3, 0, 0, 0); @@ -91,7 +97,7 @@ private void runTestNgTest(String version, String classifier, boolean validateRu assertEquals(3, report.size()); assertTrue( - "TestNGSuiteTestC was executed first", + "TestNGSuiteTestC was not executed first", getTestClass(report, 0).endsWith("TestNGSuiteTestC")); assertTrue( diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ClassPathOrderIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClassPathOrderIT.java index e4bbb071d0..1e17badbf5 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ClassPathOrderIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClassPathOrderIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,7 +27,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class ClassPathOrderIT extends SurefireJUnit4IntegrationTestCase { +public class ClassPathOrderIT extends SurefireJUnitIntegrationTestCase { @Test public void classPathOrder() { unpack("/classpath-order").executeTest().verifyErrorFree(2); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathFilteringIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathFilteringIT.java index 8d7a7fa477..6a511d8e80 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathFilteringIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathFilteringIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author pgier */ -public class ClasspathFilteringIT extends SurefireJUnit4IntegrationTestCase { +public class ClasspathFilteringIT extends SurefireJUnitIntegrationTestCase { @Test public void additionalClasspath() { unpack("classpath-filtering").debugLogging().executeTest().verifyErrorFree(1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathScopeFilteringIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathScopeFilteringIT.java index 0955df91d1..77c6ea15e9 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathScopeFilteringIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathScopeFilteringIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,7 +27,7 @@ * @author pgier * @author Kristian Rosenvold */ -public class ClasspathScopeFilteringIT extends SurefireJUnit4IntegrationTestCase { +public class ClasspathScopeFilteringIT extends SurefireJUnitIntegrationTestCase { @Test public void additionalClasspath() { unpack("classpath-scope-filtering").executeTest().verifyErrorFree(1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java index e9e3682400..536831e5b3 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -40,7 +40,7 @@ * @author Kristian Rosenvold */ @RunWith(Parameterized.class) -public class ConsoleOutputIT extends SurefireJUnit4IntegrationTestCase { +public class ConsoleOutputIT extends SurefireJUnitIntegrationTestCase { private static final String LEGACY_FORK_NODE = "org.apache.maven.plugin.surefire.extensions.LegacyForkNodeFactory"; private static final String SUREFIRE_FORK_NODE = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java index 05faaa26f6..bf40dbc0dc 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java @@ -18,13 +18,13 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * @author Kristian Rosenvold */ -public class CrashDetectionIT extends SurefireJUnit4IntegrationTestCase { +public class CrashDetectionIT extends SurefireJUnitIntegrationTestCase { @Test public void crashInFork() { unpack("crash-detection").maven().withFailure().executeTest(); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CucumberIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CucumberIT.java index 5098d88130..1253352450 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CucumberIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CucumberIT.java @@ -21,7 +21,7 @@ import javax.xml.transform.Source; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.hamcrest.collection.IsIterableWithSize; import org.junit.Before; @@ -37,7 +37,7 @@ * */ @SuppressWarnings("checkstyle:magicnumber") -public class CucumberIT extends SurefireJUnit4IntegrationTestCase { +public class CucumberIT extends SurefireJUnitIntegrationTestCase { @Before public void setUp() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/DefaultConfigurationIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/DefaultConfigurationIT.java index 2c5c2282bb..9bba82260c 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/DefaultConfigurationIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/DefaultConfigurationIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Dan Fabulich */ -public class DefaultConfigurationIT extends SurefireJUnit4IntegrationTestCase { +public class DefaultConfigurationIT extends SurefireJUnitIntegrationTestCase { @Test public void defaultConfiguration() { executeErrorFreeTest("default-configuration", 1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariableIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariableIT.java index 3bb96a9c8c..c24d031255 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariableIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariableIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Dan Fabulich */ -public class EnvironmentVariableIT extends SurefireJUnit4IntegrationTestCase { +public class EnvironmentVariableIT extends SurefireJUnitIntegrationTestCase { @Test public void environmentVariable() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariablesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariablesIT.java index d4ecc8ce64..3371025046 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariablesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariablesIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -28,7 +28,7 @@ * @author Kristian Rosenvold * @author Christophe Deneux */ -public class EnvironmentVariablesIT extends SurefireJUnit4IntegrationTestCase { +public class EnvironmentVariablesIT extends SurefireJUnitIntegrationTestCase { @Test public void testWhenUseSystemClassLoader() { unpack("/environment-variables") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java index ae0b89fb22..f4429794d5 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java @@ -48,19 +48,12 @@ public static Iterable data() { // skipped // pipes args.add(new Object[] {"junit4-oneFork-ff1", "junit4", props(1, 1, true), 5, 0, 1, 4, true}); - args.add(new Object[] {"junit47-oneFork-ff1", "junit47", props(1, 1, true), 5, 0, 1, 4, true}); args.add(new Object[] {"junit4-oneFork-ff2", "junit4", props(1, 2, true), 5, 0, 2, 3, true}); - args.add(new Object[] {"junit47-oneFork-ff2", "junit47", props(1, 2, true), 5, 0, 2, 3, true}); args.add(new Object[] {"junit4-twoForks-ff1", "junit4", props(2, 1, true), 5, 0, 2, 3, true}); - args.add(new Object[] {"junit47-twoForks-ff1", "junit47", props(2, 1, true), 5, 0, 2, 3, true}); args.add(new Object[] {"junit4-twoForks-ff2", "junit4", props(2, 2, true), 5, 0, 2, 2, true}); args.add(new Object[] {"junit4-twoForks-ff2-tcp", "junit4", props(2, 2, true), 5, 0, 2, 2, false}); - args.add(new Object[] {"junit47-twoForks-ff2", "junit47", props(2, 2, true), 5, 0, 2, 2, true}); args.add(new Object[] {"junit4-oneFork-ff3", "junit4", props(1, 3, true), 5, 0, 2, 0, true}); - args.add(new Object[] {"junit47-oneFork-ff3", "junit47", props(1, 3, true), 5, 0, 2, 0, true}); args.add(new Object[] {"junit4-twoForks-ff3", "junit4", props(2, 3, true), 5, 0, 2, 0, true}); - args.add(new Object[] {"junit47-twoForks-ff3", "junit47", props(2, 3, true), 5, 0, 2, 0, true}); - args.add(new Object[] {"junit47-twoForks-ff3-tcp", "junit47", props(2, 3, true), 5, 0, 2, 0, false}); return args; } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java index 65955bf8ae..ae9f512556 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -29,7 +29,7 @@ * * @author Kristian Rosenvold */ -public class ForkConsoleOutputIT extends SurefireJUnit4IntegrationTestCase { +public class ForkConsoleOutputIT extends SurefireJUnitIntegrationTestCase { @Test public void printSummaryTrueWithRedirect() { unpack().setForkJvm() diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java index 1f0770f095..8f34f93b23 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -28,7 +28,7 @@ * * @author Kristian Rosenvold */ -public class ForkConsoleOutputWithErrorsIT extends SurefireJUnit4IntegrationTestCase { +public class ForkConsoleOutputWithErrorsIT extends SurefireJUnitIntegrationTestCase { @Test public void xmlFileContainsConsoleOutput() { unpack("/fork-consoleOutputWithErrors") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountIT.java index 5bd6e287b7..fec684b2d0 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountIT.java @@ -23,7 +23,7 @@ import java.util.Set; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.BeforeClass; @@ -38,7 +38,7 @@ * * @author Dan Fabulich */ -public class ForkCountIT extends SurefireJUnit4IntegrationTestCase { +public class ForkCountIT extends SurefireJUnitIntegrationTestCase { private OutputValidator outputValidator; diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountMultiModuleIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountMultiModuleIT.java index eeb4492257..350302193f 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountMultiModuleIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountMultiModuleIT.java @@ -26,7 +26,7 @@ import org.apache.maven.surefire.its.fixture.HelperAssertions; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -39,7 +39,7 @@ * * @author Andreas Gudian */ -public class ForkCountMultiModuleIT extends SurefireJUnit4IntegrationTestCase { +public class ForkCountMultiModuleIT extends SurefireJUnitIntegrationTestCase { @Test public void testForkCountOneNoReuse() { List pids = doTest(unpack(getProject()).forkCount(1).reuseForks(false)); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java index 350bbc2db0..72a0e00216 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,7 +28,7 @@ *
* Based on {@link IncludesExcludesIT}. */ -public class IncludesExcludesFromFileIT extends SurefireJUnit4IntegrationTestCase { +public class IncludesExcludesFromFileIT extends SurefireJUnitIntegrationTestCase { private SurefireLauncher unpack() { return unpack("/includes-excludes-from-file"); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileJunit5IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileJunit5IT.java new file mode 100644 index 0000000000..cc50cb3e86 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileJunit5IT.java @@ -0,0 +1,82 @@ +/* + * 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.surefire.its; + +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +/** + * Test include/exclude from files. + *
+ * Based on {@link IncludesExcludesIT}. + */ +public class IncludesExcludesFromFileJunit5IT extends SurefireJUnitIntegrationTestCase { + private SurefireLauncher unpack() { + return unpack("/includes-excludes-from-file-junit-5"); + } + + @Test + public void testSimple() { + testWithProfile("simple"); + } + + @Test + public void testSimpleMixed() { + testWithProfile("simple-mixed"); + } + + @Test + public void testRegex() { + testWithProfile("regex"); + } + + @Test + public void testPath() { + testWithProfile("path"); + } + + @Test + public void testMissingExcludes() { + expectBuildFailure("missing-excludes-file", "Failed to load list from file", "no-such-excludes-file"); + } + + @Test + public void testMissingIncludes() { + expectBuildFailure("missing-includes-file", "Failed to load list from file", "no-such-includes-file"); + } + + private void testWithProfile(String profile) { + final OutputValidator outputValidator = + unpack().activateProfile(profile).executeTest().verifyErrorFree(2); + + outputValidator.getTargetFile("testTouchFile.txt").assertFileExists(); + outputValidator.getTargetFile("defaultTestTouchFile.txt").assertFileExists(); + } + + private void expectBuildFailure(final String profile, final String... messages) { + final OutputValidator outputValidator = + unpack().activateProfile(profile).maven().withFailure().executeTest(); + + for (String message : messages) { + outputValidator.verifyTextInLog(message); + } + } +} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java index dccc81bce7..a5ca8f6391 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,7 +28,7 @@ * * @author Benjamin Bentmann */ -public class IncludesExcludesIT extends SurefireJUnit4IntegrationTestCase { +public class IncludesExcludesIT extends SurefireJUnitIntegrationTestCase { private SurefireLauncher unpack() { return unpack("/includes-excludes"); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesJunit5IT.java similarity index 51% rename from surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java rename to surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesJunit5IT.java index 423a1e7ba6..899f8e6947 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesJunit5IT.java @@ -18,32 +18,43 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; /** - * Test simple TestNG suite XML file + * Test include/exclude patterns. * - * @author Dan Fabulich + * @author Benjamin Bentmann */ -public class CheckTestNgSuiteXmlIT extends SurefireJUnit4IntegrationTestCase { +public class IncludesExcludesJunit5IT extends SurefireJUnitIntegrationTestCase { + private SurefireLauncher unpack() { + return unpack("/includes-excludes-junit-5"); + } + + /** + * Test surefire inclusions/exclusions + */ @Test - public void suiteXml() { - unpack().executeTest().assertTestSuiteResults(2, 0, 0, 0); + public void testIncludesExcludes() { + testWithProfile("simple"); } @Test - public void suiteXmlForkAlways() { - unpack().forkAlways().executeTest().verifyTextInLog("Tests run: 2, Failures: 0, Errors: 0, Skipped: 0"); + public void testRegexIncludesExcludes() { + testWithProfile("regex"); } @Test - public void suiteXmlForkCountTwoReuse() { - unpack().forkCount(2).reuseForks(true).executeTest().assertTestSuiteResults(2, 0, 0, 0); + public void testPathBasedIncludesExcludes() { + testWithProfile("path"); } - private SurefireLauncher unpack() { - return unpack("testng-suite-xml").sysProp("testNgVersion", "5.7").sysProp("testNgClassifier", "jdk15"); + private void testWithProfile(String profile) { + final OutputValidator outputValidator = + unpack().activateProfile(profile).executeTest().verifyErrorFree(2); + outputValidator.getTargetFile("testTouchFile.txt").assertFileExists(); + outputValidator.getTargetFile("defaultTestTouchFile.txt").assertFileExists(); } } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit44HamcrestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit44HamcrestIT.java deleted file mode 100644 index 5fda920a5e..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit44HamcrestIT.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.surefire.its; - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.junit.Test; - -/** - * Test project using JUnit4.4 (including Hamcrest extensions) - * - * @author Dan Fabulich - */ -public class JUnit44HamcrestIT extends SurefireJUnit4IntegrationTestCase { - @Test - public void testJUnit44Hamcrest() { - executeErrorFreeTest("junit44-hamcrest", 1); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java index 681fa00803..f30dc9b579 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.hamcrest.CoreMatchers.anyOf; @@ -33,7 +33,7 @@ * * @author Kristian Rosenvold */ -public class JUnit47ConcurrencyIT extends SurefireJUnit4IntegrationTestCase { +public class JUnit47ConcurrencyIT extends SurefireJUnitIntegrationTestCase { @Test public void test47() throws Exception { OutputValidator validator = unpack("junit47-concurrency").executeTest().verifyErrorFree(4); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java index 54b5fd22f8..dfebb15742 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java @@ -21,8 +21,9 @@ import java.util.Iterator; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Ignore; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -34,7 +35,8 @@ * @since 2.16 */ @SuppressWarnings("checkstyle:magicnumber") -public class JUnit47ParallelIT extends SurefireJUnit4IntegrationTestCase { +@Ignore +public class JUnit47ParallelIT extends SurefireJUnitIntegrationTestCase { @Test public void unknownThreadCountSuites() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java index 3c5d5ffb3a..e97cfb574c 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,7 +28,7 @@ * @author Tibor Digana (tibor17) * @since 2.19 */ -public class JUnit47ParallelNotThreadSafeIT extends SurefireJUnit4IntegrationTestCase { +public class JUnit47ParallelNotThreadSafeIT extends SurefireJUnitIntegrationTestCase { private SurefireLauncher unpack() { return unpack("junit47-parallel-nts"); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java index 6e7b5e30f0..e3f4654c65 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java @@ -20,7 +20,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -30,7 +30,7 @@ /** * */ -public class JUnit47RedirectOutputIT extends SurefireJUnit4IntegrationTestCase { +public class JUnit47RedirectOutputIT extends SurefireJUnitIntegrationTestCase { @Test public void testPrintSummaryTrueWithRedirect() { final OutputValidator clean = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java index a893c35873..2887eefa44 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; import org.junit.runner.RunWith; @@ -41,7 +41,7 @@ */ @RunWith(Parameterized.class) @SuppressWarnings("checkstyle:magicnumber") -public class JUnit47RerunFailingTestWithCucumberIT extends SurefireJUnit4IntegrationTestCase { +public class JUnit47RerunFailingTestWithCucumberIT extends SurefireJUnitIntegrationTestCase { private static final String LEGACY_FORK_NODE = "org.apache.maven.plugin.surefire.extensions.LegacyForkNodeFactory"; private static final String SUREFIRE_FORK_NODE = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47StaticInnerClassTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47StaticInnerClassTestsIT.java index fef7e21298..da3226f2e7 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47StaticInnerClassTestsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47StaticInnerClassTestsIT.java @@ -18,13 +18,13 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * */ -public class JUnit47StaticInnerClassTestsIT extends SurefireJUnit4IntegrationTestCase { +public class JUnit47StaticInnerClassTestsIT extends SurefireJUnitIntegrationTestCase { @Test public void testStaticInnerClassTests() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47WithCucumberIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47WithCucumberIT.java index cee97fffe7..00f0b7fb75 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47WithCucumberIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47WithCucumberIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -30,7 +30,7 @@ * @author agudian */ @SuppressWarnings("checkstyle:magicnumber") -public class JUnit47WithCucumberIT extends SurefireJUnit4IntegrationTestCase { +public class JUnit47WithCucumberIT extends SurefireJUnitIntegrationTestCase { @Test public void testWithoutParallel() { doTest("none"); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java index eb7b55c48a..fd9b6252e0 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,7 +28,7 @@ * @author Todd Lipcon * @author Kristian Rosenvold */ -public class JUnit48TestCategoriesIT extends SurefireJUnit4IntegrationTestCase { +public class JUnit48TestCategoriesIT extends SurefireJUnitIntegrationTestCase { @Test public void testCategoriesAB() { runAB(unpacked()); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitDepIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitDepIT.java deleted file mode 100644 index 23cc29e3c1..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitDepIT.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.surefire.its; - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.junit.Test; - -/** - * Test project using JUnit4.4 -dep. junit-dep includes only junit.* classes, and depends explicitly on hamcrest-core - * - * @author Dan Fabulich - */ -public class JUnitDepIT extends SurefireJUnit4IntegrationTestCase { - public SurefireLauncher unpack() { - return unpack("/junit44-dep"); - } - - @Test - public void testJUnit44Dep() { - unpack().debugLogging() - .sysProp("junit-dep.version", "4.4") - .executeTest() - .verifyErrorFree(1) - .verifyTextInLog("surefire-junit4"); // Ahem. Will match on the 4.7 provider too - } - - @Test - public void testJUnit44DepWithSneaky381() { - unpack().debugLogging() - .sysProp("junit-dep.version", "4.4") - .activateProfile("provided381") - .executeTest() - .verifyErrorFree(1); - } - - @Test - public void testJUnit47Dep() { - unpack().debugLogging() - .sysProp("junit-dep.version", "4.7") - .executeTest() - .verifyErrorFree(1) - .verifyTextInLog("surefire-junit47"); - } - - @Test - public void testJUnit48Dep() { - unpack().debugLogging() - .sysProp("junit-dep.version", "4.8") - .executeTest() - .verifyErrorFree(1) - .verifyTextInLog("surefire-junit47"); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4ForkAlwaysStaticInitPollutionIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitForkAlwaysStaticInitPollutionIT.java similarity index 86% rename from surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4ForkAlwaysStaticInitPollutionIT.java rename to surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitForkAlwaysStaticInitPollutionIT.java index f5382f262e..4fd79eebd8 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4ForkAlwaysStaticInitPollutionIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitForkAlwaysStaticInitPollutionIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Dan Fabulich */ -public class JUnit4ForkAlwaysStaticInitPollutionIT extends SurefireJUnit4IntegrationTestCase { +public class JUnitForkAlwaysStaticInitPollutionIT extends SurefireJUnitIntegrationTestCase { @Test public void testJunit4Ignore() { executeErrorFreeTest("junit4-forkAlways-staticInit", 2); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4IgnoreIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitIgnoreIT.java similarity index 78% rename from surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4IgnoreIT.java rename to surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitIgnoreIT.java index a880f64a63..f602f7f4ae 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4IgnoreIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitIgnoreIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -27,20 +27,19 @@ * * @author Dan Fabulich */ -public class JUnit4IgnoreIT extends SurefireJUnit4IntegrationTestCase { +public class JUnitIgnoreIT extends SurefireJUnitIntegrationTestCase { @Test public void testJunit4Ignore() { - // Todo: Support assumption failure == ignore for junit4 - unpack().executeTest().verifyErrorFreeLog().assertTestSuiteResults(7, 0, 0, 6); + unpack().executeTest().verifyErrorFreeLog().assertTestSuiteResults(8, 0, 0, 7); } @Test - public void testJunit47ParallelIgnore() { - unpack().setJUnitVersion("4.8.1") + public void testJunit4ParallelIgnore() { + unpack().setJUnitVersion("4.12") .parallelClasses() .executeTest() .verifyErrorFreeLog() - .assertTestSuiteResults(7, 0, 0, 7); + .assertTestSuiteResults(8, 0, 0, 7); } private SurefireLauncher unpack() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java index 8f6b7b366b..ac290cdeda 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java @@ -23,7 +23,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -47,7 +47,7 @@ */ @RunWith(Parameterized.class) @SuppressWarnings("checkstyle:magicnumber") -public class JUnitPlatformEnginesIT extends SurefireJUnit4IntegrationTestCase { +public class JUnitPlatformEnginesIT extends SurefireJUnitIntegrationTestCase { // This must correspond to the Surefire version uses for testing private static final String XML_TESTSUITE_FRAGMENT = "Qingzhou Luo */ -public class JUnit4RerunFailingTestsIT extends SurefireJUnit4IntegrationTestCase { +public class JUnitRerunFailingTestsIT extends SurefireJUnitIntegrationTestCase { private static final String VERSION = "4.13.2"; private SurefireLauncher unpack() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4RunListenerIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitRunListenerIT.java similarity index 80% rename from surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4RunListenerIT.java rename to surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitRunListenerIT.java index 268402aa0f..fe4d647bd4 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4RunListenerIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitRunListenerIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,17 +28,15 @@ * * @author Matthew Gilliard */ -public class JUnit4RunListenerIT extends SurefireJUnit4IntegrationTestCase { +public class JUnitRunListenerIT extends SurefireJUnitIntegrationTestCase { private SurefireLauncher unpack() { return unpack("/junit4-runlistener"); } @Test public void testJUnit4RunListener() { - final OutputValidator outputValidator = unpack().addGoal("-Dprovider=surefire-junit4") - .setJUnitVersion("4.4") - .executeTest() - .verifyErrorFreeLog(); + final OutputValidator outputValidator = + unpack().setJUnitVersion("4.12").executeTest().verifyErrorFreeLog(); assertResults(outputValidator); outputValidator.verifyTextInLog("testRunStarted null"); outputValidator.verifyTextInLog("testFinished simpleTest"); @@ -47,9 +45,8 @@ public void testJUnit4RunListener() { @Test public void testRunlistenerJunitCoreProvider() { - final OutputValidator outputValidator = unpack().addGoal("-Dprovider=surefire-junit47") - .setJUnitVersion("4.8.1") - .addGoal("-DjunitVersion=4.8.1") + final OutputValidator outputValidator = unpack().setJUnitVersion("4.12") + .addGoal("-DjunitVersion=4.12") .executeTest() .verifyErrorFreeLog(); // Todo: Fix junitVesion assertResults(outputValidator); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitUnsupportedVersionsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitUnsupportedVersionsIT.java new file mode 100644 index 0000000000..2098906888 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitUnsupportedVersionsIT.java @@ -0,0 +1,64 @@ +/* + * 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.surefire.its; + +import java.util.Collection; + +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; + +import static java.util.Arrays.asList; +import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_3_8_2; +import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_11; +import static org.junit.runners.Parameterized.Parameters; + +/** + * Basic suite test using all known versions of JUnit 4.x + * + */ +@RunWith(Parameterized.class) +public class JUnitUnsupportedVersionsIT extends SurefireJUnitIntegrationTestCase { + + @Parameters(name = "{index}: JUnit {0}") + public static Collection junitVersions() { + return asList(new Object[][] {{JUNIT_3_8_2}, {JUNIT_4_11}}); + } + + @Parameter + @SuppressWarnings("checkstyle:visibilitymodifier") + public JUnitVersion version; + + @Test() + public void testJunitTemp() { + version.configure(unpack()) + .maven() + .withFailure() + .execute("verify") + .verifyTextInLog(String.format( + "The used JUnit Version %s is not supported anymore. Please update to version 4.12+", version)); + } + + private SurefireLauncher unpack() { + return unpack("/junit-unsupported", version.toString()); + } +} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitVersion.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitVersion.java index 8ddfd2680a..47840eee67 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitVersion.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitVersion.java @@ -24,20 +24,7 @@ * Enum listing all the JUnit version. */ public enum JUnitVersion { - JUNIT_4_0("4.0"), - JUNIT_4_1("4.1"), - JUNIT_4_2("4.2"), - JUNIT_4_3("4.3"), - JUNIT_4_3_1("4.3.1"), - JUNIT_4_4("4.4"), - JUNIT_4_5("4.5"), - JUNIT_4_6("4.6"), - JUNIT_4_7("4.7"), - JUNIT_4_8("4.8"), - JUNIT_4_8_1("4.8.1"), - JUNIT_4_8_2("4.8.2"), - JUNIT_4_9("4.9"), - JUNIT_4_10("4.10"), + JUNIT_3_8_2("3.8.2"), JUNIT_4_11("4.11"), JUNIT_4_12("4.12"), JUNIT_4_13("4.13"), diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitVersionsIT.java similarity index 54% rename from surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java rename to surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitVersionsIT.java index 3de3748dbe..26902747c0 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitVersionsIT.java @@ -20,7 +20,7 @@ import java.util.Collection; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; import org.junit.runner.RunWith; @@ -28,25 +28,10 @@ import org.junit.runners.Parameterized.Parameter; import static java.util.Arrays.asList; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_0; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_1; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_10; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_11; import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_12; import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_13; import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_13_1; import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_13_2; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_2; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_3; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_3_1; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_4; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_5; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_6; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_7; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_8; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_8_1; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_8_2; -import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_9; import static org.junit.runners.Parameterized.Parameters; /** @@ -55,31 +40,11 @@ * @author Dan Fabulich */ @RunWith(Parameterized.class) -public class JUnit4VersionsIT extends SurefireJUnit4IntegrationTestCase { +public class JUnitVersionsIT extends SurefireJUnitIntegrationTestCase { @Parameters(name = "{index}: JUnit {0}") public static Collection junitVersions() { - return asList(new Object[][] { - {JUNIT_4_0}, - {JUNIT_4_1}, - {JUNIT_4_2}, - {JUNIT_4_3}, - {JUNIT_4_3_1}, - {JUNIT_4_4}, - {JUNIT_4_5}, - {JUNIT_4_6}, - {JUNIT_4_7}, - {JUNIT_4_8}, - {JUNIT_4_8_1}, - {JUNIT_4_8_2}, - {JUNIT_4_9}, - {JUNIT_4_10}, - {JUNIT_4_11}, - {JUNIT_4_12}, - {JUNIT_4_13}, - {JUNIT_4_13_1}, - {JUNIT_4_13_2} - }); + return asList(new Object[][] {{JUNIT_4_12}, {JUNIT_4_13}, {JUNIT_4_13_1}, {JUNIT_4_13_2}}); } @Parameter diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/LongWindowsPathIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/LongWindowsPathIT.java index d48626e190..110667b36f 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/LongWindowsPathIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/LongWindowsPathIT.java @@ -21,7 +21,7 @@ import java.io.File; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -39,7 +39,7 @@ * @author Tibor Digana (tibor17) * @since 2.20.1 */ -public class LongWindowsPathIT extends SurefireJUnit4IntegrationTestCase { +public class LongWindowsPathIT extends SurefireJUnitIntegrationTestCase { private static final String PROJECT_DIR = "long-windows-path"; @Test diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/NoRunnableTestsInClassIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/NoRunnableTestsInClassIT.java index 99cbbd6156..1eb435e6b2 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/NoRunnableTestsInClassIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/NoRunnableTestsInClassIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Kristian Rosenvold */ -public class NoRunnableTestsInClassIT extends SurefireJUnit4IntegrationTestCase { +public class NoRunnableTestsInClassIT extends SurefireJUnitIntegrationTestCase { @Test public void testJunit3ParallelBuildResultCount() { unpack("norunnableTests") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/PlainOldJavaClasspathIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/PlainOldJavaClasspathIT.java index 753ea5ac93..e0426173e0 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/PlainOldJavaClasspathIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/PlainOldJavaClasspathIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Dan Fabulich */ -public class PlainOldJavaClasspathIT extends SurefireJUnit4IntegrationTestCase { +public class PlainOldJavaClasspathIT extends SurefireJUnitIntegrationTestCase { @Test public void testPlainOldJavaClasspath() { executeErrorFreeTest("plain-old-java-classpath", 1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/PlexusConflictIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/PlexusConflictIT.java index c242e9860e..1761727af0 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/PlexusConflictIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/PlexusConflictIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -27,7 +27,7 @@ * * @author Dan Fabulich */ -public class PlexusConflictIT extends SurefireJUnit4IntegrationTestCase { +public class PlexusConflictIT extends SurefireJUnitIntegrationTestCase { @Test public void testPlexusConflict() { unpack().executeTest().verifyErrorFree(1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/PojoSimpleIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/PojoSimpleIT.java deleted file mode 100644 index 96780f8a37..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/PojoSimpleIT.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.surefire.its; - -import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.junit.Test; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; - -/** - * Test support for POJO tests. - * - * @author Benjamin Bentmann - */ -public class PojoSimpleIT extends SurefireJUnit4IntegrationTestCase { - @Test - public void twoTestsWithFixtures() throws VerificationException { - unpack("pojo-simple") - .executeTest() - .assertTestSuiteResults(2, 0, 1, 0) - .assertThatLogLine(containsString("setUp called 1"), is(1)) - .assertThatLogLine(containsString("setUp called 2"), is(1)) - .assertThatLogLine(containsString("tearDown called 1"), is(1)) - .assertThatLogLine(containsString("tearDown called 2"), is(1)); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ReportersIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ReportersIT.java index b95bf78dcc..e04447203a 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ReportersIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ReportersIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -28,14 +28,17 @@ * * @author Kristian Rosenvold */ -public class ReportersIT extends SurefireJUnit4IntegrationTestCase { +public class ReportersIT extends SurefireJUnitIntegrationTestCase { @Test public void testRedirectOutputTestNg() { OutputValidator reporters = unpack("reporters").redirectToFile(true).printSummary(true).executeTest(); - reporters.getSurefireReportsFile("TestSuite-output.txt").assertFileExists(); - reporters.getSurefireReportsXmlFile("TEST-TestSuite.xml").assertFileExists(); - reporters.getSurefireReportsFile("TestSuite.txt").assertFileExists(); + reporters.getSurefireReportsFile("TEST-reporters.Test1.xml").assertFileExists(); + reporters.getSurefireReportsXmlFile("TEST-reporters.Test1.xml").assertFileExists(); + reporters.getSurefireReportsFile("reporters.Test1.txt").assertFileExists(); + reporters.getSurefireReportsFile("reporters.Test2.txt").assertFileExists(); + reporters.getSurefireReportsFile("reporters.Test1-output.txt").assertFileExists(); + reporters.getSurefireReportsFile("reporters.Test2-output.txt").assertFileExists(); } } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ResultCountingIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ResultCountingIT.java index 14fdbd8fe3..82fc54b12c 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ResultCountingIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ResultCountingIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -29,7 +29,7 @@ * @author Kristian Rosenvold */ @SuppressWarnings("checkstyle:magicnumber") -public class ResultCountingIT extends SurefireJUnit4IntegrationTestCase { +public class ResultCountingIT extends SurefireJUnitIntegrationTestCase { @Test public void testCountingWithJunit481ForkNever() { assertForkCount(0, true); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java index fe046eb2bb..2615b8976a 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java @@ -23,7 +23,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -33,7 +33,7 @@ * @author Kristian Rosenvold */ @SuppressWarnings("checkstyle:magicnumber") -public class RunOrderIT extends SurefireJUnit4IntegrationTestCase { +public class RunOrderIT extends SurefireJUnitIntegrationTestCase { private static final String[] TESTS_IN_ALPHABETICAL_ORDER = {"TA", "TB", "TC"}; private static final String[] TESTS_IN_REVERSE_ALPHABETICAL_ORDER = {"TC", "TB", "TA"}; diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/SiblingAggregatorIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/SiblingAggregatorIT.java index 35f3e83c66..c76c9e9d8f 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/SiblingAggregatorIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/SiblingAggregatorIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -29,7 +29,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class SiblingAggregatorIT extends SurefireJUnit4IntegrationTestCase { +public class SiblingAggregatorIT extends SurefireJUnitIntegrationTestCase { @Test public void testSiblingAggregator() throws Exception { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/SmartStackTraceIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/SmartStackTraceIT.java index a26bbf0a23..e3f87b5fbc 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/SmartStackTraceIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/SmartStackTraceIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,7 +27,7 @@ * * @author Kristian Rosenvold */ -public class SmartStackTraceIT extends SurefireJUnit4IntegrationTestCase { +public class SmartStackTraceIT extends SurefireJUnitIntegrationTestCase { @Test public void misg() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/Surefire1602IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/Surefire1602IT.java index 41f9dca4e9..eb2329512b 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/Surefire1602IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/Surefire1602IT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,7 +28,7 @@ * * @author Enrico Olivelli */ -public class Surefire1602IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1602IT extends SurefireJUnitIntegrationTestCase { @Test public void nonCanonicalPath() throws VerificationException { SurefireLauncher launcher = unpack("/surefire-1602"); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/SystemPropertiesTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/SystemPropertiesTestIT.java index 9e3b3ec1bc..ecb85e63d5 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/SystemPropertiesTestIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/SystemPropertiesTestIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -27,7 +27,7 @@ * * @author Dan Fabulich */ -public class SystemPropertiesTestIT extends SurefireJUnit4IntegrationTestCase { +public class SystemPropertiesTestIT extends SurefireJUnitIntegrationTestCase { @Test public void testSystemProperties() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java index edcb9d7336..98180c2395 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java @@ -25,7 +25,7 @@ import java.util.Map.Entry; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; import org.junit.runner.RunWith; @@ -42,7 +42,7 @@ * @author Olivier Lamy */ @RunWith(Parameterized.class) -public class TestMethodPatternIT extends SurefireJUnit4IntegrationTestCase { +public class TestMethodPatternIT extends SurefireJUnitIntegrationTestCase { private static final String RUNNING_WITH_PROVIDER47 = "parallel='none', perCoreThreadCount=true, threadCount=0"; private static final String LEGACY_FORK_NODE = "org.apache.maven.plugin.surefire.extensions.LegacyForkNodeFactory"; @@ -85,25 +85,14 @@ private OutputValidator runMethodPattern(String projectName, Map } @Test - public void testJUnit44() throws Exception { - runMethodPattern("junit44-method-pattern", Collections.emptyMap()); + public void testJUnit4() throws Exception { + runMethodPattern("junit4-method-pattern", Collections.emptyMap()); } @Test - public void testJUnit48Provider4() throws Exception { - runMethodPattern("junit48-method-pattern", Collections.emptyMap(), "-P surefire-junit4"); - } - - @Test - public void testJUnit48Provider47() throws Exception { - runMethodPattern("junit48-method-pattern", Collections.emptyMap(), "-P surefire-junit47") - .verifyTextInLog(RUNNING_WITH_PROVIDER47); - } - - @Test - public void testJUnit48WithCategoryFilter() throws Exception { + public void testJUnit4WithCategoryFilter() throws Exception { String cls = profileId == null ? LEGACY_FORK_NODE : SUREFIRE_FORK_NODE; - SurefireLauncher launcher = unpack("junit48-method-pattern", profileId == null ? "" : "-" + profileId); + SurefireLauncher launcher = unpack("junit4-method-pattern", profileId == null ? "" : "-" + profileId); if (profileId != null) { launcher.activateProfile(profileId); @@ -119,16 +108,14 @@ public void testJUnit48WithCategoryFilter() throws Exception { @Test public void testTestNgMethodBefore() throws Exception { Map props = new HashMap<>(); - props.put("testNgVersion", "5.7"); - props.put("testNgClassifier", "jdk15"); + props.put("testNgVersion", "6.14.3"); runMethodPattern("testng-method-pattern-before", props); } @Test public void testTestNGMethodPattern() throws Exception { Map props = new HashMap<>(); - props.put("testNgVersion", "5.7"); - props.put("testNgClassifier", "jdk15"); + props.put("testNgVersion", "6.14.3"); runMethodPattern("/testng-method-pattern", props); } @@ -142,8 +129,7 @@ public void testMethodPatternAfter() throws Exception { } launcher.debugLogging() - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .executeTest() .verifyErrorFree(2) .verifyTextInLog("Called tearDown") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodPatternsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodPatternsIT.java index 8dd0eb0e83..937ae86a93 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodPatternsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodPatternsIT.java @@ -39,14 +39,7 @@ public TestMultipleMethodPatternsIT(Settings settings) { @Parameters public static Iterable data() { - return Arrays.asList(new Object[][] { - {Settings.JUNIT4_TEST}, - {Settings.JUNIT47_TEST}, - {Settings.JUNIT4_INCLUDES}, - {Settings.JUNIT47_INCLUDES}, - {Settings.JUNIT4_INCLUDES_EXCLUDES}, - {Settings.JUNIT47_INCLUDES_EXCLUDES} - }); + return Arrays.asList(new Object[][] {{Settings.JUNIT4_INCLUDES}, {Settings.JUNIT4_INCLUDES_EXCLUDES}}); } @Override @@ -56,6 +49,6 @@ protected Settings getSettings() { @Override protected SurefireLauncher unpack() { - return unpack("junit48-multiple-method-patterns", "_" + settings.path()); + return unpack("junit4-multiple-method-patterns", "_" + settings.path()); } } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java index b49f2bfb7b..71d0024965 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,9 +28,7 @@ * * @author rainLee */ -public class TestMultipleMethodsIT extends SurefireJUnit4IntegrationTestCase { - - private static final String RUNNING_WITH_PROVIDER47 = "parallel='none', perCoreThreadCount=true, threadCount=0"; +public class TestMultipleMethodsIT extends SurefireJUnitIntegrationTestCase { public OutputValidator multipleMethod(String projectName, String... goals) { SurefireLauncher launcher = unpack(projectName); @@ -50,12 +48,7 @@ public void testJunit44() { } @Test - public void testJunit48Provider4() { - multipleMethod("junit48-multiple-methods", "-P surefire-junit4"); - } - - @Test - public void testJunit48Provider47() { - multipleMethod("junit48-multiple-methods", "-P surefire-junit47").verifyTextInLog(RUNNING_WITH_PROVIDER47); + public void testJunit5() { + multipleMethod("junit44-multiple-methods"); } } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgGroupsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgGroupsIT.java index 826888d5c7..cd8dedc558 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgGroupsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgGroupsIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -26,7 +26,7 @@ * Test the group filter for TestNG * */ -public class TestNgGroupsIT extends SurefireJUnit4IntegrationTestCase { +public class TestNgGroupsIT extends SurefireJUnitIntegrationTestCase { @Test public void testExclusion() { unpack().setExcludedGroups("notincluded").executeTest().verifyErrorFree(5); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgParallelWithAnnotationsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgParallelWithAnnotationsIT.java index ee15d3f70f..bb3e0d3be0 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgParallelWithAnnotationsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgParallelWithAnnotationsIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Haikal Saadh */ -public class TestNgParallelWithAnnotationsIT extends SurefireJUnit4IntegrationTestCase { +public class TestNgParallelWithAnnotationsIT extends SurefireJUnitIntegrationTestCase { @Test public void testTestNgGroupThreadParallel() { executeErrorFreeTest("/testng-parallel-with-annotations", 3); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgSuccessPercentageIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgSuccessPercentageIT.java index afdb20c322..5c3f2d7221 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgSuccessPercentageIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestNgSuccessPercentageIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -29,12 +29,11 @@ * @author Jon Todd * @author Andreas Gudian */ -public class TestNgSuccessPercentageIT extends SurefireJUnit4IntegrationTestCase { +public class TestNgSuccessPercentageIT extends SurefireJUnitIntegrationTestCase { @Test public void testPassesWhenFailuresLessThanSuccessPercentage() { OutputValidator validator = unpack("/testng-succes-percentage") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .mavenTestFailureIgnore(true) .executeTest(); validator.assertTestSuiteResults(8, 0, 1, 0); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java index b9359b69d2..7ce5ec6704 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java @@ -23,7 +23,7 @@ import java.util.Map; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -32,7 +32,7 @@ * * @author Olivier Lamy */ -public class TestSingleMethodIT extends SurefireJUnit4IntegrationTestCase { +public class TestSingleMethodIT extends SurefireJUnitIntegrationTestCase { private static final String RUNNING_WITH_PROVIDER47 = "parallel='none', perCoreThreadCount=true, threadCount=0"; public OutputValidator singleMethod( @@ -80,8 +80,7 @@ public void testJunit48parallel() { @Test public void testTestNg() { Map props = new HashMap<>(); - props.put("testNgVersion", "5.7"); - props.put("testNgClassifier", "jdk15"); + props.put("testNgVersion", "6.14.3"); singleMethod("testng-single-method", props, null); } @@ -111,8 +110,7 @@ public void fullyQualifiedJunit48Provider47() { @Test public void fullyQualifiedTestNg() { Map props = new HashMap<>(); - props.put("testNgVersion", "5.7"); - props.put("testNgClassifier", "jdk15"); + props.put("testNgVersion", "6.14.3"); singleMethod("testng-single-method", props, "testng.BasicTest#testSuccessOne"); } } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java index 5580e66c87..e58a257d8b 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Dan Fabulich */ -public class TimeoutForkedTestIT extends SurefireJUnit4IntegrationTestCase { +public class TimeoutForkedTestIT extends SurefireJUnitIntegrationTestCase { @Test public void testTimeoutForked() { unpack("/timeout-forked") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java index 626fc2285d..544785cdfa 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java @@ -26,7 +26,7 @@ import org.apache.maven.surefire.its.fixture.HelperAssertions; import org.apache.maven.surefire.its.fixture.IntegrationTestSuiteResults; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -37,12 +37,11 @@ * * @author Dan Fabulich */ -public class TwoTestCasesIT extends SurefireJUnit4IntegrationTestCase { +public class TwoTestCasesIT extends SurefireJUnitIntegrationTestCase { @Test public void testTwoTestCases() { unpack("junit-twoTestCases") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .executeTest() .verifyErrorFreeLog() .assertTestSuiteResults(2, 0, 0, 0); @@ -54,8 +53,7 @@ public void testTwoTestCases() { @Test public void testTwoTestCaseSuite() { final OutputValidator outputValidator = unpack("junit-twoTestCaseSuite") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .executeTest(); outputValidator.verifyErrorFreeLog().assertTestSuiteResults(2, 0, 0, 0); List reports = HelperAssertions.extractReports(outputValidator.getBaseDir()); @@ -85,8 +83,7 @@ private Set extractClassNames(List reports) { @Test public void testJunit4Suite() { final OutputValidator outputValidator = unpack("junit4-twoTestCaseSuite") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .executeTest(); outputValidator.verifyErrorFreeLog().assertTestSuiteResults(2, 0, 0, 0); @@ -98,20 +95,4 @@ public void testJunit4Suite() { IntegrationTestSuiteResults results = HelperAssertions.parseReportList(reports); HelperAssertions.assertTestSuiteResults(2, 0, 0, 0, results); } - - @Test - public void testTestNGSuite() { - final OutputValidator outputValidator = unpack("testng-twoTestCaseSuite") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") - .executeTest(); - outputValidator.assertTestSuiteResults(2, 0, 0, 0); - List reports = HelperAssertions.extractReports(outputValidator.getBaseDir()); - Set classNames = extractClassNames(reports); - assertContains(classNames, "testng.two.TestNGTestTwo"); - assertContains(classNames, "testng.two.TestNGSuiteTest"); - assertEquals("wrong number of classes", 2, classNames.size()); - IntegrationTestSuiteResults results = HelperAssertions.parseReportList(reports); - HelperAssertions.assertTestSuiteResults(2, 0, 0, 0, results); - } } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java index cdd9bc96ab..ad5c79bad3 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java @@ -26,7 +26,7 @@ import org.apache.maven.shared.utils.io.FileUtils; import org.apache.maven.surefire.its.fixture.MavenLauncher; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.After; import org.junit.Before; @@ -46,7 +46,7 @@ * * @author Dan Fabulich */ -public class UmlautDirIT extends SurefireJUnit4IntegrationTestCase { +public class UmlautDirIT extends SurefireJUnitIntegrationTestCase { private String localRepo; @Before diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java index 49245ab44b..ceaaddba6d 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java @@ -21,7 +21,7 @@ import java.io.File; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -35,7 +35,7 @@ /** * Verifies unicode filenames pass through correctly. */ -public class UnicodeTestNamesIT extends SurefireJUnit4IntegrationTestCase { +public class UnicodeTestNamesIT extends SurefireJUnitIntegrationTestCase { private static final String REPORT_FILE_CONTENT = "junit.twoTestCases.\u800C\u7D22\u5176\u60C5Test"; private static final String TXT_REPORT = "junit.twoTestCases.\u800C\u7D22\u5176\u60C5Test.txt"; private static final String XML_REPORT = "TEST-junit.twoTestCases.\u800C\u7D22\u5176\u60C5Test.xml"; diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/UseIsolatedClassLoaderIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/UseIsolatedClassLoaderIT.java index bbf5fa2c5c..f4cc50ae3d 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/UseIsolatedClassLoaderIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/UseIsolatedClassLoaderIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Dan Fabulich */ -public class UseIsolatedClassLoaderIT extends SurefireJUnit4IntegrationTestCase { +public class UseIsolatedClassLoaderIT extends SurefireJUnitIntegrationTestCase { @Test public void testUseSystemClassLoader() { executeErrorFreeTest("/isolated-classloader", 1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIT.java index d7a7c3a9de..1dbdf2bd7c 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIT.java @@ -25,7 +25,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -40,7 +40,7 @@ * @author Dan Fabulich * @author Kristian Rosenvold */ -public class WorkingDirectoryIT extends SurefireJUnit4IntegrationTestCase { +public class WorkingDirectoryIT extends SurefireJUnitIntegrationTestCase { @Test public void testWorkingDirectory() throws Exception { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIsInvalidPropertyIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIsInvalidPropertyIT.java index d6b2962637..a0794021f3 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIsInvalidPropertyIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIsInvalidPropertyIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Kristian Rosenvold */ -public class WorkingDirectoryIsInvalidPropertyIT extends SurefireJUnit4IntegrationTestCase { +public class WorkingDirectoryIsInvalidPropertyIT extends SurefireJUnitIntegrationTestCase { @Test public void testWorkingDirectory() { unpack("working-directory-is-invalid-property") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java index 19edd75866..cffd9bdf07 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Stephen Connolly */ -public class WorkingDirectoryMissingIT extends SurefireJUnit4IntegrationTestCase { +public class WorkingDirectoryMissingIT extends SurefireJUnitIntegrationTestCase { @Test public void testWorkingDirectory() { unpack("working-directory-missing").executeTest().verifyErrorFreeLog(); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/XmlReporterRunTimeIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/XmlReporterRunTimeIT.java index f193c01825..ad0945be1d 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/XmlReporterRunTimeIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/XmlReporterRunTimeIT.java @@ -20,7 +20,7 @@ import org.apache.maven.plugins.surefire.report.ReportTestSuite; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.apache.maven.surefire.its.fixture.HelperAssertions.extractReports; @@ -35,7 +35,7 @@ * @author Kristian Rosenvold */ @SuppressWarnings({"checkstyle:magicnumber", "checkstyle:linelength"}) -public class XmlReporterRunTimeIT extends SurefireJUnit4IntegrationTestCase { +public class XmlReporterRunTimeIT extends SurefireJUnitIntegrationTestCase { @Test public void testForkAlways() { // just generate .surefire- in order to apply runOrder diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/AbstractJava9PlusIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/AbstractJava9PlusIT.java index f6aa5fc247..9422977c68 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/AbstractJava9PlusIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/AbstractJava9PlusIT.java @@ -26,7 +26,7 @@ * @author Tibor Digana (tibor17) * @since 2.20.1 */ -public abstract class AbstractJava9PlusIT extends SurefireJUnit4IntegrationTestCase { +public abstract class AbstractJava9PlusIT extends SurefireJUnitIntegrationTestCase { protected abstract String getProjectDirectoryName(); protected SurefireLauncher assumeJava9() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java index dcd43f6532..3a422bb016 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; @@ -130,7 +131,9 @@ public static List extractReports(File... testDirs) { ConsoleLogger logger = new PrintStreamLogger(System.out); SurefireReportParser parser = new SurefireReportParser(reportsDirs, logger); try { - return parser.parseXMLReportFiles(); + List suites = parser.parseXMLReportFiles(); + suites.sort(Comparator.comparing(ReportTestSuite::getLastModified)); + return suites; } catch (Exception e) { throw new RuntimeException("Couldn't parse XML reports", e); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java index 441d449692..8e207e8efa 100755 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java @@ -201,11 +201,11 @@ public MavenLauncher addGoal(String goal) { } public FailsafeOutputValidator executeVerify() { - return new FailsafeOutputValidator(conditionalExec("verify")); + return new FailsafeOutputValidator(executeGoal("verify")); } public OutputValidator executeTest() { - return conditionalExec("test"); + return executeGoal("test"); } List getGoals() { @@ -231,7 +231,7 @@ private void writeGoal(String newGoal) { goals.add(newGoal); } - private OutputValidator conditionalExec(String goal) { + private OutputValidator executeGoal(String goal) { OutputValidator verify; try { verify = execute(goal); @@ -260,6 +260,7 @@ public OutputValidator execute(String goal) { public OutputValidator executeCurrentGoals() { try { + props.put("maven.build.cache.enabled", "false"); getVerifier().addCliArguments(cliOptions.toArray(new String[0])); getVerifier().addCliArguments(goals.toArray(new String[] {})); getVerifier().setSystemProperties(props); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java index 5b157e9f42..96ab981014 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java @@ -31,6 +31,7 @@ import org.hamcrest.Matcher; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.apache.maven.shared.verifier.Verifier.stripAnsi; import static org.hamcrest.MatcherAssert.assertThat; /** @@ -57,6 +58,23 @@ public OutputValidator verifyTextInLog(String text) { return this; } + public OutputValidator verifyTextNotInLog(String text) throws VerificationException { + List lines = verifier.loadFile(this.getBasedir(), verifier.getLogFileName(), false); + boolean result = false; + + for (String line : lines) { + if (stripAnsi(line).contains(text)) { + result = true; + break; + } + } + + if (!result) { + return this; + } + throw new SurefireVerifierException(new Exception(text + " found in logs")); + } + public OutputValidator verifyErrorFreeLog() { try { verifier.verifyErrorFreeLog(); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/Settings.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/Settings.java index cb33d80448..c95fb37fc5 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/Settings.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/Settings.java @@ -24,15 +24,10 @@ */ public enum Settings { JUNIT4_TEST(TestFramework.JUNIT4, Configuration.TEST), - JUNIT47_TEST(TestFramework.JUNIT47, Configuration.TEST), JUNIT4_INCLUDES(TestFramework.JUNIT4, Configuration.INCLUDES), - JUNIT47_INCLUDES(TestFramework.JUNIT47, Configuration.INCLUDES), JUNIT4_INCLUDES_EXCLUDES(TestFramework.JUNIT4, Configuration.INCLUDES_EXCLUDES), - JUNIT47_INCLUDES_EXCLUDES(TestFramework.JUNIT47, Configuration.INCLUDES_EXCLUDES), JUNIT4_INCLUDES_FILE(TestFramework.JUNIT4, Configuration.INCLUDES_FILE), - JUNIT47_INCLUDES_FILE(TestFramework.JUNIT47, Configuration.INCLUDES_FILE), JUNIT4_INCLUDES_EXCLUDES_FILE(TestFramework.JUNIT4, Configuration.INCLUDES_EXCLUDES_FILE), - JUNIT47_INCLUDES_EXCLUDES_FILE(TestFramework.JUNIT47, Configuration.INCLUDES_EXCLUDES_FILE), TestNG_TEST(TestFramework.TestNG, Configuration.TEST), TestNG_INCLUDES(TestFramework.TestNG, Configuration.INCLUDES), TestNG_INCLUDES_EXCLUDES(TestFramework.TestNG, Configuration.INCLUDES_EXCLUDES), diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnitIntegrationTestCase.java similarity index 97% rename from surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java rename to surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnitIntegrationTestCase.java index b390446532..6c9f2836e9 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnitIntegrationTestCase.java @@ -30,7 +30,7 @@ * * @author Kristian Rosenvold */ -public abstract class SurefireJUnit4IntegrationTestCase { +public abstract class SurefireJUnitIntegrationTestCase { private static final int JAVA9_VERSION = 9; public static final double JAVA_VERSION = javaVersion(); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFramework.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFramework.java index bd0fd5fe32..6f60ed4d97 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFramework.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFramework.java @@ -24,6 +24,5 @@ */ public enum TestFramework { JUNIT4, - JUNIT47, TestNG } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/SpockIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/SpockIT.java index 64f14771f4..39ace988aa 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/SpockIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/SpockIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaMaxVersion; @@ -27,7 +27,7 @@ * */ @SuppressWarnings("checkstyle:magicnumber") -public class SpockIT extends SurefireJUnit4IntegrationTestCase { +public class SpockIT extends SurefireJUnitIntegrationTestCase { @Test public void test() { assumeJavaMaxVersion(14d); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1004RunTestFromDependencyJarsTypeAndClassifierIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1004RunTestFromDependencyJarsTypeAndClassifierIT.java index a4c83ce21a..a77a5dd173 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1004RunTestFromDependencyJarsTypeAndClassifierIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1004RunTestFromDependencyJarsTypeAndClassifierIT.java @@ -21,7 +21,7 @@ import java.util.Collection; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -30,7 +30,7 @@ /** * */ -public class Surefire1004RunTestFromDependencyJarsTypeAndClassifierIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1004RunTestFromDependencyJarsTypeAndClassifierIT extends SurefireJUnitIntegrationTestCase { @Test public void shouldScanAndRunTestsInDependencyJars() throws Exception { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java index 450ef015a6..2c064c5430 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -31,7 +31,7 @@ * @see SUREFIRE-1024 * @since 2.19 */ -public class Surefire1024VerifyFailsafeIfTestedIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1024VerifyFailsafeIfTestedIT extends SurefireJUnitIntegrationTestCase { @Test public void shouldScanAndRunTestsInDependencyJars() throws Exception { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java index 9620ddfe98..b019d12bda 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -40,7 +40,7 @@ * @see SUREFIRE-1028 * @since 2.18 */ -public class Surefire1028UnableToRunSingleIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1028UnableToRunSingleIT extends SurefireJUnitIntegrationTestCase { @Test public void methodFilteringParallelExecution() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java index 71a521c645..2543878b9e 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java @@ -23,7 +23,7 @@ import org.apache.maven.shared.utils.xml.Xpp3Dom; import org.apache.maven.shared.utils.xml.Xpp3DomBuilder; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -37,7 +37,7 @@ * @see SUREFIRE-1036 * @since 2.18 */ -public class Surefire1036NonFilterableJUnitRunnerWithCategoriesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1036NonFilterableJUnitRunnerWithCategoriesIT extends SurefireJUnitIntegrationTestCase { @Test public void test() throws FileNotFoundException { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java index 643e659c42..392281a60d 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Andreas Gudian */ -public class Surefire1041FailingJUnitRunnerIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1041FailingJUnitRunnerIT extends SurefireJUnitIntegrationTestCase { @Test public void reportErrorInJUnitRunnerAsTestError() { unpack("surefire-1041-exception-in-junit-runner") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java index a8eda80e3c..13341c02fb 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -30,7 +30,7 @@ * @see SUREFIRE-1053 * @since 2.18 */ -public class Surefire1053SystemPropertiesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1053SystemPropertiesIT extends SurefireJUnitIntegrationTestCase { @Test public void checkWarningsFileEncoding() { unpack().sysProp("file.encoding", "ISO-8859-1") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1055CorrectConcurrentTestCountIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1055CorrectConcurrentTestCountIT.java index f52f5dde8c..10dc85360a 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1055CorrectConcurrentTestCountIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1055CorrectConcurrentTestCountIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -28,7 +28,7 @@ * @author Kristian Rosenvold */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire1055CorrectConcurrentTestCountIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1055CorrectConcurrentTestCountIT extends SurefireJUnitIntegrationTestCase { @Test public void testTestNgAndJUnitTogether() { OutputValidator outputValidator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java index 138457a91a..7a21d981d8 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -37,7 +37,7 @@ * @see SUREFIRE-1080 * @since 2.18 */ -public class Surefire1080ParallelForkDoubleTestIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1080ParallelForkDoubleTestIT extends SurefireJUnitIntegrationTestCase { @Test public void test() { unpack().executeTest().assertTestSuiteResults(9); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java index 45042aec43..aa3986f5c5 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java @@ -24,7 +24,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -42,7 +42,7 @@ * @see SUREFIRE-1082 * @since 2.18 */ -public class Surefire1082ParallelJUnitParameterizedIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1082ParallelJUnitParameterizedIT extends SurefireJUnitIntegrationTestCase { private static Set printOnlyTestLinesFromOutFile(OutputValidator validator) { TestFile report = validator.getSurefireReportsFile("jiras.surefire1082.Jira1082Test-output.txt"); report.assertFileExists(); @@ -63,16 +63,16 @@ private static void assertParallelRun(Set log) { assertThat(log.size(), is(4)); Set expectedLogs1 = new TreeSet<>(); - expectedLogs1.add("class jiras.surefire1082.Jira1082Test a 0 pool-[\\d]+-thread-1"); - expectedLogs1.add("class jiras.surefire1082.Jira1082Test b 0 pool-[\\d]+-thread-1"); - expectedLogs1.add("class jiras.surefire1082.Jira1082Test a 1 pool-[\\d]+-thread-2"); - expectedLogs1.add("class jiras.surefire1082.Jira1082Test b 1 pool-[\\d]+-thread-2"); + expectedLogs1.add("class jiras.surefire1082.Jira1082Test a 0 ForkJoinPool.*"); + expectedLogs1.add("class jiras.surefire1082.Jira1082Test b 0 ForkJoinPool.*"); + expectedLogs1.add("class jiras.surefire1082.Jira1082Test a 1 ForkJoinPool.*"); + expectedLogs1.add("class jiras.surefire1082.Jira1082Test b 1 ForkJoinPool.*"); Set expectedLogs2 = new TreeSet<>(); - expectedLogs2.add("class jiras.surefire1082.Jira1082Test a 1 pool-[\\d]+-thread-1"); - expectedLogs2.add("class jiras.surefire1082.Jira1082Test b 1 pool-[\\d]+-thread-1"); - expectedLogs2.add("class jiras.surefire1082.Jira1082Test a 0 pool-[\\d]+-thread-2"); - expectedLogs2.add("class jiras.surefire1082.Jira1082Test b 0 pool-[\\d]+-thread-2"); + expectedLogs2.add("class jiras.surefire1082.Jira1082Test a 1 ForkJoinPool.*"); + expectedLogs2.add("class jiras.surefire1082.Jira1082Test b 1 ForkJoinPool.*"); + expectedLogs2.add("class jiras.surefire1082.Jira1082Test a 0 ForkJoinPool.*"); + expectedLogs2.add("class jiras.surefire1082.Jira1082Test b 0 ForkJoinPool.*"); assertThat(log, anyOf(regex(expectedLogs1), regex(expectedLogs2))); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListenerIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListenerIT.java index 9b55e7c2f0..4f273f22d3 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListenerIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListenerIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -44,7 +44,7 @@ * @see * @since 2.18 */ -public final class Surefire1095NpeInRunListenerIT extends SurefireJUnit4IntegrationTestCase { +public final class Surefire1095NpeInRunListenerIT extends SurefireJUnitIntegrationTestCase { /** * Method Request.classes( String, Class[] ); exists in JUnit 4.0 - 4.4 @@ -52,10 +52,10 @@ public final class Surefire1095NpeInRunListenerIT extends SurefireJUnit4Integrat */ @Test public void testRunStartedWithJUnit40() { - unpack().setJUnitVersion("4.0") + unpack().setJUnitVersion("4.12") .executeTest() .verifyErrorFree(1) - .verifyTextInLog("Running JUnit 4.0") + .verifyTextInLog("Running JUnit 4.12") .verifyTextInLog("testRunStarted [jiras.surefire1095.SomeTest]"); } @@ -65,19 +65,19 @@ public void testRunStartedWithJUnit40() { */ @Test public void testRunStartedWithJUnit45() { - unpack().setJUnitVersion("4.5") + unpack().setJUnitVersion("4.12") .executeTest() .verifyErrorFree(1) - .verifyTextInLog("Running JUnit 4.5") + .verifyTextInLog("Running JUnit 4.12") .verifyTextInLog("testRunStarted [jiras.surefire1095.SomeTest]"); } @Test public void testRunStartedWithJUnit47() { - unpack().setJUnitVersion("4.7") + unpack().setJUnitVersion("4.12") .executeTest() .verifyErrorFree(1) - .verifyTextInLog("Running JUnit 4.7") + .verifyTextInLog("Running JUnit 4.12") .verifyTextInLog("testRunStarted [jiras.surefire1095.SomeTest]"); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java index 1fe4488fb5..d871f9e819 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java @@ -25,7 +25,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -44,7 +44,7 @@ * @see SUREFIRE-1098 * @since 2.18 */ -public class Surefire1098BalancedRunOrderIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1098BalancedRunOrderIT extends SurefireJUnitIntegrationTestCase { @Test public void reorderedParallelClasses() throws VerificationException { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java index fbd24692c7..e40d88e90e 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java @@ -18,14 +18,14 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * @author agudian * @see SUREFIRE-1122 */ -public class Surefire1122ParallelAndFlakyTestsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1122ParallelAndFlakyTestsIT extends SurefireJUnitIntegrationTestCase { @Test public void nonParallelCreatesCorrectReport() { unpack("surefire-1122-parallel-and-flakyTests").executeTest().assertTestSuiteResults(2, 0, 0, 0, 1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java index e13564eee2..0012a6f770 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java @@ -22,24 +22,23 @@ import org.apache.maven.shared.utils.xml.Xpp3Dom; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; import static org.apache.maven.shared.utils.xml.Xpp3DomBuilder.build; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayWithSize; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.isEmptyOrNullString; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; /** * Test surefire-report on TestNG test * * @author Michal Bocek */ -public class Surefire1135ImproveIgnoreMessageForTestNGIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1135ImproveIgnoreMessageForTestNGIT extends SurefireJUnitIntegrationTestCase { private enum ResultType { SKIPPED("skipped"), @@ -59,30 +58,19 @@ public String getType() { @Test public void testNgReport688() throws Exception { testNgReport( - "6.8.8", + "6.14.3", null, ResultType.SKIPPED, "Skip test", /*"org.testng.SkipException"*/ null, - /*"SkipExceptionReportTest.java:30"*/ null); - } - - @Test - public void testNgReport57() throws Exception { - testNgReport( - "5.7", - "jdk15", - ResultType.SKIPPED, - "Skip test", - /*"org.testng.SkipException"*/ null, - /*"SkipExceptionReportTest.java:30"*/ null); + "SkipExceptionReportTest.java:30"); } private void testNgReport( String version, String classifier, ResultType resultType, String message, String type, String stackTrace) throws Exception { OutputValidator outputValidator = - runTest(version, classifier, resultType, "/surefire-1135-improve-ignore-message-for-testng"); + runTest(version, resultType, "/surefire-1135-improve-ignore-message-for-testng"); Xpp3Dom[] children = readTests(outputValidator, "testng.SkipExceptionReportTest"); assertThat("Report should contains only one test case", children.length, is(1)); @@ -97,17 +85,6 @@ private void testNgReport( "Test should contains only one " + resultType.getType() + " element", children, is(arrayWithSize(1))); Xpp3Dom result = children[0]; - if (message == null) { - assertThat("Subelement message attribute must be null", result.getAttribute("message"), is(nullValue())); - } else { - assertThat("Subelement should contains message attribute", result.getAttribute("message"), is(message)); - } - - if (type == null) { - assertThat("Subelement type attribute must be null", result.getAttribute("type"), is(nullValue())); - } else { - assertThat("Subelement should contains type attribute", result.getAttribute("type"), is(type)); - } if (stackTrace == null) { assertThat("Element body must be null", result.getValue(), isEmptyOrNullString()); @@ -116,16 +93,12 @@ private void testNgReport( } } - private OutputValidator runTest(String version, String classifier, ResultType resultType, String resource) { + private OutputValidator runTest(String version, ResultType resultType, String resource) { int skipped = ResultType.SKIPPED.equals(resultType) ? 1 : 0; int failure = ResultType.FAILURE.equals(resultType) ? 1 : 0; SurefireLauncher launcher = unpack(resource).sysProp("testNgVersion", version); - if (classifier != null) { - launcher.sysProp("testNgClassifier", classifier); - } - return launcher.addSurefireReportGoal().executeCurrentGoals().assertTestSuiteResults(1, 0, failure, skipped); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java index 0870caddab..e04fbdbde8 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -30,7 +30,7 @@ * * @author Norbert Wnuk */ -public class Surefire1136CwdPropagationInForkedModeIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1136CwdPropagationInForkedModeIT extends SurefireJUnitIntegrationTestCase { @Test public void testTestNgAndJUnitTogether() { OutputValidator outputValidator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1144XmlRunTimeIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1144XmlRunTimeIT.java index dc3fa35c53..9d86a38817 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1144XmlRunTimeIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1144XmlRunTimeIT.java @@ -22,7 +22,7 @@ import org.apache.maven.plugins.surefire.report.ReportTestSuite; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.apache.maven.surefire.its.fixture.HelperAssertions.extractReports; @@ -37,7 +37,7 @@ * @author Lamyaa Eloussi */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire1144XmlRunTimeIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1144XmlRunTimeIT extends SurefireJUnitIntegrationTestCase { @Test public void testXmlRunTime() { OutputValidator outputValidator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterizedIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterizedIT.java index 9d28f17456..2f54e9d549 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterizedIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterizedIT.java @@ -19,13 +19,13 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * @see SUREFIRE-1146 */ -public class Surefire1146RerunFailedAndParameterizedIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1146RerunFailedAndParameterizedIT extends SurefireJUnitIntegrationTestCase { @Test public void testsAreRerun() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java index c17bf3e44e..5d9e0f4919 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,29 +28,14 @@ * * @author Sean Flanigan */ -public class Surefire1152RerunFailingTestsInSuiteIT extends SurefireJUnit4IntegrationTestCase { - private static final String RUNNING_WITH_PROVIDER47 = - "Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider"; +public class Surefire1152RerunFailingTestsInSuiteIT extends SurefireJUnitIntegrationTestCase { - private OutputValidator runMethodPattern(String... goals) { + @Test + public void testJUnit48Provider4() { SurefireLauncher launcher = unpack("surefire-1152-rerunFailingTestsCount-suite"); - for (String goal : goals) { - launcher.addGoal(goal); - } OutputValidator outputValidator = launcher.showErrorStackTraces().debugLogging().executeVerify(); outputValidator.assertTestSuiteResults(3, 0, 0, 0, 3); outputValidator.assertIntegrationTestSuiteResults(1, 0, 0, 0); - return outputValidator; - } - - @Test - public void testJUnit48Provider4() { - runMethodPattern("-P surefire-junit4"); - } - - @Test - public void testJUnit48Provider47() { - runMethodPattern("-P surefire-junit47").verifyTextInLog(RUNNING_WITH_PROVIDER47); } } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java index 0fcb86f7d0..8d2db483c1 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java @@ -18,13 +18,13 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * */ -public class Surefire1153IncludesAndSpecifiedTestIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1153IncludesAndSpecifiedTestIT extends SurefireJUnitIntegrationTestCase { @Test public void testSpecifiedTestInIncludes() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java deleted file mode 100644 index 56e50137b0..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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.surefire.its.jiras; - -import java.util.ArrayList; - -import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireVerifierException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import static org.junit.Assert.fail; -import static org.junit.runners.Parameterized.Parameter; -import static org.junit.runners.Parameterized.Parameters; - -/** - * @author Tibor Digana (tibor17) - * @see SUREFIRE-1158 - * @since 2.19 - */ -@RunWith(Parameterized.class) -public class Surefire1158RemoveInfoLinesIT extends SurefireJUnit4IntegrationTestCase { - - @Parameters(name = "{0}") - public static Iterable data() { - ArrayList args = new ArrayList<>(); - args.add(new Object[] {"junit-option-ff", "JUnitTest", "-ff", "surefire-junit47", false, true}); - args.add(new Object[] {"testng-option-ff", "TestNGSuiteTest", "-ff", "surefire-testng", false, false}); - args.add(new Object[] {"junit-option-X", "JUnitTest", "-X", "surefire-junit47", true, true}); - args.add(new Object[] {"testng-option-X", "TestNGSuiteTest", "-X", "surefire-testng", true, false}); - args.add(new Object[] {"junit-option-e", "JUnitTest", "-e", "surefire-junit47", true, true}); - args.add(new Object[] {"testng-option-e", "TestNGSuiteTest", "-e", "surefire-testng", true, false}); - return args; - } - - @Parameter(0) - @SuppressWarnings("checkstyle:visibilitymodifier") - public String description; - - @Parameter(1) - @SuppressWarnings("checkstyle:visibilitymodifier") - public String testToRun; - - @Parameter(2) - @SuppressWarnings("checkstyle:visibilitymodifier") - public String cliOption; - - @Parameter(3) - @SuppressWarnings("checkstyle:visibilitymodifier") - public String provider; - - @Parameter(4) - @SuppressWarnings("checkstyle:visibilitymodifier") - public boolean printsInfoLines; - - @Parameter(5) - @SuppressWarnings("checkstyle:visibilitymodifier") - public boolean isJUnit; - - @Test - public void shouldRunWithCliOption() { - OutputValidator validator = assertTest(); - if (isJUnit) { - assertJUnitTestLogs(validator); - } else { - assertTestNGTestLogs(validator); - } - } - - private OutputValidator assertTest() { - final String[] cli = {"--batch-mode"}; - return unpack("/surefire-1158-remove-info-lines", "_" + description, cli) - .sysProp("provider", provider) - .addGoal(cliOption) - .setTestToRun(testToRun) - .executeTest() - .verifyErrorFreeLog() - .assertTestSuiteResults(1, 0, 0, 0); - } - - private void assertJUnitTestLogs(OutputValidator validator) { - try { - validator.verifyTextInLog("Surefire report directory:"); - validator.verifyTextInLog( - "Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider"); - validator.verifyTextInLog("parallel='none', perCoreThreadCount=true, threadCount=0, " - + "useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, " - + "threadCountMethods=0, parallelOptimized=true"); - if (!printsInfoLines) { - fail(); - } - } catch (SurefireVerifierException e) { - if (printsInfoLines) { - fail(); - } - } - } - - private void assertTestNGTestLogs(OutputValidator validator) { - try { - validator.verifyTextInLog("Surefire report directory:"); - validator.verifyTextInLog("Using configured provider org.apache.maven.surefire.testng.TestNGProvider"); - validator.verifyTextInLog("Configuring TestNG with: TestNGMapConfigurator"); - if (!printsInfoLines) { - fail(); - } - } catch (SurefireVerifierException e) { - if (printsInfoLines) { - fail(); - } - } - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java deleted file mode 100644 index a468a816fe..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.surefire.its.jiras; - -import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.junit.Test; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.startsWith; - -/** - * IT for https://issues.apache.org/jira/browse/SUREFIRE-1177 - * - * @author Tibor Digana (tibor17) - * @since 2.19 - */ -public class Surefire1177TestngParallelSuitesIT extends SurefireJUnit4IntegrationTestCase { - private static final String EXPECTED_LINE = "TestNGSuiteTest#shouldRunAndPrintItself()"; - private static final String UNEXPECTED_LINE = "ShouldNotRunTest#shouldNotRun()"; - - @Test - public void twoSuitesInParallel() throws VerificationException { - OutputValidator validator = unpack().forkNever().executeTest().verifyErrorFree(2); - - validator.assertThatLogLine(startsWith(EXPECTED_LINE), is(2)); - validator.assertThatLogLine(is(EXPECTED_LINE + " 1."), is(1)); - validator.assertThatLogLine(is(EXPECTED_LINE + " 2."), is(1)); - validator.assertThatLogLine(containsString(UNEXPECTED_LINE), is(0)); - } - - @Test - public void twoSuitesInParallelForked() throws VerificationException { - OutputValidator validator = unpack().forkOnce().executeTest().verifyErrorFree(2); - - validator.assertThatLogLine(startsWith(EXPECTED_LINE), is(2)); - validator.assertThatLogLine(is(EXPECTED_LINE + " 1."), is(1)); - validator.assertThatLogLine(is(EXPECTED_LINE + " 2."), is(1)); - validator.assertThatLogLine(containsString(UNEXPECTED_LINE), is(0)); - } - - private SurefireLauncher unpack() { - return unpack("testng-parallel-suites"); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java index 7f7678abf6..6e0c54ef18 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java @@ -18,14 +18,14 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; /** * Fix for TestNG parameter -dataproviderthreadcount. */ -public class Surefire1179IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1179IT extends SurefireJUnitIntegrationTestCase { @Test public void suiteXmlForkCountTwoReuse() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java index cd9649be65..724ae10e36 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -40,7 +40,7 @@ * * Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 */ -public class Surefire1185DoNotSpawnTestsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1185DoNotSpawnTestsIT extends SurefireJUnitIntegrationTestCase { @Test public void doNotSpawnUnwantedTests() throws VerificationException { unpack().setTestToRun("RunningTest#test") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java index 8bf878a2e3..7910d061c9 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -29,11 +29,7 @@ * @see SUREFIRE-1202 * @since 2.19.1 */ -public class Surefire1202RerunAndSkipIT extends SurefireJUnit4IntegrationTestCase { - @Test - public void junit47() { - unpack().executeTest().assertTestSuiteResults(5, 0, 0, 3, 4); - } +public class Surefire1202RerunAndSkipIT extends SurefireJUnitIntegrationTestCase { @Test public void junit4() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java index 010ccf344a..465ee45bbd 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -31,7 +31,7 @@ * @see SUREFIRE-1209 * @since 2.19 */ -public class Surefire1209RerunAndForkCountIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1209RerunAndForkCountIT extends SurefireJUnitIntegrationTestCase { private static final String SUMMARY_COUNTS = "Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Flakes: 2"; @Test diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java index dcca781733..57453429ca 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -27,7 +27,7 @@ * @see SUREFIRE-1211 * @since 2.19.1 */ -public class Surefire1211JUnitTestNgIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1211JUnitTestNgIT extends SurefireJUnitIntegrationTestCase { @Test public void withJUnit() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java index 6f71193df0..83b42302ca 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -31,7 +31,7 @@ * @see SUREFIRE-1260 * @since 2.20 */ -public class Surefire1260NewTestsPattern extends SurefireJUnit4IntegrationTestCase { +public class Surefire1260NewTestsPattern extends SurefireJUnitIntegrationTestCase { @Test public void defaultConfig() { unpack().executeTest().verifyErrorFree(5); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java index 1d771889c5..cfe428ba87 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * @see SUREFIRE-1264 * @since 2.20.1 */ -public class Surefire1264IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1264IT extends SurefireJUnitIntegrationTestCase { @Test public void positiveTests() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java index 53cba24371..119535a39a 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -26,7 +26,7 @@ * Test the group filter for TestNG * */ -public class Surefire1278GroupNameEndingIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1278GroupNameEndingIT extends SurefireJUnitIntegrationTestCase { @Test public void testOnlyGroups() { unpack().setGroups("group").executeTest().verifyErrorFree(1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java index 21681533ff..086f6b5a6f 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java @@ -21,7 +21,7 @@ import java.util.Iterator; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; import org.junit.runner.RunWith; @@ -46,7 +46,7 @@ * @since 2.20 */ @RunWith(Parameterized.class) -public class Surefire1295AttributeJvmCrashesToTestsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1295AttributeJvmCrashesToTestsIT extends SurefireJUnitIntegrationTestCase { private static final int ONE_FORK_REUSE_THREAD_COUNT = 1; /** diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1360PropertiesElementIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1360PropertiesElementIT.java index 4f2181883d..f7d2971e6a 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1360PropertiesElementIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1360PropertiesElementIT.java @@ -19,14 +19,14 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; /** * Test for SUREFIRE-1360. Enabling and disabling properties element in plugin configuration. */ -public class Surefire1360PropertiesElementIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1360PropertiesElementIT extends SurefireJUnitIntegrationTestCase { @Test public void testPropertiesElementDisabled() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java index 55ea8f8fb5..6029ce6b9d 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -29,42 +29,7 @@ * @author Tibor Digana (tibor17) * @since 2.20.1 */ -public class Surefire1364SystemPropertiesIT extends SurefireJUnit4IntegrationTestCase { - @Test - public void junit3Forked() { - SurefireLauncher launcher = unpack("surefire-1364"); - OutputValidator validator = launcher.setForkJvm() - .activateProfile("junit3") - .forkOnce() - .executeTest() - .verifyErrorFree(2); - - validator - .getSurefireReportsXmlFile("TEST-FirstTest.xml") - .assertContainsText(""); - - validator - .getSurefireReportsXmlFile("TEST-SecondTest.xml") - .assertContainsText(""); - } - - @Test - public void junit3InProcess() { - SurefireLauncher launcher = unpack("surefire-1364"); - OutputValidator validator = launcher.setForkJvm() - .activateProfile("junit3") - .forkNever() - .executeTest() - .verifyErrorFree(2); - - validator - .getSurefireReportsXmlFile("TEST-FirstTest.xml") - .assertContainsText(""); - - validator - .getSurefireReportsXmlFile("TEST-SecondTest.xml") - .assertContainsText(""); - } +public class Surefire1364SystemPropertiesIT extends SurefireJUnitIntegrationTestCase { @Test public void junit4Forked() { @@ -96,84 +61,6 @@ public void junit4InProcess() { .assertContainsText(""); } - @Test - public void junit47Forked() { - SurefireLauncher launcher = unpack("surefire-1364"); - OutputValidator validator = launcher.setForkJvm() - .activateProfile("junit47") - .forkOnce() - .executeTest() - .verifyErrorFree(2); - - validator - .getSurefireReportsXmlFile("TEST-FirstTest.xml") - .assertContainsText(""); - - validator - .getSurefireReportsXmlFile("TEST-SecondTest.xml") - .assertContainsText(""); - } - - @Test - public void junit47InProcess() { - SurefireLauncher launcher = unpack("surefire-1364"); - OutputValidator validator = launcher.setForkJvm() - .activateProfile("junit47") - .forkNever() - .executeTest() - .verifyErrorFree(2); - - validator - .getSurefireReportsXmlFile("TEST-FirstTest.xml") - .assertContainsText(""); - - validator - .getSurefireReportsXmlFile("TEST-SecondTest.xml") - .assertContainsText(""); - } - - @Test - public void junit47ForkedParallel() { - SurefireLauncher launcher = unpack("surefire-1364"); - OutputValidator validator = launcher.setForkJvm() - .activateProfile("junit47") - .forkOnce() - .parallelClasses() - .threadCount(2) - .disablePerCoreThreadCount() - .executeTest() - .verifyErrorFree(2); - - validator - .getSurefireReportsXmlFile("TEST-FirstTest.xml") - .assertContainsText(""); - - validator - .getSurefireReportsXmlFile("TEST-SecondTest.xml") - .assertContainsText(""); - } - - @Test - public void junit47InProcessParallel() { - SurefireLauncher launcher = unpack("surefire-1364"); - OutputValidator validator = launcher.setForkJvm() - .activateProfile("junit47") - .forkNever() - .parallelClasses() - .threadCount(2) - .disablePerCoreThreadCount() - .executeTest() - .verifyErrorFree(2); - - validator - .getSurefireReportsXmlFile("TEST-FirstTest.xml") - .assertContainsText(""); - - validator - .getSurefireReportsXmlFile("TEST-SecondTest.xml") - .assertContainsText(""); - } - @Test public void testNg() { SurefireLauncher launcher = unpack("surefire-1364"); @@ -184,7 +71,7 @@ public void testNg() { .verifyErrorFree(3); validator - .getSurefireReportsXmlFile("TEST-TestSuite.xml") + .getSurefireReportsXmlFile("TEST-FirstTest.xml") .assertContainsText(""); } @@ -198,7 +85,7 @@ public void testNgInProcess() { .verifyErrorFree(3); validator - .getSurefireReportsXmlFile("TEST-TestSuite.xml") + .getSurefireReportsXmlFile("TEST-FirstTest.xml") .assertContainsText(""); } } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java index 32c453bbd8..f3430d730d 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -30,7 +30,7 @@ * @see SUREFIRE-1367 * @since 2.20.1 */ -public class Surefire1367AssumptionLogsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1367AssumptionLogsIT extends SurefireJUnitIntegrationTestCase { private static final String NL = System.getProperty("line.separator"); @Test diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1383ScanSessionDependenciesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1383ScanSessionDependenciesIT.java index c2b0ec0015..60a29f09dd 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1383ScanSessionDependenciesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1383ScanSessionDependenciesIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,7 +28,7 @@ * @see SUREFIRE-1383 * @since 2.22.0 */ -public class Surefire1383ScanSessionDependenciesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1383ScanSessionDependenciesIT extends SurefireJUnitIntegrationTestCase { @Test public void test() throws VerificationException { SurefireLauncher launcher = unpack("surefire-1383"); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java index cd1f3bd33e..0c498f7773 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java @@ -18,14 +18,14 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.BeforeClass; import org.junit.Test; /** * @author Jonathan Bell */ -public class Surefire1396CustomProviderClassPathIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1396CustomProviderClassPathIT extends SurefireJUnitIntegrationTestCase { @BeforeClass public static void installProvider() { unpack( diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java index f8a1fa7844..63c722af41 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java @@ -22,7 +22,7 @@ import java.io.FilenameFilter; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireVerifierException; import org.junit.BeforeClass; import org.junit.Test; @@ -34,7 +34,7 @@ * * @author Kristian Rosenvold */ -public class Surefire141PluggableProvidersIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire141PluggableProvidersIT extends SurefireJUnitIntegrationTestCase { @BeforeClass public static void installProvider() { unpack(Surefire141PluggableProvidersIT.class, "surefire-141-pluggableproviders-provider", "prov") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1426JvmCrashShouldNotBeIgnoredIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1426JvmCrashShouldNotBeIgnoredIT.java index 4e2c89c9cd..0ba5fad5ac 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1426JvmCrashShouldNotBeIgnoredIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1426JvmCrashShouldNotBeIgnoredIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.hamcrest.Matchers.containsString; @@ -29,7 +29,7 @@ * Test https://issues.apache.org/jira/browse/SUREFIRE-1426 * */ -public class Surefire1426JvmCrashShouldNotBeIgnoredIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1426JvmCrashShouldNotBeIgnoredIT extends SurefireJUnitIntegrationTestCase { @Test public void mavenShouldFail() throws VerificationException { unpack("surefire-1426-ignore-fail-jvm-crash") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire146ForkPerTestNoSetupIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire146ForkPerTestNoSetupIT.java index edd5113d8f..a9f300e907 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire146ForkPerTestNoSetupIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire146ForkPerTestNoSetupIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Dan Fabulich */ -public class Surefire146ForkPerTestNoSetupIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire146ForkPerTestNoSetupIT extends SurefireJUnitIntegrationTestCase { @Test public void testForkPerTestNoSetup() { executeErrorFreeTest("surefire-146-forkPerTestNoSetup", 1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1490ReportTitleDescriptionIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1490ReportTitleDescriptionIT.java index e49aa46242..c4bf36fc39 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1490ReportTitleDescriptionIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1490ReportTitleDescriptionIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,7 +28,7 @@ * @see SUREFIRE-1490 * @since 3.0.0-M1 */ -public class Surefire1490ReportTitleDescriptionIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1490ReportTitleDescriptionIT extends SurefireJUnitIntegrationTestCase { @Test public void shouldHaveDefaultReportTitleAndDescription() { OutputValidator validator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1535TestNGParallelSuitesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1535TestNGParallelSuitesIT.java deleted file mode 100644 index 82f9fa19c4..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1535TestNGParallelSuitesIT.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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.surefire.its.jiras; - -import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.apache.maven.surefire.its.fixture.TestFile; -import org.junit.Test; - -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; - -/** - * - */ -public class Surefire1535TestNGParallelSuitesIT extends SurefireJUnit4IntegrationTestCase { - private static final String TEST_RESULT_1 = platformEncoding("Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, "); - private static final String TEST_RESULT_2 = platformEncoding("Tests run: 2, Failures: 0, Errors: 0, Skipped: 0"); - private static final String SUITE1 = platformEncoding("Suite1"); - private static final String SUITE2 = platformEncoding("Suite2"); - private static final String TEST1 = platformEncoding("test 1"); - private static final String TEST2 = platformEncoding("test 2"); - private static final String TEST_SUITE = platformEncoding("Running TestSuite"); - - @Test - public void forks2() throws VerificationException { - OutputValidator validator = unpack().activateProfile("forked-reports-directory") - .forkCount(2) - .executeTest(); - - TestFile testFile = validator.getSurefireReportsFile("../surefire-reports-1/TEST-TestSuite.xml", UTF_8); - testFile.assertFileExists(); - testFile.assertContainsText("Dan Fabulich */ -public class Surefire162CharsetProviderIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire162CharsetProviderIT extends SurefireJUnitIntegrationTestCase { @SuppressWarnings({"ResultOfMethodCallIgnored"}) @Test public void testCharsetProvider() throws Exception { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1643IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1643IT.java index cacd1a7935..502c70587e 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1643IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1643IT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -27,7 +27,7 @@ * */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire1643IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1643IT extends SurefireJUnitIntegrationTestCase { @Test public void shouldNotMixResults() { OutputValidator outputValidator = unpack("surefire-1643-parallel-junit5") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1737IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1737IT.java index 041be27c32..57d7cea8db 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1737IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1737IT.java @@ -20,7 +20,7 @@ import java.io.File; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -30,7 +30,7 @@ /** * Integration Tests for SUREFIRE-1737 */ -public class Surefire1737IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1737IT extends SurefireJUnitIntegrationTestCase { @Test public void selectJUnit5UsingConfiguredProviderWithPlatformRunner() { SurefireLauncher launcher = unpack("surefire-1737"); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1744AlwaysIncludeOutputLogsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1744AlwaysIncludeOutputLogsIT.java index 4141670b1b..e22f22b281 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1744AlwaysIncludeOutputLogsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1744AlwaysIncludeOutputLogsIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,7 +27,7 @@ * * @author Dan Fabulich */ -public class Surefire1744AlwaysIncludeOutputLogsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1744AlwaysIncludeOutputLogsIT extends SurefireJUnitIntegrationTestCase { @Test public void testAlwaysIncludeOutputLogs() { OutputValidator outputValidator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java index 1f77524143..585730c39e 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java @@ -21,7 +21,7 @@ import javax.xml.transform.Source; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.hamcrest.collection.IsIterableWithSize; import org.junit.Test; @@ -37,7 +37,7 @@ * */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire1787JUnit5IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1787JUnit5IT extends SurefireJUnitIntegrationTestCase { @Test public void bothEngines() { @@ -91,7 +91,7 @@ public void selectJUnit5() { unpack("junit-4-5") .activateProfile("select-junit5") .executeTest() - .verifyErrorFree(1) + .verifyErrorFree(2) .verifyTextInLog("Running pkg.JUnit5Test") .verifyTextInLog( "Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider"); @@ -132,15 +132,6 @@ public void testNgWithJupiterEngine() { "Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider"); } - @Test - public void junit4Runner() { - unpack("junit5-runner") - .executeTest() - .verifyErrorFree(1) - .verifyTextInLog("Running pkg.JUnit5Tests") - .verifyTextInLog("Using auto detected provider org.apache.maven.surefire.junit4.JUnit4Provider"); - } - @Test public void junit5Suite() throws Exception { OutputValidator outputValidator = unpack("junit5-suite") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1881IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1881IT.java index 88200401be..cf89352cd4 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1881IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1881IT.java @@ -18,14 +18,14 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire1881IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1881IT extends SurefireJUnitIntegrationTestCase { @Test(timeout = 60_000L) public void test() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1914XmlReportingParameterizedTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1914XmlReportingParameterizedTestIT.java index 16042f9b9c..5da33dc808 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1914XmlReportingParameterizedTestIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1914XmlReportingParameterizedTestIT.java @@ -21,7 +21,7 @@ import java.util.Arrays; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -35,7 +35,7 @@ */ @RunWith(Parameterized.class) @SuppressWarnings("checkstyle:magicnumber") -public class Surefire1914XmlReportingParameterizedTestIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1914XmlReportingParameterizedTestIT extends SurefireJUnitIntegrationTestCase { @Parameter @SuppressWarnings("checkstyle:visibilitymodifier") public String jupiterVersion; diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1934OutErrElementsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1934OutErrElementsIT.java index 495e0d1963..b7ac2760a1 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1934OutErrElementsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1934OutErrElementsIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -28,7 +28,7 @@ * * @author NissMoony */ -public class Surefire1934OutErrElementsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1934OutErrElementsIT extends SurefireJUnitIntegrationTestCase { @Test public void testOutErrElementsDisabled() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1964IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1964IT.java index ca7b97b6c0..3cec9e975c 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1964IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1964IT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.hamcrest.Matchers.containsString; @@ -27,7 +27,7 @@ /** * */ -public class Surefire1964IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1964IT extends SurefireJUnitIntegrationTestCase { @Test public void shouldFilterTests() throws Exception { unpack("surefire-1964") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java index 0d41205d29..555127cdb2 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author findepi */ -public class Surefire1967CheckTestNgMethodParallelOrderingIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1967CheckTestNgMethodParallelOrderingIT extends SurefireJUnitIntegrationTestCase { @Test public void testNgParallelOrdering() { unpack("surefire-1967-testng-method-parallel-ordering") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1993JpmsProvidingModulesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1993JpmsProvidingModulesIT.java index b59f680f49..f17a4b3787 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1993JpmsProvidingModulesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1993JpmsProvidingModulesIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Before; import org.junit.Test; @@ -32,7 +32,7 @@ * * @author mthmulders */ -public class Surefire1993JpmsProvidingModulesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire1993JpmsProvidingModulesIT extends SurefireJUnitIntegrationTestCase { @Before public void setUp() { assumeJavaVersion(9); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2006ShadefireTransformersIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2006ShadefireTransformersIT.java index f91f1d6b0e..80443a39ce 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2006ShadefireTransformersIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2006ShadefireTransformersIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.hamcrest.Matchers.is; @@ -30,7 +30,7 @@ * * @author Slawomir Jaranowski */ -public class Surefire2006ShadefireTransformersIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire2006ShadefireTransformersIT extends SurefireJUnitIntegrationTestCase { @Test public void shadefireShouldBeUsed() throws VerificationException { unpack("surefire-2006-shadefire-transformers") @@ -41,7 +41,6 @@ public void shadefireShouldBeUsed() throws VerificationException { containsString( "[INFO] Using configured provider org.apache.maven.shadefire.surefire.junitplatform.JUnitPlatformProvider"), is(1)) - .assertThatLogLine(containsString("[INFO] Running PojoTest"), is(0)) .assertThatLogLine(containsString("[INFO] Running JUnit4Test"), is(1)) .assertThatLogLine(containsString("[INFO] Running JUnit5Test"), is(1)); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2032NestedSkippedIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2032NestedSkippedIT.java index 43d36e809e..46c8dd7171 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2032NestedSkippedIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2032NestedSkippedIT.java @@ -21,7 +21,7 @@ import javax.xml.transform.Source; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.hamcrest.MatcherAssert; import org.hamcrest.collection.IsIterableWithSize; @@ -36,7 +36,7 @@ * Integration Test for SUREFIRE-2032 */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire2032NestedSkippedIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire2032NestedSkippedIT extends SurefireJUnitIntegrationTestCase { @Test public void testXmlReport() { OutputValidator validator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2036IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2036IT.java index 2b3a4084b8..1ed66efb78 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2036IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2036IT.java @@ -18,14 +18,14 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * Integration Tests for SUREFIRE-2036 */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire2036IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire2036IT extends SurefireJUnitIntegrationTestCase { @Test public void selectJUnit5UsingConfiguredProviderWithPlatformRunner() { unpack("surefire-2036") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2065IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2065IT.java index 95a923fd75..f02f6858ab 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2065IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2065IT.java @@ -20,7 +20,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.hamcrest.Matchers; import org.junit.Test; @@ -30,7 +30,7 @@ * Integration Tests for SUREFIRE-2065 */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire2065IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire2065IT extends SurefireJUnitIntegrationTestCase { @Test public void shouldNotDetectFlakyTestsWhenCombiningJunit4And5Tests() throws VerificationException { OutputValidator validator = unpack("surefire-2065-common") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2095FailsafeJvmCrashShouldNotBeIgnoredIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2095FailsafeJvmCrashShouldNotBeIgnoredIT.java index 8004979ad3..84592bfb12 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2095FailsafeJvmCrashShouldNotBeIgnoredIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2095FailsafeJvmCrashShouldNotBeIgnoredIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.shared.verifier.VerificationException; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.hamcrest.Matchers.containsString; @@ -29,7 +29,7 @@ * Test https://issues.apache.org/jira/browse/SUREFIRE-2095 * */ -public class Surefire2095FailsafeJvmCrashShouldNotBeIgnoredIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire2095FailsafeJvmCrashShouldNotBeIgnoredIT extends SurefireJUnitIntegrationTestCase { @Test public void mavenShouldFail() throws VerificationException { // Run failsafe with testFailureIgnore=true and an unknown JVM option that will cause a crash diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2117XmlReportingNestedIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2117XmlReportingNestedIT.java index 8fcfe05442..560da964db 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2117XmlReportingNestedIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2117XmlReportingNestedIT.java @@ -21,7 +21,7 @@ import java.util.Arrays; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -35,7 +35,7 @@ */ @RunWith(Parameterized.class) @SuppressWarnings("checkstyle:magicnumber") -public class Surefire2117XmlReportingNestedIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire2117XmlReportingNestedIT extends SurefireJUnitIntegrationTestCase { @Parameter @SuppressWarnings("checkstyle:visibilitymodifier") public String jupiterVersion; diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2143ParameterizedSkippedIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2143ParameterizedSkippedIT.java index 00c60054ff..332c1a903e 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2143ParameterizedSkippedIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2143ParameterizedSkippedIT.java @@ -22,7 +22,7 @@ import java.util.List; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static java.nio.charset.StandardCharsets.UTF_8; @@ -33,7 +33,7 @@ * Integration Test for SUREFIRE-2143 */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire2143ParameterizedSkippedIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire2143ParameterizedSkippedIT extends SurefireJUnitIntegrationTestCase { @Test public void junit5ParameterizedSkipped() { OutputValidator validator = unpack("surefire-2143-junit5-parameterized-test-skipped") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java index 8f03404567..4713b0eba2 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java @@ -24,7 +24,7 @@ import org.apache.maven.plugins.surefire.report.ReportTestSuite; import org.apache.maven.surefire.its.fixture.HelperAssertions; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -34,7 +34,7 @@ * * @author Dan Fabulich */ -public class Surefire224WellFormedXmlFailuresIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire224WellFormedXmlFailuresIT extends SurefireJUnitIntegrationTestCase { @SuppressWarnings("ConstantConditions") @Test public void testWellFormedXmlFailures() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2298IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2298IT.java index f3eebb378d..eef36f8ccb 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2298IT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2298IT.java @@ -21,7 +21,7 @@ import javax.xml.transform.Source; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.hamcrest.collection.IsIterableWithSize; import org.junit.Before; @@ -37,7 +37,7 @@ * */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire2298IT extends SurefireJUnit4IntegrationTestCase { +public class Surefire2298IT extends SurefireJUnitIntegrationTestCase { @Before public void setUp() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire257NotRerunningTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire257NotRerunningTestsIT.java index 77847ba655..287637d364 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire257NotRerunningTestsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire257NotRerunningTestsIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Kristian Rosenvold */ -public class Surefire257NotRerunningTestsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire257NotRerunningTestsIT extends SurefireJUnitIntegrationTestCase { @Test public void shouldNotRerun() { unpack("/surefire-257-rerunningTests") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire260TestWithIdenticalNamesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire260TestWithIdenticalNamesIT.java index 995ec35615..2af47a82f5 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire260TestWithIdenticalNamesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire260TestWithIdenticalNamesIT.java @@ -22,7 +22,7 @@ import java.net.URI; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.htmlunit.WebClient; import org.htmlunit.html.HtmlAnchor; @@ -40,7 +40,7 @@ * @author Kristian Rosenvold */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire260TestWithIdenticalNamesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire260TestWithIdenticalNamesIT extends SurefireJUnitIntegrationTestCase { @Test public void testWithIdenticalNames() throws IOException { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire34SecurityManagerIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire34SecurityManagerIT.java deleted file mode 100644 index f4528d9a4e..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire34SecurityManagerIT.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.surefire.its.jiras; - -import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.apache.maven.surefire.its.fixture.TestFile; -import org.junit.Test; - -import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaMaxVersion; -import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion; -import static org.assertj.core.api.Assertions.assertThat; - -/** - * SUREFIRE-621 Asserts proper test counts when running junit 3 tests in parallel - * - * @author Kristian Rosenvold - */ -@SuppressWarnings("checkstyle:magicnumber") -public class Surefire34SecurityManagerIT extends SurefireJUnit4IntegrationTestCase { - @Test - public void testSecurityManager() { - assumeJavaMaxVersion(17); - SurefireLauncher surefireLauncher = - unpack("surefire-34-securityManager").failNever(); - surefireLauncher.executeTest().assertTestSuiteResults(2, 1, 0, 0); - } - - @Test - public void testSecurityManagerSuccessful() { - assumeJavaMaxVersion(17); - SurefireLauncher surefireLauncher = unpack("surefire-34-securityManager-success"); - surefireLauncher.executeTest().assertTestSuiteResults(2, 0, 0, 0); - } - - @Test - public void shouldFailOnJDK() { - assumeJavaVersion(18); - - OutputValidator validator = unpack("surefire-34-securityManager") - .failNever() - .executeTest() - .verifyTextInLog("JDK does not support overriding Security Manager with " - + "a value in system property 'surefire.security.manager'."); - - TestFile xmlReport = validator.getSurefireReportsFile("junit4.SecurityManagerTest.xml"); - - assertThat(xmlReport.exists()) - .describedAs("junit4.SecurityManagerTest.xml should not exist. " - + "The provider should fail before starting any test.") - .isFalse(); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java index a71e55f401..11a825abee 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,13 +26,12 @@ * * @author Dan Fabulich */ -public class Surefire376TestNgAfterSuiteFailureIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire376TestNgAfterSuiteFailureIT extends SurefireJUnitIntegrationTestCase { @Test public void testAfterSuiteFailure() { unpack("/testng-afterSuiteFailure") .maven() - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .withFailure() .executeTest() .assertTestSuiteResults(2, 0, 1, 0); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java index 1557495e49..2d9f500ac7 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,12 +26,11 @@ * * @author Dan Fabulich */ -public class Surefire377TestNgAndJUnitTogetherIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire377TestNgAndJUnitTogetherIT extends SurefireJUnitIntegrationTestCase { @Test public void testTestNgAndJUnitTogether() { unpack("/testng-junit-together") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .executeTest() .verifyErrorFree(2); } @@ -39,8 +38,7 @@ public void testTestNgAndJUnitTogether() { @Test public void testTestNgAndJUnit4Together() { unpack("/testng-junit4-together") - .sysProp("testNgVersion", "5.7") - .sysProp("testNgClassifier", "jdk15") + .sysProp("testNgVersion", "6.14.3") .executeTest() .verifyErrorFree(3); } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java index 054805975b..3e388a4221 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Kristian Rosenvold */ -public class Surefire408ManualProviderSelectionIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire408ManualProviderSelectionIT extends SurefireJUnitIntegrationTestCase { @Test public void testParallelBuildResultCount() { unpack("/surefire-408-manual-provider-selection") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire44InnerClassTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire412InnerClassTestIT.java similarity index 88% rename from surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire44InnerClassTestIT.java rename to surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire412InnerClassTestIT.java index 2421cf28f9..e5fc2aabaa 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire44InnerClassTestIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire412InnerClassTestIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Dan Fabulich */ -public class Surefire44InnerClassTestIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire412InnerClassTestIT extends SurefireJUnitIntegrationTestCase { @Test public void testInnerClass() { executeErrorFreeTest("/junit-innerClass", 1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire42NotExtendingTestCaseIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire42NotExtendingTestCaseIT.java index 12edcaa6a4..25117fb549 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire42NotExtendingTestCaseIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire42NotExtendingTestCaseIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Dan Fabulich */ -public class Surefire42NotExtendingTestCaseIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire42NotExtendingTestCaseIT extends SurefireJUnitIntegrationTestCase { @Test public void testInnerClass() { executeErrorFreeTest("junit-notExtendingTestCase", 1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire500PuzzlingErrorIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire500PuzzlingErrorIT.java index b1e4b2e9f9..aa651d0da6 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire500PuzzlingErrorIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire500PuzzlingErrorIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -28,7 +28,7 @@ * * @author Kristian Rosenvold */ -public class Surefire500PuzzlingErrorIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire500PuzzlingErrorIT extends SurefireJUnitIntegrationTestCase { @Test public void testBuildFailingWhenErrors() { OutputValidator outputValidator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire510TestClassPathForkModesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire510TestClassPathForkModesIT.java index 1bd0e32d96..bc8b21fcce 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire510TestClassPathForkModesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire510TestClassPathForkModesIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -27,7 +27,7 @@ * * @author Kristian Rosenvold */ -public class Surefire510TestClassPathForkModesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire510TestClassPathForkModesIT extends SurefireJUnitIntegrationTestCase { @Test public void testForkAlways() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java index 3161e88530..2e7bebe7a8 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -28,7 +28,7 @@ * * @author Aslak Knutsen */ -public class Surefire569RunTestFromDependencyJarsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire569RunTestFromDependencyJarsIT extends SurefireJUnitIntegrationTestCase { @Test public void shouldScanAndRunTestsInDependencyJars() throws Exception { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire570MultipleReportDirectoriesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire570MultipleReportDirectoriesIT.java index 516153e0d6..b96d4ec8cf 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire570MultipleReportDirectoriesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire570MultipleReportDirectoriesIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -29,7 +29,7 @@ * * @author Kristian Rosenvold */ -public class Surefire570MultipleReportDirectoriesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire570MultipleReportDirectoriesIT extends SurefireJUnitIntegrationTestCase { @Test public void testReportWithAggregate() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire613TestCountInParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire613TestCountInParallelIT.java index 731c23deba..2d896cbc58 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire613TestCountInParallelIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire613TestCountInParallelIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -28,7 +28,7 @@ * @author Kristian Rosenvold */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire613TestCountInParallelIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire613TestCountInParallelIT extends SurefireJUnitIntegrationTestCase { @Test public void testParallelBuildResultCount() { OutputValidator validator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire621TestCountingJunit3InParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire621TestCountingJunit3InParallelIT.java index 496283f0e7..09c6c531d1 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire621TestCountingJunit3InParallelIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire621TestCountingJunit3InParallelIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -31,7 +31,7 @@ * @author Kristian Rosenvold * @author Tibor Digana (tibor17) */ -public class Surefire621TestCountingJunit3InParallelIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire621TestCountingJunit3InParallelIT extends SurefireJUnitIntegrationTestCase { /** * SUREFIRE-1264 */ diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire628ConsoleOutputBeforeAndAfterClassIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire628ConsoleOutputBeforeAndAfterClassIT.java index 45f662b1e0..da070b31e1 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire628ConsoleOutputBeforeAndAfterClassIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire628ConsoleOutputBeforeAndAfterClassIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,7 +27,7 @@ * * @author Kristian Rosenvold assertContainsText */ -public class Surefire628ConsoleOutputBeforeAndAfterClassIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire628ConsoleOutputBeforeAndAfterClassIT extends SurefireJUnitIntegrationTestCase { @Test public void testJunit3ParallelBuildResultCount() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire634UnsettableSystemPropertiesWarningIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire634UnsettableSystemPropertiesWarningIT.java index bb82cccbf6..6927bfe43d 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire634UnsettableSystemPropertiesWarningIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire634UnsettableSystemPropertiesWarningIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Kristian Rosenvold */ -public class Surefire634UnsettableSystemPropertiesWarningIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire634UnsettableSystemPropertiesWarningIT extends SurefireJUnitIntegrationTestCase { @Test public void testJunit3ParallelBuildResultCount() { unpack("/surefire-634-systemPropertiesWarning") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire649EmptyStringSystemPropertiesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire649EmptyStringSystemPropertiesIT.java index e0108dfa96..bc5ab449bf 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire649EmptyStringSystemPropertiesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire649EmptyStringSystemPropertiesIT.java @@ -20,7 +20,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -31,7 +31,7 @@ * @see SUREFIRE-649 * @since 2.18 */ -public class Surefire649EmptyStringSystemPropertiesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire649EmptyStringSystemPropertiesIT extends SurefireJUnitIntegrationTestCase { @Test public void systemProperties() throws VerificationException { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire673MockitoIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire673MockitoIT.java index 47866e56b7..5965332950 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire673MockitoIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire673MockitoIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -27,7 +27,7 @@ * @author Kristian Rosenvold */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire673MockitoIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire673MockitoIT extends SurefireJUnitIntegrationTestCase { @Test public void testBuildFailingWhenErrors() { unpack("/surefire-673-mockito").executeTest().assertTestSuiteResults(1, 0, 0, 0); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire674BuildFailingWhenErrorsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire674BuildFailingWhenErrorsIT.java index 5e318d6967..24e018fdea 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire674BuildFailingWhenErrorsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire674BuildFailingWhenErrorsIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Kristian Rosenvold */ -public class Surefire674BuildFailingWhenErrorsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire674BuildFailingWhenErrorsIT extends SurefireJUnitIntegrationTestCase { @Test public void testBuildFailingWhenErrors() { unpack("/surefire-674-buildFailingWhenErrors") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire674BuildFailingWhenFailsafeErrorsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire674BuildFailingWhenFailsafeErrorsIT.java index 3980eef344..bd76b810e2 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire674BuildFailingWhenFailsafeErrorsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire674BuildFailingWhenFailsafeErrorsIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Kristian Rosenvold */ -public class Surefire674BuildFailingWhenFailsafeErrorsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire674BuildFailingWhenFailsafeErrorsIT extends SurefireJUnitIntegrationTestCase { @Test public void testBuildFailingWhenErrors() { unpack("/failsafe-buildfail").maven().withFailure().executeVerify().verifyTextInLog("BUILD FAILURE"); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire685CommaSeparatedIncludesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire685CommaSeparatedIncludesIT.java index 887a4657be..e8b310adbc 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire685CommaSeparatedIncludesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire685CommaSeparatedIncludesIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Kristian Rosenvold */ -public class Surefire685CommaSeparatedIncludesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire685CommaSeparatedIncludesIT extends SurefireJUnitIntegrationTestCase { @Test public void testBuildFailingWhenErrors() { executeErrorFreeTest("/surefire-685-commaseparatedIncludes", 2); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire697NiceSummaryIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire697NiceSummaryIT.java index 2a7e914bbb..003f38da4c 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire697NiceSummaryIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire697NiceSummaryIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,12 +26,16 @@ * * @author Kristian Rosenvold */ -public class Surefire697NiceSummaryIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire697NiceSummaryIT extends SurefireJUnitIntegrationTestCase { @Test public void testBuildFailingWhenErrors() { unpack("/surefire-697-niceSummary") - .failNever() + .maven() + .withFailure() .executeTest() - .verifyTextInLog("junit.surefire697.BasicTest#testShortMultiline RuntimeException A very short m"); + .verifyTextInLog("junit.surefire697.BasicTest.testShortMultiline") + // testing multiline log would be more accurate but this approach avoids line ending issues + .verifyTextInLog("java.lang.RuntimeException:") + .verifyTextInLog("A very short m"); } } diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire705ParallelForkTimeoutIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire705ParallelForkTimeoutIT.java index 2f9e79a49f..b5ff5f7564 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire705ParallelForkTimeoutIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire705ParallelForkTimeoutIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,12 +26,12 @@ * * @author Kristian Rosenvold */ -public class Surefire705ParallelForkTimeoutIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire705ParallelForkTimeoutIT extends SurefireJUnitIntegrationTestCase { @Test public void testTimeoutForked() { unpack("/fork-timeout") - .setJUnitVersion("4.8.1") - .addGoal("-Djunit.version=4.8.1") + .setJUnitVersion("4.12") + .addGoal("-Djunit.version=4.12") .addGoal("-Djunit.parallel=classes") .addGoal("-DtimeOut=1") .maven() diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire733AllOverrridesCapturedIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire733AllOverrridesCapturedIT.java index 14c42df301..47bc67a752 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire733AllOverrridesCapturedIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire733AllOverrridesCapturedIT.java @@ -18,13 +18,13 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * @author Kristian Rosenvold */ -public class Surefire733AllOverrridesCapturedIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire733AllOverrridesCapturedIT extends SurefireJUnitIntegrationTestCase { @Test public void testLogOutput() { unpack("surefire-733-allOverridesCaptured").executeTest().verifyTextInLog("abc"); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java index 38bdeff1c6..3830bb06d2 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire735ForkFailWithRedirectConsoleOutputIT.java @@ -24,7 +24,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -34,7 +34,7 @@ /** * @author Kristian Rosenvold */ -public class Surefire735ForkFailWithRedirectConsoleOutputIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire735ForkFailWithRedirectConsoleOutputIT extends SurefireJUnitIntegrationTestCase { @Test public void vmStartFail() throws VerificationException { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java index e0137ac682..d9367d9d3b 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -30,7 +30,7 @@ * * @author Kristian Rosenvold */ -public class Surefire740TruncatedCommaIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire740TruncatedCommaIT extends SurefireJUnitIntegrationTestCase { @Test public void testRussianLocaleReport() { OutputValidator validator = unpack("/surefire-740-comma-truncated") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772BothReportsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772BothReportsIT.java index 8fbfa01dc1..958fa0fc23 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772BothReportsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772BothReportsIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -32,7 +32,7 @@ * * @author Kristian Rosenvold */ -public class Surefire772BothReportsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire772BothReportsIT extends SurefireJUnitIntegrationTestCase { public SurefireLauncher unpack() { SurefireLauncher unpack = unpack("/surefire-772-both-reports"); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoFailsafeReportsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoFailsafeReportsIT.java index ce536591e2..fe44e58c71 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoFailsafeReportsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoFailsafeReportsIT.java @@ -20,7 +20,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -33,7 +33,7 @@ * * @author Kristian Rosenvold */ -public class Surefire772NoFailsafeReportsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire772NoFailsafeReportsIT extends SurefireJUnitIntegrationTestCase { @Test public void testReportGeneration() throws Exception { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoSurefireReportsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoSurefireReportsIT.java index 4ca1b4366a..34b21ecf78 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoSurefireReportsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772NoSurefireReportsIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -32,7 +32,7 @@ * * @author Kristian Rosenvold */ -public class Surefire772NoSurefireReportsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire772NoSurefireReportsIT extends SurefireJUnitIntegrationTestCase { @Test public void testReportGeneration() { OutputValidator validator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772SpecifiedReportsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772SpecifiedReportsIT.java index 405fd452b1..22241a7d19 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772SpecifiedReportsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire772SpecifiedReportsIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -32,7 +32,7 @@ * * @author Kristian Rosenvold */ -public class Surefire772SpecifiedReportsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire772SpecifiedReportsIT extends SurefireJUnitIntegrationTestCase { @Test public void testReportGeneration() { OutputValidator validator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire801ForkNeverClassLoaderIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire801ForkNeverClassLoaderIT.java index 194d302d26..c133fa2868 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire801ForkNeverClassLoaderIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire801ForkNeverClassLoaderIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Kristian Rosenvold */ -public class Surefire801ForkNeverClassLoaderIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire801ForkNeverClassLoaderIT extends SurefireJUnitIntegrationTestCase { @Test public void testShouldBeOkWithForkNever() { unpack("fork-count-resource-loading").forkNever().executeTest(); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire803MultiFailsafeExecsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire803MultiFailsafeExecsIT.java index c8876a8a3d..fb7e15f82b 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire803MultiFailsafeExecsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire803MultiFailsafeExecsIT.java @@ -18,14 +18,14 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; /** * */ -public class Surefire803MultiFailsafeExecsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire803MultiFailsafeExecsIT extends SurefireJUnitIntegrationTestCase { @Test public void testSecondExecutionRunsAfterFirstExecutionFails() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire806SpecifiedTestControlsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire806SpecifiedTestControlsIT.java index 0ab8ce8ac4..a211b84bcd 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire806SpecifiedTestControlsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire806SpecifiedTestControlsIT.java @@ -18,14 +18,14 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Ignore; import org.junit.Test; /** * */ -public class Surefire806SpecifiedTestControlsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire806SpecifiedTestControlsIT extends SurefireJUnitIntegrationTestCase { @Test @Ignore("since SUREFIRE-1153 the includes/excludes are overridden by -Dtest or it.test for whatever execution") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire809GroupExpressionsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire809GroupExpressionsIT.java deleted file mode 100755 index 1e618541db..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire809GroupExpressionsIT.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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.surefire.its.jiras; - -import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.junit.Test; - -/** - * - */ -public class Surefire809GroupExpressionsIT extends SurefireJUnit4IntegrationTestCase { - @Test - public void categoryAB() { - OutputValidator validator = - unpackJUnit().groups("junit4.CategoryA AND junit4.CategoryB").executeTest(); - validator.verifyErrorFreeLog(); - validator.assertTestSuiteResults(2, 0, 0, 0); - validator.verifyTextInLog("catA: 1"); - validator.verifyTextInLog("catB: 1"); - validator.verifyTextInLog("catC: 0"); - validator.verifyTextInLog("catNone: 0"); - validator.verifyTextInLog("mA: 1"); - validator.verifyTextInLog("mB: 1"); - validator.verifyTextInLog("mC: 0"); - } - - @Test - public void incorrectJUnitVersions() { - unpackJUnit() - .setJUnitVersion("4.5") - .groups("junit4.CategoryA AND junit4.CategoryB") - .maven() - .withFailure() - .executeTest(); - } - - @Test - public void testJUnitRunCategoryNotC() { - OutputValidator validator = unpackJUnit().groups("!junit4.CategoryC").executeTest(); - validator.verifyErrorFreeLog(); - validator.assertTestSuiteResults(5, 0, 0, 0); - validator.verifyTextInLog("catA: 2"); - validator.verifyTextInLog("catB: 2"); - validator.verifyTextInLog("catC: 0"); - validator.verifyTextInLog("catNone: 1"); - validator.verifyTextInLog("NoCategoryTest.CatNone: 1"); - } - - @Test - public void testExcludedGroups() { - OutputValidator validator = - unpackJUnit().setExcludedGroups("junit4.CategoryC").executeTest(); - validator.verifyErrorFreeLog(); - validator.assertTestSuiteResults(5, 0, 0, 0); - validator.verifyTextInLog("catA: 2"); - validator.verifyTextInLog("catB: 2"); - validator.verifyTextInLog("catC: 0"); - validator.verifyTextInLog("catNone: 1"); - validator.verifyTextInLog("NoCategoryTest.CatNone: 1"); - } - - @Test - public void testNGRunCategoryAB() { - OutputValidator validator = - unpackTestNG().groups("CategoryA AND CategoryB").debugLogging().executeTest(); - validator.verifyErrorFreeLog(); - validator.assertTestSuiteResults(2, 0, 0, 0); - validator.verifyTextInLog("BasicTest.testInCategoriesAB()"); - validator.verifyTextInLog("CategoryCTest.testInCategoriesAB()"); - } - - @Test - public void testNGRunCategoryNotC() { - OutputValidator validator = - unpackTestNG().groups("!CategoryC").debugLogging().executeTest(); - validator.verifyErrorFreeLog(); - validator.assertTestSuiteResults(8, 0, 0, 0); - validator.verifyTextInLog("catA: 2"); - validator.verifyTextInLog("catB: 2"); - validator.verifyTextInLog("catC: 0"); - validator.verifyTextInLog("catNone: 1"); - validator.verifyTextInLog("mA: 2"); - validator.verifyTextInLog("mB: 2"); - validator.verifyTextInLog("mC: 0"); - validator.verifyTextInLog("NoCategoryTest.CatNone: 1"); - } - - private SurefireLauncher unpackJUnit() { - return unpack("surefire-809-groupExpr-junit48"); - } - - private SurefireLauncher unpackTestNG() { - return unpack("surefire-809-groupExpr-testng"); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire812Log4JClassLoaderIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire812Log4JClassLoaderIT.java index a753546e98..c930e9f162 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire812Log4JClassLoaderIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire812Log4JClassLoaderIT.java @@ -18,13 +18,13 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * @author Kristian Rosenvold */ -public class Surefire812Log4JClassLoaderIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire812Log4JClassLoaderIT extends SurefireJUnitIntegrationTestCase { @Test public void testJunit3ParallelBuildResultCount() { executeErrorFreeTest("surefire-812-log4j-classloader", 1); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire817SystemExitIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire817SystemExitIT.java index 77692f0f60..bae82ed192 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire817SystemExitIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire817SystemExitIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -27,7 +27,7 @@ * @see SUREFIRE-817 * @since 2.18 */ -public class Surefire817SystemExitIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire817SystemExitIT extends SurefireJUnitIntegrationTestCase { @Test public void systemExit1() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire818NpeIgnoresTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire818NpeIgnoresTestsIT.java index 78d77be2c1..f29a96863f 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire818NpeIgnoresTestsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire818NpeIgnoresTestsIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * * @author Kristian Rosenvold */ -public class Surefire818NpeIgnoresTestsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire818NpeIgnoresTestsIT extends SurefireJUnitIntegrationTestCase { @Test public void testBuildFailingWhenErrors() { unpack("surefire-818-ignored-tests-on-npe") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java deleted file mode 100644 index bb799a15cd..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.surefire.its.jiras; - -import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.junit.Test; - -/** - * - */ -public class Surefire828EmptyGroupExprIT extends SurefireJUnit4IntegrationTestCase { - // !CategoryC - @Test - public void testJUnitRunEmptyGroups() { - OutputValidator validator = - unpackJUnit().sysProp("profile", "emptyGroups").executeTest(); - validator.verifyErrorFreeLog(); - validator.assertTestSuiteResults(5, 0, 0, 0); - validator.verifyTextInLog("catA: 2"); - validator.verifyTextInLog("catB: 2"); - validator.verifyTextInLog("catC: 0"); - validator.verifyTextInLog("catNone: 1"); - validator.verifyTextInLog("NoCategoryTest.CatNone: 1"); - } - - // CategoryA && CategoryB - @Test - public void testJUnitRunEmptyExcludeGroups() { - OutputValidator validator = - unpackJUnit().sysProp("profile", "emptyExcludedGroups").executeTest(); - validator.verifyErrorFreeLog(); - validator.assertTestSuiteResults(2, 0, 0, 0); - validator.verifyTextInLog("catA: 1"); - validator.verifyTextInLog("catB: 1"); - validator.verifyTextInLog("catC: 0"); - validator.verifyTextInLog("catNone: 0"); - validator.verifyTextInLog("mA: 1"); - validator.verifyTextInLog("mB: 1"); - validator.verifyTextInLog("mC: 0"); - } - - // CategoryA && CategoryB - @Test - public void testTestNGRunEmptyExcludeGroups() { - OutputValidator validator = - unpackTestNG().sysProp("profile", "emptyExcludedGroups").executeTest(); - validator.verifyErrorFreeLog(); - validator.assertTestSuiteResults(2, 0, 0, 0); - validator.verifyTextInLog("BasicTest.testInCategoriesAB()"); - validator.verifyTextInLog("CategoryCTest.testInCategoriesAB()"); - } - - // !CategoryC - @Test - public void testTestNGRunEmptyGroups() { - OutputValidator validator = - unpackTestNG().sysProp("profile", "emptyGroups").executeTest(); - validator.verifyErrorFreeLog(); - validator.assertTestSuiteResults(8, 0, 0, 0); - validator.verifyTextInLog("catA: 2"); - validator.verifyTextInLog("catB: 2"); - validator.verifyTextInLog("catC: 0"); - validator.verifyTextInLog("catNone: 1"); - validator.verifyTextInLog("mA: 2"); - validator.verifyTextInLog("mB: 2"); - validator.verifyTextInLog("mC: 0"); - validator.verifyTextInLog("NoCategoryTest.CatNone: 1"); - } - - private SurefireLauncher unpackJUnit() { - return unpack("surefire-828-emptyGroupExpr-junit48"); - } - - private SurefireLauncher unpackTestNG() { - return unpack("surefire-828-emptyGroupExpr-testng"); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire832ProviderSelectionIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire832ProviderSelectionIT.java index 5f7294e8b2..4a19cc1c6d 100755 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire832ProviderSelectionIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire832ProviderSelectionIT.java @@ -19,14 +19,14 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; /** * */ -public class Surefire832ProviderSelectionIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire832ProviderSelectionIT extends SurefireJUnitIntegrationTestCase { @Test public void testJUnitRunCategoryAB() { OutputValidator validator = diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire839TestWithoutCategoriesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire839TestWithoutCategoriesIT.java index 4bf247feab..9f404aa825 100755 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire839TestWithoutCategoriesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire839TestWithoutCategoriesIT.java @@ -18,23 +18,23 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * */ -public class Surefire839TestWithoutCategoriesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire839TestWithoutCategoriesIT extends SurefireJUnitIntegrationTestCase { @Test public void classWithoutCategory() { - unpack("junit48-categories").setJUnitVersion("4.11").executeTest().verifyErrorFree(3); + unpack("junit48-categories").setJUnitVersion("4.12").executeTest().verifyErrorFree(3); } @Test public void classWithoutCategoryForked() { int threadCount = 2; unpack("junit48-categories") - .setJUnitVersion("4.11") + .setJUnitVersion("4.12") .forkPerThread(threadCount) .threadCount(threadCount) .executeTest() diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire847AdditionalFailureIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire847AdditionalFailureIT.java index 92868af237..c934729667 100755 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire847AdditionalFailureIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire847AdditionalFailureIT.java @@ -18,13 +18,13 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * */ -public class Surefire847AdditionalFailureIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire847AdditionalFailureIT extends SurefireJUnitIntegrationTestCase { @Test public void testJUnitRunCategoryAB() { unpack("surefire-847-testngfail") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire855AllowFailsafeUseArtifactFileIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire855AllowFailsafeUseArtifactFileIT.java index a87ce3bcda..4061158dfc 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire855AllowFailsafeUseArtifactFileIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire855AllowFailsafeUseArtifactFileIT.java @@ -18,7 +18,7 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** @@ -26,7 +26,7 @@ * @see SUREFIRE-855 * @since 2.19 */ -public class Surefire855AllowFailsafeUseArtifactFileIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire855AllowFailsafeUseArtifactFileIT extends SurefireJUnitIntegrationTestCase { @Test public void warShouldUseClasses() { unpack("surefire-855-failsafe-use-war").maven().executeVerify().verifyErrorFree(2); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire901MIssingResultfileWhenNoTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire901MIssingResultfileWhenNoTestsIT.java index d4c4333827..ed5c2485a8 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire901MIssingResultfileWhenNoTestsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire901MIssingResultfileWhenNoTestsIT.java @@ -18,14 +18,14 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * Failsafe should work with early return when no tests * s */ -public class Surefire901MIssingResultfileWhenNoTestsIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire901MIssingResultfileWhenNoTestsIT extends SurefireJUnitIntegrationTestCase { @Test public void failsafeWithNoTests() { unpack("failsafe-notests").executeVerify(); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java index c8b9af7e2d..19ea8e8084 100755 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java @@ -19,13 +19,13 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * */ -public class Surefire920TestFailureIgnoreWithTimeoutIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire920TestFailureIgnoreWithTimeoutIT extends SurefireJUnitIntegrationTestCase { @Test public void timeoutInForkWithBuildFail() { OutputValidator validator = unpack("fork-timeout") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire926FailureWith2ProvidersIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire926FailureWith2ProvidersIT.java index deb1908faf..752a9782f9 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire926FailureWith2ProvidersIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire926FailureWith2ProvidersIT.java @@ -18,13 +18,13 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * @author Kristian Rosenvold */ -public class Surefire926FailureWith2ProvidersIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire926FailureWith2ProvidersIT extends SurefireJUnitIntegrationTestCase { @Test public void testBuildFailingWhenErrors() { unpack("surefire-926-2-provider-failure").maven().withFailure().executeTest(); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire930TestNgSuiteXmlIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire930TestNgSuiteXmlIT.java deleted file mode 100644 index 34f8fbeaec..0000000000 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire930TestNgSuiteXmlIT.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.surefire.its.jiras; - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.junit.Test; - -/** - * - */ -public class Surefire930TestNgSuiteXmlIT extends SurefireJUnit4IntegrationTestCase { - - @Test - public void suiteXmlRun() { - unpack("surefire-930-failsafe-runtests") - .maven() - .withFailure() - .executeVerify() - .assertIntegrationTestSuiteResults(1, 0, 1, 0); - } -} diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java index 9e1361e446..6cda54bd91 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java @@ -23,14 +23,14 @@ import org.apache.maven.shared.utils.xml.Xpp3Dom; import org.apache.maven.shared.utils.xml.Xpp3DomBuilder; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Assert; import org.junit.Test; /** * */ -public class Surefire943ReportContentIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire943ReportContentIT extends SurefireJUnitIntegrationTestCase { @Test @SuppressWarnings("checkstyle:methodname") @@ -52,7 +52,7 @@ private void doTest(String parallelMode) throws Exception { .withFailure() .executeTest(); - validator.assertTestSuiteResults(10, 1, 3, 3); + validator.assertTestSuiteResults(11, 1, 3, 4); validate(validator, "org.sample.module.My1Test", 1); validate(validator, "org.sample.module.My2Test", 1); @@ -88,12 +88,13 @@ private void validateFailInBeforeClass(OutputValidator validator, String classNa private void validateSkipped(OutputValidator validator, String className) throws FileNotFoundException { Xpp3Dom[] children = readTests(validator, className); - Assert.assertEquals(1, children.length); + Assert.assertEquals(2, children.length); Xpp3Dom child = children[0]; Assert.assertEquals(className, child.getAttribute("classname")); - Assert.assertEquals("", child.getAttribute("name")); + Assert.assertEquals("alsoIgnored", child.getAttribute("name")); + Assert.assertEquals(1, child.getChildren("skipped").length); Assert.assertEquals( "Expected skipped tag for ignored method for " + className, 1, child.getChildren("skipped").length); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire946KillMainProcessInReusableForkIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire946KillMainProcessInReusableForkIT.java index a1e39a8cbd..5ba1f8d4cb 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire946KillMainProcessInReusableForkIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire946KillMainProcessInReusableForkIT.java @@ -25,7 +25,7 @@ import java.io.File; import java.util.ArrayList; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -42,7 +42,7 @@ */ @RunWith(Parameterized.class) @SuppressWarnings("checkstyle:magicnumber") -public class Surefire946KillMainProcessInReusableForkIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire946KillMainProcessInReusableForkIT extends SurefireJUnitIntegrationTestCase { // there are 10 test classes that each would wait 3.5 seconds. private static final int TEST_SLEEP_TIME = 3_500; diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire972BizarreNoClassDefIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire972BizarreNoClassDefIT.java index b42a1befa2..abf9f9ea21 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire972BizarreNoClassDefIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire972BizarreNoClassDefIT.java @@ -18,13 +18,13 @@ */ package org.apache.maven.surefire.its.jiras; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * */ -public class Surefire972BizarreNoClassDefIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire972BizarreNoClassDefIT extends SurefireJUnitIntegrationTestCase { @Test public void testJunit3ParallelBuildResultCount() { unpack("surefire-972-bizarre-noclassdef").maven().withFailure().executeVerify(); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire975DefaultVMEncodingIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire975DefaultVMEncodingIT.java index 1a578bfdb5..aa49b6687e 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire975DefaultVMEncodingIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire975DefaultVMEncodingIT.java @@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; import static org.apache.maven.surefire.its.fixture.HelperAssertions.convertUnicodeToUTF8; @@ -27,7 +27,7 @@ /** * */ -public class Surefire975DefaultVMEncodingIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire975DefaultVMEncodingIT extends SurefireJUnitIntegrationTestCase { @Test public void runWithRussian1251() { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire979WrongClassLoaderIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire979WrongClassLoaderIT.java index 780fc3997a..7191252acf 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire979WrongClassLoaderIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire979WrongClassLoaderIT.java @@ -19,13 +19,13 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.junit.Test; /** * */ -public class Surefire979WrongClassLoaderIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire979WrongClassLoaderIT extends SurefireJUnitIntegrationTestCase { @Test public void wrongClassloaderUSedInSmartStacktraceparser() { OutputValidator outputValidator = unpack("surefire-979-smartStackTrace-wrongClassloader") diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire985ParameterizedRunnerAndCategoriesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire985ParameterizedRunnerAndCategoriesIT.java index 55fa12dfe6..bf4a20e31a 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire985ParameterizedRunnerAndCategoriesIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire985ParameterizedRunnerAndCategoriesIT.java @@ -23,7 +23,7 @@ import org.apache.maven.shared.utils.xml.Xpp3Dom; import org.apache.maven.shared.utils.xml.Xpp3DomBuilder; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; @@ -34,7 +34,7 @@ /** * */ -public class Surefire985ParameterizedRunnerAndCategoriesIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire985ParameterizedRunnerAndCategoriesIT extends SurefireJUnitIntegrationTestCase { @Test public void test() throws Exception { diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire995CategoryInheritanceIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire995CategoryInheritanceIT.java index a6d5fcd5ce..f07463c1e7 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire995CategoryInheritanceIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire995CategoryInheritanceIT.java @@ -20,7 +20,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -32,7 +32,7 @@ * @see SUREFIRE-995 * @since 2.18.1 */ -public class Surefire995CategoryInheritanceIT extends SurefireJUnit4IntegrationTestCase { +public class Surefire995CategoryInheritanceIT extends SurefireJUnitIntegrationTestCase { @Test public void negativeTestShouldRunAllCategories() { @@ -40,26 +40,27 @@ public void negativeTestShouldRunAllCategories() { } @Test - public void junit411ShouldRunExplicitCategory() { + public void junit4xShouldRunExplicitCategory() { final OutputValidator outputValidator = unpack().addGoal("-Ppositive-tests") - .sysProp("version.junit", "4.11") + .sysProp("version.junit", "4.12") .executeTest(); - outputValidator.verifyErrorFree(1).verifyTextInLog("CategorizedTest#a"); + outputValidator + .verifyErrorFree(3) + .verifyTextInLog("CategorizedTest#a") + .verifyTextInLog("SpecialCategorizedTest#b"); } @Test - public void junit411ShouldExcludeExplicitCategory() { + public void junit4xShouldExcludeExplicitCategory() throws VerificationException { final OutputValidator outputValidator = unpack().addGoal("-Ppositive-tests-excluded-categories") - .sysProp("version.junit", "4.11") + .sysProp("version.junit", "4.12") .executeTest(); - // SpecialCategorizedTest inherits the excluded annotation but should still run as - // until junit 4.11, the Category annotation is not inherited - outputValidator.verifyTextInLog("SpecialCategorizedTest#b").verifyErrorFree(16); + outputValidator.verifyTextNotInLog("SpecialCategorizedTest#b").verifyErrorFree(14); } @Test - public void junit412ShouldRunInheritedCategory() { + public void junit4xShouldRunInheritedCategory() { unpack().setTestToRun("Special*Test") .addGoal("-Ppositive-tests") .executeTest() @@ -67,7 +68,7 @@ public void junit412ShouldRunInheritedCategory() { } @Test - public void junit412ShouldExcludeInheritedCategory() { + public void junit4xShouldExcludeInheritedCategory() { unpack().setTestToRun("Special*Test") .addGoal("-Ppositive-tests-excluded-categories") .executeTest() @@ -76,10 +77,9 @@ public void junit412ShouldExcludeInheritedCategory() { } @Test - public void junit411ShouldIgnoreInheritedCategories() throws VerificationException { - // GIVEN a project using junit 4.11 + public void junit4xShouldRunInheritedCategories() throws VerificationException { final OutputValidator outputValidator = unpack().addGoal("-Ppositive-tests-included-and-excluded-categories") - .sysProp("version.junit", "4.11") + .sysProp("version.junit", "4.12") // AND the tests marked with CategoryB are marked for execution .setGroups("jiras.surefire955.group.marker.CategoryB") // WHEN the tests are executed @@ -94,14 +94,13 @@ public void junit411ShouldIgnoreInheritedCategories() throws VerificationExcepti .verifyTextInLog("AbstractCTest#pc") .verifyTextInLog("Running jiras.surefire955.group.BTest") .verifyTextInLog("BTest#b") - // Test does not run when there is no category in the concrete class - .assertThatLogLine(containsString("BCTest#bc"), is(0)) + .assertThatLogLine(containsString("BCTest#bc"), is(1)) .assertThatLogLine(containsString("ABCTest#abc"), is(0)) - .verifyErrorFree(4); + .verifyErrorFree(7); } @Test - public void junit412ShouldExecuteInheritedCategories() { + public void junit4xShouldExecuteInheritedCategories() { // GIVEN a project using junit 4.12 final OutputValidator outputValidator = unpack().addGoal("-Ppositive-tests-included-and-excluded-categories") .sysProp("version.junit", "4.12") @@ -112,7 +111,7 @@ public void junit412ShouldExecuteInheritedCategories() { // THEN the tests in classes directly marked with the CategoryB outputValidator - .verifyErrorFree(10) + .verifyErrorFree(7) .verifyTextInLog("Running jiras.surefire955.group.BBCTest") // AND Test runs when an already existing category is added in the concrete class .verifyTextInLog("BBCTest#bbc") @@ -120,11 +119,6 @@ public void junit412ShouldExecuteInheritedCategories() { .verifyTextInLog("AbstractCTest#pc") .verifyTextInLog("Running jiras.surefire955.group.BTest") .verifyTextInLog("BTest#b") - // AND the tests in classes inheriting the CategoryB category should be executed - .verifyTextInLog("Running jiras.surefire955.group.ABCTest") - // AND Test runs when the concrete class has an additional (not excluded) category - .verifyTextInLog("ABCTest#abc") - .verifyTextInLog("AbstractBCTest#pb") .verifyTextInLog("AbstractCTest#pc") .verifyTextInLog("Running jiras.surefire955.group.BCTest") // AND Test runs when there is no category in the concrete class diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire747MethodParallelWithSuiteCountIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/SurefireJUnitMethodParallelWithSuiteCountIT.java similarity index 77% rename from surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire747MethodParallelWithSuiteCountIT.java rename to surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/SurefireJUnitMethodParallelWithSuiteCountIT.java index cb40accc5e..414a3cb2e6 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire747MethodParallelWithSuiteCountIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/SurefireJUnitMethodParallelWithSuiteCountIT.java @@ -26,7 +26,7 @@ import org.apache.maven.shared.verifier.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnitIntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Before; import org.junit.Test; @@ -37,15 +37,16 @@ import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.endsWith; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** * @author Kristian Rosenvold */ @SuppressWarnings("checkstyle:magicnumber") -public class Surefire747MethodParallelWithSuiteCountIT extends SurefireJUnit4IntegrationTestCase { +public class SurefireJUnitMethodParallelWithSuiteCountIT extends SurefireJUnitIntegrationTestCase { // if you want to change his constant, change it in SuiteTest1.java and SuiteTest2.java as well private static final int PERFORMANCE_TEST_MULTIPLICATION_FACTOR = 4; @@ -83,7 +84,9 @@ public void init() { @Test public void testMethodsParallelWithSuite() throws VerificationException { - OutputValidator validator = unpack().executeTest().verifyErrorFree(6); + OutputValidator validator = unpack().addGoal("-Djunit.jupiter.execution.parallel.mode.default=concurrent") + .executeTest() + .verifyErrorFree(6); Set testLines = printTestLines(validator, "test finished after duration="); assertThat(testLines.size(), is(2)); for (String testLine : testLines) { @@ -95,13 +98,13 @@ public void testMethodsParallelWithSuite() throws VerificationException { duration > min && duration < max); } Set suiteLines = printTestLines(validator, "suite finished after duration="); - assertThat(suiteLines.size(), is(1)); - long duration = duration(suiteLines.iterator().next()); - long min = 750 * PERFORMANCE_TEST_MULTIPLICATION_FACTOR; - long max = 1250 * PERFORMANCE_TEST_MULTIPLICATION_FACTOR; - assertTrue( - format("duration %d should be between %d and %d ms", duration, min, max), - duration > min && duration < max); + assertThat(suiteLines, hasSize(1)); + // long duration = duration(suiteLines.iterator().next()); + // long min = 750 * PERFORMANCE_TEST_MULTIPLICATION_FACTOR; + // long max = 1250 * PERFORMANCE_TEST_MULTIPLICATION_FACTOR; + // assertTrue( + // format("duration %d should be between %d and %d ms", duration, min, max), + // duration > min && duration < max); String delayMin = lowerScaleFormatter.format(0.98 * PERFORMANCE_TEST_MULTIPLICATION_FACTOR * 0.5); String delayMax = noFractionalDigitsFormatter.format(PERFORMANCE_TEST_MULTIPLICATION_FACTOR * 0.5) + "."; @@ -124,17 +127,19 @@ public void testMethodsParallelWithSuite() throws VerificationException { @Test public void testClassesParallelWithSuite() throws VerificationException { - OutputValidator validator = unpack().parallelClasses().executeTest().verifyErrorFree(6); + OutputValidator validator = unpack().addGoal("-Djunit.vintage.execution.parallel.classes=true") + .executeTest() + .verifyErrorFree(6); Set testLines = printTestLines(validator, "test finished after duration="); assertThat(testLines.size(), is(2)); - for (String testLine : testLines) { - long duration = duration(testLine); - long min = 1450 * PERFORMANCE_TEST_MULTIPLICATION_FACTOR; - long max = 1750 * PERFORMANCE_TEST_MULTIPLICATION_FACTOR; - assertTrue( - format("duration %d should be between %d and %d ms", duration, min, max), - duration > min && duration < max); - } + // for (String testLine : testLines) { + // long duration = duration(testLine); + // long min = 1450 * PERFORMANCE_TEST_MULTIPLICATION_FACTOR; + // long max = 1750 * PERFORMANCE_TEST_MULTIPLICATION_FACTOR; + // assertTrue( + // format("duration %d should be between %d and %d ms", duration, min, max), + // duration > min && duration < max); + // } Set suiteLines = printTestLines(validator, "suite finished after duration="); assertThat(suiteLines.size(), is(1)); long duration = duration(suiteLines.iterator().next()); @@ -146,6 +151,6 @@ public void testClassesParallelWithSuite() throws VerificationException { } public SurefireLauncher unpack() { - return unpack("junit47-parallel-with-suite"); + return unpack("junit-parallel-with-suite"); } } diff --git a/surefire-its/src/test/resources/SurefireToolchains/pom.xml b/surefire-its/src/test/resources/SurefireToolchains/pom.xml index 2a1df2604b..5680001423 100644 --- a/surefire-its/src/test/resources/SurefireToolchains/pom.xml +++ b/surefire-its/src/test/resources/SurefireToolchains/pom.xml @@ -22,7 +22,7 @@ junit junit - 4.8.2 + 4.12 test diff --git a/surefire-its/src/test/resources/additional-classpath/pom.xml b/surefire-its/src/test/resources/additional-classpath/pom.xml index 01ce10c7b4..5b4041cfd1 100644 --- a/surefire-its/src/test/resources/additional-classpath/pom.xml +++ b/surefire-its/src/test/resources/additional-classpath/pom.xml @@ -57,7 +57,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/aggregate-report/child1/pom.xml b/surefire-its/src/test/resources/aggregate-report/child1/pom.xml index 9897a25f78..6854dbbce6 100644 --- a/surefire-its/src/test/resources/aggregate-report/child1/pom.xml +++ b/surefire-its/src/test/resources/aggregate-report/child1/pom.xml @@ -36,7 +36,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/aggregate-report/child2/pom.xml b/surefire-its/src/test/resources/aggregate-report/child2/pom.xml index b67c49a100..e89da992f1 100644 --- a/surefire-its/src/test/resources/aggregate-report/child2/pom.xml +++ b/surefire-its/src/test/resources/aggregate-report/child2/pom.xml @@ -36,7 +36,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/ant-ignore/pom.xml b/surefire-its/src/test/resources/ant-ignore/pom.xml index 6360bedcc3..2e25979cfa 100644 --- a/surefire-its/src/test/resources/ant-ignore/pom.xml +++ b/surefire-its/src/test/resources/ant-ignore/pom.xml @@ -40,7 +40,7 @@ junit junit - 4.4 + 4.12 test diff --git a/surefire-its/src/test/resources/argLine-parameter/pom.xml b/surefire-its/src/test/resources/argLine-parameter/pom.xml index 5522fa2bbc..85a6cd9bc9 100644 --- a/surefire-its/src/test/resources/argLine-parameter/pom.xml +++ b/surefire-its/src/test/resources/argLine-parameter/pom.xml @@ -40,7 +40,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/argLine-properties/pom.xml b/surefire-its/src/test/resources/argLine-properties/pom.xml index ef10cfefc1..60ca8cbc98 100644 --- a/surefire-its/src/test/resources/argLine-properties/pom.xml +++ b/surefire-its/src/test/resources/argLine-properties/pom.xml @@ -44,7 +44,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/classpath-filtering/pom.xml b/surefire-its/src/test/resources/classpath-filtering/pom.xml index a92e75750d..508f5aba49 100644 --- a/surefire-its/src/test/resources/classpath-filtering/pom.xml +++ b/surefire-its/src/test/resources/classpath-filtering/pom.xml @@ -57,7 +57,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/classpath-order/pom.xml b/surefire-its/src/test/resources/classpath-order/pom.xml index b49fda71b4..b0bdb12363 100644 --- a/surefire-its/src/test/resources/classpath-order/pom.xml +++ b/surefire-its/src/test/resources/classpath-order/pom.xml @@ -56,7 +56,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/consoleOutput/pom.xml b/surefire-its/src/test/resources/consoleOutput/pom.xml index 05b4d65556..eee63af5fa 100644 --- a/surefire-its/src/test/resources/consoleOutput/pom.xml +++ b/surefire-its/src/test/resources/consoleOutput/pom.xml @@ -20,7 +20,7 @@ junit junit - 4.7 + 4.12 diff --git a/surefire-its/src/test/resources/consoleOutputEncoding/pom.xml b/surefire-its/src/test/resources/consoleOutputEncoding/pom.xml index 7654190787..343f9321a6 100644 --- a/surefire-its/src/test/resources/consoleOutputEncoding/pom.xml +++ b/surefire-its/src/test/resources/consoleOutputEncoding/pom.xml @@ -63,7 +63,7 @@ - 4.8.1 + 4.12 1 true true diff --git a/surefire-its/src/test/resources/consoleoutput-noisy/pom.xml b/surefire-its/src/test/resources/consoleoutput-noisy/pom.xml index a002f45e1d..4c6ce22bc7 100644 --- a/surefire-its/src/test/resources/consoleoutput-noisy/pom.xml +++ b/surefire-its/src/test/resources/consoleoutput-noisy/pom.xml @@ -51,12 +51,11 @@ true - 4.8.1 + 4.12 true 1 true true - brief true 4 diff --git a/surefire-its/src/test/resources/crash-detection/pom.xml b/surefire-its/src/test/resources/crash-detection/pom.xml index b84ffeb558..7c9f4e1099 100644 --- a/surefire-its/src/test/resources/crash-detection/pom.xml +++ b/surefire-its/src/test/resources/crash-detection/pom.xml @@ -38,7 +38,7 @@ junit junit - 4.4 + 4.12 test diff --git a/surefire-its/src/test/resources/crash-during-test/pom.xml b/surefire-its/src/test/resources/crash-during-test/pom.xml index b3c6828afe..cbb386d178 100644 --- a/surefire-its/src/test/resources/crash-during-test/pom.xml +++ b/surefire-its/src/test/resources/crash-during-test/pom.xml @@ -38,7 +38,7 @@ junit junit - 4.4 + 4.12 test diff --git a/surefire-its/src/test/resources/default-configuration-noTests/pom.xml b/surefire-its/src/test/resources/default-configuration-noTests/pom.xml index fc77535595..a0a917b4c8 100644 --- a/surefire-its/src/test/resources/default-configuration-noTests/pom.xml +++ b/surefire-its/src/test/resources/default-configuration-noTests/pom.xml @@ -51,21 +51,6 @@ junit47 - - - - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - - diff --git a/surefire-its/src/test/resources/default-configuration/pom.xml b/surefire-its/src/test/resources/default-configuration/pom.xml index 1d9587ae46..db194b8d6b 100644 --- a/surefire-its/src/test/resources/default-configuration/pom.xml +++ b/surefire-its/src/test/resources/default-configuration/pom.xml @@ -40,7 +40,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/environment-variables/pom.xml b/surefire-its/src/test/resources/environment-variables/pom.xml index 1ead4fc588..3f43db8e55 100644 --- a/surefire-its/src/test/resources/environment-variables/pom.xml +++ b/surefire-its/src/test/resources/environment-variables/pom.xml @@ -39,7 +39,7 @@ junit junit - 4.4 + 4.12 test diff --git a/surefire-its/src/test/resources/fail-fast-junit/pom.xml b/surefire-its/src/test/resources/fail-fast-junit/pom.xml index 2dbe1e2d44..c66c54dd53 100644 --- a/surefire-its/src/test/resources/fail-fast-junit/pom.xml +++ b/surefire-its/src/test/resources/fail-fast-junit/pom.xml @@ -34,7 +34,7 @@ 1.0 - 4.0 + 4.12 @@ -51,6 +51,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${surefire.version} alphabetical -Xms64m -Xmx128m @@ -60,45 +61,6 @@ - - junit4 - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - - - - - - - junit47 - - 4.7 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - - tcp diff --git a/surefire-its/src/test/resources/fail-fast-testng/pom.xml b/surefire-its/src/test/resources/fail-fast-testng/pom.xml index 064c6f879b..9d22e7f311 100644 --- a/surefire-its/src/test/resources/fail-fast-testng/pom.xml +++ b/surefire-its/src/test/resources/fail-fast-testng/pom.xml @@ -37,8 +37,7 @@ org.testng testng - 5.10 - jdk15 + 6.14.3 test @@ -48,6 +47,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${surefire.version} alphabetical -Xms64m -Xmx128m diff --git a/surefire-its/src/test/resources/failingBuilds/pom.xml b/surefire-its/src/test/resources/failingBuilds/pom.xml index 5972073345..6316585270 100644 --- a/surefire-its/src/test/resources/failingBuilds/pom.xml +++ b/surefire-its/src/test/resources/failingBuilds/pom.xml @@ -32,7 +32,7 @@
- 4.8.1 + 4.12 1 1.8 1.8 diff --git a/surefire-its/src/test/resources/failsafe-buildfail/pom.xml b/surefire-its/src/test/resources/failsafe-buildfail/pom.xml index c28972fda3..19f8f8fdb5 100644 --- a/surefire-its/src/test/resources/failsafe-buildfail/pom.xml +++ b/surefire-its/src/test/resources/failsafe-buildfail/pom.xml @@ -29,7 +29,7 @@ junit junit - 3.8.2 + 4.12 test diff --git a/surefire-its/src/test/resources/failsafe-nofail/pom.xml b/surefire-its/src/test/resources/failsafe-nofail/pom.xml index c28972fda3..19f8f8fdb5 100644 --- a/surefire-its/src/test/resources/failsafe-nofail/pom.xml +++ b/surefire-its/src/test/resources/failsafe-nofail/pom.xml @@ -29,7 +29,7 @@ junit junit - 3.8.2 + 4.12 test diff --git a/surefire-its/src/test/resources/failsafe-notests/pom.xml b/surefire-its/src/test/resources/failsafe-notests/pom.xml index 6c4493e855..0362f7548e 100644 --- a/surefire-its/src/test/resources/failsafe-notests/pom.xml +++ b/surefire-its/src/test/resources/failsafe-notests/pom.xml @@ -36,7 +36,7 @@ junit junit - 3.8.2 + 4.12 test diff --git a/surefire-its/src/test/resources/failsafe-regular/pom.xml b/surefire-its/src/test/resources/failsafe-regular/pom.xml index 4755cb4534..e8a1a53077 100644 --- a/surefire-its/src/test/resources/failsafe-regular/pom.xml +++ b/surefire-its/src/test/resources/failsafe-regular/pom.xml @@ -29,7 +29,7 @@ junit junit - 3.8.2 + 4.12 test diff --git a/surefire-its/src/test/resources/failure-result-counting/pom.xml b/surefire-its/src/test/resources/failure-result-counting/pom.xml index 5be562cb6b..a7681c9d1d 100644 --- a/surefire-its/src/test/resources/failure-result-counting/pom.xml +++ b/surefire-its/src/test/resources/failure-result-counting/pom.xml @@ -31,7 +31,7 @@ - 4.10 + 4.12 1 true 1.8 diff --git a/surefire-its/src/test/resources/failureOutput/pom.xml b/surefire-its/src/test/resources/failureOutput/pom.xml index b6e2bf6b18..7080de6a55 100644 --- a/surefire-its/src/test/resources/failureOutput/pom.xml +++ b/surefire-its/src/test/resources/failureOutput/pom.xml @@ -38,7 +38,7 @@ - 4.8.1 + 4.12 true 1 true diff --git a/surefire-its/src/test/resources/fork-consoleOutput/pom.xml b/surefire-its/src/test/resources/fork-consoleOutput/pom.xml index 8545e8c403..9dead9fca8 100644 --- a/surefire-its/src/test/resources/fork-consoleOutput/pom.xml +++ b/surefire-its/src/test/resources/fork-consoleOutput/pom.xml @@ -37,7 +37,7 @@ - 4.8.1 + 4.12 1 true true diff --git a/surefire-its/src/test/resources/fork-consoleOutputWithErrors/pom.xml b/surefire-its/src/test/resources/fork-consoleOutputWithErrors/pom.xml index aa18bf963a..afd2cbd28f 100644 --- a/surefire-its/src/test/resources/fork-consoleOutputWithErrors/pom.xml +++ b/surefire-its/src/test/resources/fork-consoleOutputWithErrors/pom.xml @@ -38,7 +38,7 @@ - 4.8.1 + 4.12 true 1 true diff --git a/surefire-its/src/test/resources/fork-count-multimodule/pom.xml b/surefire-its/src/test/resources/fork-count-multimodule/pom.xml index 21f07b8234..ad59afe2ab 100644 --- a/surefire-its/src/test/resources/fork-count-multimodule/pom.xml +++ b/surefire-its/src/test/resources/fork-count-multimodule/pom.xml @@ -59,7 +59,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/fork-count-testng/pom.xml b/surefire-its/src/test/resources/fork-count-testng/pom.xml index c041cc02e0..9c416e7538 100644 --- a/surefire-its/src/test/resources/fork-count-testng/pom.xml +++ b/surefire-its/src/test/resources/fork-count-testng/pom.xml @@ -35,8 +35,7 @@ org.testng testng - 5.7 - jdk15 + 6.14.3 test diff --git a/surefire-its/src/test/resources/fork-count/pom.xml b/surefire-its/src/test/resources/fork-count/pom.xml index f1a2cc2aaf..8c25b4ea69 100644 --- a/surefire-its/src/test/resources/fork-count/pom.xml +++ b/surefire-its/src/test/resources/fork-count/pom.xml @@ -52,7 +52,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/fork-fail/pom.xml b/surefire-its/src/test/resources/fork-fail/pom.xml index 58b1f041fa..91a023ba1e 100644 --- a/surefire-its/src/test/resources/fork-fail/pom.xml +++ b/surefire-its/src/test/resources/fork-fail/pom.xml @@ -52,7 +52,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/fork-timeout/pom.xml b/surefire-its/src/test/resources/fork-timeout/pom.xml index 085f0dcc89..d1baefc599 100644 --- a/surefire-its/src/test/resources/fork-timeout/pom.xml +++ b/surefire-its/src/test/resources/fork-timeout/pom.xml @@ -8,7 +8,7 @@ fork-timeout http://maven.apache.org - 4.8.1 + 4.12 classes 1 true diff --git a/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/common-excludes.txt b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/common-excludes.txt new file mode 100644 index 0000000000..483aae33ae --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/common-excludes.txt @@ -0,0 +1,3 @@ +# common excludes + +**/DontRunTest.* \ No newline at end of file diff --git a/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/path-includes.txt b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/path-includes.txt new file mode 100644 index 0000000000..cedff2af8b --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/path-includes.txt @@ -0,0 +1,3 @@ +# path includes + +*/test/* diff --git a/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/pom.xml b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/pom.xml new file mode 100644 index 0000000000..35e3589dbb --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/pom.xml @@ -0,0 +1,152 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.surefire + maven-it-includes-excludes + 1.0-SNAPSHOT + + Maven Integration Test :: includes-excludes-from-file + Test surefire inclusion/exclusions from files + + + 1.8 + 1.8 + + + + + org.junit.jupiter + junit-jupiter + 5.14.0 + test + + + + + + + + maven-surefire-plugin + ${surefire.version} + + + + + + + + simple + + + + maven-surefire-plugin + + ${project.basedir}/common-excludes.txt + ${project.basedir}/simple-includes.txt + + + + + + + + simple-mixed + + + + maven-surefire-plugin + + ${project.basedir}/common-excludes.txt + + **/NotIncludedByDefault.java + + ${project.basedir}/simple-mixed-includes.txt + + + + + + + + regex + + + + maven-surefire-plugin + + ${project.basedir}/common-excludes.txt + ${project.basedir}/regex-includes.txt + + + + + + + + path + + + + maven-surefire-plugin + + ${project.basedir}/common-excludes.txt + ${project.basedir}/path-includes.txt + + + + + + + + missing-excludes-file + + + + maven-surefire-plugin + + ${project.basedir}/no-such-excludes-file + ${project.basedir}/simple-includes.txt + + + + + + + + missing-includes-file + + + + maven-surefire-plugin + + ${project.basedir}/common-excludes.txt + ${project.basedir}/no-such-includes-file + + + + + + + + diff --git a/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/regex-includes.txt b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/regex-includes.txt new file mode 100644 index 0000000000..fcf6f9ee66 --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/regex-includes.txt @@ -0,0 +1,3 @@ +# regex includes + +%regex[.*Test.*|.*Not.*] \ No newline at end of file diff --git a/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/simple-includes.txt b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/simple-includes.txt new file mode 100644 index 0000000000..d2b1d12fb4 --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/simple-includes.txt @@ -0,0 +1,4 @@ +# simple includes + +**/NotIncludedByDefault.java +**/*Test.java \ No newline at end of file diff --git a/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/simple-mixed-includes.txt b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/simple-mixed-includes.txt new file mode 100644 index 0000000000..68a1d5c6c0 --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/simple-mixed-includes.txt @@ -0,0 +1,3 @@ +# simple-mixed includes + +**/*Test.java \ No newline at end of file diff --git a/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/DefaultTest.java b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/DefaultTest.java new file mode 100644 index 0000000000..64afcf8eb4 --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/DefaultTest.java @@ -0,0 +1,17 @@ +package org.test; + +import java.io.FileOutputStream; +import org.junit.jupiter.api.Test; + +public class DefaultTest +{ + @Test + public void testRun() + throws Exception + { + try ( FileOutputStream fout = new FileOutputStream( "target/defaultTestTouchFile.txt" ) ) + { + fout.write( '!' ); + } + } +} diff --git a/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/DontRunTest.java b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/DontRunTest.java new file mode 100644 index 0000000000..786ef0c2aa --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/DontRunTest.java @@ -0,0 +1,14 @@ +package org.test; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + + +public class DontRunTest +{ + @Test + public void testRun() + { + assertEquals(true, false); + } +} diff --git a/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/NotIncludedByDefault.java b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/NotIncludedByDefault.java new file mode 100644 index 0000000000..0c149aa0d3 --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/NotIncludedByDefault.java @@ -0,0 +1,17 @@ +package org.test; + +import java.io.FileOutputStream; +import org.junit.jupiter.api.Test; + +public class NotIncludedByDefault +{ + @Test + public void testRun() + throws Exception + { + try ( FileOutputStream fout = new FileOutputStream( "target/testTouchFile.txt" ) ) + { + fout.write( '!' ); + } + } +} diff --git a/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/aTestXmlFile.xml b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/aTestXmlFile.xml new file mode 100644 index 0000000000..17f382faf4 --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-from-file-junit-5/src/test/java/org/test/aTestXmlFile.xml @@ -0,0 +1,24 @@ + + + + + + + diff --git a/surefire-its/src/test/resources/includes-excludes-from-file/pom.xml b/surefire-its/src/test/resources/includes-excludes-from-file/pom.xml index 92d46d6f3b..0443cce175 100644 --- a/surefire-its/src/test/resources/includes-excludes-from-file/pom.xml +++ b/surefire-its/src/test/resources/includes-excludes-from-file/pom.xml @@ -30,7 +30,7 @@ under the License. Test surefire inclusion/exclusions from files - 3.8.2 + 4.13 1.8 1.8 diff --git a/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/DefaultTest.java b/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/DefaultTest.java index 2ba90a2124..59e3a08689 100644 --- a/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/DefaultTest.java +++ b/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/DefaultTest.java @@ -1,9 +1,11 @@ package org.test; import java.io.FileOutputStream; +import org.junit.Test; public class DefaultTest { + @Test public void testRun() throws Exception { diff --git a/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/DontRunTest.java b/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/DontRunTest.java index 3d94c854a7..6fd8a23ded 100644 --- a/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/DontRunTest.java +++ b/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/DontRunTest.java @@ -1,9 +1,11 @@ package org.test; import junit.framework.TestCase; +import org.junit.Test; public class DontRunTest extends TestCase { + @Test public void testRun() { assertEquals(true, false); diff --git a/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/NotIncludedByDefault.java b/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/NotIncludedByDefault.java index 359e54934c..185909cc01 100644 --- a/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/NotIncludedByDefault.java +++ b/surefire-its/src/test/resources/includes-excludes-from-file/src/test/java/org/test/NotIncludedByDefault.java @@ -1,9 +1,11 @@ package org.test; import java.io.FileOutputStream; +import org.junit.Test; public class NotIncludedByDefault { + @Test public void testRun() throws Exception { diff --git a/surefire-its/src/test/resources/includes-excludes-junit-5/pom.xml b/surefire-its/src/test/resources/includes-excludes-junit-5/pom.xml new file mode 100644 index 0000000000..a20ed25efc --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-junit-5/pom.xml @@ -0,0 +1,134 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.surefire + maven-it-includes-excludes + 1.0-SNAPSHOT + + Maven Integration Test :: includes-excludes + Test surefire inclusion/exclusions + + + 1.8 + 1.8 + + + + + org.junit.jupiter + junit-jupiter + 5.14.0 + test + + + + + + + + maven-surefire-plugin + ${surefire.version} + + + + + + + simple + + + + maven-surefire-plugin + + + **/DontRunTest.* + + + + + **/NotIncludedByDefault.java + **/*Test.java + + + + + + + + regex + + + + maven-surefire-plugin + + + **/DontRunTest.* + + + %regex[.*Test.*|.*Not.*] + + + + + + + + path + + + + maven-surefire-plugin + + + **/DontRunTest.java + + + */test/* + + + + + + + + withXmlFile + + + + maven-surefire-plugin + + + **/DontRunTest.java + + + **/*.xml + + + + + + + + + diff --git a/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/DefaultTest.java b/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/DefaultTest.java new file mode 100644 index 0000000000..64afcf8eb4 --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/DefaultTest.java @@ -0,0 +1,17 @@ +package org.test; + +import java.io.FileOutputStream; +import org.junit.jupiter.api.Test; + +public class DefaultTest +{ + @Test + public void testRun() + throws Exception + { + try ( FileOutputStream fout = new FileOutputStream( "target/defaultTestTouchFile.txt" ) ) + { + fout.write( '!' ); + } + } +} diff --git a/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/DontRunTest.java b/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/DontRunTest.java new file mode 100644 index 0000000000..786ef0c2aa --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/DontRunTest.java @@ -0,0 +1,14 @@ +package org.test; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + + +public class DontRunTest +{ + @Test + public void testRun() + { + assertEquals(true, false); + } +} diff --git a/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/NotIncludedByDefault.java b/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/NotIncludedByDefault.java new file mode 100644 index 0000000000..0c149aa0d3 --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/NotIncludedByDefault.java @@ -0,0 +1,17 @@ +package org.test; + +import java.io.FileOutputStream; +import org.junit.jupiter.api.Test; + +public class NotIncludedByDefault +{ + @Test + public void testRun() + throws Exception + { + try ( FileOutputStream fout = new FileOutputStream( "target/testTouchFile.txt" ) ) + { + fout.write( '!' ); + } + } +} diff --git a/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/aTestXmlFile.xml b/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/aTestXmlFile.xml new file mode 100644 index 0000000000..17f382faf4 --- /dev/null +++ b/surefire-its/src/test/resources/includes-excludes-junit-5/src/test/java/org/test/aTestXmlFile.xml @@ -0,0 +1,24 @@ + + + + + + + diff --git a/surefire-its/src/test/resources/includes-excludes/pom.xml b/surefire-its/src/test/resources/includes-excludes/pom.xml index 0e3ea3c339..6454368131 100644 --- a/surefire-its/src/test/resources/includes-excludes/pom.xml +++ b/surefire-its/src/test/resources/includes-excludes/pom.xml @@ -30,7 +30,7 @@ under the License. Test surefire inclusion/exclusions - 3.8.2 + 4.12 1.8 1.8 diff --git a/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/DefaultTest.java b/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/DefaultTest.java index 2ba90a2124..59e3a08689 100644 --- a/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/DefaultTest.java +++ b/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/DefaultTest.java @@ -1,9 +1,11 @@ package org.test; import java.io.FileOutputStream; +import org.junit.Test; public class DefaultTest { + @Test public void testRun() throws Exception { diff --git a/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/DontRunTest.java b/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/DontRunTest.java index 3d94c854a7..6fd8a23ded 100644 --- a/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/DontRunTest.java +++ b/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/DontRunTest.java @@ -1,9 +1,11 @@ package org.test; import junit.framework.TestCase; +import org.junit.Test; public class DontRunTest extends TestCase { + @Test public void testRun() { assertEquals(true, false); diff --git a/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/NotIncludedByDefault.java b/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/NotIncludedByDefault.java index 359e54934c..185909cc01 100644 --- a/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/NotIncludedByDefault.java +++ b/surefire-its/src/test/resources/includes-excludes/src/test/java/org/test/NotIncludedByDefault.java @@ -1,9 +1,11 @@ package org.test; import java.io.FileOutputStream; +import org.junit.Test; public class NotIncludedByDefault { + @Test public void testRun() throws Exception { diff --git a/surefire-its/src/test/resources/isolated-classloader/pom.xml b/surefire-its/src/test/resources/isolated-classloader/pom.xml index 072884c358..b30b7e9078 100644 --- a/surefire-its/src/test/resources/isolated-classloader/pom.xml +++ b/surefire-its/src/test/resources/isolated-classloader/pom.xml @@ -48,7 +48,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/junit-ignore/pom.xml b/surefire-its/src/test/resources/junit-ignore/pom.xml index 5227f24f73..64b9ec1005 100644 --- a/surefire-its/src/test/resources/junit-ignore/pom.xml +++ b/surefire-its/src/test/resources/junit-ignore/pom.xml @@ -29,7 +29,7 @@ Test of @Ignore annotation - 4.4 + 4.12 3 1.8 diff --git a/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java b/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java index 765eb8a120..122767c4fb 100644 --- a/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java +++ b/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java @@ -34,5 +34,11 @@ public void testWithAssumptionFailure() Assume.assumeNotNull( new Object[]{ null} ); } + @Test + public void testAllGood() + { + System.out.println("testAllGood"); + } + } diff --git a/surefire-its/src/test/resources/junit-innerClass/pom.xml b/surefire-its/src/test/resources/junit-innerClass/pom.xml index cfec9224ca..e1b63d3c68 100644 --- a/surefire-its/src/test/resources/junit-innerClass/pom.xml +++ b/surefire-its/src/test/resources/junit-innerClass/pom.xml @@ -37,7 +37,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/junit-notExtendingTestCase/pom.xml b/surefire-its/src/test/resources/junit-notExtendingTestCase/pom.xml index 00c0d23101..f59c4031ff 100644 --- a/surefire-its/src/test/resources/junit-notExtendingTestCase/pom.xml +++ b/surefire-its/src/test/resources/junit-notExtendingTestCase/pom.xml @@ -37,7 +37,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/junit-parallel-with-suite/pom.xml b/surefire-its/src/test/resources/junit-parallel-with-suite/pom.xml new file mode 100644 index 0000000000..175966dfd2 --- /dev/null +++ b/surefire-its/src/test/resources/junit-parallel-with-suite/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + org.apache.maven.plugins.surefire + junit4-test + jar + 1.0-SNAPSHOT + surefire-747-parallel-method-skips-test + http://maven.apache.org + + + org.junit.jupiter + junit-jupiter-api + 5.14.1 + test + + + org.junit.platform + junit-platform-suite-api + 1.14.1 + test + + + org.junit.platform + junit-platform-suite-engine + 1.14.1 + test + + + + 0.8 + 10 + dynamic + true + concurrent + same_thread + true + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + + + + junit.jupiter.execution.parallel.enabled=${junit.jupiter.execution.parallel.enabled} + junit.jupiter.execution.parallel.mode.default=${junit.jupiter.execution.parallel.mode.default} + junit.jupiter.execution.parallel.mode.classes.default=${junit.jupiter.execution.parallel.mode.classes.default} + junit.jupiter.execution.parallel.config.strategy=${junit.jupiter.execution.parallel.config.strategy} + junit.jupiter.execution.parallel.config.fixed.parallelism=${junit.jupiter.execution.parallel.config.fixed.parallelism} + junit.jupiter.execution.parallel.config.dynamic.factor=${junit.jupiter.execution.parallel.config.dynamic.factor} + junit.jupiter.extensions.autodetection.enabled=${junit.jupiter.extensions.autodetection.enabled} + + + **/TestSuite.java + + + + + + diff --git a/surefire-its/src/test/resources/junit47-parallel-with-suite/src/test/java/surefire747/SuiteTest1.java b/surefire-its/src/test/resources/junit-parallel-with-suite/src/test/java/junit/SuiteTest1.java similarity index 85% rename from surefire-its/src/test/resources/junit47-parallel-with-suite/src/test/java/surefire747/SuiteTest1.java rename to surefire-its/src/test/resources/junit-parallel-with-suite/src/test/java/junit/SuiteTest1.java index a277cd9558..28c658c5a3 100644 --- a/surefire-its/src/test/resources/junit47-parallel-with-suite/src/test/java/surefire747/SuiteTest1.java +++ b/surefire-its/src/test/resources/junit-parallel-with-suite/src/test/java/junit/SuiteTest1.java @@ -1,10 +1,10 @@ -package surefire747; +package junit; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * @author Kristian Rosenvold @@ -20,26 +20,26 @@ public SuiteTest1() System.out.println( "SuiteTest1.constructor" ); } - @BeforeClass + @BeforeAll public static void beforeClass() { startedAt = System.currentTimeMillis(); } - @AfterClass + @AfterAll public static void afterClass() { System.out.println( String.format( "%s test finished after duration=%d", SuiteTest1.class.getSimpleName(), System.currentTimeMillis() - startedAt ) ); } - @Before + @BeforeEach public void setUp() { System.out.println( "SuiteTest1.setUp" ); } - @After + @AfterEach public void tearDown() { System.out.println( "SuiteTest1.tearDown" ); diff --git a/surefire-its/src/test/resources/junit47-parallel-with-suite/src/test/java/surefire747/SuiteTest2.java b/surefire-its/src/test/resources/junit-parallel-with-suite/src/test/java/junit/SuiteTest2.java similarity index 85% rename from surefire-its/src/test/resources/junit47-parallel-with-suite/src/test/java/surefire747/SuiteTest2.java rename to surefire-its/src/test/resources/junit-parallel-with-suite/src/test/java/junit/SuiteTest2.java index 53f05df2fe..a52e01d823 100644 --- a/surefire-its/src/test/resources/junit47-parallel-with-suite/src/test/java/surefire747/SuiteTest2.java +++ b/surefire-its/src/test/resources/junit-parallel-with-suite/src/test/java/junit/SuiteTest2.java @@ -1,10 +1,10 @@ -package surefire747; +package junit; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * @author Kristian Rosenvold @@ -20,26 +20,26 @@ public SuiteTest2() System.out.println( "SuiteTest2.constructor" ); } - @BeforeClass + @BeforeAll public static void beforeClass() { startedAt = System.currentTimeMillis(); } - @AfterClass + @AfterAll public static void afterClass() { System.out.println( String.format( "%s test finished after duration=%d", SuiteTest2.class.getSimpleName(), System.currentTimeMillis() - startedAt ) ); } - @Before + @BeforeEach public void setUp() { System.out.println( "SuiteTest2.setUp" ); } - @After + @AfterEach public void tearDown() { System.out.println( "SuiteTest2.tearDown" ); diff --git a/surefire-its/src/test/resources/junit-parallel-with-suite/src/test/java/junit/TestSuite.java b/surefire-its/src/test/resources/junit-parallel-with-suite/src/test/java/junit/TestSuite.java new file mode 100644 index 0000000000..1c0ae4ff6b --- /dev/null +++ b/surefire-its/src/test/resources/junit-parallel-with-suite/src/test/java/junit/TestSuite.java @@ -0,0 +1,33 @@ +package junit; + +import org.junit.platform.suite.api.Suite; +import org.junit.platform.suite.api.SuiteDisplayName; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.IncludeClassNamePatterns; +import org.junit.platform.suite.api.BeforeSuite; +import org.junit.platform.suite.api.AfterSuite; + +/** + * @author Kristian Rosenvold + */ +@Suite +@SuiteDisplayName("JUnit Platform Suite Test") +@SelectPackages("junit") +@IncludeClassNamePatterns(".*SuiteTest.*") +public class TestSuite +{ + private static long startedAt; + + @BeforeSuite + public static void beforeClass() + { + startedAt = System.currentTimeMillis(); + } + + @AfterSuite + public static void afterClass() + { + System.out.println( String.format( "%s suite finished after duration=%d", TestSuite.class.getSimpleName(), + System.currentTimeMillis() - startedAt ) ); + } +} diff --git a/surefire-its/src/test/resources/junit-pathWithUmlaut/pom.xml b/surefire-its/src/test/resources/junit-pathWithUmlaut/pom.xml index 68c05ef211..2641fb0135 100644 --- a/surefire-its/src/test/resources/junit-pathWithUmlaut/pom.xml +++ b/surefire-its/src/test/resources/junit-pathWithUmlaut/pom.xml @@ -38,7 +38,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/junit-platform/pom.xml b/surefire-its/src/test/resources/junit-platform/pom.xml index 02e5c003d8..9edbbbf6a9 100644 --- a/surefire-its/src/test/resources/junit-platform/pom.xml +++ b/surefire-its/src/test/resources/junit-platform/pom.xml @@ -58,16 +58,4 @@ - - - oss-sonatype - oss-sonatype - https://oss.sonatype.org/content/repositories/snapshots/ - - true - always - ignore - - - diff --git a/surefire-its/src/test/resources/junit-twoTestCaseSuite/pom.xml b/surefire-its/src/test/resources/junit-twoTestCaseSuite/pom.xml index 5f22017615..a70cb97b30 100644 --- a/surefire-its/src/test/resources/junit-twoTestCaseSuite/pom.xml +++ b/surefire-its/src/test/resources/junit-twoTestCaseSuite/pom.xml @@ -51,7 +51,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/junit-twoTestCases/pom.xml b/surefire-its/src/test/resources/junit-twoTestCases/pom.xml index 46ffd1d667..d8670456fe 100644 --- a/surefire-its/src/test/resources/junit-twoTestCases/pom.xml +++ b/surefire-its/src/test/resources/junit-twoTestCases/pom.xml @@ -37,7 +37,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/pom.xml b/surefire-its/src/test/resources/junit-unsupported/pom.xml similarity index 88% rename from surefire-its/src/test/resources/surefire-809-groupExpr-junit48/pom.xml rename to surefire-its/src/test/resources/junit-unsupported/pom.xml index 38dd327789..60deb8702e 100644 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/pom.xml +++ b/surefire-its/src/test/resources/junit-unsupported/pom.xml @@ -24,15 +24,13 @@ 4.0.0 org.apache.maven.plugins.surefire - junit4 + junit-unsupported 1.0-SNAPSHOT - Test for JUnit 4.8.1 - + Test for correct handling of unsupported version - 4.8.1 - 1.8 - 1.8 + 8 + 8 diff --git a/surefire-its/src/test/resources/junit-unsupported/src/test/java/junitUnsupported/BasicTest.java b/surefire-its/src/test/resources/junit-unsupported/src/test/java/junitUnsupported/BasicTest.java new file mode 100644 index 0000000000..74683fbea5 --- /dev/null +++ b/surefire-its/src/test/resources/junit-unsupported/src/test/java/junitUnsupported/BasicTest.java @@ -0,0 +1,14 @@ +package junitUnsupported; + +import junit.framework.TestCase; + +public class BasicTest extends TestCase +{ + + public void testEnvVar() + { + assertEquals(1, 1); + } + + +} diff --git a/surefire-its/src/test/resources/junit4-forkAlways-staticInit/pom.xml b/surefire-its/src/test/resources/junit4-forkAlways-staticInit/pom.xml index b11506c018..6d2a4f47e2 100644 --- a/surefire-its/src/test/resources/junit4-forkAlways-staticInit/pom.xml +++ b/surefire-its/src/test/resources/junit4-forkAlways-staticInit/pom.xml @@ -19,7 +19,7 @@ junit junit - 4.5 + 4.12 test diff --git a/surefire-its/src/test/resources/junit44-method-pattern/pom.xml b/surefire-its/src/test/resources/junit4-method-pattern/pom.xml similarity index 69% rename from surefire-its/src/test/resources/junit44-method-pattern/pom.xml rename to surefire-its/src/test/resources/junit4-method-pattern/pom.xml index 71cae0d7f3..da11fbc5d2 100644 --- a/surefire-its/src/test/resources/junit44-method-pattern/pom.xml +++ b/surefire-its/src/test/resources/junit4-method-pattern/pom.xml @@ -23,16 +23,20 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + org.apache.maven.surefire + it-parent + 1.0 + ../pom.xml + + org.apache.maven.plugins.surefire junit4 1.0-SNAPSHOT Test for JUnit 4 - - 4.4 - 1.8 - 1.8 + 4.12 @@ -52,26 +56,27 @@ ${surefire.version} BasicTest#testSuccess* + 1 - - - tcp - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - - + + + tcp + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + diff --git a/surefire-its/src/test/resources/junit48-method-pattern/src/test/java/junit4/BasicTest.java b/surefire-its/src/test/resources/junit4-method-pattern/src/test/java/junit4/BasicTest.java similarity index 100% rename from surefire-its/src/test/resources/junit48-method-pattern/src/test/java/junit4/BasicTest.java rename to surefire-its/src/test/resources/junit4-method-pattern/src/test/java/junit4/BasicTest.java diff --git a/surefire-its/src/test/resources/junit48-method-pattern/src/test/java/junit4/SampleCategory.java b/surefire-its/src/test/resources/junit4-method-pattern/src/test/java/junit4/SampleCategory.java similarity index 100% rename from surefire-its/src/test/resources/junit48-method-pattern/src/test/java/junit4/SampleCategory.java rename to surefire-its/src/test/resources/junit4-method-pattern/src/test/java/junit4/SampleCategory.java diff --git a/surefire-its/src/test/resources/junit48-multiple-methods/pom.xml b/surefire-its/src/test/resources/junit4-multiple-method-patterns/pom.xml similarity index 69% rename from surefire-its/src/test/resources/junit48-multiple-methods/pom.xml rename to surefire-its/src/test/resources/junit4-multiple-method-patterns/pom.xml index f13284326b..4084992778 100644 --- a/surefire-its/src/test/resources/junit48-multiple-methods/pom.xml +++ b/surefire-its/src/test/resources/junit4-multiple-method-patterns/pom.xml @@ -22,28 +22,26 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.apache.maven.surefire it-parent 1.0 ../pom.xml - org.apache.maven.plugins.surefire - junit4 - 1.0-SNAPSHOT - Test for JUnit 4.8.1 + jiras-surefire-745-junit + 1.0 - 4.8.1 + + junit junit - ${junitVersion} + 4.12 test @@ -53,47 +51,42 @@ org.apache.maven.plugins maven-surefire-plugin - - junit4/BasicTest#testSuccessOne+testFailOne,junit4/TestThree#testSuccessTwo - 1 - - surefire-junit47 + junit4-includes org.apache.maven.plugins maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - + + + ${included} + + - surefire-junit4 + junit4-includes-excludes org.apache.maven.plugins maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - + + + ${included} + + + ${excluded} + + diff --git a/surefire-its/src/test/resources/junit48-multiple-method-patterns/src/test/java/jiras/surefire745/BasicTest.java b/surefire-its/src/test/resources/junit4-multiple-method-patterns/src/test/java/jiras/surefire745/BasicTest.java similarity index 100% rename from surefire-its/src/test/resources/junit48-multiple-method-patterns/src/test/java/jiras/surefire745/BasicTest.java rename to surefire-its/src/test/resources/junit4-multiple-method-patterns/src/test/java/jiras/surefire745/BasicTest.java diff --git a/surefire-its/src/test/resources/junit48-multiple-method-patterns/src/test/java/jiras/surefire745/TestFive.java b/surefire-its/src/test/resources/junit4-multiple-method-patterns/src/test/java/jiras/surefire745/TestFive.java similarity index 100% rename from surefire-its/src/test/resources/junit48-multiple-method-patterns/src/test/java/jiras/surefire745/TestFive.java rename to surefire-its/src/test/resources/junit4-multiple-method-patterns/src/test/java/jiras/surefire745/TestFive.java diff --git a/surefire-its/src/test/resources/junit48-multiple-method-patterns/src/test/java/jiras/surefire745/TestFour.java b/surefire-its/src/test/resources/junit4-multiple-method-patterns/src/test/java/jiras/surefire745/TestFour.java similarity index 100% rename from surefire-its/src/test/resources/junit48-multiple-method-patterns/src/test/java/jiras/surefire745/TestFour.java rename to surefire-its/src/test/resources/junit4-multiple-method-patterns/src/test/java/jiras/surefire745/TestFour.java diff --git a/surefire-its/src/test/resources/junit48-multiple-method-patterns/src/test/java/jiras/surefire745/TestThree.java b/surefire-its/src/test/resources/junit4-multiple-method-patterns/src/test/java/jiras/surefire745/TestThree.java similarity index 100% rename from surefire-its/src/test/resources/junit48-multiple-method-patterns/src/test/java/jiras/surefire745/TestThree.java rename to surefire-its/src/test/resources/junit4-multiple-method-patterns/src/test/java/jiras/surefire745/TestThree.java diff --git a/surefire-its/src/test/resources/junit48-multiple-method-patterns/src/test/java/jiras/surefire745/TestTwo.java b/surefire-its/src/test/resources/junit4-multiple-method-patterns/src/test/java/jiras/surefire745/TestTwo.java similarity index 100% rename from surefire-its/src/test/resources/junit48-multiple-method-patterns/src/test/java/jiras/surefire745/TestTwo.java rename to surefire-its/src/test/resources/junit4-multiple-method-patterns/src/test/java/jiras/surefire745/TestTwo.java diff --git a/surefire-its/src/test/resources/junit4-runlistener/pom.xml b/surefire-its/src/test/resources/junit4-runlistener/pom.xml index 71336d91da..c89ff2ca79 100644 --- a/surefire-its/src/test/resources/junit4-runlistener/pom.xml +++ b/surefire-its/src/test/resources/junit4-runlistener/pom.xml @@ -29,7 +29,7 @@ JUnit4 RunListener test - 4.4 + 4.12 surefire-junit4 1.8 1.8 @@ -58,13 +58,6 @@ - - - org.apache.maven.surefire - ${provider} - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/junit4-twoTestCaseSuite/pom.xml b/surefire-its/src/test/resources/junit4-twoTestCaseSuite/pom.xml index ea7f2071e6..4a3aeb4d93 100644 --- a/surefire-its/src/test/resources/junit4-twoTestCaseSuite/pom.xml +++ b/surefire-its/src/test/resources/junit4-twoTestCaseSuite/pom.xml @@ -30,7 +30,7 @@ - 4.4 + 4.12 1.8 1.8 diff --git a/surefire-its/src/test/resources/junit44-dep/pom.xml b/surefire-its/src/test/resources/junit44-dep/pom.xml deleted file mode 100644 index 6590bf298d..0000000000 --- a/surefire-its/src/test/resources/junit44-dep/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - junit44-dep - 1.0-SNAPSHOT - Test for junit-dep - - - 1.8 - 1.8 - - - - - junit - junit-dep - ${junit-dep.version} - test - - - - - - provided381 - - - junit - junit - 3.8.1 - provided - - - - - - - - maven-surefire-plugin - ${surefire.version} - - classes - 1 - - - - - - diff --git a/surefire-its/src/test/resources/junit44-dep/src/test/java/junit44Dep/BasicTest.java b/surefire-its/src/test/resources/junit44-dep/src/test/java/junit44Dep/BasicTest.java deleted file mode 100644 index 1e4ccb74da..0000000000 --- a/surefire-its/src/test/resources/junit44-dep/src/test/java/junit44Dep/BasicTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package junit44Dep; - -import org.hamcrest.core.Is; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - - -public class BasicTest -{ - - private boolean setUpCalled = false; - - private static boolean tearDownCalled = false; - - @Before - public void setUp() - { - setUpCalled = true; - tearDownCalled = false; - System.out.println( "Called setUp" ); - } - - @After - public void tearDown() - { - setUpCalled = false; - tearDownCalled = true; - System.out.println( "Called tearDown" ); - } - - @Test - public void testSetUp() - { - Assert.assertTrue( "setUp was not called", setUpCalled ); - Assert.assertFalse( "tearDown was called", tearDownCalled ); - Assert.assertThat( true, Is.is( true ) ); - } - - @AfterClass - public static void oneTimeTearDown() - { - Assert.assertTrue( "tearDown was not called", tearDownCalled ); - } - -} diff --git a/surefire-its/src/test/resources/junit44-environment/pom.xml b/surefire-its/src/test/resources/junit44-environment/pom.xml index 89cf295373..e39b061b8d 100644 --- a/surefire-its/src/test/resources/junit44-environment/pom.xml +++ b/surefire-its/src/test/resources/junit44-environment/pom.xml @@ -37,7 +37,7 @@ junit junit - 4.4 + 4.12 test diff --git a/surefire-its/src/test/resources/junit44-hamcrest/pom.xml b/surefire-its/src/test/resources/junit44-hamcrest/pom.xml deleted file mode 100644 index 2ff74b1f88..0000000000 --- a/surefire-its/src/test/resources/junit44-hamcrest/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - junit44-hamcrest - 1.0-SNAPSHOT - Test for JUnit44 with Hamcrest extensions - - - 1.8 - 1.8 - - - - - junit - junit - 4.4 - test - - - - - - - maven-surefire-plugin - ${surefire.version} - - - - - diff --git a/surefire-its/src/test/resources/junit44-hamcrest/src/test/java/junit44/hamcrest/BasicTest.java b/surefire-its/src/test/resources/junit44-hamcrest/src/test/java/junit44/hamcrest/BasicTest.java deleted file mode 100644 index f7c590007b..0000000000 --- a/surefire-its/src/test/resources/junit44-hamcrest/src/test/java/junit44/hamcrest/BasicTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package junit44.hamcrest; - -import org.hamcrest.core.Is; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - - -public class BasicTest -{ - - private boolean setUpCalled = false; - - private static boolean tearDownCalled = false; - - @Before - public void setUp() - { - setUpCalled = true; - tearDownCalled = false; - System.out.println( "Called setUp" ); - } - - @After - public void tearDown() - { - setUpCalled = false; - tearDownCalled = true; - System.out.println( "Called tearDown" ); - } - - @Test - public void testSetUp() - { - Assert.assertTrue( "setUp was not called", setUpCalled ); - Assert.assertThat( true, Is.is( true ) ); - } - - @AfterClass - public static void oneTimeTearDown() - { - Assert.assertTrue( "tearDown was not called", tearDownCalled ); - } - -} diff --git a/surefire-its/src/test/resources/junit44-multiple-methods/pom.xml b/surefire-its/src/test/resources/junit44-multiple-methods/pom.xml index 9858f4cff6..8a7cb3dcee 100644 --- a/surefire-its/src/test/resources/junit44-multiple-methods/pom.xml +++ b/surefire-its/src/test/resources/junit44-multiple-methods/pom.xml @@ -35,13 +35,8 @@ 1.0-SNAPSHOT Test for JUnit 4 - - - 4.4 + 4.12 @@ -58,6 +53,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${surefire.version} junit4/BasicTest#testSuccessOne+testFailOne,junit4/TestThree#testSuccessTwo diff --git a/surefire-its/src/test/resources/junit44-single-method/pom.xml b/surefire-its/src/test/resources/junit44-single-method/pom.xml index 692041d4fd..cc236bb5ed 100644 --- a/surefire-its/src/test/resources/junit44-single-method/pom.xml +++ b/surefire-its/src/test/resources/junit44-single-method/pom.xml @@ -30,7 +30,7 @@ - 4.4 + 4.12 1.8 1.8 diff --git a/surefire-its/src/test/resources/junit47-concurrency/pom.xml b/surefire-its/src/test/resources/junit47-concurrency/pom.xml index 21bd802984..0420d6e07b 100644 --- a/surefire-its/src/test/resources/junit47-concurrency/pom.xml +++ b/surefire-its/src/test/resources/junit47-concurrency/pom.xml @@ -39,7 +39,7 @@ junit junit - 4.7 + 4.12 test diff --git a/surefire-its/src/test/resources/junit47-cucumber/pom.xml b/surefire-its/src/test/resources/junit47-cucumber/pom.xml index a6d0ea4aba..49d70b1295 100644 --- a/surefire-its/src/test/resources/junit47-cucumber/pom.xml +++ b/surefire-its/src/test/resources/junit47-cucumber/pom.xml @@ -46,13 +46,6 @@ 0 true - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/junit47-parallel-nts/pom.xml b/surefire-its/src/test/resources/junit47-parallel-nts/pom.xml index 92a2fb38ec..212c94d4e0 100644 --- a/surefire-its/src/test/resources/junit47-parallel-nts/pom.xml +++ b/surefire-its/src/test/resources/junit47-parallel-nts/pom.xml @@ -46,7 +46,7 @@ junit junit - 4.8.1 + 4.12 com.github.stephenc.jcip @@ -57,7 +57,9 @@ + org.apache.maven.plugins maven-surefire-plugin + ${surefire.version} diff --git a/surefire-its/src/test/resources/junit47-parallel-with-suite/pom.xml b/surefire-its/src/test/resources/junit47-parallel-with-suite/pom.xml deleted file mode 100644 index d0baf0cf51..0000000000 --- a/surefire-its/src/test/resources/junit47-parallel-with-suite/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - 4.0.0 - org.apache.maven.plugins.surefire - junit4-test - jar - 1.0-SNAPSHOT - surefire-747-parallel-method-skips-test - http://maven.apache.org - - - junit - junit - 4.8.1 - - - - methods - 1.8 - 1.8 - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - false - 5 - - **/TestSuite.java - - - - - - diff --git a/surefire-its/src/test/resources/junit47-parallel-with-suite/src/test/java/surefire747/TestSuite.java b/surefire-its/src/test/resources/junit47-parallel-with-suite/src/test/java/surefire747/TestSuite.java deleted file mode 100644 index 499ab1b504..0000000000 --- a/surefire-its/src/test/resources/junit47-parallel-with-suite/src/test/java/surefire747/TestSuite.java +++ /dev/null @@ -1,33 +0,0 @@ -package surefire747; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * @author Kristian Rosenvold - */ -@RunWith(Suite.class) -@Suite.SuiteClasses( -{ - SuiteTest1.class, - SuiteTest2.class -}) -public class TestSuite -{ - private static long startedAt; - - @BeforeClass - public static void beforeClass() - { - startedAt = System.currentTimeMillis(); - } - - @AfterClass - public static void afterClass() - { - System.out.println( String.format( "%s suite finished after duration=%d", TestSuite.class.getSimpleName(), - System.currentTimeMillis() - startedAt ) ); - } -} diff --git a/surefire-its/src/test/resources/junit47-parallel/pom.xml b/surefire-its/src/test/resources/junit47-parallel/pom.xml index ac04eedd37..9a8a6a3fd9 100644 --- a/surefire-its/src/test/resources/junit47-parallel/pom.xml +++ b/surefire-its/src/test/resources/junit47-parallel/pom.xml @@ -48,7 +48,7 @@ junit junit - 4.8.1 + 4.12 diff --git a/surefire-its/src/test/resources/junit47-redirect-output/pom.xml b/surefire-its/src/test/resources/junit47-redirect-output/pom.xml index d953380cbc..2419c514f9 100644 --- a/surefire-its/src/test/resources/junit47-redirect-output/pom.xml +++ b/surefire-its/src/test/resources/junit47-redirect-output/pom.xml @@ -21,13 +21,6 @@ org.apache.maven.plugins maven-surefire-plugin ${surefire.version} - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - ${forkCount} ${reuseForks} @@ -47,7 +40,7 @@ - 4.8.1 + 4.12 true 1 true diff --git a/surefire-its/src/test/resources/junit47-rerun-failing-tests-with-cucumber/pom.xml b/surefire-its/src/test/resources/junit47-rerun-failing-tests-with-cucumber/pom.xml index a26a8f5a05..e320f469bb 100644 --- a/surefire-its/src/test/resources/junit47-rerun-failing-tests-with-cucumber/pom.xml +++ b/surefire-its/src/test/resources/junit47-rerun-failing-tests-with-cucumber/pom.xml @@ -45,13 +45,6 @@ 1 - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/junit47-static-inner-class-tests/pom.xml b/surefire-its/src/test/resources/junit47-static-inner-class-tests/pom.xml index bee90e6f7e..6c52544e90 100644 --- a/surefire-its/src/test/resources/junit47-static-inner-class-tests/pom.xml +++ b/surefire-its/src/test/resources/junit47-static-inner-class-tests/pom.xml @@ -15,7 +15,7 @@ junit junit - 4.8.1 + 4.12 @@ -27,13 +27,6 @@ 0 - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/junit48-categories/pom.xml b/surefire-its/src/test/resources/junit48-categories/pom.xml index 858eabb189..a0137a072e 100644 --- a/surefire-its/src/test/resources/junit48-categories/pom.xml +++ b/surefire-its/src/test/resources/junit48-categories/pom.xml @@ -30,7 +30,7 @@ - 4.8.1 + 4.12 junit4.CategoryA,junit4.CategoryB 1.8 @@ -56,13 +56,6 @@ ${groups} ${excludedGroups} - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/junit48-method-pattern/pom.xml b/surefire-its/src/test/resources/junit48-method-pattern/pom.xml deleted file mode 100644 index c53e9aaa68..0000000000 --- a/surefire-its/src/test/resources/junit48-method-pattern/pom.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - 4.0.0 - - - org.apache.maven.surefire - it-parent - 1.0 - ../pom.xml - - - org.apache.maven.plugins.surefire - junit4 - 1.0-SNAPSHOT - Test for JUnit 4.8.1 - - - 4.8.1 - - - - - junit - junit - ${junitVersion} - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - BasicTest#testSuccess* - 1 - - - - - - - - surefire-junit47 - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - - - - surefire-junit4 - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - - - - - - - tcp - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - - - - diff --git a/surefire-its/src/test/resources/junit48-multiple-method-patterns/pom.xml b/surefire-its/src/test/resources/junit48-multiple-method-patterns/pom.xml deleted file mode 100644 index f307687df3..0000000000 --- a/surefire-its/src/test/resources/junit48-multiple-method-patterns/pom.xml +++ /dev/null @@ -1,195 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.surefire - it-parent - 1.0 - ../pom.xml - - org.apache.maven.plugins.surefire - jiras-surefire-745-junit - 1.0 - - - - - - - - - junit - junit - 4.8.1 - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - - junit4-test - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - - - - - - - junit47-test - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - - - - junit4-includes - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${included} - - - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - - - - - - - junit47-includes - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${included} - - - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - - - - junit4-includes-excludes - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${included} - - - ${excluded} - - - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - - - - - - - junit47-includes-excludes - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${included} - - - ${excluded} - - - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - - - - - diff --git a/surefire-its/src/test/resources/junit48-multiple-methods/src/test/java/junit4/BasicTest.java b/surefire-its/src/test/resources/junit48-multiple-methods/src/test/java/junit4/BasicTest.java deleted file mode 100644 index de387d3586..0000000000 --- a/surefire-its/src/test/resources/junit48-multiple-methods/src/test/java/junit4/BasicTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package junit4; - - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - - -public class BasicTest -{ - - private boolean setUpCalled = false; - - private static boolean tearDownCalled = false; - - @Before - public void setUp() - { - setUpCalled = true; - tearDownCalled = false; - System.out.println( "Called setUp" ); - } - - @After - public void tearDown() - { - setUpCalled = false; - tearDownCalled = true; - System.out.println( "Called tearDown" ); - } - - @Test - public void testSetUp() - { - Assert.assertTrue( "setUp was not called", setUpCalled ); - } - - - @Test - public void testSuccessOne() - { - Assert.assertTrue( true ); - } - - @Test - public void testSuccessTwo() - { - Assert.assertTrue( true ); - } - - @Test - public void testFailOne() - { - Assert.assertFalse( false ); - } - - @AfterClass - public static void oneTimeTearDown() - { - - } - -} diff --git a/surefire-its/src/test/resources/junit48-multiple-methods/src/test/java/junit4/TestTwo.java b/surefire-its/src/test/resources/junit48-multiple-methods/src/test/java/junit4/TestTwo.java deleted file mode 100644 index 137bf8b88c..0000000000 --- a/surefire-its/src/test/resources/junit48-multiple-methods/src/test/java/junit4/TestTwo.java +++ /dev/null @@ -1,76 +0,0 @@ -package junit4; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - - -public class TestTwo -{ - - private boolean setUpCalled = false; - - private static boolean tearDownCalled = false; - - @Before - public void setUp() - { - setUpCalled = true; - tearDownCalled = false; - System.out.println( "Called setUp" ); - } - - @After - public void tearDown() - { - setUpCalled = false; - tearDownCalled = true; - System.out.println( "Called tearDown" ); - } - - @Test - public void testSetUp() - { - Assert.assertTrue( "setUp was not called", setUpCalled ); - } - - - @Test - public void testSuccessOne() - { - Assert.assertTrue( true ); - } - - @Test - public void testSuccessTwo() - { - Assert.assertTrue( true ); - } - - @AfterClass - public static void oneTimeTearDown() - { - - } - -} diff --git a/surefire-its/src/test/resources/junit48-single-method/pom.xml b/surefire-its/src/test/resources/junit48-single-method/pom.xml index a56bf39ecd..ff0ed0ecb9 100644 --- a/surefire-its/src/test/resources/junit48-single-method/pom.xml +++ b/surefire-its/src/test/resources/junit48-single-method/pom.xml @@ -36,7 +36,7 @@ Test for JUnit 4.8.1 - 4.8.1 + 4.12 @@ -69,13 +69,6 @@ org.apache.maven.plugins maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - @@ -87,13 +80,6 @@ org.apache.maven.plugins maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/junit48-smartStackTrace/pom.xml b/surefire-its/src/test/resources/junit48-smartStackTrace/pom.xml index 6b16ad8a13..f35d1d05a0 100644 --- a/surefire-its/src/test/resources/junit48-smartStackTrace/pom.xml +++ b/surefire-its/src/test/resources/junit48-smartStackTrace/pom.xml @@ -30,7 +30,7 @@ - 4.8.1 + 4.12 1.8 1.8 diff --git a/surefire-its/src/test/resources/testng-listeners/pom.xml b/surefire-its/src/test/resources/junit5-multiple-methods/pom.xml similarity index 74% rename from surefire-its/src/test/resources/testng-listeners/pom.xml rename to surefire-its/src/test/resources/junit5-multiple-methods/pom.xml index 904c3915e2..6d7c48d48b 100644 --- a/surefire-its/src/test/resources/testng-listeners/pom.xml +++ b/surefire-its/src/test/resources/junit5-multiple-methods/pom.xml @@ -30,16 +30,29 @@ ../pom.xml - testng-listeners + org.apache.maven.plugins.surefire + junit4 1.0-SNAPSHOT + Test for JUnit 5 + + + + + 5.14.1 + - org.testng - testng - 6.8.8 + org.junit.jupiter + junit-jupiter-api + ${junitVersion} + test + @@ -47,9 +60,10 @@ maven-surefire-plugin ${surefire.version} - 0 + junit5/BasicTest#testSuccessOne+testFailOne,junit5/TestThree#testSuccessTwo + diff --git a/surefire-its/src/test/resources/junit5-multiple-methods/src/test/java/junit5/BasicTest.java b/surefire-its/src/test/resources/junit5-multiple-methods/src/test/java/junit5/BasicTest.java new file mode 100644 index 0000000000..503f885e4e --- /dev/null +++ b/surefire-its/src/test/resources/junit5-multiple-methods/src/test/java/junit5/BasicTest.java @@ -0,0 +1,67 @@ +package junit5; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterClass; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + + +public class BasicTest +{ + + private boolean setUpCalled = false; + + private static boolean tearDownCalled = false; + + @BeforeEach + public void setUp() + { + setUpCalled = true; + tearDownCalled = false; + System.out.println( "Called setUp" ); + } + + @AfterEach + public void tearDown() + { + setUpCalled = false; + tearDownCalled = true; + System.out.println( "Called tearDown" ); + } + + @Test + public void testSetUp() + { + assertTrue( "setUp was not called", setUpCalled ); + } + + + @Test + public void testSuccessOne() + { + assertTrue( true ); + } + + @Test + public void testSuccessTwo() + { + assertTrue( true ); + } + + @Test + public void testFailOne() + { + assertFalse( false ); + } + + @AfterClass + public static void oneTimeTearDown() + { + + } + +} diff --git a/surefire-its/src/test/resources/junit48-multiple-methods/src/test/java/junit4/TestThree.java b/surefire-its/src/test/resources/junit5-multiple-methods/src/test/java/junit5/TestThree.java similarity index 54% rename from surefire-its/src/test/resources/junit48-multiple-methods/src/test/java/junit4/TestThree.java rename to surefire-its/src/test/resources/junit5-multiple-methods/src/test/java/junit5/TestThree.java index e4b6f2b324..392e0ac284 100644 --- a/surefire-its/src/test/resources/junit48-multiple-methods/src/test/java/junit4/TestThree.java +++ b/surefire-its/src/test/resources/junit5-multiple-methods/src/test/java/junit5/TestThree.java @@ -1,10 +1,13 @@ -package junit4; +package junit5; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterClass; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestThree @@ -14,7 +17,7 @@ public class TestThree private static boolean tearDownCalled = false; - @Before + @BeforeEach public void setUp() { setUpCalled = true; @@ -22,7 +25,7 @@ public void setUp() System.out.println( "Called setUp" ); } - @After + @AfterEach public void tearDown() { setUpCalled = false; @@ -33,20 +36,20 @@ public void tearDown() @Test public void testSetUp() { - Assert.assertTrue( "setUp was not called", setUpCalled ); + assertTrue( "setUp was not called", setUpCalled ); } @Test public void testSuccessOne() { - Assert.assertTrue( true ); + assertTrue( true ); } @Test public void testSuccessTwo() { - Assert.assertTrue( true ); + assertTrue( true ); } @AfterClass diff --git a/surefire-its/src/test/resources/junit44-method-pattern/src/test/java/junit4/BasicTest.java b/surefire-its/src/test/resources/junit5-multiple-methods/src/test/java/junit5/TestTwo.java similarity index 53% rename from surefire-its/src/test/resources/junit44-method-pattern/src/test/java/junit4/BasicTest.java rename to surefire-its/src/test/resources/junit5-multiple-methods/src/test/java/junit5/TestTwo.java index 73f3fb40e8..1d62a13710 100644 --- a/surefire-its/src/test/resources/junit44-method-pattern/src/test/java/junit4/BasicTest.java +++ b/surefire-its/src/test/resources/junit5-multiple-methods/src/test/java/junit5/TestTwo.java @@ -1,20 +1,23 @@ -package junit4; +package junit5; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterClass; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class BasicTest +public class TestTwo { private boolean setUpCalled = false; private static boolean tearDownCalled = false; - @Before + @BeforeEach public void setUp() { setUpCalled = true; @@ -22,7 +25,7 @@ public void setUp() System.out.println( "Called setUp" ); } - @After + @AfterEach public void tearDown() { setUpCalled = false; @@ -33,20 +36,20 @@ public void tearDown() @Test public void testSetUp() { - Assert.assertTrue( "setUp was not called", setUpCalled ); + assertTrue( "setUp was not called", setUpCalled ); } @Test public void testSuccessOne() { - Assert.assertTrue( true ); + assertTrue( true ); } @Test public void testSuccessTwo() { - Assert.assertTrue( true ); + assertTrue( true ); } @AfterClass diff --git a/surefire-its/src/test/resources/junit5-runner/pom.xml b/surefire-its/src/test/resources/junit5-runner/pom.xml index ee78e7aa97..8cce07c80a 100644 --- a/surefire-its/src/test/resources/junit5-runner/pom.xml +++ b/surefire-its/src/test/resources/junit5-runner/pom.xml @@ -37,13 +37,13 @@ org.junit.jupiter junit-jupiter-engine - 5.9.1 + 5.12.1 test org.junit.platform junit-platform-runner - 1.9.1 + 1.12.1 test diff --git a/surefire-its/src/test/resources/large-test-results/pom.xml b/surefire-its/src/test/resources/large-test-results/pom.xml index 36caa01070..43131e7179 100644 --- a/surefire-its/src/test/resources/large-test-results/pom.xml +++ b/surefire-its/src/test/resources/large-test-results/pom.xml @@ -47,7 +47,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/modulepath/pom.xml b/surefire-its/src/test/resources/modulepath/pom.xml index f5cc763a70..077e2a0978 100644 --- a/surefire-its/src/test/resources/modulepath/pom.xml +++ b/surefire-its/src/test/resources/modulepath/pom.xml @@ -38,7 +38,7 @@ org.testng testng - 6.11 + 6.14.3 test diff --git a/surefire-its/src/test/resources/norunnableTests/pom.xml b/surefire-its/src/test/resources/norunnableTests/pom.xml index aa9d67bb03..dbf306ea16 100644 --- a/surefire-its/src/test/resources/norunnableTests/pom.xml +++ b/surefire-its/src/test/resources/norunnableTests/pom.xml @@ -37,7 +37,7 @@ junit junit - 4.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/parallel-runtime/pom.xml b/surefire-its/src/test/resources/parallel-runtime/pom.xml index a425b4dc1a..33f2b59d1d 100644 --- a/surefire-its/src/test/resources/parallel-runtime/pom.xml +++ b/surefire-its/src/test/resources/parallel-runtime/pom.xml @@ -11,7 +11,7 @@ junit junit - 4.10 + 4.12 diff --git a/surefire-its/src/test/resources/plain-old-java-classpath/pom.xml b/surefire-its/src/test/resources/plain-old-java-classpath/pom.xml index df60dcf153..f42f0a3fda 100644 --- a/surefire-its/src/test/resources/plain-old-java-classpath/pom.xml +++ b/surefire-its/src/test/resources/plain-old-java-classpath/pom.xml @@ -49,7 +49,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/plexus-conflict/pom.xml b/surefire-its/src/test/resources/plexus-conflict/pom.xml index d15b643dbd..35ea100d2b 100644 --- a/surefire-its/src/test/resources/plexus-conflict/pom.xml +++ b/surefire-its/src/test/resources/plexus-conflict/pom.xml @@ -42,7 +42,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/pojo-simple/pom.xml b/surefire-its/src/test/resources/pojo-simple/pom.xml deleted file mode 100644 index 57c8d705e1..0000000000 --- a/surefire-its/src/test/resources/pojo-simple/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - pojo-simple - 1.0-SNAPSHOT - Pojo simple test - - - 1.8 - 1.8 - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - true - - - - - diff --git a/surefire-its/src/test/resources/pojo-simple/src/test/java/PojoTest.java b/surefire-its/src/test/resources/pojo-simple/src/test/java/PojoTest.java deleted file mode 100644 index 18fad81681..0000000000 --- a/surefire-its/src/test/resources/pojo-simple/src/test/java/PojoTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -public class PojoTest -{ - private static int calls; - - public void setUp() - { - System.out.println( "setUp called " + ++calls ); - } - - public void tearDown() - { - System.out.println( "tearDown called " + calls ); - } - - public void testSuccess() - { - assert true; - } - - public void testFailure() - { - assert false; - } - -} diff --git a/surefire-its/src/test/resources/reporters/pom.xml b/surefire-its/src/test/resources/reporters/pom.xml index f3369ef1fa..599a85b7ce 100644 --- a/surefire-its/src/test/resources/reporters/pom.xml +++ b/surefire-its/src/test/resources/reporters/pom.xml @@ -12,9 +12,13 @@ org.testng testng - 5.8 + 6.14.3 test - jdk15 + + + junit + junit + ${junit.version} @@ -40,7 +44,7 @@ - 4.8.1 + 4.12 true 1 true diff --git a/surefire-its/src/test/resources/reporters/src/test/java/reporters/Test2.java b/surefire-its/src/test/resources/reporters/src/test/java/reporters/Test2.java index 13a532b25f..0a0dfcfd64 100644 --- a/surefire-its/src/test/resources/reporters/src/test/java/reporters/Test2.java +++ b/surefire-its/src/test/resources/reporters/src/test/java/reporters/Test2.java @@ -19,7 +19,6 @@ * under the License. */ - import junit.framework.TestCase; public class Test2 extends TestCase diff --git a/surefire-its/src/test/resources/result-counting/pom.xml b/surefire-its/src/test/resources/result-counting/pom.xml index 243d616f37..9d883db7e2 100644 --- a/surefire-its/src/test/resources/result-counting/pom.xml +++ b/surefire-its/src/test/resources/result-counting/pom.xml @@ -34,7 +34,7 @@ - 4.8.1 + 4.12 1 true 1.8 diff --git a/surefire-its/src/test/resources/runOrder/pom.xml b/surefire-its/src/test/resources/runOrder/pom.xml index 19d0cfdf28..b6464d3835 100644 --- a/surefire-its/src/test/resources/runOrder/pom.xml +++ b/surefire-its/src/test/resources/runOrder/pom.xml @@ -55,7 +55,7 @@ junit junit - 4.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/runorder-parallel/pom.xml b/surefire-its/src/test/resources/runorder-parallel/pom.xml index 0acd6e4982..8bdcb8c9ab 100644 --- a/surefire-its/src/test/resources/runorder-parallel/pom.xml +++ b/surefire-its/src/test/resources/runorder-parallel/pom.xml @@ -11,7 +11,7 @@ junit junit - 4.10 + 4.12 diff --git a/surefire-its/src/test/resources/sibling-aggregator/child1/pom.xml b/surefire-its/src/test/resources/sibling-aggregator/child1/pom.xml index ff06e537ec..c9898b8f14 100644 --- a/surefire-its/src/test/resources/sibling-aggregator/child1/pom.xml +++ b/surefire-its/src/test/resources/sibling-aggregator/child1/pom.xml @@ -37,7 +37,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/sibling-aggregator/child2/pom.xml b/surefire-its/src/test/resources/sibling-aggregator/child2/pom.xml index 6e2914e36f..8ac7778219 100644 --- a/surefire-its/src/test/resources/sibling-aggregator/child2/pom.xml +++ b/surefire-its/src/test/resources/sibling-aggregator/child2/pom.xml @@ -42,7 +42,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/small-result-counting/pom.xml b/surefire-its/src/test/resources/small-result-counting/pom.xml index 338d1baec8..069f006ca6 100644 --- a/surefire-its/src/test/resources/small-result-counting/pom.xml +++ b/surefire-its/src/test/resources/small-result-counting/pom.xml @@ -31,7 +31,7 @@ - 4.8.1 + 4.12 1 true 1.8 diff --git a/surefire-its/src/test/resources/surefire-1004-RunTestFromDependencyJarsTypeAndClassifier/surefire-1004-module1/pom.xml b/surefire-its/src/test/resources/surefire-1004-RunTestFromDependencyJarsTypeAndClassifier/surefire-1004-module1/pom.xml index 6986b5cbd9..6febfb9d30 100644 --- a/surefire-its/src/test/resources/surefire-1004-RunTestFromDependencyJarsTypeAndClassifier/surefire-1004-module1/pom.xml +++ b/surefire-its/src/test/resources/surefire-1004-RunTestFromDependencyJarsTypeAndClassifier/surefire-1004-module1/pom.xml @@ -17,7 +17,7 @@ junit junit - 4.8.1 + 4.12 jar test diff --git a/surefire-its/src/test/resources/surefire-1004-RunTestFromDependencyJarsTypeAndClassifier/surefire-1004-testjar/pom.xml b/surefire-its/src/test/resources/surefire-1004-RunTestFromDependencyJarsTypeAndClassifier/surefire-1004-testjar/pom.xml index 4467908ab7..a576263884 100644 --- a/surefire-its/src/test/resources/surefire-1004-RunTestFromDependencyJarsTypeAndClassifier/surefire-1004-testjar/pom.xml +++ b/surefire-its/src/test/resources/surefire-1004-RunTestFromDependencyJarsTypeAndClassifier/surefire-1004-testjar/pom.xml @@ -17,7 +17,7 @@ junit junit - 4.8.1 + 4.12 jar test diff --git a/surefire-its/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml b/surefire-its/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml index 5285fb1cd3..46184f3fdc 100644 --- a/surefire-its/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml +++ b/surefire-its/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml @@ -36,7 +36,7 @@ junit junit - 4.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml b/surefire-its/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml index c2086144ab..6f9425c110 100644 --- a/surefire-its/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml +++ b/surefire-its/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml @@ -40,7 +40,7 @@ junit junit - 4.8.1 + 4.12 true diff --git a/surefire-its/src/test/resources/surefire-1028-unable-to-run-single-test/pom.xml b/surefire-its/src/test/resources/surefire-1028-unable-to-run-single-test/pom.xml index 8598f1e6ac..7ee9632ef0 100644 --- a/surefire-its/src/test/resources/surefire-1028-unable-to-run-single-test/pom.xml +++ b/surefire-its/src/test/resources/surefire-1028-unable-to-run-single-test/pom.xml @@ -46,7 +46,7 @@ junit junit - 4.10 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1036-NonFilterableJUnitRunnerWithCategories/pom.xml b/surefire-its/src/test/resources/surefire-1036-NonFilterableJUnitRunnerWithCategories/pom.xml index 6fefa7d176..5acc4e085b 100644 --- a/surefire-its/src/test/resources/surefire-1036-NonFilterableJUnitRunnerWithCategories/pom.xml +++ b/surefire-its/src/test/resources/surefire-1036-NonFilterableJUnitRunnerWithCategories/pom.xml @@ -46,7 +46,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml b/surefire-its/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml index 7630c4ea84..1080d1aee8 100644 --- a/surefire-its/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml +++ b/surefire-its/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml @@ -37,13 +37,6 @@ 1 - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - @@ -52,7 +45,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1053-system-properties/pom.xml b/surefire-its/src/test/resources/surefire-1053-system-properties/pom.xml index 3df1d01caa..b93d1c8693 100644 --- a/surefire-its/src/test/resources/surefire-1053-system-properties/pom.xml +++ b/surefire-its/src/test/resources/surefire-1053-system-properties/pom.xml @@ -45,7 +45,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1055-parallelTestCount/pom.xml b/surefire-its/src/test/resources/surefire-1055-parallelTestCount/pom.xml index 6e4bfdf2a8..c087203c79 100644 --- a/surefire-its/src/test/resources/surefire-1055-parallelTestCount/pom.xml +++ b/surefire-its/src/test/resources/surefire-1055-parallelTestCount/pom.xml @@ -43,7 +43,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1080-parallel-fork-double-test/pom.xml b/surefire-its/src/test/resources/surefire-1080-parallel-fork-double-test/pom.xml index 4f6e96617c..c8a59abc49 100644 --- a/surefire-its/src/test/resources/surefire-1080-parallel-fork-double-test/pom.xml +++ b/surefire-its/src/test/resources/surefire-1080-parallel-fork-double-test/pom.xml @@ -53,7 +53,7 @@ junit junit - 4.7 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1082-parallel-junit-parameterized/pom.xml b/surefire-its/src/test/resources/surefire-1082-parallel-junit-parameterized/pom.xml index 869a8a6b80..6507d9c41d 100644 --- a/surefire-its/src/test/resources/surefire-1082-parallel-junit-parameterized/pom.xml +++ b/surefire-its/src/test/resources/surefire-1082-parallel-junit-parameterized/pom.xml @@ -48,7 +48,7 @@ junit junit - 4.7 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1098-balanced-runorder/pom.xml b/surefire-its/src/test/resources/surefire-1098-balanced-runorder/pom.xml index 75f1c8e30d..24ab0e4b3e 100644 --- a/surefire-its/src/test/resources/surefire-1098-balanced-runorder/pom.xml +++ b/surefire-its/src/test/resources/surefire-1098-balanced-runorder/pom.xml @@ -45,7 +45,7 @@ junit junit - 4.7 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1122-parallel-and-flakyTests/pom.xml b/surefire-its/src/test/resources/surefire-1122-parallel-and-flakyTests/pom.xml index e620e2788c..41b6b8360b 100644 --- a/surefire-its/src/test/resources/surefire-1122-parallel-and-flakyTests/pom.xml +++ b/surefire-its/src/test/resources/surefire-1122-parallel-and-flakyTests/pom.xml @@ -34,7 +34,7 @@ junit junit - 4.11 + 4.12 test @@ -44,13 +44,6 @@ maven-surefire-plugin ${surefire.version} - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - 2 diff --git a/surefire-its/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml b/surefire-its/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml index 84b69f69b0..fac962da19 100644 --- a/surefire-its/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml +++ b/surefire-its/src/test/resources/surefire-1135-improve-ignore-message-for-testng/pom.xml @@ -33,36 +33,14 @@ 1.8 1.8 - - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - + + + + org.testng + testng + ${testNgVersion} + + diff --git a/surefire-its/src/test/resources/surefire-1136-cwd-propagation-in-forked-mode/pom.xml b/surefire-its/src/test/resources/surefire-1136-cwd-propagation-in-forked-mode/pom.xml index 1d34cbcac8..2bfb311fba 100644 --- a/surefire-its/src/test/resources/surefire-1136-cwd-propagation-in-forked-mode/pom.xml +++ b/surefire-its/src/test/resources/surefire-1136-cwd-propagation-in-forked-mode/pom.xml @@ -43,7 +43,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1144-xml-runtime/pom.xml b/surefire-its/src/test/resources/surefire-1144-xml-runtime/pom.xml index b1834144af..e142b1fe33 100644 --- a/surefire-its/src/test/resources/surefire-1144-xml-runtime/pom.xml +++ b/surefire-its/src/test/resources/surefire-1144-xml-runtime/pom.xml @@ -44,7 +44,7 @@ junit junit - 4.0 + 4.12 diff --git a/surefire-its/src/test/resources/surefire-1152-rerunFailingTestsCount-suite/pom.xml b/surefire-its/src/test/resources/surefire-1152-rerunFailingTestsCount-suite/pom.xml index bdba56b8a4..4c1d8c5142 100644 --- a/surefire-its/src/test/resources/surefire-1152-rerunFailingTestsCount-suite/pom.xml +++ b/surefire-its/src/test/resources/surefire-1152-rerunFailingTestsCount-suite/pom.xml @@ -70,72 +70,11 @@ - - - surefire-junit47 - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - - - - surefire-junit4 - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - - - - - - - junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1158-remove-info-lines/pom.xml b/surefire-its/src/test/resources/surefire-1158-remove-info-lines/pom.xml deleted file mode 100644 index 954a31c284..0000000000 --- a/surefire-its/src/test/resources/surefire-1158-remove-info-lines/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - 4.0.0 - - - org.apache.maven.surefire - it-parent - 1.0 - - - org.apache.maven.plugins.surefire - surefire-1158 - 1.0 - - - - org.testng - testng - 5.7 - jdk15 - - - junit - junit - 4.7 - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - 1 - false - - - - org.apache.maven.surefire - ${provider} - ${surefire.version} - - - - - - - diff --git a/surefire-its/src/test/resources/surefire-1158-remove-info-lines/src/test/java/jira1158/JUnitTest.java b/surefire-its/src/test/resources/surefire-1158-remove-info-lines/src/test/java/jira1158/JUnitTest.java deleted file mode 100644 index 1d1c23f57b..0000000000 --- a/surefire-its/src/test/resources/surefire-1158-remove-info-lines/src/test/java/jira1158/JUnitTest.java +++ /dev/null @@ -1,12 +0,0 @@ -package jira1158; - -import org.junit.Test; - -public class JUnitTest { - - @Test - public void doNothing() - { - - } -} diff --git a/surefire-its/src/test/resources/surefire-1158-remove-info-lines/src/test/java/jira1158/TestNGSuiteTest.java b/surefire-its/src/test/resources/surefire-1158-remove-info-lines/src/test/java/jira1158/TestNGSuiteTest.java deleted file mode 100644 index 00fa52a8b2..0000000000 --- a/surefire-its/src/test/resources/surefire-1158-remove-info-lines/src/test/java/jira1158/TestNGSuiteTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package jira1158; - -import org.testng.annotations.Test; - - -public class TestNGSuiteTest { - - @Test - public void doNothing() - { - - } -} diff --git a/surefire-its/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml b/surefire-its/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml index e61abeb6f2..3fd08286af 100644 --- a/surefire-its/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml +++ b/surefire-its/src/test/resources/surefire-1179-testng-parallel-dataprovider/pom.xml @@ -46,8 +46,7 @@ org.testng testng - 5.10 - jdk15 + 6.14.3 @@ -70,4 +69,4 @@ - \ No newline at end of file + diff --git a/surefire-its/src/test/resources/surefire-1185/pom.xml b/surefire-its/src/test/resources/surefire-1185/pom.xml index ca15310d84..5b76342d23 100644 --- a/surefire-its/src/test/resources/surefire-1185/pom.xml +++ b/surefire-its/src/test/resources/surefire-1185/pom.xml @@ -45,7 +45,7 @@ junit junit - 4.0 + 4.12 test @@ -53,13 +53,6 @@ maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/surefire-1202-rerun-and-failfast/pom.xml b/surefire-its/src/test/resources/surefire-1202-rerun-and-failfast/pom.xml index fc1caa724d..976fb553ae 100644 --- a/surefire-its/src/test/resources/surefire-1202-rerun-and-failfast/pom.xml +++ b/surefire-its/src/test/resources/surefire-1202-rerun-and-failfast/pom.xml @@ -45,15 +45,6 @@ 1.8 - - - junit - junit - 4.12 - test - - - @@ -73,41 +64,21 @@ - - junit47 - - true - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - - junit4 + + + junit + junit + 4.12 + test + + org.apache.maven.plugins maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/surefire-1209-rerun-and-forkcount/pom.xml b/surefire-its/src/test/resources/surefire-1209-rerun-and-forkcount/pom.xml index fc2b58abd5..484ba4e91d 100644 --- a/surefire-its/src/test/resources/surefire-1209-rerun-and-forkcount/pom.xml +++ b/surefire-its/src/test/resources/surefire-1209-rerun-and-forkcount/pom.xml @@ -81,13 +81,6 @@ org.apache.maven.plugins maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - @@ -99,13 +92,6 @@ org.apache.maven.plugins maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit4 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/surefire-1211/pom.xml b/surefire-its/src/test/resources/surefire-1211/pom.xml index 3572a954b6..dfd55b75ab 100644 --- a/surefire-its/src/test/resources/surefire-1211/pom.xml +++ b/surefire-its/src/test/resources/surefire-1211/pom.xml @@ -41,12 +41,12 @@ org.testng testng - 6.9.4 + 6.14.3 junit junit - 4.10 + 4.12 @@ -55,6 +55,7 @@ org.apache.maven.plugins maven-surefire-plugin + ${surefire.version} 1 diff --git a/surefire-its/src/test/resources/surefire-1260-new-tests-pattern/pom.xml b/surefire-its/src/test/resources/surefire-1260-new-tests-pattern/pom.xml index 5f3df665d3..4efa866c28 100644 --- a/surefire-its/src/test/resources/surefire-1260-new-tests-pattern/pom.xml +++ b/surefire-its/src/test/resources/surefire-1260-new-tests-pattern/pom.xml @@ -53,7 +53,7 @@ junit junit - 4.0 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1264/pom.xml b/surefire-its/src/test/resources/surefire-1264/pom.xml index aad5867f77..7ff53454f7 100644 --- a/surefire-its/src/test/resources/surefire-1264/pom.xml +++ b/surefire-its/src/test/resources/surefire-1264/pom.xml @@ -29,13 +29,6 @@ ${canFail} - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/surefire-1278-group-name-ending/pom.xml b/surefire-its/src/test/resources/surefire-1278-group-name-ending/pom.xml index 6d04864282..47e530d7e6 100644 --- a/surefire-its/src/test/resources/surefire-1278-group-name-ending/pom.xml +++ b/surefire-its/src/test/resources/surefire-1278-group-name-ending/pom.xml @@ -37,7 +37,7 @@ org.testng testng - 6.8.7 + 6.14.3 test diff --git a/surefire-its/src/test/resources/surefire-1360-disable-properties-element/pom.xml b/surefire-its/src/test/resources/surefire-1360-disable-properties-element/pom.xml index cbcafd5086..54c71140cf 100644 --- a/surefire-its/src/test/resources/surefire-1360-disable-properties-element/pom.xml +++ b/surefire-its/src/test/resources/surefire-1360-disable-properties-element/pom.xml @@ -38,7 +38,7 @@ junit junit - 4.0 + 4.12 diff --git a/surefire-its/src/test/resources/surefire-1360-enable-properties-element/pom.xml b/surefire-its/src/test/resources/surefire-1360-enable-properties-element/pom.xml index 10d85898b8..04e79a6974 100644 --- a/surefire-its/src/test/resources/surefire-1360-enable-properties-element/pom.xml +++ b/surefire-its/src/test/resources/surefire-1360-enable-properties-element/pom.xml @@ -38,7 +38,7 @@ junit junit - 4.0 + 4.12 diff --git a/surefire-its/src/test/resources/surefire-1364/pom.xml b/surefire-its/src/test/resources/surefire-1364/pom.xml index 3e149b08f1..55484cc084 100644 --- a/surefire-its/src/test/resources/surefire-1364/pom.xml +++ b/surefire-its/src/test/resources/surefire-1364/pom.xml @@ -74,53 +74,13 @@ - - junit3 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit3 - ${surefire.version} - - - - - - - - - junit47 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - - - testng org.testng testng - 6.8.21 + 6.14.3 test @@ -136,17 +96,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.surefire - surefire-testng - ${surefire.version} - - - diff --git a/surefire-its/src/test/resources/surefire-1383/runner/pom.xml b/surefire-its/src/test/resources/surefire-1383/runner/pom.xml index c058868d6d..cb828ffc1a 100644 --- a/surefire-its/src/test/resources/surefire-1383/runner/pom.xml +++ b/surefire-its/src/test/resources/surefire-1383/runner/pom.xml @@ -33,7 +33,7 @@ org.testng testng - 6.5.1 + 6.14.3 diff --git a/surefire-its/src/test/resources/surefire-1396-pluggableproviders-classpath/pom.xml b/surefire-its/src/test/resources/surefire-1396-pluggableproviders-classpath/pom.xml index 0387efbdc0..46ba28db2f 100644 --- a/surefire-its/src/test/resources/surefire-1396-pluggableproviders-classpath/pom.xml +++ b/surefire-its/src/test/resources/surefire-1396-pluggableproviders-classpath/pom.xml @@ -37,7 +37,7 @@ junit junit - 4.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-141-pluggableproviders/pom.xml b/surefire-its/src/test/resources/surefire-141-pluggableproviders/pom.xml index 335ffcc1f2..be251bd3f9 100644 --- a/surefire-its/src/test/resources/surefire-141-pluggableproviders/pom.xml +++ b/surefire-its/src/test/resources/surefire-141-pluggableproviders/pom.xml @@ -32,7 +32,7 @@ junit junit - 4.8.1 + 4.12 test @@ -52,7 +52,7 @@ org.apache.maven.surefire surefire-junit3 - ${surefire.version} + 3.5.4 org.apache.maven.plugins.surefire diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/pom.xml b/surefire-its/src/test/resources/surefire-1535-parallel-testng/pom.xml deleted file mode 100644 index 18addd70db..0000000000 --- a/surefire-its/src/test/resources/surefire-1535-parallel-testng/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - surefire-1535-parallel-testng - 1.0-SNAPSHOT - Test execution testng suites in parallel - - - 1.8 - 1.8 - - - - - org.testng - testng - 6.13.1 - test - - - - - - forked-reports-directory - - - - - maven-surefire-plugin - - target/surefire-reports-${surefire.forkNumber} - - - - - - - - - - - - maven-surefire-plugin - ${surefire.version} - - false - - src/test/resources/Suite1.xml - src/test/resources/Suite2.xml - - - - surefire.testng.verbose - 1 - - - - - - - - diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest1.java b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest1.java deleted file mode 100644 index d23bb277cf..0000000000 --- a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest1.java +++ /dev/null @@ -1,16 +0,0 @@ -package it; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.util.concurrent.TimeUnit; - -@Test -public class ParallelTest1 -{ - public void test() throws Exception - { - System.out.println( "test 1" ); - TimeUnit.SECONDS.sleep( 1L ); - } -} diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest2.java b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest2.java deleted file mode 100644 index 17b7837fbd..0000000000 --- a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest2.java +++ /dev/null @@ -1,16 +0,0 @@ -package it; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.util.concurrent.TimeUnit; - -@Test -public class ParallelTest2 -{ - public void test() throws Exception - { - System.out.println( "test 2" ); - TimeUnit.SECONDS.sleep( 1L ); - } -} diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite1.xml b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite1.xml deleted file mode 100644 index b6ca16bd68..0000000000 --- a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite1.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite2.xml b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite2.xml deleted file mode 100644 index aef1754f6e..0000000000 --- a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite2.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/surefire-its/src/test/resources/surefire-1602/integration-tests/pom.xml b/surefire-its/src/test/resources/surefire-1602/integration-tests/pom.xml index c2016a21da..ce3d41be45 100644 --- a/surefire-its/src/test/resources/surefire-1602/integration-tests/pom.xml +++ b/surefire-its/src/test/resources/surefire-1602/integration-tests/pom.xml @@ -22,7 +22,7 @@ junit junit - 4.12 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1602/unit-tests/pom.xml b/surefire-its/src/test/resources/surefire-1602/unit-tests/pom.xml index 2e116a10b3..add42abfa7 100644 --- a/surefire-its/src/test/resources/surefire-1602/unit-tests/pom.xml +++ b/surefire-its/src/test/resources/surefire-1602/unit-tests/pom.xml @@ -22,7 +22,7 @@ junit junit - 4.12 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/pom.xml b/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/pom.xml index 5ea0007603..2700217e35 100644 --- a/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/pom.xml +++ b/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/pom.xml @@ -39,7 +39,7 @@ junit junit - 4.0 + 4.12 log4j diff --git a/surefire-its/src/test/resources/surefire-1934-disable-out-err-elements/pom.xml b/surefire-its/src/test/resources/surefire-1934-disable-out-err-elements/pom.xml index 4deef9036e..116d52c284 100644 --- a/surefire-its/src/test/resources/surefire-1934-disable-out-err-elements/pom.xml +++ b/surefire-its/src/test/resources/surefire-1934-disable-out-err-elements/pom.xml @@ -38,7 +38,7 @@ junit junit - 4.0 + 4.12 org.slf4j diff --git a/surefire-its/src/test/resources/surefire-1934-enable-out-err-elements/pom.xml b/surefire-its/src/test/resources/surefire-1934-enable-out-err-elements/pom.xml index a3ed9d4fd3..1fe14ef8b0 100644 --- a/surefire-its/src/test/resources/surefire-1934-enable-out-err-elements/pom.xml +++ b/surefire-its/src/test/resources/surefire-1934-enable-out-err-elements/pom.xml @@ -38,7 +38,7 @@ junit junit - 4.0 + 4.12 org.slf4j diff --git a/surefire-its/src/test/resources/surefire-2036/pom.xml b/surefire-its/src/test/resources/surefire-2036/pom.xml index 73c7116d53..bd1349c832 100644 --- a/surefire-its/src/test/resources/surefire-2036/pom.xml +++ b/surefire-its/src/test/resources/surefire-2036/pom.xml @@ -46,6 +46,12 @@ 1.9.1 test + + junit + junit + 4.13.2 + compile + @@ -53,7 +59,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${surefire.version} + ${surefire.version} org.apache.maven.surefire @@ -61,6 +67,14 @@ ${surefire.version} + + + + junit + false + + + diff --git a/surefire-its/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml b/surefire-its/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml index eee2fc04d4..263687ab3e 100644 --- a/surefire-its/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml +++ b/surefire-its/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml @@ -37,7 +37,7 @@ junit junit - 4.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-34-securityManager-success/pom.xml b/surefire-its/src/test/resources/surefire-34-securityManager-success/pom.xml deleted file mode 100644 index d409355950..0000000000 --- a/surefire-its/src/test/resources/surefire-34-securityManager-success/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - surefire34 - 1.0-SNAPSHOT - Surefire-34-SecurityManager - - - 3.8.1 - 1.8 - 1.8 - - - - - junit - junit - ${junitVersion} - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - - java.lang.SecurityManager - - - - - - - diff --git a/surefire-its/src/test/resources/surefire-34-securityManager-success/src/test/java/junit4/SecurityManagerTest.java b/surefire-its/src/test/resources/surefire-34-securityManager-success/src/test/java/junit4/SecurityManagerTest.java deleted file mode 100644 index 30c4c074ae..0000000000 --- a/surefire-its/src/test/resources/surefire-34-securityManager-success/src/test/java/junit4/SecurityManagerTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package junit4; - -import junit.framework.TestCase; - - -public class SecurityManagerTest - extends TestCase -{ - - private boolean setUpCalled = false; - - private static boolean tearDownCalled = false; - - public void setUp() - { - setUpCalled = true; - tearDownCalled = false; - System.out.println( "Called setUp" ); - } - - public void tearDown() - { - setUpCalled = false; - tearDownCalled = true; - System.out.println( "Called tearDown" ); - } - - public void testSetUp() - { - assertTrue( "setUp was not called", setUpCalled ); - } - - public void testNotMuch() - { - } - -} diff --git a/surefire-its/src/test/resources/surefire-34-securityManager/pom.xml b/surefire-its/src/test/resources/surefire-34-securityManager/pom.xml deleted file mode 100644 index d409355950..0000000000 --- a/surefire-its/src/test/resources/surefire-34-securityManager/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - surefire34 - 1.0-SNAPSHOT - Surefire-34-SecurityManager - - - 3.8.1 - 1.8 - 1.8 - - - - - junit - junit - ${junitVersion} - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - - java.lang.SecurityManager - - - - - - - diff --git a/surefire-its/src/test/resources/surefire-34-securityManager/src/test/java/junit4/SecurityManagerTest.java b/surefire-its/src/test/resources/surefire-34-securityManager/src/test/java/junit4/SecurityManagerTest.java deleted file mode 100644 index c4d9889202..0000000000 --- a/surefire-its/src/test/resources/surefire-34-securityManager/src/test/java/junit4/SecurityManagerTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package junit4; - -import java.io.File; - -import junit.framework.TestCase; - - -public class SecurityManagerTest - extends TestCase -{ - - private boolean setUpCalled = false; - - private static boolean tearDownCalled = false; - - public void setUp() - { - setUpCalled = true; - tearDownCalled = false; - System.out.println( "Called setUp" ); - } - - public void tearDown() - { - setUpCalled = false; - tearDownCalled = true; - System.out.println( "Called tearDown" ); - } - - public void testSetUp() - { - assertTrue( "setUp was not called", setUpCalled ); - } - - public void testWillFailWhenAccessingCurrentDirectory() - { - File file = new File( "." ); - file.isDirectory(); - } - -} diff --git a/surefire-its/src/test/resources/surefire-408-manual-provider-selection/pom.xml b/surefire-its/src/test/resources/surefire-408-manual-provider-selection/pom.xml index b48adfe301..35da5e0ef7 100644 --- a/surefire-its/src/test/resources/surefire-408-manual-provider-selection/pom.xml +++ b/surefire-its/src/test/resources/surefire-408-manual-provider-selection/pom.xml @@ -37,7 +37,7 @@ junit junit - 4.8.1 + 4.12 test @@ -52,23 +52,8 @@ org.apache.maven.surefire surefire-junit3 - ${surefire.version} + 3.5.4 - diff --git a/surefire-its/src/test/resources/surefire-500-puzzling-error/pom.xml b/surefire-its/src/test/resources/surefire-500-puzzling-error/pom.xml index ccd82acb50..d4c50891b5 100644 --- a/surefire-its/src/test/resources/surefire-500-puzzling-error/pom.xml +++ b/surefire-its/src/test/resources/surefire-500-puzzling-error/pom.xml @@ -8,7 +8,7 @@ surefire-500-puzzling-error http://maven.apache.org - 4.4 + 4.12 1.8 1.8 diff --git a/surefire-its/src/test/resources/surefire-510-testClassPath/pom.xml b/surefire-its/src/test/resources/surefire-510-testClassPath/pom.xml index 6cb2b507c8..efb45c1b5e 100644 --- a/surefire-its/src/test/resources/surefire-510-testClassPath/pom.xml +++ b/surefire-its/src/test/resources/surefire-510-testClassPath/pom.xml @@ -50,7 +50,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-569-RunTestFromDependencyJars/module1/pom.xml b/surefire-its/src/test/resources/surefire-569-RunTestFromDependencyJars/module1/pom.xml index d173770b54..424d3bebec 100644 --- a/surefire-its/src/test/resources/surefire-569-RunTestFromDependencyJars/module1/pom.xml +++ b/surefire-its/src/test/resources/surefire-569-RunTestFromDependencyJars/module1/pom.xml @@ -17,7 +17,7 @@ junit junit - 4.8.1 + 4.12 jar test @@ -47,4 +47,4 @@ - \ No newline at end of file + diff --git a/surefire-its/src/test/resources/surefire-569-RunTestFromDependencyJars/testjar/pom.xml b/surefire-its/src/test/resources/surefire-569-RunTestFromDependencyJars/testjar/pom.xml index 7778331030..9062387327 100644 --- a/surefire-its/src/test/resources/surefire-569-RunTestFromDependencyJars/testjar/pom.xml +++ b/surefire-its/src/test/resources/surefire-569-RunTestFromDependencyJars/testjar/pom.xml @@ -17,7 +17,7 @@ junit junit - 4.8.1 + 4.12 jar test @@ -44,4 +44,4 @@ - \ No newline at end of file + diff --git a/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/module1/pom.xml b/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/module1/pom.xml index 5b8fd7c33d..b8d8974b2b 100644 --- a/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/module1/pom.xml +++ b/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/module1/pom.xml @@ -15,9 +15,9 @@ junit junit - 3.8.2 + 4.12 jar test - \ No newline at end of file + diff --git a/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/module2/pom.xml b/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/module2/pom.xml index 9972a510dd..1dfe9218e1 100644 --- a/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/module2/pom.xml +++ b/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/module2/pom.xml @@ -15,9 +15,9 @@ junit junit - 3.8.2 + 4.12 jar test - \ No newline at end of file + diff --git a/surefire-its/src/test/resources/surefire-613-testCount-in-parallel/pom.xml b/surefire-its/src/test/resources/surefire-613-testCount-in-parallel/pom.xml index f2d008a851..bae2864d4a 100644 --- a/surefire-its/src/test/resources/surefire-613-testCount-in-parallel/pom.xml +++ b/surefire-its/src/test/resources/surefire-613-testCount-in-parallel/pom.xml @@ -15,7 +15,7 @@ junit junit - 4.8.1 + 4.12 diff --git a/surefire-its/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml b/surefire-its/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml index 1291723055..62961a8e77 100644 --- a/surefire-its/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml +++ b/surefire-its/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml @@ -8,7 +8,7 @@ junit-test http://maven.apache.org - 4.8.1 + 4.12 1.8 1.8 @@ -128,13 +128,6 @@ - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - @@ -202,13 +195,6 @@ - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/surefire-628-consoleoutputbeforeandafterclass/pom.xml b/surefire-its/src/test/resources/surefire-628-consoleoutputbeforeandafterclass/pom.xml index 9685535979..c6b0ae486c 100644 --- a/surefire-its/src/test/resources/surefire-628-consoleoutputbeforeandafterclass/pom.xml +++ b/surefire-its/src/test/resources/surefire-628-consoleoutputbeforeandafterclass/pom.xml @@ -8,7 +8,7 @@ junit4-test http://maven.apache.org - 4.8.1 + 4.12 methods 1.8 1.8 diff --git a/surefire-its/src/test/resources/surefire-634-systemPropertiesWarning/pom.xml b/surefire-its/src/test/resources/surefire-634-systemPropertiesWarning/pom.xml index 45e1ff128d..adb882361c 100644 --- a/surefire-its/src/test/resources/surefire-634-systemPropertiesWarning/pom.xml +++ b/surefire-its/src/test/resources/surefire-634-systemPropertiesWarning/pom.xml @@ -29,7 +29,7 @@ Test for warning about system properties that cannot be set - 4.4 + 4.12 1.8 1.8 diff --git a/surefire-its/src/test/resources/surefire-649-systemProperties/pom.xml b/surefire-its/src/test/resources/surefire-649-systemProperties/pom.xml index 985d8df1f6..ba0953a141 100644 --- a/surefire-its/src/test/resources/surefire-649-systemProperties/pom.xml +++ b/surefire-its/src/test/resources/surefire-649-systemProperties/pom.xml @@ -45,7 +45,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-649-systemPropertyVariables/pom.xml b/surefire-its/src/test/resources/surefire-649-systemPropertyVariables/pom.xml index e7a7fadcbd..967e862b34 100644 --- a/surefire-its/src/test/resources/surefire-649-systemPropertyVariables/pom.xml +++ b/surefire-its/src/test/resources/surefire-649-systemPropertyVariables/pom.xml @@ -45,7 +45,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-673-mockito/pom.xml b/surefire-its/src/test/resources/surefire-673-mockito/pom.xml index acbb2602fb..aaf737eafe 100644 --- a/surefire-its/src/test/resources/surefire-673-mockito/pom.xml +++ b/surefire-its/src/test/resources/surefire-673-mockito/pom.xml @@ -24,7 +24,7 @@ junit junit - 4.8.2 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-674-buildFailingWhenErrors/pom.xml b/surefire-its/src/test/resources/surefire-674-buildFailingWhenErrors/pom.xml index 155bfcaf91..60af498efe 100644 --- a/surefire-its/src/test/resources/surefire-674-buildFailingWhenErrors/pom.xml +++ b/surefire-its/src/test/resources/surefire-674-buildFailingWhenErrors/pom.xml @@ -34,7 +34,7 @@ - 4.8.1 + 4.12 1 true 1.8 diff --git a/surefire-its/src/test/resources/surefire-685-commaseparatedIncludes/pom.xml b/surefire-its/src/test/resources/surefire-685-commaseparatedIncludes/pom.xml index 178a089181..9612405ebe 100644 --- a/surefire-its/src/test/resources/surefire-685-commaseparatedIncludes/pom.xml +++ b/surefire-its/src/test/resources/surefire-685-commaseparatedIncludes/pom.xml @@ -37,7 +37,7 @@ junit junit - 4.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-697-niceSummary/pom.xml b/surefire-its/src/test/resources/surefire-697-niceSummary/pom.xml index 3772db131c..6051e1f60a 100644 --- a/surefire-its/src/test/resources/surefire-697-niceSummary/pom.xml +++ b/surefire-its/src/test/resources/surefire-697-niceSummary/pom.xml @@ -37,7 +37,7 @@ junit junit - 3.8.1 + 4.13.2 test diff --git a/surefire-its/src/test/resources/surefire-733-allOverridesCaptured/pom.xml b/surefire-its/src/test/resources/surefire-733-allOverridesCaptured/pom.xml index 1350dd4bc3..0198c88a80 100644 --- a/surefire-its/src/test/resources/surefire-733-allOverridesCaptured/pom.xml +++ b/surefire-its/src/test/resources/surefire-733-allOverridesCaptured/pom.xml @@ -49,7 +49,7 @@ - 4.8.1 + 4.12 1.8 1.8 diff --git a/surefire-its/src/test/resources/surefire-772-no-reports/pom.xml b/surefire-its/src/test/resources/surefire-772-no-reports/pom.xml index ab991666f3..d2930eda2a 100644 --- a/surefire-its/src/test/resources/surefire-772-no-reports/pom.xml +++ b/surefire-its/src/test/resources/surefire-772-no-reports/pom.xml @@ -32,7 +32,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/pom.xml b/surefire-its/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/pom.xml index f2fe509f90..b4727a7462 100644 --- a/surefire-its/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/pom.xml +++ b/surefire-its/src/test/resources/surefire-803-multiFailsafeExec-failureInFirst/pom.xml @@ -19,7 +19,7 @@ junit junit - 4.8.2 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-803-multiFailsafeExec-rebuildOverwrites/pom.xml b/surefire-its/src/test/resources/surefire-803-multiFailsafeExec-rebuildOverwrites/pom.xml index 2791186e90..c37b2b72f8 100644 --- a/surefire-its/src/test/resources/surefire-803-multiFailsafeExec-rebuildOverwrites/pom.xml +++ b/surefire-its/src/test/resources/surefire-803-multiFailsafeExec-rebuildOverwrites/pom.xml @@ -19,7 +19,7 @@ junit junit - 4.8.2 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/BasicTest.java b/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/BasicTest.java deleted file mode 100644 index 672e1c28ca..0000000000 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/BasicTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package junit4; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; - - -public class BasicTest -{ - static int catACount = 0; - static int catBCount = 0; - static int catCCount = 0; - static int catNoneCount = 0; - - @Rule - public TestName testName = new TestName(); - - @Before - public void testName() - { - System.out.println( "Running " + getClass().getName() + "." + testName.getMethodName() ); - } - - @Test - @Category(CategoryA.class) - public void testInCategoryA() - { - catACount++; - } - - @Test - @Category(CategoryB.class) - public void testInCategoryB() - { - catBCount++; - } - - @Test - @Category({CategoryA.class, CategoryB.class}) - public void testInCategoryAB() - { - catACount++; - catBCount++; - } - - @Test - @Category(CategoryC.class) - public void testInCategoryC() - { - catCCount++; - } - - @Test - public void testInNoCategory() - { - catNoneCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("catA: " + catACount + "\n" + - "catB: " + catBCount + "\n" + - "catC: " + catCCount + "\n" + - "catNone: " + catNoneCount); - } -} diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryA.java b/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryA.java deleted file mode 100644 index 9b8b855a60..0000000000 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryA.java +++ /dev/null @@ -1,21 +0,0 @@ -package junit4; -/* - * 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. - */ - -interface CategoryA {} diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryB.java b/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryB.java deleted file mode 100644 index f10f3b14be..0000000000 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryB.java +++ /dev/null @@ -1,21 +0,0 @@ -package junit4; -/* - * 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. - */ - -interface CategoryB {} diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryC.java b/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryC.java deleted file mode 100644 index 3e9e8542f0..0000000000 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryC.java +++ /dev/null @@ -1,21 +0,0 @@ -package junit4; -/* - * 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. - */ - -interface CategoryC {} diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryCTest.java b/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryCTest.java deleted file mode 100644 index f69e070b15..0000000000 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryCTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package junit4; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; - - -@Category(CategoryC.class) -public class CategoryCTest -{ - static int catACount = 0; - static int catBCount = 0; - static int catCCount = 0; - - @Rule - public TestName testName = new TestName(); - - @Before - public void testName() - { - System.out.println( "Running " + getClass().getName() + "." + testName.getMethodName() ); - } - - @Test - @Category( CategoryA.class ) - public void testInCategoryA() - { - catACount++; - } - - @Test - @Category(CategoryB.class) - public void testInCategoryB() - { - catBCount++; - } - - @Test - @Category({CategoryA.class, CategoryB.class}) - public void testInCategoriesAB() - { - catACount++; - catBCount++; - } - - @Test - public void testInCategoryC() - { - catCCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("mA: " + catACount + "\n" + - "mB: " + catBCount + "\n" + - "mC: " + catCCount ); - } -} diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/NoCategoryTest.java b/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/NoCategoryTest.java deleted file mode 100644 index 8cb62d1107..0000000000 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/NoCategoryTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package junit4; -import org.junit.AfterClass; -import org.junit.Test; - -public class NoCategoryTest { - static int catNoneCount = 0; - - @Test - public void testInNoCategory() - { - catNoneCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("NoCategoryTest.CatNone: " + catNoneCount); - } -} diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-testng/pom.xml b/surefire-its/src/test/resources/surefire-809-groupExpr-testng/pom.xml deleted file mode 100644 index c3debfc199..0000000000 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-testng/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - testng-group-expressions - 1.0-SNAPSHOT - TestNG group expressions tests - - - - org.testng - testng - 5.8 - jdk15 - test - - - - - !CategoryC - 1.8 - 1.8 - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - - - diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/BasicTest.java b/surefire-its/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/BasicTest.java deleted file mode 100644 index dbc6521d15..0000000000 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/BasicTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package testng; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - - -public class BasicTest -{ - static int catACount = 0; - static int catBCount = 0; - static int catCCount = 0; - static int catNoneCount = 0; - - @Test( groups = "CategoryA" ) - public void testInCategoryA() - { - catACount++; - } - - @Test( groups = "CategoryB" ) - public void testInCategoryB() - { - catBCount++; - } - - @Test( groups = { "CategoryA", "CategoryB" } ) - public void testInCategoryAB() - { - System.out.println( getClass().getSimpleName() + ".testInCategoriesAB()" ); - catACount++; - catBCount++; - } - - @Test( groups = "CategoryC" ) - public void testInCategoryC() - { - catCCount++; - } - - @Test - public void testInNoCategory() - { - catNoneCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("catA: " + catACount + "\n" + - "catB: " + catBCount + "\n" + - "catC: " + catCCount + "\n" + - "catNone: " + catNoneCount); - } -} diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/CategoryCTest.java b/surefire-its/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/CategoryCTest.java deleted file mode 100644 index a6db88a3de..0000000000 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/CategoryCTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package testng; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -public class CategoryCTest -{ - static int catACount = 0; - static int catBCount = 0; - static int catCCount = 0; - - @Test( groups = "CategoryA" ) - public void testInCategoryA() - { - catACount++; - } - - @Test( groups = "CategoryB" ) - public void testInCategoryB() - { - catBCount++; - } - - @Test( groups = { "CategoryA", "CategoryB" } ) - public void testInCategoriesAB() - { - System.out.println( getClass().getSimpleName() + ".testInCategoriesAB()" ); - catACount++; - catBCount++; - } - - @Test( groups="CategoryC" ) - public void testInCategoryC() - { - catCCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("mA: " + catACount + "\n" + - "mB: " + catBCount + "\n" + - "mC: " + catCCount ); - } -} diff --git a/surefire-its/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/NoCategoryTest.java b/surefire-its/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/NoCategoryTest.java deleted file mode 100644 index efbb13f114..0000000000 --- a/surefire-its/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/NoCategoryTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package testng; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -public class NoCategoryTest { - static int catNoneCount = 0; - - @Test - public void testInNoCategory() - { - catNoneCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("NoCategoryTest.CatNone: " + catNoneCount); - } -} diff --git a/surefire-its/src/test/resources/surefire-812-log4j-classloader/pom.xml b/surefire-its/src/test/resources/surefire-812-log4j-classloader/pom.xml index 08e4d6ecf0..5b3fcbb441 100644 --- a/surefire-its/src/test/resources/surefire-812-log4j-classloader/pom.xml +++ b/surefire-its/src/test/resources/surefire-812-log4j-classloader/pom.xml @@ -33,7 +33,7 @@ junit junit - 4.8.2 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-817-system-exit/pom.xml b/surefire-its/src/test/resources/surefire-817-system-exit/pom.xml index 1f963b900a..075176ac9f 100644 --- a/surefire-its/src/test/resources/surefire-817-system-exit/pom.xml +++ b/surefire-its/src/test/resources/surefire-817-system-exit/pom.xml @@ -45,7 +45,7 @@ junit junit - 4.7 + 4.12 test @@ -57,13 +57,6 @@ 1 false - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/surefire-818-ignored-tests-on-npe/pom.xml b/surefire-its/src/test/resources/surefire-818-ignored-tests-on-npe/pom.xml index 3b771a3ac0..57bf3cac85 100644 --- a/surefire-its/src/test/resources/surefire-818-ignored-tests-on-npe/pom.xml +++ b/surefire-its/src/test/resources/surefire-818-ignored-tests-on-npe/pom.xml @@ -15,7 +15,7 @@ junit junit - 4.4 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-822-legal-JUnit4-descriptions/pom.xml b/surefire-its/src/test/resources/surefire-822-legal-JUnit4-descriptions/pom.xml index a06ab61a85..273b7f0633 100644 --- a/surefire-its/src/test/resources/surefire-822-legal-JUnit4-descriptions/pom.xml +++ b/surefire-its/src/test/resources/surefire-822-legal-JUnit4-descriptions/pom.xml @@ -11,8 +11,8 @@ junit - junit-dep - 4.10 + junit + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml deleted file mode 100644 index cb3d4120d3..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - junit4 - 1.0-SNAPSHOT - Test for JUnit 4.8.1 - - - - 4.8.1 - junit4.CategoryA,junit4.CategoryB - 1.8 - 1.8 - - - - - junit - junit - ${junitVersion} - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - ${groups} - ${excludedGroups} - - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - - - - - - - - emptyGroups - - - profile - emptyGroups - - - - - junit4.CategoryC - - - - emptyExcludedGroups - - - profile - emptyExcludedGroups - - - - junit4.CategoryA && junit4.CategoryB - - - - - - diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/BasicTest.java b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/BasicTest.java deleted file mode 100644 index 672e1c28ca..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/BasicTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package junit4; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; - - -public class BasicTest -{ - static int catACount = 0; - static int catBCount = 0; - static int catCCount = 0; - static int catNoneCount = 0; - - @Rule - public TestName testName = new TestName(); - - @Before - public void testName() - { - System.out.println( "Running " + getClass().getName() + "." + testName.getMethodName() ); - } - - @Test - @Category(CategoryA.class) - public void testInCategoryA() - { - catACount++; - } - - @Test - @Category(CategoryB.class) - public void testInCategoryB() - { - catBCount++; - } - - @Test - @Category({CategoryA.class, CategoryB.class}) - public void testInCategoryAB() - { - catACount++; - catBCount++; - } - - @Test - @Category(CategoryC.class) - public void testInCategoryC() - { - catCCount++; - } - - @Test - public void testInNoCategory() - { - catNoneCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("catA: " + catACount + "\n" + - "catB: " + catBCount + "\n" + - "catC: " + catCCount + "\n" + - "catNone: " + catNoneCount); - } -} diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryA.java b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryA.java deleted file mode 100644 index 9b8b855a60..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryA.java +++ /dev/null @@ -1,21 +0,0 @@ -package junit4; -/* - * 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. - */ - -interface CategoryA {} diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryB.java b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryB.java deleted file mode 100644 index f10f3b14be..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryB.java +++ /dev/null @@ -1,21 +0,0 @@ -package junit4; -/* - * 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. - */ - -interface CategoryB {} diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryC.java b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryC.java deleted file mode 100644 index 3e9e8542f0..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryC.java +++ /dev/null @@ -1,21 +0,0 @@ -package junit4; -/* - * 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. - */ - -interface CategoryC {} diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryCTest.java b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryCTest.java deleted file mode 100644 index f69e070b15..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryCTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package junit4; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; - - -@Category(CategoryC.class) -public class CategoryCTest -{ - static int catACount = 0; - static int catBCount = 0; - static int catCCount = 0; - - @Rule - public TestName testName = new TestName(); - - @Before - public void testName() - { - System.out.println( "Running " + getClass().getName() + "." + testName.getMethodName() ); - } - - @Test - @Category( CategoryA.class ) - public void testInCategoryA() - { - catACount++; - } - - @Test - @Category(CategoryB.class) - public void testInCategoryB() - { - catBCount++; - } - - @Test - @Category({CategoryA.class, CategoryB.class}) - public void testInCategoriesAB() - { - catACount++; - catBCount++; - } - - @Test - public void testInCategoryC() - { - catCCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("mA: " + catACount + "\n" + - "mB: " + catBCount + "\n" + - "mC: " + catCCount ); - } -} diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/NoCategoryTest.java b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/NoCategoryTest.java deleted file mode 100644 index 8cb62d1107..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/NoCategoryTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package junit4; -import org.junit.AfterClass; -import org.junit.Test; - -public class NoCategoryTest { - static int catNoneCount = 0; - - @Test - public void testInNoCategory() - { - catNoneCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("NoCategoryTest.CatNone: " + catNoneCount); - } -} diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml deleted file mode 100644 index 77d5e7a56e..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - testng-group-expressions - 1.0-SNAPSHOT - TestNG group expressions tests - - - 1.8 - 1.8 - - - - - org.testng - testng - 5.8 - jdk15 - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - ${groups} - ${excludedGroups} - - - - - - - - emptyGroups - - - profile - emptyGroups - - - - - CategoryC - - - - emptyExcludedGroups - - - profile - emptyExcludedGroups - - - - CategoryA && CategoryB - - - - - diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/BasicTest.java b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/BasicTest.java deleted file mode 100644 index dbc6521d15..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/BasicTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package testng; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - - -public class BasicTest -{ - static int catACount = 0; - static int catBCount = 0; - static int catCCount = 0; - static int catNoneCount = 0; - - @Test( groups = "CategoryA" ) - public void testInCategoryA() - { - catACount++; - } - - @Test( groups = "CategoryB" ) - public void testInCategoryB() - { - catBCount++; - } - - @Test( groups = { "CategoryA", "CategoryB" } ) - public void testInCategoryAB() - { - System.out.println( getClass().getSimpleName() + ".testInCategoriesAB()" ); - catACount++; - catBCount++; - } - - @Test( groups = "CategoryC" ) - public void testInCategoryC() - { - catCCount++; - } - - @Test - public void testInNoCategory() - { - catNoneCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("catA: " + catACount + "\n" + - "catB: " + catBCount + "\n" + - "catC: " + catCCount + "\n" + - "catNone: " + catNoneCount); - } -} diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/CategoryCTest.java b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/CategoryCTest.java deleted file mode 100644 index a6db88a3de..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/CategoryCTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package testng; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -public class CategoryCTest -{ - static int catACount = 0; - static int catBCount = 0; - static int catCCount = 0; - - @Test( groups = "CategoryA" ) - public void testInCategoryA() - { - catACount++; - } - - @Test( groups = "CategoryB" ) - public void testInCategoryB() - { - catBCount++; - } - - @Test( groups = { "CategoryA", "CategoryB" } ) - public void testInCategoriesAB() - { - System.out.println( getClass().getSimpleName() + ".testInCategoriesAB()" ); - catACount++; - catBCount++; - } - - @Test( groups="CategoryC" ) - public void testInCategoryC() - { - catCCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("mA: " + catACount + "\n" + - "mB: " + catBCount + "\n" + - "mC: " + catCCount ); - } -} diff --git a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/NoCategoryTest.java b/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/NoCategoryTest.java deleted file mode 100644 index efbb13f114..0000000000 --- a/surefire-its/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/NoCategoryTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package testng; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -public class NoCategoryTest { - static int catNoneCount = 0; - - @Test - public void testInNoCategory() - { - catNoneCount++; - } - - @AfterClass - public static void oneTimeTearDown() - { - System.out.println("NoCategoryTest.CatNone: " + catNoneCount); - } -} diff --git a/surefire-its/src/test/resources/surefire-832-provider-selection/pom.xml b/surefire-its/src/test/resources/surefire-832-provider-selection/pom.xml index 2b5a438904..8b0e99a78a 100644 --- a/surefire-its/src/test/resources/surefire-832-provider-selection/pom.xml +++ b/surefire-its/src/test/resources/surefire-832-provider-selection/pom.xml @@ -30,7 +30,7 @@ - 4.8.1 + 4.12 junit4.CategoryA,junit4.CategoryB 1.8 1.8 diff --git a/surefire-its/src/test/resources/surefire-847-testngfail/pom.xml b/surefire-its/src/test/resources/surefire-847-testngfail/pom.xml index 9aca4a78ab..06585fd7be 100644 --- a/surefire-its/src/test/resources/surefire-847-testngfail/pom.xml +++ b/surefire-its/src/test/resources/surefire-847-testngfail/pom.xml @@ -34,7 +34,7 @@ org.testng testng - 6.5.1 + 6.14.3 test diff --git a/surefire-its/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml b/surefire-its/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml index 5494bf53a8..23c8f29f30 100644 --- a/surefire-its/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml +++ b/surefire-its/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml @@ -46,7 +46,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-855-failsafe-use-jar/pom.xml b/surefire-its/src/test/resources/surefire-855-failsafe-use-jar/pom.xml index 01412f1614..53be7ad36b 100644 --- a/surefire-its/src/test/resources/surefire-855-failsafe-use-jar/pom.xml +++ b/surefire-its/src/test/resources/surefire-855-failsafe-use-jar/pom.xml @@ -45,7 +45,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-855-failsafe-use-war/pom.xml b/surefire-its/src/test/resources/surefire-855-failsafe-use-war/pom.xml index 07c01272ad..a49f8b6add 100644 --- a/surefire-its/src/test/resources/surefire-855-failsafe-use-war/pom.xml +++ b/surefire-its/src/test/resources/surefire-855-failsafe-use-war/pom.xml @@ -46,7 +46,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-926-2-provider-failure/pom.xml b/surefire-its/src/test/resources/surefire-926-2-provider-failure/pom.xml index ecafe113e2..38741a4ba4 100644 --- a/surefire-its/src/test/resources/surefire-926-2-provider-failure/pom.xml +++ b/surefire-its/src/test/resources/surefire-926-2-provider-failure/pom.xml @@ -9,18 +9,6 @@ org.apache.maven.plugins maven-surefire-plugin ${surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${surefire.version} - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - @@ -28,13 +16,13 @@ junit junit - 4.10 + 4.12 test org.testng testng - 6.8 + 6.14.3 test diff --git a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/pom.xml b/surefire-its/src/test/resources/surefire-930-failsafe-runtests/pom.xml deleted file mode 100644 index 8c66d0370b..0000000000 --- a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - 4.0.0 - - org.apache.maven.plugins - failsafe-test - 1.0.0-SNAPSHOT - - FailSafe Test - surefire-930 - - - 1.8 - 1.8 - - - - org.testng - testng - 6.8 - test - - - - - - - - maven-surefire-plugin - ${surefire.version} - - true - - - - maven-failsafe-plugin - ${surefire.version} - - - ${project.basedir}/src/test/resources/testng-integrationTest.xml - - - - - - integration-test - verify - - - - - - - diff --git a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/java/org/apache/maven/plugins/failsafe/ExampleIntegrationTest.java b/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/java/org/apache/maven/plugins/failsafe/ExampleIntegrationTest.java deleted file mode 100644 index 937fda6734..0000000000 --- a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/java/org/apache/maven/plugins/failsafe/ExampleIntegrationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.apache.maven.plugins.failsafe; - -import org.junit.Assert; -import org.testng.annotations.Test; - -@Test(groups = { TestConstants.IntegrationTest }) -public class ExampleIntegrationTest { - - public void shouldRun() { - System.out.println("Hello from Integration-Test"); - Assert.fail("this will not be executed"); - } -} diff --git a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/java/org/apache/maven/plugins/failsafe/ExampleTest.java b/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/java/org/apache/maven/plugins/failsafe/ExampleTest.java deleted file mode 100644 index bb26b896aa..0000000000 --- a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/java/org/apache/maven/plugins/failsafe/ExampleTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.apache.maven.plugins.failsafe; - -import org.junit.Assert; -import org.testng.annotations.Test; - -@Test(groups = { TestConstants.UnitTest }) -public class ExampleTest { - - public void shouldRun() { - System.out.println("Hello from Unit-Test"); - Assert.assertTrue(true); - } -} diff --git a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/java/org/apache/maven/plugins/failsafe/TestConstants.java b/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/java/org/apache/maven/plugins/failsafe/TestConstants.java deleted file mode 100644 index 5fb74e2802..0000000000 --- a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/java/org/apache/maven/plugins/failsafe/TestConstants.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.apache.maven.plugins.failsafe; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Constants for testing - * - * @author mspika - */ -public final class TestConstants { - - public static final String UnitTest = "Unit-Test"; - public static final String IntegrationTest = "Integration-Test"; - public static final String ManualTest = "Manual-Test"; - public static final String BrokenTest = "Broken-Test"; -} diff --git a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/resources/testng-integrationTest.xml b/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/resources/testng-integrationTest.xml deleted file mode 100644 index 5db8b246b1..0000000000 --- a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/resources/testng-integrationTest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/resources/testng.xml b/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/resources/testng.xml deleted file mode 100644 index a9b8733992..0000000000 --- a/surefire-its/src/test/resources/surefire-930-failsafe-runtests/src/test/resources/testng.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/surefire-its/src/test/resources/surefire-931-provider-failure/pom.xml b/surefire-its/src/test/resources/surefire-931-provider-failure/pom.xml index 8b9cf6059e..ee4c05565e 100644 --- a/surefire-its/src/test/resources/surefire-931-provider-failure/pom.xml +++ b/surefire-its/src/test/resources/surefire-931-provider-failure/pom.xml @@ -35,7 +35,7 @@ org.testng testng - 6.8 + 6.14.3 diff --git a/surefire-its/src/test/resources/surefire-942-testngSuite/pom.xml b/surefire-its/src/test/resources/surefire-942-testngSuite/pom.xml index 4ea86b999c..33a7ea226e 100644 --- a/surefire-its/src/test/resources/surefire-942-testngSuite/pom.xml +++ b/surefire-its/src/test/resources/surefire-942-testngSuite/pom.xml @@ -12,7 +12,7 @@ org.testng testng - 5.14 + 6.14.3 test diff --git a/surefire-its/src/test/resources/surefire-943-report-content/pom.xml b/surefire-its/src/test/resources/surefire-943-report-content/pom.xml index a4a8d8abfb..cc985f3038 100644 --- a/surefire-its/src/test/resources/surefire-943-report-content/pom.xml +++ b/surefire-its/src/test/resources/surefire-943-report-content/pom.xml @@ -9,7 +9,6 @@ surefire-943-report-content - 2.13 1.8 1.8 @@ -21,13 +20,6 @@ org.apache.maven.plugins maven-surefire-plugin ${surefire.version} - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - @@ -38,7 +30,7 @@ junit junit test - 4.11 + 4.12 diff --git a/surefire-its/src/test/resources/surefire-946-killMainProcessInReusableFork/pom.xml b/surefire-its/src/test/resources/surefire-946-killMainProcessInReusableFork/pom.xml index 1b31510e14..11b2e47892 100644 --- a/surefire-its/src/test/resources/surefire-946-killMainProcessInReusableFork/pom.xml +++ b/surefire-its/src/test/resources/surefire-946-killMainProcessInReusableFork/pom.xml @@ -42,7 +42,7 @@ junit junit - 4.4 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml b/surefire-its/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml index d4cc4ed8ef..7b28542f5e 100644 --- a/surefire-its/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml +++ b/surefire-its/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml @@ -11,7 +11,7 @@ junit junit - 4.11 + 4.12 test @@ -39,13 +39,6 @@ - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - diff --git a/surefire-its/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml b/surefire-its/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml index 8eaf1873c1..2018188b7a 100644 --- a/surefire-its/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml +++ b/surefire-its/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml @@ -11,7 +11,7 @@ junit junit - 4.11 + 4.12 diff --git a/surefire-its/src/test/resources/surefire-975-wrong-encoding/pom.xml b/surefire-its/src/test/resources/surefire-975-wrong-encoding/pom.xml index de8f847eed..cffcbd50c8 100755 --- a/surefire-its/src/test/resources/surefire-975-wrong-encoding/pom.xml +++ b/surefire-its/src/test/resources/surefire-975-wrong-encoding/pom.xml @@ -17,7 +17,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/pom.xml b/surefire-its/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/pom.xml index d84cfcc1d9..268b172592 100644 --- a/surefire-its/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/pom.xml +++ b/surefire-its/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/pom.xml @@ -15,7 +15,7 @@ junit junit - 4.10 + 4.12 commons-io diff --git a/surefire-its/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/pom.xml b/surefire-its/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/pom.xml index 6387f35906..96ed9e3f83 100644 --- a/surefire-its/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/pom.xml +++ b/surefire-its/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/pom.xml @@ -15,7 +15,7 @@ junit junit - 4.10 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-985-parameterized-and-categories/pom.xml b/surefire-its/src/test/resources/surefire-985-parameterized-and-categories/pom.xml index 607015e4c2..f36534a01c 100644 --- a/surefire-its/src/test/resources/surefire-985-parameterized-and-categories/pom.xml +++ b/surefire-its/src/test/resources/surefire-985-parameterized-and-categories/pom.xml @@ -26,7 +26,7 @@ junit junit - 4.11 + 4.12 test diff --git a/surefire-its/src/test/resources/surefire-995-categoryInheritance/pom.xml b/surefire-its/src/test/resources/surefire-995-categoryInheritance/pom.xml index f59e1331ff..b5a13e59fc 100644 --- a/surefire-its/src/test/resources/surefire-995-categoryInheritance/pom.xml +++ b/surefire-its/src/test/resources/surefire-995-categoryInheritance/pom.xml @@ -53,11 +53,13 @@ - - - maven-surefire-plugin - - + + + + maven-surefire-plugin + + + diff --git a/surefire-its/src/test/resources/system-properties/pom.xml b/surefire-its/src/test/resources/system-properties/pom.xml index c663d11ad7..a058f87adc 100644 --- a/surefire-its/src/test/resources/system-properties/pom.xml +++ b/surefire-its/src/test/resources/system-properties/pom.xml @@ -84,7 +84,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/testng-afterSuiteFailure/pom.xml b/surefire-its/src/test/resources/testng-afterSuiteFailure/pom.xml index 788d400982..3901750643 100644 --- a/surefire-its/src/test/resources/testng-afterSuiteFailure/pom.xml +++ b/surefire-its/src/test/resources/testng-afterSuiteFailure/pom.xml @@ -33,35 +33,13 @@ 1.8 - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - + + + org.testng + testng + ${testNgVersion} + + diff --git a/surefire-its/src/test/resources/testng-beforeMethod/pom.xml b/surefire-its/src/test/resources/testng-beforeMethod/pom.xml index 40085f5840..a5e7f67fee 100644 --- a/surefire-its/src/test/resources/testng-beforeMethod/pom.xml +++ b/surefire-its/src/test/resources/testng-beforeMethod/pom.xml @@ -33,35 +33,14 @@ 1.8 - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - + + + org.testng + testng + ${testNgVersion} + + + diff --git a/surefire-its/src/test/resources/testng-beforeMethodFailure/pom.xml b/surefire-its/src/test/resources/testng-beforeMethodFailure/pom.xml index 2d8179586d..74554923a4 100644 --- a/surefire-its/src/test/resources/testng-beforeMethodFailure/pom.xml +++ b/surefire-its/src/test/resources/testng-beforeMethodFailure/pom.xml @@ -33,35 +33,13 @@ 1.8 - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - + + + org.testng + testng + ${testNgVersion} + + diff --git a/surefire-its/src/test/resources/testng-execute-error/pom.xml b/surefire-its/src/test/resources/testng-execute-error/pom.xml index 657fe73454..4004821bf9 100644 --- a/surefire-its/src/test/resources/testng-execute-error/pom.xml +++ b/surefire-its/src/test/resources/testng-execute-error/pom.xml @@ -33,35 +33,13 @@ 1.8 - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - + + + org.testng + testng + ${testNgVersion} + + diff --git a/surefire-its/src/test/resources/testng-group-thread-parallel/pom.xml b/surefire-its/src/test/resources/testng-group-thread-parallel/pom.xml index 4405bd3c5e..b0428621d1 100644 --- a/surefire-its/src/test/resources/testng-group-thread-parallel/pom.xml +++ b/surefire-its/src/test/resources/testng-group-thread-parallel/pom.xml @@ -35,35 +35,13 @@ 1.0-SNAPSHOT TestNG group/parallel thread tests - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - + + + org.testng + testng + ${testNgVersion} + + diff --git a/surefire-its/src/test/resources/testng-groups/pom.xml b/surefire-its/src/test/resources/testng-groups/pom.xml index 1d679e7c5b..2bb6ac09af 100644 --- a/surefire-its/src/test/resources/testng-groups/pom.xml +++ b/surefire-its/src/test/resources/testng-groups/pom.xml @@ -37,7 +37,7 @@ org.testng testng - 6.8.7 + 6.14.3 test diff --git a/surefire-its/src/test/resources/testng-jdk14/pom.xml b/surefire-its/src/test/resources/testng-jdk14/pom.xml deleted file mode 100644 index 19d9a9919f..0000000000 --- a/surefire-its/src/test/resources/testng-jdk14/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - testng-jdk14 - 1.0-SNAPSHOT - Test for testng jdk14 integration - - - 1.8 - 1.8 - - - - - junit - junit - 3.8.1 - test - - - org.testng - testng - 5.7 - jdk14 - test - - - - - src/test/java - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - functional - - - - - - diff --git a/surefire-its/src/test/resources/testng-jdk14/src/test/java/testng/jdk14/TestNGJavadocTest.java b/surefire-its/src/test/resources/testng-jdk14/src/test/java/testng/jdk14/TestNGJavadocTest.java deleted file mode 100644 index 90bb4f2a40..0000000000 --- a/surefire-its/src/test/resources/testng-jdk14/src/test/java/testng/jdk14/TestNGJavadocTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package testng.jdk14; - -import org.testng.Assert; - -/** - * Tests that forcing testng to run tests via the "${maven.test.forcetestng}" configuration option works. - * - * @author jkuhnert - */ -public class TestNGJavadocTest -{ - - /** - * Sets up testObject - * - * @testng.configuration beforeTestClass = "true" groups = "functional" - */ - public void configureTest() - { - testObject = new Object(); - } - - Object testObject; - - /** - * Tests reporting an error - * - * @testng.test groups = "functional, notincluded" - */ - public void isTestObjectNull() - { - Assert.assertNotNull( testObject, "testObject is null" ); - } - - /** - * Sample method that shouldn't be run by test suite. - * - * @testng.test groups = "notincluded" - */ - public void shouldNotRun() - { - Assert.assertTrue( false, "Group specified by test shouldnt be run." ); - } -} diff --git a/surefire-its/src/test/resources/testng-junit-together/pom.xml b/surefire-its/src/test/resources/testng-junit-together/pom.xml index 3342796078..8aeb39fd67 100644 --- a/surefire-its/src/test/resources/testng-junit-together/pom.xml +++ b/surefire-its/src/test/resources/testng-junit-together/pom.xml @@ -33,41 +33,17 @@ 1.8 - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - + + org.testng + testng + ${testNgVersion} + junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/testng-junit4-together/pom.xml b/surefire-its/src/test/resources/testng-junit4-together/pom.xml index e8efb68f59..39232006fb 100644 --- a/surefire-its/src/test/resources/testng-junit4-together/pom.xml +++ b/surefire-its/src/test/resources/testng-junit4-together/pom.xml @@ -36,13 +36,13 @@ junit junit - 4.11 + 4.12 test org.testng testng - 6.8.5 + 6.14.3 test diff --git a/surefire-its/src/test/resources/testng-listener-reporter/pom.xml b/surefire-its/src/test/resources/testng-listener-reporter/pom.xml index cc7d86f992..e2062976c3 100644 --- a/surefire-its/src/test/resources/testng-listener-reporter/pom.xml +++ b/surefire-its/src/test/resources/testng-listener-reporter/pom.xml @@ -33,42 +33,21 @@ 1.8 - - - testng-old - - testNgClassifier - - - + + + org.testng + testng + ${testNgVersion} + + + org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - org.testng - guice - - - - - - + guice + + +
+ + diff --git a/surefire-its/src/test/resources/testng-listeners/src/test/java/listeners/MarkAsFailureListener.java b/surefire-its/src/test/resources/testng-listeners/src/test/java/listeners/MarkAsFailureListener.java deleted file mode 100644 index a10460462c..0000000000 --- a/surefire-its/src/test/resources/testng-listeners/src/test/java/listeners/MarkAsFailureListener.java +++ /dev/null @@ -1,83 +0,0 @@ -package listeners; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -import org.testng.IInvokedMethod; -import org.testng.IInvokedMethodListener; -import org.testng.ITestContext; -import org.testng.ITestListener; -import org.testng.ITestResult; - -/** - * Created by etigwuu on 2014-04-26. - */ -public class MarkAsFailureListener implements ITestListener, IInvokedMethodListener { - - @Override - public void onTestStart(ITestResult result) { - - } - - @Override - public void onTestSuccess(ITestResult result) { - - } - - public static int counter = 0; - /** - * I will be called twice in some condition!!! - * @param result - */ - @Override - public void onTestFailure(ITestResult result) { - System.out.println(++counter); - } - - @Override - public void onTestSkipped(ITestResult result) { - - } - - @Override - public void onTestFailedButWithinSuccessPercentage(ITestResult result) { - - } - - @Override - public void onStart(ITestContext context) { - - } - - @Override - public void onFinish(ITestContext context) { - - } - - @Override - public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { - - } - - @Override - public void afterInvocation(IInvokedMethod method, ITestResult testResult) { - testResult.setStatus(ITestResult.FAILURE); - } -} diff --git a/surefire-its/src/test/resources/testng-listeners/src/test/java/listeners/SimpleTest.java b/surefire-its/src/test/resources/testng-listeners/src/test/java/listeners/SimpleTest.java deleted file mode 100644 index c90ea78d34..0000000000 --- a/surefire-its/src/test/resources/testng-listeners/src/test/java/listeners/SimpleTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package listeners; - -import org.testng.annotations.Listeners; -import org.testng.annotations.Test; - -/** - * Created by etigwuu on 2014-04-26. - */ -@Listeners(MarkAsFailureListener.class) -public class SimpleTest { - - @Test - public void test1(){ - System.out.println("Hello world"); - } -} diff --git a/surefire-its/src/test/resources/testng-method-pattern-after/pom.xml b/surefire-its/src/test/resources/testng-method-pattern-after/pom.xml index 84bada55ec..779e579ee4 100644 --- a/surefire-its/src/test/resources/testng-method-pattern-after/pom.xml +++ b/surefire-its/src/test/resources/testng-method-pattern-after/pom.xml @@ -34,33 +34,6 @@ - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - tcp @@ -76,7 +49,15 @@ - + + + + org.testng + testng + ${testNgVersion} + + + diff --git a/surefire-its/src/test/resources/testng-method-pattern-before/pom.xml b/surefire-its/src/test/resources/testng-method-pattern-before/pom.xml index 84bada55ec..3c1862d1b4 100644 --- a/surefire-its/src/test/resources/testng-method-pattern-before/pom.xml +++ b/surefire-its/src/test/resources/testng-method-pattern-before/pom.xml @@ -33,34 +33,15 @@ 1.8 + + + org.testng + testng + ${testNgVersion} + + + - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - tcp diff --git a/surefire-its/src/test/resources/testng-method-pattern/pom.xml b/surefire-its/src/test/resources/testng-method-pattern/pom.xml index 5e8c3dc0f8..882f8d09b2 100644 --- a/surefire-its/src/test/resources/testng-method-pattern/pom.xml +++ b/surefire-its/src/test/resources/testng-method-pattern/pom.xml @@ -34,33 +34,6 @@ - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - tcp @@ -75,8 +48,15 @@ - - + + + + + org.testng + testng + ${testNgVersion} + + diff --git a/surefire-its/src/test/resources/testng-multiple-method-patterns/pom.xml b/surefire-its/src/test/resources/testng-multiple-method-patterns/pom.xml index eef5f5703d..53a5134b54 100644 --- a/surefire-its/src/test/resources/testng-multiple-method-patterns/pom.xml +++ b/surefire-its/src/test/resources/testng-multiple-method-patterns/pom.xml @@ -41,8 +41,7 @@ org.testng testng - 5.7 - jdk15 + 6.14.3 test diff --git a/surefire-its/src/test/resources/testng-objectFactory/pom.xml b/surefire-its/src/test/resources/testng-objectFactory/pom.xml index ee76f099d3..a8bad3ed0d 100644 --- a/surefire-its/src/test/resources/testng-objectFactory/pom.xml +++ b/surefire-its/src/test/resources/testng-objectFactory/pom.xml @@ -39,8 +39,7 @@ org.testng testng - 5.7 - jdk15 + 6.14.3 test diff --git a/surefire-its/src/test/resources/testng-parallel-suites/pom.xml b/surefire-its/src/test/resources/testng-parallel-suites/pom.xml deleted file mode 100644 index e3e347bc27..0000000000 --- a/surefire-its/src/test/resources/testng-parallel-suites/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - 4.0.0 - - - org.apache.maven.surefire - it-parent - 1.0 - ../pom.xml - - - org.apache.maven.plugins.surefire - testng-parallel-suites - 1.0 - - http://maven.apache.org - - - - tibordigana - Tibor Digaňa (tibor17) - tibordigana@apache.org - - Committer - - Europe/Bratislava - - - - - - org.testng - testng - 6.9.8 - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - src/test/resources/testng1.xml - src/test/resources/testng2.xml - - - - suitethreadpoolsize - 2 - - - - - - - - diff --git a/surefire-its/src/test/resources/testng-parallel-suites/src/test/java/testng/suiteXml/ShouldNotRunTest.java b/surefire-its/src/test/resources/testng-parallel-suites/src/test/java/testng/suiteXml/ShouldNotRunTest.java deleted file mode 100644 index 1b9e7bf4b0..0000000000 --- a/surefire-its/src/test/resources/testng-parallel-suites/src/test/java/testng/suiteXml/ShouldNotRunTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package testng.suiteXml; - -import org.testng.annotations.Test; - -/** - * @author Tibor Digana (tibor17) - * @since 2.19 - */ -public class ShouldNotRunTest { - - @Test - public void shouldNotRun() - { - System.out.println( getClass().getSimpleName() + "#shouldNotRun()" ); - } -} diff --git a/surefire-its/src/test/resources/testng-parallel-suites/src/test/java/testng/suiteXml/TestNGSuiteTest.java b/surefire-its/src/test/resources/testng-parallel-suites/src/test/java/testng/suiteXml/TestNGSuiteTest.java deleted file mode 100644 index 179db0b14a..0000000000 --- a/surefire-its/src/test/resources/testng-parallel-suites/src/test/java/testng/suiteXml/TestNGSuiteTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package testng.suiteXml; - -import org.testng.annotations.Test; - -import java.nio.charset.Charset; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * @author Tibor Digana (tibor17) - * @since 2.19 - */ -public class TestNGSuiteTest { - private static final AtomicInteger COUNTER = new AtomicInteger(); - - @Test - public void shouldRunAndPrintItself() - throws Exception - { - System.out.println( getClass().getSimpleName() - + "#shouldRunAndPrintItself() " - + COUNTER.incrementAndGet() - + "." ); - - TimeUnit.SECONDS.sleep( 2 ); - } -} diff --git a/surefire-its/src/test/resources/testng-parallel-suites/src/test/resources/testng1.xml b/surefire-its/src/test/resources/testng-parallel-suites/src/test/resources/testng1.xml deleted file mode 100644 index ac62eca7d1..0000000000 --- a/surefire-its/src/test/resources/testng-parallel-suites/src/test/resources/testng1.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/surefire-its/src/test/resources/testng-parallel-suites/src/test/resources/testng2.xml b/surefire-its/src/test/resources/testng-parallel-suites/src/test/resources/testng2.xml deleted file mode 100644 index 4036c218d0..0000000000 --- a/surefire-its/src/test/resources/testng-parallel-suites/src/test/resources/testng2.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/surefire-its/src/test/resources/testng-parallel-with-annotations/pom.xml b/surefire-its/src/test/resources/testng-parallel-with-annotations/pom.xml index 87fd811da5..2b888746da 100644 --- a/surefire-its/src/test/resources/testng-parallel-with-annotations/pom.xml +++ b/surefire-its/src/test/resources/testng-parallel-with-annotations/pom.xml @@ -25,8 +25,7 @@ org.testng testng - 5.8 - jdk15 + 6.14.3 test diff --git a/surefire-its/src/test/resources/testng-path with spaces/pom.xml b/surefire-its/src/test/resources/testng-path with spaces/pom.xml index 5882ad7d1d..b90d3a0d86 100644 --- a/surefire-its/src/test/resources/testng-path with spaces/pom.xml +++ b/surefire-its/src/test/resources/testng-path with spaces/pom.xml @@ -33,35 +33,13 @@ 1.8 - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - + + + org.testng + testng + ${testNgVersion} + + diff --git a/surefire-its/src/test/resources/testng-simple/pom.xml b/surefire-its/src/test/resources/testng-simple/pom.xml index cace78a2eb..63c512d363 100644 --- a/surefire-its/src/test/resources/testng-simple/pom.xml +++ b/surefire-its/src/test/resources/testng-simple/pom.xml @@ -28,50 +28,6 @@ 1.0-SNAPSHOT TestNG simple test - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - junit - junit - - - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - junit - junit - - - - - - - 0 @@ -79,8 +35,22 @@ 1.8 1.8 - + + + org.testng + testng + ${testNgVersion} + + + + junit + junit + + + + + org.apache.maven.plugins diff --git a/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestA.java b/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestA.java index 9c25e2668f..d333e7076c 100644 --- a/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestA.java +++ b/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestA.java @@ -6,8 +6,8 @@ public class TestNGSuiteTestA { @Test - public void doNothing() + public void doNothing() throws Exception { - + Thread.sleep(1000); } } diff --git a/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestB.java b/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestB.java index db97fbc762..f24f434a6b 100644 --- a/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestB.java +++ b/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestB.java @@ -6,8 +6,8 @@ public class TestNGSuiteTestB { @Test - public void doNothing() + public void doNothing() throws Exception { - + Thread.sleep(1000); } } diff --git a/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestC.java b/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestC.java index c85893cc77..15f4e5c2f6 100644 --- a/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestC.java +++ b/surefire-its/src/test/resources/testng-simple/src/test/java/testng/simple/TestNGSuiteTestC.java @@ -6,8 +6,8 @@ public class TestNGSuiteTestC { @Test - public void doNothing() + public void doNothing() throws Exception { - + Thread.sleep(1000); } } diff --git a/surefire-its/src/test/resources/testng-single-method-5-14-9/pom.xml b/surefire-its/src/test/resources/testng-single-method-5-14-9/pom.xml index 198e388dd9..b89c10dab7 100644 --- a/surefire-its/src/test/resources/testng-single-method-5-14-9/pom.xml +++ b/surefire-its/src/test/resources/testng-single-method-5-14-9/pom.xml @@ -37,7 +37,7 @@ org.testng testng - 5.14.9 + 6.14.3 diff --git a/surefire-its/src/test/resources/testng-single-method/pom.xml b/surefire-its/src/test/resources/testng-single-method/pom.xml index 4dbbac998c..06fe1e7ab8 100644 --- a/surefire-its/src/test/resources/testng-single-method/pom.xml +++ b/surefire-its/src/test/resources/testng-single-method/pom.xml @@ -33,37 +33,14 @@ 1.8 - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - - - + + + org.testng + testng + ${testNgVersion} + + + diff --git a/surefire-its/src/test/resources/testng-succes-percentage/pom.xml b/surefire-its/src/test/resources/testng-succes-percentage/pom.xml index 4e74bd8a36..6cee1c98e2 100644 --- a/surefire-its/src/test/resources/testng-succes-percentage/pom.xml +++ b/surefire-its/src/test/resources/testng-succes-percentage/pom.xml @@ -33,33 +33,11 @@ 1.0-SNAPSHOT Test for Testng - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - + + + org.testng + testng + ${testNgVersion} + + diff --git a/surefire-its/src/test/resources/testng-suite-xml/pom.xml b/surefire-its/src/test/resources/testng-suite-xml/pom.xml deleted file mode 100644 index 280c2174ae..0000000000 --- a/surefire-its/src/test/resources/testng-suite-xml/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - suiteXml - 1.0-SNAPSHOT - TestNG Suite XML File - - - 1.8 - 1.8 - - - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - - src/test-data/testng1.xml - src/test-data/testng2.xml - - - - - - - - - diff --git a/surefire-its/src/test/resources/testng-suite-xml/src/test-data/testng2.xml b/surefire-its/src/test/resources/testng-suite-xml/src/test-data/testng2.xml deleted file mode 100644 index 4036c218d0..0000000000 --- a/surefire-its/src/test/resources/testng-suite-xml/src/test-data/testng2.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/surefire-its/src/test/resources/testng-suite-xml/src/test/java/testng/suiteXml/TestNGSuiteTest.java b/surefire-its/src/test/resources/testng-suite-xml/src/test/java/testng/suiteXml/TestNGSuiteTest.java deleted file mode 100644 index 228a9d9e25..0000000000 --- a/surefire-its/src/test/resources/testng-suite-xml/src/test/java/testng/suiteXml/TestNGSuiteTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package testng.suiteXml; - -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -/** - * Tests that forcing testng to run tests via the - * "${maven.test.forcetestng}" configuration option - * works. - * - * @author jkuhnert - */ -public class TestNGSuiteTest { - - /** - * Sets up testObject - */ - @BeforeClass - public void configureTest() - { - testObject = new Object(); - } - - Object testObject; - - /** - * Tests reporting an error - */ - @Test - public void isTestObjectNull() - { - assert testObject != null : "testObject is null"; - } -} diff --git a/surefire-its/src/test/resources/testng-testRunnerFactory/pom.xml b/surefire-its/src/test/resources/testng-testRunnerFactory/pom.xml deleted file mode 100644 index 818d53e501..0000000000 --- a/surefire-its/src/test/resources/testng-testRunnerFactory/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - 4.0.0 - - - org.apache.maven.surefire - it-parent - 1.0 - ../pom.xml - - - org.apache.maven.plugins.surefire - testng-testrunnerfactory - 1.0 - TestNG using custom test runner factory - - - - - org.testng - testng - 5.10 - jdk15 - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - testrunfactory - testng.testrunnerfactory.TestNGCustomTestRunnerFactory - - - - - - - - diff --git a/surefire-its/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java b/surefire-its/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java deleted file mode 100644 index 225cb8a6d8..0000000000 --- a/surefire-its/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/FileHelper.java +++ /dev/null @@ -1,25 +0,0 @@ -package testng.testrunnerfactory; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -public class FileHelper -{ - public static void writeFile( String fileName, String content ) - { - try - { - File target = new File( System.getProperty( "user.dir" ), "target" ).getCanonicalFile(); - File listenerOutput = new File( target, fileName ); - try ( FileWriter out = new FileWriter( listenerOutput, true ) ) - { - out.write( content ); - } - } - catch ( IOException e ) - { - throw new RuntimeException( e ); - } - } -} diff --git a/surefire-its/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/TestNGCustomTestRunnerFactory.java b/surefire-its/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/TestNGCustomTestRunnerFactory.java deleted file mode 100644 index d52ec961f3..0000000000 --- a/surefire-its/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/TestNGCustomTestRunnerFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package testng.testrunnerfactory; - -import org.testng.ISuite; -import org.testng.ITestRunnerFactory; -import org.testng.TestRunner; -import org.testng.xml.XmlTest; -//import org.testng.IInvokedMethodListener; - -import java.util.List; - -public class TestNGCustomTestRunnerFactory - implements ITestRunnerFactory -{ - - public TestRunner newTestRunner( ISuite suite, XmlTest test/*, List listeners*/ ) - { - FileHelper.writeFile( "testrunnerfactory-output.txt", - "Instantiated Test Runner for suite:\n\t" + suite - + "\nand test:\n\t" + test +"\n\n" ); - return new TestRunner( suite, test, test.skipFailedInvocationCounts()/*, listeners*/ ); - } -} diff --git a/surefire-its/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/TestNGSuiteTest.java b/surefire-its/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/TestNGSuiteTest.java deleted file mode 100644 index 6ad173db7e..0000000000 --- a/surefire-its/src/test/resources/testng-testRunnerFactory/src/test/java/testng/testrunnerfactory/TestNGSuiteTest.java +++ /dev/null @@ -1,11 +0,0 @@ -package testng.testrunnerfactory; - -import org.testng.annotations.Test; - -public class TestNGSuiteTest -{ - @Test - public void doNothing() - { - } -} \ No newline at end of file diff --git a/surefire-its/src/test/resources/testng-twoTestCaseSuite/pom.xml b/surefire-its/src/test/resources/testng-twoTestCaseSuite/pom.xml deleted file mode 100644 index b6f315f615..0000000000 --- a/surefire-its/src/test/resources/testng-twoTestCaseSuite/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - 4.0.0 - - org.apache.maven.plugins.surefire - testng-twoTestCaseSuite - 1.0-SNAPSHOT - TestNG Suite XML with two test cases - - - 1.8 - 1.8 - - - - - testng-old - - testNgClassifier - - - - org.testng - testng - ${testNgVersion} - ${testNgClassifier} - - - - - testng-new - - !testNgClassifier - - - - org.testng - testng - ${testNgVersion} - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - - src/test/resources/suite.xml - - - - - - - diff --git a/surefire-its/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGSuiteTest.java b/surefire-its/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGSuiteTest.java deleted file mode 100644 index db8dc94c44..0000000000 --- a/surefire-its/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGSuiteTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package testng.two; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -import org.testng.annotations.Test; - - -public class TestNGSuiteTest { - - @Test - public void doNothing() - { - - } -} \ No newline at end of file diff --git a/surefire-its/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGTestTwo.java b/surefire-its/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGTestTwo.java deleted file mode 100644 index f4a9dec7bd..0000000000 --- a/surefire-its/src/test/resources/testng-twoTestCaseSuite/src/test/java/testng/two/TestNGTestTwo.java +++ /dev/null @@ -1,13 +0,0 @@ -package testng.two; - -import org.testng.annotations.Test; - - -public class TestNGTestTwo { - - @Test - public void testTwo() - { - - } -} diff --git a/surefire-its/src/test/resources/testng-twoTestCaseSuite/src/test/resources/suite.xml b/surefire-its/src/test/resources/testng-twoTestCaseSuite/src/test/resources/suite.xml deleted file mode 100644 index a768654040..0000000000 --- a/surefire-its/src/test/resources/testng-twoTestCaseSuite/src/test/resources/suite.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/surefire-its/src/test/resources/timeout-forked/pom.xml b/surefire-its/src/test/resources/timeout-forked/pom.xml index f798643671..755886f67f 100644 --- a/surefire-its/src/test/resources/timeout-forked/pom.xml +++ b/surefire-its/src/test/resources/timeout-forked/pom.xml @@ -50,7 +50,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/unicode-testnames/pom.xml b/surefire-its/src/test/resources/unicode-testnames/pom.xml index 955f46702b..0d7fcff802 100644 --- a/surefire-its/src/test/resources/unicode-testnames/pom.xml +++ b/surefire-its/src/test/resources/unicode-testnames/pom.xml @@ -39,7 +39,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/webapp/pom.xml b/surefire-its/src/test/resources/webapp/pom.xml index f471175226..a107d314e0 100644 --- a/surefire-its/src/test/resources/webapp/pom.xml +++ b/surefire-its/src/test/resources/webapp/pom.xml @@ -37,7 +37,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-its/src/test/resources/working-directory/child/pom.xml b/surefire-its/src/test/resources/working-directory/child/pom.xml index bdfbed8c6f..dc27710eb2 100644 --- a/surefire-its/src/test/resources/working-directory/child/pom.xml +++ b/surefire-its/src/test/resources/working-directory/child/pom.xml @@ -36,7 +36,7 @@ junit junit - 3.8.1 + 4.12 test diff --git a/surefire-logger-api/pom.xml b/surefire-logger-api/pom.xml index eb1d897209..51c8666caa 100644 --- a/surefire-logger-api/pom.xml +++ b/surefire-logger-api/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-logger-api diff --git a/surefire-providers/common-java5/pom.xml b/surefire-providers/common-java5/pom.xml index 3e7f45aa78..7ae8bc7733 100644 --- a/surefire-providers/common-java5/pom.xml +++ b/surefire-providers/common-java5/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT common-java5 diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java index e5c66dde8a..f96a7039a5 100644 --- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java +++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java @@ -216,7 +216,13 @@ private static String toString(Throwable t, Iterable elements StringBuilder result = new StringBuilder(); if (t != null) { result.append(t.getClass().getName()); - String msg = t.getMessage(); + String msg; + // SUREFIRE-818 + try { + msg = t.getMessage(); + } catch (NullPointerException npe) { + msg = ""; + } if (msg != null) { result.append(": "); if (isMultiLine(msg)) { diff --git a/surefire-providers/common-junit3/pom.xml b/surefire-providers/common-junit3/pom.xml deleted file mode 100644 index 8ea9c95a3c..0000000000 --- a/surefire-providers/common-junit3/pom.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - 4.0.0 - - - org.apache.maven.surefire - surefire-providers - 3.5.5-SNAPSHOT - - - common-junit3 - - Shared JUnit3 Provider Code - Shared JUnit3 Provider Code - - - - junit - junit - 3.8.1 - provided - - - - - - - org.jacoco - jacoco-maven-plugin - - jacoco.agent - - - - jacoco-agent - - prepare-agent - - - - - - maven-surefire-plugin - - ${jvm.args.tests} ${jacoco.agent} - - - - org.apache.maven.surefire - surefire-shadefire - - - 3.5.0 - - - - - - diff --git a/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java b/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java deleted file mode 100644 index ed76798749..0000000000 --- a/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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.surefire.common.junit3; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -import org.apache.maven.surefire.api.util.ReflectionUtils; - -/** - * Reflection facade for JUnit3 classes - * - */ -public final class JUnit3Reflector { - private static final String TEST_CASE = "junit.framework.Test"; - - private static final String TEST_RESULT = "junit.framework.TestResult"; - - private static final String TEST_LISTENER = "junit.framework.TestListener"; - - private static final String TEST = "junit.framework.Test"; - - private static final String ADD_LISTENER_METHOD = "addListener"; - - private static final String RUN_METHOD = "run"; - - private static final String TEST_SUITE = "junit.framework.TestSuite"; - - private static final Class[] EMPTY_CLASS_ARRAY = {}; - - private static final Object[] EMPTY_OBJECT_ARRAY = {}; - - private final Class[] interfacesImplementedByDynamicProxy; - - private final Class testResultClass; - - private final Method addListenerMethod; - - private final Method testInterfaceRunMethod; - - private final Class testInterface; - - private final Class testCase; - - private final Constructor testsSuiteConstructor; - - public JUnit3Reflector(ClassLoader testClassLoader) { - testResultClass = ReflectionUtils.tryLoadClass(testClassLoader, TEST_RESULT); - testCase = ReflectionUtils.tryLoadClass(testClassLoader, TEST_CASE); - testInterface = ReflectionUtils.tryLoadClass(testClassLoader, TEST); - interfacesImplementedByDynamicProxy = - new Class[] {ReflectionUtils.tryLoadClass(testClassLoader, TEST_LISTENER)}; - Class[] constructorParamTypes = {Class.class}; - - Class testSuite = ReflectionUtils.tryLoadClass(testClassLoader, TEST_SUITE); - - // The interface implemented by the dynamic proxy (TestListener), happens to be - // the same as the param types of TestResult.addTestListener - - if (isJUnit3Available()) { - testsSuiteConstructor = ReflectionUtils.getConstructor(testSuite, constructorParamTypes); - addListenerMethod = tryGetMethod(testResultClass, ADD_LISTENER_METHOD, interfacesImplementedByDynamicProxy); - testInterfaceRunMethod = getMethod(testInterface, RUN_METHOD, testResultClass); - } else { - testsSuiteConstructor = null; - addListenerMethod = null; - testInterfaceRunMethod = null; - } - } - - // Switch to reflectionutils when building with 2.7.2 - private static Method tryGetMethod(Class clazz, String methodName, Class... parameters) { - try { - return clazz.getMethod(methodName, parameters); - } catch (NoSuchMethodException e) { - return null; - } - } - - private static Method getMethod(Class clazz, String methodName, Class... parameters) { - try { - return clazz.getMethod(methodName, parameters); - } catch (NoSuchMethodException e) { - throw new RuntimeException("When finding method " + methodName, e); - } - } - - public Object constructTestObject(Class testClass) - throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException { - Object testObject = createInstanceFromSuiteMethod(testClass); - - if (testObject == null && testCase.isAssignableFrom(testClass)) { - testObject = testsSuiteConstructor.newInstance(testClass); - } - - if (testObject == null) { - Constructor testConstructor = getTestConstructor(testClass); - - if (testConstructor.getParameterTypes().length == 0) { - testObject = testConstructor.newInstance(EMPTY_OBJECT_ARRAY); - } else { - testObject = testConstructor.newInstance(testClass.getName()); - } - } - return testObject; - } - - private static Object createInstanceFromSuiteMethod(Class testClass) - throws IllegalAccessException, InvocationTargetException { - Object testObject = null; - try { - Method suiteMethod = testClass.getMethod("suite", EMPTY_CLASS_ARRAY); - - if (Modifier.isPublic(suiteMethod.getModifiers()) && Modifier.isStatic(suiteMethod.getModifiers())) { - testObject = suiteMethod.invoke(null, EMPTY_OBJECT_ARRAY); - } - } catch (NoSuchMethodException e) { - // No suite method - } - return testObject; - } - - private static Constructor getTestConstructor(Class testClass) throws NoSuchMethodException { - try { - return testClass.getConstructor(String.class); - } catch (NoSuchMethodException e) { - return testClass.getConstructor(EMPTY_CLASS_ARRAY); - } - } - - public Class[] getInterfacesImplementedByDynamicProxy() { - return interfacesImplementedByDynamicProxy; - } - - public Class getTestResultClass() { - return testResultClass; - } - - public Method getAddListenerMethod() { - return addListenerMethod; - } - - public Method getTestInterfaceRunMethod() { - return testInterfaceRunMethod; - } - - public Class getTestInterface() { - return testInterface; - } - - public Method getRunMethod(Class testClass) { - return getMethod(testClass, RUN_METHOD, getTestResultClass()); - } - - public boolean isJUnit3Available() { - return testResultClass != null; - } -} diff --git a/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3TestChecker.java b/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3TestChecker.java deleted file mode 100644 index da655560cb..0000000000 --- a/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3TestChecker.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.surefire.common.junit3; - -import java.lang.reflect.Method; - -import org.apache.maven.surefire.api.filter.NonAbstractClassFilter; -import org.apache.maven.surefire.api.util.ScannerFilter; - -import static java.lang.reflect.Modifier.isPublic; -import static java.lang.reflect.Modifier.isStatic; -import static org.apache.maven.surefire.api.util.ReflectionUtils.tryGetMethod; -import static org.apache.maven.surefire.api.util.ReflectionUtils.tryLoadClass; - -/** - * Missing tests ? This class is basically a subset of the JUnit4TestChecker, which is tested - * to boredom and back. Unfortunately we don't have any common module between these providers, - * so this stuff is duplicated. We should probably make some modules and just shade the content - * into the providers. - * - * @author Kristian Rosenvold - */ -public class JUnit3TestChecker implements ScannerFilter { - private static final Class[] EMPTY_CLASS_ARRAY = new Class[0]; - - private final Class junitClass; - - private final NonAbstractClassFilter nonAbstractClassFilter = new NonAbstractClassFilter(); - - public JUnit3TestChecker(ClassLoader testClassLoader) { - junitClass = tryLoadClass(testClassLoader, "junit.framework.Test"); - } - - @Override - public boolean accept(Class testClass) { - return nonAbstractClassFilter.accept(testClass) && isValidJUnit3Test(testClass); - } - - private boolean isValidJUnit3Test(Class testClass) { - return junitClass != null && (junitClass.isAssignableFrom(testClass) || isSuiteOnly(testClass)); - } - - private boolean isSuiteOnly(Class testClass) { - final Method suite = tryGetMethod(testClass, "suite", EMPTY_CLASS_ARRAY); - if (suite != null) { - final int modifiers = suite.getModifiers(); - if (isPublic(modifiers) && isStatic(modifiers)) { - return junit.framework.Test.class.isAssignableFrom(suite.getReturnType()); - } - } - return false; - } -} diff --git a/surefire-providers/common-junit3/src/test/java/org/apache/maven/surefire/common/junit3/JUnit3TestCheckerTest.java b/surefire-providers/common-junit3/src/test/java/org/apache/maven/surefire/common/junit3/JUnit3TestCheckerTest.java deleted file mode 100644 index efb89fe247..0000000000 --- a/surefire-providers/common-junit3/src/test/java/org/apache/maven/surefire/common/junit3/JUnit3TestCheckerTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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.surefire.common.junit3; - -import junit.framework.TestCase; -import junit.framework.TestResult; - -/** - * @author Kristian Rosenvold - */ -public class JUnit3TestCheckerTest extends TestCase { - private final JUnit3TestChecker jUnit3TestChecker = - new JUnit3TestChecker(this.getClass().getClassLoader()); - - public void testValidJunit4Annotated() { - assertTrue(jUnit3TestChecker.accept(JUnit3TestCheckerTest.class)); - } - - public void testValidJunit4itsAJunit3Test() { - assertTrue(jUnit3TestChecker.accept(AlsoValid.class)); - } - - public void testValidJunitSubclassWithoutOwnTestmethods() { - assertTrue(jUnit3TestChecker.accept(SubClassWithoutOwnTestMethods.class)); - } - - public void testInvalidTest() { - assertFalse(jUnit3TestChecker.accept(NotValidTest.class)); - } - - public void testDontAcceptAbstractClasses() { - assertFalse(jUnit3TestChecker.accept(BaseClassWithTest.class)); - } - - public void testSuiteOnlyTest() { - assertTrue(jUnit3TestChecker.accept(SuiteOnlyTest.class)); - } - - public void testCustomSuiteOnlyTest() { - assertTrue(jUnit3TestChecker.accept(CustomSuiteOnlyTest.class)); - } - - public void testIinnerClassNotAutomaticallyTc() { - assertTrue(jUnit3TestChecker.accept(NestedTC.class)); - assertFalse(jUnit3TestChecker.accept(NestedTC.Inner.class)); - } - - /** - * - */ - public static class AlsoValid extends TestCase { - public void testSomething() {} - } - - /** - * - */ - public static class SuiteOnlyTest { - public static junit.framework.Test suite() { - return null; - } - } - - /** - * - */ - public static class CustomSuiteOnlyTest { - public static MySuite2 suite() { - return null; - } - } - - /** - * - */ - public static class MySuite2 implements junit.framework.Test { - @Override - public int countTestCases() { - return 0; - } - - @Override - public void run(TestResult testResult) {} - } - - /** - * - */ - public static class NotValidTest { - public void testSomething() {} - } - - /** - * - */ - public abstract static class BaseClassWithTest extends TestCase { - public void testWeAreAlsoATest() {} - } - - /** - * - */ - public static class SubClassWithoutOwnTestMethods extends BaseClassWithTest {} - - class NestedTC extends TestCase { - public class Inner {} - } -} diff --git a/surefire-providers/common-junit4/pom.xml b/surefire-providers/common-junit4/pom.xml deleted file mode 100644 index c45d067ab0..0000000000 --- a/surefire-providers/common-junit4/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - 4.0.0 - - - org.apache.maven.surefire - surefire-providers - 3.5.5-SNAPSHOT - - - common-junit4 - - Shared JUnit4 Provider Code - Shared JUnit4 Provider Code - - - - junit - junit - 4.0 - provided - - - org.apache.maven.surefire - surefire-logger-api - ${project.version} - - - org.apache.maven.surefire - surefire-shared-utils - - - org.apache.maven.surefire - common-junit3 - ${project.version} - - - org.apache.maven.surefire - common-java5 - ${project.version} - - - - - - - org.jacoco - jacoco-maven-plugin - - jacoco.agent - - - - jacoco-agent - - prepare-agent - - - - - - maven-surefire-plugin - - ${jvm.args.tests} ${jacoco.agent} - - - - org.apache.maven.surefire - surefire-shadefire - - - 3.5.0 - - - - - - diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4ProviderUtil.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4ProviderUtil.java deleted file mode 100644 index 4b88aadc00..0000000000 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4ProviderUtil.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.maven.surefire.api.util.internal.ClassMethod; -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; -import org.junit.runner.notification.Failure; - -import static org.apache.maven.surefire.api.util.internal.TestClassMethodNameUtils.extractClassName; -import static org.apache.maven.surefire.api.util.internal.TestClassMethodNameUtils.extractMethodName; -import static org.junit.runner.Description.TEST_MECHANISM; - -/** - * - * Utility method used among all JUnit4 providers - * - * @author Qingzhou Luo - * - */ -public final class JUnit4ProviderUtil { - private JUnit4ProviderUtil() { - throw new IllegalStateException("Cannot instantiate."); - } - - /** - * Get all descriptions from a list of Failures - * - * @param allFailures the list of failures for a given test class - * @return the list of descriptions - */ - public static Set generateFailingTestDescriptions(List allFailures) { - Set failingTestDescriptions = new HashSet<>(); - - for (Failure failure : allFailures) { - Description description = failure.getDescription(); - if (description.isTest() && !isFailureInsideJUnitItself(description)) { - failingTestDescriptions.add(description); - } - } - return failingTestDescriptions; - } - - public static boolean isFailureInsideJUnitItself(Description failure) { - return TEST_MECHANISM.equals(failure); - } - - /** - * Java Patterns of regex is slower than cutting a substring. - * @param description method(class) or method[#](class) or method[#whatever-literals](class) - * @return method JUnit test method - */ - public static ClassMethod toClassMethod(Description description) { - String clazz = extractClassName(description.getDisplayName()); - if (clazz == null || isInsaneJunitNullString(clazz)) { - // This can happen upon early failures (class instantiation error etc) - Iterator it = description.getChildren().iterator(); - if (it.hasNext()) { - description = it.next(); - clazz = extractClassName(description.getDisplayName()); - } - if (clazz == null) { - clazz = "Test Instantiation Error"; - } - } - String method = extractMethodName(description.getDisplayName()); - return new ClassMethod(clazz, method); - } - - private static boolean isInsaneJunitNullString(String value) { - return "null".equals(value); - } - - public static Filter createMatchAnyDescriptionFilter(Iterable descriptions) { - return new MatchDescriptions(descriptions); - } -} diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java deleted file mode 100644 index ba919b30d6..0000000000 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.junit.Ignore; -import org.junit.runner.Description; - -import static org.apache.maven.surefire.api.util.ReflectionUtils.getMethod; -import static org.apache.maven.surefire.api.util.ReflectionUtils.invokeMethodWithArray; -import static org.apache.maven.surefire.api.util.ReflectionUtils.tryGetMethod; - -/** - * JUnit4 reflection helper - * - */ -public final class JUnit4Reflector { - private static final Class[] PARAMS = {Class.class}; - - private static final Object[] IGNORE_PARAMS = {Ignore.class}; - - private static final Class[] PARAMS_WITH_ANNOTATIONS = {String.class, Annotation[].class}; - - private JUnit4Reflector() { - throw new IllegalStateException("not instantiable constructor"); - } - - public static Ignore getAnnotatedIgnore(Description d) { - Method getAnnotation = tryGetMethod(d.getClass(), "getAnnotation", PARAMS); - return getAnnotation == null ? null : (Ignore) invokeMethodWithArray(d, getAnnotation, IGNORE_PARAMS); - } - - static String getAnnotatedIgnoreValue(Description description) { - final Ignore ignore = getAnnotatedIgnore(description); - return ignore != null ? ignore.value() : null; - } - - public static Description createDescription(String description) { - try { - return Description.createSuiteDescription(description); - } catch (NoSuchMethodError e) { - Method method = getMethod(Description.class, "createSuiteDescription", PARAMS_WITH_ANNOTATIONS); - // may throw exception probably with broken JUnit 4.x - return invokeMethodWithArray(null, method, description, new Annotation[0]); - } - } - - public static Description createDescription(String description, Annotation... annotations) { - Method method = tryGetMethod(Description.class, "createSuiteDescription", PARAMS_WITH_ANNOTATIONS); - return method == null - ? Description.createSuiteDescription(description) - : (Description) invokeMethodWithArray(null, method, description, annotations); - } - - public static Ignore createIgnored(String value) { - return new IgnoredWithUserError(value); - } - - @SuppressWarnings("ClassExplicitlyAnnotation") - private static class IgnoredWithUserError implements Annotation, Ignore { - private final String value; - - IgnoredWithUserError(String value) { - this.value = value; - } - - @Override - public String value() { - return value; - } - - @Override - public Class annotationType() { - return Ignore.class; - } - - @Override - public int hashCode() { - return value == null ? 0 : value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof Ignore && equalValue((Ignore) obj); - } - - @Override - public String toString() { - return String.format("%s(%s)", Ignore.class, value); - } - - private boolean equalValue(Ignore ignore) { - return ignore != null && ignore.value().equals(value); - } - } -} diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java deleted file mode 100644 index 09f7abc68b..0000000000 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.apache.maven.surefire.api.report.OutputReportEntry; -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.RunMode; -import org.apache.maven.surefire.api.report.SimpleReportEntry; -import org.apache.maven.surefire.api.report.StackTraceWriter; -import org.apache.maven.surefire.api.report.TestOutputReceiver; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.api.util.internal.ClassMethod; -import org.apache.maven.surefire.report.ClassMethodIndexer; -import org.apache.maven.surefire.report.RunModeSetter; -import org.junit.runner.Description; -import org.junit.runner.Result; -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunListener; - -import static org.apache.maven.surefire.api.report.SimpleReportEntry.assumption; -import static org.apache.maven.surefire.api.report.SimpleReportEntry.ignored; -import static org.apache.maven.surefire.api.report.SimpleReportEntry.withException; -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.isFailureInsideJUnitItself; -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.toClassMethod; -import static org.apache.maven.surefire.common.junit4.JUnit4Reflector.getAnnotatedIgnoreValue; - -/** - * RunListener for JUnit4, delegates to our own RunListener - * - */ -public class JUnit4RunListener extends RunListener implements TestOutputReceiver, RunModeSetter { - protected final ClassMethodIndexer classMethodIndexer = new ClassMethodIndexer(); - protected final TestReportListener reporter; - private volatile RunMode runMode; - - /** - * This flag is set after a failure has occurred so that a - * {@link org.apache.maven.surefire.api.report.RunListener#testSucceeded} event is not fired. - * This is necessary because JUnit4 always fires a - * {@link org.junit.runner.notification.RunListener#testRunFinished(Result)} - * event-- even if there was a failure. - */ - private final ThreadLocal failureFlag = new InheritableThreadLocal<>(); - - /** - * Constructor. - * - * @param reporter the reporter to log testing events to - */ - public JUnit4RunListener(TestReportListener reporter) { - this.reporter = reporter; - } - - public final ConsoleLogger getConsoleLogger() { - return reporter; - } - - @Override - public void setRunMode(RunMode runMode) { - this.runMode = runMode; - } - - protected final RunMode getRunMode() { - return runMode; - } - - // Testrun methods are not invoked when using the runner - - /** - * Called when a specific test has been skipped (for whatever reason). - * - * @see org.junit.runner.notification.RunListener#testIgnored(org.junit.runner.Description) - */ - @Override - public void testIgnored(Description description) throws Exception { - String reason = getAnnotatedIgnoreValue(description); - ClassMethod classMethod = toClassMethod(description); - long testRunId = classMethodIndexer.indexClassMethod(classMethod.getClazz(), classMethod.getMethod()); - reporter.testSkipped( - ignored(runMode, testRunId, classMethod.getClazz(), null, classMethod.getMethod(), null, reason)); - } - - /** - * Called when a specific test has started. - * - * @see org.junit.runner.notification.RunListener#testStarted(org.junit.runner.Description) - */ - @Override - public void testStarted(Description description) throws Exception { - try { - reporter.testStarting(createReportEntry(description)); - } finally { - failureFlag.remove(); - } - } - - /** - * Called when a specific test has failed. - * - * @see org.junit.runner.notification.RunListener#testFailure(org.junit.runner.notification.Failure) - */ - @Override - @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"}) - public void testFailure(Failure failure) throws Exception { - try { - StackTraceWriter stackTrace = createStackTraceWriter(failure); - ClassMethod classMethod = toClassMethod(failure.getDescription()); - long testRunId = classMethodIndexer.indexClassMethod(classMethod.getClazz(), classMethod.getMethod()); - ReportEntry report = withException( - runMode, testRunId, classMethod.getClazz(), null, classMethod.getMethod(), null, stackTrace); - - if (failure.getException() instanceof AssertionError) { - reporter.testFailed(report); - } else { - reporter.testError(report); - } - } finally { - failureFlag.set(true); - } - } - - public void testAssumptionFailure(Failure failure) { - try { - Description desc = failure.getDescription(); - ClassMethod classMethod = toClassMethod(desc); - long testRunId = classMethodIndexer.indexClassMethod(classMethod.getClazz(), classMethod.getMethod()); - ReportEntry report = assumption( - runMode, - testRunId, - classMethod.getClazz(), - null, - classMethod.getMethod(), - null, - failure.getMessage()); - reporter.testAssumptionFailure(report); - } finally { - failureFlag.set(true); - } - } - - /** - * Called after a specific test has finished. - * - * @see org.junit.runner.notification.RunListener#testFinished(org.junit.runner.Description) - */ - @Override - public void testFinished(Description description) throws Exception { - Boolean failure = failureFlag.get(); - if (failure == null) { - reporter.testSucceeded(createReportEntry(description)); - } - } - - /** - * Delegates to {@link org.apache.maven.surefire.api.report.RunListener#testExecutionSkippedByUser()}. - */ - public void testExecutionSkippedByUser() { - reporter.testExecutionSkippedByUser(); - } - - protected StackTraceWriter createStackTraceWriter(Failure failure) { - return new JUnit4StackTraceWriter(failure); - } - - protected SimpleReportEntry createReportEntry(Description description) { - ClassMethod classMethod = toClassMethod(description); - long testRunId = classMethodIndexer.indexClassMethod(classMethod.getClazz(), classMethod.getMethod()); - return new SimpleReportEntry(runMode, testRunId, classMethod.getClazz(), null, classMethod.getMethod(), null); - } - - public static void rethrowAnyTestMechanismFailures(Result run) throws TestSetFailedException { - for (Failure failure : run.getFailures()) { - if (isFailureInsideJUnitItself(failure.getDescription())) { - throw new TestSetFailedException( - failure.getTestHeader() + " :: " + failure.getMessage(), failure.getException()); - } - } - } - - @Override - public void writeTestOutput(OutputReportEntry reportEntry) { - Long testRunId = classMethodIndexer.getLocalIndex(); - reporter.writeTestOutput(new TestOutputReportEntry(reportEntry, runMode, testRunId)); - } -} diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerFactory.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerFactory.java deleted file mode 100644 index b0a74a4f79..0000000000 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerFactory.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.surefire.api.util.ReflectionUtils; -import org.junit.runner.notification.RunListener; - -import static org.apache.maven.surefire.shared.utils.StringUtils.isNotBlank; - -/** - * @author Kristian Rosenvold - */ -public class JUnit4RunListenerFactory { - public static List createCustomListeners(String listeners) { - List result = new ArrayList<>(); - if (isNotBlank(listeners)) { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - for (String listener : listeners.split(",")) { - if (isNotBlank(listener)) { - result.add(ReflectionUtils.instantiate(cl, listener, RunListener.class)); - } - } - } - return result; - } -} diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java deleted file mode 100644 index e0a9c9de12..0000000000 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import org.apache.maven.surefire.api.report.SafeThrowable; -import org.apache.maven.surefire.api.report.StackTraceWriter; -import org.apache.maven.surefire.api.util.internal.ClassMethod; -import org.apache.maven.surefire.report.SmartStackTraceParser; -import org.junit.runner.notification.Failure; - -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.toClassMethod; -import static org.apache.maven.surefire.report.SmartStackTraceParser.stackTraceWithFocusOnClassAsString; - -/** - * Writes out a specific {@link org.junit.runner.notification.Failure} for - * surefire as a stacktrace. - * - * @author Karl M. Davis - */ -public class JUnit4StackTraceWriter implements StackTraceWriter { - private final Failure junitFailure; - - /** - * Constructor. - * - * @param junitFailure the {@link Failure} that this will be operating on - */ - public JUnit4StackTraceWriter(Failure junitFailure) { - this.junitFailure = junitFailure; - } - - /* - * (non-Javadoc) - * - * @see org.apache.maven.surefire.report.StackTraceWriter#writeTraceToString() - */ - @Override - public String writeTraceToString() { - Throwable t = junitFailure.getException(); - if (t != null) { - String originalTrace = junitFailure.getTrace(); - if (isMultiLineExceptionMessage(t)) { - // SUREFIRE-986 - StringBuilder builder = new StringBuilder(originalTrace); - String exc = t.getClass().getName() + ": "; - if (originalTrace.startsWith(exc)) { - builder.insert(exc.length(), '\n'); - } - return builder.toString(); - } - return originalTrace; - } - return ""; - } - - @Override - public String smartTrimmedStackTrace() { - Throwable exception = junitFailure.getException(); - ClassMethod classMethod = toClassMethod(junitFailure.getDescription()); - return exception == null - ? junitFailure.getMessage() - : new SmartStackTraceParser(classMethod.getClazz(), exception, classMethod.getMethod()).getString(); - } - - /** - * At the moment, returns the same as {@link #writeTraceToString()}. - * - * @see StackTraceWriter#writeTrimmedTraceToString() - */ - @Override - public String writeTrimmedTraceToString() { - String testClass = toClassMethod(junitFailure.getDescription()).getClazz(); - try { - Throwable e = junitFailure.getException(); - return stackTraceWithFocusOnClassAsString(e, testClass); - } catch (Throwable t) { - return stackTraceWithFocusOnClassAsString(t, testClass); - } - } - - /** - * Returns the exception associated with this failure. - * - * @see StackTraceWriter#getThrowable() - */ - @Override - public SafeThrowable getThrowable() { - return new SafeThrowable(junitFailure.getException()); - } - - private static boolean isMultiLineExceptionMessage(Throwable t) { - String msg = t.getLocalizedMessage(); - if (msg != null) { - int countNewLines = 0; - for (int i = 0, length = msg.length(); i < length; i++) { - if (msg.charAt(i) == '\n') { - if (++countNewLines == 2) { - break; - } - } - } - return countNewLines > 1 || countNewLines == 1 && !msg.trim().endsWith("\n"); - } - return false; - } -} diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4TestChecker.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4TestChecker.java deleted file mode 100644 index 88a1cd2ccc..0000000000 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4TestChecker.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.apache.maven.surefire.api.filter.NonAbstractClassFilter; -import org.apache.maven.surefire.api.util.ScannerFilter; -import org.apache.maven.surefire.common.junit3.JUnit3TestChecker; - -import static org.apache.maven.surefire.api.util.ReflectionUtils.tryLoadClass; - -/** - * @author Kristian Rosenvold - */ -public class JUnit4TestChecker implements ScannerFilter { - private final NonAbstractClassFilter nonAbstractClassFilter; - - private final Class runWith; - - private final JUnit3TestChecker jUnit3TestChecker; - - public JUnit4TestChecker(ClassLoader testClassLoader) { - jUnit3TestChecker = new JUnit3TestChecker(testClassLoader); - runWith = tryLoadClass(testClassLoader, org.junit.runner.RunWith.class.getName()); - nonAbstractClassFilter = new NonAbstractClassFilter(); - } - - @Override - public boolean accept(Class testClass) { - return jUnit3TestChecker.accept(testClass) || isValidJUnit4Test(testClass); - } - - @SuppressWarnings({"unchecked"}) - private boolean isValidJUnit4Test(Class testClass) { - if (!nonAbstractClassFilter.accept(testClass)) { - return false; - } - - if (isRunWithPresentInClassLoader()) { - Annotation runWithAnnotation = testClass.getAnnotation(runWith); - if (runWithAnnotation != null) { - return true; - } - } - - return lookForTestAnnotatedMethods(testClass); - } - - private boolean lookForTestAnnotatedMethods(Class testClass) { - Class classToCheck = testClass; - while (classToCheck != null) { - if (checkforTestAnnotatedMethod(classToCheck)) { - return true; - } - classToCheck = classToCheck.getSuperclass(); - } - return false; - } - - public boolean checkforTestAnnotatedMethod(Class testClass) { - for (Method lMethod : testClass.getDeclaredMethods()) { - for (Annotation lAnnotation : lMethod.getAnnotations()) { - if (org.junit.Test.class.isAssignableFrom(lAnnotation.annotationType())) { - return true; - } - } - } - return false; - } - - public boolean isRunWithPresentInClassLoader() { - return runWith != null; - } -} diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java deleted file mode 100644 index dc477d132b..0000000000 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunListener; - -/** - * Test listener to record all the failures during one run - * - * @author Qingzhou Luo - */ -public class JUnitTestFailureListener extends RunListener { - private final List allFailures = new ArrayList<>(); - - @Override - public void testFailure(Failure failure) throws Exception { - if (failure != null) { - allFailures.add(failure); - } - } - - public List getAllFailures() { - return allFailures; - } - - public void reset() { - allFailures.clear(); - } -} diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/MatchDescriptions.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/MatchDescriptions.java deleted file mode 100644 index 78ec311246..0000000000 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/MatchDescriptions.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -/** - * Only run test methods in the given failure set. - * - * @author mpkorstanje - */ -public final class MatchDescriptions extends Filter { - private final List filters = new ArrayList<>(); - - public MatchDescriptions(Iterable descriptions) { - for (Description description : descriptions) { - filters.add(matchDescription(description)); - } - } - - @Override - public boolean shouldRun(Description description) { - for (Filter filter : filters) { - if (filter.shouldRun(description)) { - return true; - } - } - return false; - } - - @Override - public String describe() { - StringBuilder description = new StringBuilder("Matching description "); - for (int i = 0; i < filters.size(); i++) { - description.append(filters.get(i).describe()); - if (i != filters.size() - 1) { - description.append(" OR "); - } - } - return description.toString(); - } - - private static Filter matchDescription(final Description desiredDescription) { - return new Filter() { - @Override - public boolean shouldRun(Description description) { - if (description.isTest()) { - return desiredDescription.equals(description); - } - - for (Description each : description.getChildren()) { - if (shouldRun(each)) { - return true; - } - } - - return false; - } - - @Override - public String describe() { - return String.format("Method %s", desiredDescription.getDisplayName()); - } - }; - } -} diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/Notifier.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/Notifier.java deleted file mode 100644 index e467304055..0000000000 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/Notifier.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicInteger; - -import org.junit.runner.Description; -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunListener; -import org.junit.runner.notification.RunNotifier; -import org.junit.runner.notification.StoppedByUserException; - -import static org.apache.maven.surefire.api.util.internal.ConcurrencyUtils.runIfZeroCountDown; -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.toClassMethod; - -/** - * Extends {@link RunNotifier JUnit notifier}, - * encapsulates several different types of {@link RunListener JUnit listeners}, and - * fires events to listeners. - * - * @author Tibor Digana (tibor17) - * @since 2.19 - */ -public class Notifier extends RunNotifier { - private final Collection listeners = new ArrayList<>(); - - private final Queue testClassNames = new ConcurrentLinkedQueue<>(); - - private final AtomicInteger skipAfterFailureCount; - - private final JUnit4RunListener reporter; - - private volatile boolean failFast; - - public Notifier(JUnit4RunListener reporter, int skipAfterFailureCount) { - addListener(reporter); - this.reporter = reporter; - this.skipAfterFailureCount = new AtomicInteger(skipAfterFailureCount); - } - - private Notifier() { - reporter = null; - skipAfterFailureCount = null; - } - - public static Notifier pureNotifier() { - return new Notifier() { - @Override - public void asFailFast(@SuppressWarnings({"unused", "checkstyle:hiddenfieldcheck"}) boolean failFast) { - throw new UnsupportedOperationException("pure notifier"); - } - }; - } - - public void asFailFast(boolean enableFailFast) { - failFast = enableFailFast; - } - - public final boolean isFailFast() { - return failFast; - } - - @Override - @SuppressWarnings("checkstyle:redundantthrowscheck") // checkstyle is wrong here, see super.fireTestStarted() - public final void fireTestStarted(Description description) throws StoppedByUserException { - // If fireTestStarted() throws exception (== skipped test), the class must not be removed from testClassNames. - // Therefore this class will be removed only if test class started with some test method. - super.fireTestStarted(description); - if (!testClassNames.isEmpty()) { - testClassNames.remove(toClassMethod(description).getClazz()); - } - } - - @Override - public final void fireTestFailure(Failure failure) { - if (failFast) { - fireStopEvent(); - } - super.fireTestFailure(failure); - } - - @Override - public final void addListener(RunListener listener) { - listeners.add(listener); - super.addListener(listener); - } - - public final Notifier addListeners(Collection given) { - for (RunListener listener : given) { - addListener(listener); - } - return this; - } - - @SuppressWarnings("unused") - public final Notifier addListeners(RunListener... given) { - for (RunListener listener : given) { - addListener(listener); - } - return this; - } - - @Override - public final void removeListener(RunListener listener) { - listeners.remove(listener); - super.removeListener(listener); - } - - public final void removeListeners() { - for (Iterator it = listeners.iterator(); it.hasNext(); ) { - RunListener listener = it.next(); - it.remove(); - super.removeListener(listener); - } - } - - public final Queue getRemainingTestClasses() { - return failFast ? testClassNames : null; - } - - public final void copyListenersTo(Notifier copyTo) { - copyTo.addListeners(listeners); - } - - /** - * Fire stop even to plugin process and/or call {@link org.junit.runner.notification.RunNotifier#pleaseStop()}. - */ - private void fireStopEvent() { - runIfZeroCountDown(this::pleaseStop, skipAfterFailureCount); - reporter.testExecutionSkippedByUser(); - } -} diff --git a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4ProviderUtilTest.java b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4ProviderUtilTest.java deleted file mode 100644 index 51199bbac1..0000000000 --- a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4ProviderUtilTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import junit.framework.TestCase; -import org.apache.maven.surefire.api.util.internal.ClassMethod; -import org.junit.runner.Description; -import org.junit.runner.notification.Failure; - -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.generateFailingTestDescriptions; - -/** - * @author Qingzhou Luo - */ -public class JUnit4ProviderUtilTest extends TestCase { - public void testGenerateFailingTestDescriptions() { - List failures = new ArrayList<>(); - - Description test1Description = Description.createTestDescription(T1.class, "testOne"); - Description test2Description = Description.createTestDescription(T1.class, "testTwo"); - Description test3Description = Description.createTestDescription(T2.class, "testThree"); - Description test4Description = Description.createTestDescription(T2.class, "testFour"); - Description test5Description = Description.createSuiteDescription("Test mechanism"); - - failures.add(new Failure(test1Description, new AssertionError())); - failures.add(new Failure(test2Description, new AssertionError())); - failures.add(new Failure(test3Description, new RuntimeException())); - failures.add(new Failure(test4Description, new AssertionError())); - failures.add(new Failure(test5Description, new RuntimeException())); - - Set result = generateFailingTestDescriptions(failures); - - assertEquals(4, result.size()); - - assertTrue(result.contains(test1Description)); - assertTrue(result.contains(test2Description)); - assertTrue(result.contains(test3Description)); - assertTrue(result.contains(test4Description)); - } - - public void testIllegalTestDescriptionNegativeTest() { - Description test = Description.createSuiteDescription("someTestMethod"); - ClassMethod classMethod = JUnit4ProviderUtil.toClassMethod(test); - assertFalse(classMethod.isValidTest()); - } - - public void testOldJUnitParameterizedDescriptionParser() { - Description test = Description.createTestDescription(T1.class, " \n testMethod[5] "); - assertEquals(" \n testMethod[5] (" + T1.class.getName() + ")", test.getDisplayName()); - ClassMethod classMethod = JUnit4ProviderUtil.toClassMethod(test); - assertTrue(classMethod.isValidTest()); - assertEquals(" \n testMethod[5] ", classMethod.getMethod()); - assertEquals(T1.class.getName(), classMethod.getClazz()); - } - - public void testNewJUnitParameterizedDescriptionParser() { - Description test = Description.createTestDescription(T1.class, "flakyTest[3: (Test11); Test12; Test13;]"); - ClassMethod classMethod = JUnit4ProviderUtil.toClassMethod(test); - assertTrue(classMethod.isValidTest()); - assertEquals("flakyTest[3: (Test11); Test12; Test13;]", classMethod.getMethod()); - assertEquals(T1.class.getName(), classMethod.getClazz()); - } - - private static class T1 {} - - private static class T2 {} -} diff --git a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector40Test.java b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector40Test.java deleted file mode 100644 index ad12f5d466..0000000000 --- a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector40Test.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import junit.framework.TestCase; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.Description; - -/** - * @author Kristian Rosenvold - */ -public class JUnit4Reflector40Test extends TestCase { - public void testGetAnnotatedIgnore() { - Description desc = Description.createTestDescription(IgnoreWithDescription.class, "testSomething2"); - Ignore annotatedIgnore = JUnit4Reflector.getAnnotatedIgnore(desc); - assertNull(annotatedIgnore); - } - - private static final String REASON = "Ignorance is bliss"; - - /** - * - */ - public static class IgnoreWithDescription { - - @Test - @Ignore(REASON) - public void testSomething2() {} - } - - public void testCreateIgnored() { - Ignore ignore = JUnit4Reflector.createIgnored("error"); - assertNotNull(ignore); - assertNotNull(ignore.value()); - assertEquals("error", ignore.value()); - } - - public void testCreateDescription() { - Ignore ignore = JUnit4Reflector.createIgnored("error"); - Description description = JUnit4Reflector.createDescription("exception", ignore); - assertEquals("exception", description.getDisplayName()); - assertEquals("exception", description.toString()); - assertEquals(0, description.getChildren().size()); - // JUnit 4 description does not get annotations - Ignore annotatedIgnore = JUnit4Reflector.getAnnotatedIgnore(description); - assertNull(annotatedIgnore); - } - - public void testCreatePureDescription() { - Description description = JUnit4Reflector.createDescription("exception"); - assertEquals("exception", description.getDisplayName()); - assertEquals("exception", description.toString()); - assertEquals(0, description.getChildren().size()); - } -} diff --git a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java deleted file mode 100644 index 1d22b0d085..0000000000 --- a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import java.util.concurrent.CountDownLatch; - -import junit.framework.Assert; -import junit.framework.TestCase; -import org.apache.maven.surefire.api.util.internal.DaemonThreadFactory; -import org.junit.Test; -import org.junit.runner.Description; -import org.junit.runner.Request; -import org.junit.runner.Runner; -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunListener; -import org.junit.runner.notification.RunNotifier; - -/** - * @author Kristian Rosenvold - */ -public class JUnit4RunListenerTest extends TestCase { - public void testTestStarted() { - RunListener jUnit4TestSetReporter = new JUnit4RunListener(new MockReporter()); - Runner junitTestRunner = - Request.classes("abc", STest1.class, STest2.class).getRunner(); - RunNotifier runNotifier = new RunNotifier(); - runNotifier.addListener(jUnit4TestSetReporter); - junitTestRunner.run(runNotifier); - } - - public void testParallelInvocations() throws Exception { - final MockReporter reporter = new MockReporter(); - final RunListener jUnit4TestSetReporter = new JUnit4RunListener(reporter); - final CountDownLatch countDownLatch = new CountDownLatch(1); - final Description testSomething = Description.createTestDescription(STest1.class, "testSomething"); - final Description testSomething2 = Description.createTestDescription(STest2.class, "testSomething2"); - - jUnit4TestSetReporter.testStarted(testSomething); - - DaemonThreadFactory.newDaemonThread(new Runnable() { - @Override - public void run() { - try { - jUnit4TestSetReporter.testStarted(testSomething2); - jUnit4TestSetReporter.testFailure(new Failure(testSomething2, new AssertionError("Fud"))); - jUnit4TestSetReporter.testFinished(testSomething2); - countDownLatch.countDown(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }) - .start(); - - countDownLatch.await(); - jUnit4TestSetReporter.testFinished(testSomething); - - Assert.assertEquals("Failing tests", 1, reporter.getTestFailed()); - Assert.assertEquals("Succeeded tests", 1, reporter.getTestSucceeded()); - } - - /** - * - */ - public static class STest1 { - @Test - public void testSomething() {} - } - - /** - * - */ - public static class STest2 { - @Test - public void testSomething2() {} - } -} diff --git a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/MockReporter.java b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/MockReporter.java deleted file mode 100644 index eb5baf092a..0000000000 --- a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/MockReporter.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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.surefire.common.junit4; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.apache.maven.surefire.api.report.TestSetReportEntry; - -/** - * Internal tests use only. - */ -final class MockReporter implements TestReportListener { - private final List events = new ArrayList<>(); - - private static final String SET_STARTED = "SET_STARTED"; - - private static final String SET_COMPLETED = "SET_COMPLETED"; - - private static final String TEST_STARTED = "TEST_STARTED"; - - private static final String TEST_COMPLETED = "TEST_COMPLETED"; - - private static final String TEST_SKIPPED = "TEST_SKIPPED"; - - private final AtomicInteger testSucceeded = new AtomicInteger(); - - private final AtomicInteger testIgnored = new AtomicInteger(); - - private final AtomicInteger testFailed = new AtomicInteger(); - - private final AtomicInteger testError = new AtomicInteger(); - - MockReporter() {} - - @Override - public void testSetStarting(TestSetReportEntry report) { - events.add(SET_STARTED); - } - - @Override - public void testSetCompleted(TestSetReportEntry report) { - events.add(SET_COMPLETED); - } - - @Override - public void testStarting(ReportEntry report) { - events.add(TEST_STARTED); - } - - @Override - public void testSucceeded(ReportEntry report) { - events.add(TEST_COMPLETED); - testSucceeded.incrementAndGet(); - } - - @Override - public void testSkipped(ReportEntry report) { - events.add(TEST_SKIPPED); - testIgnored.incrementAndGet(); - } - - @Override - public void testExecutionSkippedByUser() {} - - public int getTestSucceeded() { - return testSucceeded.get(); - } - - public int getTestFailed() { - return testFailed.get(); - } - - @Override - public void testError(ReportEntry report) { - testError.incrementAndGet(); - } - - @Override - public void testFailed(ReportEntry report) { - testFailed.incrementAndGet(); - } - - @Override - public void testAssumptionFailure(ReportEntry report) {} - - @Override - public void writeTestOutput(TestOutputReportEntry reportEntry) {} - - @Override - public boolean isDebugEnabled() { - return false; - } - - @Override - public void debug(String message) {} - - @Override - public boolean isInfoEnabled() { - return false; - } - - @Override - public void info(String message) {} - - @Override - public boolean isWarnEnabled() { - return false; - } - - @Override - public void warning(String message) {} - - @Override - public boolean isErrorEnabled() { - return false; - } - - @Override - public void error(String message) {} - - @Override - public void error(String message, Throwable t) {} - - @Override - public void error(Throwable t) {} -} diff --git a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java deleted file mode 100644 index 23a9c6673c..0000000000 --- a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * 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.surefire.junit4; - -import java.util.Collections; -import java.util.Set; - -import junit.framework.TestCase; -import junit.framework.TestResult; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.common.junit4.JUnit4TestChecker; -import org.junit.Test; -import org.junit.internal.runners.InitializationError; -import org.junit.runner.Description; -import org.junit.runner.RunWith; -import org.junit.runner.Runner; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.Suite; - -/** - * @author Kristian Rosenvold - */ -public class JUnit4TestCheckerTest extends TestCase { - private final JUnit4TestChecker jUnit4TestChecker = - new JUnit4TestChecker(this.getClass().getClassLoader()); - - public void testValidJunit4Annotated() throws TestSetFailedException { - assertTrue(jUnit4TestChecker.accept(JUnit4TestCheckerTest.class)); - } - - public void testValidJunit4itsAJunit3Test() throws TestSetFailedException { - assertTrue(jUnit4TestChecker.accept(AlsoValid.class)); - } - - public void testValidJunitSubclassWithoutOwnTestmethods() throws TestSetFailedException { - assertTrue(jUnit4TestChecker.accept(SubClassWithoutOwnTestMethods.class)); - } - - public void testValidSuite() throws TestSetFailedException { - assertTrue(jUnit4TestChecker.accept(SuiteValid1.class)); - } - - public void testValidCustomSuite() throws TestSetFailedException { - assertTrue(jUnit4TestChecker.accept(SuiteValid2.class)); - } - - public void testValidCustomRunner() throws TestSetFailedException { - assertTrue(jUnit4TestChecker.accept(SuiteValidCustomRunner.class)); - } - - public void testInvalidTest() throws TestSetFailedException { - assertFalse(jUnit4TestChecker.accept(NotValidTest.class)); - } - - public void testDontAcceptAbstractClasses() { - assertFalse(jUnit4TestChecker.accept(BaseClassWithTest.class)); - } - - public void testSuiteOnlyTest() { - assertTrue(jUnit4TestChecker.accept(SuiteOnlyTest.class)); - } - - public void testCustomSuiteOnlyTest() { - assertTrue(jUnit4TestChecker.accept(CustomSuiteOnlyTest.class)); - } - - public void testInnerClassNotAutomaticallyTc() { - assertTrue(jUnit4TestChecker.accept(NestedTC.class)); - assertFalse(jUnit4TestChecker.accept(NestedTC.Inner.class)); - } - - public void testCannotLoadRunWithAnnotation() throws Exception { - Class testClass = SimpleJUnit4TestClass.class; - ClassLoader testClassLoader = testClass.getClassLoader(); - // Emulate an OSGi classloader which filters on package level. - // Use a classloader which can only load classes in package org.junit, - // e.g. org.junit.Test, but no classes from other packages, - // in particular org.junit.runner.RunWith can't be loaded - Set visiblePackages = Collections.singleton("org.junit"); - PackageFilteringClassLoader filteringTestClassloader = - new PackageFilteringClassLoader(testClassLoader, visiblePackages); - JUnit4TestChecker checker = new JUnit4TestChecker(filteringTestClassloader); - assertTrue(checker.accept(testClass)); - } - - /** - * - */ - public static class AlsoValid extends TestCase { - public void testSomething() {} - } - - /** - * - */ - public static class SuiteOnlyTest { - public static junit.framework.Test suite() { - return null; - } - } - - /** - * - */ - public static class CustomSuiteOnlyTest { - public static MySuite2 suite() { - return null; - } - } - - /** - * - */ - public static class MySuite2 implements junit.framework.Test { - @Override - public int countTestCases() { - return 0; - } - - @Override - public void run(TestResult testResult) {} - } - - /** - * - */ - @SuppressWarnings({"UnusedDeclaration"}) - public static class NotValidTest { - public void testSomething() {} - } - - /** - * - */ - public abstract static class BaseClassWithTest { - @Test - public void weAreAlsoATest() {} - } - - /** - * - */ - public static class SubClassWithoutOwnTestMethods extends BaseClassWithTest {} - - /** - * - */ - @RunWith(Suite.class) - public static class SuiteValid1 { - public void testSomething() {} - } - - class CustomRunner extends Runner { - @Override - public Description getDescription() { - return Description.createSuiteDescription("CustomRunner"); - } - - @Override - public void run(RunNotifier runNotifier) {} - } - - /** - * - */ - @RunWith(CustomRunner.class) - public static class SuiteValidCustomRunner { - public void testSomething() {} - } - - /** - * - */ - @RunWith(MySuite.class) - public static class SuiteValid2 { - public void testSomething() {} - } - - /** - * - */ - public static class SimpleJUnit4TestClass { - @Test - public void testMethod() {} - } - - class MySuite extends Suite { - MySuite(Class klass) throws InitializationError { - super(klass); - } - } - - class NestedTC extends TestCase { - public class Inner {} - } -} diff --git a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/junit4/PackageFilteringClassLoader.java b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/junit4/PackageFilteringClassLoader.java deleted file mode 100644 index 8e5e54fd47..0000000000 --- a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/junit4/PackageFilteringClassLoader.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.surefire.junit4; - -import java.util.Set; - -/** - * Emulate an OSGi classloader which only loads packages that have been imported via Import-Package MANIFEST header. - */ -public class PackageFilteringClassLoader extends ClassLoader { - - private ClassLoader wrapped; - - private Set visiblePackages; - - public PackageFilteringClassLoader(ClassLoader wrapped, Set visiblePackages) { - this.wrapped = wrapped; - this.visiblePackages = visiblePackages; - } - - @Override - public Class loadClass(String className) throws ClassNotFoundException { - String packageName = ""; - int lastDot = className.lastIndexOf('.'); - if (lastDot != -1) { - packageName = className.substring(0, lastDot); - } - if (visiblePackages.contains(packageName)) { - return wrapped.loadClass(className); - } else { - throw new ClassNotFoundException(className); - } - } -} diff --git a/surefire-providers/common-junit48/pom.xml b/surefire-providers/common-junit48/pom.xml deleted file mode 100644 index cf79ab96cd..0000000000 --- a/surefire-providers/common-junit48/pom.xml +++ /dev/null @@ -1,185 +0,0 @@ - - - - 4.0.0 - - - org.apache.maven.surefire - surefire-providers - 3.5.5-SNAPSHOT - - - common-junit48 - - Shared JUnit48 Provider Code - Shared JUnit48 Provider Code - - - - junit - junit - 4.8.1 - provided - - - org.apache.maven.surefire - surefire-shared-utils - - - org.apache.maven.surefire - common-junit4 - ${project.version} - - - org.apache.maven.surefire - surefire-grouper - ${project.version} - - - org.hamcrest - hamcrest - test - - - - - - - org.jacoco - jacoco-maven-plugin - - jacoco.agent - - - - jacoco-agent - - prepare-agent - - - - - - maven-dependency-plugin - - - junit-4.11 - - copy - - process-test-sources - - ${project.build.directory}/endorsed-test - false - - - junit - junit - 4.11 - jar - - - - - - test - - copy - - process-test-sources - - ${project.build.directory}/endorsed-test - false - - - junit - junit - 4.12 - jar - - - - - - - - maven-surefire-plugin - - ${jvm.args.tests} ${jacoco.agent} - - - - org.apache.maven.surefire - surefire-shadefire - - - 3.5.0 - - - - - default-test - - test - - test - - - **/JUnit4SuiteTest.java - - - - - junit-4.11 - - test - - test - - GroupMatcherCategoryFilterPreJUnit412Test$JUnit4SuiteTest - - junit:junit - - - ${project.build.directory}/endorsed-test/junit-4.11.jar - - - - - junit-4.12 - - test - - test - - GroupMatcherCategoryFilterTest$JUnit4SuiteTest - - junit:junit - - - ${project.build.directory}/endorsed-test/junit-4.12.jar - - - - - - - - diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/AndFilter.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/AndFilter.java deleted file mode 100644 index 48a119b256..0000000000 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/AndFilter.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -final class AndFilter extends Filter { - private final Filter[] filters; - - AndFilter(Filter... filters) { - this.filters = filters; - } - - @Override - public boolean shouldRun(Description description) { - for (Filter filter : filters) { - if (!filter.shouldRun(description)) { - return false; - } - } - return true; - } - - @Override - public String describe() { - StringBuilder description = new StringBuilder(); - for (int i = 0; i < filters.length; i++) { - description.append(filters[i].describe()); - if (i != filters.length - 1) { - description.append(" AND "); - } - } - return description.toString(); - } -} diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/CombinedCategoryFilter.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/CombinedCategoryFilter.java deleted file mode 100644 index 075426b1b6..0000000000 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/CombinedCategoryFilter.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import java.util.Collection; - -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -final class CombinedCategoryFilter extends Filter { - private final Collection includedFilters; - - private final Collection excludedFilters; - - CombinedCategoryFilter(Collection includedFilters, Collection excludedFilters) { - this.includedFilters = includedFilters; - this.excludedFilters = excludedFilters; - } - - @Override - public boolean shouldRun(Description description) { - return (includedFilters.isEmpty() || anyFilterMatchesDescription(includedFilters, description)) - && (excludedFilters.isEmpty() || allFiltersMatchDescription(excludedFilters, description)); - } - - private boolean anyFilterMatchesDescription(Collection filters, Description description) { - for (Filter f : filters) { - if (f.shouldRun(description)) { - return true; - } - } - return false; - } - - private boolean allFiltersMatchDescription(Collection filters, Description description) { - for (Filter f : filters) { - if (!f.shouldRun(description)) { - return false; - } - } - return true; - } - - @Override - public String describe() { - StringBuilder sb = new StringBuilder(); - if (!includedFilters.isEmpty()) { - sb.append("("); - sb.append(joinFilters(includedFilters, " OR ")); - sb.append(")"); - if (!excludedFilters.isEmpty()) { - sb.append(" AND "); - } - } - - if (!excludedFilters.isEmpty()) { - sb.append("NOT ("); - sb.append(joinFilters(includedFilters, " OR ")); - sb.append(")"); - } - - return sb.toString(); - } - - private String joinFilters(Collection filters, String sep) { - boolean isFirst = true; - StringBuilder sb = new StringBuilder(); - for (Filter f : filters) { - if (!isFirst) { - sb.append(sep); - } - sb.append(f.describe()); - isFirst = false; - } - return sb.toString(); - } -} diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java deleted file mode 100644 index 45d21b7513..0000000000 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import java.util.Map; - -import org.apache.maven.surefire.api.booter.ProviderParameterNames; -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil; -import org.apache.maven.surefire.group.match.GroupMatcher; -import org.apache.maven.surefire.group.parse.GroupMatcherParser; -import org.apache.maven.surefire.group.parse.ParseException; -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -import static org.apache.maven.surefire.api.booter.ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP; -import static org.apache.maven.surefire.api.booter.ProviderParameterNames.TESTNG_GROUPS_PROP; -import static org.apache.maven.surefire.shared.utils.StringUtils.isNotBlank; - -/** - * @author Todd Lipcon - */ -public class FilterFactory { - private final ClassLoader testClassLoader; - - public FilterFactory(ClassLoader testClassLoader) { - this.testClassLoader = testClassLoader; - } - - /** - * @return {@code true} if non-blank - * {@link ProviderParameterNames#TESTNG_GROUPS_PROP} and/or - * {@link ProviderParameterNames#TESTNG_EXCLUDEDGROUPS_PROP} exists. - */ - public boolean canCreateGroupFilter(Map providerProperties) { - String groups = providerProperties.get(TESTNG_GROUPS_PROP); - String excludedGroups = providerProperties.get(TESTNG_EXCLUDEDGROUPS_PROP); - return isNotBlank(groups) || isNotBlank(excludedGroups); - } - - /** - * Creates filter using he key - * {@link ProviderParameterNames#TESTNG_GROUPS_PROP} and/or - * {@link ProviderParameterNames#TESTNG_EXCLUDEDGROUPS_PROP}. - */ - public Filter createGroupFilter(Map providerProperties) { - String groups = providerProperties.get(TESTNG_GROUPS_PROP); - - GroupMatcher included = null; - if (isNotBlank(groups)) { - try { - included = new GroupMatcherParser(groups).parse(); - } catch (ParseException e) { - throw new IllegalArgumentException( - "Invalid group expression: '" + groups + "'. Reason: " + e.getMessage(), e); - } - } - - String excludedGroups = providerProperties.get(TESTNG_EXCLUDEDGROUPS_PROP); - - GroupMatcher excluded = null; - if (isNotBlank(excludedGroups)) { - try { - excluded = new GroupMatcherParser(excludedGroups).parse(); - } catch (ParseException e) { - throw new IllegalArgumentException( - "Invalid group expression: '" + excludedGroups + "'. Reason: " + e.getMessage(), e); - } - } - - if (included != null && testClassLoader != null) { - included.loadGroupClasses(testClassLoader); - } - - if (excluded != null && testClassLoader != null) { - excluded.loadGroupClasses(testClassLoader); - } - - return new GroupMatcherCategoryFilter(included, excluded); - } - - public Filter createMethodFilter(String requestedTestMethod) { - return new MethodFilter(requestedTestMethod); - } - - public Filter createMethodFilter(TestListResolver resolver) { - return new MethodFilter(resolver); - } - - public Filter createMatchAnyDescriptionFilter(Iterable descriptions) { - return JUnit4ProviderUtil.createMatchAnyDescriptionFilter(descriptions); - } - - public Filter and(Filter filter1, Filter filter2) { - return new AndFilter(filter1, filter2); - } -} diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilter.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilter.java deleted file mode 100644 index 956c7aa01a..0000000000 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilter.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import java.lang.annotation.Inherited; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; - -import org.apache.maven.surefire.group.match.AndGroupMatcher; -import org.apache.maven.surefire.group.match.GroupMatcher; -import org.apache.maven.surefire.group.match.InverseGroupMatcher; -import org.junit.experimental.categories.Category; -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -import static java.util.Collections.addAll; -import static org.junit.runner.Description.createSuiteDescription; - -final class GroupMatcherCategoryFilter extends Filter { - /** - * Only traverse the tree if @Category annotation is inherited (since junit 4.12). - */ - private static final boolean IS_CATEGORY_INHERITED = Category.class.isAnnotationPresent(Inherited.class); - - private final AndGroupMatcher matcher; - - GroupMatcherCategoryFilter(GroupMatcher included, GroupMatcher excluded) { - GroupMatcher invertedExclude = excluded == null ? null : new InverseGroupMatcher(excluded); - if (included != null || invertedExclude != null) { - matcher = new AndGroupMatcher(); - if (included != null) { - matcher.addMatcher(included); - } - - if (invertedExclude != null) { - matcher.addMatcher(invertedExclude); - } - } else { - matcher = null; - } - } - - @Override - public boolean shouldRun(Description description) { - if (invalidTestClass(description)) { - return shouldRun(description, null, null); - } - - if (describesTestClass(description)) // is a test class - { - Class testClass = description.getTestClass(); - return shouldRun(description, null, testClass); - } else - // is a test method - { - Class testClass = description.getTestClass(); - return shouldRun(description, createSuiteDescription(testClass), testClass); - } - } - - private boolean describesTestClass(Description description) { - String methodName = description.getMethodName(); - // Description parser in Junit 4.8 can return "null" String. - return methodName == null || methodName.equals("null"); - } - - private boolean invalidTestClass(Description description) { - return description.getTestClass() == null; - } - - private static void findSuperclassCategories(Set> cats, Class clazz) { - if (IS_CATEGORY_INHERITED && hasSuperclass(clazz)) { - Category cat = clazz.getSuperclass().getAnnotation(Category.class); - if (cat != null) { - // Found categories in current superclass - addAll(cats, cat.value()); - } - // Search the hierarchy - findSuperclassCategories(cats, clazz.getSuperclass()); - } - } - - private static boolean hasSuperclass(Class clazz) { - return clazz != null && clazz.getSuperclass() != null; - } - - private boolean shouldRun(Description description, Description parent, Class parentClass) { - if (matcher == null) { - return true; - } else { - Set> cats = new HashSet<>(); - Category cat = description.getAnnotation(Category.class); - if (cat != null) { - // Found categories in current description - addAll(cats, cat.value()); - } - - if (parent != null) { - cat = parent.getAnnotation(Category.class); - if (cat != null) { - // Found categories in current parent - addAll(cats, cat.value()); - } - } - if (parentClass != null) { - findSuperclassCategories(cats, parentClass); - } - - Class testClass = description.getTestClass(); - if (testClass != null) { - cat = testClass.getAnnotation(Category.class); - if (cat != null) { - // Found categories in current testClass - addAll(cats, cat.value()); - } - } - - cats.remove(null); - boolean result = matcher.enabled(cats.toArray(new Class[cats.size()])); - - if (!result) { - ArrayList children = description.getChildren(); - if (children != null) { - for (Description child : children) { - if (shouldRun(child, description, null)) { - result = true; - break; - } - } - } - } - - return result; - } - } - - @Override - public String describe() { - return matcher == null ? "ANY" : matcher.toString(); - } -} diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/InvertedFilter.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/InvertedFilter.java deleted file mode 100644 index e9021e0fca..0000000000 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/InvertedFilter.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -final class InvertedFilter extends Filter { - private final Filter filter; - - InvertedFilter(Filter filter) { - this.filter = filter; - } - - @Override - public boolean shouldRun(Description description) { - return !filter.shouldRun(description); - } - - @Override - public String describe() { - return filter.describe(); - } -} diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java deleted file mode 100644 index 8749f15f54..0000000000 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import static org.apache.maven.surefire.api.util.ReflectionUtils.tryLoadClass; - -/** - * @author Kristian Rosenvold - */ -public final class JUnit48Reflector { - private static final String CATEGORIES = "org.junit.experimental.categories.Categories"; - - private static final String CATEGORY = "org.junit.experimental.categories.Category"; - - private final Class categories; - - private final Class category; - - public JUnit48Reflector(ClassLoader testClassLoader) { - categories = tryLoadClass(testClassLoader, CATEGORIES); - category = tryLoadClass(testClassLoader, CATEGORY); - } - - public boolean isJUnit48Available() { - return categories != null; - } - - boolean isCategoryAnnotationPresent(Class clazz) { - return clazz != null - && category != null - && (clazz.getAnnotation(category) != null || isCategoryAnnotationPresent(clazz.getSuperclass())); - } -} diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java deleted file mode 100644 index 324eb876aa..0000000000 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import org.apache.maven.surefire.api.filter.NonAbstractClassFilter; -import org.apache.maven.surefire.api.util.ScannerFilter; -import org.apache.maven.surefire.common.junit4.JUnit4TestChecker; -import org.junit.experimental.runners.Enclosed; - -/** - * Looks for additional junit48-like features - * @author Geoff Denning - * @author Kristian Rosenvold - */ -public class JUnit48TestChecker implements ScannerFilter { - private final NonAbstractClassFilter nonAbstractClassFilter; - - private final JUnit4TestChecker jUnit4TestChecker; - - public JUnit48TestChecker(ClassLoader testClassLoader) { - this.jUnit4TestChecker = new JUnit4TestChecker(testClassLoader); - this.nonAbstractClassFilter = new NonAbstractClassFilter(); - } - - @Override - public boolean accept(Class testClass) { - return jUnit4TestChecker.accept(testClass) || isAbstractWithEnclosedRunner(testClass); - } - - @SuppressWarnings({"unchecked"}) - private boolean isAbstractWithEnclosedRunner(Class testClass) { - return jUnit4TestChecker.isRunWithPresentInClassLoader() - && isAbstract(testClass) - && isRunWithEnclosedRunner(testClass); - } - - private boolean isRunWithEnclosedRunner(Class testClass) { - @SuppressWarnings("unchecked") - org.junit.runner.RunWith runWithAnnotation = - (org.junit.runner.RunWith) testClass.getAnnotation(org.junit.runner.RunWith.class); - return (runWithAnnotation != null && Enclosed.class.equals(runWithAnnotation.value())); - } - - private boolean isAbstract(Class testClass) { - return !nonAbstractClassFilter.accept(testClass); - } -} diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/MethodFilter.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/MethodFilter.java deleted file mode 100644 index c2e6181c95..0000000000 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/MethodFilter.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import java.util.Collection; -import java.util.LinkedHashSet; - -import org.apache.maven.surefire.api.testset.ResolvedTest; -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -final class MethodFilter extends Filter { - private final CombinedCategoryFilter combinedFilter; - - MethodFilter(String requestString) { - this(new TestListResolver(requestString)); - } - - MethodFilter(TestListResolver testResolver) { - Collection includedFilters = new LinkedHashSet<>(); - Collection excludedFilters = new LinkedHashSet<>(); - for (ResolvedTest test : testResolver.getIncludedPatterns()) { - includedFilters.add(new RequestedTest(test, true)); - } - for (ResolvedTest test : testResolver.getExcludedPatterns()) { - excludedFilters.add(new RequestedTest(test, false)); - } - combinedFilter = new CombinedCategoryFilter(includedFilters, excludedFilters); - } - - @Override - public boolean shouldRun(Description description) { - if (description.isEmpty()) { - return false; - } else if (description.isTest()) { - return combinedFilter.shouldRun(description); - } else { - for (Description o : description.getChildren()) { - if (combinedFilter.shouldRun(o) || shouldRun(o)) { - return true; - } - } - return false; - } - } - - @Override - public String describe() { - return combinedFilter.describe(); - } -} diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/OrFilter.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/OrFilter.java deleted file mode 100644 index b11528ae0f..0000000000 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/OrFilter.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -final class OrFilter extends Filter { - private final Filter[] filters; - - OrFilter(Filter[] filters) { - this.filters = filters; - } - - @Override - public boolean shouldRun(Description description) { - for (Filter filter : filters) { - if (filter.shouldRun(description)) { - return true; - } - } - return false; - } - - @Override - public String describe() { - StringBuilder description = new StringBuilder(); - for (int i = 0; i < filters.length; i++) { - description.append(filters[i].describe()); - if (i != filters.length - 1) { - description.append(" OR "); - } - } - return description.toString(); - } -} diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/RequestedTest.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/RequestedTest.java deleted file mode 100644 index e2f788691d..0000000000 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/RequestedTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import org.apache.maven.surefire.api.testset.ResolvedTest; -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -final class RequestedTest extends Filter { - private static final String CLASS_FILE_EXTENSION = ".class"; - - private final ResolvedTest test; - private final boolean isPositiveFilter; - - RequestedTest(ResolvedTest test, boolean isPositiveFilter) { - this.test = test; - this.isPositiveFilter = isPositiveFilter; - } - - @Override - public boolean shouldRun(Description description) { - Class realTestClass = description.getTestClass(); - String methodName = description.getMethodName(); - if (realTestClass == null && methodName == null) { - return true; - } else { - String testClass = classFile(realTestClass); - return isPositiveFilter - ? test.matchAsInclusive(testClass, methodName) - : !test.matchAsExclusive(testClass, methodName); - } - } - - @Override - public String describe() { - String description = test.toString(); - return description.isEmpty() ? "*" : description; - } - - @Override - public boolean equals(Object o) { - return this == o || o != null && getClass() == o.getClass() && equals((RequestedTest) o); - } - - private boolean equals(RequestedTest o) { - return isPositiveFilter == o.isPositiveFilter && test.equals(o.test); - } - - @Override - public int hashCode() { - return test.hashCode(); - } - - private String classFile(Class realTestClass) { - return realTestClass == null ? null : realTestClass.getName().replace('.', '/') + CLASS_FILE_EXTENSION; - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/FilterFactoryTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/FilterFactoryTest.java deleted file mode 100644 index ddb772ae68..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/FilterFactoryTest.java +++ /dev/null @@ -1,981 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import java.io.File; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; - -import org.apache.maven.surefire.api.testset.ResolvedTest; -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.apache.maven.surefire.common.junit48.tests.pt.PT; -import org.apache.maven.surefire.shared.utils.io.MatchPatterns; -import org.junit.Test; -import org.junit.runner.Description; -import org.junit.runner.JUnitCore; -import org.junit.runner.Request; -import org.junit.runner.Result; -import org.junit.runner.RunWith; -import org.junit.runner.manipulation.Filter; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.runner.Description.createSuiteDescription; -import static org.junit.runner.Description.createTestDescription; - -/** - * - */ -@SuppressWarnings("checkstyle:constantname") -public class FilterFactoryTest { - /** - * - */ - @RunWith(org.junit.runners.Suite.class) - @org.junit.runners.Suite.SuiteClasses({FirstClass.class, SecondClass.class}) - public static class Suite {} - - /** - * - */ - public static class FirstClass { - @Test - public void testMethod() { - // System.out.println( "FirstClass#testMethod" ); - } - - @Test - public void secondTestMethod() { - // System.out.println( "FirstClass#secondTestMethod" ); - } - - @Test - public void otherMethod() { - // System.out.println( "FirstClass#otherMethod" ); - } - } - - /** - * - */ - public static class SecondClass { - @Test - public void testMethod() { - // System.out.println( "SecondClass#testMethod" ); - } - - @Test - public void secondTestMethod() { - // System.out.println( "SecondClass#secondTestMethod" ); - } - } - - /** - * - */ - public static class ThirdClass { - @Test - public void testMethod() { - // System.out.println( "ThirdClass#testMethod" ); - } - - @Test - public void secondTestMethod() { - // System.out.println( "ThirdClass#secondTestMethod" ); - } - } - - private static final Description testMethod = createTestDescription(FirstClass.class, "testMethod"); - - private static final Description secondTestMethod = createTestDescription(FirstClass.class, "secondTestMethod"); - - private static final Description otherMethod = createTestDescription(FirstClass.class, "otherMethod"); - - private static final Description testMethodInSecondClass = createTestDescription(SecondClass.class, "testMethod"); - - private static final Description secondTestMethodInSecondClass = - createTestDescription(SecondClass.class, "secondTestMethod"); - - private static final String firstClassName = FirstClass.class.getName().replace('.', '/'); - - private static final String secondClassName = SecondClass.class.getName().replace('.', '/'); - - private static final String firstClassRegex = FirstClass.class.getName().replace("$", "\\$"); - - private static final String secondClassRegex = SecondClass.class.getName().replace("$", "\\$"); - - private Filter createMethodFilter(String requestString) { - return new FilterFactory(getClass().getClassLoader()).createMethodFilter(requestString); - } - - @Test - public void testSanity() { - ResolvedTest test = new ResolvedTest(ResolvedTest.Type.CLASS, " \t \n ", true); - assertNull(test.getTestClassPattern()); - assertNull(test.getTestMethodPattern()); - assertFalse(test.hasTestClassPattern()); - assertFalse(test.hasTestMethodPattern()); - assertTrue(test.isEmpty()); - assertTrue(test.isRegexTestClassPattern()); - assertFalse(test.isRegexTestMethodPattern()); - test = new ResolvedTest(ResolvedTest.Type.METHOD, " \n \t ", true); - assertNull(test.getTestClassPattern()); - assertNull(test.getTestMethodPattern()); - assertFalse(test.hasTestClassPattern()); - assertFalse(test.hasTestMethodPattern()); - assertTrue(test.isEmpty()); - assertFalse(test.isRegexTestClassPattern()); - assertTrue(test.isRegexTestMethodPattern()); - test = new ResolvedTest(ResolvedTest.Type.METHOD, " \n ", false); - assertNull(test.getTestClassPattern()); - assertNull(test.getTestMethodPattern()); - assertFalse(test.hasTestClassPattern()); - assertFalse(test.hasTestMethodPattern()); - assertTrue(test.isEmpty()); - assertFalse(test.isRegexTestClassPattern()); - assertFalse(test.isRegexTestMethodPattern()); - test = new ResolvedTest(" \n \t ", " \n \t ", false); - assertNull(test.getTestClassPattern()); - assertNull(test.getTestMethodPattern()); - assertFalse(test.hasTestClassPattern()); - assertFalse(test.hasTestMethodPattern()); - assertTrue(test.isEmpty()); - assertFalse(test.isRegexTestClassPattern()); - assertFalse(test.isRegexTestMethodPattern()); - } - - @Test - public void testNegativeIllegalRegex() { - try { - new TestListResolver("#%regex[.*.Test.class]"); - } catch (IllegalArgumentException e) { - // expected in junit 3.x - } - } - - @Test - public void testNegativeIllegalRegex2() { - try { - new TestListResolver("%regex[.*.Test.class]#"); - } catch (IllegalArgumentException e) { - // expected in junit 3.x - } - } - - @Test - public void testNegativeEmptyRegex() { - TestListResolver resolver = new TestListResolver("%regex[ ]"); - assertTrue(resolver.getExcludedPatterns().isEmpty()); - assertTrue(resolver.getIncludedPatterns().isEmpty()); - assertTrue(resolver.isEmpty()); - assertEquals(0, resolver.getPluginParameterTest().length()); - assertFalse(resolver.hasExcludedMethodPatterns()); - assertFalse(resolver.hasIncludedMethodPatterns()); - assertFalse(resolver.hasMethodPatterns()); - } - - @Test - public void testNegativeEmptyRegexWithHash() { - TestListResolver resolver = new TestListResolver("%regex[# ]"); - assertTrue(resolver.getExcludedPatterns().isEmpty()); - assertTrue(resolver.getIncludedPatterns().isEmpty()); - assertTrue(resolver.isEmpty()); - assertEquals(0, resolver.getPluginParameterTest().length()); - assertFalse(resolver.hasExcludedMethodPatterns()); - assertFalse(resolver.hasIncludedMethodPatterns()); - assertFalse(resolver.hasMethodPatterns()); - } - - @Test - public void testNegativeRegexWithEmptyMethod() { - TestListResolver resolver = new TestListResolver("%regex[.*.Test.class# ]"); - assertFalse(resolver.isEmpty()); - assertTrue(resolver.getExcludedPatterns().isEmpty()); - assertFalse(resolver.getIncludedPatterns().isEmpty()); - assertEquals(1, resolver.getIncludedPatterns().size()); - assertEquals("%regex[.*.Test.class]", resolver.getPluginParameterTest()); - assertFalse(resolver.hasExcludedMethodPatterns()); - assertFalse(resolver.hasIncludedMethodPatterns()); - assertFalse(resolver.hasMethodPatterns()); - } - - @Test - public void testBackwardsCompatibilityNullMethodFilter() { - Filter filter = createMethodFilter(null); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(5, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testBackwardsCompatibilityEmptyMethodFilter() { - Filter filter = createMethodFilter(""); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(5, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testBackwardsCompatibilityBlankMethodFilter() { - Filter filter = createMethodFilter(" \n"); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(5, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testBackwardsCompatibilityTestParameterClass() { - Filter filter = createMethodFilter(firstClassName); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testBackwardsCompatibilityTestParameterJavaClass() { - Filter filter = createMethodFilter(firstClassName + ".java"); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testBackwardsCompatibilityTestParameterMethod1() { - Filter filter = createMethodFilter(firstClassName + ".java#testMethod"); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(1, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testBackwardsCompatibilityTestParameterMethod2() { - Filter filter = createMethodFilter(firstClassName + "#testMethod"); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(1, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testBackwardsCompatibilityTestParameterMethod3() { - Filter filter = createMethodFilter(firstClassName + "#testMethod"); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(1, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithWildcard() { - Filter filter = createMethodFilter("%regex[" + firstClassRegex + ".*]"); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithWildcardClass() { - Filter filter = createMethodFilter("%regex[" + firstClassRegex + ".*.class]"); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithExactClass() { - Filter filter = createMethodFilter("%regex[" + firstClassRegex + ".class]"); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithWildcardJavaClassNegativeTest() { - Filter filter = createMethodFilter("%regex[" + firstClassRegex + ".*.class]"); - JUnitCore core = new JUnitCore(); - Result result = - core.run(Request.classes(FirstClass.class, SecondClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithTwoClasses() { - Filter filter = createMethodFilter("%regex[" + firstClassRegex + ".*|" + secondClassRegex + ".*]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(5, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithTwoClassesComplement() { - Filter filter = createMethodFilter("!%regex[" + firstClassRegex + ".*|" + secondClassRegex + ".*]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(2, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithTwoClassesAndOneMethod() { - Filter filter = - createMethodFilter("%regex[" + firstClassRegex + ".*|" + secondClassRegex + ".* # otherMethod]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(1, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithTwoClassesAndOneMethodComplement() { - Filter filter = - createMethodFilter("!%regex[" + firstClassRegex + ".*|" + secondClassRegex + ".*# otherMethod]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(6, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithTwoClassesAndWildcardMethod() { - Filter filter = createMethodFilter("%regex[" + firstClassRegex + ".*|" + secondClassRegex + ".*#test.* ]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(2, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithTwoClassesAndRegexMethodComplement() { - Filter filter = createMethodFilter("!%regex[" + firstClassRegex + ".*|" + secondClassRegex + ".*#test.*]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(5, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithTwoClassesAndRegexMethods() { - Filter filter = - createMethodFilter("%regex[ " + firstClassRegex + ".*|" + secondClassRegex + ".* # test.*|other.* ]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testRegexWithTwoClassesAndRegexMethodsComplement() { - Filter filter = - createMethodFilter("!%regex[" + firstClassRegex + ".*|" + secondClassRegex + ".* # test.*|other.* ]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(4, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleRegexClasses() { - Filter filter = createMethodFilter("%regex[" + firstClassRegex + ".*], %regex[" + secondClassRegex + ".*]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(5, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleRegexClassesComplement() { - Filter filter = createMethodFilter("!%regex[" + firstClassRegex + ".*] , !%regex[" + secondClassRegex + ".*]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(2, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleClasses() { - Filter filter = createMethodFilter(firstClassName + "," + secondClassName); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(5, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleClassesMethods() { - Filter filter = createMethodFilter(firstClassName + "#other*," + secondClassName + "#*TestMethod"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(2, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleClassesAndMultipleMethodsWithWildcards() { - Filter filter = - createMethodFilter(firstClassName + "#other*+second*Method," + secondClassName + "#*TestMethod"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleClassesAndMultipleMethodsWithRegex() { - Filter filter = createMethodFilter("%regex[" + firstClassRegex + ".class#other.*|second.*Method]," + "%regex[" - + secondClassRegex + ".class#.*TestMethod]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleClassesAndMultipleMethodsMix() { - Filter filter = createMethodFilter( - "%regex[" + firstClassRegex + ".class # other.*|second.*Method]," + secondClassName + "#*TestMethod"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleClassesAndMultipleMethods() { - Filter filter = - createMethodFilter(firstClassName + "#other*+secondTestMethod," + secondClassName + "#*TestMethod"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleClassesComplement() { - Filter filter = createMethodFilter("!" + firstClassName + ",!" + secondClassName); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(2, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleRegexClassesMethods() { - Filter filter = createMethodFilter( - "%regex[" + firstClassRegex + ".* # test.*|other.*]," + "%regex[" + secondClassRegex + ".*#second.*]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(3, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testMultipleRegexClassesMethodsComplement() { - Filter filter = createMethodFilter("!%regex[" + firstClassRegex + ".* # test.*|other.*]," + "!%regex[" - + secondClassRegex + ".*#second.*]"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class, SecondClass.class, ThirdClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(4, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testShouldMatchExactMethodName() { - Filter exactFilter = createMethodFilter("#testMethod"); - assertTrue("exact match on name should run", exactFilter.shouldRun(testMethod)); - } - - @Test - public void testShouldMatchExactMethodNameComplement() { - Filter exactFilter = createMethodFilter("!#testMethod"); - assertFalse("should not run testMethod", exactFilter.shouldRun(testMethod)); - assertTrue("should run other than testMethod", exactFilter.shouldRun(secondTestMethod)); - assertFalse("should not run testMethod", exactFilter.shouldRun(testMethodInSecondClass)); - assertTrue("should run other than testMethod", exactFilter.shouldRun(secondTestMethodInSecondClass)); - - exactFilter = createMethodFilter("!FilterFactoryTest$FirstClass#testMethod"); - assertFalse("should not run testMethod", exactFilter.shouldRun(testMethod)); - assertTrue("should run other than testMethod", exactFilter.shouldRun(secondTestMethod)); - assertTrue("should not run testMethod", exactFilter.shouldRun(testMethodInSecondClass)); - assertTrue("should run other than testMethod", exactFilter.shouldRun(secondTestMethodInSecondClass)); - - exactFilter = createMethodFilter( - "!FilterFactoryTest$FirstClass#testMethod, !FilterFactoryTest$SecondClass#testMethod"); - assertFalse("should not run testMethod", exactFilter.shouldRun(testMethod)); - assertTrue("should run other than testMethod", exactFilter.shouldRun(secondTestMethod)); - assertFalse("should not run testMethod", exactFilter.shouldRun(testMethodInSecondClass)); - assertTrue("should run other than testMethod", exactFilter.shouldRun(secondTestMethodInSecondClass)); - } - - @Test - public void testShouldMatchExactMethodNameWithHash() { - final Filter exactFilter = createMethodFilter("#testMethod"); - assertTrue("exact match on name should run", exactFilter.shouldRun(testMethod)); - } - - @Test - public void testShouldRunSuiteWithIncludedMethod() { - String sourceFile = "pkg" + File.separator + "XMyTest.class"; - assertTrue(new TestListResolver("#testMethod").shouldRun(sourceFile, null)); - } - - @Test - public void testShouldNotRunDifferentMethods() { - final Filter exactFilter = createMethodFilter("#testMethod"); - Description testCase = createSuiteDescription(FirstClass.class); - testCase.addChild(otherMethod); - assertFalse("exact match test case", exactFilter.shouldRun(testCase)); - } - - @Test - public void testShouldNotRunExactMethodWithoutClass() { - Filter exactFilter = createMethodFilter("#testMethod"); - assertFalse("should run containing matching method", exactFilter.shouldRun(secondTestMethod)); - } - - @Test - public void testShouldNotMatchExactOnOtherMethod() { - Filter exactFilter = createMethodFilter("#testMethod"); - assertFalse("should not run other methods", exactFilter.shouldRun(otherMethod)); - } - - @Test - public void testShouldMatchWildCardsInMethodName() { - Filter starAtEnd = createMethodFilter("#test*"); - assertTrue("match ending with star should run", starAtEnd.shouldRun(testMethod)); - - Filter starAtBeginning = createMethodFilter("#*Method"); - assertTrue("match starting with star should run", starAtBeginning.shouldRun(testMethod)); - - Filter starInMiddle = createMethodFilter("#test*thod"); - assertTrue("match containing star should run", starInMiddle.shouldRun(testMethod)); - - Filter questionAtEnd = createMethodFilter("#testMetho?"); - assertTrue("match ending with question mark should run", questionAtEnd.shouldRun(testMethod)); - - Filter questionAtBeginning = createMethodFilter("#????Method"); - assertTrue("match starting with question mark should run", questionAtBeginning.shouldRun(testMethod)); - - Filter questionInMiddle = createMethodFilter("#testM?thod"); - assertTrue("match containing question mark should run", questionInMiddle.shouldRun(testMethod)); - - Filter starAndQuestion = createMethodFilter("#t?st*thod"); - assertTrue("match containing star and question mark should run", starAndQuestion.shouldRun(testMethod)); - } - - @Test - public void testShouldMatchExactClassAndMethod() { - Filter exactFilter = createMethodFilter(firstClassName + "#testMethod"); - assertTrue("exact match on name should run", exactFilter.shouldRun(testMethod)); - } - - @Test - public void testShouldMatchSimpleClassNameWithMethod() { - Filter exactFilter = createMethodFilter("FilterFactoryTest$FirstClass#testMethod"); - assertTrue("exact match on name should run", exactFilter.shouldRun(testMethod)); - assertFalse("other method should not match", exactFilter.shouldRun(otherMethod)); - } - - @Test - public void testShouldMatchNestedClassAsRegexWithMethod() { - Filter exactFilter = - createMethodFilter("%regex[.*.common.junit48.FilterFactoryTest\\$FirstClass.class#testMethod]"); - assertTrue("exact match on name should run", exactFilter.shouldRun(testMethod)); - assertFalse("other method should not match", exactFilter.shouldRun(otherMethod)); - } - - @Test - public void testShouldMatchNestedCanonicalClassAsRegexWithMethod() { - Filter exactFilter = - createMethodFilter("%regex[.*.common.junit48.FilterFactoryTest.FirstClass.class#testMethod]"); - assertTrue("exact match on name should run", exactFilter.shouldRun(testMethod)); - assertFalse("other method should not match", exactFilter.shouldRun(otherMethod)); - } - - @Test - public void testShouldMatchClassNameWithWildcardAndMethod() { - Filter exactFilter = createMethodFilter("*First*#testMethod"); - assertTrue("exact match on name should run", exactFilter.shouldRun(testMethod)); - assertFalse("other method should not match", exactFilter.shouldRun(otherMethod)); - } - - @Test - public void testShouldMatchClassNameWithWildcardCompletely() { - Filter exactFilter = createMethodFilter("First*#testMethod"); - assertFalse("other method should not match", exactFilter.shouldRun(testMethod)); - assertFalse("other method should not match", exactFilter.shouldRun(otherMethod)); - } - - @Test - public void testShouldMatchMultipleMethodsSeparatedByComma() { - Filter exactFilter = createMethodFilter(firstClassName + "#testMethod,#secondTestMethod"); - - assertTrue("exact match on name should run", exactFilter.shouldRun(testMethod)); - assertTrue("exact match on name should run", exactFilter.shouldRun(secondTestMethod)); - assertTrue("exact match on name should run", exactFilter.shouldRun(secondTestMethodInSecondClass)); - - assertFalse("other method should not match", exactFilter.shouldRun(otherMethod)); - } - - @Test - public void testShouldMatchMultipleMethodsInSameClassSeparatedByPlus() { - Filter exactFilter = createMethodFilter(firstClassName + "#testMethod+secondTestMethod"); - - assertTrue("exact match on name should run", exactFilter.shouldRun(testMethod)); - assertTrue("exact match on name should run", exactFilter.shouldRun(secondTestMethod)); - - assertFalse("method in another class should not match", exactFilter.shouldRun(secondTestMethodInSecondClass)); - - assertFalse("other method should not match", exactFilter.shouldRun(otherMethod)); - } - - @Test - public void testShouldRunCompleteClassWhenSeparatedByCommaWithoutHash() { - Filter exactFilter = createMethodFilter(firstClassName + "#testMethod," + secondClassName); - - assertTrue("exact match on name should run", exactFilter.shouldRun(testMethod)); - - assertFalse("other method should not match", exactFilter.shouldRun(secondTestMethod)); - assertFalse("other method should not match", exactFilter.shouldRun(otherMethod)); - - assertTrue("should run complete second class", exactFilter.shouldRun(testMethodInSecondClass)); - assertTrue("should run complete second class", exactFilter.shouldRun(secondTestMethodInSecondClass)); - } - - @Test - public void testShouldRunSuitesContainingExactMethodName() { - Description suite = Description.createSuiteDescription(Suite.class); - suite.addChild(testMethod); - suite.addChild(secondTestMethod); - - Filter exactFilter = createMethodFilter("#testMethod"); - assertTrue("should run suites containing matching method", exactFilter.shouldRun(suite)); - } - - @Test - public void testShouldSkipSuitesNotContainingExactMethodName() { - Filter exactFilter = createMethodFilter("#otherMethod"); - assertFalse("should not run method", exactFilter.shouldRun(testMethod)); - assertFalse("should not run method", exactFilter.shouldRun(secondTestMethod)); - Description suite = Description.createSuiteDescription(Suite.class); - suite.addChild(testMethod); - suite.addChild(secondTestMethod); - assertFalse("should not run suites containing no matches", exactFilter.shouldRun(suite)); - } - - @Test - public void testSingleMethodWithJUnitCoreSuite() { - Filter filter = createMethodFilter("#testMethod"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(Suite.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(2, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testShouldNotRunNonExistingMethodJUnitCoreSuite() { - Filter filter = createMethodFilter("#nonExisting"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(Suite.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(0, result.getRunCount()); // running the Suite - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testShouldRunNonExistingMethodJUnitCoreSuite() { - Filter filter = createMethodFilter("!#nonExisting"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(Suite.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(5, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testClassAndMethodJUnitCoreSuite() { - Filter filter = createMethodFilter("FilterFactoryTest$FirstClass#testMethod"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(Suite.class, FirstClass.class, SecondClass.class) - .filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(2, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testSingleMethodWithJUnitCoreFirstClass() { - Filter filter = createMethodFilter("#testMethod"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(1, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testWithJUnitCoreFirstClassAndSingleMethod() { - Filter filter = createMethodFilter("FilterFactoryTest$FirstClass#testMethod"); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(FirstClass.class).filterWith(filter)); - assertTrue(result.wasSuccessful()); - assertEquals(1, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testShouldRunSuite() { - TestListResolver filter = new TestListResolver("Su?te"); - filter = TestListResolver.optionallyWildcardFilter(filter); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(Suite.class).filterWith(new MethodFilter(filter))); - assertTrue(result.wasSuccessful()); - assertEquals(5, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testShouldRunParameterized() { - TestListResolver filter = new TestListResolver("#testAA[?]+testB?[?], " - + "PT#testC*, " - + "!PT.java#testCY[?]," - + "%regex[.*.tests.pt.PT.class#w.*|x.*T.*]"); - filter = TestListResolver.optionallyWildcardFilter(filter); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(PT.class).filterWith(new MethodFilter(filter))); - assertTrue(result.wasSuccessful()); - assertEquals(12, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testShouldRunParameterizedWithPlusDelimiter() { - // Running parameterized tests: w12T34, x12T34 and x12T35. - // Two parameters "x" and "y" in the test case PT.java change the method descriptions to the following ones: - // w12T34[0], w12T34[1] - // x12T34[0], x12T34[1] - // x12T35[0], x12T35[1] - TestListResolver filter = new TestListResolver("%regex[.*.PT.* # w.*|x(\\d+)T(\\d+)\\[(\\d+)\\]]"); - filter = TestListResolver.optionallyWildcardFilter(filter); - JUnitCore core = new JUnitCore(); - Result result = core.run(Request.classes(PT.class).filterWith(new MethodFilter(filter))); - assertTrue(result.wasSuccessful()); - assertEquals(6, result.getRunCount()); - assertEquals(0, result.getFailureCount()); - assertEquals(0, result.getIgnoreCount()); - } - - @Test - public void testTestListResolver() { - assertFalse(new TestListResolver("b/ATest.java").shouldRun("tests/a/ATest.class", null)); - assertFalse(new TestListResolver("b/Test.java").shouldRun("a/ATest.class", null)); - assertTrue(new TestListResolver("ATest.java").shouldRun("tests/a/ATest.class", null)); - assertTrue(new TestListResolver("a/ATest.java").shouldRun("a/ATest.class", null)); - assertTrue(new TestListResolver("**/ATest.java").shouldRun("a/ATest.class", null)); - Class testsATest = org.apache.maven.surefire.common.junit48.tests.ATest.class; - Class aTest = org.apache.maven.surefire.common.junit48.tests.a.ATest.class; - assertFalse(new TestListResolver("b/ATest.java").shouldRun(testsATest, null)); - assertFalse(new TestListResolver("b/ATest.java").shouldRun(aTest, null)); - assertTrue(new TestListResolver("ATest.java").shouldRun(testsATest, null)); - assertTrue(new TestListResolver("a/ATest.java").shouldRun(aTest, null)); - assertTrue(new TestListResolver("**/ATest.java").shouldRun(aTest, null)); - } - - @Test - public void testShouldRunClassOnly() { - Class testsATest = org.apache.maven.surefire.common.junit48.tests.ATest.class; - TestListResolver resolver = new TestListResolver("**/ATest.java#testSuccessTwo"); - assertTrue(resolver.shouldRun(testsATest, null)); - resolver = new TestListResolver("**/BTest.java#testSuccessTwo"); - assertFalse(resolver.shouldRun(testsATest, null)); - } - - @Test - public void testMatchPatterns() { - String sourceFile = "pkg" + File.separator + "MyTest.class"; - boolean matchPattern = - MatchPatterns.from("**" + File.separator + "MyTest.class").matches(sourceFile, true); - assertTrue(matchPattern); - - matchPattern = MatchPatterns.from("MyTest.class").matches(sourceFile, true); - assertFalse(matchPattern); - - matchPattern = MatchPatterns.from("MyTest.class").matches("MyTest.class", true); - assertTrue(matchPattern); - - matchPattern = - MatchPatterns.from("**" + File.separator + "MyTest.class").matches("MyTest.class", true); - assertTrue(matchPattern); - } - - @Test - public void testNegativePatternOnPackageLessClass() { - String sourceFile = "pkg" + File.separator + "XMyTest.class"; - assertFalse(new TestListResolver("**/MyTest.java").shouldRun(sourceFile, null)); - assertFalse(new TestListResolver("MyTest.java").shouldRun(sourceFile, null)); - assertFalse(new TestListResolver("MyTest.java").shouldRun("XMyTest.class", null)); - assertFalse(new TestListResolver("**/MyTest.java").shouldRun("XMyTest.class", null)); - } - - @Test - public void testPatternOnPackageLessClass() { - String sourceFile = "pkg" + File.separator + "MyTest.class"; - assertTrue(new TestListResolver("**/MyTest.java").shouldRun(sourceFile, null)); - assertTrue(new TestListResolver("MyTest.java").shouldRun(sourceFile, null)); - assertTrue(new TestListResolver("MyTest.java").shouldRun("MyTest.class", null)); - assertTrue(new TestListResolver("**/MyTest.java").shouldRun("MyTest.class", null)); - } - - @Test - public void testIncludesExcludes() { - Collection inc = Arrays.asList("**/NotIncludedByDefault.java", "**/*Test.java"); - Collection exc = Collections.singletonList("**/DontRunTest.*"); - TestListResolver resolver = new TestListResolver(inc, exc); - assertFalse(resolver.shouldRun("org/test/DontRunTest.class", null)); - assertTrue(resolver.shouldRun("org/test/DefaultTest.class", null)); - assertTrue(resolver.shouldRun("org/test/NotIncludedByDefault.class", null)); - } - - @Test - public void testSimple() { - TestListResolver resolver = new TestListResolver("NotIncludedByDefault"); - assertTrue(resolver.shouldRun("org/test/NotIncludedByDefault.class", null)); - } - - @Test - public void testFullyQualifiedClass() { - TestListResolver resolver = new TestListResolver("my.package.MyTest"); - assertFalse(resolver.shouldRun("my/package/AnotherTest.class", null)); - assertTrue(resolver.shouldRun("my/package/MyTest.class", null)); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterPreJUnit412Test.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterPreJUnit412Test.java deleted file mode 100644 index b2260048fe..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterPreJUnit412Test.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import junit.framework.JUnit4TestAdapter; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.runner.Version; -import org.apache.maven.surefire.common.junit48.tests.group.ABCParameterizedTest; -import org.apache.maven.surefire.common.junit48.tests.group.ABCTest; -import org.apache.maven.surefire.common.junit48.tests.group.ATest; -import org.apache.maven.surefire.common.junit48.tests.group.BCTest; -import org.apache.maven.surefire.group.match.GroupMatcher; -import org.apache.maven.surefire.group.match.SingleGroupMatcher; -import org.junit.BeforeClass; -import org.junit.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.runner.Description.createSuiteDescription; -import static org.junit.runner.Description.createTestDescription; - -/** - * Before JUnit 4.12, @Category annotation was not @Inherited. These tests make sure the implied contract is honored. - */ -public class GroupMatcherCategoryFilterPreJUnit412Test { - private GroupMatcherCategoryFilter cut; - - @BeforeClass - public static void printVersion() { - System.out.println(Version.id()); - } - - @Test - public void shouldNotMatchIncludedCategoryInParent() { - GroupMatcher included = - new SingleGroupMatcher("org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB"); - GroupMatcher excluded = null; - cut = new GroupMatcherCategoryFilter(included, excluded); - assertFalse(cut.shouldRun(createSuiteDescription(BCTest.class))); - assertFalse(cut.shouldRun(createSuiteDescription(ATest.class))); - } - - @Test - public void shouldNotMatchIncludedCategoryInHierarchy() { - GroupMatcher included = - new SingleGroupMatcher("org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryC"); - GroupMatcher excluded = null; - cut = new GroupMatcherCategoryFilter(included, excluded); - assertFalse(cut.shouldRun(createSuiteDescription(ABCTest.class))); - assertFalse(cut.shouldRun(createSuiteDescription(BCTest.class))); - assertFalse(cut.shouldRun(createSuiteDescription(ATest.class))); - } - - @Test - public void shouldNotMatchIncludedCategoryInParentWhenSelfHasAnother() { - GroupMatcher included = - new SingleGroupMatcher("org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB"); - GroupMatcher excluded = null; - cut = new GroupMatcherCategoryFilter(included, excluded); - assertFalse(cut.shouldRun(createSuiteDescription(ABCTest.class))); - assertFalse(cut.shouldRun(createTestDescription(ABCTest.class, "abc"))); - assertFalse(cut.shouldRun(createSuiteDescription(ABCParameterizedTest.class))); - assertFalse(cut.shouldRun(createTestDescription(ABCParameterizedTest.class, "abc"))); - } - - /** - * - */ - public static class JUnit4SuiteTest extends TestCase { - public static junit.framework.Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(new JUnit4TestAdapter(GroupMatcherCategoryFilterPreJUnit412Test.class)); - return suite; - } - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterTest.java deleted file mode 100644 index e76ec17d74..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import junit.framework.JUnit4TestAdapter; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.runner.Version; -import org.apache.maven.surefire.common.junit48.tests.group.ABCParameterizedTest; -import org.apache.maven.surefire.common.junit48.tests.group.ABCTest; -import org.apache.maven.surefire.common.junit48.tests.group.ATest; -import org.apache.maven.surefire.common.junit48.tests.group.BBCTest; -import org.apache.maven.surefire.common.junit48.tests.group.BCTest; -import org.apache.maven.surefire.common.junit48.tests.group.BTest; -import org.apache.maven.surefire.group.match.GroupMatcher; -import org.apache.maven.surefire.group.match.SingleGroupMatcher; -import org.junit.BeforeClass; -import org.junit.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.runner.Description.createSuiteDescription; -import static org.junit.runner.Description.createTestDescription; - -/** - * Tests covering inheritance in @Categories for Test classes. - */ -public class GroupMatcherCategoryFilterTest { - private GroupMatcherCategoryFilter cut; - - @BeforeClass - public static void printVersion() { - System.out.println(Version.id()); - } - - @Test - public void shouldMatchIncludedCategoryInSelf() { - GroupMatcher included = - new SingleGroupMatcher("org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB"); - GroupMatcher excluded = null; - cut = new GroupMatcherCategoryFilter(included, excluded); - assertTrue(cut.shouldRun(createSuiteDescription(BTest.class))); - } - - @Test - public void shouldMatchIncludedCategoryInParent() { - GroupMatcher included = - new SingleGroupMatcher("org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB"); - GroupMatcher excluded = null; - cut = new GroupMatcherCategoryFilter(included, excluded); - assertTrue(cut.shouldRun(createSuiteDescription(BCTest.class))); - assertFalse(cut.shouldRun(createSuiteDescription(ATest.class))); - } - - @Test - public void shouldMatchIncludedCategoryInHierarchy() { - GroupMatcher included = - new SingleGroupMatcher("org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryC"); - GroupMatcher excluded = null; - cut = new GroupMatcherCategoryFilter(included, excluded); - assertTrue(cut.shouldRun(createSuiteDescription(ABCTest.class))); - assertTrue(cut.shouldRun(createSuiteDescription(BCTest.class))); - assertFalse(cut.shouldRun(createSuiteDescription(ATest.class))); - } - - @Test - public void shouldMatchIncludedCategoryInParentWhenSelfHasAnother() { - GroupMatcher included = - new SingleGroupMatcher("org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB"); - GroupMatcher excluded = null; - cut = new GroupMatcherCategoryFilter(included, excluded); - assertTrue(cut.shouldRun(createSuiteDescription(ABCTest.class))); - assertTrue(cut.shouldRun(createTestDescription(ABCTest.class, "abc"))); - assertTrue(cut.shouldRun(createSuiteDescription(ABCParameterizedTest.class))); - assertTrue(cut.shouldRun(createTestDescription(ABCParameterizedTest.class, "abc"))); - } - - @Test - public void shouldNotMatchIncludedCategoryInParentWhenSelfHasExcludedCategory() { - GroupMatcher included = - new SingleGroupMatcher("org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB"); - GroupMatcher excluded = - new SingleGroupMatcher("org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryA"); - cut = new GroupMatcherCategoryFilter(included, excluded); - assertFalse(cut.shouldRun(createSuiteDescription(ABCTest.class))); - assertTrue(cut.shouldRun(createSuiteDescription(BBCTest.class))); - assertTrue(cut.shouldRun(createSuiteDescription(BTest.class))); - } - - @Test - public void shouldMatchExcludedCategoryInSelf() { - GroupMatcher included = null; - GroupMatcher excluded = - new SingleGroupMatcher("org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryA"); - cut = new GroupMatcherCategoryFilter(included, excluded); - assertFalse(cut.shouldRun(createSuiteDescription(ATest.class))); - assertTrue(cut.shouldRun(createSuiteDescription(BTest.class))); - assertTrue(cut.shouldRun(createSuiteDescription(BBCTest.class))); - } - - /** - * - */ - public static class JUnit4SuiteTest extends TestCase { - public static junit.framework.Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(new JUnit4TestAdapter(GroupMatcherCategoryFilterTest.class)); - return suite; - } - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit48ReflectorTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit48ReflectorTest.java deleted file mode 100644 index 3515ff2d28..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit48ReflectorTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import junit.framework.TestCase; -import org.junit.experimental.categories.Category; - -/** - * @author Kristian Rosenvold - */ -public class JUnit48ReflectorTest extends TestCase { - public void testIsJUnit48Available() { - JUnit48Reflector jUnit48Reflector = new JUnit48Reflector(getClass().getClassLoader()); - assertTrue(jUnit48Reflector.isJUnit48Available()); - } - - public void testCategoryAnnotation() { - JUnit48Reflector jUnit48Reflector = new JUnit48Reflector(getClass().getClassLoader()); - assertTrue(jUnit48Reflector.isCategoryAnnotationPresent(Test1.class)); - assertTrue(jUnit48Reflector.isCategoryAnnotationPresent(Test3.class)); - assertFalse(jUnit48Reflector.isCategoryAnnotationPresent(Test2.class)); - } - - interface Foo {} - - @Category(Foo.class) - private class Test1 {} - - private class Test2 {} - - private class Test3 extends Test1 {} -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit48TestCheckerTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit48TestCheckerTest.java deleted file mode 100644 index d4f9800f0b..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit48TestCheckerTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * @author Kristian Rosenvold - */ -public class JUnit48TestCheckerTest { - @Test - public void valid48Class() { - JUnit48TestChecker tc = new JUnit48TestChecker(this.getClass().getClassLoader()); - assertTrue(tc.accept(BasicTest.class)); - } - - @Test - public void notValid48Class() { - JUnit48TestChecker tc = new JUnit48TestChecker(this.getClass().getClassLoader()); - assertFalse(tc.accept(BasicTest2.class)); - } - - /** - * - */ - @RunWith(Enclosed.class) - public abstract static class BasicTest { - /** - * - */ - public static class InnerTest { - @Test - public void testSomething() {} - } - } - - /** - * - */ - @RunWith(Parameterized.class) - public abstract static class BasicTest2 { - /** - * - */ - public static class InnerTest { - @Test - public void testSomething() {} - } - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit4SuiteTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit4SuiteTest.java deleted file mode 100644 index 1233d889b6..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit4SuiteTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.surefire.common.junit48; - -import junit.framework.JUnit4TestAdapter; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Adapt the JUnit4 tests which use only annotations to the JUnit3 test suite. - * - * @author Tibor Digana (tibor17) - * @since 2.19 - */ -public class JUnit4SuiteTest extends TestCase { - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTestSuite(JUnit48ReflectorTest.class); - suite.addTest(new JUnit4TestAdapter(JUnit48TestCheckerTest.class)); - suite.addTest(new JUnit4TestAdapter(FilterFactoryTest.class)); - return suite; - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/ATest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/ATest.java deleted file mode 100644 index 869f46606e..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/ATest.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.surefire.common.junit48.tests; - -/** - * - */ -public class ATest {} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/a/ATest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/a/ATest.java deleted file mode 100644 index ca1ac89cd1..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/a/ATest.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.a; - -/** - * - */ -public class ATest {} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ABCParameterizedTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ABCParameterizedTest.java deleted file mode 100644 index 235c3418f0..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ABCParameterizedTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group; - -import java.util.Arrays; -import java.util.List; - -import org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryA; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -/** - * ABCParameterizedTest. - */ -@Category(CategoryA.class) -@RunWith(Parameterized.class) -public class ABCParameterizedTest extends AbstractBCTest { - @Parameterized.Parameters - public static List data() { - return Arrays.asList(new Object[][] {{0}, {1}, {6}}); - } - - private int number; - - public ABCParameterizedTest(int number) { - this.number = number; - } - - @Test - public void abc() { - System.out.println("ABCTest#abc(" + number + ")"); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ABCTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ABCTest.java deleted file mode 100644 index 780b4c67cf..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ABCTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group; - -import org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryA; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * ABCTest. - */ -@Category(CategoryA.class) -public class ABCTest extends AbstractBCTest { - - @Test - public void abc() { - System.out.println("ABCTest#abc"); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ABMethodTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ABMethodTest.java deleted file mode 100644 index a4c693060a..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ABMethodTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group; - -import org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryA; -import org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * ABMethodTest. - */ -@Category(CategoryA.class) -public class ABMethodTest { - - @Test - public void a() { - System.out.println("ATest#a"); - } - - @Category(CategoryB.class) - @Test - public void b() { - System.out.println("ATest#b"); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ATest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ATest.java deleted file mode 100644 index ce3244b9ad..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/ATest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group; - -import org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryA; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * ATest. - */ -@Category(CategoryA.class) -public class ATest { - - @Test - public void a() { - System.out.println("ATest#a"); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/AbstractBCTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/AbstractBCTest.java deleted file mode 100644 index 2f01e69032..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/AbstractBCTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group; - -import org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * AbstractBCTest. - */ -@Category(CategoryB.class) -public abstract class AbstractBCTest extends AbstractCTest { - - @Test - public void pb() { - System.out.println("AbstractBCTest#pb"); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/AbstractCTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/AbstractCTest.java deleted file mode 100644 index 083dd0b47a..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/AbstractCTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group; - -import org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryC; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * AbstractCTest. - */ -@Category(CategoryC.class) -public abstract class AbstractCTest { - - @Test - public void pc() { - System.out.println("AbstractCTest#pc"); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/BBCTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/BBCTest.java deleted file mode 100644 index 452adc2a86..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/BBCTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group; - -import org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * BBCTest. - */ -@Category(CategoryB.class) -public class BBCTest extends AbstractBCTest { - - @Test - public void bbc() { - System.out.println("BBCTest#bbc"); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/BCTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/BCTest.java deleted file mode 100644 index ce687e6a6d..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/BCTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group; - -import org.junit.Test; - -/** - * BCTest. - */ -public class BCTest extends AbstractBCTest { - - @Test - public void bc() { - System.out.println("BCTest#bc"); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/BTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/BTest.java deleted file mode 100644 index b20f45dab1..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/BTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group; - -import org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * BTest. - */ -@Category(CategoryB.class) -public class BTest { - - @Test - public void b() { - System.out.println("BTest#b"); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/UncategorizedTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/UncategorizedTest.java deleted file mode 100644 index f1cdeaf029..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/UncategorizedTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group; - -import org.junit.Test; - -/** - * UncategorizedTest. - */ -public class UncategorizedTest { - - @Test - public void a() { - System.out.println("Uncategorized#a"); - } -} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/marker/CategoryA.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/marker/CategoryA.java deleted file mode 100644 index d88962c850..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/marker/CategoryA.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group.marker; - -/** - * CategoryA marker. - */ -public interface CategoryA {} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/marker/CategoryB.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/marker/CategoryB.java deleted file mode 100644 index f7ed686a93..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/marker/CategoryB.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group.marker; - -/** - * CategoryB marker. - */ -public interface CategoryB {} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/marker/CategoryC.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/marker/CategoryC.java deleted file mode 100644 index aaea9ac094..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/group/marker/CategoryC.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.group.marker; - -/** - * CategoryC marker. - */ -public interface CategoryC {} diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/pt/PT.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/pt/PT.java deleted file mode 100644 index 43a6897bab..0000000000 --- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/tests/pt/PT.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.surefire.common.junit48.tests.pt; - -import java.util.Arrays; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -/** - * - */ -@RunWith(Parameterized.class) -public class PT { - - public PT(String x) {} - - @Parameterized.Parameters - public static Iterable data() { - return Arrays.asList(new Object[][] {{"x"}, {"y"}}); - } - - @Test - public void testAA() {} - - @Test - public void testB5() {} - - @Test - public void testCX() {} - - @Test - public void testCY() {} - - @Test - public void w12T34() {} - - @Test - public void x12T34() {} - - @Test - public void x12T35() {} - - @Test - public void x12t36() {} - - @Test - public void y12t34() {} -} diff --git a/surefire-providers/pom.xml b/surefire-providers/pom.xml index ca44f999bf..cf710a3ad6 100644 --- a/surefire-providers/pom.xml +++ b/surefire-providers/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-providers @@ -33,16 +33,8 @@ Surefire Providers Aggregator POM - common-junit3 common-java5 - common-junit4 - common-junit48 - surefire-junit3 - surefire-junit4 - surefire-junit47 surefire-junit-platform - surefire-testng-utils - surefire-testng diff --git a/surefire-providers/surefire-junit-platform/pom.xml b/surefire-providers/surefire-junit-platform/pom.xml index e108957264..8d98e80c97 100644 --- a/surefire-providers/surefire-junit-platform/pom.xml +++ b/surefire-providers/surefire-junit-platform/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire-providers - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-junit-platform diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java index 1047d156da..1ae181e038 100644 --- a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java +++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java @@ -21,7 +21,10 @@ import java.io.IOException; import java.io.StringReader; import java.io.UncheckedIOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; @@ -31,8 +34,11 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; +import org.apache.maven.surefire.api.booter.ProviderParameterNames; import org.apache.maven.surefire.api.provider.AbstractProvider; import org.apache.maven.surefire.api.provider.CommandChainReader; import org.apache.maven.surefire.api.provider.ProviderParameters; @@ -46,25 +52,31 @@ import org.apache.maven.surefire.api.util.ScanResult; import org.apache.maven.surefire.api.util.TestsToRun; import org.apache.maven.surefire.shared.utils.StringUtils; +import org.apache.maven.surefire.shared.utils.io.SelectorUtils; import org.junit.platform.engine.DiscoverySelector; import org.junit.platform.engine.Filter; +import org.junit.platform.engine.FilterResult; +import org.junit.platform.engine.discovery.ClassNameFilter; +import org.junit.platform.engine.support.descriptor.ClassSource; +import org.junit.platform.engine.support.descriptor.MethodSource; import org.junit.platform.launcher.EngineFilter; import org.junit.platform.launcher.LauncherDiscoveryRequest; +import org.junit.platform.launcher.PostDiscoveryFilter; import org.junit.platform.launcher.TagFilter; import org.junit.platform.launcher.TestExecutionListener; import org.junit.platform.launcher.TestIdentifier; import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; import static java.util.Arrays.stream; -import static java.util.Collections.emptyMap; import static java.util.Optional.empty; import static java.util.Optional.of; import static java.util.logging.Level.WARNING; import static java.util.stream.Collectors.toList; +import static org.apache.maven.surefire.api.booter.ProviderParameterNames.EXCLUDEDGROUPS_PROP; import static org.apache.maven.surefire.api.booter.ProviderParameterNames.EXCLUDE_JUNIT5_ENGINES_PROP; +import static org.apache.maven.surefire.api.booter.ProviderParameterNames.GROUPS_PROP; import static org.apache.maven.surefire.api.booter.ProviderParameterNames.INCLUDE_JUNIT5_ENGINES_PROP; -import static org.apache.maven.surefire.api.booter.ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP; -import static org.apache.maven.surefire.api.booter.ProviderParameterNames.TESTNG_GROUPS_PROP; +import static org.apache.maven.surefire.api.booter.ProviderParameterNames.JUNIT_VINTAGE_DETECTED; import static org.apache.maven.surefire.api.report.ConsoleOutputCapture.startCapture; import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; import static org.apache.maven.surefire.api.report.RunMode.RERUN_TEST_AFTER_FAILURE; @@ -90,7 +102,7 @@ public class JUnitPlatformProvider extends AbstractProvider { private final Filter[] filters; - private final Map configurationParameters; + private Map configurationParameters = new HashMap<>(); private final CommandChainReader commandsReader; @@ -102,9 +114,36 @@ public JUnitPlatformProvider(ProviderParameters parameters) { this.parameters = parameters; this.launcherSessionFactory = launcherSessionFactory; filters = newFilters(); - configurationParameters = newConfigurationParameters(); + parameters.getProviderProperties().entrySet().stream() + .filter(entry -> entry.getKey().startsWith("junit.vintage.execution.parallel")) + .forEach(entry -> configurationParameters.put(entry.getKey(), entry.getValue())); + configurationParameters.putAll(newConfigurationParameters()); + // don't start a thread in CommandReader while we are in in-plugin process commandsReader = parameters.isInsideFork() ? parameters.getCommandReader() : null; + + parameters.getProviderProperties().entrySet().stream() + .filter(entry -> entry.getKey().startsWith("testng.")) + .forEach(entry -> configurationParameters.put(entry.getKey(), entry.getValue())); + // testng compatibility parameters + String groups = parameters.getProviderProperties().get(GROUPS_PROP); + if (groups != null) { + configurationParameters.put("testng.groups", groups); + } + + // configurationParameters.put("testng.useDefaultListeners", "true"); + + Optional.ofNullable(parameters.getProviderProperties().get("listener")) + .ifPresent(listener -> configurationParameters.put("testng.listeners", listener)); + + Optional.ofNullable(parameters.getProviderProperties().get("reporter")) + .ifPresent(reporter -> configurationParameters.compute( + "testng.listeners", (key, value) -> value == null ? reporter : value + "," + reporter)); + + String excludeGroups = parameters.getProviderProperties().get(EXCLUDEDGROUPS_PROP); + if (excludeGroups != null) { + configurationParameters.put("testng.excludedGroups", excludeGroups); + } } @Override @@ -223,15 +262,132 @@ private LauncherDiscoveryRequestBuilder newRequest() { return request().filters(filters).configurationParameters(configurationParameters); } + private boolean matchClassName(String className, String pattern) { + // pattern can be either fully qualified or simple class name or package + simple class name + #method + int hashIndex = pattern.indexOf('#'); + // we receive only -Dtest=#method (weird but possible) + if (hashIndex == 0) { + return true; + } + if (hashIndex != -1) { + pattern = pattern.substring(0, hashIndex); + } + boolean match = className.endsWith("." + pattern) || SelectorUtils.matchPath(pattern, className); + + if (className.contains(".")) { + String simpleName = className.substring(className.lastIndexOf('.') + 1); + match = match || SelectorUtils.matchPath(pattern, simpleName); + } + + if (pattern.contains("/")) { + String pkgStylePattern = pattern.replace('/', '.'); + match = match || SelectorUtils.matchPath(pkgStylePattern, className); + } + + return match; + } + private Filter[] newFilters() { List> filters = new ArrayList<>(); - getPropertiesList(TESTNG_GROUPS_PROP).map(TagFilter::includeTags).ifPresent(filters::add); + // includeClassNamePatterns support only regex patterns + Optional includesList = + Optional.ofNullable(parameters.getProviderProperties().get(ProviderParameterNames.INCLUDES_SCAN_LIST)); + if (includesList.isPresent()) { + String[] includesRegex = Stream.of(includesList.get().split(",")) + .filter(s -> s.startsWith("%regex[")) + .map(s -> StringUtils.replace(s, "%regex[", "")) + .map(s -> s.substring(0, s.length() - 1)) + .toArray(String[]::new); + if (includesRegex.length > 0) { + filters.add(ClassNameFilter.includeClassNamePatterns(includesRegex)); + } + } - getPropertiesList(TESTNG_EXCLUDEDGROUPS_PROP) - .map(TagFilter::excludeTags) - .ifPresent(filters::add); + // excludeClassNamePatterns support only regex patterns + Optional excludesList = + Optional.ofNullable(parameters.getProviderProperties().get(ProviderParameterNames.EXCLUDES_SCAN_LIST)); + if (excludesList.isPresent()) { + String[] excludesRegex = Stream.of(excludesList.get().split(",")) + .filter(s -> s.startsWith("%regex[")) + .map(s -> StringUtils.replace(s, "%regex[", "")) + .map(s -> s.substring(0, s.length() - 1)) + .toArray(String[]::new); + if (excludesRegex.length > 0) { + filters.add(ClassNameFilter.excludeClassNamePatterns(excludesRegex)); + } + } + + if (includesList.isPresent()) { + // usual include/exclude are scanner style patterns + List includes = Stream.of(includesList.get().split(",")) + .filter(s -> !s.startsWith("%regex[")) + .map(pattern -> StringUtils.replace(pattern, ".java", "")) + // .map(pattern -> StringUtils.replace(pattern, "/", ".")) + .collect(toList()); + if (!includes.isEmpty()) { + // use of CompositeFilter? + ClassNameFilter classNameFilter = clasName -> { + FilterResult result = includes.stream() + .map(pattern -> FilterResult.includedIf( + SelectorUtils.match(pattern, clasName) || matchClassName(clasName, pattern))) + .filter(FilterResult::included) + .findAny() + .orElse(FilterResult.excluded("Not included by any pattern: " + includes)); + return result; + }; + filters.add(classNameFilter); + } + } + + if (excludesList.isPresent()) { + + List excludes = Stream.of(excludesList.get().split(",")) + .filter(s -> !s.startsWith("%regex[")) + .map(pattern -> StringUtils.replace(pattern, ".java", "")) + // .map(pattern -> StringUtils.replace(pattern, "/", ".")) + .collect(toList()); + if (!excludes.isEmpty()) { + // use of CompositeFilter? + ClassNameFilter classNameFilter = className -> { + FilterResult result = excludes.stream() + .map(pattern -> { + boolean inclusive = SelectorUtils.match(pattern, className); + return !inclusive + ? FilterResult.included("Not excluded by pattern: " + pattern) + : FilterResult.excluded("Excluded by pattern: " + pattern); + }) + .filter(FilterResult::excluded) + .findAny() + .orElse(FilterResult.included("Not excluded by any pattern: " + excludes)); + return result; + }; + filters.add(classNameFilter); + } + } + boolean useTestNG = parameters.getProviderProperties().get("testng.version") != null; + + if (!Boolean.parseBoolean(parameters.getProviderProperties().get(JUNIT_VINTAGE_DETECTED)) && !useTestNG) { + getPropertiesList(GROUPS_PROP).map(TagFilter::includeTags).ifPresent(filters::add); + getPropertiesList(EXCLUDEDGROUPS_PROP).map(TagFilter::excludeTags).ifPresent(filters::add); + } else if (!useTestNG) { + Optional> categoryClass = getCategoryClass(); + if (categoryClass.isPresent()) { + getPropertiesList(GROUPS_PROP) + .map(strings -> getIncludeCategoryFilter(strings, categoryClass)) + .ifPresent(filters::add); + } + } + + if (!useTestNG) { + Optional> categoryClass = getCategoryClass(); + if (categoryClass.isPresent()) { + getPropertiesList(EXCLUDEDGROUPS_PROP) + .map(strings -> getExcludeCategoryFilter(strings, categoryClass)) + .ifPresent(filters::add); + } + } of(optionallyWildcardFilter(parameters.getTestRequest().getTestListResolver())) .filter(f -> !f.isEmpty()) .filter(f -> !f.isWildcard()) @@ -253,10 +409,127 @@ Filter[] getFilters() { return filters; } + PostDiscoveryFilter getIncludeCategoryFilter(List categories, Optional> categoryClass) { + + return testDescriptor -> { + Optional methodSource = testDescriptor + .getSource() + .filter(testSource -> testSource instanceof MethodSource) + .map(testSource -> (MethodSource) testSource); + boolean hasCategoryClass = false, hasCategoryMethod = false; + if (methodSource.isPresent()) { + if (categoryClass.isPresent()) { + hasCategoryMethod = hasCategoryAnnotation( + methodSource.get().getJavaMethod(), categoryClass.orElse(null), categories) + || hasCategoryAnnotation( + methodSource.get().getJavaClass(), categoryClass.orElse(null), categories); + } + } + + Optional classSource = testDescriptor + .getSource() + .filter(testSource -> testSource instanceof ClassSource) + .map(testSource -> (ClassSource) testSource); + if (classSource.isPresent()) { + if (categoryClass.isPresent()) { + hasCategoryClass = hasCategoryAnnotation( + classSource.get().getJavaClass(), categoryClass.orElse(null), categories); + } + } + + return hasCategoryClass || hasCategoryMethod + ? FilterResult.included("Category found") + : FilterResult.excluded("Does not have category annotation"); + }; + } + + PostDiscoveryFilter getExcludeCategoryFilter(List categories, Optional> categoryClass) { + + return testDescriptor -> { + Optional methodSource = testDescriptor + .getSource() + .filter(testSource -> testSource instanceof MethodSource) + .map(testSource -> (MethodSource) testSource); + boolean hasCategoryClass = false, hasCategoryMethod = false; + if (methodSource.isPresent()) { + if (categoryClass.isPresent()) { + hasCategoryMethod = hasCategoryAnnotation( + methodSource.get().getJavaMethod(), categoryClass.orElse(null), categories) + || hasCategoryAnnotation( + methodSource.get().getJavaClass(), categoryClass.orElse(null), categories); + } + } + + Optional classSource = testDescriptor + .getSource() + .filter(testSource -> testSource instanceof ClassSource) + .map(testSource -> (ClassSource) testSource); + if (classSource.isPresent()) { + if (categoryClass.isPresent()) { + hasCategoryClass = hasCategoryAnnotation( + classSource.get().getJavaClass(), categoryClass.orElse(null), categories); + } + } + + return hasCategoryClass || hasCategoryMethod + ? FilterResult.excluded("Does have exclude category annotation") + : FilterResult.included("Does not have category excluded found"); + }; + } + + private boolean hasCategoryAnnotation(Class clazz, Class categoryClass, List categories) { + Optional anno = stream(clazz.getAnnotations()) + .filter(annotation -> annotation.annotationType().equals(categoryClass)) + .findFirst(); + if (anno.isPresent()) { + List catValue = getCategoryValue(of(anno.get())); + return catValue.stream().anyMatch(categories::contains); + } + return false; + } + + private boolean hasCategoryAnnotation(Method method, Class categoryClass, List categories) { + Optional anno = stream(method.getAnnotations()) + .filter(annotation -> annotation.annotationType().equals(categoryClass)) + .findFirst(); + if (anno.isPresent()) { + List catValue = getCategoryValue(of(anno.get())); + return catValue.stream().anyMatch(categories::contains); + } + return false; + } + + private Optional> getCategoryClass() { + return getClass("org.junit.experimental.categories.Category"); + } + + private Optional> getClass(String className) { + Thread currentThread = Thread.currentThread(); + try { + return Optional.of(currentThread.getContextClassLoader().loadClass(className)); + } catch (Exception e) { + return Optional.empty(); + } + } + + private List getCategoryValue(Optional instance) { + Optional> optionalClass = getCategoryClass(); + if (optionalClass.isPresent()) { + try { + Class[] classes = + (Class[]) optionalClass.get().getMethod("value").invoke(instance.get()); + return stream(classes).map(Class::getName).collect(Collectors.toList()); + } catch (Exception e) { + // ignore + } + } + return Collections.emptyList(); + } + private Map newConfigurationParameters() { String content = parameters.getProviderProperties().get(CONFIGURATION_PARAMETERS); if (content == null) { - return emptyMap(); + return new HashMap<>(); } try (StringReader reader = new StringReader(content)) { Map result = new HashMap<>(); diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProviderTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProviderTest.java index fb7d44e933..6464aa153e 100644 --- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProviderTest.java +++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProviderTest.java @@ -67,10 +67,10 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static java.util.stream.Collectors.toSet; +import static org.apache.maven.surefire.api.booter.ProviderParameterNames.EXCLUDEDGROUPS_PROP; import static org.apache.maven.surefire.api.booter.ProviderParameterNames.EXCLUDE_JUNIT5_ENGINES_PROP; +import static org.apache.maven.surefire.api.booter.ProviderParameterNames.GROUPS_PROP; import static org.apache.maven.surefire.api.booter.ProviderParameterNames.INCLUDE_JUNIT5_ENGINES_PROP; -import static org.apache.maven.surefire.api.booter.ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP; -import static org.apache.maven.surefire.api.booter.ProviderParameterNames.TESTNG_GROUPS_PROP; import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -716,7 +716,7 @@ public void outputIsCaptured() throws Exception { @Test public void onlyGroupsIsDeclared() { - Map properties = singletonMap(TESTNG_GROUPS_PROP, "groupOne, groupTwo"); + Map properties = singletonMap(GROUPS_PROP, "groupOne, groupTwo"); ProviderParameters providerParameters = providerParametersMock(TestClass1.class); when(providerParameters.getProviderProperties()).thenReturn(properties); @@ -728,7 +728,7 @@ public void onlyGroupsIsDeclared() { @Test public void onlyExcludeTagsIsDeclared() { - Map properties = singletonMap(TESTNG_EXCLUDEDGROUPS_PROP, "tagOne, tagTwo"); + Map properties = singletonMap(EXCLUDEDGROUPS_PROP, "tagOne, tagTwo"); ProviderParameters providerParameters = providerParametersMock(TestClass1.class); when(providerParameters.getProviderProperties()).thenReturn(properties); @@ -740,7 +740,7 @@ public void onlyExcludeTagsIsDeclared() { @Test public void noFiltersAreCreatedIfTagsAreEmpty() { - Map properties = singletonMap(TESTNG_GROUPS_PROP, ""); + Map properties = singletonMap(GROUPS_PROP, ""); ProviderParameters providerParameters = providerParametersMock(TestClass1.class); when(providerParameters.getProviderProperties()).thenReturn(properties); @@ -752,7 +752,7 @@ public void noFiltersAreCreatedIfTagsAreEmpty() { @Test public void filtersWithEmptyTagsAreNotRegistered() { // Here only tagOne is registered as a valid tag and other tags are ignored as they are empty - Map properties = singletonMap(TESTNG_EXCLUDEDGROUPS_PROP, "tagOne,"); + Map properties = singletonMap(EXCLUDEDGROUPS_PROP, "tagOne,"); ProviderParameters providerParameters = providerParametersMock(TestClass1.class); when(providerParameters.getProviderProperties()).thenReturn(properties); @@ -764,8 +764,8 @@ public void filtersWithEmptyTagsAreNotRegistered() { @Test public void bothIncludeAndExcludeAreAllowed() { Map properties = new HashMap<>(); - properties.put(TESTNG_GROUPS_PROP, "tagOne, tagTwo"); - properties.put(TESTNG_EXCLUDEDGROUPS_PROP, "tagThree, tagFour"); + properties.put(GROUPS_PROP, "tagOne, tagTwo"); + properties.put(EXCLUDEDGROUPS_PROP, "tagThree, tagFour"); ProviderParameters providerParameters = providerParametersMock(TestClass1.class); when(providerParameters.getProviderProperties()).thenReturn(properties); @@ -778,8 +778,8 @@ public void bothIncludeAndExcludeAreAllowed() { @Test public void tagExpressionsAreSupportedForIncludeTagsContainingVerticalBar() { Map properties = new HashMap<>(); - properties.put(TESTNG_GROUPS_PROP, "tagOne | tagTwo"); - properties.put(TESTNG_EXCLUDEDGROUPS_PROP, "tagThree | tagFour"); + properties.put(GROUPS_PROP, "tagOne | tagTwo"); + properties.put(EXCLUDEDGROUPS_PROP, "tagThree | tagFour"); ProviderParameters providerParameters = providerParametersMock(TestClass1.class); when(providerParameters.getProviderProperties()).thenReturn(properties); @@ -792,8 +792,8 @@ public void tagExpressionsAreSupportedForIncludeTagsContainingVerticalBar() { @Test public void tagExpressionsAreSupportedForIncludeTagsContainingAmpersand() { Map properties = new HashMap<>(); - properties.put(TESTNG_GROUPS_PROP, "tagOne & !tagTwo"); - properties.put(TESTNG_EXCLUDEDGROUPS_PROP, "tagThree & !tagFour"); + properties.put(GROUPS_PROP, "tagOne & !tagTwo"); + properties.put(EXCLUDEDGROUPS_PROP, "tagThree & !tagFour"); ProviderParameters providerParameters = providerParametersMock(TestClass1.class); when(providerParameters.getProviderProperties()).thenReturn(properties); @@ -913,7 +913,7 @@ public void shouldFilterTestMethod() { TestListResolver testListResolver = new TestListResolver("**/*Test#test*"); assertFalse(testListResolver.isEmpty()); assertFalse(testListResolver.isWildcard()); - TestRequest request = new TestRequest(null, null, testListResolver, 0); + TestRequest request = new TestRequest(null, null, 0); when(providerParameters.getTestRequest()).thenReturn(request); JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters); @@ -935,7 +935,7 @@ public void shouldNotFilterEmpty() { TestListResolver testListResolver = new TestListResolver(""); assertTrue(testListResolver.isEmpty()); assertFalse(testListResolver.isWildcard()); - TestRequest request = new TestRequest(null, null, testListResolver, 0); + TestRequest request = new TestRequest(null, null, 0); when(providerParameters.getTestRequest()).thenReturn(request); JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters); @@ -949,7 +949,7 @@ public void shouldNotFilterWildcard() { TestListResolver testListResolver = new TestListResolver("*.java"); assertTrue(testListResolver.isWildcard()); assertFalse(testListResolver.isEmpty()); - TestRequest request = new TestRequest(null, null, testListResolver, 0); + TestRequest request = new TestRequest(null, null, 0); when(providerParameters.getTestRequest()).thenReturn(request); JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters); diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java index 69678aec49..bc617eb38a 100644 --- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java +++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java @@ -97,7 +97,7 @@ public class RunListenerAdapterTest { public void setUp() { listener = mock(TestReportListener.class); adapter = new RunListenerAdapter(listener, Stoppable.NOOP); - adapter.testPlanExecutionStarted(TestPlan.from(emptyList(), CONFIG_PARAMS, OUTPUT_DIRECTORY)); + adapter.testPlanExecutionStarted(TestPlan.from(false, emptyList(), CONFIG_PARAMS, OUTPUT_DIRECTORY)); adapter.setRunMode(NORMAL_RUN); } @@ -106,7 +106,7 @@ public void notifiedWithCorrectNamesWhenMethodExecutionStarted() throws Exceptio ArgumentCaptor entryCaptor = ArgumentCaptor.forClass(ReportEntry.class); TestPlan testPlan = TestPlan.from( - singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); + false, singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); adapter.testPlanExecutionStarted(testPlan); TestIdentifier methodIdentifier = @@ -126,7 +126,7 @@ public void notifiedWithCompatibleNameForMethodWithArguments() throws Exception ArgumentCaptor entryCaptor = ArgumentCaptor.forClass(ReportEntry.class); TestPlan testPlan = TestPlan.from( - singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); + false, singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); adapter.testPlanExecutionStarted(testPlan); TestIdentifier methodIdentifier = @@ -150,7 +150,7 @@ public void notifiedEagerlyForTestSetWhenClassExecutionStarted() throws Exceptio engine.addChild(parent); TestDescriptor child = newMethodDescriptor(); parent.addChild(child); - TestPlan plan = TestPlan.from(singletonList(engine), CONFIG_PARAMS, OUTPUT_DIRECTORY); + TestPlan plan = TestPlan.from(false, singletonList(engine), CONFIG_PARAMS, OUTPUT_DIRECTORY); String className = MyTestClass.class.getName(); @@ -214,7 +214,7 @@ public void displayNamesInClassAndMethods() throws Exception { new DefaultJupiterConfiguration(CONFIG_PARAMS, OUTPUT_DIRECTORY)); parent.addChild(child2); - TestPlan plan = TestPlan.from(singletonList(engine), CONFIG_PARAMS, OUTPUT_DIRECTORY); + TestPlan plan = TestPlan.from(false, singletonList(engine), CONFIG_PARAMS, OUTPUT_DIRECTORY); InOrder inOrder = inOrder(listener); @@ -306,7 +306,7 @@ public Type getType() { return TEST; } }; - TestPlan plan = TestPlan.from(singletonList(engine), CONFIG_PARAMS, OUTPUT_DIRECTORY); + TestPlan plan = TestPlan.from(false, singletonList(engine), CONFIG_PARAMS, OUTPUT_DIRECTORY); adapter.testPlanExecutionStarted(plan); assertThat((TestPlan) getInternalState(adapter, "testPlan")).isSameAs(plan); @@ -358,7 +358,7 @@ public void notifiedWithCorrectNamesWhenClassExecutionSkipped() throws Exception TestDescriptor method2 = newMethodDescriptor(); classTestDescriptor.addChild(method2); engineDescriptor.addChild(classTestDescriptor); - TestPlan testPlan = TestPlan.from(singletonList(engineDescriptor), CONFIG_PARAMS, OUTPUT_DIRECTORY); + TestPlan testPlan = TestPlan.from(false, singletonList(engineDescriptor), CONFIG_PARAMS, OUTPUT_DIRECTORY); adapter.testPlanExecutionStarted(testPlan); TestIdentifier classIdentifier = @@ -430,7 +430,7 @@ public void notifiedWhenMethodExecutionFailedWithError() throws Exception { public void notifiedWithCorrectNamesWhenClassExecutionFailed() { ArgumentCaptor entryCaptor = ArgumentCaptor.forClass(ReportEntry.class); TestPlan testPlan = TestPlan.from( - singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); + false, singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); adapter.testPlanExecutionStarted(testPlan); adapter.executionFinished( @@ -449,7 +449,7 @@ public void notifiedWithCorrectNamesWhenClassExecutionFailed() { public void notifiedWithCorrectNamesWhenClassExecutionErrored() { ArgumentCaptor entryCaptor = ArgumentCaptor.forClass(ReportEntry.class); TestPlan testPlan = TestPlan.from( - singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); + false, singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); adapter.testPlanExecutionStarted(testPlan); adapter.executionFinished( @@ -468,7 +468,7 @@ public void notifiedWithCorrectNamesWhenClassExecutionErrored() { public void notifiedWithCorrectNamesWhenContainerFailed() throws Exception { ArgumentCaptor entryCaptor = ArgumentCaptor.forClass(ReportEntry.class); TestPlan testPlan = TestPlan.from( - singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); + false, singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); adapter.testPlanExecutionStarted(testPlan); adapter.executionFinished(newContainerIdentifier(), failed(new RuntimeException())); @@ -493,7 +493,8 @@ public void notifiedForTestSetWhenClassExecutionSucceeded() { EngineDescriptor engineDescriptor = newEngineDescriptor(); TestDescriptor classDescriptor = newClassDescriptor(); engineDescriptor.addChild(classDescriptor); - adapter.testPlanExecutionStarted(TestPlan.from(singleton(engineDescriptor), CONFIG_PARAMS, OUTPUT_DIRECTORY)); + adapter.testPlanExecutionStarted( + TestPlan.from(false, singleton(engineDescriptor), CONFIG_PARAMS, OUTPUT_DIRECTORY)); adapter.executionStarted(TestIdentifier.from(classDescriptor)); adapter.executionFinished(TestIdentifier.from(classDescriptor), successful()); @@ -524,7 +525,7 @@ public void notifiedForTestSetWhenClassExecutionSucceeded() { public void notifiedWithParentDisplayNameWhenTestClassUnknown() { // Set up a test plan TestPlan plan = TestPlan.from( - singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); + false, singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); adapter.testPlanExecutionStarted(plan); // Use the test plan to set up child with parent. @@ -545,7 +546,7 @@ public void notifiedWithParentDisplayNameWhenTestClassUnknown() { @Test public void stackTraceWriterPresentWhenParentHasSource() { TestPlan plan = TestPlan.from( - singletonList(new EngineDescriptor(newId(), "Some Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); + false, singletonList(new EngineDescriptor(newId(), "Some Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); adapter.testPlanExecutionStarted(plan); TestIdentifier child = @@ -559,7 +560,7 @@ public void stackTraceWriterPresentWhenParentHasSource() { @Test public void stackTraceWriterDefaultsToTestClass() { TestPlan plan = TestPlan.from( - singletonList(new EngineDescriptor(newId(), "Some Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); + false, singletonList(new EngineDescriptor(newId(), "Some Plan")), CONFIG_PARAMS, OUTPUT_DIRECTORY); adapter.testPlanExecutionStarted(plan); TestIdentifier child = newSourcelessChildIdentifierWithParent(plan, "Parent", null); diff --git a/surefire-providers/surefire-junit3/pom.xml b/surefire-providers/surefire-junit3/pom.xml deleted file mode 100644 index c7ba6500ea..0000000000 --- a/surefire-providers/surefire-junit3/pom.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - 4.0.0 - - - org.apache.maven.surefire - surefire-providers - 3.5.5-SNAPSHOT - - - surefire-junit3 - - Surefire JUnit Runner - Surefire JUnit3 Runner - - - - junit - junit - 3.8.1 - provided - - - org.apache.maven.surefire - common-junit3 - ${project.version} - - - org.apache.maven.surefire - common-java5 - ${project.version} - - - org.apache.maven.surefire - surefire-shared-utils - test - - - - - - - org.jacoco - jacoco-maven-plugin - - jacoco.agent - - - - jacoco-agent - - prepare-agent - - - - - - maven-surefire-plugin - - ${jvm.args.tests} ${jacoco.agent} - - - - org.apache.maven.surefire - surefire-shadefire - - - 3.5.0 - - - - - - diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java deleted file mode 100644 index e018096dc9..0000000000 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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.surefire.junit; - -import java.util.Map; - -import org.apache.maven.surefire.api.provider.AbstractProvider; -import org.apache.maven.surefire.api.provider.ProviderParameters; -import org.apache.maven.surefire.api.report.ReporterFactory; -import org.apache.maven.surefire.api.report.SimpleReportEntry; -import org.apache.maven.surefire.api.report.TestSetReportEntry; -import org.apache.maven.surefire.api.suite.RunResult; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.api.util.RunOrderCalculator; -import org.apache.maven.surefire.api.util.ScanResult; -import org.apache.maven.surefire.api.util.TestsToRun; -import org.apache.maven.surefire.common.junit3.JUnit3Reflector; -import org.apache.maven.surefire.common.junit3.JUnit3TestChecker; - -import static org.apache.maven.surefire.api.report.ConsoleOutputCapture.startCapture; -import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; -import static org.apache.maven.surefire.api.util.ReflectionUtils.instantiate; -import static org.apache.maven.surefire.api.util.internal.ObjectUtils.isSecurityManagerSupported; -import static org.apache.maven.surefire.api.util.internal.ObjectUtils.systemProps; - -/** - * @author Kristian Rosenvold - */ -public class JUnit3Provider extends AbstractProvider { - private final ClassLoader testClassLoader; - - private final PojoAndJUnit3Checker testChecker; - - private final JUnit3TestChecker jUnit3TestChecker; - - private final JUnit3Reflector reflector; - - private final ProviderParameters providerParameters; - - private final RunOrderCalculator runOrderCalculator; - - private final ScanResult scanResult; - - public JUnit3Provider(ProviderParameters booterParameters) { - this.providerParameters = booterParameters; - testClassLoader = booterParameters.getTestClassLoader(); - scanResult = booterParameters.getScanResult(); - runOrderCalculator = booterParameters.getRunOrderCalculator(); - reflector = new JUnit3Reflector(testClassLoader); - jUnit3TestChecker = new JUnit3TestChecker(testClassLoader); - testChecker = new PojoAndJUnit3Checker(jUnit3TestChecker); // Todo; use reflector - } - - @Override - public RunResult invoke(Object forkTestSet) throws TestSetFailedException { - ReporterFactory reporterFactory = providerParameters.getReporterFactory(); - JUnit3Reporter reporter = new JUnit3Reporter(reporterFactory.createTestReportListener()); - reporter.setRunMode(NORMAL_RUN); - startCapture(reporter); - - final TestsToRun testsToRun; - if (forkTestSet instanceof TestsToRun) { - testsToRun = (TestsToRun) forkTestSet; - } else if (forkTestSet instanceof Class) { - testsToRun = TestsToRun.fromClass((Class) forkTestSet); - } else { - testsToRun = scanClassPath(); - } - - RunResult runResult; - try { - Map systemProperties = systemProps(); - setSystemManager(System.getProperty("surefire.security.manager")); - - for (Class clazz : testsToRun) { - SurefireTestSetExecutor surefireTestSetExecutor = createTestSet(clazz, reporter); - executeTestSet(clazz, surefireTestSetExecutor, reporter, systemProperties); - } - } finally { - runResult = reporterFactory.close(); - } - return runResult; - } - - static void setSystemManager(String smClassName) throws TestSetFailedException { - if (smClassName != null) { - if (!isSecurityManagerSupported()) { - throw new TestSetFailedException("JDK does not support overriding Security Manager with " - + "a value in system property 'surefire.security.manager'."); - } - ClassLoader classLoader = JUnit3Provider.class.getClassLoader(); - SecurityManager sm = instantiate(classLoader, smClassName, SecurityManager.class); - System.setSecurityManager(sm); - } - } - - private SurefireTestSetExecutor createTestSet(Class clazz, JUnit3Reporter reporter) { - return reflector.isJUnit3Available() && jUnit3TestChecker.accept(clazz) - ? new JUnitTestSetExecutor(reflector, reporter) - : new PojoTestSetExecutor(reporter); - } - - private void executeTestSet( - Class testSet, - SurefireTestSetExecutor testSetExecutor, - JUnit3Reporter reporter, - Map systemProperties) - throws TestSetFailedException { - String clazz = testSet.getName(); - long testId = reporter.getClassMethodIndexer().indexClass(clazz); - - try { - TestSetReportEntry started = new SimpleReportEntry(NORMAL_RUN, testId, clazz, null, null, null); - reporter.testSetStarting(started); - testSetExecutor.execute(testSet, testClassLoader); - } finally { - TestSetReportEntry completed = - new SimpleReportEntry(NORMAL_RUN, testId, clazz, null, null, null, systemProperties); - reporter.testSetCompleted(completed); - } - } - - private TestsToRun scanClassPath() { - TestsToRun testsToRun = scanResult.applyFilter(testChecker, testClassLoader); - return runOrderCalculator.orderTestClasses(testsToRun); - } - - @Override - public Iterable> getSuites() { - return scanClassPath(); - } -} diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Reporter.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Reporter.java deleted file mode 100644 index 234ff72b7e..0000000000 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Reporter.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.surefire.junit; - -import org.apache.maven.surefire.api.report.OutputReportEntry; -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.RunListener; -import org.apache.maven.surefire.api.report.RunMode; -import org.apache.maven.surefire.api.report.TestOutputReceiver; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.apache.maven.surefire.api.report.TestSetReportEntry; -import org.apache.maven.surefire.report.ClassMethodIndexer; -import org.apache.maven.surefire.report.RunModeSetter; - -/** - * This implementation of {@link RunListener} handles {@link OutputReportEntry} in the - * {@link TestOutputReceiver output receiver}, downcasting to {@link TestOutputReportEntry}, and - * delegates the report entry to the {@link TestReportListener}. - * This object necessarily requires setting the {@link RunMode} in order to behave properly. - */ -final class JUnit3Reporter implements RunListener, TestOutputReceiver, RunModeSetter { - private final ClassMethodIndexer classMethodIndexer = new ClassMethodIndexer(); - private final TestReportListener reporter; - private volatile RunMode runMode; - - JUnit3Reporter(TestReportListener reporter) { - this.reporter = reporter; - } - - ClassMethodIndexer getClassMethodIndexer() { - return classMethodIndexer; - } - - @Override - public void setRunMode(RunMode runMode) { - this.runMode = runMode; - } - - @Override - public void testSetStarting(TestSetReportEntry report) { - reporter.testSetStarting(report); - } - - @Override - public void testSetCompleted(TestSetReportEntry report) { - reporter.testSetCompleted(report); - } - - @Override - public void testStarting(ReportEntry report) { - reporter.testStarting(report); - } - - @Override - public void testSucceeded(ReportEntry report) { - reporter.testSucceeded(report); - } - - @Override - public void testAssumptionFailure(ReportEntry report) { - reporter.testAssumptionFailure(report); - } - - @Override - public void testError(ReportEntry report) { - reporter.testError(report); - } - - @Override - public void testFailed(ReportEntry report) { - reporter.testFailed(report); - } - - @Override - public void testSkipped(ReportEntry report) { - reporter.testSkipped(report); - } - - @Override - public void testExecutionSkippedByUser() { - reporter.testExecutionSkippedByUser(); - } - - @Override - public void writeTestOutput(OutputReportEntry reportEntry) { - Long testRunId = classMethodIndexer.getLocalIndex(); - reporter.writeTestOutput(new TestOutputReportEntry(reportEntry, runMode, testRunId)); - } -} diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSetExecutor.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSetExecutor.java deleted file mode 100644 index 2d113d385d..0000000000 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSetExecutor.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.surefire.junit; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.common.junit3.JUnit3Reflector; - -/** - * JUnit3 test set - * - */ -public final class JUnitTestSetExecutor implements SurefireTestSetExecutor { - private final JUnit3Reflector reflector; - - private final JUnit3Reporter reporter; - - public JUnitTestSetExecutor(JUnit3Reflector reflector, JUnit3Reporter reporter) { - this.reflector = reflector; - this.reporter = reporter; - - // ---------------------------------------------------------------------- - // Strategy for executing JUnit tests - // - // o look for the suite method and if that is present execute that method - // to get the test object. - // - // o look for test classes that are assignable from TestCase - // - // o look for test classes that only implement the Test interface - // ---------------------------------------------------------------------- - - // The interface implemented by the dynamic proxy (TestListener), happens to be - // the same as the param types of TestResult.addTestListener - } - - @Override - public void execute(Class testClass, ClassLoader loader) throws TestSetFailedException { - try { - Object testObject = reflector.constructTestObject(testClass); - final Method runMethod; - - if (reflector.getTestInterface().isAssignableFrom(testObject.getClass())) { - runMethod = reflector.getTestInterfaceRunMethod(); - } else { - runMethod = reflector.getRunMethod(testClass); - } - - Object instanceOfTestResult = reflector.getTestResultClass().newInstance(); - - TestListenerInvocationHandler invocationHandler = new TestListenerInvocationHandler(reporter); - - Object testListener = Proxy.newProxyInstance( - loader, reflector.getInterfacesImplementedByDynamicProxy(), invocationHandler); - - Object[] addTestListenerParams = {testListener}; - - reflector.getAddListenerMethod().invoke(instanceOfTestResult, addTestListenerParams); - - Object[] runParams = {instanceOfTestResult}; - - runMethod.invoke(testObject, runParams); - } catch (InvocationTargetException e) { - throw new TestSetFailedException(testClass.getName(), e.getTargetException()); - } catch (NoSuchMethodException e) { - throw new TestSetFailedException("Class is not a JUnit TestCase", e); - } catch (ReflectiveOperationException e) { - throw new TestSetFailedException(testClass.getName(), e); - } - } -} diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java deleted file mode 100644 index 6f7fa1009c..0000000000 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.surefire.junit; - -import org.apache.maven.surefire.api.filter.NonAbstractClassFilter; -import org.apache.maven.surefire.api.util.ScannerFilter; -import org.apache.maven.surefire.common.junit3.JUnit3TestChecker; - -/** - * @author Kristian Rosenvold - */ -public class PojoAndJUnit3Checker implements ScannerFilter { - private final JUnit3TestChecker jUnit3TestChecker; - - private final NonAbstractClassFilter nonAbstractClassFilter = new NonAbstractClassFilter(); - - public PojoAndJUnit3Checker(JUnit3TestChecker jUnit3TestChecker) { - this.jUnit3TestChecker = jUnit3TestChecker; - } - - @Override - public boolean accept(Class testClass) { - return jUnit3TestChecker.accept(testClass) || nonAbstractClassFilter.accept(testClass) && isPojoTest(testClass); - } - - private boolean isPojoTest(Class testClass) { - try { - testClass.getConstructor(); - return true; - } catch (Exception e) { - return false; - } - } -} diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSetExecutor.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSetExecutor.java deleted file mode 100644 index f9769aea35..0000000000 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSetExecutor.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * 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.surefire.junit; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; - -import org.apache.maven.surefire.api.report.LegacyPojoStackTraceWriter; -import org.apache.maven.surefire.api.report.SimpleReportEntry; -import org.apache.maven.surefire.api.report.StackTraceWriter; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.report.ClassMethodIndexer; - -import static java.util.Objects.requireNonNull; -import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; -import static org.apache.maven.surefire.api.report.SimpleReportEntry.withException; - -/** - * Executes a JUnit3 test class - * - */ -public class PojoTestSetExecutor implements SurefireTestSetExecutor { - private static final String TEST_METHOD_PREFIX = "test"; - - private static final String SETUP_METHOD_NAME = "setUp"; - - private static final String TEARDOWN_METHOD_NAME = "tearDown"; - - private static final Object[] EMPTY_OBJECT_ARRAY = {}; - - private final JUnit3Reporter reporter; - - public PojoTestSetExecutor(JUnit3Reporter reporter) { - this.reporter = requireNonNull(reporter, "reportManager is null"); - } - - @Override - public void execute(Class testClass, ClassLoader loader) throws TestSetFailedException { - DiscoveredTestMethods discoveredTestMethods = discoverTestMethods(requireNonNull(testClass)); - - for (Method testMethod : discoveredTestMethods.testMethods) { - ClassMethodIndexer indexer = reporter.getClassMethodIndexer(); - long testRunId = indexer.indexClassMethod(testClass.getName(), testMethod.getName()); - boolean abort = executeTestMethod(testClass, testMethod, testRunId, discoveredTestMethods); - if (abort) { - break; - } - } - } - - private boolean executeTestMethod(Class testClass, Method method, long testRunId, DiscoveredTestMethods methods) - throws TestSetFailedException { - final Object testObject; - - try { - testObject = testClass.getDeclaredConstructor().newInstance(); - } catch (ReflectiveOperationException e) { - throw new TestSetFailedException("Unable to instantiate POJO '" + testClass + "'.", e); - } - - final String testClassName = testClass.getName(); - final String methodName = method.getName(); - final String userFriendlyMethodName = methodName + "()"; - final String testName = getTestName(testClassName, userFriendlyMethodName); - - reporter.testStarting(new SimpleReportEntry(NORMAL_RUN, testRunId, testClassName, null, testName, null)); - - try { - setUpFixture(testObject, methods); - } catch (Throwable e) { - StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter(testClassName, methodName, e); - reporter.testFailed( - withException(NORMAL_RUN, testRunId, testClassName, null, testName, null, stackTraceWriter)); - - // A return value of true indicates to this class's executeTestMethods - // method that it should abort and not attempt to execute - // any other test methods. The other caller of this method, - // TestRerunner.rerun, ignores this return value, because it is - // only running one test. - return true; - } - - // Make sure that tearDownFixture - try { - method.invoke(testObject, EMPTY_OBJECT_ARRAY); - reporter.testSucceeded(new SimpleReportEntry(NORMAL_RUN, testRunId, testClassName, null, testName, null)); - } catch (InvocationTargetException e) { - Throwable t = e.getTargetException(); - StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter(testClassName, methodName, t); - reporter.testFailed( - withException(NORMAL_RUN, testRunId, testClassName, null, testName, null, stackTraceWriter)); - // Don't return here, because tearDownFixture should be called even - // if the test method throws an exception. - } catch (Throwable t) { - StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter(testClassName, methodName, t); - reporter.testFailed( - withException(NORMAL_RUN, testRunId, testClassName, null, testName, null, stackTraceWriter)); - // Don't return here, because tearDownFixture should be called even - // if the test method throws an exception. - } - - try { - tearDownFixture(testObject, methods); - } catch (Throwable t) { - StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter(testClassName, methodName, t); - // Treat any exception from tearDownFixture as a failure of the test. - reporter.testFailed( - withException(NORMAL_RUN, testRunId, testClassName, null, testName, null, stackTraceWriter)); - - // A return value of true indicates to this class's executeTestMethods - // method that it should abort and not attempt to execute - // any other test methods. The other caller of this method, - // TestRerunner.rerun, ignores this return value, because it is - // only running one test. - return true; - } - - // A return value of false indicates to this class's executeTestMethods - // method that it should keep plowing ahead and invoke more test methods. - // The other caller of this method, - // TestRerunner.rerun, ignores this return value, because it is - // only running one test. - return false; - } - - private String getTestName(String testClassName, String testMethodName) { - return testClassName + "." + requireNonNull(testMethodName, "testMethodName is null"); - } - - private void setUpFixture(Object testObject, DiscoveredTestMethods methods) throws Throwable { - if (methods.setUpMethod != null) { - methods.setUpMethod.invoke(testObject); - } - } - - private void tearDownFixture(Object testObject, DiscoveredTestMethods methods) throws Throwable { - if (methods.tearDownMethod != null) { - methods.tearDownMethod.invoke(testObject); - } - } - - private DiscoveredTestMethods discoverTestMethods(Class testClass) { - DiscoveredTestMethods methods = new DiscoveredTestMethods(); - for (Method m : testClass.getMethods()) { - if (isNoArgsInstanceMethod(m)) { - if (isValidTestMethod(m)) { - methods.testMethods.add(m); - } else if (SETUP_METHOD_NAME.equals(m.getName())) { - methods.setUpMethod = m; - } else if (TEARDOWN_METHOD_NAME.equals(m.getName())) { - methods.tearDownMethod = m; - } - } - } - return methods; - } - - private static boolean isNoArgsInstanceMethod(Method m) { - boolean isInstanceMethod = !Modifier.isStatic(m.getModifiers()); - boolean returnsVoid = m.getReturnType().equals(void.class); - boolean hasNoParams = m.getParameterTypes().length == 0; - return isInstanceMethod && returnsVoid && hasNoParams; - } - - private static boolean isValidTestMethod(Method m) { - return m.getName().startsWith(TEST_METHOD_PREFIX); - } - - private static class DiscoveredTestMethods { - final Collection testMethods = new ArrayList<>(); - Method setUpMethod; - Method tearDownMethod; - } -} diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/SurefireTestSetExecutor.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/SurefireTestSetExecutor.java deleted file mode 100644 index 6379c6ae12..0000000000 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/SurefireTestSetExecutor.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.surefire.junit; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; - -/** - * Describes a single test set - * - */ -public interface SurefireTestSetExecutor { - void execute(Class testClass, ClassLoader loader) throws TestSetFailedException; -} diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java deleted file mode 100644 index 083d076f33..0000000000 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * 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.surefire.junit; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Set; - -import org.apache.maven.surefire.api.report.LegacyPojoStackTraceWriter; -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.RunListener; -import org.apache.maven.surefire.api.report.SimpleReportEntry; -import org.apache.maven.surefire.api.report.StackTraceWriter; - -import static java.util.Objects.requireNonNull; -import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; -import static org.apache.maven.surefire.api.report.SimpleReportEntry.withException; -import static org.apache.maven.surefire.api.util.internal.TestClassMethodNameUtils.extractClassName; -import static org.apache.maven.surefire.api.util.internal.TestClassMethodNameUtils.extractMethodName; - -/** - * Invocation Handler for TestListener proxies to delegate to our {@link RunListener} - * - */ -public class TestListenerInvocationHandler implements InvocationHandler { - // The String names of the four methods in interface junit.framework.TestListener - private static final String START_TEST = "startTest"; - - private static final String ADD_FAILURE = "addFailure"; - - private static final String ADD_ERROR = "addError"; - - private static final String END_TEST = "endTest"; - - private final Set failedTestsSet = new HashSet<>(); - - private final JUnit3Reporter reporter; - - private static final Class[] EMPTY_CLASS_ARRAY = {}; - - private static final Object[] EMPTY_STRING_ARRAY = {}; - - private static class FailedTest { - private final Object testThatFailed; - private final Thread threadOnWhichTestFailed; - - FailedTest(Object testThatFailed, Thread threadOnWhichTestFailed) { - this.testThatFailed = requireNonNull(testThatFailed, "testThatFailed is null"); - - this.threadOnWhichTestFailed = requireNonNull(threadOnWhichTestFailed, "threadOnWhichTestFailed is null"); - } - - @Override - public boolean equals(Object obj) { - boolean retVal = true; - - if (obj == null || getClass() != obj.getClass()) { - retVal = false; - } else { - FailedTest ft = (FailedTest) obj; - - if (ft.testThatFailed != testThatFailed) { - retVal = false; - } else if (!ft.threadOnWhichTestFailed.equals(threadOnWhichTestFailed)) { - retVal = false; - } - } - - return retVal; - } - - @Override - public int hashCode() { - return threadOnWhichTestFailed.hashCode(); - } - } - - public TestListenerInvocationHandler(JUnit3Reporter reporter) { - this.reporter = requireNonNull(reporter, "reporter is null"); - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - String methodName = method.getName(); - - switch (methodName) { - case START_TEST: - handleStartTest(args); - break; - case ADD_ERROR: - handleAddError(args); - break; - case ADD_FAILURE: - handleAddFailure(args); - break; - case END_TEST: - handleEndTest(args); - break; - default: - break; - } - - return null; - } - - // Handler for TestListener.startTest(Test) - private void handleStartTest(Object[] args) { - ReportEntry report = createStartEndReportEntry(args); - - reporter.testStarting(report); - } - - // Handler for TestListener.addFailure(Test, Throwable) - private void handleAddError(Object[] args) throws ReflectiveOperationException { - ReportEntry report = toReportEntryWithException(args); - - reporter.testError(report); - - failedTestsSet.add(new FailedTest(args[0], Thread.currentThread())); - } - - private static LegacyPojoStackTraceWriter toStackTraceWriter(Object[] args) throws ReflectiveOperationException { - String testName; - - try { - Method m = args[0].getClass().getMethod("getName", EMPTY_CLASS_ARRAY); - testName = (String) m.invoke(args[0], EMPTY_STRING_ARRAY); - } catch (NoSuchMethodException e) { - testName = "UNKNOWN"; - } - - return new LegacyPojoStackTraceWriter(args[0].getClass().getName(), testName, (Throwable) args[1]); - } - - private void handleAddFailure(Object[] args) throws ReflectiveOperationException { - ReportEntry report = toReportEntryWithException(args); - - reporter.testFailed(report); - - failedTestsSet.add(new FailedTest(args[0], Thread.currentThread())); - } - - private void handleEndTest(Object[] args) { - boolean testHadFailed = failedTestsSet.remove(new FailedTest(args[0], Thread.currentThread())); - - if (!testHadFailed) { - ReportEntry report = createStartEndReportEntry(args); - - reporter.testSucceeded(report); - } - } - - private ReportEntry toReportEntryWithException(Object[] args) throws ReflectiveOperationException { - String description = args[0].toString(); - String className = extractClassName(description); - String methodName = extractMethodName(description); - StackTraceWriter stackTraceWriter = toStackTraceWriter(args); - long testRunId = reporter.getClassMethodIndexer().indexClassMethod(className, methodName); - return withException(NORMAL_RUN, testRunId, className, null, methodName, null, stackTraceWriter); - } - - private SimpleReportEntry createStartEndReportEntry(Object[] args) { - String description = args[0].toString(); - String className = extractClassName(description); - String methodName = extractMethodName(description); - long testRunId = reporter.getClassMethodIndexer().indexClassMethod(className, methodName); - return new SimpleReportEntry(NORMAL_RUN, testRunId, className, null, methodName, null); - } -} diff --git a/surefire-providers/surefire-junit3/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider b/surefire-providers/surefire-junit3/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider deleted file mode 100644 index 83af8db2d0..0000000000 --- a/surefire-providers/surefire-junit3/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider +++ /dev/null @@ -1 +0,0 @@ -org.apache.maven.surefire.junit.JUnit3Provider diff --git a/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java b/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java deleted file mode 100644 index 35979a1ecf..0000000000 --- a/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * 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.surefire.junit; - -import java.security.AccessControlException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.List; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.RunListener; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.apache.maven.surefire.api.report.TestSetReportEntry; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.common.junit3.JUnit3Reflector; - -import static org.apache.maven.surefire.shared.lang3.JavaVersion.JAVA_17; -import static org.apache.maven.surefire.shared.lang3.JavaVersion.JAVA_RECENT; - -/** - * - */ -public class JUnitTestSetTest extends TestCase { - - public void testExecuteSuiteClass() throws Exception { - ClassLoader testClassLoader = this.getClass().getClassLoader(); - JUnit3Reflector reflector = new JUnit3Reflector(testClassLoader); - SuccessListener listener = new SuccessListener(); - JUnit3Reporter reporter = new JUnit3Reporter(listener); - JUnitTestSetExecutor testSet = new JUnitTestSetExecutor(reflector, reporter); - testSet.execute(Suite.class, testClassLoader); - List succeededTests = listener.getSucceededTests(); - assertEquals(1, succeededTests.size()); - assertEquals( - "org.apache.maven.surefire.junit.JUnitTestSetTest$AlwaysSucceeds", - succeededTests.get(0).getSourceName()); - assertEquals("testSuccess", succeededTests.get(0).getName()); - } - - public void testSystemManager() { - boolean isDeprecated = !JAVA_RECENT.atMost(JAVA_17); - Object originalSm = null; - try { - if (!isDeprecated) { - originalSm = System.getSecurityManager(); - } - - JUnit3Provider.setSystemManager("java.lang.SecurityManager"); - - if (isDeprecated) { - fail(); - } - - Object sm = System.getSecurityManager(); - assertNotNull(sm); - assertEquals("java.lang.SecurityManager", sm.getClass().getName()); - assertNotSame(originalSm, sm); - } catch (TestSetFailedException e) { - if (!isDeprecated) { - fail(); - } - } finally { - if (!isDeprecated) { - try { - SecurityManager sm = (SecurityManager) originalSm; - AccessController.doPrivileged((PrivilegedAction) () -> { - System.setSecurityManager(sm); - return null; - }); - } catch (AccessControlException e) { - // ignore - } - } - } - } - - /** - * - */ - public static final class AlwaysSucceeds extends TestCase { - public void testSuccess() { - assertTrue(true); - } - } - - /** - * - */ - public static class SuccessListener implements RunListener, TestReportListener { - - private List succeededTests = new ArrayList<>(); - - @Override - public void testSetStarting(TestSetReportEntry report) {} - - @Override - public void testSetCompleted(TestSetReportEntry report) {} - - @Override - public void testStarting(ReportEntry report) {} - - @Override - public void testSucceeded(ReportEntry report) { - succeededTests.add(report); - } - - @Override - public void testAssumptionFailure(ReportEntry report) { - throw new IllegalStateException(); - } - - @Override - public void testError(ReportEntry report) { - throw new IllegalStateException(); - } - - @Override - public void testFailed(ReportEntry report) { - throw new IllegalStateException(); - } - - @Override - public void testSkipped(ReportEntry report) { - throw new IllegalStateException(); - } - - @Override - public void testExecutionSkippedByUser() {} - - List getSucceededTests() { - return succeededTests; - } - - @Override - public void writeTestOutput(TestOutputReportEntry reportEntry) {} - - @Override - public boolean isDebugEnabled() { - return false; - } - - @Override - public void debug(String message) {} - - @Override - public boolean isInfoEnabled() { - return false; - } - - @Override - public void info(String message) {} - - @Override - public boolean isWarnEnabled() { - return false; - } - - @Override - public void warning(String message) {} - - @Override - public boolean isErrorEnabled() { - return false; - } - - @Override - public void error(String message) {} - - @Override - public void error(String message, Throwable t) {} - - @Override - public void error(Throwable t) {} - } - - /** - * - */ - public static class Suite { - - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTestSuite(AlwaysSucceeds.class); - return suite; - } - } -} diff --git a/surefire-providers/surefire-junit4/pom.xml b/surefire-providers/surefire-junit4/pom.xml deleted file mode 100644 index c47308797b..0000000000 --- a/surefire-providers/surefire-junit4/pom.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - 4.0.0 - - - org.apache.maven.surefire - surefire-providers - 3.5.5-SNAPSHOT - - - surefire-junit4 - - Surefire JUnit4 Runner - Surefire JUnit 4.0+ Runner - - - - junit - junit - 4.0 - provided - - - org.apache.maven.surefire - common-java5 - ${project.version} - - - org.apache.maven.surefire - common-junit4 - ${project.version} - - - org.hamcrest - hamcrest - test - - - - - - - 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 - surefire-shadefire - - - 3.5.0 - - - - - - diff --git a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java deleted file mode 100644 index 2668290e9a..0000000000 --- a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * 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.surefire.junit4; - -import java.util.Collection; -import java.util.Set; - -import org.apache.maven.surefire.api.booter.Command; -import org.apache.maven.surefire.api.provider.AbstractProvider; -import org.apache.maven.surefire.api.provider.CommandChainReader; -import org.apache.maven.surefire.api.provider.CommandListener; -import org.apache.maven.surefire.api.provider.ProviderParameters; -import org.apache.maven.surefire.api.report.ReporterFactory; -import org.apache.maven.surefire.api.report.RunListener; -import org.apache.maven.surefire.api.report.SimpleReportEntry; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.apache.maven.surefire.api.suite.RunResult; -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.apache.maven.surefire.api.testset.TestRequest; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.api.util.RunOrderCalculator; -import org.apache.maven.surefire.api.util.ScanResult; -import org.apache.maven.surefire.api.util.TestsToRun; -import org.apache.maven.surefire.common.junit4.JUnit4RunListener; -import org.apache.maven.surefire.common.junit4.JUnit4TestChecker; -import org.apache.maven.surefire.common.junit4.JUnitTestFailureListener; -import org.apache.maven.surefire.common.junit4.Notifier; -import org.apache.maven.surefire.report.ClassMethodIndexer; -import org.apache.maven.surefire.report.PojoStackTraceWriter; -import org.apache.maven.surefire.report.RunModeSetter; -import org.junit.runner.Description; -import org.junit.runner.Request; -import org.junit.runner.Result; -import org.junit.runner.Runner; -import org.junit.runner.manipulation.Filter; -import org.junit.runner.notification.StoppedByUserException; - -import static java.lang.reflect.Modifier.isAbstract; -import static java.lang.reflect.Modifier.isInterface; -import static org.apache.maven.surefire.api.report.ConsoleOutputCapture.startCapture; -import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; -import static org.apache.maven.surefire.api.report.RunMode.RERUN_TEST_AFTER_FAILURE; -import static org.apache.maven.surefire.api.report.SimpleReportEntry.withException; -import static org.apache.maven.surefire.api.testset.TestListResolver.optionallyWildcardFilter; -import static org.apache.maven.surefire.api.util.TestsToRun.fromClass; -import static org.apache.maven.surefire.api.util.internal.ObjectUtils.systemProps; -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.createMatchAnyDescriptionFilter; -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.generateFailingTestDescriptions; -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.isFailureInsideJUnitItself; -import static org.apache.maven.surefire.common.junit4.JUnit4Reflector.createDescription; -import static org.apache.maven.surefire.common.junit4.JUnit4Reflector.createIgnored; -import static org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures; -import static org.apache.maven.surefire.common.junit4.JUnit4RunListenerFactory.createCustomListeners; -import static org.apache.maven.surefire.common.junit4.Notifier.pureNotifier; -import static org.junit.runner.Request.aClass; - -/** - * @author Kristian Rosenvold - */ -public class JUnit4Provider extends AbstractProvider { - private static final String UNDETERMINED_TESTS_DESCRIPTION = "cannot determine test in forked JVM with surefire"; - - private final ClassMethodIndexer classMethodIndexer = new ClassMethodIndexer(); - - private final ClassLoader testClassLoader; - - private final String customRunListeners; - - private final JUnit4TestChecker jUnit4TestChecker; - - private final TestListResolver testResolver; - - private final ProviderParameters providerParameters; - - private final RunOrderCalculator runOrderCalculator; - - private final ScanResult scanResult; - - private final int rerunFailingTestsCount; - - private final CommandChainReader commandsReader; - - private TestsToRun testsToRun; - - public JUnit4Provider(ProviderParameters bootParams) { - // don't start a thread in CommandReader while we are in in-plugin process - commandsReader = bootParams.isInsideFork() ? bootParams.getCommandReader() : null; - providerParameters = bootParams; - testClassLoader = bootParams.getTestClassLoader(); - scanResult = bootParams.getScanResult(); - runOrderCalculator = bootParams.getRunOrderCalculator(); - customRunListeners = bootParams.getProviderProperties().get("listener"); - jUnit4TestChecker = new JUnit4TestChecker(testClassLoader); - TestRequest testRequest = bootParams.getTestRequest(); - testResolver = testRequest.getTestListResolver(); - rerunFailingTestsCount = testRequest.getRerunFailingTestsCount(); - } - - @Override - public RunResult invoke(Object forkTestSet) throws TestSetFailedException { - upgradeCheck(); - - ReporterFactory reporterFactory = providerParameters.getReporterFactory(); - - RunResult runResult; - try { - TestReportListener reporter = reporterFactory.createTestReportListener(); - JUnit4RunListener listener = new JUnit4RunListener(reporter); - listener.setRunMode(NORMAL_RUN); - - startCapture(listener); - // startCapture() called in prior to setTestsToRun() - - if (testsToRun == null) { - setTestsToRun(forkTestSet); - } - - Notifier notifier = new Notifier(listener, getSkipAfterFailureCount()); - Result result = new Result(); - notifier.addListeners(createCustomListeners(customRunListeners)).addListener(result.createListener()); - - if (isFailFast() && commandsReader != null) { - registerPleaseStopJUnitListener(notifier); - } - - try { - notifier.fireTestRunStarted( - testsToRun.allowEagerReading() - ? createTestsDescription(testsToRun) - : createDescription(UNDETERMINED_TESTS_DESCRIPTION)); - - if (commandsReader != null) { - registerShutdownListener(testsToRun); - commandsReader.awaitStarted(); - } - - for (Class testToRun : testsToRun) { - executeTestSet(testToRun, reporter, notifier, listener); - } - } finally { - notifier.fireTestRunFinished(result); - notifier.removeListeners(); - } - rethrowAnyTestMechanismFailures(result); - } finally { - runResult = reporterFactory.close(); - } - return runResult; - } - - private void setTestsToRun(Object forkTestSet) throws TestSetFailedException { - if (forkTestSet instanceof TestsToRun) { - testsToRun = (TestsToRun) forkTestSet; - } else if (forkTestSet instanceof Class) { - testsToRun = fromClass((Class) forkTestSet); - } else { - testsToRun = scanClassPath(); - } - } - - private boolean isRerunFailingTests() { - return rerunFailingTestsCount > 0; - } - - private boolean isFailFast() { - return providerParameters.getSkipAfterFailureCount() > 0; - } - - private int getSkipAfterFailureCount() { - return isFailFast() ? providerParameters.getSkipAfterFailureCount() : 0; - } - - private void registerShutdownListener(final TestsToRun testsToRun) { - commandsReader.addShutdownListener(new CommandListener() { - @Override - public void update(Command command) { - testsToRun.markTestSetFinished(); - } - }); - } - - private void registerPleaseStopJUnitListener(final Notifier notifier) { - commandsReader.addSkipNextTestsListener(new CommandListener() { - @Override - public void update(Command command) { - notifier.pleaseStop(); - } - }); - } - - private void executeTestSet(Class clazz, RunListener reporter, Notifier notifier, RunModeSetter runMode) { - long testRunId = classMethodIndexer.indexClass(clazz.getName()); - SimpleReportEntry report = - new SimpleReportEntry(NORMAL_RUN, testRunId, clazz.getName(), null, null, null, systemProps()); - reporter.testSetStarting(report); - try { - executeWithRerun(clazz, notifier, runMode); - } catch (Throwable e) { - if (isFailFast() && e instanceof StoppedByUserException) { - String reason = e.getClass().getName(); - Description skippedTest = createDescription(clazz.getName(), createIgnored(reason)); - notifier.fireTestIgnored(skippedTest); - } else { - String reportName = report.getName(); - String reportSourceName = report.getSourceName(); - PojoStackTraceWriter stackWriter = new PojoStackTraceWriter(reportSourceName, reportName, e); - reporter.testError( - withException(NORMAL_RUN, testRunId, reportSourceName, null, reportName, null, stackWriter)); - } - } finally { - reporter.testSetCompleted(report); - } - } - - private void executeWithRerun(Class clazz, Notifier notifier, RunModeSetter runMode) { - JUnitTestFailureListener failureListener = new JUnitTestFailureListener(); - notifier.addListener(failureListener); - boolean hasMethodFilter = testResolver != null && testResolver.hasMethodPatterns(); - - try { - try { - notifier.asFailFast(isFailFast()); - execute(clazz, notifier, hasMethodFilter ? createMethodFilter() : null); - } finally { - notifier.asFailFast(false); - } - - // Rerun failing tests if rerunFailingTestsCount is larger than 0 - if (isRerunFailingTests()) { - runMode.setRunMode(RERUN_TEST_AFTER_FAILURE); - Notifier rerunNotifier = pureNotifier(); - notifier.copyListenersTo(rerunNotifier); - for (int i = 0; - i < rerunFailingTestsCount - && !failureListener.getAllFailures().isEmpty(); - i++) { - Set failures = generateFailingTestDescriptions(failureListener.getAllFailures()); - failureListener.reset(); - Filter failureDescriptionFilter = createMatchAnyDescriptionFilter(failures); - execute(clazz, rerunNotifier, failureDescriptionFilter); - } - } - } finally { - notifier.removeListener(failureListener); - } - } - - @Override - public Iterable> getSuites() { - testsToRun = scanClassPath(); - return testsToRun; - } - - private TestsToRun scanClassPath() { - final TestsToRun scannedClasses = scanResult.applyFilter(jUnit4TestChecker, testClassLoader); - return runOrderCalculator.orderTestClasses(scannedClasses); - } - - private void upgradeCheck() throws TestSetFailedException { - if (isJUnit4UpgradeCheck()) { - Collection> classesSkippedByValidation = - scanResult.getClassesSkippedByValidation(jUnit4TestChecker, testClassLoader); - if (!classesSkippedByValidation.isEmpty()) { - StringBuilder reason = new StringBuilder(); - reason.append("Updated check failed\n"); - reason.append("There are tests that would be run with junit4 / surefire 2.6 but not with [2.7,):\n"); - for (Class testClass : classesSkippedByValidation) { - reason.append(" "); - reason.append(testClass.getName()); - reason.append("\n"); - } - throw new TestSetFailedException(reason.toString()); - } - } - } - - static Description createTestsDescription(Iterable> classes) { - // "null" string rather than null; otherwise NPE in junit:4.0 - Description description = createDescription("null"); - for (Class clazz : classes) { - description.addChild(createDescription(clazz.getName())); - } - return description; - } - - private static boolean isJUnit4UpgradeCheck() { - return System.getProperty("surefire.junit4.upgradecheck") != null; - } - - private static void execute(Class testClass, Notifier notifier, Filter filter) { - final int classModifiers = testClass.getModifiers(); - if (!isAbstract(classModifiers) && !isInterface(classModifiers)) { - Request request = aClass(testClass); - if (filter != null) { - request = request.filterWith(filter); - } - Runner runner = request.getRunner(); - if (countTestsInRunner(runner.getDescription()) != 0) { - runner.run(notifier); - } - } - } - - /** - * JUnit error: test count includes one test-class as a suite which has filtered out all children. - * Then the child test has a description "initializationError0(org.junit.runner.manipulation.Filter)" - * for JUnit 4.0 or "initializationError(org.junit.runner.manipulation.Filter)" for JUnit 4.12 - * and Description#isTest() returns true, but this description is not a real test - * and therefore it should not be included in the entire test count. - */ - private static int countTestsInRunner(Description description) { - if (description.isSuite()) { - int count = 0; - for (Description child : description.getChildren()) { - if (!hasFilteredOutAllChildren(child)) { - count += countTestsInRunner(child); - } - } - return count; - } else if (description.isTest()) { - return hasFilteredOutAllChildren(description) ? 0 : 1; - } else { - return 0; - } - } - - private static boolean hasFilteredOutAllChildren(Description description) { - if (isFailureInsideJUnitItself(description)) { - return true; - } - String name = description.getDisplayName(); - // JUnit 4.0: initializationError0; JUnit 4.12: initializationError. - if (name == null) { - return true; - } else { - name = name.trim(); - return name.startsWith("initializationError0(org.junit.runner.manipulation.Filter)") - || name.startsWith("initializationError(org.junit.runner.manipulation.Filter)"); - } - } - - private Filter createMethodFilter() { - TestListResolver methodFilter = optionallyWildcardFilter(testResolver); - return methodFilter.isEmpty() || methodFilter.isWildcard() ? null : new TestResolverFilter(methodFilter); - } -} diff --git a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/TestResolverFilter.java b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/TestResolverFilter.java deleted file mode 100644 index 1d05aabb92..0000000000 --- a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/TestResolverFilter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.surefire.junit4; - -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.apache.maven.surefire.api.util.internal.ClassMethod; -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -import static org.apache.maven.surefire.api.testset.TestListResolver.toClassFileName; -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.toClassMethod; - -/** - * Method filter used in {@link JUnit4Provider}. - */ -final class TestResolverFilter extends Filter { - private final TestListResolver methodFilter; - - TestResolverFilter(TestListResolver methodFilter) { - this.methodFilter = methodFilter; - } - - @Override - public boolean shouldRun(Description description) { - // class: Java class name; method: 1. "testMethod" or 2. "testMethod[5+whatever]" in @Parameterized - final ClassMethod cm = toClassMethod(description); - final boolean isSuite = description.isSuite(); - final boolean isValidTest = description.isTest() && cm.isValidTest(); - final String clazz = cm.getClazz(); - final String method = cm.getMethod(); - return isSuite || isValidTest && methodFilter.shouldRun(toClassFileName(clazz), method); - } - - @Override - public String describe() { - return methodFilter.toString(); - } -} diff --git a/surefire-providers/surefire-junit4/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider b/surefire-providers/surefire-junit4/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider deleted file mode 100644 index d99929df47..0000000000 --- a/surefire-providers/surefire-junit4/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider +++ /dev/null @@ -1 +0,0 @@ -org.apache.maven.surefire.junit4.JUnit4Provider diff --git a/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java b/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java deleted file mode 100644 index 960bc8dc64..0000000000 --- a/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.surefire.junit4; - -import java.io.File; -import java.util.HashMap; - -import org.apache.maven.surefire.api.booter.BaseProviderFactory; -import org.apache.maven.surefire.api.testset.RunOrderParameters; -import org.apache.maven.surefire.api.testset.TestRequest; -import org.junit.Test; -import org.junit.runner.Description; - -import static java.util.Arrays.asList; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.isEmptyOrNullString; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertNotNull; -import static org.junit.runner.Description.createSuiteDescription; - -/** - * @author Kristian Rosenvold - */ -public class JUnit4ProviderTest { - @Test - public void testCreateProvider() { - assertNotNull(getJUnit4Provider()); - } - - private JUnit4Provider getJUnit4Provider() { - BaseProviderFactory providerParameters = new BaseProviderFactory(true); - providerParameters.setProviderProperties(new HashMap<>()); - providerParameters.setClassLoaders(getClass().getClassLoader()); - providerParameters.setTestRequest(new TestRequest(null, null, null)); - providerParameters.setRunOrderParameters(new RunOrderParameters("hourly", new File(""))); - return new JUnit4Provider(providerParameters); - } - - @Test - public void testShouldCreateDescription() { - class A {} - - class B {} - - Description d = JUnit4Provider.createTestsDescription(asList(A.class, B.class)); - assertThat(d, is(notNullValue())); - assertThat(d.getDisplayName(), not(isEmptyOrNullString())); - assertThat(d.getDisplayName(), is("null")); - assertThat(d.getChildren(), hasSize(2)); - Description a = createSuiteDescription(A.class); - Description b = createSuiteDescription(B.class); - assertThat(d.getChildren(), contains(a, b)); - } -} diff --git a/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4SuiteTest.java b/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4SuiteTest.java deleted file mode 100644 index 98203f8982..0000000000 --- a/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4SuiteTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.surefire.junit4; - -import junit.framework.JUnit4TestAdapter; -import junit.framework.Test; -import junit.framework.TestCase; - -/** - * Adapt the JUnit4 tests which use only annotations to the JUnit3 test suite. - */ -public class JUnit4SuiteTest extends TestCase { - public static Test suite() { - return new JUnit4TestAdapter(JUnit4ProviderTest.class); - } -} diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml deleted file mode 100644 index db8219936e..0000000000 --- a/surefire-providers/surefire-junit47/pom.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - 4.0.0 - - - org.apache.maven.surefire - surefire-providers - 3.5.5-SNAPSHOT - - - surefire-junit47 - - Surefire JUnitCore Runner - Surefire JUnitCore (JUnit 4.7+) Runner - - - - org.apache.maven.surefire - surefire-logger-api - ${project.version} - - - org.apache.maven.surefire - common-java5 - ${project.version} - - - org.apache.maven.surefire - common-junit4 - ${project.version} - - - org.apache.maven.surefire - common-junit48 - ${project.version} - - - junit - junit - 4.8.2 - provided - - - org.apache.maven.surefire - maven-surefire-common - ${project.version} - test - - - com.github.stephenc.jcip - jcip-annotations - 1.0-1 - test - - - org.mockito - mockito-core - test - - - org.hamcrest - hamcrest - test - - - - - - - org.jacoco - jacoco-maven-plugin - - jacoco.agent - - - - jacoco-agent - - prepare-agent - - - - - - maven-surefire-plugin - - ${jvm.args.tests} ${jacoco.agent} - true - - **/JUnit47SuiteTest.java - - - - - org.apache.maven.surefire - surefire-shadefire - - - 3.5.0 - - - - - - diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java deleted file mode 100644 index 39a96b0753..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import org.junit.runners.model.RunnerScheduler; - -/** - * Since SUREFIRE 2.18 this class is deprecated. - * Use {@link org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder} instead. - * - * @author Kristian Rosenvold - */ -@Deprecated -public class AsynchronousRunner implements RunnerScheduler { - private final List> futures = Collections.synchronizedList(new ArrayList<>()); - - private final ExecutorService fService; - - public AsynchronousRunner(ExecutorService fService) { - this.fService = fService; - } - - @Override - public void schedule(final Runnable childStatement) { - futures.add(fService.submit(Executors.callable(childStatement))); - } - - @Override - public void finished() { - try { - waitForCompletion(); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } - } - - public void waitForCompletion() throws ExecutionException { - for (Future each : futures) { - try { - each.get(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java deleted file mode 100644 index d11fc7d1b0..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.Map; - -import org.apache.maven.surefire.api.report.ReporterFactory; - -/** - * @author Kristian Rosenvold - */ -@Deprecated // remove this class after StatelessXmlReporter is capable of parallel test sets processing -final class ClassesParallelRunListener extends ConcurrentRunListener { - ClassesParallelRunListener(Map classMethodCounts, ReporterFactory reporterFactory) { - super(reporterFactory, false, classMethodCounts); - } - - @Override - protected void checkIfTestSetCanBeReported(TestSet testSetForTest) { - TestSet currentlyAttached = TestSet.getThreadTestSet(); - if (currentlyAttached != null && currentlyAttached != testSetForTest) { - currentlyAttached.setAllScheduled(getRunListener()); - } - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentRunListener.java deleted file mode 100644 index cb819a052c..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentRunListener.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.Map; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.ReporterFactory; -import org.apache.maven.surefire.api.report.StackTraceWriter; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.apache.maven.surefire.api.report.TestSetReportEntry; - -import static java.lang.ThreadLocal.withInitial; -import static org.apache.maven.surefire.junitcore.TestMethod.getThreadTestMethod; - -/** - * Handles responses from concurrent junit - *
- * Stuff to remember about JUnit threading: - * parallel=classes; beforeClass/afterClass, constructor and all tests method run on same thread - * parallel=methods; beforeClass/afterClass run on main thread, constructor + each test method run on same thread - * parallel=both; same as parallel=methods - * - * @see org.apache.maven.surefire.junitcore.JUnitCoreRunListener for details about regular junit run listening - * @author Kristian Rosenvold - */ -@Deprecated // remove this class after StatelessXmlReporter is capable of parallel test sets processing -abstract class ConcurrentRunListener implements TestReportListener { - private final Map classMethodCounts; - - private final ThreadLocal> reporterManagerThreadLocal; - - private final boolean reportImmediately; - - private final ConsoleLogger logger; - - ConcurrentRunListener( - final ReporterFactory reporterFactory, boolean reportImmediately, Map classMethodCounts) { - this.reportImmediately = reportImmediately; - this.classMethodCounts = classMethodCounts; - logger = reporterFactory.createTestReportListener(); - reporterManagerThreadLocal = withInitial(reporterFactory::createTestReportListener); - } - - @Override - public void testSetStarting(TestSetReportEntry description) {} - - @Override - public void testSetCompleted(TestSetReportEntry result) { - try { - TestReportListener reporterManager = getRunListener(); - for (TestSet testSet : classMethodCounts.values()) { - testSet.replay(reporterManager); - } - } finally { - reporterManagerThreadLocal.remove(); - } - } - - @Override - public void testFailed(ReportEntry failure) { - final TestMethod testMethod = getOrCreateThreadAttachedTestMethod(failure); - if (testMethod != null) { - testMethod.testFailure(failure); - testMethod.detachFromCurrentThread(); - } - } - - @Override - public void testError(ReportEntry failure) { - final TestMethod testMethod = getOrCreateThreadAttachedTestMethod(failure); - if (testMethod != null) { - testMethod.testError(failure); - testMethod.detachFromCurrentThread(); - } - } - - @Override - public void testSkipped(ReportEntry description) { - TestSet testSet = getTestSet(description); - TestMethod testMethod = testSet.createThreadAttachedTestMethod(description); - testMethod.testIgnored(description); - testSet.incrementFinishedTests(getRunListener(), reportImmediately); - testMethod.detachFromCurrentThread(); - } - - @Override - public void testExecutionSkippedByUser() { - // cannot guarantee proper call to all listeners - getRunListener().testExecutionSkippedByUser(); - } - - @Override - public void testAssumptionFailure(ReportEntry failure) { - final TestMethod testMethod = getOrCreateThreadAttachedTestMethod(failure); - if (testMethod != null) { - testMethod.testAssumption(failure); - testMethod.detachFromCurrentThread(); - } - } - - @Override - public void testStarting(ReportEntry description) { - TestSet testSet = getTestSet(description); - testSet.createThreadAttachedTestMethod(description); - - checkIfTestSetCanBeReported(testSet); - testSet.attachToThread(); - } - - @Override - public void testSucceeded(ReportEntry report) { - TestMethod testMethod = getThreadTestMethod(); - if (testMethod != null) { - testMethod.testFinished(); - testMethod.getTestSet().incrementFinishedTests(getRunListener(), reportImmediately); - testMethod.detachFromCurrentThread(); - } - } - - private TestMethod getOrCreateThreadAttachedTestMethod(ReportEntry description) { - TestMethod threadTestMethod = getThreadTestMethod(); - if (threadTestMethod != null) { - return threadTestMethod; - } - TestSet testSet = getTestSet(description); - if (testSet == null) { - logger.warning(description.getName()); - StackTraceWriter writer = description.getStackTraceWriter(); - if (writer != null) { - logger.error(writer.writeTraceToString()); - } - return null; - } else { - return testSet.createThreadAttachedTestMethod(description); - } - } - - protected abstract void checkIfTestSetCanBeReported(TestSet testSetForTest); - - private TestSet getTestSet(ReportEntry description) { - return classMethodCounts.get(description.getSourceName()); - } - - final TestReportListener getRunListener() { - return reporterManagerThreadLocal.get(); - } - - public static ConcurrentRunListener createInstance( - Map classMethodCounts, - ReporterFactory reporterFactory, - boolean parallelClasses, - boolean parallelBoth) { - return parallelClasses - ? new ClassesParallelRunListener(classMethodCounts, reporterFactory) - : new MethodsParallelRunListener(classMethodCounts, reporterFactory, !parallelBoth); - } - - @Override - public void writeTestOutput(TestOutputReportEntry reportEntry) { - TestMethod threadTestMethod = getThreadTestMethod(); - if (threadTestMethod != null) { - LogicalStream logicalStream = threadTestMethod.getLogicalStream(); - logicalStream.write(reportEntry); - } else { - // Not able to associate output with any thread. Just dump to console - logger.info(reportEntry.getLog()); - } - } - - @Override - public boolean isDebugEnabled() { - return logger.isDebugEnabled(); - } - - @Override - public void debug(String message) { - logger.debug(message); - } - - @Override - public boolean isInfoEnabled() { - return logger.isInfoEnabled(); - } - - @Override - public void info(String message) { - logger.info(message); - } - - @Override - public boolean isWarnEnabled() { - return logger.isWarnEnabled(); - } - - @Override - public void warning(String message) { - logger.warning(message); - } - - @Override - public boolean isErrorEnabled() { - return logger.isErrorEnabled(); - } - - @Override - public void error(String message) { - logger.error(message); - } - - @Override - public void error(String message, Throwable t) { - logger.error(message, t); - } - - @Override - public void error(Throwable t) { - logger.error(t); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java deleted file mode 100644 index c74021aa9f..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; - -import org.apache.maven.surefire.api.util.internal.DaemonThreadFactory; -import org.junit.runner.Computer; -import org.junit.runner.Runner; -import org.junit.runners.ParentRunner; -import org.junit.runners.Suite; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.RunnerBuilder; -import org.junit.runners.model.RunnerScheduler; - -/** - * Since SUREFIRE 2.18 this class is deprecated. - * Use {@link org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder} instead. - * - * @author Kristian Rosenvold - */ -@Deprecated -public class ConfigurableParallelComputer extends Computer { - private static final ThreadFactory DAEMON_THREAD_FACTORY = DaemonThreadFactory.newDaemonThreadFactory(); - - private final boolean fClasses; - - private final boolean fMethods; - - private final boolean fixedPool; - - private final ExecutorService fService; - - private final List nonBlockers = Collections.synchronizedList(new ArrayList<>()); - - public ConfigurableParallelComputer() { - this(true, true, Executors.newCachedThreadPool(DAEMON_THREAD_FACTORY), false); - } - - public ConfigurableParallelComputer(boolean fClasses, boolean fMethods) { - this(fClasses, fMethods, Executors.newCachedThreadPool(DAEMON_THREAD_FACTORY), false); - } - - public ConfigurableParallelComputer(boolean fClasses, boolean fMethods, Integer numberOfThreads, boolean perCore) { - this( - fClasses, - fMethods, - Executors.newFixedThreadPool( - numberOfThreads * (perCore ? Runtime.getRuntime().availableProcessors() : 1), - DAEMON_THREAD_FACTORY), - true); - } - - private ConfigurableParallelComputer( - boolean fClasses, boolean fMethods, ExecutorService executorService, boolean fixedPool) { - this.fClasses = fClasses; - this.fMethods = fMethods; - fService = executorService; - this.fixedPool = fixedPool; - } - - @SuppressWarnings({"UnusedDeclaration"}) - public void close() throws ExecutionException { - for (AsynchronousRunner nonBlocker : nonBlockers) { - nonBlocker.waitForCompletion(); - } - - fService.shutdown(); - try { - if (!fService.awaitTermination(10, java.util.concurrent.TimeUnit.SECONDS)) { - throw new RuntimeException("Executor did not shut down within timeout"); - } - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - private Runner parallelize(Runner runner, RunnerScheduler runnerInterceptor) { - if (runner instanceof ParentRunner) { - ((ParentRunner) runner).setScheduler(runnerInterceptor); - } - return runner; - } - - private RunnerScheduler getMethodInterceptor() { - if (fClasses && fMethods) { - final AsynchronousRunner blockingAsynchronousRunner = new AsynchronousRunner(fService); - nonBlockers.add(blockingAsynchronousRunner); - return blockingAsynchronousRunner; - } - return fMethods ? new AsynchronousRunner(fService) : new SynchronousRunner(); - } - - private RunnerScheduler getClassInterceptor() { - if (fClasses) { - return fMethods ? new SynchronousRunner() : new AsynchronousRunner(fService); - } - return new SynchronousRunner(); - } - - @Override - public Runner getSuite(RunnerBuilder builder, java.lang.Class[] classes) throws InitializationError { - Runner suite = super.getSuite(builder, classes); - return fClasses ? parallelize(suite, getClassInterceptor()) : suite; - } - - @Override - protected Runner getRunner(RunnerBuilder builder, Class testClass) throws Throwable { - Runner runner = super.getRunner(builder, testClass); - return fMethods && !isTestSuite(testClass) ? parallelize(runner, getMethodInterceptor()) : runner; - } - - private boolean isTestSuite(Class testClass) { - // Todo: Find out how/if this is enough - final Suite.SuiteClasses annotation = testClass.getAnnotation(Suite.SuiteClasses.class); - return (annotation != null); - } - - @Override - public String toString() { - return "ConfigurableParallelComputer{" + "classes=" + fClasses + ", methods=" + fMethods + ", fixedPool=" - + fixedPool + '}'; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/FilteringRequest.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/FilteringRequest.java deleted file mode 100644 index 96b410a6e9..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/FilteringRequest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.surefire.junitcore; - -import org.junit.runner.Request; -import org.junit.runner.Runner; -import org.junit.runner.manipulation.Filter; -import org.junit.runner.manipulation.NoTestsRemainException; - -/** - * Moved nested class from {@link JUnitCoreWrapper}. - */ -final class FilteringRequest extends Request { - private Runner filteredRunner; - - FilteringRequest(Request req, Filter filter) { - try { - Runner runner = req.getRunner(); - filter.apply(runner); - filteredRunner = runner; - } catch (NoTestsRemainException e) { - filteredRunner = null; - } - } - - @Override - public Runner getRunner() { - return filteredRunner; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCore.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCore.java deleted file mode 100644 index d4101ce8a0..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCore.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.surefire.junitcore; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.common.junit4.Notifier; -import org.junit.runner.Result; -import org.junit.runner.Runner; -import org.junit.runner.notification.RunListener; - -/** - * JUnitCore solves bugs in original junit class {@link org.junit.runner.JUnitCore}.

- * The notifier method {@link org.junit.runner.notification.RunNotifier#fireTestRunFinished} - * is called anyway in finally block. - * - * @author Tibor Digana (tibor17) - * @since 2.19 - * @see JUnit issue 1186 - */ -class JUnitCore { - private final Notifier notifier; - - JUnitCore(Notifier notifier) { - this.notifier = notifier; - } - - Result run(Runner runner) throws TestSetFailedException { - Result result = new Result(); - RunListener listener = result.createListener(); - notifier.addFirstListener(listener); - try { - notifier.fireTestRunStarted(runner.getDescription()); - runner.run(notifier); - } catch (Throwable e) { - afterException(e); - } finally { - notifier.fireTestRunFinished(result); - notifier.removeListener(listener); - afterFinished(); - } - return result; - } - - protected void afterException(Throwable e) throws TestSetFailedException { - throw new TestSetFailedException(e); - } - - protected void afterFinished() {} -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java deleted file mode 100644 index 51eea78d40..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -import org.apache.maven.surefire.api.booter.ProviderParameterNames; - -/** - * @author Kristian Rosenvold - */ -public final class JUnitCoreParameters { - public static final String PARALLEL_KEY = ProviderParameterNames.PARALLEL_PROP; - - public static final String PERCORETHREADCOUNT_KEY = "perCoreThreadCount"; - - public static final String THREADCOUNT_KEY = ProviderParameterNames.THREADCOUNT_PROP; - - public static final String THREADCOUNTSUITES_KEY = ProviderParameterNames.THREADCOUNTSUITES_PROP; - - public static final String THREADCOUNTCLASSES_KEY = ProviderParameterNames.THREADCOUNTCLASSES_PROP; - - public static final String THREADCOUNTMETHODS_KEY = ProviderParameterNames.THREADCOUNTMETHODS_PROP; - - public static final String USEUNLIMITEDTHREADS_KEY = "useUnlimitedThreads"; - - public static final String PARALLEL_TIMEOUT_KEY = ProviderParameterNames.PARALLEL_TIMEOUT_PROP; - - public static final String PARALLEL_TIMEOUTFORCED_KEY = ProviderParameterNames.PARALLEL_TIMEOUTFORCED_PROP; - - public static final String PARALLEL_OPTIMIZE_KEY = ProviderParameterNames.PARALLEL_OPTIMIZE_PROP; - - public static final String ENABLE_OUT_ERR_ELEMENTS_KEY = ProviderParameterNames.ENABLE_OUT_ERR_ELEMENTS_PROP; - - public static final String ENABLE_PROPERTIES_ELEMENT_KEY = ProviderParameterNames.ENABLE_PROPERTIES_ELEMENT_PROP; - - private final String parallel; - - private final boolean perCoreThreadCount; - - private final int threadCount; - - private final int threadCountSuites; - - private final int threadCountClasses; - - private final int threadCountMethods; - - private final double parallelTestsTimeoutInSeconds; - - private final double parallelTestsTimeoutForcedInSeconds; - - private final boolean useUnlimitedThreads; - - private final boolean parallelOptimization; - - private final boolean enableOutErrElements; - - private final boolean enablePropertiesElement; - - public JUnitCoreParameters(Map properties) { - parallel = property(properties, PARALLEL_KEY, "none").toLowerCase(); - perCoreThreadCount = property(properties, PERCORETHREADCOUNT_KEY, true); - threadCount = property(properties, THREADCOUNT_KEY, 0); - threadCountMethods = property(properties, THREADCOUNTMETHODS_KEY, 0); - threadCountClasses = property(properties, THREADCOUNTCLASSES_KEY, 0); - threadCountSuites = property(properties, THREADCOUNTSUITES_KEY, 0); - useUnlimitedThreads = property(properties, USEUNLIMITEDTHREADS_KEY, false); - parallelTestsTimeoutInSeconds = Math.max(property(properties, PARALLEL_TIMEOUT_KEY, 0d), 0); - parallelTestsTimeoutForcedInSeconds = Math.max(property(properties, PARALLEL_TIMEOUTFORCED_KEY, 0d), 0); - parallelOptimization = property(properties, PARALLEL_OPTIMIZE_KEY, true); - enableOutErrElements = property(properties, ENABLE_OUT_ERR_ELEMENTS_KEY, true); - enablePropertiesElement = property(properties, ENABLE_PROPERTIES_ELEMENT_KEY, true); - } - - private static Collection lowerCase(String... elements) { - ArrayList lowerCase = new ArrayList<>(); - for (String element : elements) { - lowerCase.add(element.toLowerCase()); - } - return lowerCase; - } - - private boolean isAllParallel() { - return "all".equals(parallel); - } - - public boolean isParallelMethods() { - return isAllParallel() - || lowerCase("both", "methods", "suitesAndMethods", "classesAndMethods") - .contains(parallel); - } - - public boolean isParallelClasses() { - return isAllParallel() - || lowerCase("both", "classes", "suitesAndClasses", "classesAndMethods") - .contains(parallel); - } - - public boolean isParallelSuites() { - return isAllParallel() - || lowerCase("suites", "suitesAndClasses", "suitesAndMethods").contains(parallel); - } - - /** - * @deprecated Instead use the expression isParallelMethods() && isParallelClasses(). - * @return {@code true} if classes and methods are both parallel - */ - @Deprecated - @SuppressWarnings("unused") - public boolean isParallelBoth() { - return isParallelMethods() && isParallelClasses(); - } - - public boolean isPerCoreThreadCount() { - return perCoreThreadCount; - } - - public int getThreadCount() { - return threadCount; - } - - public int getThreadCountMethods() { - return threadCountMethods; - } - - public int getThreadCountClasses() { - return threadCountClasses; - } - - public int getThreadCountSuites() { - return threadCountSuites; - } - - public boolean isUseUnlimitedThreads() { - return useUnlimitedThreads; - } - - public double getParallelTestsTimeoutInSeconds() { - return parallelTestsTimeoutInSeconds; - } - - public double getParallelTestsTimeoutForcedInSeconds() { - return parallelTestsTimeoutForcedInSeconds; - } - - public boolean isNoThreading() { - return !isParallelismSelected(); - } - - public boolean isParallelismSelected() { - return isParallelSuites() || isParallelClasses() || isParallelMethods(); - } - - public boolean isParallelOptimization() { - return parallelOptimization; - } - - public boolean isEnableOutErrElements() { - return enableOutErrElements; - } - - public boolean isEnablePropertiesElement() { - return enablePropertiesElement; - } - - @Override - public String toString() { - return "parallel='" + parallel + '\'' + ", perCoreThreadCount=" + perCoreThreadCount + ", threadCount=" - + threadCount + ", useUnlimitedThreads=" + useUnlimitedThreads + ", threadCountSuites=" - + threadCountSuites - + ", threadCountClasses=" + threadCountClasses + ", threadCountMethods=" + threadCountMethods - + ", parallelOptimization=" + parallelOptimization - + ", enableOutErrElements=" + enableOutErrElements - + ", enablePropertiesElement=" + enablePropertiesElement; - } - - private static boolean property(Map properties, String key, boolean fallback) { - return properties.containsKey(key) ? Boolean.valueOf(properties.get(key)) : fallback; - } - - private static String property(Map properties, String key, String fallback) { - return properties.containsKey(key) ? properties.get(key) : fallback; - } - - private static int property(Map properties, String key, int fallback) { - return properties.containsKey(key) ? Integer.valueOf(properties.get(key)) : fallback; - } - - private static double property(Map properties, String key, double fallback) { - return properties.containsKey(key) ? Double.valueOf(properties.get(key)) : fallback; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java deleted file mode 100644 index f2f58fe815..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.apache.maven.surefire.api.booter.Command; -import org.apache.maven.surefire.api.provider.AbstractProvider; -import org.apache.maven.surefire.api.provider.CommandChainReader; -import org.apache.maven.surefire.api.provider.CommandListener; -import org.apache.maven.surefire.api.provider.ProviderParameters; -import org.apache.maven.surefire.api.report.ReporterFactory; -import org.apache.maven.surefire.api.suite.RunResult; -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.api.util.RunOrderCalculator; -import org.apache.maven.surefire.api.util.ScanResult; -import org.apache.maven.surefire.api.util.ScannerFilter; -import org.apache.maven.surefire.api.util.TestsToRun; -import org.apache.maven.surefire.common.junit4.JUnit4RunListener; -import org.apache.maven.surefire.common.junit4.JUnitTestFailureListener; -import org.apache.maven.surefire.common.junit4.Notifier; -import org.apache.maven.surefire.common.junit48.FilterFactory; -import org.apache.maven.surefire.common.junit48.JUnit48Reflector; -import org.apache.maven.surefire.common.junit48.JUnit48TestChecker; -import org.junit.runner.Description; -import org.junit.runner.manipulation.Filter; - -import static org.apache.maven.surefire.api.report.ConsoleOutputCapture.startCapture; -import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; -import static org.apache.maven.surefire.api.report.RunMode.RERUN_TEST_AFTER_FAILURE; -import static org.apache.maven.surefire.api.testset.TestListResolver.optionallyWildcardFilter; -import static org.apache.maven.surefire.api.util.TestsToRun.fromClass; -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.generateFailingTestDescriptions; -import static org.apache.maven.surefire.common.junit4.JUnit4RunListenerFactory.createCustomListeners; -import static org.apache.maven.surefire.common.junit4.Notifier.pureNotifier; -import static org.apache.maven.surefire.junitcore.ConcurrentRunListener.createInstance; - -/** - * @author Kristian Rosenvold - */ -@SuppressWarnings({"UnusedDeclaration"}) -public class JUnitCoreProvider extends AbstractProvider { - private final ClassLoader testClassLoader; - - private final JUnitCoreParameters jUnitCoreParameters; - - private final ScannerFilter scannerFilter; - - private final String customRunListeners; - - private final ProviderParameters providerParameters; - - private final ScanResult scanResult; - - private final int rerunFailingTestsCount; - - private final JUnit48Reflector jUnit48Reflector; - - private final RunOrderCalculator runOrderCalculator; - - private final TestListResolver testResolver; - - private final CommandChainReader commandsReader; - - private TestsToRun testsToRun; - - public JUnitCoreProvider(ProviderParameters bootParams) { - // don't start a thread in CommandReader while we are in in-plugin process - commandsReader = bootParams.isInsideFork() ? bootParams.getCommandReader() : null; - providerParameters = bootParams; - testClassLoader = bootParams.getTestClassLoader(); - scanResult = bootParams.getScanResult(); - runOrderCalculator = bootParams.getRunOrderCalculator(); - jUnitCoreParameters = new JUnitCoreParameters(bootParams.getProviderProperties()); - scannerFilter = new JUnit48TestChecker(testClassLoader); - testResolver = bootParams.getTestRequest().getTestListResolver(); - rerunFailingTestsCount = bootParams.getTestRequest().getRerunFailingTestsCount(); - customRunListeners = bootParams.getProviderProperties().get("listener"); - jUnit48Reflector = new JUnit48Reflector(testClassLoader); - } - - @Override - public Iterable> getSuites() { - testsToRun = scanClassPath(); - return testsToRun; - } - - private boolean isSingleThreaded() { - return jUnitCoreParameters.isNoThreading(); - } - - @Override - public RunResult invoke(Object forkTestSet) throws TestSetFailedException { - ReporterFactory reporterFactory = providerParameters.getReporterFactory(); - JUnit4RunListener listener = createRunListener(reporterFactory); - listener.setRunMode(NORMAL_RUN); - ConsoleLogger logger = listener.getConsoleLogger(); - Notifier notifier = new Notifier(listener, getSkipAfterFailureCount()); - // startCapture() called in createRunListener() in prior to setTestsToRun() - - Filter filter = jUnit48Reflector.isJUnit48Available() ? createJUnit48Filter() : null; - - if (testsToRun == null) { - setTestsToRun(forkTestSet); - } - - // Add test failure listener - JUnitTestFailureListener testFailureListener = new JUnitTestFailureListener(); - notifier.addListener(testFailureListener); - - if (isFailFast() && commandsReader != null) { - registerPleaseStopJUnitListener(notifier); - } - - final RunResult runResult; - - try { - JUnitCoreWrapper core = new JUnitCoreWrapper(notifier, jUnitCoreParameters, logger); - - if (commandsReader != null) { - registerShutdownListener(testsToRun); - commandsReader.awaitStarted(); - } - - notifier.asFailFast(isFailFast()); - core.execute(testsToRun, createCustomListeners(customRunListeners), filter); - notifier.asFailFast(false); - - // Rerun failing tests if rerunFailingTestsCount is larger than 0 - if (isRerunFailingTests()) { - listener.setRunMode(RERUN_TEST_AFTER_FAILURE); - Notifier rerunNotifier = pureNotifier(); - notifier.copyListenersTo(rerunNotifier); - JUnitCoreWrapper rerunCore = new JUnitCoreWrapper(rerunNotifier, jUnitCoreParameters, logger); - for (int i = 0; - i < rerunFailingTestsCount - && !testFailureListener.getAllFailures().isEmpty(); - i++) { - Set failures = generateFailingTestDescriptions(testFailureListener.getAllFailures()); - testFailureListener.reset(); - FilterFactory filterFactory = new FilterFactory(testClassLoader); - Filter failureDescriptionFilter = filterFactory.createMatchAnyDescriptionFilter(failures); - rerunCore.execute(testsToRun, failureDescriptionFilter); - } - } - } finally { - runResult = reporterFactory.close(); - notifier.removeListeners(); - } - return runResult; - } - - private void setTestsToRun(Object forkTestSet) throws TestSetFailedException { - if (forkTestSet instanceof TestsToRun) { - testsToRun = (TestsToRun) forkTestSet; - } else if (forkTestSet instanceof Class) { - Class theClass = (Class) forkTestSet; - testsToRun = fromClass(theClass); - } else { - testsToRun = scanClassPath(); - } - } - - private boolean isRerunFailingTests() { - return rerunFailingTestsCount > 0; - } - - private boolean isFailFast() { - return providerParameters.getSkipAfterFailureCount() > 0; - } - - private int getSkipAfterFailureCount() { - return isFailFast() ? providerParameters.getSkipAfterFailureCount() : 0; - } - - private void registerShutdownListener(final TestsToRun testsToRun) { - commandsReader.addShutdownListener(new CommandListener() { - @Override - public void update(Command command) { - testsToRun.markTestSetFinished(); - } - }); - } - - private void registerPleaseStopJUnitListener(final Notifier stoppable) { - commandsReader.addSkipNextTestsListener(new CommandListener() { - @Override - public void update(Command command) { - stoppable.pleaseStop(); - } - }); - } - - private JUnit4RunListener createRunListener(ReporterFactory reporterFactory) { - final JUnit4RunListener listener; - if (isSingleThreaded()) { - listener = new NonConcurrentRunListener(reporterFactory.createTestReportListener()); - } else { - Map testSetMap = new ConcurrentHashMap<>(); - boolean parallelClasses = isParallelTypes(); - boolean parallelBoth = isParallelMethodsAndTypes(); - ConcurrentRunListener concurrentListener = - createInstance(testSetMap, reporterFactory, parallelClasses, parallelBoth); - listener = new JUnitCoreRunListener(concurrentListener, testSetMap); - } - - startCapture(listener); - return listener; - } - - private boolean isParallelMethodsAndTypes() { - return jUnitCoreParameters.isParallelMethods() && isParallelTypes(); - } - - private boolean isParallelTypes() { - return jUnitCoreParameters.isParallelClasses() || jUnitCoreParameters.isParallelSuites(); - } - - private Filter createJUnit48Filter() { - final FilterFactory factory = new FilterFactory(testClassLoader); - Map props = providerParameters.getProviderProperties(); - Filter groupFilter = factory.canCreateGroupFilter(props) ? factory.createGroupFilter(props) : null; - TestListResolver methodFilter = optionallyWildcardFilter(testResolver); - boolean onlyGroups = methodFilter.isEmpty() || methodFilter.isWildcard(); - if (onlyGroups) { - return groupFilter; - } else { - Filter jUnitMethodFilter = factory.createMethodFilter(methodFilter); - return groupFilter == null ? jUnitMethodFilter : factory.and(groupFilter, jUnitMethodFilter); - } - } - - private TestsToRun scanClassPath() { - TestsToRun scanned = scanResult.applyFilter(scannerFilter, testClassLoader); - return runOrderCalculator.orderTestClasses(scanned); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java deleted file mode 100644 index 31a939f401..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.Map; - -import org.apache.maven.surefire.api.report.StackTraceWriter; -import org.apache.maven.surefire.common.junit4.JUnit4RunListener; -import org.apache.maven.surefire.common.junit4.JUnit4StackTraceWriter; -import org.junit.runner.Description; -import org.junit.runner.Result; -import org.junit.runner.notification.Failure; - -import static org.apache.maven.surefire.api.util.internal.TestClassMethodNameUtils.extractClassName; - -/** - * Noteworthy things about JUnit4 listening: - *
- * A class that is annotated with @Ignore will have one invocation of "testSkipped" with source==name - * A method that is annotated with @Ignore will have a invocation of testSkipped with source and name distinct - * Methods annotated with @Ignore trigger no further events. - * - * @see org.apache.maven.surefire.junitcore.ConcurrentRunListener for details about parallel running - */ -final class JUnitCoreRunListener extends JUnit4RunListener { - private final Map classMethodCounts; - - /** - * @param reporter the report manager to log testing events to - * @param classMethodCounts A map of methods - */ - JUnitCoreRunListener(ConcurrentRunListener reporter, Map classMethodCounts) { - super(reporter); - this.classMethodCounts = classMethodCounts; - } - - /** - * Called right before any tests from a specific class are run. - * - * @see org.junit.runner.notification.RunListener#testRunStarted(org.junit.runner.Description) - */ - @Override - public void testRunStarted(Description description) throws Exception { - fillTestCountMap(description); - reporter.testSetStarting(null); // Not entirely meaningful as we can see - } - - @Override - public void testRunFinished(Result result) throws Exception { - try { - reporter.testSetCompleted(null); - } finally { - classMethodCounts.clear(); - } - } - - private void fillTestCountMap(Description testDesc) { - for (Description child : testDesc.getChildren()) { - if (!asTestLeaf(child)) { - fillTestCountMap(child); - } - } - } - - private boolean asTestLeaf(Description description) { - if (description.isTest()) { - final String testClassName = extractClassName(description.getDisplayName()); - if (testClassName != null) { - final TestSet testSet; - if (classMethodCounts.containsKey(testClassName)) { - testSet = classMethodCounts.get(testClassName); - } else { - testSet = new TestSet(testClassName, getRunMode(), classMethodIndexer); - classMethodCounts.put(testClassName, testSet); - } - testSet.incrementTestMethodCount(); - } - return true; - } else { - return false; - } - } - - @Override - protected StackTraceWriter createStackTraceWriter(Failure failure) { - return new JUnit4StackTraceWriter(failure); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java deleted file mode 100644 index 96fc928fa8..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.Queue; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.api.util.TestsToRun; -import org.apache.maven.surefire.common.junit4.Notifier; -import org.apache.maven.surefire.junitcore.pc.ParallelComputer; -import org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder; -import org.junit.Ignore; -import org.junit.runner.Computer; -import org.junit.runner.Description; -import org.junit.runner.Request; -import org.junit.runner.Result; -import org.junit.runner.manipulation.Filter; -import org.junit.runner.notification.RunListener; -import org.junit.runner.notification.StoppedByUserException; - -import static org.apache.maven.surefire.common.junit4.JUnit4Reflector.createDescription; -import static org.apache.maven.surefire.common.junit4.JUnit4Reflector.createIgnored; -import static org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures; -import static org.junit.runner.Computer.serial; -import static org.junit.runner.Request.classes; - -/** - * Encapsulates access to JUnitCore - * - * @author Kristian Rosenvold - */ -final class JUnitCoreWrapper { - private final Notifier notifier; - private final JUnitCoreParameters jUnitCoreParameters; - private final ConsoleLogger consoleStream; - - JUnitCoreWrapper(Notifier notifier, JUnitCoreParameters jUnitCoreParameters, ConsoleLogger consoleStream) { - this.notifier = notifier; - this.jUnitCoreParameters = jUnitCoreParameters; - this.consoleStream = consoleStream; - } - - void execute(TestsToRun testsToRun, Filter filter) throws TestSetFailedException { - execute(testsToRun, true, Collections.emptyList(), filter); - } - - void execute(TestsToRun testsToRun, Collection listeners, Filter filter) - throws TestSetFailedException { - execute(testsToRun, false, listeners, filter); - } - - private void execute(TestsToRun testsToRun, boolean useIterated, Collection listeners, Filter filter) - throws TestSetFailedException { - if (testsToRun.allowEagerReading()) { - executeEager(testsToRun, filter, listeners); - } else { - executeLazy(testsToRun, useIterated, filter, listeners); - } - } - - private JUnitCore createJUnitCore(Notifier notifier, Collection listeners) { - JUnitCore junitCore = new JUnitCore(); - - // custom listeners added last - notifier.addListeners(listeners); - - return junitCore; - } - - private void executeEager(TestsToRun testsToRun, Filter filter, Collection listeners) - throws TestSetFailedException { - JUnitCore junitCore = createJUnitCore(notifier, listeners); - Class[] tests = testsToRun.getLocatedClasses(); - Computer computer = createComputer(); - createRequestAndRun(filter, computer, junitCore.withReportedTests(tests), tests); - } - - private void executeLazy( - TestsToRun testsToRun, boolean useIterated, Filter filter, Collection listeners) - throws TestSetFailedException { - JUnitCore junitCore = createJUnitCore(notifier, listeners); - for (Iterator> it = useIterated ? testsToRun.iterated() : testsToRun.iterator(); it.hasNext(); ) { - Class clazz = it.next(); - Computer computer = createComputer(); - createRequestAndRun(filter, computer, junitCore.withReportedTests(clazz), clazz); - } - } - - private void createRequestAndRun(Filter filter, Computer computer, JUnitCore junitCore, Class... classesToRun) - throws TestSetFailedException { - Request req = classes(computer, classesToRun); - if (filter != null) { - req = new FilteringRequest(req, filter); - if (req.getRunner() == null) { - // nothing to run - return; - } - } - - Result run = junitCore.run(req.getRunner()); - rethrowAnyTestMechanismFailures(run); - - if (computer instanceof ParallelComputer) { - String timeoutMessage = ((ParallelComputer) computer).describeElapsedTimeout(); - if (!timeoutMessage.isEmpty()) { - throw new TestSetFailedException(timeoutMessage); - } - } - } - - private Computer createComputer() { - return jUnitCoreParameters.isNoThreading() - ? serial() - : new ParallelComputerBuilder(consoleStream, jUnitCoreParameters).buildComputer(); - } - - private final class JUnitCore extends org.apache.maven.surefire.junitcore.JUnitCore { - JUnitCore() { - super(JUnitCoreWrapper.this.notifier); - } - - JUnitCore withReportedTests(Class... tests) { - Queue stoppedTests = JUnitCoreWrapper.this.notifier.getRemainingTestClasses(); - if (stoppedTests != null) { - for (Class test : tests) { - stoppedTests.add(test.getName()); - } - } - return this; - } - - @Override - @SuppressWarnings("checkstyle:innerassignment") - protected void afterException(Throwable e) throws TestSetFailedException { - if (JUnitCoreWrapper.this.notifier.isFailFast() && e instanceof StoppedByUserException) { - Queue stoppedTests = JUnitCoreWrapper.this.notifier.getRemainingTestClasses(); - if (stoppedTests != null) { - String reason = e.getClass().getName(); - Ignore reasonForSkippedTest = createIgnored(reason); - for (String clazz; (clazz = stoppedTests.poll()) != null; ) { - Description skippedTest = createDescription(clazz, reasonForSkippedTest); - JUnitCoreWrapper.this.notifier.fireTestIgnored(skippedTest); - } - } - } else { - super.afterException(e); - } - } - - @Override - protected void afterFinished() { - Queue stoppedTests = JUnitCoreWrapper.this.notifier.getRemainingTestClasses(); - if (stoppedTests != null) { - stoppedTests.clear(); - } - } - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java deleted file mode 100644 index a4846be6d2..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; - -import org.apache.maven.surefire.api.report.TestOutputReceiver; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; - -/** - * A stream-like object that preserves ordering between stdout/stderr - */ -@Deprecated // remove this class after StatelessXmlReporter is capable of parallel test sets processing -final class LogicalStream { - private final Queue output = new ConcurrentLinkedQueue<>(); - - synchronized void write(TestOutputReportEntry reportEntry) { - output.add(reportEntry); - } - - void writeDetails(TestOutputReceiver outputReceiver) { - for (TestOutputReportEntry entry = output.poll(); entry != null; entry = output.poll()) { - outputReceiver.writeTestOutput(entry); - } - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java deleted file mode 100644 index f157a35f13..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.Map; - -import org.apache.maven.surefire.api.report.ReporterFactory; - -/** - * @author Kristian Rosenvold - */ -@Deprecated // remove this class after StatelessXmlReporter is capable of parallel test sets processing -final class MethodsParallelRunListener extends ConcurrentRunListener { - private volatile TestSet lastStarted; - - private final Object lock = new Object(); - - MethodsParallelRunListener( - Map classMethodCounts, ReporterFactory reporterFactory, boolean reportImmediately) { - super(reporterFactory, reportImmediately, classMethodCounts); - } - - @Override - protected void checkIfTestSetCanBeReported(TestSet testSetForTest) { - synchronized (lock) { - if (testSetForTest != lastStarted) { - if (lastStarted != null) { - lastStarted.setAllScheduled(getRunListener()); - } - lastStarted = testSetForTest; - } - } - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java deleted file mode 100644 index 0959aaa136..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.Collections; -import java.util.Map; - -import org.apache.maven.surefire.api.report.SimpleReportEntry; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.apache.maven.surefire.api.report.TestSetReportEntry; -import org.apache.maven.surefire.api.util.internal.ClassMethod; -import org.apache.maven.surefire.common.junit4.JUnit4RunListener; -import org.junit.runner.Description; -import org.junit.runner.Result; -import org.junit.runner.notification.Failure; - -import static org.apache.maven.surefire.api.util.internal.ObjectUtils.systemProps; -import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.toClassMethod; - -/** - * A class to be used when there is no JUnit parallelism (methods or/and class). This allows to workaround JUnit - * limitation a la Junit4 provider. Specifically, we can redirect properly the output even if we don't have class - * demarcation in JUnit. It works when if there is a JVM instance per test run, i.e. with reuseForks=false and - * forkCount greater than one. - */ -@Deprecated // remove this class after StatelessXmlReporter is capable of parallel test sets processing -class NonConcurrentRunListener extends JUnit4RunListener { - private Description currentTestSetDescription; - - private Description lastFinishedDescription; - - NonConcurrentRunListener(TestReportListener reporter) { - super(reporter); - } - - private TestSetReportEntry createReportEntryForTestSet(Description description, Map systemProps) { - ClassMethod classMethod = toClassMethod(description); - String className = classMethod.getClazz(); - String methodName = classMethod.getMethod(); - long testRunId = classMethodIndexer.indexClassMethod(className, methodName); - return new SimpleReportEntry(getRunMode(), testRunId, className, null, null, null, systemProps); - } - - private TestSetReportEntry createTestSetReportEntryStarted(Description description) { - return createReportEntryForTestSet(description, Collections.emptyMap()); - } - - private TestSetReportEntry createTestSetReportEntryFinished(Description description) { - return createReportEntryForTestSet(description, systemProps()); - } - - @Override - public void testStarted(Description description) throws Exception { - finishLastTestSetIfNecessary(description); - super.testStarted(description); - } - - private void finishLastTestSetIfNecessary(Description description) { - if (describesNewTestSet(description)) { - currentTestSetDescription = description; - if (lastFinishedDescription != null) { - reporter.testSetCompleted(createTestSetReportEntryFinished(lastFinishedDescription)); - lastFinishedDescription = null; - } - reporter.testSetStarting(createTestSetReportEntryStarted(description)); - } - } - - private boolean describesNewTestSet(Description description) { - if (currentTestSetDescription != null) { - if (null != description.getTestClass()) { - return !description.getTestClass().equals(currentTestSetDescription.getTestClass()); - } else if (description.isSuite()) { - return description.getChildren().equals(currentTestSetDescription.getChildren()); - } - - return false; - } - - return true; - } - - @Override - public void testFinished(Description description) throws Exception { - super.testFinished(description); - lastFinishedDescription = description; - } - - @Override - public void testIgnored(Description description) throws Exception { - finishLastTestSetIfNecessary(description); - - super.testIgnored(description); - lastFinishedDescription = description; - } - - @Override - public void testFailure(Failure failure) throws Exception { - finishLastTestSetIfNecessary(failure.getDescription()); - - super.testFailure(failure); - lastFinishedDescription = failure.getDescription(); - } - - @Override - public void testAssumptionFailure(Failure failure) { - finishLastTestSetIfNecessary(failure.getDescription()); - - super.testAssumptionFailure(failure); - lastFinishedDescription = failure.getDescription(); - } - - @Override - public void testRunStarted(Description description) throws Exception {} - - @Override - public void testRunFinished(Result result) throws Exception { - if (lastFinishedDescription != null) { - reporter.testSetCompleted(createTestSetReportEntryFinished(lastFinishedDescription)); - lastFinishedDescription = null; - } - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java deleted file mode 100644 index 6d57ce864d..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.surefire.junitcore; - -import org.junit.runners.model.RunnerScheduler; - -/** - * Since SUREFIRE 2.18 this class is deprecated. - * Use {@link org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder} instead. - * - * @author Kristian Rosenvold - */ -@Deprecated -class SynchronousRunner implements RunnerScheduler { - @Override - public void schedule(final Runnable childStatement) { - childStatement.run(); - } - - @Override - public void finished() {} -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java deleted file mode 100644 index cdff242e8f..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.maven.surefire.api.report.CategorizedReportEntry; -import org.apache.maven.surefire.api.report.ConsoleOutputReceiverForCurrentThread; -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.TestOutputReceiver; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; - -/** - * Represents the test-state of a single test method that is run. - *
- * Notes about thread safety: This instance is serially confined to 1-3 threads (construction, test-run, reporting), - * without any actual parallel access - */ -@Deprecated // remove this class after StatelessXmlReporter is capable of parallel test sets processing -class TestMethod implements TestOutputReceiver { - private static final InheritableThreadLocal TEST_METHOD = new InheritableThreadLocal<>(); - - private final AtomicReference output = new AtomicReference<>(); - - private final ReportEntry description; - - private final TestSet testSet; - - private final long startTime; - - private volatile long endTime; - - private volatile ReportEntry testFailure; - - private volatile ReportEntry testError; - - private volatile ReportEntry testIgnored; - - private volatile ReportEntry testAssumption; - - TestMethod(ReportEntry description, TestSet testSet) { - this.description = description; - this.testSet = testSet; - startTime = System.currentTimeMillis(); - } - - void testFinished() { - setEndTime(); - } - - void testIgnored(ReportEntry description) { - testIgnored = description; - setEndTime(); - } - - void testFailure(ReportEntry failure) { - this.testFailure = failure; - setEndTime(); - } - - void testError(ReportEntry failure) { - this.testError = failure; - setEndTime(); - } - - void testAssumption(ReportEntry failure) { - this.testAssumption = failure; - setEndTime(); - } - - private void setEndTime() { - this.endTime = System.currentTimeMillis(); - } - - int getElapsed() { - return endTime > 0 ? (int) (endTime - startTime) : 0; - } - - long getStartTime() { - return startTime; - } - - long getEndTime() { - return endTime; - } - - void replay(TestReportListener reporter) { - if (testIgnored != null) { - reporter.testSkipped(createReportEntry(testIgnored)); - } else { - ReportEntry descriptionReport = createReportEntry(description); - reporter.testStarting(descriptionReport); - LogicalStream ls = output.get(); - if (ls != null) { - ls.writeDetails(reporter); - } - - if (testFailure != null) { - reporter.testFailed(createReportEntry(testFailure)); - } else if (testError != null) { - reporter.testError(createReportEntry(testError)); - } else if (testAssumption != null) { - reporter.testAssumptionFailure(createReportEntry(testAssumption)); - } else { - reporter.testSucceeded(descriptionReport); - } - } - } - - private ReportEntry createReportEntry(ReportEntry reportEntry) { - return new CategorizedReportEntry( - reportEntry.getRunMode(), - reportEntry.getTestRunId(), - reportEntry.getSourceName(), - reportEntry.getName(), - reportEntry.getGroup(), - reportEntry.getStackTraceWriter(), - getElapsed(), - reportEntry.getMessage()); - } - - void attachToThread() { - TEST_METHOD.set(this); - ConsoleOutputReceiverForCurrentThread.set(this); - } - - void detachFromCurrentThread() { - TEST_METHOD.remove(); - ConsoleOutputReceiverForCurrentThread.remove(); - } - - static TestMethod getThreadTestMethod() { - return TEST_METHOD.get(); - } - - LogicalStream getLogicalStream() { - LogicalStream ls = output.get(); - if (ls == null) { - ls = new LogicalStream(); - if (!output.compareAndSet(null, ls)) { - ls = output.get(); - } - } - return ls; - } - - @Override - public void writeTestOutput(TestOutputReportEntry reportEntry) { - getLogicalStream().write(reportEntry); - } - - TestSet getTestSet() { - return testSet; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java deleted file mode 100644 index 3d7bebf726..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.RunMode; -import org.apache.maven.surefire.api.report.SimpleReportEntry; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.apache.maven.surefire.api.report.TestSetReportEntry; -import org.apache.maven.surefire.report.ClassMethodIndexer; - -import static org.apache.maven.surefire.api.util.internal.ObjectUtils.systemProps; - -/** - * * Represents the test-state of a testset that is run. - */ -@Deprecated // remove this class after StatelessXmlReporter is capable of parallel test sets processing -public class TestSet { - private static final InheritableThreadLocal TEST_SET = new InheritableThreadLocal<>(); - - private final String testClassName; - - private final Collection testMethods = new ConcurrentLinkedQueue<>(); - - private final AtomicBoolean played = new AtomicBoolean(); - - private final AtomicInteger numberOfCompletedChildren = new AtomicInteger(); - - // While the two parameters may seem duplicated, it is not entirely the case, - // since numberOfTests has the correct value from the start, while testMethods grows as method execution starts. - - private final AtomicInteger numberOfTests = new AtomicInteger(); - - private final RunMode runMode; - - private final ClassMethodIndexer classMethodIndexer; - - private volatile boolean allScheduled; - - public TestSet(String testClassName, RunMode runMode, ClassMethodIndexer classMethodIndexer) { - this.testClassName = testClassName; - this.runMode = runMode; - this.classMethodIndexer = classMethodIndexer; - } - - final RunMode getRunMode() { - return runMode; - } - - final ClassMethodIndexer getClassMethodIndexer() { - return classMethodIndexer; - } - - public void replay(TestReportListener target) { - if (played.compareAndSet(false, true)) { - try { - TestSetReportEntry report = createReportEntryStarted(); - - target.testSetStarting(report); - - long startTime = 0; - long endTime = 0; - for (TestMethod testMethod : testMethods) { - if (startTime == 0 || testMethod.getStartTime() < startTime) { - startTime = testMethod.getStartTime(); - } - - if (endTime == 0 || testMethod.getEndTime() > endTime) { - endTime = testMethod.getEndTime(); - } - - testMethod.replay(target); - } - - int elapsed = (int) (endTime - startTime); - - report = createReportEntryCompleted(elapsed); - - target.testSetCompleted(report); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - public TestMethod createThreadAttachedTestMethod(ReportEntry description) { - TestMethod testMethod = new TestMethod(description, this); - addTestMethod(testMethod); - testMethod.attachToThread(); - return testMethod; - } - - private TestSetReportEntry createReportEntryStarted() { - return createReportEntry(null, Collections.emptyMap()); - } - - private TestSetReportEntry createReportEntryCompleted(int elapsed) { - return createReportEntry(elapsed, systemProps()); - } - - private TestSetReportEntry createReportEntry(Integer elapsed, Map systemProps) { - return new SimpleReportEntry( - runMode, - classMethodIndexer.indexClass(testClassName), - testClassName, - null, - testClassName, - null, - null, - elapsed, - systemProps); - } - - public void incrementTestMethodCount() { - numberOfTests.incrementAndGet(); - } - - private void addTestMethod(TestMethod testMethod) { - testMethods.add(testMethod); - } - - public void incrementFinishedTests(TestReportListener reporterManager, boolean reportImmediately) { - numberOfCompletedChildren.incrementAndGet(); - if (allScheduled && isAllTestsDone() && reportImmediately) { - replay(reporterManager); - } - } - - public void setAllScheduled(TestReportListener reporterManager) { - allScheduled = true; - if (isAllTestsDone()) { - replay(reporterManager); - } - } - - private boolean isAllTestsDone() { - return numberOfTests.get() == numberOfCompletedChildren.get(); - } - - public void attachToThread() { - TEST_SET.set(this); - } - - public static TestSet getThreadTestSet() { - return TEST_SET.get(); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/AbstractThreadPoolStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/AbstractThreadPoolStrategy.java deleted file mode 100644 index 3d1c0aa131..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/AbstractThreadPoolStrategy.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.Collection; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; - -/** - * Abstract parallel scheduling strategy in private package. - * The remaining abstract methods have to be implemented differently - * depending if the thread pool is shared with other strategies or not. - * - * @author Tibor Digana (tibor17) - * @see SchedulingStrategy - * @see SharedThreadPoolStrategy - * @see NonSharedThreadPoolStrategy - * @since 2.16 - */ -abstract class AbstractThreadPoolStrategy extends SchedulingStrategy { - private final ExecutorService threadPool; - - private final Collection> futureResults; - - private volatile boolean isDestroyed; - - AbstractThreadPoolStrategy(ConsoleLogger logger, ExecutorService threadPool) { - this(logger, threadPool, null); - } - - AbstractThreadPoolStrategy(ConsoleLogger logger, ExecutorService threadPool, Collection> futureResults) { - super(logger); - this.threadPool = threadPool; - this.futureResults = futureResults; - } - - protected final ExecutorService getThreadPool() { - return threadPool; - } - - protected final Collection> getFutureResults() { - return futureResults; - } - - @Override - public void schedule(Runnable task) { - if (canSchedule()) { - Future futureResult = threadPool.submit(task); - if (futureResults != null) { - futureResults.add(futureResult); - } - } - } - - @Override - protected boolean stop() { - boolean wasRunning = disable(); - if (threadPool.isShutdown()) { - wasRunning = false; - } else { - threadPool.shutdown(); - } - return wasRunning; - } - - @Override - protected boolean stopNow() { - boolean wasRunning = disable(); - if (threadPool.isShutdown()) { - wasRunning = false; - } else { - threadPool.shutdownNow(); - } - return wasRunning; - } - - /** - * @see Scheduler.ShutdownHandler - */ - @Override - protected void setDefaultShutdownHandler(Scheduler.ShutdownHandler handler) { - if (threadPool instanceof ThreadPoolExecutor) { - ThreadPoolExecutor pool = (ThreadPoolExecutor) threadPool; - handler.setRejectedExecutionHandler(pool.getRejectedExecutionHandler()); - pool.setRejectedExecutionHandler(handler); - } - } - - @Override - public boolean destroy() { - try { - if (!isDestroyed) // just an optimization - { - disable(); - threadPool.shutdown(); - this.isDestroyed |= threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); - } - return isDestroyed; - } catch (InterruptedException e) { - return false; - } - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java deleted file mode 100644 index bbaabb8ae4..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -/** - * The Balancer controls the maximum of concurrent threads in the current Scheduler(s) and prevents - * from own thread resources exhaustion if other group of schedulers share the same pool of threads. - *
- * If a permit is available, {@link #acquirePermit()} simply returns and a new test is scheduled - * by {@link Scheduler#schedule(Runnable)} in the current runner. Otherwise waiting for a release. - * One permit is released as soon as the child thread has finished. - * - * @author Tibor Digana (tibor17) - * @since 2.16 - */ -public interface Balancer { - - /** - * Acquires a permit from this balancer, blocking until one is available. - * - * @return {@code true} if current thread is NOT interrupted - * while waiting for a permit. - */ - boolean acquirePermit(); - - /** - * Releases a permit, returning it to the balancer. - */ - void releasePermit(); - - void releaseAllPermits(); -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/BalancerFactory.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/BalancerFactory.java deleted file mode 100644 index 58d2618ddc..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/BalancerFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -/** - * @author Tibor Digana (tibor17) - * @see Balancer - * @since 2.16 - */ -public class BalancerFactory { - private BalancerFactory() {} - - /** - * Infinite permits. - * @return Balancer wih infinite permits - */ - public static Balancer createInfinitePermitsBalancer() { - return balancer(0, false); - } - - /** - * Balancer without fairness. - * Fairness guarantees the waiting schedulers to wake up in order they acquired a permit. - * - * @param concurrency number of permits to acquire when maintaining concurrency on tests - * @return Balancer with given number of permits - */ - public static Balancer createBalancer(int concurrency) { - return balancer(concurrency, false); - } - - /** - * Balancer with fairness. - * Fairness guarantees the waiting schedulers to wake up in order they acquired a permit. - * - * @param concurrency number of permits to acquire when maintaining concurrency on tests - * @return Balancer with given number of permits - */ - public static Balancer createBalancerWithFairness(int concurrency) { - return balancer(concurrency, true); - } - - private static Balancer balancer(int concurrency, boolean fairness) { - boolean shouldBalance = concurrency > 0 && concurrency < Integer.MAX_VALUE; - return shouldBalance ? new ThreadResourcesBalancer(concurrency, fairness) : new NullBalancer(); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Concurrency.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Concurrency.java deleted file mode 100644 index 7850083972..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Concurrency.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -/** - * @author tibor17 (Tibor Digana) - * @since 2.17 - */ -final class Concurrency { - int suites, classes, methods, capacity; -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Destroyable.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Destroyable.java deleted file mode 100644 index 53037e80b2..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Destroyable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -/** - * Destroys the embedded thread-pool. - * - * @author Tibor Digana (tibor17) - * @see ParallelComputerBuilder - * @since 2.18 - */ -public interface Destroyable { - /** - * Calling {@link java.util.concurrent.ThreadPoolExecutor#shutdown()} - * and {@link java.util.concurrent.ThreadPoolExecutor#awaitTermination(long, java.util.concurrent.TimeUnit)}. - * - * @return {@code true} if not interrupted in current thread - */ - boolean destroy(); -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ExecutionStatus.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ExecutionStatus.java deleted file mode 100644 index 9595a40845..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ExecutionStatus.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -/** - * Status of {@link ParallelComputer ParallelComputer runtime}.
- * Used together with shutdown hook. - * - * @author Tibor Digana (tibor17) - * @see ParallelComputer - * @since 2.18 - */ -enum ExecutionStatus { - STARTED, - FINISHED, - TIMEOUT -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java deleted file mode 100644 index e83ff5d391..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; - -/** - * The sequentially executing strategy in private package. - * - * @author Tibor Digana (tibor17) - * @see SchedulingStrategy - * @since 2.16 - */ -final class InvokerStrategy extends SchedulingStrategy { - - private final Queue activeThreads = new ConcurrentLinkedQueue<>(); - - protected InvokerStrategy(ConsoleLogger logger) { - super(logger); - } - - @Override - public void schedule(Runnable task) { - if (canSchedule()) { - final Thread currentThread = Thread.currentThread(); - try { - activeThreads.add(currentThread); - task.run(); - } finally { - activeThreads.remove(currentThread); - } - } - } - - @Override - protected boolean stop() { - return disable(); - } - - @Override - protected boolean stopNow() { - final boolean stopped = disable(); - - for (Thread activeThread = activeThreads.poll(); activeThread != null; activeThread = activeThreads.poll()) { - activeThread.interrupt(); - } - return stopped; - } - - @Override - public boolean hasSharedThreadPool() { - return false; - } - - @Override - public boolean finished() throws InterruptedException { - return disable(); - } - - @Override - public boolean destroy() { - return stop(); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/NonSharedThreadPoolStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/NonSharedThreadPoolStrategy.java deleted file mode 100644 index ee251af9fa..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/NonSharedThreadPoolStrategy.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.TimeUnit; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; - -/** - * Parallel strategy for non-shared thread pool in private package. - * - * @author Tibor Digana (tibor17) - * @see AbstractThreadPoolStrategy - * @since 2.16 - */ -final class NonSharedThreadPoolStrategy extends AbstractThreadPoolStrategy { - NonSharedThreadPoolStrategy(ConsoleLogger logger, ExecutorService threadPool) { - super(logger, threadPool); - } - - @Override - public boolean hasSharedThreadPool() { - return false; - } - - @Override - public boolean finished() throws InterruptedException { - boolean wasRunning = disable(); - getThreadPool().shutdown(); - getThreadPool().awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); - return wasRunning; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/NullBalancer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/NullBalancer.java deleted file mode 100644 index 7f5c2307a6..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/NullBalancer.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -/** - * This balancer implements {@link Balancer} and does not do anything -no blocking operation. - * - * @author Tibor Digana (tibor17) - * @see Balancer - * @since 2.16 - */ -final class NullBalancer implements Balancer { - @Override - public boolean acquirePermit() { - return true; - } - - @Override - public void releasePermit() {} - - @Override - public void releaseAllPermits() {} -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java deleted file mode 100644 index ec14246970..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.Collection; -import java.util.TreeSet; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ThreadFactory; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.api.util.internal.DaemonThreadFactory; -import org.junit.runner.Computer; -import org.junit.runner.Description; - -import static java.util.concurrent.TimeUnit.NANOSECONDS; - -/** - * ParallelComputer extends JUnit {@link Computer} and has a shutdown functionality. - * - * @author Tibor Digana (tibor17) - * @see ParallelComputerBuilder - * @since 2.16 - */ -public abstract class ParallelComputer extends Computer { - private static final ThreadFactory DAEMON_THREAD_FACTORY = DaemonThreadFactory.newDaemonThreadFactory(); - - private static final double NANOS_IN_A_SECOND = 1E9; - - private final ShutdownStatus shutdownStatus = new ShutdownStatus(); - - private final ShutdownStatus forcedShutdownStatus = new ShutdownStatus(); - - private final long timeoutNanos; - - private final long timeoutForcedNanos; - - private ScheduledExecutorService shutdownScheduler; - - public ParallelComputer(double timeoutInSeconds, double timeoutForcedInSeconds) { - this.timeoutNanos = secondsToNanos(timeoutInSeconds); - this.timeoutForcedNanos = secondsToNanos(timeoutForcedInSeconds); - } - - protected abstract ShutdownResult describeStopped(boolean shutdownNow); - - protected abstract boolean shutdownThreadPoolsAwaitingKilled(); - - protected final void beforeRunQuietly() { - shutdownStatus.setDescriptionsBeforeShutdown(hasTimeout() ? scheduleShutdown() : null); - forcedShutdownStatus.setDescriptionsBeforeShutdown(hasTimeoutForced() ? scheduleForcedShutdown() : null); - } - - protected final boolean afterRunQuietly() { - shutdownStatus.tryFinish(); - forcedShutdownStatus.tryFinish(); - boolean notInterrupted = true; - if (shutdownScheduler != null) { - shutdownScheduler.shutdownNow(); - /** - * Clear interrupted status of the (main) Thread. - * Could be previously interrupted by {@link InvokerStrategy} after triggering immediate shutdown. - */ - Thread.interrupted(); - try { - shutdownScheduler.awaitTermination(Long.MAX_VALUE, NANOSECONDS); - } catch (InterruptedException e) { - notInterrupted = false; - } - } - notInterrupted &= shutdownThreadPoolsAwaitingKilled(); - return notInterrupted; - } - - public String describeElapsedTimeout() throws TestSetFailedException { - final StringBuilder msg = new StringBuilder(); - final boolean isShutdownTimeout = shutdownStatus.isTimeoutElapsed(); - final boolean isForcedShutdownTimeout = forcedShutdownStatus.isTimeoutElapsed(); - if (isShutdownTimeout || isForcedShutdownTimeout) { - msg.append("The test run has finished abruptly after timeout of "); - msg.append(nanosToSeconds(minTimeout(timeoutNanos, timeoutForcedNanos))); - msg.append(" seconds.\n"); - - try { - final TreeSet executedTests = new TreeSet<>(); - final TreeSet incompleteTests = new TreeSet<>(); - - if (isShutdownTimeout) { - printShutdownHook(executedTests, incompleteTests, shutdownStatus.getDescriptionsBeforeShutdown()); - } - - if (isForcedShutdownTimeout) { - printShutdownHook( - executedTests, incompleteTests, forcedShutdownStatus.getDescriptionsBeforeShutdown()); - } - - if (!executedTests.isEmpty()) { - msg.append("These tests were executed in prior to the shutdown operation:\n"); - for (String executedTest : executedTests) { - msg.append(executedTest).append('\n'); - } - } - - if (!incompleteTests.isEmpty()) { - msg.append("These tests are incomplete:\n"); - for (String incompleteTest : incompleteTests) { - msg.append(incompleteTest).append('\n'); - } - } - } catch (InterruptedException e) { - throw new TestSetFailedException("Timed termination was interrupted.", e); - } catch (ExecutionException e) { - throw new TestSetFailedException(e.getLocalizedMessage(), e.getCause()); - } - } - return msg.toString(); - } - - private Future scheduleShutdown() { - return getShutdownScheduler().schedule(createShutdownTask(), timeoutNanos, NANOSECONDS); - } - - private Future scheduleForcedShutdown() { - return getShutdownScheduler().schedule(createForcedShutdownTask(), timeoutForcedNanos, NANOSECONDS); - } - - private ScheduledExecutorService getShutdownScheduler() { - if (shutdownScheduler == null) { - shutdownScheduler = Executors.newScheduledThreadPool(2, DAEMON_THREAD_FACTORY); - } - return shutdownScheduler; - } - - private Callable createShutdownTask() { - return new Callable() { - @Override - public ShutdownResult call() throws Exception { - boolean stampedStatusWithTimeout = ParallelComputer.this.shutdownStatus.tryTimeout(); - return stampedStatusWithTimeout ? ParallelComputer.this.describeStopped(false) : null; - } - }; - } - - private Callable createForcedShutdownTask() { - return new Callable() { - @Override - public ShutdownResult call() throws Exception { - boolean stampedStatusWithTimeout = ParallelComputer.this.forcedShutdownStatus.tryTimeout(); - return stampedStatusWithTimeout ? ParallelComputer.this.describeStopped(true) : null; - } - }; - } - - private double nanosToSeconds(long nanos) { - return (double) nanos / NANOS_IN_A_SECOND; - } - - private boolean hasTimeout() { - return timeoutNanos > 0; - } - - private boolean hasTimeoutForced() { - return timeoutForcedNanos > 0; - } - - private static long secondsToNanos(double seconds) { - double nanos = seconds > 0 ? seconds * NANOS_IN_A_SECOND : 0; - return Double.isInfinite(nanos) || nanos >= Long.MAX_VALUE ? 0 : (long) nanos; - } - - private static long minTimeout(long timeout1, long timeout2) { - if (timeout1 == 0) { - return timeout2; - } else if (timeout2 == 0) { - return timeout1; - } else { - return Math.min(timeout1, timeout2); - } - } - - private static void printShutdownHook( - Collection executedTests, - Collection incompleteTests, - Future testsBeforeShutdown) - throws ExecutionException, InterruptedException { - if (testsBeforeShutdown != null) { - final ShutdownResult shutdownResult = testsBeforeShutdown.get(); - if (shutdownResult != null) { - for (final Description test : shutdownResult.getTriggeredTests()) { - if (test != null && test.getDisplayName() != null) { - executedTests.add(test.getDisplayName()); - } - } - - for (final Description test : shutdownResult.getIncompleteTests()) { - if (test != null && test.getDisplayName() != null) { - incompleteTests.add(test.getDisplayName()); - } - } - } - } - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java deleted file mode 100755 index 08f365cf7d..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java +++ /dev/null @@ -1,594 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.api.util.internal.DaemonThreadFactory; -import org.apache.maven.surefire.junitcore.JUnitCoreParameters; -import org.junit.internal.runners.ErrorReportingRunner; -import org.junit.runner.Description; -import org.junit.runner.Runner; -import org.junit.runner.manipulation.Filter; -import org.junit.runner.manipulation.NoTestsRemainException; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.ParentRunner; -import org.junit.runners.Suite; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.RunnerBuilder; - -import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.resolveConcurrency; -import static org.apache.maven.surefire.junitcore.pc.SchedulingStrategies.createParallelStrategy; -import static org.apache.maven.surefire.junitcore.pc.SchedulingStrategies.createParallelStrategyUnbounded; -import static org.apache.maven.surefire.junitcore.pc.Type.CLASSES; -import static org.apache.maven.surefire.junitcore.pc.Type.METHODS; -import static org.apache.maven.surefire.junitcore.pc.Type.SUITES; - -@SuppressWarnings({"javadoc", "checkstyle:javadoctype"}) -/* - * Executing suites, classes and methods with defined concurrency. In this example the threads which completed - * the suites and classes can be reused in parallel methods. - *

- * JUnitCoreParameters parameters = ...;
- * ParallelComputerBuilder builder = new ParallelComputerBuilder(parameters);
- * builder.useOnePool(8).parallelSuites(2).parallelClasses(4).parallelMethods();
- * ParallelComputerBuilder.ParallelComputer computer = builder.buildComputer();
- * Class[] tests = {...};
- * new JUnitCore().run(computer, tests);
- * 
- * Note that the type has always at least one thread even if unspecified. The capacity in - * {@link ParallelComputerBuilder#useOnePool(int)} must be greater than the number of concurrent suites and classes - * altogether. - *
- * The Computer can be stopped in a separate thread. Pending tests will be interrupted if the argument is - * {@code true}. - *
- * computer.describeStopped(true);
- * 
- * - * @author Tibor Digana (tibor17) - * @since 2.16 - */ -public final class ParallelComputerBuilder { - private static final ThreadFactory DAEMON_THREAD_FACTORY = DaemonThreadFactory.newDaemonThreadFactory(); - - private static final Class JCIP_NOT_THREAD_SAFE = loadNotThreadSafeAnnotations(); - - private static final Set NULL_SINGLETON = Collections.singleton(null); - - static final int TOTAL_POOL_SIZE_UNDEFINED = 0; - - private final Map parallelGroups = new EnumMap<>(Type.class); - - private final ConsoleLogger logger; - - private boolean useSeparatePools; - - private int totalPoolSize; - - private JUnitCoreParameters parameters; - - private boolean optimize; - - private boolean runningInTests; - - /** - * Calling {@link #useSeparatePools()}. - * Can be used only in unit tests. - * Do NOT call this constructor in production. - */ - ParallelComputerBuilder(ConsoleLogger logger) { - this.logger = logger; - runningInTests = true; - useSeparatePools(); - parallelGroups.put(SUITES, 0); - parallelGroups.put(CLASSES, 0); - parallelGroups.put(METHODS, 0); - } - - public ParallelComputerBuilder(ConsoleLogger logger, JUnitCoreParameters parameters) { - this(logger); - runningInTests = false; - this.parameters = parameters; - } - - public ParallelComputer buildComputer() { - return new PC(); - } - - ParallelComputerBuilder useSeparatePools() { - totalPoolSize = TOTAL_POOL_SIZE_UNDEFINED; - useSeparatePools = true; - return this; - } - - ParallelComputerBuilder useOnePool() { - totalPoolSize = TOTAL_POOL_SIZE_UNDEFINED; - useSeparatePools = false; - return this; - } - - /** - * @param totalPoolSize Pool size where suites, classes and methods are executed in parallel. - * If the totalPoolSize is {@link Integer#MAX_VALUE}, the pool capacity is not - * limited. - * @throws IllegalArgumentException If totalPoolSize is < 1. - */ - ParallelComputerBuilder useOnePool(int totalPoolSize) { - if (totalPoolSize < 1) { - throw new IllegalArgumentException("Size of common pool is less than 1."); - } - this.totalPoolSize = totalPoolSize; - useSeparatePools = false; - return this; - } - - boolean isOptimized() { - return optimize; - } - - ParallelComputerBuilder optimize(boolean optimize) { - this.optimize = optimize; - return this; - } - - ParallelComputerBuilder parallelSuites() { - return parallel(SUITES); - } - - ParallelComputerBuilder parallelSuites(int nThreads) { - return parallel(nThreads, SUITES); - } - - ParallelComputerBuilder parallelClasses() { - return parallel(CLASSES); - } - - ParallelComputerBuilder parallelClasses(int nThreads) { - return parallel(nThreads, CLASSES); - } - - ParallelComputerBuilder parallelMethods() { - return parallel(METHODS); - } - - ParallelComputerBuilder parallelMethods(int nThreads) { - return parallel(nThreads, METHODS); - } - - private ParallelComputerBuilder parallel(int nThreads, Type parallelType) { - if (nThreads < 0) { - throw new IllegalArgumentException("negative nThreads " + nThreads); - } - - if (parallelType == null) { - throw new IllegalArgumentException("null parallelType"); - } - - parallelGroups.put(parallelType, nThreads); - return this; - } - - private ParallelComputerBuilder parallel(Type parallelType) { - return parallel(Integer.MAX_VALUE, parallelType); - } - - private double parallelTestsTimeoutInSeconds() { - return parameters == null ? 0d : parameters.getParallelTestsTimeoutInSeconds(); - } - - private double parallelTestsTimeoutForcedInSeconds() { - return parameters == null ? 0d : parameters.getParallelTestsTimeoutForcedInSeconds(); - } - - @SuppressWarnings("unchecked") - private static Class loadNotThreadSafeAnnotations() { - try { - Class c = Class.forName("net.jcip.annotations.NotThreadSafe"); - return c.isAnnotation() ? (Class) c : null; - } catch (ClassNotFoundException e) { - return null; - } - } - - final class PC extends ParallelComputer { - private final SingleThreadScheduler notThreadSafeTests = - new SingleThreadScheduler(ParallelComputerBuilder.this.logger); - - private final Collection suites = new LinkedHashSet<>(); - - private final Collection nestedSuites = new LinkedHashSet<>(); - - private final Collection classes = new LinkedHashSet<>(); - - private final Collection nestedClasses = new LinkedHashSet<>(); - - private final Collection notParallelRunners = new LinkedHashSet<>(); - - private int poolCapacity; - - private boolean splitPool; - - private final Map allGroups; - - private long nestedClassesChildren; - - private volatile Scheduler master; - - private PC() { - super(parallelTestsTimeoutInSeconds(), parallelTestsTimeoutForcedInSeconds()); - allGroups = new EnumMap<>(ParallelComputerBuilder.this.parallelGroups); - poolCapacity = ParallelComputerBuilder.this.totalPoolSize; - splitPool = ParallelComputerBuilder.this.useSeparatePools; - } - - Collection getSuites() { - return suites; - } - - Collection getNestedSuites() { - return nestedSuites; - } - - Collection getClasses() { - return classes; - } - - Collection getNestedClasses() { - return nestedClasses; - } - - Collection getNotParallelRunners() { - return notParallelRunners; - } - - int getPoolCapacity() { - return poolCapacity; - } - - boolean isSplitPool() { - return splitPool; - } - - @Override - protected ShutdownResult describeStopped(boolean shutdownNow) { - ShutdownResult shutdownResult = notThreadSafeTests.describeStopped(shutdownNow); - final Scheduler m = master; - if (m != null) { - ShutdownResult shutdownResultOfMaster = m.describeStopped(shutdownNow); - shutdownResult.getTriggeredTests().addAll(shutdownResultOfMaster.getTriggeredTests()); - shutdownResult.getIncompleteTests().addAll(shutdownResultOfMaster.getIncompleteTests()); - } - return shutdownResult; - } - - @Override - protected boolean shutdownThreadPoolsAwaitingKilled() { - boolean notInterrupted = notThreadSafeTests.shutdownThreadPoolsAwaitingKilled(); - final Scheduler m = master; - if (m != null) { - notInterrupted &= m.shutdownThreadPoolsAwaitingKilled(); - } - return notInterrupted; - } - - @Override - public Runner getSuite(RunnerBuilder builder, Class[] cls) throws InitializationError { - try { - super.getSuite(builder, cls); - populateChildrenFromSuites(); - - WrappedRunners suiteSuites = wrapRunners(suites); - WrappedRunners suiteClasses = wrapRunners(classes); - - long suitesCount = suites.size(); - long classesCount = classes.size() + nestedClasses.size(); - long methodsCount = suiteClasses.embeddedChildrenCount + nestedClassesChildren; - if (!ParallelComputerBuilder.this.runningInTests) { - determineThreadCounts(suitesCount, classesCount, methodsCount); - } - - return setSchedulers(suiteSuites.wrappingSuite, suiteClasses.wrappingSuite); - } catch (TestSetFailedException e) { - throw new InitializationError(Collections.singletonList(e)); - } - } - - @Override - protected Runner getRunner(RunnerBuilder builder, Class testClass) throws Throwable { - Runner runner = super.getRunner(builder, testClass); - if (canSchedule(runner)) { - if (!isThreadSafe(runner)) { - ((ParentRunner) runner).setScheduler(notThreadSafeTests.newRunnerScheduler()); - notParallelRunners.add(runner); - } else if (runner instanceof Suite) { - suites.add((Suite) runner); - } else { - classes.add((ParentRunner) runner); - } - } else { - notParallelRunners.add(runner); - } - return runner; - } - - private void determineThreadCounts(long suites, long classes, long methods) throws TestSetFailedException { - RunnerCounter counts = - ParallelComputerBuilder.this.optimize ? new RunnerCounter(suites, classes, methods) : null; - Concurrency concurrency = resolveConcurrency(ParallelComputerBuilder.this.parameters, counts); - allGroups.put(SUITES, concurrency.suites); - allGroups.put(CLASSES, concurrency.classes); - allGroups.put(METHODS, concurrency.methods); - poolCapacity = concurrency.capacity; - splitPool &= concurrency.capacity <= 0; // fault if negative; should not happen - } - - private WrappedRunners wrapRunners(Collection runners) throws InitializationError { - // Do NOT use allGroups here. - long childrenCounter = 0; - ArrayList runs = new ArrayList<>(); - for (T runner : runners) { - if (runner != null) { - int children = countChildren(runner); - childrenCounter += children; - runs.add(runner); - } - } - return runs.isEmpty() ? new WrappedRunners() : new WrappedRunners(createSuite(runs), childrenCounter); - } - - private int countChildren(Runner runner) { - Description description = runner.getDescription(); - Collection children = description == null ? null : description.getChildren(); - return children == null ? 0 : children.size(); - } - - private ExecutorService createPool(int poolSize) { - return poolSize < Integer.MAX_VALUE - ? Executors.newFixedThreadPool(poolSize, DAEMON_THREAD_FACTORY) - : Executors.newCachedThreadPool(DAEMON_THREAD_FACTORY); - } - - private Scheduler createMaster(ExecutorService pool, int poolSize) { - // can be 0, 1, 2 or 3 - final int finalRunnersCounter = countFinalRunners(); - - final SchedulingStrategy strategy; - if (finalRunnersCounter <= 1 || poolSize <= 1) { - strategy = new InvokerStrategy(ParallelComputerBuilder.this.logger); - } else if (pool != null && poolSize == Integer.MAX_VALUE) { - strategy = new SharedThreadPoolStrategy(ParallelComputerBuilder.this.logger, pool); - } else { - strategy = createParallelStrategy(ParallelComputerBuilder.this.logger, finalRunnersCounter); - } - return new Scheduler(ParallelComputerBuilder.this.logger, null, strategy); - } - - private int countFinalRunners() { - int counter = notParallelRunners.isEmpty() ? 0 : 1; - - if (!suites.isEmpty() && allGroups.get(SUITES) > 0) { - ++counter; - } - - if (!classes.isEmpty() && allGroups.get(CLASSES) > 0) { - ++counter; - } - - return counter; - } - - private void populateChildrenFromSuites() { - // Do NOT use allGroups here. - Filter filter = new SuiteFilter(); - for (Iterator it = suites.iterator(); it.hasNext(); ) { - ParentRunner suite = it.next(); - try { - suite.filter(filter); - } catch (NoTestsRemainException e) { - it.remove(); - } - } - } - - private int totalPoolSize() { - if (poolCapacity == TOTAL_POOL_SIZE_UNDEFINED) { - int total = 0; - for (int nThreads : allGroups.values()) { - total += nThreads; - if (total < 0) { - total = Integer.MAX_VALUE; - break; - } - } - return total; - } else { - return poolCapacity; - } - } - - private Runner setSchedulers(ParentRunner suiteSuites, ParentRunner suiteClasses) throws InitializationError { - int parallelSuites = allGroups.get(SUITES); - int parallelClasses = allGroups.get(CLASSES); - int parallelMethods = allGroups.get(METHODS); - int poolSize = totalPoolSize(); - ExecutorService commonPool = splitPool || poolSize == 0 ? null : createPool(poolSize); - master = createMaster(commonPool, poolSize); - - if (suiteSuites != null) { - // a scheduler for parallel suites - if (commonPool != null && parallelSuites > 0) { - Balancer balancer = BalancerFactory.createBalancerWithFairness(parallelSuites); - suiteSuites.setScheduler(createScheduler(null, commonPool, true, balancer)); - } else { - suiteSuites.setScheduler(createScheduler(parallelSuites)); - } - } - - // schedulers for parallel classes - ArrayList allSuites = new ArrayList<>(suites); - allSuites.addAll(nestedSuites); - if (suiteClasses != null) { - allSuites.add(suiteClasses); - } - if (!allSuites.isEmpty()) { - setSchedulers(allSuites, parallelClasses, commonPool); - } - - // schedulers for parallel methods - ArrayList allClasses = new ArrayList<>(classes); - allClasses.addAll(nestedClasses); - if (!allClasses.isEmpty()) { - setSchedulers(allClasses, parallelMethods, commonPool); - } - - // resulting runner for Computer#getSuite() scheduled by master scheduler - ParentRunner all = createFinalRunner(removeNullRunners( - Arrays.asList(suiteSuites, suiteClasses, createSuite(notParallelRunners)))); - all.setScheduler(master); - return all; - } - - private ParentRunner createFinalRunner(List runners) throws InitializationError { - return new Suite(null, runners) { - @Override - public void run(RunNotifier notifier) { - try { - beforeRunQuietly(); - super.run(notifier); - } finally { - afterRunQuietly(); - } - } - }; - } - - private void setSchedulers(Iterable runners, int poolSize, ExecutorService commonPool) { - if (commonPool != null) { - Balancer concurrencyLimit = BalancerFactory.createBalancerWithFairness(poolSize); - boolean doParallel = poolSize > 0; - for (ParentRunner runner : runners) { - runner.setScheduler( - createScheduler(runner.getDescription(), commonPool, doParallel, concurrencyLimit)); - } - } else { - ExecutorService pool = null; - if (poolSize == Integer.MAX_VALUE) { - pool = Executors.newCachedThreadPool(DAEMON_THREAD_FACTORY); - } else if (poolSize > 0) { - pool = Executors.newFixedThreadPool(poolSize, DAEMON_THREAD_FACTORY); - } - boolean doParallel = pool != null; - for (ParentRunner runner : runners) { - runner.setScheduler(createScheduler( - runner.getDescription(), - pool, - doParallel, - BalancerFactory.createInfinitePermitsBalancer())); - } - } - } - - private Scheduler createScheduler( - Description desc, ExecutorService pool, boolean doParallel, Balancer concurrency) { - SchedulingStrategy strategy = doParallel & pool != null - ? new SharedThreadPoolStrategy(ParallelComputerBuilder.this.logger, pool) - : new InvokerStrategy(ParallelComputerBuilder.this.logger); - return new Scheduler(ParallelComputerBuilder.this.logger, desc, master, strategy, concurrency); - } - - private Scheduler createScheduler(int poolSize) { - final SchedulingStrategy strategy; - if (poolSize == Integer.MAX_VALUE) { - strategy = createParallelStrategyUnbounded(ParallelComputerBuilder.this.logger); - } else if (poolSize == 0) { - strategy = new InvokerStrategy(ParallelComputerBuilder.this.logger); - } else { - strategy = createParallelStrategy(ParallelComputerBuilder.this.logger, poolSize); - } - return new Scheduler(ParallelComputerBuilder.this.logger, null, master, strategy); - } - - private boolean canSchedule(Runner runner) { - return !(runner instanceof ErrorReportingRunner) && runner instanceof ParentRunner; - } - - private boolean isThreadSafe(Runner runner) { - return runner.getDescription().getAnnotation(JCIP_NOT_THREAD_SAFE) == null; - } - - private class SuiteFilter extends Filter { - // Do NOT use allGroups in SuiteFilter. - - @Override - public boolean shouldRun(Description description) { - return true; - } - - @Override - public void apply(Object child) throws NoTestsRemainException { - super.apply(child); - if (child instanceof ParentRunner) { - ParentRunner runner = (ParentRunner) child; - if (!isThreadSafe(runner)) { - runner.setScheduler(notThreadSafeTests.newRunnerScheduler()); - } else if (child instanceof Suite) { - nestedSuites.add((Suite) child); - } else { - ParentRunner parentRunner = (ParentRunner) child; - nestedClasses.add(parentRunner); - nestedClassesChildren += - parentRunner.getDescription().getChildren().size(); - } - } - } - - @Override - public String describe() { - return ""; - } - } - } - - private static Suite createSuite(Collection runners) throws InitializationError { - final List onlyRunners = removeNullRunners(runners); - return onlyRunners.isEmpty() ? null : new Suite(null, onlyRunners) {}; - } - - private static List removeNullRunners(Collection runners) { - final List onlyRunners = new ArrayList<>(runners); - onlyRunners.removeAll(NULL_SINGLETON); - return onlyRunners; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java deleted file mode 100644 index 95b0bb3d81..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.junitcore.JUnitCoreParameters; -import org.junit.runner.Description; - -/** - * An algorithm which configures {@link ParallelComputer} with allocated thread resources by given - * {@link org.apache.maven.surefire.junitcore.JUnitCoreParameters}. - * The {@code AbstractSurefireMojo} has to provide correct combinations of thread-counts and - * configuration parameter {@code parallel}. - * - * @author Tibor Digana (tibor17) - * @see org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder - * @since 2.16 - */ -final class ParallelComputerUtil { - private static final Collection UNUSED_DESCRIPTIONS = Arrays.asList( - null, Description.createSuiteDescription("null"), Description.TEST_MECHANISM, Description.EMPTY); - - private static int availableProcessors = Runtime.getRuntime().availableProcessors(); - - private ParallelComputerUtil() { - throw new IllegalStateException("Suppresses calling constructor, ensuring non-instantiability."); - } - - /* - * For testing purposes. - */ - static void overrideAvailableProcessors(int availableProcessors) { - ParallelComputerUtil.availableProcessors = availableProcessors; - } - - /* - * For testing purposes. - */ - static void setDefaultAvailableProcessors() { - ParallelComputerUtil.availableProcessors = Runtime.getRuntime().availableProcessors(); - } - - static Concurrency resolveConcurrency(JUnitCoreParameters params, RunnerCounter counts) - throws TestSetFailedException { - if (!params.isParallelismSelected()) { - throw new TestSetFailedException("Unspecified parameter '" + JUnitCoreParameters.PARALLEL_KEY + "'."); - } - - if (!params.isUseUnlimitedThreads() && !hasThreadCount(params) && !hasThreadCounts(params)) { - throw new TestSetFailedException("Unspecified thread-count(s). " - + "See the parameters " - + JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY + ", " - + JUnitCoreParameters.THREADCOUNT_KEY + ", " - + JUnitCoreParameters.THREADCOUNTSUITES_KEY + ", " - + JUnitCoreParameters.THREADCOUNTCLASSES_KEY + ", " - + JUnitCoreParameters.THREADCOUNTMETHODS_KEY + "."); - } - - if (params.isUseUnlimitedThreads()) { - return concurrencyForUnlimitedThreads(params); - } else if (hasThreadCount(params)) { - if (hasThreadCounts(params)) { - return isLeafUnspecified(params) - ? concurrencyFromAllThreadCountsButUnspecifiedLeafCount(params, counts) - : concurrencyFromAllThreadCounts(params); - } else { - return estimateConcurrency(params, counts); - } - } else { - return concurrencyFromThreadCounts(params); - } - } - - static boolean isUnusedDescription(Description examined) { - if (UNUSED_DESCRIPTIONS.contains(examined)) { - return true; - } else { - // UNUSED_DESCRIPTIONS ensures that "examined" cannot be null - for (Description unused : UNUSED_DESCRIPTIONS) { - if (unused != null && unused.getDisplayName().equals(examined.getDisplayName())) { - return true; - } - } - return false; - } - } - - static void removeUnusedDescriptions(Collection examined) { - for (Iterator it = examined.iterator(); it.hasNext(); ) { - if (isUnusedDescription(it.next())) { - it.remove(); - } - } - } - - private static Concurrency concurrencyForUnlimitedThreads(JUnitCoreParameters params) { - Concurrency concurrency = new Concurrency(); - concurrency.suites = params.isParallelSuites() ? threadCountSuites(params) : 0; - concurrency.classes = params.isParallelClasses() ? threadCountClasses(params) : 0; - concurrency.methods = params.isParallelMethods() ? threadCountMethods(params) : 0; - concurrency.capacity = Integer.MAX_VALUE; - return concurrency; - } - - private static Concurrency estimateConcurrency(JUnitCoreParameters params, RunnerCounter counts) { - final Concurrency concurrency = new Concurrency(); - final int parallelEntities = countParallelEntities(params); - concurrency.capacity = multiplyByCoreCount(params, params.getThreadCount()); - if (parallelEntities == 1 || counts == null || counts.classes == 0) { - // Estimate parallel thread counts. - double ratio = 1d / parallelEntities; - int threads = multiplyByCoreCount(params, ratio * params.getThreadCount()); - concurrency.suites = params.isParallelSuites() ? minSuites(threads, counts) : 0; - concurrency.classes = params.isParallelClasses() ? minClasses(threads, counts) : 0; - concurrency.methods = params.isParallelMethods() ? minMethods(threads, counts) : 0; - if (parallelEntities == 1) { - concurrency.capacity = 0; - } else { - adjustLeaf(params, concurrency); - } - } else { - // Try to allocate suites+classes+methods within threadCount, - concurrency.suites = params.isParallelSuites() ? toNonNegative(counts.suites) : 0; - concurrency.classes = params.isParallelClasses() ? toNonNegative(counts.classes) : 0; - concurrency.methods = - params.isParallelMethods() ? toNonNegative(Math.ceil(counts.methods / (double) counts.classes)) : 0; - double sum = toNonNegative(concurrency.suites + concurrency.classes + concurrency.methods); - if (concurrency.capacity < sum && sum != 0) { - // otherwise allocate them using the weighting factor < 1. - double weight = concurrency.capacity / sum; - concurrency.suites *= weight; - concurrency.classes *= weight; - concurrency.methods *= weight; - } - adjustLeaf(params, concurrency); - } - return concurrency; - } - - private static Concurrency concurrencyFromAllThreadCountsButUnspecifiedLeafCount( - JUnitCoreParameters params, RunnerCounter counts) { - Concurrency concurrency = new Concurrency(); - concurrency.suites = params.isParallelSuites() ? params.getThreadCountSuites() : 0; - concurrency.suites = params.isParallelSuites() ? multiplyByCoreCount(params, concurrency.suites) : 0; - concurrency.classes = params.isParallelClasses() ? params.getThreadCountClasses() : 0; - concurrency.classes = params.isParallelClasses() ? multiplyByCoreCount(params, concurrency.classes) : 0; - concurrency.methods = params.isParallelMethods() ? params.getThreadCountMethods() : 0; - concurrency.methods = params.isParallelMethods() ? multiplyByCoreCount(params, concurrency.methods) : 0; - concurrency.capacity = multiplyByCoreCount(params, params.getThreadCount()); - - if (counts != null) { - concurrency.suites = toNonNegative(Math.min(concurrency.suites, counts.suites)); - concurrency.classes = toNonNegative(Math.min(concurrency.classes, counts.classes)); - } - - setLeafInfinite(params, concurrency); - - return concurrency; - } - - private static Concurrency concurrencyFromAllThreadCounts(JUnitCoreParameters params) { - Concurrency concurrency = new Concurrency(); - concurrency.suites = params.isParallelSuites() ? params.getThreadCountSuites() : 0; - concurrency.classes = params.isParallelClasses() ? params.getThreadCountClasses() : 0; - concurrency.methods = params.isParallelMethods() ? params.getThreadCountMethods() : 0; - concurrency.capacity = params.getThreadCount(); - double all = sumThreadCounts(concurrency); - - concurrency.suites = params.isParallelSuites() - ? multiplyByCoreCount(params, concurrency.capacity * (concurrency.suites / all)) - : 0; - - concurrency.classes = params.isParallelClasses() - ? multiplyByCoreCount(params, concurrency.capacity * (concurrency.classes / all)) - : 0; - - concurrency.methods = params.isParallelMethods() - ? multiplyByCoreCount(params, concurrency.capacity * (concurrency.methods / all)) - : 0; - - concurrency.capacity = multiplyByCoreCount(params, concurrency.capacity); - adjustPrecisionInLeaf(params, concurrency); - return concurrency; - } - - private static Concurrency concurrencyFromThreadCounts(JUnitCoreParameters params) { - Concurrency concurrency = new Concurrency(); - concurrency.suites = params.isParallelSuites() ? threadCountSuites(params) : 0; - concurrency.classes = params.isParallelClasses() ? threadCountClasses(params) : 0; - concurrency.methods = params.isParallelMethods() ? threadCountMethods(params) : 0; - concurrency.capacity = toNonNegative(sumThreadCounts(concurrency)); - return concurrency; - } - - private static int countParallelEntities(JUnitCoreParameters params) { - int count = 0; - if (params.isParallelSuites()) { - count++; - } - - if (params.isParallelClasses()) { - count++; - } - - if (params.isParallelMethods()) { - count++; - } - return count; - } - - private static void adjustPrecisionInLeaf(JUnitCoreParameters params, Concurrency concurrency) { - if (params.isParallelMethods()) { - concurrency.methods = concurrency.capacity - concurrency.suites - concurrency.classes; - } else if (params.isParallelClasses()) { - concurrency.classes = concurrency.capacity - concurrency.suites; - } - } - - private static void adjustLeaf(JUnitCoreParameters params, Concurrency concurrency) { - if (params.isParallelMethods()) { - concurrency.methods = Integer.MAX_VALUE; - } else if (params.isParallelClasses()) { - concurrency.classes = Integer.MAX_VALUE; - } - } - - private static void setLeafInfinite(JUnitCoreParameters params, Concurrency concurrency) { - if (params.isParallelMethods()) { - concurrency.methods = Integer.MAX_VALUE; - } else if (params.isParallelClasses()) { - concurrency.classes = Integer.MAX_VALUE; - } else if (params.isParallelSuites()) { - concurrency.suites = Integer.MAX_VALUE; - } - } - - private static boolean isLeafUnspecified(JUnitCoreParameters params) { - int maskOfParallel = params.isParallelSuites() ? 4 : 0; - maskOfParallel |= params.isParallelClasses() ? 2 : 0; - maskOfParallel |= params.isParallelMethods() ? 1 : 0; - - int maskOfConcurrency = params.getThreadCountSuites() > 0 ? 4 : 0; - maskOfConcurrency |= params.getThreadCountClasses() > 0 ? 2 : 0; - maskOfConcurrency |= params.getThreadCountMethods() > 0 ? 1 : 0; - - maskOfConcurrency &= maskOfParallel; - - int leaf = Integer.lowestOneBit(maskOfParallel); - return maskOfConcurrency == maskOfParallel - leaf; - } - - private static double sumThreadCounts(Concurrency concurrency) { - double sum = concurrency.suites; - sum += concurrency.classes; - sum += concurrency.methods; - return sum; - } - - private static boolean hasThreadCounts(JUnitCoreParameters jUnitCoreParameters) { - return (jUnitCoreParameters.isParallelSuites() && jUnitCoreParameters.getThreadCountSuites() > 0) - || (jUnitCoreParameters.isParallelClasses() && jUnitCoreParameters.getThreadCountClasses() > 0) - || (jUnitCoreParameters.isParallelMethods() && jUnitCoreParameters.getThreadCountMethods() > 0); - } - - private static boolean hasThreadCount(JUnitCoreParameters jUnitCoreParameters) { - return jUnitCoreParameters.getThreadCount() > 0; - } - - private static int threadCountMethods(JUnitCoreParameters jUnitCoreParameters) { - return multiplyByCoreCount(jUnitCoreParameters, jUnitCoreParameters.getThreadCountMethods()); - } - - private static int threadCountClasses(JUnitCoreParameters jUnitCoreParameters) { - return multiplyByCoreCount(jUnitCoreParameters, jUnitCoreParameters.getThreadCountClasses()); - } - - private static int threadCountSuites(JUnitCoreParameters jUnitCoreParameters) { - return multiplyByCoreCount(jUnitCoreParameters, jUnitCoreParameters.getThreadCountSuites()); - } - - private static int multiplyByCoreCount(JUnitCoreParameters jUnitCoreParameters, double threadsPerCore) { - double numberOfThreads = jUnitCoreParameters.isPerCoreThreadCount() - ? threadsPerCore * (double) availableProcessors - : threadsPerCore; - - return numberOfThreads > 0 ? toNonNegative(numberOfThreads) : Integer.MAX_VALUE; - } - - private static int minSuites(int threads, RunnerCounter counts) { - long count = counts == null ? Integer.MAX_VALUE : counts.suites; - return Math.min(threads, toNonNegative(count)); - } - - private static int minClasses(int threads, RunnerCounter counts) { - long count = counts == null ? Integer.MAX_VALUE : counts.classes; - return Math.min(threads, toNonNegative(count)); - } - - private static int minMethods(int threads, RunnerCounter counts) { - long count = counts == null ? Integer.MAX_VALUE : counts.methods; - return Math.min(threads, toNonNegative(count)); - } - - private static int toNonNegative(long num) { - return (int) Math.min(num > 0 ? num : 0, Integer.MAX_VALUE); - } - - private static int toNonNegative(double num) { - return (int) Math.min(num > 0 ? num : 0, Integer.MAX_VALUE); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/RunnerCounter.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/RunnerCounter.java deleted file mode 100644 index 55e7e64b2f..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/RunnerCounter.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -/** - * Counts number of JUnit suites, classes and methods. - * - * @author tibor17 (Tibor Digana) - * @see ParallelComputerBuilder - * @since 2.17 - */ -final class RunnerCounter { - final long suites; - - final long classes; - - final long methods; - - RunnerCounter(long suites, long classes, long methods) { - this.suites = suites; - this.classes = classes; - this.methods = methods; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Scheduler.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Scheduler.java deleted file mode 100644 index b92f53f376..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Scheduler.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.Collection; -import java.util.Set; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.RejectedExecutionHandler; -import java.util.concurrent.ThreadPoolExecutor; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.junit.runner.Description; -import org.junit.runners.model.RunnerScheduler; - -/** - * Schedules tests, controls thread resources, awaiting tests and other schedulers finished, and - * a master scheduler can shutdown slaves. - *
- * The scheduler objects should be first created (and wired) and set in runners - * {@link org.junit.runners.ParentRunner#setScheduler(org.junit.runners.model.RunnerScheduler)}. - *
- * A new instance of scheduling strategy should be passed to the constructor of this scheduler. - * - * @author Tibor Digana (tibor17) - * @since 2.16 - */ -public class Scheduler implements RunnerScheduler { - private final Balancer balancer; - - private final SchedulingStrategy strategy; - - private final Set slaves = new CopyOnWriteArraySet<>(); - - private final Description description; - - private final ConsoleLogger logger; - - private volatile boolean shutdown = false; - - private volatile boolean started = false; - - private volatile boolean finished = false; - - private volatile Controller masterController; - - /** - * Use e.g. parallel classes have own non-shared thread pool, and methods another pool. - *
- * You can use it with one infinite thread pool shared in strategies across all - * suites, class runners, etc. - * - * @param logger console logger - * @param description JUnit description of class - * @param strategy scheduling strategy - */ - public Scheduler(ConsoleLogger logger, Description description, SchedulingStrategy strategy) { - this(logger, description, strategy, -1); - } - - /** - * Should be used if schedulers in parallel children and parent use one instance of bounded thread pool. - *
- * Set this scheduler in a e.g. one suite of classes, then every individual class runner should reference - * {@link #Scheduler(ConsoleLogger, org.junit.runner.Description, Scheduler, SchedulingStrategy)} - * or {@link #Scheduler(ConsoleLogger, org.junit.runner.Description, Scheduler, SchedulingStrategy, int)}. - * - * @param logger current logger implementation - * @param description description of current runner - * @param strategy scheduling strategy with a shared thread pool - * @param concurrency determines maximum concurrent children scheduled a time via {@link #schedule(Runnable)} - * @throws NullPointerException if null strategy - */ - public Scheduler(ConsoleLogger logger, Description description, SchedulingStrategy strategy, int concurrency) { - this(logger, description, strategy, BalancerFactory.createBalancer(concurrency)); - } - - /** - * New instances should be used by schedulers with limited concurrency by balancer - * against other groups of schedulers. The schedulers share one pool. - *
- * Unlike in {@link #Scheduler(ConsoleLogger, org.junit.runner.Description, SchedulingStrategy, int)} which was - * limiting the concurrency of children of a runner where this scheduler was set, {@code this} - * balancer is limiting the concurrency of all children in runners having schedulers created by this - * constructor. - * - * @param logger current logger implementation - * @param description description of current runner - * @param strategy scheduling strategy which may share threads with other strategy - * @param balancer determines maximum concurrent children scheduled a time via {@link #schedule(Runnable)} - * @throws NullPointerException if null strategy or balancer - */ - public Scheduler(ConsoleLogger logger, Description description, SchedulingStrategy strategy, Balancer balancer) { - strategy.setDefaultShutdownHandler(newShutdownHandler()); - this.logger = logger; - this.description = description; - this.strategy = strategy; - this.balancer = balancer; - masterController = null; - } - - /** - * Can be used by e.g. a runner having parallel classes in use case with parallel - * suites, classes and methods sharing the same thread pool. - * - * @param logger current logger implementation - * @param description description of current runner - * @param masterScheduler scheduler sharing own threads with this slave - * @param strategy scheduling strategy for this scheduler - * @param balancer determines maximum concurrent children scheduled a time via {@link #schedule(Runnable)} - * @throws NullPointerException if null masterScheduler, strategy or balancer - */ - public Scheduler( - ConsoleLogger logger, - Description description, - Scheduler masterScheduler, - SchedulingStrategy strategy, - Balancer balancer) { - this(logger, description, strategy, balancer); - strategy.setDefaultShutdownHandler(newShutdownHandler()); - masterScheduler.register(this); - } - - /** - * @param logger console logger - * @param description JUnit description of class - * @param masterScheduler a reference to - * {@link #Scheduler(ConsoleLogger, org.junit.runner.Description, SchedulingStrategy, int)} - * or {@link #Scheduler(ConsoleLogger, org.junit.runner.Description, SchedulingStrategy)} - * @param strategy scheduling strategy - * @param concurrency determines maximum concurrent children scheduled a time via {@link #schedule(Runnable)} - * - * @see #Scheduler(ConsoleLogger, org.junit.runner.Description, SchedulingStrategy) - * @see #Scheduler(ConsoleLogger, org.junit.runner.Description, SchedulingStrategy, int) - */ - public Scheduler( - ConsoleLogger logger, - Description description, - Scheduler masterScheduler, - SchedulingStrategy strategy, - int concurrency) { - this(logger, description, strategy, concurrency); - strategy.setDefaultShutdownHandler(newShutdownHandler()); - masterScheduler.register(this); - } - - /** - * Should be used with individual pools on suites, classes and methods, see - * {@link org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder#useSeparatePools()}. - *
- * Cached thread pool is infinite and can be always shared. - * - * @param logger console logger - * @param description JUnit description of class - * @param masterScheduler parent scheduler - * @param strategy scheduling strategy - */ - public Scheduler( - ConsoleLogger logger, Description description, Scheduler masterScheduler, SchedulingStrategy strategy) { - this(logger, description, masterScheduler, strategy, 0); - } - - private void setController(Controller masterController) { - if (masterController == null) { - throw new NullPointerException("null ExecutionController"); - } - this.masterController = masterController; - } - - /** - * @param slave a slave scheduler to register - * @return {@code true} if successfully registered the slave. - */ - private boolean register(Scheduler slave) { - boolean canRegister = slave != null && slave != this; - if (canRegister) { - Controller controller = new Controller(slave); - canRegister = !slaves.contains(controller); - if (canRegister) { - slaves.add(controller); - slave.setController(controller); - } - } - return canRegister; - } - - /** - * @return {@code true} if new tasks can be scheduled. - */ - private boolean canSchedule() { - return !shutdown && (masterController == null || masterController.canSchedule()); - } - - protected void logQuietly(Throwable t) { - logger.error(t); - } - - protected void logQuietly(String msg) { - logger.warning(msg); - } - - /** - * Attempts to stop all actively executing tasks and immediately returns a collection - * of descriptions of those tasks which have started prior to this call. - *
- * This scheduler and other registered schedulers will stop, see {@link #register(Scheduler)}. - * If shutdownNow is set, waiting methods will be interrupted via {@link Thread#interrupt}. - * - * @param stopNow if {@code true} interrupts waiting test methods - * @return collection of descriptions started before shutting down - */ - protected ShutdownResult describeStopped(boolean stopNow) { - Collection executedTests = new ConcurrentLinkedQueue<>(); - Collection incompleteTests = new ConcurrentLinkedQueue<>(); - stop(executedTests, incompleteTests, false, stopNow); - return new ShutdownResult(executedTests, incompleteTests); - } - - /** - * Stop/Shutdown/Interrupt scheduler and its children (if any). - * - * @param executedTests Started tests which have finished normally or abruptly till called this method. - * @param incompleteTests Started tests which have finished incomplete due to shutdown. - * @param tryCancelFutures Useful to set to {@code false} if a timeout is specified in plugin config. - * When the runner of - * {@link ParallelComputer#getSuite(org.junit.runners.model.RunnerBuilder, Class[])} - * is finished in - * {@link org.junit.runners.Suite#run(org.junit.runner.notification.RunNotifier)} - * all the thread-pools created by {@link ParallelComputerBuilder.PC} are already dead. - * See the unit test {@code ParallelComputerBuilder#timeoutAndForcedShutdown()}. - * @param stopNow Interrupting tests by {@link java.util.concurrent.ExecutorService#shutdownNow()} or - * {@link java.util.concurrent.Future#cancel(boolean) Future#cancel(true)} or - * {@link Thread#interrupt()}. - */ - private void stop( - Collection executedTests, - Collection incompleteTests, - boolean tryCancelFutures, - boolean stopNow) { - shutdown = true; - try { - if (started && !ParallelComputerUtil.isUnusedDescription(description)) { - if (executedTests != null) { - executedTests.add(description); - } - - if (incompleteTests != null && !finished) { - incompleteTests.add(description); - } - } - - for (Controller slave : slaves) { - slave.stop(executedTests, incompleteTests, tryCancelFutures, stopNow); - } - } finally { - try { - balancer.releaseAllPermits(); - } finally { - if (stopNow) { - strategy.stopNow(); - } else if (tryCancelFutures) { - strategy.stop(); - } else { - strategy.disable(); - } - } - } - } - - protected boolean shutdownThreadPoolsAwaitingKilled() { - if (masterController == null) { - stop(null, null, true, false); - boolean isNotInterrupted = true; - if (strategy != null) { - isNotInterrupted = strategy.destroy(); - } - for (Controller slave : slaves) { - isNotInterrupted &= slave.destroy(); - } - return isNotInterrupted; - } else { - throw new UnsupportedOperationException("cannot call this method if this is not a master scheduler"); - } - } - - protected void beforeExecute() {} - - protected void afterExecute() {} - - @Override - public void schedule(Runnable childStatement) { - if (childStatement == null) { - logQuietly("cannot schedule null"); - } else if (canSchedule() && strategy.canSchedule()) { - try { - boolean isNotInterrupted = balancer.acquirePermit(); - if (isNotInterrupted && !shutdown) { - Runnable task = wrapTask(childStatement); - strategy.schedule(task); - started = true; - } - } catch (RejectedExecutionException e) { - stop(null, null, true, false); - } catch (Throwable t) { - balancer.releasePermit(); - logQuietly(t); - } - } - } - - @Override - public void finished() { - try { - strategy.finished(); - } catch (InterruptedException e) { - logQuietly(e); - } finally { - finished = true; - } - } - - private Runnable wrapTask(final Runnable task) { - return new Runnable() { - @Override - public void run() { - try { - beforeExecute(); - task.run(); - } finally { - try { - afterExecute(); - } finally { - balancer.releasePermit(); - } - } - } - }; - } - - protected ShutdownHandler newShutdownHandler() { - return new ShutdownHandler(); - } - - /** - * If this is a master scheduler, the slaves can stop scheduling by the master through the controller. - */ - private final class Controller { - private final Scheduler slave; - - private Controller(Scheduler slave) { - this.slave = slave; - } - - /** - * @return {@code true} if new children can be scheduled. - */ - boolean canSchedule() { - return Scheduler.this.canSchedule(); - } - - void stop( - Collection executedTests, - Collection incompleteTests, - boolean tryCancelFutures, - boolean shutdownNow) { - slave.stop(executedTests, incompleteTests, tryCancelFutures, shutdownNow); - } - - /** - * @see org.apache.maven.surefire.junitcore.pc.Destroyable#destroy() - */ - boolean destroy() { - return slave.strategy.destroy(); - } - - @Override - public int hashCode() { - return slave.hashCode(); - } - - @Override - public boolean equals(Object o) { - return o == this || (o instanceof Controller) && slave.equals(((Controller) o).slave); - } - } - - /** - * There is a way to shutdown the hierarchy of schedulers. You can do it in master scheduler via - * {@link #shutdownThreadPoolsAwaitingKilled()} which kills the current master and children recursively. - * If alternatively a shared {@link java.util.concurrent.ExecutorService} used by the master and children - * schedulers is shutdown from outside, then the {@link ShutdownHandler} is a hook calling current - * {@link #describeStopped(boolean)}. The method {@link #describeStopped(boolean)} is again shutting down children - * schedulers recursively as well. - */ - public class ShutdownHandler implements RejectedExecutionHandler { - private volatile RejectedExecutionHandler poolHandler; - - protected ShutdownHandler() { - poolHandler = null; - } - - public void setRejectedExecutionHandler(RejectedExecutionHandler poolHandler) { - this.poolHandler = poolHandler; - } - - @Override - public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { - if (executor.isShutdown()) { - Scheduler.this.stop(null, null, true, false); - } - final RejectedExecutionHandler poolHandler = this.poolHandler; - if (poolHandler != null) { - poolHandler.rejectedExecution(r, executor); - } - } - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java deleted file mode 100644 index f2a4e7d1e6..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.apache.maven.surefire.api.util.internal.DaemonThreadFactory; - -/** - * The factory of {@link SchedulingStrategy}. - * - * @author Tibor Digana (tibor17) - * @since 2.16 - */ -public class SchedulingStrategies { - private static final ThreadFactory DAEMON_THREAD_FACTORY = DaemonThreadFactory.newDaemonThreadFactory(); - - /** - * @param logger current error logger - * @return sequentially executing strategy - */ - public static SchedulingStrategy createInvokerStrategy(ConsoleLogger logger) { - return new InvokerStrategy(logger); - } - - /** - * @param logger current error logger - * @param nThreads fixed pool capacity - * @return parallel scheduling strategy - */ - public static SchedulingStrategy createParallelStrategy(ConsoleLogger logger, int nThreads) { - return new NonSharedThreadPoolStrategy(logger, Executors.newFixedThreadPool(nThreads, DAEMON_THREAD_FACTORY)); - } - - /** - * @param logger current error logger - * @return parallel scheduling strategy with unbounded capacity - */ - public static SchedulingStrategy createParallelStrategyUnbounded(ConsoleLogger logger) { - return new NonSharedThreadPoolStrategy(logger, Executors.newCachedThreadPool(DAEMON_THREAD_FACTORY)); - } - - /** - * The threadPool passed to this strategy can be shared in other strategies. - *
- * The call {@link SchedulingStrategy#finished()} is waiting until own tasks have finished. - * New tasks will not be scheduled by this call in this strategy. This strategy is not - * waiting for other strategies to finish. The {@link org.junit.runners.model.RunnerScheduler#finished()} may - * freely use {@link SchedulingStrategy#finished()}. - * - * @param logger current error logger - * @param threadPool thread pool possibly shared with other strategies - * @return parallel strategy with shared thread pool - * @throws NullPointerException if threadPool is null - */ - public static SchedulingStrategy createParallelSharedStrategy(ConsoleLogger logger, ExecutorService threadPool) { - if (threadPool == null) { - throw new NullPointerException("null threadPool in #createParallelSharedStrategy"); - } - return new SharedThreadPoolStrategy(logger, threadPool); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java deleted file mode 100644 index 7495464e8a..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; - -/** - * Specifies the strategy of scheduling whether sequential, or parallel. - * The strategy may use a thread pool shared with other strategies. - *
- * One instance of strategy can be used just by one {@link Scheduler}. - *
- * The strategy is scheduling tasks in {@link #schedule(Runnable)} and awaiting them - * completed in {@link #finished()}. Both methods should be used in one thread. - * - * @author Tibor Digana (tibor17) - * @since 2.16 - */ -public abstract class SchedulingStrategy implements Destroyable { - - private final AtomicBoolean canSchedule = new AtomicBoolean(true); - - private final ConsoleLogger logger; - - protected SchedulingStrategy(ConsoleLogger logger) { - this.logger = logger; - } - - /** - * Schedules tasks if {@link #canSchedule()}. - * - * @param task runnable to schedule in a thread pool or invoke - * @throws java.util.concurrent.RejectedExecutionException if task - * cannot be scheduled for execution - * @throws NullPointerException if task is null - * @see org.junit.runners.model.RunnerScheduler#schedule(Runnable) - * @see java.util.concurrent.Executor#execute(Runnable) - */ - protected abstract void schedule(Runnable task); - - /** - * Waiting for scheduled tasks to finish. - * New tasks will not be scheduled by calling this method. - * - * @return {@code true} if successfully stopped the scheduler, else - * {@code false} if already stopped (a shared thread - * pool was shutdown externally). - * @throws InterruptedException if interrupted while waiting - * for scheduled tasks to finish - * @see org.junit.runners.model.RunnerScheduler#finished() - */ - protected abstract boolean finished() throws InterruptedException; - - /** - * Stops scheduling new tasks (e.g. by {@link java.util.concurrent.ExecutorService#shutdown()} - * on a private thread pool which cannot be shared with other strategy). - * - * @return {@code true} if successfully stopped the scheduler, else - * {@code false} if already stopped (a shared thread - * pool was shutdown externally). - * @see java.util.concurrent.ExecutorService#shutdown() - */ - protected abstract boolean stop(); - - /** - * Stops scheduling new tasks and {@code interrupts} running tasks - * (e.g. by {@link java.util.concurrent.ExecutorService#shutdownNow()} on a private thread pool - * which cannot be shared with other strategy). - *
- * This method calls {@link #stop()} by default. - * - * @return {@code true} if successfully stopped the scheduler, else - * {@code false} if already stopped (a shared thread - * pool was shutdown externally). - * @see java.util.concurrent.ExecutorService#shutdownNow() - */ - protected boolean stopNow() { - return stop(); - } - - /** - * Persistently disables this strategy. Atomically ignores {@link Balancer} to acquire a new permit.
- * The method {@link #canSchedule()} atomically returns {@code false}. - * @return {@code true} if {@link #canSchedule()} has return {@code true} on the beginning of this method call. - */ - protected boolean disable() { - return canSchedule.getAndSet(false); - } - - protected void setDefaultShutdownHandler(Scheduler.ShutdownHandler handler) {} - - /** - * @return {@code true} if a thread pool associated with this strategy - * can be shared with other strategies. - */ - protected abstract boolean hasSharedThreadPool(); - - /** - * @return {@code true} unless stopped, finished or disabled. - */ - protected boolean canSchedule() { - return canSchedule.get(); - } - - protected void logQuietly(Throwable t) { - logger.error(t); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SharedThreadPoolStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SharedThreadPoolStrategy.java deleted file mode 100644 index e24ad1bfa0..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SharedThreadPoolStrategy.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.concurrent.CancellationException; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; - -/** - * Parallel strategy for shared thread pool in private package. - * - * @author Tibor Digana (tibor17) - * @see AbstractThreadPoolStrategy - * @since 2.16 - */ -final class SharedThreadPoolStrategy extends AbstractThreadPoolStrategy { - SharedThreadPoolStrategy(ConsoleLogger logger, ExecutorService threadPool) { - super(logger, threadPool, new ConcurrentLinkedQueue<>()); - } - - @Override - public boolean hasSharedThreadPool() { - return true; - } - - @Override - public boolean finished() throws InterruptedException { - boolean wasRunningAll = disable(); - for (Future futureResult : getFutureResults()) { - try { - futureResult.get(); - } catch (InterruptedException e) { - // after called external ExecutorService#shutdownNow() - wasRunningAll = false; - } catch (ExecutionException e) { - // JUnit core throws exception. - if (e.getCause() != null) { - logQuietly(e.getCause()); - } - } catch (CancellationException e) { - /** - * Cancelled by {@link Future#cancel(boolean)} in {@link stop()} and {@link stopNow()}. - */ - } - } - return wasRunningAll; - } - - @Override - protected boolean stop() { - return stop(false); - } - - @Override - protected boolean stopNow() { - return stop(true); - } - - private boolean stop(boolean interrupt) { - final boolean wasRunning = disable(); - for (Future futureResult : getFutureResults()) { - futureResult.cancel(interrupt); - } - return wasRunning; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownResult.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownResult.java deleted file mode 100644 index c43914f7d8..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownResult.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.Collection; -import java.util.Collections; - -import org.junit.runner.Description; - -/** - * Populates collection {@code triggeredTests} of descriptions started before shutting down. - * Populates collection {@code incompleteTests} which describes started tests but unfinished due to abrupt shutdown. - * The collection {@code triggeredTests} contains all elements from {@code incompleteTests}. - * - * @author Tibor Digana (tibor17) - * @see Scheduler - * @since 2.18 - */ -public final class ShutdownResult { - private final Collection triggeredTests; - - private final Collection incompleteTests; - - public ShutdownResult(Collection triggeredTests, Collection incompleteTests) { - this.triggeredTests = triggeredTests == null ? Collections.emptySet() : triggeredTests; - this.incompleteTests = incompleteTests == null ? Collections.emptySet() : incompleteTests; - } - - public Collection getTriggeredTests() { - return triggeredTests; - } - - public Collection getIncompleteTests() { - return incompleteTests; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownStatus.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownStatus.java deleted file mode 100644 index cde6fe7361..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownStatus.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.concurrent.Future; -import java.util.concurrent.atomic.AtomicReference; - -/** - * Wrapper of {@link ParallelComputer ParallelComputer status information} and tests been populated before - * a shutdown hook has been triggered. - * - * @author Tibor Digana (tibor17) - * @see ParallelComputer - * @since 2.18 - */ -final class ShutdownStatus { - private final AtomicReference status = new AtomicReference<>(ExecutionStatus.STARTED); - - private Future descriptionsBeforeShutdown; - - boolean tryFinish() { - return status.compareAndSet(ExecutionStatus.STARTED, ExecutionStatus.FINISHED); - } - - boolean tryTimeout() { - return status.compareAndSet(ExecutionStatus.STARTED, ExecutionStatus.TIMEOUT); - } - - boolean isTimeoutElapsed() { - return status.get() == ExecutionStatus.TIMEOUT; - } - - Future getDescriptionsBeforeShutdown() { - return descriptionsBeforeShutdown; - } - - void setDescriptionsBeforeShutdown(Future descriptionsBeforeShutdown) { - this.descriptionsBeforeShutdown = descriptionsBeforeShutdown; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java deleted file mode 100644 index 304fa87dd9..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.Collection; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.apache.maven.surefire.api.util.internal.DaemonThreadFactory; -import org.junit.runner.Description; -import org.junit.runners.model.RunnerScheduler; - -/** - * Used to execute tests annotated with net.jcip.annotations.NotThreadSafe. - *
- * - * @author Tibor Digana (tibor17) - * @see ParallelComputerBuilder - * @since 2.18 - */ -final class SingleThreadScheduler { - private final ConsoleLogger logger; - - private final ExecutorService pool = newPool(); - - private final Scheduler master; - - private static ExecutorService newPool() { - ThreadFactory tf = DaemonThreadFactory.newDaemonThreadFactory("maven-surefire-plugin@NotThreadSafe"); - return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), tf); - } - - SingleThreadScheduler(ConsoleLogger logger) { - this.logger = logger; - SchedulingStrategy strategy = SchedulingStrategies.createParallelSharedStrategy(logger, pool); - master = new Scheduler(logger, null, strategy); - } - - RunnerScheduler newRunnerScheduler() { - SchedulingStrategy strategy = SchedulingStrategies.createParallelSharedStrategy(logger, pool); - return new Scheduler(logger, null, master, strategy); - } - - /** - * @see Scheduler#describeStopped(boolean) - */ - ShutdownResult describeStopped(boolean shutdownNow) { - ShutdownResult shutdownResult = master.describeStopped(shutdownNow); - return new ShutdownResult( - copyExisting(shutdownResult.getTriggeredTests()), copyExisting(shutdownResult.getIncompleteTests())); - } - - /** - * @see Scheduler#shutdownThreadPoolsAwaitingKilled() - */ - boolean shutdownThreadPoolsAwaitingKilled() { - return master.shutdownThreadPoolsAwaitingKilled(); - } - - private Collection copyExisting(Collection descriptions) { - Collection activeChildren = new ConcurrentLinkedQueue<>(descriptions); - ParallelComputerUtil.removeUnusedDescriptions(activeChildren); - return activeChildren; - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ThreadResourcesBalancer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ThreadResourcesBalancer.java deleted file mode 100644 index 5bb47dd4a1..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ThreadResourcesBalancer.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.concurrent.Semaphore; - -/** - * @author Tibor Digana (tibor17) - * @see Balancer - * @since 2.16 - */ -final class ThreadResourcesBalancer implements Balancer { - private final Semaphore balancer; - - private final int numPermits; - - /** - * fair set to false. - * - * @param numPermits number of permits to acquire when maintaining concurrency on tests. - * Must be >0 and < {@link Integer#MAX_VALUE}. - * @see #ThreadResourcesBalancer(int, boolean) - */ - ThreadResourcesBalancer(int numPermits) { - this(numPermits, false); - } - - /** - * @param numPermits number of permits to acquire when maintaining concurrency on tests. - * Must be >0 and < {@link Integer#MAX_VALUE}. - * @param fair {@code true} guarantees the waiting schedulers to wake up in order they acquired a permit - * @throws IllegalArgumentException if numPermits is not positive number - */ - ThreadResourcesBalancer(int numPermits, boolean fair) { - if (numPermits <= 0) { - throw new IllegalArgumentException(String.format("numPermits=%d should be positive number", numPermits)); - } - balancer = new Semaphore(numPermits, fair); - this.numPermits = numPermits; - } - - /** - * Acquires a permit from this balancer, blocking until one is available. - * - * @return {@code true} if current thread is NOT interrupted - * while waiting for a permit. - */ - @Override - public boolean acquirePermit() { - try { - balancer.acquire(); - return true; - } catch (InterruptedException e) { - return false; - } - } - - /** - * Releases a permit, returning it to the balancer. - */ - @Override - public void releasePermit() { - balancer.release(); - } - - @Override - public void releaseAllPermits() { - balancer.release(numPermits); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Type.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Type.java deleted file mode 100644 index a48397f1ac..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Type.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -/** - * @author tibor17 (Tibor Digana) - * @since 2.17 - */ -enum Type { - SUITES, - CLASSES, - METHODS -} diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/WrappedRunners.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/WrappedRunners.java deleted file mode 100644 index 5b47a544ad..0000000000 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/WrappedRunners.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import org.junit.runners.ParentRunner; - -/** - * We need to wrap runners in a suite and count children of these runners. - *
- * Old JUnit versions do not cache children after the first call of - * {@link org.junit.runners.ParentRunner#getChildren()}. - * Due to performance reasons, the children have to be observed just once. - * - * @author tibor17 (Tibor Digana) - * @see ParallelComputerBuilder - * @since 2.17 - */ -final class WrappedRunners { - final ParentRunner wrappingSuite; - - final long embeddedChildrenCount; - - WrappedRunners(ParentRunner wrappingSuite, long embeddedChildrenCount) { - this.wrappingSuite = wrappingSuite; - this.embeddedChildrenCount = embeddedChildrenCount; - } - - WrappedRunners() { - this(null, 0); - } -} diff --git a/surefire-providers/surefire-junit47/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider b/surefire-providers/surefire-junit47/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider deleted file mode 100644 index 584ed7a3e1..0000000000 --- a/surefire-providers/surefire-junit47/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider +++ /dev/null @@ -1 +0,0 @@ -org.apache.maven.surefire.junitcore.JUnitCoreProvider diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentRunListenerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentRunListenerTest.java deleted file mode 100644 index 00f6104a0d..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentRunListenerTest.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.util.HashMap; -import java.util.Map; - -import junit.framework.Assert; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.apache.maven.plugin.surefire.report.DefaultReporterFactory; -import org.apache.maven.surefire.api.report.ReporterFactory; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.report.RunStatistics; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.Computer; -import org.junit.runner.JUnitCore; - -/** - * @author Kristian Rosenvold - */ -public class ConcurrentRunListenerTest extends TestCase { - // Tests are in order of increasing complexity - public void testNoErrorsCounting() throws Exception { - runClasses(3, 0, 0, DummyAllOk.class); - } - - public void testNoErrorsCounting2() throws Exception { - runClasses(2, 0, 0, Dummy3.class); - } - - public void testOneIgnoreCounting() throws Exception { - runClasses(3, 1, 0, DummyWithOneIgnore.class); - } - - public void testOneFailureCounting() throws Exception { - runClasses(3, 0, 1, DummyWithFailure.class); - } - - public void testWithErrorsCountingDemultiplexed() throws Exception { - runClasses(6, 1, 1, DummyWithOneIgnore.class, DummyWithFailure.class); - } - - public void testJunitResultCountingDemultiplexed() throws Exception { - runClasses(8, 1, 1, DummyWithOneIgnore.class, DummyWithFailure.class, Dummy3.class); - } - - public void testJunitResultCountingJUnit3Demultiplexed() throws Exception { - runClasses(3, 0, 0, Junit3Tc1.class, Junit3Tc2.class); - } - - public void testJunitResultCountingJUnit3OddTest() throws Exception { - runClasses(2, 0, 0, Junit3OddTest1.class); - } - - public void testJunit3WithNestedSuite() throws TestSetFailedException { - runClasses(4, 0, 0, Junit3WithNestedSuite.class); - } - - public void testJunit3NestedSuite() throws Exception { - runClasses(2, 0, 0, Junit3OddTest1.class); - } - - public void testSimpleOutput() throws Exception { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - PrintStream collector = new PrintStream(byteArrayOutputStream); - PrintStream orgOur = System.out; - System.setOut(collector); - - RunStatistics result = runClasses(Dummy3.class); - assertReporter(result, 2, 0, 0, "msgs"); - - String foo = new String(byteArrayOutputStream.toByteArray()); - assertNotNull(foo); - - System.setOut(orgOur); - } - - public void testOutputOrdering() throws Exception { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - PrintStream collector = new PrintStream(byteArrayOutputStream); - PrintStream orgOur = System.out; - System.setOut(collector); - - RunStatistics result = runClasses(DummyWithOneIgnore.class, DummyWithFailure.class, Dummy3.class); - assertReporter(result, 8, 1, 1, "msgs"); - - String foo = new String(byteArrayOutputStream.toByteArray()); - assertNotNull(foo); - - System.setOut(orgOur); - - // final List stringList = result.getEvents(); - // assertEquals( 23, stringList.size() ); - } - - private void runClasses(int success, int ignored, int failure, Class... classes) throws TestSetFailedException { - DefaultReporterFactory reporterFactory = createReporterFactory(); - HashMap classMethodCounts = new HashMap<>(); - ConcurrentRunListener reporter = new ClassesParallelRunListener(classMethodCounts, reporterFactory); - JUnitCoreRunListener runListener = new JUnitCoreRunListener(reporter, classMethodCounts); - RunStatistics result = runClasses(reporterFactory, runListener, classes); - assertReporter(result, success, ignored, failure, "classes"); - classMethodCounts.clear(); - - reporterFactory = createReporterFactory(); - reporter = new MethodsParallelRunListener(classMethodCounts, reporterFactory, true); - runListener = new JUnitCoreRunListener(reporter, classMethodCounts); - result = runClasses(reporterFactory, runListener, classes); - assertReporter(result, success, ignored, failure, "methods"); - } - - private RunStatistics runClasses(Class... classes) throws TestSetFailedException { - HashMap classMethodCounts = new HashMap<>(); - final DefaultReporterFactory reporterManagerFactory = createReporterFactory(); - org.junit.runner.notification.RunListener demultiplexingRunListener = - createRunListener(reporterManagerFactory, classMethodCounts); - - JUnitCore jUnitCore = new JUnitCore(); - - jUnitCore.addListener(demultiplexingRunListener); - Computer computer = new Computer(); - - jUnitCore.run(computer, classes); - reporterManagerFactory.close(); - return reporterManagerFactory.getGlobalRunStatistics(); - } - - private RunStatistics runClasses( - DefaultReporterFactory reporterManagerFactory, - org.junit.runner.notification.RunListener demultiplexingRunListener, - Class... classes) - throws TestSetFailedException { - - JUnitCore jUnitCore = new JUnitCore(); - - jUnitCore.addListener(demultiplexingRunListener); - Computer computer = new Computer(); - - jUnitCore.run(computer, classes); - return reporterManagerFactory.getGlobalRunStatistics(); - } - - private org.junit.runner.notification.RunListener createRunListener( - ReporterFactory reporterFactory, Map testSetMap) { - ConcurrentRunListener handler = new ClassesParallelRunListener(testSetMap, reporterFactory); - return new JUnitCoreRunListener(handler, testSetMap); - } - - /** - * - */ - public static class DummyWithOneIgnore { - @Test - public void testNotMuch() {} - - @Ignore - @Test - public void testStub1() {} - - @Test - public void testStub2() {} - } - - /** - * - */ - public static class DummyWithFailure { - @Test - public void testBeforeFail() {} - - @Test - public void testWillFail() { - Assert.fail("We will fail"); - } - - @Test - public void testAfterFail() {} - } - - /** - * - */ - public static class DummyAllOk { - - @Test - public void testNotMuchA() {} - - @Test - public void testStub1A() {} - - @Test - public void testStub2A() {} - } - - /** - * - */ - public static class Dummy3 { - - @Test - public void testNotMuchA() { - System.out.println("tNMA1"); - System.err.println("tNMA1err"); - } - - @Test - public void testStub2A() { - System.out.println("tS2A"); - System.err.println("tS2AErr"); - } - } - - /** - * - */ - public static class Junit3Tc1 extends TestCase { - - public Junit3Tc1() { - super("testNotMuchJunit3TC1"); - } - - public void testNotMuchJunit3TC1() { - System.out.println("Junit3TC1"); - } - - public static junit.framework.Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(new Junit3Tc1()); - return suite; - } - } - - /** - * - */ - public static class Junit3Tc2 extends TestCase { - public Junit3Tc2(String testMethod) { - super(testMethod); - } - - public void testNotMuchJunit3TC2() { - System.out.println("Junit3TC2"); - } - - public void testStubJ3TC2A() { - System.out.println("testStubJ3TC2A"); - } - - public static junit.framework.Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(new Junit3Tc2("testNotMuchJunit3TC2")); - suite.addTest(new Junit3Tc2("testStubJ3TC2A")); - return suite; - } - } - - /** - * - */ - public static class Junit3OddTest1 extends TestCase { - public static junit.framework.Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTest(new Junit3OddTest1("testMe")); - suite.addTest(new Junit3OddTest1("testMe2")); - - return suite; - } - - public Junit3OddTest1(String name) { - super(name); - } - - public void testMe() { - assertTrue(true); - } - } - - /** - * - */ - public static class Junit3WithNestedSuite extends TestCase { - public static junit.framework.Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTest(new Junit3WithNestedSuite("testMe")); - suite.addTest(new Junit3WithNestedSuite("testMe2")); - suite.addTestSuite(Junit3Tc2.class); - return suite; - } - - public Junit3WithNestedSuite(String name) { - super(name); - } - - public void testMe2() { - assertTrue(true); - } - } - - private DefaultReporterFactory createReporterFactory() { - return JUnitCoreTester.defaultNoXml(); - } - - private void assertReporter(RunStatistics result, int success, int ignored, int failure, String message) { - assertEquals(message, success, result.getCompletedCount()); - assertEquals(message, ignored, result.getSkipped()); - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputerTest.java deleted file mode 100644 index 07f83b5c16..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputerTest.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutionException; - -import junit.framework.TestCase; -import org.junit.Test; -import org.junit.runner.Computer; -import org.junit.runner.JUnitCore; -import org.junit.runner.Result; -import org.junit.runner.notification.RunListener; - -/** - * Simple test of ConfigurableParallelComputer. - * - * @author Kristian Rosenvold - */ -public class ConfigurableParallelComputerTest extends TestCase { - private static final int NUMTESTS = 1000; - - // I'm sorry about all the sout's in this test; but if you deadlock when building you will appreciate it. - - @Test - public void testAnythingYouWantToPlayWith() throws Exception { - Result result = new Result(); - Class[] realClasses = new Class[] {Dummy.class, Dummy2.class}; - - DiagnosticRunListener diagnosticRunListener = new DiagnosticRunListener(false, result.createListener()); - JUnitCore jUnitCore = getJunitCore(diagnosticRunListener); - ConfigurableParallelComputer computer = new ConfigurableParallelComputer(true, false); - jUnitCore.run(computer, realClasses); - computer.close(); - assertEquals("All tests should succeed, right ?", 5, result.getRunCount()); - } - - @Test - public void testOneMethod() throws ExecutionException { - JUnitCore jUnitCore = new JUnitCore(); - ConfigurableParallelComputer computer = new ConfigurableParallelComputer(false, true); - jUnitCore.run(computer, new Class[] {Dummy.class, Dummy.class, Dummy.class}); - computer.close(); - } - - @Test - public void testSerial() throws Exception { - Result result = new Result(); - Class[] realClasses = getClassList(); - JUnitCore jUnitCore = getJunitCore(result); - Computer computer = new Computer(); - timedRun(NUMTESTS, result, realClasses, jUnitCore, computer); - } - - @Test - public void testFullTestRunPC() throws Exception { - Result result = new Result(); - Class[] realClasses = getClassList(); - JUnitCore jUnitCore = getJunitCore(result); - Computer computer = new ConfigurableParallelComputer(true, true); - timedRun(NUMTESTS, result, realClasses, jUnitCore, computer); - } - - @Test - public void testWithFailingAssertionCPC() throws Exception { - runWithFailingAssertion(new ConfigurableParallelComputer(false, true, 6, true)); - runWithFailingAssertion(new ConfigurableParallelComputer(true, false, 12, false)); - runWithFailingAssertion(new ConfigurableParallelComputer(true, true, 2, false)); - } - - @Test - public void testWithSlowTestJustAfew() throws Exception { - Result result = new Result(); - final Computer computer = new ConfigurableParallelComputer(false, true, 3, false); - Class[] realClasses = getClassList(SlowTest.class, 5); // 300 ms in methods, 600 in classes - - JUnitCore jUnitCore = getJunitCore(result); - runIt(realClasses, jUnitCore, computer); - } - - private void runWithFailingAssertion(Computer computer) throws ExecutionException { - Result result = new Result(); - Class[] realClasses = getClassList(FailingAssertions.class); - JUnitCore jUnitCore = getJunitCore(result); - runIt(realClasses, jUnitCore, computer); - assertEquals( - "No tests should fail, right ?", NUMTESTS, result.getFailures().size()); - assertEquals("All tests should succeed, right ?", 0, result.getIgnoreCount()); - assertEquals("All tests should succeed, right ?", NUMTESTS * 3, result.getRunCount()); - } - - @Test - public void testWithFailure() throws Exception { - Computer computer = new ConfigurableParallelComputer(false, true, 4, true); - Result result = new Result(); - Class[] realClasses = getClassList(Failure.class); - JUnitCore jUnitCore = getJunitCore(result); - runIt(realClasses, jUnitCore, computer); - assertEquals( - "No tests should fail, right ?", NUMTESTS, result.getFailures().size()); - assertEquals("All tests should succeed, right ?", 0, result.getIgnoreCount()); - assertEquals("All tests should succeed, right ?", NUMTESTS * 3, result.getRunCount()); - } - - @Test - public void testFixedThreadPool() throws Exception { - Result result = new Result(); - Class[] realClasses = getClassList(); - JUnitCore jUnitCore = getJunitCore(result); - ConfigurableParallelComputer computer = new ConfigurableParallelComputer(false, true, 2, false); - timedRun(NUMTESTS, result, realClasses, jUnitCore, computer); - } - - @Test - public void testClassesUnlimited() throws Exception { - Result result = new Result(); - Class[] realClasses = getClassList(); - JUnitCore jUnitCore = getJunitCore(result); - ConfigurableParallelComputer computer = new ConfigurableParallelComputer(true, false); - timedRun(NUMTESTS, result, realClasses, jUnitCore, computer); - } - - @Test - public void testBothUnlimited() throws Exception { - Result result = new Result(); - Class[] realClasses = getClassList(); - DiagnosticRunListener diagnosticRunListener = new DiagnosticRunListener(false, result.createListener()); - JUnitCore jUnitCore = getJunitCore(diagnosticRunListener); - ConfigurableParallelComputer computer = new ConfigurableParallelComputer(true, true); - timedRun(NUMTESTS, result, realClasses, jUnitCore, computer); - } - - private JUnitCore getJunitCore(Result result) { - RunListener listener = result.createListener(); - JUnitCore jUnitCore = new JUnitCore(); - jUnitCore.addListener(listener); - return jUnitCore; - } - - private JUnitCore getJunitCore(RunListener listener) { - JUnitCore jUnitCore = new JUnitCore(); - jUnitCore.addListener(listener); - return jUnitCore; - } - - private long runIt(Class[] realClasses, JUnitCore jUnitCore, Computer computer) throws ExecutionException { - long start = System.currentTimeMillis(); - jUnitCore.run(computer, realClasses); - if (computer instanceof ConfigurableParallelComputer) { - ((ConfigurableParallelComputer) computer).close(); - } - return System.currentTimeMillis() - start; - } - - private long timedRun(int numTests, Result result, Class[] realClasses, JUnitCore jUnitCore, Computer computer) - throws ExecutionException { - long time = runIt(realClasses, jUnitCore, computer); - assertEquals("No tests should fail, right ?", 0, result.getFailures().size()); - assertEquals("All tests should succeed, right ?", 0, result.getIgnoreCount()); - assertEquals("All tests should succeed, right ?", numTests * 3, result.getRunCount()); - return time; - } - - private Class[] getClassList() { - return getClassList(Dummy.class, NUMTESTS); - } - - private Class[] getClassList(Class testClass) { - return getClassList(testClass, NUMTESTS); - } - - private Class[] getClassList(Class testClass, int numItems) { - List> realClasses = new ArrayList<>(); - for (int i = 0; i < numItems; i++) { - realClasses.add(testClass); - } - return realClasses.toArray(new Class[realClasses.size()]); - } - - static void sleepReallyEvenOnWindows(long ms) throws InterruptedException { - long endAt = System.currentTimeMillis() + ms; - Thread.sleep(ms); - while (endAt > System.currentTimeMillis()) { - Thread.sleep(ms / 10); - Thread.yield(); - } - } - - /** - * - */ - public static class Dummy { - @Test - public void testNotMuch() {} - - @Test - public void testStub1() { - // Add your code here - } - - @Test - public void testStub2() { - // Add your code here - } - } - - /** - * - */ - public static class Dummy2 { - @Test - public void testNotMuch() {} - - @Test - public void testDummy2() { - // Add your code here - } - } - - /** - * - */ - public static class SlowTest { - final int scaling = 100; - - @Test - public void testNotMuch() throws InterruptedException { - sleepReallyEvenOnWindows(scaling); - } - - @Test - public void testNotMuch2() throws InterruptedException { - sleepReallyEvenOnWindows(3 * scaling); - } - - @Test - public void testNotMuch3() throws InterruptedException { - sleepReallyEvenOnWindows(2 * scaling); - } - } - - /** - * - */ - public static class FailingAssertions { - @Test - public void testNotMuch() {} - - @Test - public void testNotMuch2() {} - - @Test - public void testWithFail() { - fail("We excpect this"); - } - } - - /** - * - */ - public static class Failure { - @Test - public void testNotMuch() {} - - @Test - public void testNotMuch2() {} - - @Test - public void testWithException() { - throw new RuntimeException("We expect this"); - } - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DiagnosticRunListener.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DiagnosticRunListener.java deleted file mode 100644 index 78042fa40a..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DiagnosticRunListener.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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.surefire.junitcore; - -/* - * 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. - * - * Also licensed under CPL http://junit.sourceforge.net/cpl-v10.html - */ - -import java.util.concurrent.atomic.AtomicInteger; - -import org.junit.runner.Description; -import org.junit.runner.Result; -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunListener; - -/** - * @author Kristian Rosenvold, kristianAzeniorD0Tno - */ -public class DiagnosticRunListener extends RunListener { - private final AtomicInteger numTestStarted = new AtomicInteger(); - - private final AtomicInteger numTestFailed = new AtomicInteger(); - - private final AtomicInteger numTestAssumptionsFailed = new AtomicInteger(); - - private final AtomicInteger numTestFinished = new AtomicInteger(); - - private final AtomicInteger numTestIgnored = new AtomicInteger(); - - private final boolean printToConsole; - - private final RunListener target; - - private void print(String event, Description description) { - if (printToConsole) { - System.out.println(Thread.currentThread().toString() + ", event = " + event + ", " + description); - } - } - - private void print(String event, Result description) { - if (printToConsole) { - System.out.println(Thread.currentThread().toString() + ", event = " + event + ", " + description); - } - } - - private void print(String event, Failure description) { - if (printToConsole) { - System.out.println(Thread.currentThread().toString() + ", event = " + event + ", " + description); - } - } - - public DiagnosticRunListener(boolean printToConsole, RunListener target) { - this.printToConsole = printToConsole; - this.target = target; - } - - @Override - public void testRunStarted(Description description) throws Exception { - print("testRunStarted", description); - if (target != null) { - target.testRunStarted(description); - } - } - - @Override - public void testRunFinished(Result result) throws Exception { - print("testRunFinished", result); - if (target != null) { - target.testRunFinished(result); - } - } - - @Override - public void testStarted(Description description) throws Exception { - numTestStarted.incrementAndGet(); - print("testStarted", description); - if (target != null) { - target.testStarted(description); - } - } - - @Override - public void testFinished(Description description) throws Exception { - numTestFinished.incrementAndGet(); - print("testFinished", description); - if (target != null) { - target.testFinished(description); - } - } - - @Override - public void testFailure(Failure failure) throws Exception { - numTestFailed.incrementAndGet(); - print("testFailure", failure); - if (target != null) { - target.testFailure(failure); - } - } - - @Override - public void testAssumptionFailure(Failure failure) { - numTestAssumptionsFailed.incrementAndGet(); - print("testAssumptionFailure", failure); - if (target != null) { - target.testAssumptionFailure(failure); - } - } - - @Override - public void testIgnored(Description description) throws Exception { - numTestIgnored.incrementAndGet(); - print("testIgnored", description); - if (target != null) { - target.testIgnored(description); - } - } - - @Override - public String toString() { - return "DiagnosticRunListener{" + "numTestIgnored=" + numTestIgnored + ", numTestStarted=" + numTestStarted - + ", numTestFailed=" + numTestFailed + ", numTestAssumptionsFailed=" + numTestAssumptionsFailed - + ", numTestFinished=" + numTestFinished + '}'; - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit47SuiteTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit47SuiteTest.java deleted file mode 100644 index 5c01d272cc..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit47SuiteTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.surefire.junitcore; - -import junit.framework.JUnit4TestAdapter; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.apache.maven.surefire.junitcore.pc.OptimizedParallelComputerTest; -import org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilderTest; -import org.apache.maven.surefire.junitcore.pc.ParallelComputerUtilTest; -import org.apache.maven.surefire.junitcore.pc.SchedulingStrategiesTest; - -/** - * Adapt the JUnit47 tests which use only annotations to the JUnit3 test suite. - * - * @author Tibor Digana (tibor17) - * @since 2.16 - */ -public class JUnit47SuiteTest extends TestCase { - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTestSuite(ConcurrentRunListenerTest.class); - suite.addTestSuite(ConfigurableParallelComputerTest.class); - suite.addTestSuite(JUnitCoreRunListenerTest.class); - suite.addTestSuite(MavenSurefireJUnit47RunnerTest.class); - suite.addTestSuite(MavenSurefireJUnit48RunnerTest.class); - suite.addTestSuite(TestMethodTest.class); - suite.addTest(new JUnit4TestAdapter(Surefire746Test.class)); - suite.addTest(new JUnit4TestAdapter(Surefire813IncorrectResultTest.class)); - suite.addTest(new JUnit4TestAdapter(ParallelComputerUtilTest.class)); - suite.addTest(new JUnit4TestAdapter(ParallelComputerBuilderTest.class)); - suite.addTest(new JUnit4TestAdapter(SchedulingStrategiesTest.class)); - suite.addTest(new JUnit4TestAdapter(OptimizedParallelComputerTest.class)); - suite.addTest(new JUnit4TestAdapter(JUnit4Reflector481Test.class)); - suite.addTest(new JUnit4TestAdapter(JUnitCoreParametersTest.class)); - return suite; - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4Reflector481Test.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4Reflector481Test.java deleted file mode 100644 index f20d2e36ec..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4Reflector481Test.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.apache.maven.surefire.api.util.ReflectionUtils; -import org.apache.maven.surefire.common.junit4.JUnit4Reflector; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.Description; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; - -/** - * Reflector Test with junit 4.8.1 - * - * @author Kristian Rosenvold - */ -public class JUnit4Reflector481Test { - private static final Class[] EMPTY_CLASS_ARRAY = new Class[0]; - - @Test - public void testGetAnnotatedIgnore() { - final Method testSomething2 = - ReflectionUtils.getMethod(IgnoreWithDescription.class, "testSomething2", EMPTY_CLASS_ARRAY); - final Annotation[] annotations = testSomething2.getAnnotations(); - Description desc = - Description.createTestDescription(IgnoreWithDescription.class, "testSomething2", annotations); - Ignore annotatedIgnore = JUnit4Reflector.getAnnotatedIgnore(desc); - assertNotNull(annotatedIgnore); - assertEquals( - "testSomething2" + "(org.apache.maven.surefire.junitcore.JUnit4Reflector481Test$IgnoreWithDescription)", - desc.getDisplayName()); - assertEquals( - "testSomething2" + "(org.apache.maven.surefire.junitcore.JUnit4Reflector481Test$IgnoreWithDescription)", - desc.toString()); - assertEquals( - "org.apache.maven.surefire.junitcore.JUnit4Reflector481Test$IgnoreWithDescription", - desc.getClassName()); - assertEquals("testSomething2", desc.getMethodName()); - assertEquals(0, desc.getChildren().size()); - assertEquals(2, desc.getAnnotations().size()); - assertSame(annotatedIgnore, desc.getAnnotation(Ignore.class)); - assertEquals(REASON, annotatedIgnore.value()); - } - - @Test - public void testGetAnnotatedIgnoreWithoutClass() { - final Method testSomething2 = - ReflectionUtils.getMethod(IgnoreWithDescription.class, "testSomething2", EMPTY_CLASS_ARRAY); - final Annotation[] annotations = testSomething2.getAnnotations(); - Description desc = Description.createSuiteDescription("testSomething2", annotations); - Ignore annotatedIgnore = JUnit4Reflector.getAnnotatedIgnore(desc); - assertNotNull(annotatedIgnore); - assertEquals("testSomething2", desc.getDisplayName()); - assertEquals("testSomething2", desc.toString()); - assertEquals("testSomething2", desc.getClassName()); - assertNull(desc.getMethodName()); - assertEquals(0, desc.getChildren().size()); - assertEquals(2, desc.getAnnotations().size()); - assertSame(annotatedIgnore, desc.getAnnotation(Ignore.class)); - assertEquals(REASON, annotatedIgnore.value()); - } - - private static final String REASON = "Ignorance is bliss"; - - /** - * - */ - public static class IgnoreWithDescription { - - @Test - @Ignore(REASON) - public void testSomething2() {} - } - - @Test - public void testCreatePureDescription() { - Description description = JUnit4Reflector.createDescription("exception"); - assertEquals("exception", description.getDisplayName()); - assertEquals("exception", description.toString()); - assertEquals(0, description.getChildren().size()); - } - - @Test - public void testCreateDescription() { - Ignore ignore = JUnit4Reflector.createIgnored("error"); - Description description = JUnit4Reflector.createDescription("exception", ignore); - assertEquals("exception", description.getDisplayName()); - assertEquals("exception", description.toString()); - assertEquals("exception", description.getClassName()); - assertEquals(0, description.getChildren().size()); - Ignore annotatedIgnore = JUnit4Reflector.getAnnotatedIgnore(description); - assertNotNull(annotatedIgnore); - assertEquals("error", annotatedIgnore.value()); - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java deleted file mode 100644 index 93e1adf954..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -/** - * @author Kristian Rosenvold, kristian.rosenvold@gmail com - */ -@SuppressWarnings("checkstyle:magicnumber") -public class JUnitCoreParametersTest { - @Test - public void defaultParameters() { - assertFalse(newTestSetDefault().isParallelismSelected()); - assertTrue(newTestSetDefault().isPerCoreThreadCount()); - assertThat(newTestSetDefault().getThreadCount(), is(0)); - assertThat(newTestSetDefault().getThreadCountMethods(), is(0)); - assertThat(newTestSetDefault().getThreadCountClasses(), is(0)); - assertThat(newTestSetDefault().getThreadCountSuites(), is(0)); - assertFalse(newTestSetDefault().isUseUnlimitedThreads()); - assertThat(newTestSetDefault().getParallelTestsTimeoutInSeconds(), is(0d)); - assertThat(newTestSetDefault().getParallelTestsTimeoutForcedInSeconds(), is(0d)); - assertTrue(newTestSetDefault().isParallelOptimization()); - assertTrue(newTestSetDefault().isEnableOutErrElements()); - assertTrue(newTestSetDefault().isEnablePropertiesElement()); - } - - @Test - public void optimizationParameter() { - assertFalse(newTestSetOptimization(false).isParallelOptimization()); - } - - @Test - public void timeoutParameters() { - JUnitCoreParameters parameters = newTestSetTimeouts(5.5d, 11.1d); - assertThat(parameters.getParallelTestsTimeoutInSeconds(), is(5.5d)); - assertThat(parameters.getParallelTestsTimeoutForcedInSeconds(), is(11.1d)); - } - - @Test - public void isParallelMethod() { - assertFalse(newTestSetClasses().isParallelMethods()); - assertTrue(newTestSetMethods().isParallelMethods()); - assertTrue(newTestSetBoth().isParallelMethods()); - } - - @Test - public void isParallelClasses() { - assertTrue(newTestSetClasses().isParallelClasses()); - assertFalse(newTestSetMethods().isParallelClasses()); - assertTrue(newTestSetBoth().isParallelClasses()); - } - - @Test - public void isParallelBoth() { - assertFalse(isParallelMethodsAndClasses(newTestSetClasses())); - assertFalse(isParallelMethodsAndClasses(newTestSetMethods())); - assertTrue(isParallelMethodsAndClasses(newTestSetBoth())); - } - - @Test - public void isPerCoreThreadCount() { - assertFalse(newTestSetClasses().isPerCoreThreadCount()); - assertFalse(newTestSetMethods().isPerCoreThreadCount()); - assertTrue(newTestSetBoth().isPerCoreThreadCount()); - } - - @Test - public void getThreadCount() { - assertFalse(newTestSetClasses().isPerCoreThreadCount()); - assertFalse(newTestSetMethods().isPerCoreThreadCount()); - assertTrue(newTestSetBoth().isPerCoreThreadCount()); - } - - @Test - public void isUseUnlimitedThreads() { - assertFalse(newTestSetClasses().isUseUnlimitedThreads()); - assertTrue(newTestSetMethods().isUseUnlimitedThreads()); - assertFalse(newTestSetBoth().isUseUnlimitedThreads()); - } - - @Test - public void isNoThreading() { - assertFalse(newTestSetClasses().isNoThreading()); - assertFalse(newTestSetMethods().isNoThreading()); - assertFalse(newTestSetBoth().isNoThreading()); - } - - @Test - public void isAnyParallelismSelected() { - assertTrue(newTestSetClasses().isParallelismSelected()); - assertTrue(newTestSetMethods().isParallelismSelected()); - assertTrue(newTestSetBoth().isParallelismSelected()); - } - - private Map newDefaultProperties() { - return new HashMap<>(); - } - - private Map newPropertiesClasses() { - Map props = new HashMap<>(); - props.put(JUnitCoreParameters.PARALLEL_KEY, "classes"); - props.put(JUnitCoreParameters.PERCORETHREADCOUNT_KEY, "false"); - props.put(JUnitCoreParameters.THREADCOUNT_KEY, "2"); - props.put(JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY, "false"); - return props; - } - - private Map newPropertiesMethods() { - Map props = new HashMap<>(); - props.put(JUnitCoreParameters.PARALLEL_KEY, "methods"); - props.put(JUnitCoreParameters.PERCORETHREADCOUNT_KEY, "false"); - props.put(JUnitCoreParameters.THREADCOUNT_KEY, "2"); - props.put(JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY, "true"); - return props; - } - - private Map newPropertiesBoth() { - Map props = new HashMap<>(); - props.put(JUnitCoreParameters.PARALLEL_KEY, "both"); - props.put(JUnitCoreParameters.PERCORETHREADCOUNT_KEY, "true"); - props.put(JUnitCoreParameters.THREADCOUNT_KEY, "7"); - props.put(JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY, "false"); - return props; - } - - private Map newPropertiesTimeouts(double timeout, double forcedTimeout) { - Map props = new HashMap<>(); - props.put(JUnitCoreParameters.PARALLEL_TIMEOUT_KEY, Double.toString(timeout)); - props.put(JUnitCoreParameters.PARALLEL_TIMEOUTFORCED_KEY, Double.toString(forcedTimeout)); - return props; - } - - private Map newPropertiesOptimization(boolean optimize) { - Map props = new HashMap<>(); - props.put(JUnitCoreParameters.PARALLEL_OPTIMIZE_KEY, Boolean.toString(optimize)); - return props; - } - - private JUnitCoreParameters newTestSetDefault() { - return new JUnitCoreParameters(newDefaultProperties()); - } - - private JUnitCoreParameters newTestSetBoth() { - return new JUnitCoreParameters(newPropertiesBoth()); - } - - private JUnitCoreParameters newTestSetClasses() { - return new JUnitCoreParameters(newPropertiesClasses()); - } - - private JUnitCoreParameters newTestSetMethods() { - return new JUnitCoreParameters(newPropertiesMethods()); - } - - private JUnitCoreParameters newTestSetOptimization(boolean optimize) { - return new JUnitCoreParameters(newPropertiesOptimization(optimize)); - } - - private JUnitCoreParameters newTestSetTimeouts(double timeout, double forcedTimeout) { - return new JUnitCoreParameters(newPropertiesTimeouts(timeout, forcedTimeout)); - } - - private boolean isParallelMethodsAndClasses(JUnitCoreParameters jUnitCoreParameters) { - return jUnitCoreParameters.isParallelMethods() && jUnitCoreParameters.isParallelClasses(); - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java deleted file mode 100644 index 22f2e9cd5a..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import junit.framework.TestCase; -import org.junit.Assume; -import org.junit.Test; -import org.junit.runner.Computer; -import org.junit.runner.Description; -import org.junit.runner.JUnitCore; -import org.junit.runner.Result; -import org.junit.runner.notification.RunListener; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.hasSize; - -/** - * @author Kristian Rosenvold - */ -public class JUnitCoreRunListenerTest extends TestCase { - public void testTestRunStarted() { - RunListener jUnit4TestSetReporter = - new JUnitCoreRunListener(new MockReporter(), new HashMap()); - JUnitCore core = new JUnitCore(); - core.addListener(jUnit4TestSetReporter); - Result result = core.run(new Computer(), STest1.class, STest2.class); - core.removeListener(jUnit4TestSetReporter); - assertEquals(2, result.getRunCount()); - } - - public void testFailedAssumption() { - RunListener jUnit4TestSetReporter = - new JUnitCoreRunListener(new MockReporter(), new HashMap()); - JUnitCore core = new JUnitCore(); - core.addListener(jUnit4TestSetReporter); - Result result = core.run(new Computer(), TestWithAssumptionFailure.class); - core.removeListener(jUnit4TestSetReporter); - assertEquals(1, result.getRunCount()); - } - - public void testStateForClassesWithNoChildren() throws Exception { - Description testDescription = Description.createSuiteDescription("testMethod(cannot.be.loaded.by.junit.Test)"); - Description st1 = Description.createSuiteDescription(STest1.class); - // st1.addChild( Description.createSuiteDescription( STest1.class ) ); - testDescription.addChild(st1); - Description st2 = Description.createSuiteDescription(STest2.class); - // st2.addChild( Description.createSuiteDescription( STest2.class ) ); - testDescription.addChild(st2); - - Map classMethodCounts = new HashMap<>(); - JUnitCoreRunListener listener = new JUnitCoreRunListener(new MockReporter(), classMethodCounts); - listener.testRunStarted(testDescription); - assertEquals(2, classMethodCounts.size()); - Iterator iterator = classMethodCounts.values().iterator(); - assertFalse(iterator.next().equals(iterator.next())); - } - - public void testTestClassNotLoadableFromJUnitClassLoader() throws Exception { - // can't use Description.createTestDescription() methods as these require a loaded Class - Description testDescription = Description.createSuiteDescription("testMethod(cannot.be.loaded.by.junit.Test)"); - assertEquals("testMethod", testDescription.getMethodName()); - assertEquals("cannot.be.loaded.by.junit.Test", testDescription.getClassName()); - // assert that the test class is not visible by the JUnit classloader - assertNull(testDescription.getTestClass()); - Description suiteDescription = Description.createSuiteDescription("testSuite"); - suiteDescription.addChild(testDescription); - Map classMethodCounts = new HashMap<>(); - JUnitCoreRunListener listener = new JUnitCoreRunListener(new MockReporter(), classMethodCounts); - listener.testRunStarted(suiteDescription); - assertEquals(1, classMethodCounts.size()); - TestSet testSet = classMethodCounts.get("cannot.be.loaded.by.junit.Test"); - assertNotNull(testSet); - } - - public void testNonEmptyTestRunStarted() throws Exception { - Description aggregator = Description.createSuiteDescription("null"); - Description suite = Description.createSuiteDescription("some.junit.Test"); - suite.addChild(Description.createSuiteDescription("testMethodA(some.junit.Test)")); - suite.addChild(Description.createSuiteDescription("testMethodB(some.junit.Test)")); - suite.addChild(Description.createSuiteDescription("testMethod(another.junit.Test)")); - aggregator.addChild(suite); - Map classMethodCounts = new HashMap<>(); - JUnitCoreRunListener listener = new JUnitCoreRunListener(new MockReporter(), classMethodCounts); - listener.testRunStarted(aggregator); - assertThat(classMethodCounts.keySet(), hasSize(2)); - assertThat(classMethodCounts.keySet(), containsInAnyOrder("some.junit.Test", "another.junit.Test")); - TestSet testSet = classMethodCounts.get("some.junit.Test"); - MockReporter reporter = new MockReporter(); - testSet.replay(reporter); - assertTrue(reporter.containsNotification(MockReporter.SET_STARTED)); - assertTrue(reporter.containsNotification(MockReporter.SET_COMPLETED)); - listener.testRunFinished(null); - assertThat(classMethodCounts.keySet(), empty()); - } - - public void testEmptySuiteTestRunStarted() throws Exception { - Description aggregator = Description.createSuiteDescription("null"); - Description suite = Description.createSuiteDescription("some.junit.TestSuite"); - aggregator.addChild(suite); - Map classMethodCounts = new HashMap<>(); - JUnitCoreRunListener listener = new JUnitCoreRunListener(new MockReporter(), classMethodCounts); - listener.testRunStarted(aggregator); - assertThat(classMethodCounts.keySet(), hasSize(1)); - assertThat(classMethodCounts.keySet(), contains("some.junit.TestSuite")); - listener.testRunFinished(null); - assertThat(classMethodCounts.keySet(), empty()); - } - - /** - * - */ - public static class STest1 { - @Test - public void testSomething() {} - } - - /** - * - */ - public static class STest2 { - @Test - public void testSomething2() {} - } - - /** - * - */ - public static class TestWithAssumptionFailure { - @Test - public void testSomething2() { - Assume.assumeTrue(false); - } - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java deleted file mode 100644 index 1a4f74c299..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.io.File; -import java.io.PrintStream; -import java.util.HashMap; -import java.util.concurrent.ExecutionException; - -import org.apache.maven.plugin.surefire.StartupReportConfiguration; -import org.apache.maven.plugin.surefire.extensions.SurefireConsoleOutputReporter; -import org.apache.maven.plugin.surefire.extensions.SurefireStatelessReporter; -import org.apache.maven.plugin.surefire.extensions.SurefireStatelessTestsetInfoReporter; -import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger; -import org.apache.maven.plugin.surefire.report.DefaultReporterFactory; -import org.apache.maven.surefire.api.report.ReporterFactory; -import org.apache.maven.surefire.api.report.ReporterFactoryOptions; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.junit.runner.Computer; -import org.junit.runner.JUnitCore; -import org.junit.runner.Result; - -import static org.apache.maven.surefire.api.report.ConsoleOutputCapture.startCapture; -import static org.apache.maven.surefire.junitcore.ConcurrentRunListener.createInstance; - -/** - * @author Kristian Rosenvold - */ -public class JUnitCoreTester { - private final Computer computer; - - public JUnitCoreTester() { - this(new Computer()); - } - - public JUnitCoreTester(Computer computer) { - this.computer = computer; - } - - public Result run(boolean parallelClasses, Class... classes) throws TestSetFailedException, ExecutionException { - ReporterFactory reporterManagerFactory = defaultNoXml(); - PrintStream out = System.out; - PrintStream err = System.err; - try { - HashMap classMethodCounts = new HashMap<>(); - ConcurrentRunListener reporter = - createInstance(classMethodCounts, reporterManagerFactory, parallelClasses, false); - JUnitCoreRunListener runListener = new JUnitCoreRunListener(reporter, classMethodCounts); - startCapture(runListener); - JUnitCore junitCore = new JUnitCore(); - - junitCore.addListener(runListener); - final Result run = junitCore.run(computer, classes); - junitCore.removeListener(runListener); - return run; - } finally { - System.setOut(out); - System.setErr(err); - reporterManagerFactory.close(); - if (computer instanceof ConfigurableParallelComputer) { - ((ConfigurableParallelComputer) computer).close(); - } - } - } - - /** - * For testing purposes only. - * - * @return DefaultReporterFactory for testing purposes - */ - public static DefaultReporterFactory defaultNoXml() { - return new DefaultReporterFactory(defaultStartupReportConfiguration(), new NullConsoleLogger()); - } - - /** - * For testing purposes only. - * - * @return StartupReportConfiguration fo testing purposes - */ - private static StartupReportConfiguration defaultStartupReportConfiguration() { - File target = new File("./target"); - File statisticsFile = new File(target, "TESTHASHxXML"); - return new StartupReportConfiguration( - true, - true, - "PLAIN", - false, - target, - false, - null, - statisticsFile, - false, - 0, - null, - null, - false, - true, - true, - new SurefireStatelessReporter(), - new SurefireConsoleOutputReporter(), - new SurefireStatelessTestsetInfoReporter(), - new ReporterFactoryOptions()); - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java deleted file mode 100644 index 3f4b3ffe55..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.surefire.junitcore; - -/* - * JBoss, Home of Professional Open Source - * Copyright 2009, Red Hat Middleware LLC, and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import junit.framework.Assert; -import junit.framework.TestCase; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.Result; -import org.junit.runner.notification.Failure; - -/** - * {@code - * TestCase that expose "No tests were executed!" on Test failure using Maven Surefire 2.6-SNAPSHOT - * and the JUnit 4.7 Runner. - *
- * ------------------------------------------------------- - * T E S T S - * ------------------------------------------------------- - *
- * Results: - *
- * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 - *
- * [INFO] ------------------------------------------------------------------------ - * [INFO] BUILD FAILURE - * [INFO] ------------------------------------------------------------------------ - * [INFO] Total time: 11.011s - * [INFO] Finished at: Thu Jul 15 13:59:14 CEST 2010 - * [INFO] Final Memory: 24M/355M - * [INFO] ------------------------------------------------------------------------ - * [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.5:test - * (default-test) on project xxxxxx: No tests were executed! (Set -DfailIfNoTests=false to - * ignore this error.) -> [Help 1] - *
- *
- * - * junit - * junit - * 4.8.1 - * test - * - *
- * - * org.apache.maven.surefire - * surefire-booter - * 2.6-SNAPSHOT - * test - * - * - * org.apache.maven.plugins - * maven-surefire-plugin - * 2.6-SNAPSHOT - * test - * - * - * org.apache.maven.surefire - * surefire-junit47 - * 2.6-SNAPSHOT - * test - * - * } - * - * @author Aslak Knutsen - * @version $Revision: $ - */ -public class MavenSurefireJUnit47RunnerTest extends TestCase { - - /* - * Assumption: - * The ConcurrentReportingRunListener assumes a Test will be Started before it Fails or Finishes. - * - * Reality: - * JUnits ParentRunner is responsible for adding the BeforeClass/AfterClass statements to the - * statement execution chain. After BeforeClass is executed, a Statement that delegates to the - * abstract method: runChild(T child, RunNotifier notifier) is called. As the JavaDoc explains: - * "Subclasses are responsible for making sure that relevant test events are reported through notifier". - * When a @BeforeClass fail, the child that should handle the relevant test events(Started, Failed, Finished) - * is never executed. - * - * Result: - * When Test Failed event is received in ConcurrentReportingRunListener without a Started event received first, - * it causes a NullPointException because there is no ClassReporter setup for that class yet. When this Exception - * is thrown from the ConcurrentReportingRunListener, JUnit catches the exception and reports is as a Failed test. - * But to avoid a wild loop, it removes the failing Listener before calling Failed test again. Since the - * ConcurrentReportingRunListener now is removed from the chain it will never receive the RunFinished event - * and the recorded state will never be replayed on the ReportManager. - * - * The End result: ReporterManager falsely believe no Test were run. - * - */ - @SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"}) - public void testSurefireShouldBeAbleToReportRunStatusEvenWithFailingTests() throws Exception { - Result result = new JUnitCoreTester().run(false, FailingTestClassTestNot.class); - - Assert.assertEquals("JUnit should report correctly number of test ran(Finished)", 0, result.getRunCount()); - - for (Failure failure : result.getFailures()) { - System.out.println(failure.getException().getMessage()); - } - - Assert.assertEquals( - "There should only be one Exception reported, the one from the failing TestCase", - 1, - result.getFailureCount()); - - Assert.assertEquals( - "The exception thrown by the failing TestCase", - RuntimeException.class, - result.getFailures().get(0).getException().getClass()); - } - - /** - * Simple TestCase to force a Exception in @BeforeClass. - */ - public static class FailingTestClassTestNot { - @BeforeClass - public static void failingBeforeClass() throws Exception { - throw new RuntimeException("Opps, we failed in @BeforeClass"); - } - - @Test - public void shouldNeverBeCalled() throws Exception { - Assert.assertTrue(true); - } - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit48RunnerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit48RunnerTest.java deleted file mode 100644 index 60a48ccd13..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit48RunnerTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.surefire.junitcore; - -/* - * JBoss, Home of Professional Open Source - * Copyright 2009, Red Hat Middleware LLC, and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import junit.framework.Assert; -import junit.framework.TestCase; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.Result; -import org.junit.runner.notification.Failure; - -/** - * TestCase that expose "No tests were executed!" on Test failure using Maven Surefire 2.6-SNAPSHOT - * and the JUnit 4.8 Runner. - * {@code - * *
- * ------------------------------------------------------- - * T E S T S - * ------------------------------------------------------- - *
- * Results: - *
- * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 - *
- * [INFO] ------------------------------------------------------------------------ - * [INFO] BUILD FAILURE - * [INFO] ------------------------------------------------------------------------ - * [INFO] Total time: 11.011s - * [INFO] Finished at: Thu Jul 15 13:59:14 CEST 2010 - * [INFO] Final Memory: 24M/355M - * [INFO] ------------------------------------------------------------------------ - * [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.5:test - * (default-test) on project xxxxxx: No tests were executed! (Set -DfailIfNoTests=false to - * ignore this error.) -> [Help 1] - *
- *
- * - * junit - * junit - * 4.8.1 - * test - * - *
- * - * org.apache.maven.surefire - * surefire-booter - * 2.6-SNAPSHOT - * test - * - * - * org.apache.maven.plugins - * maven-surefire-plugin - * 2.6-SNAPSHOT - * test - * - * - * org.apache.maven.surefire - * surefire-junit48 - * 2.6-SNAPSHOT - * test - * - * } - * - * @author Aslak Knutsen - * @version $Revision: $ - */ -public class MavenSurefireJUnit48RunnerTest extends TestCase { - - /* - * Assumption: - * The ConcurrentReportingRunListener assumes a Test will be Started before it Fails or Finishes. - * - * Reality: - * JUnits ParentRunner is responsible for adding the BeforeClass/AfterClass statements to the - * statement execution chain. After BeforeClass is executed, a Statement that delegates to the - * abstract method: runChild(T child, RunNotifier notifier) is called. As the JavaDoc explains: - * "Subclasses are responsible for making sure that relevant test events are reported through notifier". - * When a @BeforeClass fail, the child that should handle the relevant test events(Started, Failed, Finished) - * is never executed. - * - * Result: - * When Test Failed event is received in ConcurrentReportingRunListener without a Started event received first, - * it causes a NullPointException because there is no ClassReporter setup for that class yet. When this Exception - * is thrown from the ConcurrentReportingRunListener, JUnit catches the exception and reports is as a Failed test. - * But to avoid a wild loop, it removes the failing Listener before calling Failed test again. Since the - * ConcurrentReportingRunListener now is removed from the chain it will never receive the RunFinished event - * and the recorded state will never be replayed on the ReportManager. - * - * The End result: ReporterManager falsely believe no Test were run. - * - */ - @SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"}) - public void testSurefireShouldBeAbleToReportRunStatusEvenWithFailingTests() throws Exception { - Result result = new JUnitCoreTester().run(false, FailingTestClassTestNot.class); - - Assert.assertEquals("JUnit should report correctly number of test ran(Finished)", 0, result.getRunCount()); - - for (Failure failure : result.getFailures()) { - System.out.println(failure.getException().getMessage()); - } - - Assert.assertEquals( - "There should only be one Exception reported, the one from the failing TestCase", - 1, - result.getFailureCount()); - - Assert.assertEquals( - "The exception thrown by the failing TestCase", - RuntimeException.class, - result.getFailures().get(0).getException().getClass()); - } - - /** - * Simple TestCase to force a Exception in @BeforeClass. - */ - public static class FailingTestClassTestNot { - @BeforeClass - public static void failingBeforeClass() throws Exception { - throw new RuntimeException("Opps, we failed in @BeforeClass"); - } - - @Test - public void shouldNeverBeCalled() throws Exception { - Assert.assertTrue(true); - } - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java deleted file mode 100644 index 4b3bba641c..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.ReporterFactory; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestSetReportEntry; - -import static java.util.Collections.emptyMap; -import static org.mockito.Mockito.mock; - -/** - * Internal tests use only. - */ -final class MockReporter extends ConcurrentRunListener { - private final List events = new ArrayList<>(); - - static final String SET_STARTED = "SET_STARTED"; - - static final String SET_COMPLETED = "SET_COMPLETED"; - - static final String TEST_STARTED = "TEST_STARTED"; - - static final String TEST_COMPLETED = "TEST_COMPLETED"; - - static final String TEST_SKIPPED = "TEST_SKIPPED"; - - private final AtomicInteger testSucceeded = new AtomicInteger(); - - private final AtomicInteger testIgnored = new AtomicInteger(); - - private final AtomicInteger testFailed = new AtomicInteger(); - - private final AtomicInteger testError = new AtomicInteger(); - - MockReporter() { - super(mock(ReporterFactory.class), false, emptyMap()); - } - - @Override - public void testSetStarting(TestSetReportEntry report) { - events.add(SET_STARTED); - } - - @Override - public void testSetCompleted(TestSetReportEntry report) { - events.add(SET_COMPLETED); - } - - @Override - public void testStarting(ReportEntry report) { - events.add(TEST_STARTED); - } - - @Override - public void testSucceeded(ReportEntry report) { - events.add(TEST_COMPLETED); - testSucceeded.incrementAndGet(); - } - - @Override - protected void checkIfTestSetCanBeReported(TestSet testSetForTest) {} - - @Override - public void testSkipped(ReportEntry report) { - events.add(TEST_SKIPPED); - testIgnored.incrementAndGet(); - } - - @Override - public void testExecutionSkippedByUser() {} - - public int getTestSucceeded() { - return testSucceeded.get(); - } - - public int getTestFailed() { - return testFailed.get(); - } - - @Override - public void testError(ReportEntry report) { - testError.incrementAndGet(); - } - - @Override - public void testFailed(ReportEntry report) { - testFailed.incrementAndGet(); - } - - @Override - public void testAssumptionFailure(ReportEntry report) {} - - public boolean containsNotification(String event) { - return events.contains(event); - } - - @Override - public void writeTestOutput(TestOutputReportEntry reportEntry) {} - - @Override - public boolean isDebugEnabled() { - return false; - } - - @Override - public void debug(String message) {} - - @Override - public boolean isInfoEnabled() { - return false; - } - - @Override - public void info(String message) {} - - @Override - public boolean isWarnEnabled() { - return false; - } - - @Override - public void warning(String message) {} - - @Override - public boolean isErrorEnabled() { - return false; - } - - @Override - public void error(String message) {} - - @Override - public void error(String message, Throwable t) {} - - @Override - public void error(Throwable t) {} -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java deleted file mode 100644 index d81e251daa..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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.surefire.junitcore; - -/* - * JBoss, Home of Professional Open Source - * Copyright 2009, Red Hat Middleware LLC, and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.apache.maven.surefire.api.booter.BaseProviderFactory; -import org.apache.maven.surefire.api.booter.ProviderParameterNames; -import org.apache.maven.surefire.api.report.ReporterConfiguration; -import org.apache.maven.surefire.api.report.ReporterFactory; -import org.apache.maven.surefire.api.suite.RunResult; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.api.util.TestsToRun; -import org.apache.maven.surefire.common.junit4.JUnit4RunListener; -import org.apache.maven.surefire.common.junit4.Notifier; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.Description; -import org.junit.runner.RunWith; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.InitializationError; - -import static junit.framework.Assert.assertEquals; -import static org.apache.maven.surefire.junitcore.ConcurrentRunListener.createInstance; -import static org.mockito.Mockito.mock; - -/** - * {@code - * - * junit - * junit - * 4.8.1 - * test - * - *
- * - * org.apache.maven.surefire - * surefire-booter - * 2.8.1 - * test - * - * - * org.apache.maven.plugins - * maven-surefire-plugin - * 2.8.1 - * test - * - * - * org.apache.maven.surefire - * surefire-junit47 - * 2.8.1 - * test - * - * } - * - * @author Aslak Knutsen - * @version $Revision: $ - */ -public class Surefire746Test { - @Rule - public final ExpectedException exception = ExpectedException.none(); - - @Test - @SuppressWarnings("checkstyle:methodname") - public void surefireIsConfused_ByMultipleIgnore_OnClassLevel() throws Exception { - ReporterFactory reporterFactory = JUnitCoreTester.defaultNoXml(); - BaseProviderFactory providerParameters = new BaseProviderFactory(true); - providerParameters.setReporterFactory(reporterFactory); - - providerParameters.setReporterConfiguration(new ReporterConfiguration(new File(""), false)); - Map junitProps = new HashMap<>(); - junitProps.put(ProviderParameterNames.PARALLEL_PROP, "none"); - - JUnitCoreParameters jUnitCoreParameters = new JUnitCoreParameters(junitProps); - - final Map testSetMap = new ConcurrentHashMap<>(); - - ConcurrentRunListener listener = createInstance(testSetMap, reporterFactory, false, false); - - TestsToRun testsToRun = new TestsToRun(Collections.>singleton(TestClassTest.class)); - - org.junit.runner.notification.RunListener jUnit4RunListener = new JUnitCoreRunListener(listener, testSetMap); - - List customRunListeners = new ArrayList<>(); - customRunListeners.add(0, jUnit4RunListener); - - try { - // JUnitCoreWrapper#execute() is calling JUnit4RunListener#rethrowAnyTestMechanismFailures() - // and rethrows a failure which happened in listener - exception.expect(TestSetFailedException.class); - JUnit4RunListener dummy = new JUnit4RunListener(new MockReporter()); - new JUnitCoreWrapper(new Notifier(dummy, 0), jUnitCoreParameters, mock(ConsoleLogger.class)) - .execute(testsToRun, customRunListeners, null); - } finally { - RunResult result = reporterFactory.close(); - assertEquals("JUnit should report correctly number of test ran(Finished)", 1, result.getCompletedCount()); - } - } - - /** - * - */ - @RunWith(TestCaseRunner.class) - public static class TestClassTest { - @Test - public void shouldNeverBeCalled() throws Exception {} - } - - /** - * - */ - public static class TestCaseRunner extends BlockJUnit4ClassRunner { - public TestCaseRunner(Class klass) throws InitializationError { - super(klass); - } - - @Override - public void run(RunNotifier notifier) { - notifier.addListener(new Listener()); - super.run(notifier); - } - } - - private static class Listener extends org.junit.runner.notification.RunListener { - @Override - public void testFinished(Description description) throws Exception { - throw new RuntimeException( - "This Exception will cause Surefire to receive an internal JUnit Description and fail."); - } - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire813IncorrectResultTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire813IncorrectResultTest.java deleted file mode 100644 index bda8dc5121..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire813IncorrectResultTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.surefire.junitcore; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.Result; - -import static junit.framework.Assert.assertEquals; - -/** - * @author Kristian Rosenvold - * @author nkeyval - */ -public class Surefire813IncorrectResultTest { - - @Test - public void dcount() throws TestSetFailedException, ExecutionException { - JUnitCoreTester jUnitCoreTester = new JUnitCoreTester(); - final Result run = jUnitCoreTester.run(true, Test6.class); - assertEquals(0, run.getFailureCount()); - } - - /** - * - */ - public static class Test6 { - private final CountDownLatch latch = new CountDownLatch(1); - - @Test - public void test61() throws Exception { - System.out.println("Hey"); - } - - @After - public void tearDown() throws Exception { - new MyThread().start(); - latch.await(); - } - - private static final String STR = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - - public void synchPrint() { - for (int i = 0; i < 1000; ++i) // Increase this number if it does no fail - { - System.out.println(i + ":" + STR); - } - } - - private class MyThread extends Thread { - @Override - public void run() { - System.out.println(STR); - latch.countDown(); - synchPrint(); - } - } - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestMethodTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestMethodTest.java deleted file mode 100644 index 650f7e61dc..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestMethodTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.surefire.junitcore; - -import junit.framework.TestCase; -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.SimpleReportEntry; - -import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; - -/** - * @author Kristian Rosenvold - */ -public class TestMethodTest extends TestCase { - - public static final int BIG_UPTIME = 100_000; - - public void testTestFailure() { - ReportEntry reportEntry = new SimpleReportEntry(NORMAL_RUN, 0L, "a", null, "b", null); - TestSet testSet = new TestSet(TestMethodTest.class.getName(), NORMAL_RUN, null); - TestMethod testMethod = new TestMethod(reportEntry, testSet); - testMethod.testFailure(reportEntry); - final int elapsed = testMethod.getElapsed(); - assertTrue(elapsed >= 0); - assertTrue(elapsed < BIG_UPTIME); - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/OptimizedParallelComputerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/OptimizedParallelComputerTest.java deleted file mode 100644 index 50b889877a..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/OptimizedParallelComputerTest.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.junitcore.JUnitCoreParameters; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; - -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.PARALLEL_KEY; -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.THREADCOUNTCLASSES_KEY; -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.THREADCOUNTSUITES_KEY; -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.THREADCOUNT_KEY; -import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.overrideAvailableProcessors; -import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.resolveConcurrency; -import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.setDefaultAvailableProcessors; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -/** - * Testing an algorithm in {@link ParallelComputerUtil} which configures optimized thread resources in ParallelComputer - * by given {@link org.apache.maven.surefire.junitcore.JUnitCoreParameters}. - * - * @author Tibor Digana (tibor17) - * @see ParallelComputerUtil - * @since 2.17 - */ -@RunWith(Theories.class) -@SuppressWarnings("checkstyle:magicnumber") -public final class OptimizedParallelComputerTest { - @DataPoint - public static final int CPU_1 = 1; - - @DataPoint - public static final int CPU_4 = 4; - - @Rule - public final ExpectedException exception = ExpectedException.none(); - - @BeforeClass - public static void beforeClass() { - overrideAvailableProcessors(1); - } - - @AfterClass - public static void afterClass() { - setDefaultAvailableProcessors(); - } - - @Theory - public void threadCountSuites(int cpu) throws TestSetFailedException { - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suites"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(5, 10, 20); - Concurrency concurrency = resolveConcurrency(params, counter); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(0)); - assertThat(concurrency.suites, is((int) Math.min(3 * cpu, counter.suites))); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void threadCountClasses(int cpu) throws TestSetFailedException { - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classes"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(1, 5, 10); - Concurrency concurrency = resolveConcurrency(params, counter); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(0)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is((int) Math.min(3 * cpu, counter.classes))); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void threadCountMethods(int cpu) throws TestSetFailedException { - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "methods"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(1, 2, 5); - Concurrency concurrency = resolveConcurrency(params, counter); - assertFalse(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(0)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is((int) Math.min(3 * cpu, counter.methods))); - } - - @Theory - public void threadCountBoth(int cpu) throws TestSetFailedException { - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "both"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(1, 2, 5); - Concurrency concurrency = resolveConcurrency(params, counter); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is((int) Math.min((3d / 2) * cpu, 2))); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void threadCountClassesAndMethods(int cpu) throws TestSetFailedException { - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classesAndMethods"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(1, 2, 5); - Concurrency concurrency = resolveConcurrency(params, counter); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is((int) Math.min((3d / 2) * cpu, 2))); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void threadCountSuitesAndMethods(int cpu) throws TestSetFailedException { - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndMethods"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(2, 3, 5); - Concurrency concurrency = resolveConcurrency(params, counter); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is((int) Math.min((3d / 2) * cpu, 2))); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void threadCountSuitesAndClasses(int cpu) throws TestSetFailedException { - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndClasses"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(2, 5, 20); - Concurrency concurrency = resolveConcurrency(params, counter); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is((int) Math.min((2d * 3 / 7) * cpu, 2))); - assertThat(concurrency.classes, is(Integer.MAX_VALUE)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void threadCountAll(int cpu) throws TestSetFailedException { - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "all"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(2, 5, 20); - Concurrency concurrency = resolveConcurrency(params, counter); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is((int) Math.min((2d * 3 / 11) * cpu, 2))); - assertThat(concurrency.classes, is((int) Math.min((5d * 3 / 11) * cpu, 5))); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void reusableThreadCountSuitesAndClasses(int cpu) throws TestSetFailedException { - // 4 * cpu to 5 * cpu threads to run test classes - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndClasses"); - properties.put(THREADCOUNT_KEY, "6"); - properties.put(THREADCOUNTSUITES_KEY, "2"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(3, 5, 20); - Concurrency concurrency = resolveConcurrency(params, counter); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(6 * cpu)); - assertThat(concurrency.suites, is(Math.min(2 * cpu, 3))); - assertThat(concurrency.classes, is(Integer.MAX_VALUE)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void reusableThreadCountSuitesAndMethods(int cpu) throws TestSetFailedException { - // 4 * cpu to 5 * cpu threads to run test methods - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndMethods"); - properties.put(THREADCOUNT_KEY, "6"); - properties.put(THREADCOUNTSUITES_KEY, "2"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(3, 5, 20); - Concurrency concurrency = resolveConcurrency(params, counter); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(6 * cpu)); - assertThat(concurrency.suites, is(Math.min(2 * cpu, 3))); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void reusableThreadCountClassesAndMethods(int cpu) throws TestSetFailedException { - // 4 * cpu to 5 * cpu threads to run test methods - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classesAndMethods"); - properties.put(THREADCOUNT_KEY, "6"); - properties.put(THREADCOUNTCLASSES_KEY, "2"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(3, 5, 20); - Concurrency concurrency = resolveConcurrency(params, counter); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(6 * cpu)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(Math.min(2 * cpu, 5))); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void reusableThreadCountAll(int cpu) throws TestSetFailedException { - // 8 * cpu to 13 * cpu threads to run test methods - overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "all"); - properties.put(THREADCOUNT_KEY, "14"); - properties.put(THREADCOUNTSUITES_KEY, "2"); - properties.put(THREADCOUNTCLASSES_KEY, "4"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - RunnerCounter counter = new RunnerCounter(3, 5, 20); - Concurrency concurrency = resolveConcurrency(params, counter); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(14 * cpu)); - assertThat(concurrency.suites, is(Math.min(2 * cpu, 3))); - assertThat(concurrency.classes, is(Math.min(4 * cpu, 5))); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java deleted file mode 100755 index ceda3a1269..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java +++ /dev/null @@ -1,955 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.TimeUnit; - -import net.jcip.annotations.NotThreadSafe; -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.Description; -import org.junit.runner.JUnitCore; -import org.junit.runner.Result; -import org.junit.runner.RunWith; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.ParentRunner; -import org.junit.runners.Suite; -import org.junit.runners.model.InitializationError; - -import static org.apache.maven.surefire.junitcore.pc.RangeMatcher.between; -import static org.hamcrest.core.AnyOf.anyOf; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -/** - * @author Tibor Digana (tibor17) - * @since 2.16 - */ -@SuppressWarnings("checkstyle:magicnumber") -public class ParallelComputerBuilderTest { - private static final int DELAY_MULTIPLIER = 7; - - private static final Object CLASS1BLOCK = new Object(); - - private static volatile boolean beforeShutdown; - - private static volatile Runnable shutdownTask; - - private static final ConsoleLogger LOGGER = mock(ConsoleLogger.class); - - private static void testKeepBeforeAfter(ParallelComputerBuilder builder, Class... classes) { - JUnitCore core = new JUnitCore(); - for (int round = 0; round < 5; round++) { - NothingDoingTest1.METHODS.clear(); - Result result = core.run(builder.buildComputer(), classes); - assertTrue(result.wasSuccessful()); - Iterator methods = NothingDoingTest1.METHODS.iterator(); - for (Class clazz : classes) { - String a = clazz.getName() + "#a()"; - String b = clazz.getName() + "#b()"; - assertThat(methods.next(), is("init")); - assertThat(methods.next(), anyOf(is(a), is(b))); - assertThat(methods.next(), anyOf(is(a), is(b))); - assertThat(methods.next(), is("deinit")); - } - } - } - - @BeforeClass - public static void cleanup() throws InterruptedException { - System.gc(); - Thread.sleep(500L); - } - - @Before - public void beforeTest() { - Class1.maxConcurrentMethods = 0; - Class1.concurrentMethods = 0; - shutdownTask = null; - NotThreadSafeTest1.t = null; - NotThreadSafeTest2.t = null; - NotThreadSafeTest3.t = null; - NormalTest1.t = null; - NormalTest2.t = null; - } - - @Test - public void testsWithoutChildrenShouldAlsoBeRun() { - ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder(LOGGER); - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - Result result = new JUnitCore().run(computer, TestWithoutPrecalculatedChildren.class); - assertThat(result.getRunCount(), is(1)); - } - - @Test - public void parallelMethodsReuseOneOrTwoThreads() { - ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder(LOGGER); - parallelComputerBuilder.useOnePool(4); - - // One thread because one suite: TestSuite, however the capacity is 5. - parallelComputerBuilder.parallelSuites(5); - - // Two threads because TestSuite has two classes, however the capacity is 5. - parallelComputerBuilder.parallelClasses(5); - - // One or two threads because one threads comes from '#useOnePool(4)' - // and next thread may be reused from finished class, however the capacity is 3. - parallelComputerBuilder.parallelMethods(3); - - assertFalse(parallelComputerBuilder.isOptimized()); - - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - // final long t1 = systemMillis(); - final Result result = core.run(computer, TestSuite.class); - // final long t2 = systemMillis(); - // final long timeSpent = t2 - t1; - - assertThat(computer.getSuites().size(), is(1)); - assertThat(computer.getClasses().size(), is(0)); - assertThat(computer.getNestedClasses().size(), is(2)); - assertThat(computer.getNestedSuites().size(), is(0)); - assertFalse(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(4)); - assertTrue(result.wasSuccessful()); - // this is flaky as depending on hardware so comment this - // if (Class1.maxConcurrentMethods == 1) { - // assertThat(timeSpent, between(2000 * DELAY_MULTIPLIER - 50, 2250 * DELAY_MULTIPLIER)); - // } else if (Class1.maxConcurrentMethods == 2) { - // assertThat(timeSpent, between(1500 * DELAY_MULTIPLIER - 50, 1750 * DELAY_MULTIPLIER)); - // } else { - // fail(); - // } - } - - @Test - public void suiteAndClassInOnePool() { - ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder(LOGGER); - parallelComputerBuilder.useOnePool(5); - parallelComputerBuilder.parallelSuites(5); - parallelComputerBuilder.parallelClasses(5); - parallelComputerBuilder.parallelMethods(3); - assertFalse(parallelComputerBuilder.isOptimized()); - - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - final Result result = core.run(computer, TestSuite.class, Class1.class); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - - assertThat(computer.getSuites().size(), is(1)); - assertThat(computer.getClasses().size(), is(1)); - assertThat(computer.getNestedClasses().size(), is(2)); - assertThat(computer.getNestedSuites().size(), is(0)); - assertFalse(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(5)); - assertTrue(result.wasSuccessful()); - assertThat(Class1.maxConcurrentMethods, is(2)); - assertThat( - timeSpent, - anyOf( - between(1500 * DELAY_MULTIPLIER - 50, 1750 * DELAY_MULTIPLIER), - between(2000 * DELAY_MULTIPLIER - 50, 2250 * DELAY_MULTIPLIER), - between(2500 * DELAY_MULTIPLIER - 50, 2750 * DELAY_MULTIPLIER))); - } - - @Test - public void onePoolWithUnlimitedParallelMethods() { - // see ParallelComputerBuilder Javadoc - ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder(LOGGER); - parallelComputerBuilder.useOnePool(8); - parallelComputerBuilder.parallelSuites(2); - parallelComputerBuilder.parallelClasses(4); - parallelComputerBuilder.parallelMethods(); - assertFalse(parallelComputerBuilder.isOptimized()); - - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - final Result result = core.run(computer, TestSuite.class, Class1.class); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - - assertThat(computer.getSuites().size(), is(1)); - assertThat(computer.getClasses().size(), is(1)); - assertThat(computer.getNestedClasses().size(), is(2)); - assertThat(computer.getNestedSuites().size(), is(0)); - assertFalse(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(8)); - assertTrue(result.wasSuccessful()); - assertThat(Class1.maxConcurrentMethods, is(4)); - assertThat(timeSpent, between(1000 * DELAY_MULTIPLIER - 50, 1250 * DELAY_MULTIPLIER)); - } - - @Test - public void underflowParallelism() { - ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder(LOGGER); - parallelComputerBuilder.useOnePool(3); - - // One thread because one suite: TestSuite. - parallelComputerBuilder.parallelSuites(5); - - // One thread because of the limitation which is bottleneck. - parallelComputerBuilder.parallelClasses(1); - - // One thread remains from '#useOnePool(3)'. - parallelComputerBuilder.parallelMethods(3); - - assertFalse(parallelComputerBuilder.isOptimized()); - - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - final Result result = core.run(computer, TestSuite.class); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - - assertThat(computer.getSuites().size(), is(1)); - assertThat(computer.getClasses().size(), is(0)); - assertThat(computer.getNestedClasses().size(), is(2)); - assertThat(computer.getNestedSuites().size(), is(0)); - assertFalse(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(3)); - assertTrue(result.wasSuccessful()); - assertThat(Class1.maxConcurrentMethods, is(1)); - assertThat(timeSpent, between(2000 * DELAY_MULTIPLIER - 50, 2250 * DELAY_MULTIPLIER)); - } - - @Test - public void separatePoolsWithSuite() { - ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder(LOGGER); - parallelComputerBuilder.parallelSuites(5); - parallelComputerBuilder.parallelClasses(5); - parallelComputerBuilder.parallelMethods(3); - assertFalse(parallelComputerBuilder.isOptimized()); - - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - final Result result = core.run(computer, TestSuite.class); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - - assertThat(computer.getSuites().size(), is(1)); - assertThat(computer.getClasses().size(), is(0)); - assertThat(computer.getNestedClasses().size(), is(2)); - assertThat(computer.getNestedSuites().size(), is(0)); - assertTrue(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(ParallelComputerBuilder.TOTAL_POOL_SIZE_UNDEFINED)); - assertTrue(result.wasSuccessful()); - assertThat(Class1.maxConcurrentMethods, is(3)); - assertThat(timeSpent, between(1000 * DELAY_MULTIPLIER - 50, 1250 * DELAY_MULTIPLIER)); - } - - @Test - public void separatePoolsWithSuiteAndClass() { - ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder(LOGGER); - parallelComputerBuilder.parallelSuites(5); - parallelComputerBuilder.parallelClasses(5); - parallelComputerBuilder.parallelMethods(3); - assertFalse(parallelComputerBuilder.isOptimized()); - - // 6 methods altogether. - // 2 groups with 3 threads. - // Each group takes 0.5 s. - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - final Result result = core.run(computer, TestSuite.class, Class1.class); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - - assertThat(computer.getSuites().size(), is(1)); - assertThat(computer.getClasses().size(), is(1)); - assertThat(computer.getNestedClasses().size(), is(2)); - assertThat(computer.getNestedSuites().size(), is(0)); - assertTrue(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(ParallelComputerBuilder.TOTAL_POOL_SIZE_UNDEFINED)); - assertTrue(result.wasSuccessful()); - assertThat(Class1.maxConcurrentMethods, is(3)); - assertThat(timeSpent, between(1000 * DELAY_MULTIPLIER - 50, 1250 * DELAY_MULTIPLIER)); - } - - @Test - public void separatePoolsWithSuiteAndSequentialClasses() { - ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder(LOGGER); - parallelComputerBuilder.parallelSuites(5); - parallelComputerBuilder.parallelClasses(1); - parallelComputerBuilder.parallelMethods(3); - assertFalse(parallelComputerBuilder.isOptimized()); - - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - final Result result = core.run(computer, TestSuite.class, Class1.class); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - - assertThat(computer.getSuites().size(), is(1)); - assertThat(computer.getClasses().size(), is(1)); - assertThat(computer.getNestedClasses().size(), is(2)); - assertThat(computer.getNestedSuites().size(), is(0)); - assertTrue(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(ParallelComputerBuilder.TOTAL_POOL_SIZE_UNDEFINED)); - assertTrue(result.wasSuccessful()); - assertThat(Class1.maxConcurrentMethods, is(2)); - assertThat(timeSpent, between(1500 * DELAY_MULTIPLIER - 50, 1750 * DELAY_MULTIPLIER)); - } - - @Test(timeout = 2000 * DELAY_MULTIPLIER) - public void shutdown() { - final long t1 = systemMillis(); - final Result result = new ShutdownTest().run(false); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - assertTrue(result.wasSuccessful()); - assertTrue(beforeShutdown); - assertThat(timeSpent, between(500 * DELAY_MULTIPLIER - 50, 1250 * DELAY_MULTIPLIER)); - } - - @Test(timeout = 2000 * DELAY_MULTIPLIER) - public void shutdownWithInterrupt() { - final long t1 = systemMillis(); - new ShutdownTest().run(true); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - assertTrue(beforeShutdown); - assertThat(timeSpent, between(500 * DELAY_MULTIPLIER - 50, 1250 * DELAY_MULTIPLIER)); - } - - @Test - public void nothingParallel() { - JUnitCore core = new JUnitCore(); - ParallelComputerBuilder builder = new ParallelComputerBuilder(LOGGER); - assertFalse(builder.isOptimized()); - - Result result = core.run(builder.buildComputer(), NothingDoingTest1.class, NothingDoingTest2.class); - assertTrue(result.wasSuccessful()); - - result = core.run(builder.buildComputer(), NothingDoingTest1.class, NothingDoingSuite.class); - assertTrue(result.wasSuccessful()); - - builder.useOnePool(1); - assertFalse(builder.isOptimized()); - result = core.run(builder.buildComputer(), NothingDoingTest1.class, NothingDoingTest2.class); - assertTrue(result.wasSuccessful()); - - builder.useOnePool(1); - assertFalse(builder.isOptimized()); - result = core.run(builder.buildComputer(), NothingDoingTest1.class, NothingDoingSuite.class); - assertTrue(result.wasSuccessful()); - - builder.useOnePool(2); - assertFalse(builder.isOptimized()); - result = core.run(builder.buildComputer(), NothingDoingTest1.class, NothingDoingSuite.class); - assertTrue(result.wasSuccessful()); - - Class[] classes = {NothingDoingTest1.class, NothingDoingSuite.class}; - - builder.useOnePool(2).parallelSuites(1).parallelClasses(1); - assertFalse(builder.isOptimized()); - result = core.run(builder.buildComputer(), classes); - assertTrue(result.wasSuccessful()); - - builder.useOnePool(2).parallelSuites(1).parallelClasses(); - assertFalse(builder.isOptimized()); - result = core.run(builder.buildComputer(), classes); - assertTrue(result.wasSuccessful()); - - classes = new Class[] { - NothingDoingSuite.class, - NothingDoingSuite.class, - NothingDoingTest1.class, - NothingDoingTest2.class, - NothingDoingTest3.class - }; - - builder.useOnePool(2).parallelSuites(1).parallelClasses(1); - assertFalse(builder.isOptimized()); - result = core.run(builder.buildComputer(), classes); - assertTrue(result.wasSuccessful()); - - builder.useOnePool(2).parallelSuites(1).parallelClasses(); - assertFalse(builder.isOptimized()); - result = core.run(builder.buildComputer(), classes); - assertTrue(result.wasSuccessful()); - } - - @Test - public void keepBeforeAfterOneClass() { - ParallelComputerBuilder builder = new ParallelComputerBuilder(LOGGER); - builder.parallelMethods(); - assertFalse(builder.isOptimized()); - testKeepBeforeAfter(builder, NothingDoingTest1.class); - } - - @Test - public void keepBeforeAfterTwoClasses() { - ParallelComputerBuilder builder = new ParallelComputerBuilder(LOGGER); - builder.useOnePool(5).parallelClasses(1).parallelMethods(2); - assertFalse(builder.isOptimized()); - testKeepBeforeAfter(builder, NothingDoingTest1.class, NothingDoingTest2.class); - } - - @Test - public void keepBeforeAfterTwoParallelClasses() { - ParallelComputerBuilder builder = new ParallelComputerBuilder(LOGGER); - builder.useOnePool(8).parallelClasses(2).parallelMethods(2); - assertFalse(builder.isOptimized()); - JUnitCore core = new JUnitCore(); - NothingDoingTest1.METHODS.clear(); - Class[] classes = {NothingDoingTest1.class, NothingDoingTest2.class, NothingDoingTest3.class}; - Result result = core.run(builder.buildComputer(), classes); - assertTrue(result.wasSuccessful()); - ArrayList methods = new ArrayList<>(NothingDoingTest1.METHODS); - assertThat(methods.size(), is(12)); - assertThat(methods.subList(9, 12), is(not(Arrays.asList("deinit", "deinit", "deinit")))); - } - - @Test - public void notThreadSafeTest() { - ParallelComputerBuilder builder = new ParallelComputerBuilder(LOGGER) - .useOnePool(6) - .optimize(true) - .parallelClasses(3) - .parallelMethods(3); - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) builder.buildComputer(); - Result result = new JUnitCore().run(computer, NotThreadSafeTest1.class, NotThreadSafeTest2.class); - assertTrue(result.wasSuccessful()); - assertThat(result.getRunCount(), is(2)); - assertNotNull(NotThreadSafeTest1.t); - assertNotNull(NotThreadSafeTest2.t); - assertSame(NotThreadSafeTest1.t, NotThreadSafeTest2.t); - assertThat(computer.getNotParallelRunners().size(), is(2)); - assertTrue(computer.getSuites().isEmpty()); - assertTrue(computer.getClasses().isEmpty()); - assertTrue(computer.getNestedClasses().isEmpty()); - assertTrue(computer.getNestedSuites().isEmpty()); - assertFalse(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(6)); - } - - @Test - public void mixedThreadSafety() { - ParallelComputerBuilder builder = new ParallelComputerBuilder(LOGGER) - .useOnePool(6) - .optimize(true) - .parallelClasses(3) - .parallelMethods(3); - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) builder.buildComputer(); - Result result = new JUnitCore().run(computer, NotThreadSafeTest1.class, NormalTest1.class); - assertTrue(result.wasSuccessful()); - assertThat(result.getRunCount(), is(2)); - assertNotNull(NotThreadSafeTest1.t); - assertNotNull(NormalTest1.t); - assertThat(NormalTest1.t.getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - assertNotSame(NotThreadSafeTest1.t, NormalTest1.t); - assertThat(computer.getNotParallelRunners().size(), is(1)); - assertTrue(computer.getSuites().isEmpty()); - assertThat(computer.getClasses().size(), is(1)); - assertTrue(computer.getNestedClasses().isEmpty()); - assertTrue(computer.getNestedSuites().isEmpty()); - assertFalse(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(6)); - } - - @Test - public void notThreadSafeTestsInSuite() { - ParallelComputerBuilder builder = - new ParallelComputerBuilder(LOGGER).useOnePool(5).parallelMethods(3); - assertFalse(builder.isOptimized()); - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) builder.buildComputer(); - Result result = new JUnitCore().run(computer, NotThreadSafeTestSuite.class); - assertTrue(result.wasSuccessful()); - assertNotNull(NormalTest1.t); - assertNotNull(NormalTest2.t); - assertSame(NormalTest1.t, NormalTest2.t); - assertThat(NormalTest1.t.getName(), is("maven-surefire-plugin@NotThreadSafe")); - assertThat(NormalTest2.t.getName(), is("maven-surefire-plugin@NotThreadSafe")); - assertThat(computer.getNotParallelRunners().size(), is(1)); - assertTrue(computer.getSuites().isEmpty()); - assertTrue(computer.getClasses().isEmpty()); - assertTrue(computer.getNestedClasses().isEmpty()); - assertTrue(computer.getNestedSuites().isEmpty()); - assertFalse(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(5)); - } - - @Test - public void mixedThreadSafetyInSuite() { - ParallelComputerBuilder builder = new ParallelComputerBuilder(LOGGER) - .useOnePool(10) - .optimize(true) - .parallelSuites(2) - .parallelClasses(3) - .parallelMethods(3); - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) builder.buildComputer(); - Result result = new JUnitCore().run(computer, MixedSuite.class); - assertTrue(result.wasSuccessful()); - assertThat(result.getRunCount(), is(2)); - assertNotNull(NotThreadSafeTest1.t); - assertNotNull(NormalTest1.t); - assertThat(NormalTest1.t.getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - assertNotSame(NotThreadSafeTest1.t, NormalTest1.t); - assertTrue(computer.getNotParallelRunners().isEmpty()); - assertThat(computer.getSuites().size(), is(1)); - assertTrue(computer.getClasses().isEmpty()); - assertThat(computer.getNestedClasses().size(), is(1)); - assertTrue(computer.getNestedSuites().isEmpty()); - assertFalse(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(10)); - } - - @Test - public void inheritanceWithNotThreadSafe() { - ParallelComputerBuilder builder = new ParallelComputerBuilder(LOGGER) - .useOnePool(10) - .optimize(true) - .parallelSuites(2) - .parallelClasses(3) - .parallelMethods(3); - ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) builder.buildComputer(); - Result result = new JUnitCore().run(computer, OverMixedSuite.class); - assertTrue(result.wasSuccessful()); - assertThat(result.getRunCount(), is(2)); - assertNotNull(NotThreadSafeTest3.t); - assertNotNull(NormalTest1.t); - assertThat(NormalTest1.t.getName(), is("maven-surefire-plugin@NotThreadSafe")); - assertSame(NotThreadSafeTest3.t, NormalTest1.t); - assertThat(computer.getNotParallelRunners().size(), is(1)); - assertTrue(computer.getSuites().isEmpty()); - assertTrue(computer.getClasses().isEmpty()); - assertTrue(computer.getNestedClasses().isEmpty()); - assertTrue(computer.getNestedSuites().isEmpty()); - assertFalse(computer.isSplitPool()); - assertThat(computer.getPoolCapacity(), is(10)); - } - - @Test - public void beforeAfterThreadChanges() throws InterruptedException { - // try to GC dead Thread objects from previous tests - for (int i = 0; i < 5; i++) { - System.gc(); - TimeUnit.MILLISECONDS.sleep(500L); - } - Collection expectedThreads = jvmThreads(); - ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder(LOGGER); - parallelComputerBuilder.parallelMethods(3); - ParallelComputer computer = parallelComputerBuilder.buildComputer(); - Result result = new JUnitCore().run(computer, TestWithBeforeAfter.class); - assertTrue(result.wasSuccessful()); - // try to GC dead Thread objects - for (int i = 0; i < 5 && expectedThreads.size() != jvmThreads().size(); i++) { - System.gc(); - TimeUnit.MILLISECONDS.sleep(500L); - } - assertThat(jvmThreads(), is(expectedThreads)); - } - - private static Collection jvmThreads() { - Thread[] t = new Thread[1000]; - Thread.enumerate(t); - ArrayList appThreads = new ArrayList<>(t.length); - Collections.addAll(appThreads, t); - appThreads.removeAll(Collections.singleton((Thread) null)); - Collections.sort(appThreads, new Comparator() { - @Override - public int compare(Thread t1, Thread t2) { - return (int) Math.signum(t1.getId() - t2.getId()); - } - }); - return appThreads; - } - - private static class ShutdownTest { - Result run(final boolean useInterrupt) { - ParallelComputerBuilder parallelComputerBuilder = new ParallelComputerBuilder(LOGGER) - .useOnePool(8) - .parallelSuites(2) - .parallelClasses(3) - .parallelMethods(3); - - assertFalse(parallelComputerBuilder.isOptimized()); - - final ParallelComputerBuilder.PC computer = - (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - shutdownTask = new Runnable() { - @Override - public void run() { - Collection startedTests = - computer.describeStopped(useInterrupt).getTriggeredTests(); - assertThat(startedTests.size(), is(not(0))); - } - }; - return new JUnitCore().run(computer, TestSuite.class, Class2.class, Class3.class); - } - } - - /** - * - */ - public static class Class1 { - static volatile int concurrentMethods = 0; - - static volatile int maxConcurrentMethods = 0; - - @Test - public void test1() throws InterruptedException { - synchronized (CLASS1BLOCK) { - ++concurrentMethods; - CLASS1BLOCK.wait(DELAY_MULTIPLIER * 500L); - maxConcurrentMethods = Math.max(maxConcurrentMethods, concurrentMethods--); - } - } - - @Test - public void test2() throws InterruptedException { - test1(); - Runnable shutdownTask = ParallelComputerBuilderTest.shutdownTask; - if (shutdownTask != null) { - beforeShutdown = true; - shutdownTask.run(); - } - } - } - - /** - * - */ - public static class Class2 extends Class1 {} - - /** - * - */ - public static class Class3 extends Class1 {} - - /** - * - */ - public static class NothingDoingTest1 { - private static final Collection METHODS = new ConcurrentLinkedQueue<>(); - - @BeforeClass - public static void init() { - METHODS.add("init"); - } - - @AfterClass - public static void deinit() { - METHODS.add("deinit"); - } - - @Test - public void a() throws InterruptedException { - Thread.sleep(5); - METHODS.add(getClass().getName() + "#a()"); - } - - @Test - public void b() throws InterruptedException { - Thread.sleep(5); - METHODS.add(getClass().getName() + "#b()"); - } - } - - /** - * - */ - public static class NothingDoingTest2 extends NothingDoingTest1 {} - - /** - * - */ - public static class NothingDoingTest3 extends NothingDoingTest1 {} - - /** - * - */ - @RunWith(Suite.class) - @Suite.SuiteClasses({NothingDoingTest1.class, NothingDoingTest2.class}) - public static class NothingDoingSuite {} - - /** - * - */ - @RunWith(Suite.class) - @Suite.SuiteClasses({Class2.class, Class1.class}) - public static class TestSuite {} - - /** - * - */ - public static class Test2 { - @Test - public void test() {} - } - - /** - * - */ - @RunWith(ReportOneTestAtRuntimeRunner.class) - public static class TestWithoutPrecalculatedChildren {} - - /** - * - */ - public static class ReportOneTestAtRuntimeRunner extends ParentRunner { - private final Class testClass; - private final Description suiteDescription; - private final Description myTestMethodDescr; - - @SuppressWarnings("unchecked") - public ReportOneTestAtRuntimeRunner(Class testClass) throws InitializationError { - super(Object.class); - this.testClass = testClass; - suiteDescription = Description.createSuiteDescription(testClass); - myTestMethodDescr = Description.createTestDescription(testClass, "my_test"); - // suiteDescription.addChild(myTestMethodDescr); // let it be not known at start time - } - - protected List getChildren() { - throw new UnsupportedOperationException("workflow from ParentRunner not supported"); - } - - protected Description describeChild(Object child) { - throw new UnsupportedOperationException("workflow from ParentRunner not supported"); - } - - protected void runChild(Object child, RunNotifier notifier) { - throw new UnsupportedOperationException("workflow from ParentRunner not supported"); - } - - public Description getDescription() { - return suiteDescription; - } - - public void run(RunNotifier notifier) { - notifier.fireTestStarted(myTestMethodDescr); - notifier.fireTestFinished(Description.createTestDescription(testClass, "my_test")); - } - } - - /** - * - */ - @NotThreadSafe - public static class NotThreadSafeTest1 { - static volatile Thread t; - - @BeforeClass - public static void beforeSuite() { - assertThat(Thread.currentThread().getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - } - - @AfterClass - public static void afterSuite() { - assertThat(Thread.currentThread().getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - } - - @Test - public void test() { - t = Thread.currentThread(); - assertThat(t.getName(), is("maven-surefire-plugin@NotThreadSafe")); - } - } - - /** - * - */ - @NotThreadSafe - public static class NotThreadSafeTest2 { - static volatile Thread t; - - @BeforeClass - public static void beforeSuite() { - assertThat(Thread.currentThread().getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - } - - @AfterClass - public static void afterSuite() { - assertThat(Thread.currentThread().getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - } - - @Test - public void test() { - t = Thread.currentThread(); - assertThat(t.getName(), is("maven-surefire-plugin@NotThreadSafe")); - } - } - - /** - * - */ - @NotThreadSafe - public static class NotThreadSafeTest3 { - static volatile Thread t; - - @Test - public void test() { - t = Thread.currentThread(); - assertThat(t.getName(), is("maven-surefire-plugin@NotThreadSafe")); - } - } - - /** - * - */ - @RunWith(Suite.class) - @Suite.SuiteClasses({NormalTest1.class, NormalTest2.class}) - @NotThreadSafe - public static class NotThreadSafeTestSuite { - @BeforeClass - public static void beforeSuite() { - assertThat(Thread.currentThread().getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - } - - @AfterClass - public static void afterSuite() { - assertThat(Thread.currentThread().getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - } - } - - /** - * - */ - public static class NormalTest1 { - static volatile Thread t; - - @Test - public void test() { - t = Thread.currentThread(); - } - } - - /** - * - */ - public static class NormalTest2 { - static volatile Thread t; - - @Test - public void test() { - t = Thread.currentThread(); - } - } - - /** - * - */ - @RunWith(Suite.class) - @Suite.SuiteClasses({NotThreadSafeTest1.class, NormalTest1.class}) - public static class MixedSuite { - @BeforeClass - public static void beforeSuite() { - assertThat(Thread.currentThread().getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - } - - @AfterClass - public static void afterSuite() { - assertThat(Thread.currentThread().getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - } - } - - /** - * - */ - @RunWith(Suite.class) - @Suite.SuiteClasses({NotThreadSafeTest3.class, NormalTest1.class}) - @NotThreadSafe - public static class OverMixedSuite { - @BeforeClass - public static void beforeSuite() { - assertThat(Thread.currentThread().getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - } - - @AfterClass - public static void afterSuite() { - assertThat(Thread.currentThread().getName(), is(not("maven-surefire-plugin@NotThreadSafe"))); - } - } - - /** - * - */ - public static class TestWithBeforeAfter { - @BeforeClass - public static void beforeClass() throws InterruptedException { - System.out.println(new Date() + " BEG: beforeClass"); - sleepSeconds(1); - System.out.println(new Date() + " END: beforeClass"); - } - - @Before - public void before() throws InterruptedException { - System.out.println(new Date() + " BEG: before"); - sleepSeconds(1); - System.out.println(new Date() + " END: before"); - } - - @Test - public void test() throws InterruptedException { - System.out.println(new Date() + " BEG: test"); - sleepSeconds(1); - System.out.println(new Date() + " END: test"); - } - - @After - public void after() throws InterruptedException { - System.out.println(new Date() + " BEG: after"); - sleepSeconds(1); - System.out.println(new Date() + " END: after"); - } - - @AfterClass - public static void afterClass() throws InterruptedException { - System.out.println(new Date() + " BEG: afterClass"); - sleepSeconds(1); - System.out.println(new Date() + " END: afterClass"); - } - } - - private static long systemMillis() { - return TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); - } - - private static void sleepSeconds(int seconds) throws InterruptedException { - TimeUnit.SECONDS.sleep(seconds); - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java deleted file mode 100644 index add0277da4..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java +++ /dev/null @@ -1,1052 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.junitcore.JUnitCoreParameters; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.rules.ExpectedException; -import org.junit.runner.JUnitCore; -import org.junit.runner.Result; -import org.junit.runner.RunWith; - -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.PARALLEL_KEY; -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.PARALLEL_TIMEOUTFORCED_KEY; -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.PARALLEL_TIMEOUT_KEY; -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.THREADCOUNTCLASSES_KEY; -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.THREADCOUNTMETHODS_KEY; -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.THREADCOUNTSUITES_KEY; -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.THREADCOUNT_KEY; -import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY; -import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.resolveConcurrency; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -/** - * Testing an algorithm in {@link ParallelComputerUtil} which configures allocated thread resources in ParallelComputer - * by given {@link org.apache.maven.surefire.junitcore.JUnitCoreParameters}. - * - * @author Tibor Digana (tibor17) - * @see ParallelComputerUtil - * @since 2.16 - */ -@RunWith(Theories.class) -@SuppressWarnings("checkstyle:magicnumber") -public final class ParallelComputerUtilTest { - private static final ConsoleLogger LOGGER = mock(ConsoleLogger.class); - - @DataPoint - public static final int CPU_1 = 1; - - @DataPoint - public static final int CPU_4 = 4; - - @Rule - public final ExpectedException exception = ExpectedException.none(); - - @BeforeClass - public static void beforeClass() { - ParallelComputerUtil.overrideAvailableProcessors(1); - } - - @AfterClass - public static void afterClass() { - ParallelComputerUtil.setDefaultAvailableProcessors(); - } - - @Before - public void beforeTest() throws InterruptedException { - System.gc(); - Thread.sleep(50L); - assertFalse(Thread.currentThread().isInterrupted()); - } - - private static Map parallel(String parallel) { - return Collections.singletonMap(PARALLEL_KEY, parallel); - } - - @Test - public void unknownParallel() throws TestSetFailedException { - Map properties = new HashMap<>(); - exception.expect(TestSetFailedException.class); - resolveConcurrency(new JUnitCoreParameters(properties), null); - } - - @Test - public void unknownThreadCountSuites() throws TestSetFailedException { - JUnitCoreParameters params = new JUnitCoreParameters(parallel("suites")); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - exception.expect(TestSetFailedException.class); - resolveConcurrency(params, null); - } - - @Test - public void unknownThreadCountClasses() throws TestSetFailedException { - JUnitCoreParameters params = new JUnitCoreParameters(parallel("classes")); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - exception.expect(TestSetFailedException.class); - resolveConcurrency(params, null); - } - - @Test - public void unknownThreadCountMethods() throws TestSetFailedException { - JUnitCoreParameters params = new JUnitCoreParameters(parallel("methods")); - assertFalse(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - exception.expect(TestSetFailedException.class); - resolveConcurrency(params, null); - } - - @Test - public void unknownThreadCountBoth() throws TestSetFailedException { - JUnitCoreParameters params = new JUnitCoreParameters(parallel("both")); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - exception.expect(TestSetFailedException.class); - resolveConcurrency(params, null); - } - - @Test - public void unknownThreadCountAll() throws TestSetFailedException { - JUnitCoreParameters params = new JUnitCoreParameters(parallel("all")); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - exception.expect(TestSetFailedException.class); - resolveConcurrency(params, null); - } - - @Test - public void unknownThreadCountSuitesAndClasses() throws TestSetFailedException { - JUnitCoreParameters params = new JUnitCoreParameters(parallel("suitesAndClasses")); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - exception.expect(TestSetFailedException.class); - resolveConcurrency(params, null); - } - - @Test - public void unknownThreadCountSuitesAndMethods() throws TestSetFailedException { - JUnitCoreParameters params = new JUnitCoreParameters(parallel("suitesAndMethods")); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - exception.expect(TestSetFailedException.class); - resolveConcurrency(params, null); - } - - @Test - public void unknownThreadCountClassesAndMethods() throws TestSetFailedException { - JUnitCoreParameters params = new JUnitCoreParameters(parallel("classesAndMethods")); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - exception.expect(TestSetFailedException.class); - resolveConcurrency(params, null); - } - - @Theory - public void useUnlimitedThreadsSuites(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suites"); - properties.put(USEUNLIMITEDTHREADS_KEY, "true"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(Integer.MAX_VALUE)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(0)); - - properties.put(THREADCOUNTSUITES_KEY, "5"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void useUnlimitedThreadsClasses(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classes"); - properties.put(USEUNLIMITEDTHREADS_KEY, "true"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(Integer.MAX_VALUE)); - assertThat(concurrency.methods, is(0)); - - properties.put(THREADCOUNTCLASSES_KEY, "5"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(5 * cpu)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void unlimitedThreadsMethods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "methods"); - properties.put(USEUNLIMITEDTHREADS_KEY, "true"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - - properties.put(THREADCOUNTMETHODS_KEY, "5"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(5 * cpu)); - } - - @Theory - public void unlimitedThreadsSuitesAndClasses(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndClasses"); - properties.put(USEUNLIMITEDTHREADS_KEY, "true"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(Integer.MAX_VALUE)); - assertThat(concurrency.classes, is(Integer.MAX_VALUE)); - assertThat(concurrency.methods, is(0)); - - properties.put(THREADCOUNTSUITES_KEY, "5"); - properties.put(THREADCOUNTCLASSES_KEY, "15"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(15 * cpu)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void unlimitedThreadsSuitesAndMethods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndMethods"); - properties.put(USEUNLIMITEDTHREADS_KEY, "true"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(Integer.MAX_VALUE)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - - properties.put(THREADCOUNTSUITES_KEY, "5"); - properties.put(THREADCOUNTMETHODS_KEY, "15"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(15 * cpu)); - } - - @Theory - public void unlimitedThreadsClassesAndMethods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classesAndMethods"); - properties.put(USEUNLIMITEDTHREADS_KEY, "true"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(Integer.MAX_VALUE)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - - properties.put(THREADCOUNTCLASSES_KEY, "5"); - properties.put(THREADCOUNTMETHODS_KEY, "15"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(5 * cpu)); - assertThat(concurrency.methods, is(15 * cpu)); - } - - @Theory - public void unlimitedThreadsAll(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "all"); - properties.put(USEUNLIMITEDTHREADS_KEY, "true"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(Integer.MAX_VALUE)); - assertThat(concurrency.classes, is(Integer.MAX_VALUE)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - - properties.put(THREADCOUNTSUITES_KEY, "5"); - properties.put(THREADCOUNTCLASSES_KEY, "15"); - properties.put(THREADCOUNTMETHODS_KEY, "30"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(15 * cpu)); - assertThat(concurrency.methods, is(30 * cpu)); - } - - @Theory - public void threadCountSuites(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suites"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(0)); - assertThat(concurrency.suites, is(3 * cpu)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void threadCountClasses(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classes"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(0)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(3 * cpu)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void threadCountMethods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "methods"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(0)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(3 * cpu)); - } - - @Theory - public void threadCountBoth(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "both"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is((int) ((3d / 2) * cpu))); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void threadCountClassesAndMethods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classesAndMethods"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is((int) ((3d / 2) * cpu))); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void threadCountSuitesAndMethods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndMethods"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is((int) ((3d / 2) * cpu))); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void threadCountSuitesAndClasses(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndClasses"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is((int) ((3d / 2) * cpu))); - assertThat(concurrency.classes, is(Integer.MAX_VALUE)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void threadCountAll(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "all"); - properties.put(THREADCOUNT_KEY, "3"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is(cpu)); - assertThat(concurrency.classes, is(cpu)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void everyThreadCountSuitesAndClasses(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndClasses"); - properties.put(THREADCOUNT_KEY, "3"); - // % percentage ratio - properties.put(THREADCOUNTSUITES_KEY, "34"); - properties.put(THREADCOUNTCLASSES_KEY, "66"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - int concurrentSuites = (int) (0.34d * concurrency.capacity); - assertThat(concurrency.suites, is(concurrentSuites)); - assertThat(concurrency.classes, is(concurrency.capacity - concurrentSuites)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void everyThreadCountSuitesAndMethods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndMethods"); - properties.put(THREADCOUNT_KEY, "3"); - // % percentage ratio - properties.put(THREADCOUNTSUITES_KEY, "34"); - properties.put(THREADCOUNTMETHODS_KEY, "66"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - int concurrentSuites = (int) (0.34d * concurrency.capacity); - assertThat(concurrency.suites, is(concurrentSuites)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(concurrency.capacity - concurrentSuites)); - } - - @Theory - public void everyThreadCountClassesAndMethods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classesAndMethods"); - properties.put(THREADCOUNT_KEY, "3"); - // % percentage ratio - properties.put(THREADCOUNTCLASSES_KEY, "34"); - properties.put(THREADCOUNTMETHODS_KEY, "66"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - assertThat(concurrency.suites, is(0)); - int concurrentClasses = (int) (0.34d * concurrency.capacity); - assertThat(concurrency.classes, is(concurrentClasses)); - assertThat(concurrency.methods, is(concurrency.capacity - concurrentClasses)); - } - - @Theory - public void everyThreadCountAll(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "all"); - properties.put(THREADCOUNT_KEY, "3"); - // % percentage ratio - properties.put(THREADCOUNTSUITES_KEY, "17"); - properties.put(THREADCOUNTCLASSES_KEY, "34"); - properties.put(THREADCOUNTMETHODS_KEY, "49"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(3 * cpu)); - int concurrentSuites = (int) (0.17d * concurrency.capacity); - int concurrentClasses = (int) (0.34d * concurrency.capacity); - assertThat(concurrency.suites, is(concurrentSuites)); - assertThat(concurrency.classes, is(concurrentClasses)); - assertThat(concurrency.methods, is(concurrency.capacity - concurrentSuites - concurrentClasses)); - } - - @Theory - public void reusableThreadCountSuitesAndClasses(int cpu) throws TestSetFailedException { - // 4 * cpu to 5 * cpu threads to run test classes - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndClasses"); - properties.put(THREADCOUNT_KEY, "6"); - properties.put(THREADCOUNTSUITES_KEY, "2"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(6 * cpu)); - assertThat(concurrency.suites, is(2 * cpu)); - assertThat(concurrency.classes, is(Integer.MAX_VALUE)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void reusableThreadCountSuitesAndMethods(int cpu) throws TestSetFailedException { - // 4 * cpu to 5 * cpu threads to run test methods - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndMethods"); - properties.put(THREADCOUNT_KEY, "6"); - properties.put(THREADCOUNTSUITES_KEY, "2"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(6 * cpu)); - assertThat(concurrency.suites, is(2 * cpu)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void reusableThreadCountClassesAndMethods(int cpu) throws TestSetFailedException { - // 4 * cpu to 5 * cpu threads to run test methods - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classesAndMethods"); - properties.put(THREADCOUNT_KEY, "6"); - properties.put(THREADCOUNTCLASSES_KEY, "2"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(6 * cpu)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(2 * cpu)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void reusableThreadCountAll(int cpu) throws TestSetFailedException { - // 8 * cpu to 13 * cpu threads to run test methods - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "all"); - properties.put(THREADCOUNT_KEY, "14"); - properties.put(THREADCOUNTSUITES_KEY, "2"); - properties.put(THREADCOUNTCLASSES_KEY, "4"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(14 * cpu)); - assertThat(concurrency.suites, is(2 * cpu)); - assertThat(concurrency.classes, is(4 * cpu)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void suites(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suites"); - properties.put(THREADCOUNTSUITES_KEY, "5"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(5 * cpu)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void classes(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classes"); - properties.put(THREADCOUNTCLASSES_KEY, "5"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(5 * cpu)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(5 * cpu)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void methods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "methods"); - properties.put(THREADCOUNTMETHODS_KEY, "5"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(5 * cpu)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(5 * cpu)); - } - - @Theory - public void suitesAndClasses(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - - properties.put(PARALLEL_KEY, "suitesAndClasses"); - properties.put(THREADCOUNTSUITES_KEY, "5"); - properties.put(THREADCOUNTCLASSES_KEY, "15"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(20 * cpu)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(15 * cpu)); - assertThat(concurrency.methods, is(0)); - - // Warning: this case works but is not enabled in AbstractSurefireMojo - // Instead use the 'useUnlimitedThreads' parameter. - properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndClasses"); - properties.put(THREADCOUNTSUITES_KEY, "5"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertFalse(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(Integer.MAX_VALUE)); - assertThat(concurrency.methods, is(0)); - } - - @Theory - public void suitesAndMethods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - - properties.put(PARALLEL_KEY, "suitesAndMethods"); - properties.put(THREADCOUNTSUITES_KEY, "5"); - properties.put(THREADCOUNTMETHODS_KEY, "15"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(20 * cpu)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(15 * cpu)); - - // Warning: this case works but is not enabled in AbstractSurefireMojo - // Instead use the 'useUnlimitedThreads' parameter. - properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "suitesAndMethods"); - properties.put(THREADCOUNTSUITES_KEY, "5"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertFalse(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(0)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void classesAndMethods(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - - properties.put(PARALLEL_KEY, "classesAndMethods"); - properties.put(THREADCOUNTCLASSES_KEY, "5"); - properties.put(THREADCOUNTMETHODS_KEY, "15"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(20 * cpu)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(5 * cpu)); - assertThat(concurrency.methods, is(15 * cpu)); - - // Warning: this case works but is not enabled in AbstractSurefireMojo - // Instead use the 'useUnlimitedThreads' parameter. - properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "classesAndMethods"); - properties.put(THREADCOUNTCLASSES_KEY, "5"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertFalse(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(0)); - assertThat(concurrency.classes, is(5 * cpu)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Theory - public void all(int cpu) throws TestSetFailedException { - ParallelComputerUtil.overrideAvailableProcessors(cpu); - Map properties = new HashMap<>(); - - properties.put(PARALLEL_KEY, "all"); - properties.put(THREADCOUNTSUITES_KEY, "5"); - properties.put(THREADCOUNTCLASSES_KEY, "15"); - properties.put(THREADCOUNTMETHODS_KEY, "30"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - Concurrency concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(50 * cpu)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(15 * cpu)); - assertThat(concurrency.methods, is(30 * cpu)); - - // Warning: these cases work but they are not enabled in AbstractSurefireMojo - // Instead use the 'useUnlimitedThreads' parameter. - properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "all"); - properties.put(THREADCOUNTSUITES_KEY, "5"); - properties.put(THREADCOUNTCLASSES_KEY, "15"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(5 * cpu)); - assertThat(concurrency.classes, is(15 * cpu)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - - properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "all"); - properties.put(THREADCOUNTCLASSES_KEY, "15"); - params = new JUnitCoreParameters(properties); - concurrency = resolveConcurrency(params, null); - assertTrue(params.isParallelSuites()); - assertTrue(params.isParallelClasses()); - assertTrue(params.isParallelMethods()); - assertThat(concurrency.capacity, is(Integer.MAX_VALUE)); - assertThat(concurrency.suites, is(Integer.MAX_VALUE)); - assertThat(concurrency.classes, is(15 * cpu)); - assertThat(concurrency.methods, is(Integer.MAX_VALUE)); - } - - @Test - public void withoutShutdown() { - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "methods"); - properties.put(THREADCOUNTMETHODS_KEY, "2"); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder(LOGGER, params); - ParallelComputer pc = pcBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - final Result result = core.run(pc, TestClass.class); - final long t2 = systemMillis(); - long timeSpent = t2 - t1; - final long deltaTime = 500L; - - assertTrue(result.wasSuccessful()); - assertThat(result.getRunCount(), is(3)); - assertThat(result.getFailureCount(), is(0)); - assertThat(result.getIgnoreCount(), is(0)); - // assertThat( timeSpent, between (timeSpent - deltaTime, timeSpent + deltaTime + 2000L ) ); - assertEquals(10000L, timeSpent, deltaTime); - } - - @Test - public void shutdown() throws TestSetFailedException { - // The JUnitCore returns after 2.5 s. - // The test-methods in TestClass are NOT interrupted, and return normally after 5 s. - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "methods"); - properties.put(THREADCOUNTMETHODS_KEY, "2"); - properties.put(PARALLEL_TIMEOUT_KEY, Double.toString(2.5d)); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder(LOGGER, params); - ParallelComputer pc = pcBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - core.run(pc, TestClass.class); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - final long deltaTime = 500L; - - assertEquals(5000L, timeSpent, deltaTime); - String description = pc.describeElapsedTimeout(); - assertTrue(description.contains("The test run has finished abruptly after timeout of 2.5 seconds.")); - assertTrue(description.contains( - "These tests were executed in prior to the shutdown operation:\n" + TestClass.class.getName())); - } - - @Test - public void forcedShutdown() throws TestSetFailedException { - // The JUnitCore returns after 2.5 s, and the test-methods in TestClass are interrupted. - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "methods"); - properties.put(THREADCOUNTMETHODS_KEY, "2"); - properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString(2.5d)); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder(LOGGER, params); - ParallelComputer pc = pcBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - core.run(pc, TestClass.class); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - final long deltaTime = 500L; - - assertEquals(2500L, timeSpent, deltaTime); - String description = pc.describeElapsedTimeout(); - assertTrue(description.contains("The test run has finished abruptly after timeout of 2.5 seconds.")); - assertTrue(description.contains( - "These tests were executed in prior to the shutdown operation:\n" + TestClass.class.getName())); - } - - @Test - public void timeoutAndForcedShutdown() throws TestSetFailedException { - // The JUnitCore returns after 3.5 s and the test-methods in TestClass are timed out after 2.5 s. - // No new test methods are scheduled for execution after 2.5 s. - // Interruption of test methods after 3.5 s. - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "methods"); - properties.put(THREADCOUNTMETHODS_KEY, "2"); - properties.put(PARALLEL_TIMEOUT_KEY, Double.toString(2.5d)); - properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString(3.5d)); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder(LOGGER, params); - ParallelComputer pc = pcBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - core.run(pc, TestClass.class); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - final long deltaTime = 500L; - - assertEquals(3500L, timeSpent, deltaTime); - String description = pc.describeElapsedTimeout(); - assertTrue(description.contains("The test run has finished abruptly after timeout of 2.5 seconds.")); - assertTrue(description.contains( - "These tests were executed in prior to the shutdown operation:\n" + TestClass.class.getName())); - } - - @Test - public void forcedTimeoutAndShutdown() throws Exception { - // The JUnitCore returns after 3.5 s and the test-methods in TestClass are interrupted after 3.5 s. - Map properties = new HashMap<>(); - properties.put(PARALLEL_KEY, "methods"); - properties.put(THREADCOUNTMETHODS_KEY, "2"); - properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString(3.5d)); - properties.put(PARALLEL_TIMEOUT_KEY, Double.toString(4.0d)); - JUnitCoreParameters params = new JUnitCoreParameters(properties); - ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder(LOGGER, params); - ParallelComputer pc = pcBuilder.buildComputer(); - final JUnitCore core = new JUnitCore(); - final long t1 = systemMillis(); - core.run(pc, TestClass.class); - final long t2 = systemMillis(); - final long timeSpent = t2 - t1; - final long deltaTime = 500L; - - assertEquals(3500L, timeSpent, deltaTime); - String description = pc.describeElapsedTimeout(); - assertTrue(description.contains("The test run has finished abruptly after timeout of 3.5 seconds.")); - assertTrue(description.contains( - "These tests were executed in prior to the shutdown operation:\n" + TestClass.class.getName())); - } - - /** - * - */ - public static class TestClass { - @Test - public void a() throws InterruptedException { - long t1 = systemMillis(); - try { - Thread.sleep(5000L); - } finally { - System.out.println(getClass().getSimpleName() + "#a() spent " + (systemMillis() - t1)); - } - } - - @Test - public void b() throws InterruptedException { - long t1 = systemMillis(); - try { - Thread.sleep(5000L); - } finally { - System.out.println(getClass().getSimpleName() + "#b() spent " + (systemMillis() - t1)); - } - } - - @Test - public void c() throws InterruptedException { - long t1 = systemMillis(); - try { - Thread.sleep(5000L); - } finally { - System.out.println(getClass().getSimpleName() + "#c() spent " + (systemMillis() - t1)); - } - } - } - - private static long systemMillis() { - return TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/RangeMatcher.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/RangeMatcher.java deleted file mode 100644 index b4f5c1f9d8..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/RangeMatcher.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; -import org.hamcrest.Matcher; - -/** - * @author Tibor Digana (tibor17) - * @since 2.16 - */ -final class RangeMatcher extends BaseMatcher { - private final long from; - - private final long to; - - private RangeMatcher(long from, long to) { - this.from = from; - this.to = to; - } - - public static Matcher between(long from, long to) { - return new RangeMatcher(from, to); - } - - @Override - public void describeTo(Description description) { - description.appendValueList("between ", " and ", "", from, to); - } - - @Override - public boolean matches(Object o) { - long actual = (Long) o; - return actual >= from && actual <= to; - } -} diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java deleted file mode 100644 index 0700f02ccd..0000000000 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * 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.surefire.junitcore.pc; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.junit.Test; - -import static org.apache.maven.surefire.api.util.internal.DaemonThreadFactory.newDaemonThreadFactory; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -/** - * Tests the factories in SchedulingStrategy. - *
- * Th point of these tests is to check {@link Task#result} if changed - * from {@code false} to {@code true} after all scheduled tasks - * have finished. - * The call {@link SchedulingStrategy#finished()} is waiting until the - * strategy has finished. - * Then {@link Task#result} should be asserted that is {@code true}. - * - * @author Tibor Digana (tibor17) - * @see SchedulingStrategy - * @since 2.16 - */ -public class SchedulingStrategiesTest { - private static final ThreadFactory DAEMON_THREAD_FACTORY = newDaemonThreadFactory(); - private final ConsoleLogger logger = mock(ConsoleLogger.class); - - @Test - public void invokerStrategy() throws InterruptedException { - SchedulingStrategy strategy = SchedulingStrategies.createInvokerStrategy(logger); - assertFalse(strategy.hasSharedThreadPool()); - assertTrue(strategy.canSchedule()); - - Task task = new Task(); - - strategy.schedule(task); - - assertTrue(strategy.canSchedule()); - - assertTrue(task.result); - - assertTrue(strategy.finished()); - assertFalse(strategy.canSchedule()); - } - - @Test - public void nonSharedPoolStrategy() throws InterruptedException { - SchedulingStrategy strategy = SchedulingStrategies.createParallelStrategy(logger, 2); - assertFalse(strategy.hasSharedThreadPool()); - assertTrue(strategy.canSchedule()); - - Task task1 = new Task(); - Task task2 = new Task(); - - strategy.schedule(task1); - strategy.schedule(task2); - - assertTrue(strategy.canSchedule()); - - assertTrue(strategy.finished()); - assertFalse(strategy.canSchedule()); - - assertTrue(task1.result); - assertTrue(task2.result); - } - - @Test(expected = NullPointerException.class) - public void sharedPoolStrategyNullPool() { - SchedulingStrategies.createParallelSharedStrategy(logger, null); - } - - @Test - public void sharedPoolStrategy() throws InterruptedException { - ExecutorService sharedPool = Executors.newCachedThreadPool(DAEMON_THREAD_FACTORY); - - SchedulingStrategy strategy1 = SchedulingStrategies.createParallelSharedStrategy(logger, sharedPool); - assertTrue(strategy1.hasSharedThreadPool()); - assertTrue(strategy1.canSchedule()); - - SchedulingStrategy strategy2 = SchedulingStrategies.createParallelSharedStrategy(logger, sharedPool); - assertTrue(strategy2.hasSharedThreadPool()); - assertTrue(strategy2.canSchedule()); - - Task task1 = new Task(); - Task task2 = new Task(); - Task task3 = new Task(); - Task task4 = new Task(); - - strategy1.schedule(task1); - strategy2.schedule(task2); - strategy1.schedule(task3); - strategy2.schedule(task4); - - assertTrue(strategy1.canSchedule()); - assertTrue(strategy2.canSchedule()); - - assertTrue(strategy1.finished()); - assertFalse(strategy1.canSchedule()); - - assertTrue(strategy2.finished()); - assertFalse(strategy2.canSchedule()); - - assertTrue(task1.result); - assertTrue(task2.result); - assertTrue(task3.result); - assertTrue(task4.result); - } - - @Test - public void infinitePoolStrategy() throws InterruptedException { - SchedulingStrategy strategy = SchedulingStrategies.createParallelStrategyUnbounded(logger); - assertFalse(strategy.hasSharedThreadPool()); - assertTrue(strategy.canSchedule()); - - Task task1 = new Task(); - Task task2 = new Task(); - - strategy.schedule(task1); - strategy.schedule(task2); - - assertTrue(strategy.canSchedule()); - - assertTrue(strategy.finished()); - assertFalse(strategy.canSchedule()); - - assertTrue(task1.result); - assertTrue(task2.result); - } - - static class Task implements Runnable { - volatile boolean result = false; - - @Override - public void run() { - result = true; - } - } -} diff --git a/surefire-providers/surefire-testng-utils/pom.xml b/surefire-providers/surefire-testng-utils/pom.xml deleted file mode 100644 index 8bf422dc2f..0000000000 --- a/surefire-providers/surefire-testng-utils/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - 4.0.0 - - - org.apache.maven.surefire - surefire-providers - 3.5.5-SNAPSHOT - - - surefire-testng-utils - - Surefire TestNG Utils - TestNG Utilities - - - - junit - junit - 3.8.2 - provided - - - org.apache.maven.surefire - surefire-grouper - ${project.version} - - - org.testng - testng - ${testngVersion} - jdk15 - provided - - - - - - - org.jacoco - jacoco-maven-plugin - - jacoco.agent - - - - jacoco-agent - - prepare-agent - - - - - - maven-surefire-plugin - - ${jvm.args.tests} ${jacoco.agent} - - - - org.apache.maven.surefire - surefire-shadefire - - - 3.5.0 - - - - - - diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastEventsSingleton.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastEventsSingleton.java deleted file mode 100644 index c087a85ca3..0000000000 --- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastEventsSingleton.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.surefire.testng.utils; - -/** - * Stores and retrieves atomic events - * used by {@link FailFastNotifier} and TestNG provider. - * - * @author Tibor Digana (tibor17) - * @since 2.19 - */ -public final class FailFastEventsSingleton { - private static final FailFastEventsSingleton INSTANCE = new FailFastEventsSingleton(); - - private volatile boolean skipAfterFailure; - - private FailFastEventsSingleton() {} - - public static FailFastEventsSingleton getInstance() { - return INSTANCE; - } - - public boolean isSkipAfterFailure() { - return skipAfterFailure; - } - - public void setSkipOnNextTest() { - this.skipAfterFailure = true; - } -} diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastListener.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastListener.java deleted file mode 100644 index 6391f5f96a..0000000000 --- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastListener.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.surefire.testng.utils; - -import org.apache.maven.surefire.api.report.Stoppable; -import org.testng.ITestContext; -import org.testng.ITestListener; -import org.testng.ITestResult; - -/** - * Sends an even in {@link FailFastEventsSingleton} that failure has appeared. - * - * @author Tibor Digana (tibor17) - * @since 2.19 - */ -public class FailFastListener implements ITestListener { - private final Stoppable stoppable; - - public FailFastListener(Stoppable stoppable) { - this.stoppable = stoppable; - } - - @Override - public void onTestStart(ITestResult result) {} - - @Override - public void onTestSuccess(ITestResult result) {} - - @Override - public void onTestFailure(ITestResult result) { - stoppable.fireStopEvent(); - } - - @Override - public void onTestSkipped(ITestResult result) {} - - @Override - public void onTestFailedButWithinSuccessPercentage(ITestResult result) {} - - @Override - public void onStart(ITestContext context) {} - - @Override - public void onFinish(ITestContext context) {} -} diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastNotifier.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastNotifier.java deleted file mode 100644 index 6d5df202f8..0000000000 --- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/FailFastNotifier.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.surefire.testng.utils; - -import org.testng.IInvokedMethod; -import org.testng.IInvokedMethodListener; -import org.testng.ITestResult; -import org.testng.SkipException; - -/** - * Notifies TestNG core skipping remaining tests after first failure has appeared. - * - * @author Tibor Digana (tibor17) - * @since 2.19 - */ -public class FailFastNotifier implements IInvokedMethodListener { - - @Override - public void beforeInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) { - if (FailFastEventsSingleton.getInstance().isSkipAfterFailure()) { - throw new SkipException("Skipped after failure. See parameter [skipAfterFailureCount] " - + "in surefire or failsafe plugin."); - } - } - - @Override - public void afterInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) {} -} diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java deleted file mode 100644 index fa8d02efc6..0000000000 --- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.surefire.testng.utils; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.maven.surefire.group.match.AndGroupMatcher; -import org.apache.maven.surefire.group.match.GroupMatcher; -import org.apache.maven.surefire.group.match.InverseGroupMatcher; -import org.apache.maven.surefire.group.parse.GroupMatcherParser; -import org.apache.maven.surefire.group.parse.ParseException; -import org.testng.IMethodSelector; -import org.testng.IMethodSelectorContext; -import org.testng.ITestNGMethod; - -/** - * Method selector delegating to {@link GroupMatcher} to decide if a method is included or not. - * - */ -public class GroupMatcherMethodSelector implements IMethodSelector { - - private static final long serialVersionUID = 1L; - - private static GroupMatcher matcher; - - private Map answers = new HashMap<>(); - - @Override - public boolean includeMethod(IMethodSelectorContext context, ITestNGMethod method, boolean isTestMethod) { - Boolean result = answers.get(method); - if (result != null) { - return result; - } - - if (matcher == null) { - return true; - } - - String[] groups = method.getGroups(); - result = matcher.enabled(groups); - answers.put(method, result); - return result; - } - - @Override - public void setTestMethods(List testMethods) {} - - public static void setGroups(String groups, String excludedGroups) { - // System.out.println( "Processing group includes: '" + groups + "'\nExcludes: '" + excludedGroups + "'" ); - - try { - AndGroupMatcher matcher = new AndGroupMatcher(); - GroupMatcher in = null; - if (groups != null && !groups.trim().isEmpty()) { - in = new GroupMatcherParser(groups).parse(); - } - - if (in != null) { - matcher.addMatcher(in); - } - - GroupMatcher ex = null; - if (excludedGroups != null && !excludedGroups.trim().isEmpty()) { - ex = new GroupMatcherParser(excludedGroups).parse(); - } - - if (ex != null) { - matcher.addMatcher(new InverseGroupMatcher(ex)); - } - - if (in != null || ex != null) { - // System.out.println( "Group matcher: " + matcher ); - GroupMatcherMethodSelector.matcher = matcher; - } - } catch (ParseException e) { - throw new IllegalArgumentException( - "Cannot parse group includes/excludes expression(s):\nIncludes: " + groups + "\nExcludes: " - + excludedGroups, - e); - } - } - - public static void setGroupMatcher(GroupMatcher matcher) { - GroupMatcherMethodSelector.matcher = matcher; - } -} diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java deleted file mode 100644 index b5930ad4ef..0000000000 --- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.surefire.testng.utils; - -import java.util.List; - -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.testng.IMethodSelector; -import org.testng.IMethodSelectorContext; -import org.testng.ITestNGMethod; - -/** - * For internal use only - * - * @author Olivier Lamy - * @since 2.7.3 - */ -public class MethodSelector implements IMethodSelector { - private static volatile TestListResolver testListResolver = null; - - @Override - public void setTestMethods(List arg0) {} - - @Override - public boolean includeMethod(IMethodSelectorContext context, ITestNGMethod testngMethod, boolean isTestMethod) { - return testngMethod.isBeforeClassConfiguration() - || testngMethod.isBeforeGroupsConfiguration() - || testngMethod.isBeforeMethodConfiguration() - || testngMethod.isBeforeSuiteConfiguration() - || testngMethod.isBeforeTestConfiguration() - || testngMethod.isAfterClassConfiguration() - || testngMethod.isAfterGroupsConfiguration() - || testngMethod.isAfterMethodConfiguration() - || testngMethod.isAfterSuiteConfiguration() - || testngMethod.isAfterTestConfiguration() - || shouldRun(testngMethod); - } - - public static void setTestListResolver(TestListResolver testListResolver) { - MethodSelector.testListResolver = testListResolver; - } - - private static boolean shouldRun(ITestNGMethod test) { - TestListResolver resolver = testListResolver; - boolean hasTestResolver = resolver != null && !resolver.isEmpty(); - if (hasTestResolver) { - boolean run = false; - for (Class clazz = test.getRealClass(); - !run && clazz != null && clazz != Object.class; - clazz = clazz.getSuperclass()) { - run = resolver.shouldRun(clazz, test.getMethodName()); - } - return run; - } - return false; - } -} diff --git a/surefire-providers/surefire-testng-utils/src/test/java/testng/utils/BaseClassSample.java b/surefire-providers/surefire-testng-utils/src/test/java/testng/utils/BaseClassSample.java deleted file mode 100644 index 3629535053..0000000000 --- a/surefire-providers/surefire-testng-utils/src/test/java/testng/utils/BaseClassSample.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 testng.utils; - -/** - * - */ -public abstract class BaseClassSample { - public void baseClassMethodToBeIncluded() {} -} diff --git a/surefire-providers/surefire-testng-utils/src/test/java/testng/utils/ChildClassSample.java b/surefire-providers/surefire-testng-utils/src/test/java/testng/utils/ChildClassSample.java deleted file mode 100644 index e302b27cc2..0000000000 --- a/surefire-providers/surefire-testng-utils/src/test/java/testng/utils/ChildClassSample.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 testng.utils; - -/** - * - */ -public class ChildClassSample extends BaseClassSample { - public void subClassMethod() {} -} diff --git a/surefire-providers/surefire-testng-utils/src/test/java/testng/utils/MethodSelectorTest.java b/surefire-providers/surefire-testng-utils/src/test/java/testng/utils/MethodSelectorTest.java deleted file mode 100644 index c0e7838bda..0000000000 --- a/surefire-providers/surefire-testng-utils/src/test/java/testng/utils/MethodSelectorTest.java +++ /dev/null @@ -1,316 +0,0 @@ -/* - * 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 testng.utils; - -import java.lang.reflect.Method; - -import junit.framework.TestCase; -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.apache.maven.surefire.testng.utils.MethodSelector; -import org.testng.IClass; -import org.testng.IRetryAnalyzer; -import org.testng.ITestClass; -import org.testng.ITestNGMethod; -import org.testng.internal.DefaultMethodSelectorContext; - -/** - * - */ -public class MethodSelectorTest extends TestCase { - public void testInclusionOfMethodFromBaseClass() { - MethodSelector selector = new MethodSelector(); - DefaultMethodSelectorContext context = new DefaultMethodSelectorContext(); - ITestNGMethod testngMethod = new FakeTestNGMethod(ChildClassSample.class, "baseClassMethodToBeIncluded"); - TestListResolver resolver = - new TestListResolver(BaseClassSample.class.getName() + "#baseClassMethodToBeIncluded"); - MethodSelector.setTestListResolver(resolver); - boolean include = selector.includeMethod(context, testngMethod, true); - assertTrue(include); - } - - public void testNoInclusionOfMethodFromBaseClass() { - MethodSelector selector = new MethodSelector(); - DefaultMethodSelectorContext context = new DefaultMethodSelectorContext(); - ITestNGMethod testngMethod = new FakeTestNGMethod(ChildClassSample.class, "baseClassMethodToBeIncluded"); - TestListResolver resolver = new TestListResolver(BaseClassSample.class.getName() + "#nonExistedMethod"); - MethodSelector.setTestListResolver(resolver); - boolean include = selector.includeMethod(context, testngMethod, true); - assertFalse(include); - } - - public void testInclusionOfMethodFromSubClass() { - MethodSelector selector = new MethodSelector(); - DefaultMethodSelectorContext context = new DefaultMethodSelectorContext(); - ITestNGMethod testngMethod = new FakeTestNGMethod(ChildClassSample.class, "subClassMethod"); - TestListResolver resolver = new TestListResolver(ChildClassSample.class.getName() + "#sub*"); - MethodSelector.setTestListResolver(resolver); - boolean include = selector.includeMethod(context, testngMethod, true); - assertTrue(include); - } - - private static class FakeTestNGMethod implements ITestNGMethod { - private final Class clazz; - private final String methodName; - - FakeTestNGMethod(Class clazz, String methodName) { - this.clazz = clazz; - this.methodName = methodName; - } - - @Override - public Class getRealClass() { - return clazz; - } - - @Override - public ITestClass getTestClass() { - return null; - } - - @Override - public void setTestClass(ITestClass iTestClass) {} - - @Override - public Method getMethod() { - return null; - } - - @Override - public String getMethodName() { - return methodName; - } - - @Override - public Object[] getInstances() { - return new Object[0]; - } - - @Override - public long[] getInstanceHashCodes() { - return new long[0]; - } - - @Override - public String[] getGroups() { - return new String[0]; - } - - @Override - public String[] getGroupsDependedUpon() { - return new String[0]; - } - - @Override - public String getMissingGroup() { - return null; - } - - @Override - public void setMissingGroup(String s) {} - - @Override - public String[] getBeforeGroups() { - return new String[0]; - } - - @Override - public String[] getAfterGroups() { - return new String[0]; - } - - @Override - public String[] getMethodsDependedUpon() { - return new String[0]; - } - - @Override - public void addMethodDependedUpon(String s) {} - - @Override - public boolean isTest() { - return false; - } - - @Override - public boolean isBeforeMethodConfiguration() { - return false; - } - - @Override - public boolean isAfterMethodConfiguration() { - return false; - } - - @Override - public boolean isBeforeClassConfiguration() { - return false; - } - - @Override - public boolean isAfterClassConfiguration() { - return false; - } - - @Override - public boolean isBeforeSuiteConfiguration() { - return false; - } - - @Override - public boolean isAfterSuiteConfiguration() { - return false; - } - - @Override - public boolean isBeforeTestConfiguration() { - return false; - } - - @Override - public boolean isAfterTestConfiguration() { - return false; - } - - @Override - public boolean isBeforeGroupsConfiguration() { - return false; - } - - @Override - public boolean isAfterGroupsConfiguration() { - return false; - } - - @Override - public long getTimeOut() { - return 0; - } - - @Override - public int getInvocationCount() { - return 0; - } - - @Override - public void setInvocationCount(int i) {} - - @Override - public int getSuccessPercentage() { - return 0; - } - - @Override - public String getId() { - return null; - } - - @Override - public void setId(String s) {} - - @Override - public long getDate() { - return 0; - } - - @Override - public void setDate(long l) {} - - @Override - public boolean canRunFromClass(IClass iClass) { - return false; - } - - @Override - public boolean isAlwaysRun() { - return false; - } - - @Override - public int getThreadPoolSize() { - return 0; - } - - @Override - public void setThreadPoolSize(int i) {} - - @Override - public String getDescription() { - return null; - } - - @Override - public void incrementCurrentInvocationCount() {} - - @Override - public int getCurrentInvocationCount() { - return 0; - } - - @Override - public void setParameterInvocationCount(int i) {} - - @Override - public int getParameterInvocationCount() { - return 0; - } - - @Override - public ITestNGMethod clone() { - try { - return (ITestNGMethod) super.clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e); - } - } - - @Override - public IRetryAnalyzer getRetryAnalyzer() { - return null; - } - - @Override - public void setRetryAnalyzer(IRetryAnalyzer iRetryAnalyzer) {} - - @Override - public boolean skipFailedInvocations() { - return false; - } - - @Override - public void setSkipFailedInvocations(boolean b) {} - - @Override - public long getInvocationTimeOut() { - return 0; - } - - @Override - public boolean ignoreMissingDependencies() { - return false; - } - - @Override - public void setIgnoreMissingDependencies(boolean b) {} - - @Override - public int compareTo(Object o) { - return 0; - } - } -} diff --git a/surefire-providers/surefire-testng/pom.xml b/surefire-providers/surefire-testng/pom.xml deleted file mode 100644 index 2fdfe3c086..0000000000 --- a/surefire-providers/surefire-testng/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - 4.0.0 - - - org.apache.maven.surefire - surefire-providers - 3.5.5-SNAPSHOT - - - surefire-testng - - Surefire TestNG Runner - Surefire TestNG Runner - - - - junit - junit - 3.8.2 - provided - - - org.assertj - assertj-core - test - - - org.apache.maven.surefire - surefire-shared-utils - - - org.apache.maven.surefire - common-java5 - ${project.version} - - - org.apache.maven.surefire - surefire-testng-utils - ${project.version} - - - org.testng - testng - ${testngVersion} - jdk15 - provided - - - org.mockito - mockito-core - test - - - org.powermock - powermock-reflect - test - - - - - - - org.jacoco - jacoco-maven-plugin - - jacoco.agent - - - - jacoco-agent - - prepare-agent - - - - - - maven-surefire-plugin - - ${jvm.args.tests} ${jacoco.agent} - - - - org.apache.maven.surefire - surefire-shadefire - - - 3.5.0 - - - - - - diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java deleted file mode 100644 index 71637ab56d..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.surefire.testng; - -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.testng.internal.IResultListener; - -/** - * Just like TestNGReporter, but explicitly implements IResultListener; this interface is new in TestNG 5.5 - * - * @author Dan Fabulich - */ -public class ConfigurationAwareTestNGReporter extends TestNGReporter implements IResultListener { - - public ConfigurationAwareTestNGReporter(TestReportListener reportManager) { - super(reportManager); - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java deleted file mode 100644 index 871ed9f499..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * 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.surefire.testng; - -import java.io.File; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.maven.surefire.api.cli.CommandLineOption; -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.api.util.TestsToRun; - -import static java.util.Collections.singleton; -import static org.apache.maven.surefire.shared.utils.StringUtils.isBlank; -import static org.apache.maven.surefire.testng.TestNGExecutor.run; - -/** - * Test suite for TestNG based on a directory of Java test classes. Can also execute JUnit tests. - * - * @author Brett Porter - * @author Alex Popescu - */ -final class TestNGDirectoryTestSuite extends TestSuite { - private final Map options; - - private final Map junitOptions; - - private final String testSourceDirectory; - - private final File reportsDirectory; - - private final TestListResolver methodFilter; - - private final Class junitTestClass; - - private final Class junitRunWithAnnotation; - - private final Class junitTestAnnotation; - - private final List mainCliOptions; - - private final int skipAfterFailureCount; - - TestNGDirectoryTestSuite( - String testSourceDirectory, - Map confOptions, - File reportsDirectory, - TestListResolver methodFilter, - List mainCliOptions, - int skipAfterFailureCount) { - this.options = confOptions; - this.testSourceDirectory = testSourceDirectory; - this.reportsDirectory = reportsDirectory; - this.methodFilter = methodFilter; - this.junitTestClass = findJUnitTestClass(); - this.junitRunWithAnnotation = findJUnitRunWithAnnotation(); - this.junitTestAnnotation = findJUnitTestAnnotation(); - this.junitOptions = createJUnitOptions(); - this.mainCliOptions = mainCliOptions; - this.skipAfterFailureCount = skipAfterFailureCount; - } - - void execute(TestsToRun testsToRun, TestNGReporter testNGReporter) throws TestSetFailedException { - if (!testsToRun.allowEagerReading()) { - executeLazy(testsToRun, testNGReporter); - } else if (testsToRun.containsAtLeast(2)) { - executeMulti(testsToRun, testNGReporter); - } else if (testsToRun.containsAtLeast(1)) { - Class testClass = testsToRun.iterator().next(); - executeSingleClass(testNGReporter, testClass); - } - } - - private void executeSingleClass(TestNGReporter testNGReporter, Class testClass) throws TestSetFailedException { - options.put("suitename", testClass.getName()); - - startTestSuite(testNGReporter.getRunListener()); - - Map optionsToUse = isJUnitTest(testClass) ? junitOptions : options; - - run( - singleton(testClass), - testSourceDirectory, - optionsToUse, - testNGReporter, - reportsDirectory, - methodFilter, - mainCliOptions, - skipAfterFailureCount); - - finishTestSuite(testNGReporter.getRunListener()); - } - - private void executeLazy(TestsToRun testsToRun, TestNGReporter testNGReporter) throws TestSetFailedException { - for (Class testToRun : testsToRun) { - executeSingleClass(testNGReporter, testToRun); - } - } - - private static Class findJUnitTestClass() { - return lookupClass("junit.framework.Test"); - } - - private static Class findJUnitRunWithAnnotation() { - return lookupAnnotation("org.junit.runner.RunWith"); - } - - private static Class findJUnitTestAnnotation() { - return lookupAnnotation("org.junit.Test"); - } - - @SuppressWarnings("unchecked") - private static Class lookupAnnotation(String className) { - try { - return (Class) Class.forName(className); - } catch (ClassNotFoundException e) { - return null; - } - } - - private static Class lookupClass(String className) { - try { - return Class.forName(className); - } catch (ClassNotFoundException e) { - return null; - } - } - - private void executeMulti(TestsToRun testsToRun, TestNGReporter testNGReporter) throws TestSetFailedException { - List> testNgTestClasses = new ArrayList<>(); - List> junitTestClasses = new ArrayList<>(); - for (Class testToRun : testsToRun) { - if (isJUnitTest(testToRun)) { - junitTestClasses.add(testToRun); - } else { - testNgTestClasses.add(testToRun); - } - } - - File testNgReportsDirectory = reportsDirectory, junitReportsDirectory = reportsDirectory; - - if (!junitTestClasses.isEmpty() && !testNgTestClasses.isEmpty()) { - testNgReportsDirectory = new File(reportsDirectory, "testng-native-results"); - junitReportsDirectory = new File(reportsDirectory, "testng-junit-results"); - } - startTestSuite(testNGReporter.getRunListener()); - - run( - testNgTestClasses, - testSourceDirectory, - options, - testNGReporter, - testNgReportsDirectory, - methodFilter, - mainCliOptions, - skipAfterFailureCount); - - if (!junitTestClasses.isEmpty()) { - run( - junitTestClasses, - testSourceDirectory, - junitOptions, - testNGReporter, - junitReportsDirectory, - methodFilter, - mainCliOptions, - skipAfterFailureCount); - } - - finishTestSuite(testNGReporter.getRunListener()); - } - - private boolean isJUnitTest(Class c) { - return isJunit3Test(c) || isJunit4Test(c); - } - - private boolean isJunit4Test(Class c) { - return hasJunit4RunWithAnnotation(c) || hasJunit4TestAnnotation(c); - } - - private boolean hasJunit4RunWithAnnotation(Class c) { - return junitRunWithAnnotation != null && c.getAnnotation(junitRunWithAnnotation) != null; - } - - private boolean hasJunit4TestAnnotation(Class c) { - if (junitTestAnnotation != null) { - for (Method m : c.getMethods()) { - if (m.getAnnotation(junitTestAnnotation) != null) { - return true; - } - } - } - - return false; - } - - private boolean isJunit3Test(Class c) { - return junitTestClass != null && junitTestClass.isAssignableFrom(c); - } - - private Map createJUnitOptions() { - Map junitOptions = new HashMap<>(options); - String onlyJUnit = options.get("junit"); - if (isBlank(onlyJUnit)) { - onlyJUnit = "true"; - } - junitOptions.put("junit", onlyJUnit); - return junitOptions; - } - - @Override - Map getOptions() { - return options; - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java deleted file mode 100644 index 816e564252..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java +++ /dev/null @@ -1,365 +0,0 @@ -/* - * 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.surefire.testng; - -import java.io.File; -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.maven.surefire.api.booter.ProviderParameterNames; -import org.apache.maven.surefire.api.cli.CommandLineOption; -import org.apache.maven.surefire.api.report.RunListener; -import org.apache.maven.surefire.api.report.Stoppable; -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.shared.utils.StringUtils; -import org.apache.maven.surefire.testng.conf.Configurator; -import org.apache.maven.surefire.testng.utils.FailFastEventsSingleton; -import org.apache.maven.surefire.testng.utils.FailFastListener; -import org.apache.maven.surefire.testng.utils.FailFastNotifier; -import org.testng.ITestNGListener; -import org.testng.TestNG; -import org.testng.annotations.Test; -import org.testng.xml.XmlClass; -import org.testng.xml.XmlMethodSelector; -import org.testng.xml.XmlSuite; -import org.testng.xml.XmlTest; - -import static org.apache.maven.surefire.api.cli.CommandLineOption.LOGGING_LEVEL_DEBUG; -import static org.apache.maven.surefire.api.cli.CommandLineOption.SHOW_ERRORS; -import static org.apache.maven.surefire.api.util.ReflectionUtils.instantiate; -import static org.apache.maven.surefire.api.util.ReflectionUtils.invokeSetter; -import static org.apache.maven.surefire.api.util.ReflectionUtils.newInstance; -import static org.apache.maven.surefire.api.util.ReflectionUtils.tryGetConstructor; -import static org.apache.maven.surefire.api.util.ReflectionUtils.tryGetMethod; -import static org.apache.maven.surefire.api.util.ReflectionUtils.tryLoadClass; -import static org.apache.maven.surefire.api.util.internal.ConcurrencyUtils.runIfZeroCountDown; - -/** - * Contains utility methods for executing TestNG. - * - * @author Brett Porter - * @author Alex Popescu - */ -final class TestNGExecutor { - /** The default name for a suite launched from the maven surefire plugin */ - private static final String DEFAULT_SUREFIRE_SUITE_NAME = "Surefire suite"; - - /** The default name for a test launched from the maven surefire plugin */ - private static final String DEFAULT_SUREFIRE_TEST_NAME = "Surefire test"; - - private static final boolean HAS_TEST_ANNOTATION_ON_CLASSPATH = - tryLoadClass(TestNGExecutor.class.getClassLoader(), "org.testng.annotations.Test") != null; - - // Using reflection because XmlClass.setIndex is available since TestNG 6.3 - // XmlClass.m_index field is available since TestNG 5.13, but prior to 6.3 required invoking constructor - // and constructor XmlClass constructor signatures evolved over time. - private static final Method XML_CLASS_SET_INDEX = tryGetMethod(XmlClass.class, "setIndex", int.class); - - // For TestNG versions [5.13, 6.3) where XmlClass.setIndex is not available, invoke XmlClass(String, boolean, int) - // constructor. Note that XmlClass(String, boolean, int) was replaced with XmlClass(String, int) when - // XmlClass.setIndex already existed. - private static final Constructor XML_CLASS_CONSTRUCTOR_WITH_INDEX = - tryGetConstructor(XmlClass.class, String.class, boolean.class, int.class); - - private TestNGExecutor() { - throw new IllegalStateException("not instantiable constructor"); - } - - @SuppressWarnings("checkstyle:parameternumbercheck") - static void run( - Iterable> testClasses, - String testSourceDirectory, - Map options, // string,string because TestNGMapConfigurator#configure() - TestNGReporter testNGReporter, - File reportsDirectory, - TestListResolver methodFilter, - List mainCliOptions, - int skipAfterFailureCount) - throws TestSetFailedException { - TestNG testng = new TestNG(true); - - Configurator configurator = getConfigurator(options.get("testng.configurator")); - - if (isCliDebugOrShowErrors(mainCliOptions)) { - System.out.println( - "Configuring TestNG with: " + configurator.getClass().getSimpleName()); - } - - XmlMethodSelector groupMatchingSelector = createGroupMatchingSelector(options); - XmlMethodSelector methodNameFilteringSelector = createMethodNameFilteringSelector(methodFilter); - - Map suitesNames = new HashMap<>(); - - List xmlSuites = new ArrayList<>(); - for (Class testClass : testClasses) { - TestMetadata metadata = findTestMetadata(testClass); - - SuiteAndNamedTests suiteAndNamedTests = suitesNames.get(metadata.suiteName); - if (suiteAndNamedTests == null) { - suiteAndNamedTests = new SuiteAndNamedTests(); - suiteAndNamedTests.xmlSuite.setName(metadata.suiteName); - configurator.configure(suiteAndNamedTests.xmlSuite, options); - xmlSuites.add(suiteAndNamedTests.xmlSuite); - - suitesNames.put(metadata.suiteName, suiteAndNamedTests); - } - - XmlTest xmlTest = suiteAndNamedTests.testNameToTest.get(metadata.testName); - if (xmlTest == null) { - xmlTest = new XmlTest(suiteAndNamedTests.xmlSuite); - xmlTest.setName(metadata.testName); - addSelector(xmlTest, groupMatchingSelector); - addSelector(xmlTest, methodNameFilteringSelector); - xmlTest.setXmlClasses(new ArrayList<>()); - - suiteAndNamedTests.testNameToTest.put(metadata.testName, xmlTest); - } - - xmlTest.getXmlClasses() - .add(newXmlClassInstance( - testClass.getName(), xmlTest.getXmlClasses().size())); - } - - testng.setXmlSuites(xmlSuites); - configurator.configure(testng, options); - postConfigure( - testng, - testSourceDirectory, - testNGReporter, - reportsDirectory, - skipAfterFailureCount, - extractVerboseLevel(options)); - testng.run(); - } - - private static XmlClass newXmlClassInstance(String testClassName, int index) { - // In case of parallel test execution with parallel="methods", TestNG orders test execution - // by XmlClass.m_index field. When unset (equal for all XmlClass instances), TestNG can - // invoke `@BeforeClass` setup methods on many instances, without invoking `@AfterClass` - // tearDown methods, thus leading to high resource consumptions when test instances - // allocate resources. - // With index set, order of setup, test and tearDown methods is reasonable, with approximately - // #thread-count many test classes being initialized at given point in time. - // Note: XmlClass.m_index field is set automatically by TestNG when it reads a suite file. - - if (XML_CLASS_SET_INDEX != null) { - XmlClass xmlClass = new XmlClass(testClassName); - invokeSetter(xmlClass, XML_CLASS_SET_INDEX, index); - return xmlClass; - } - if (XML_CLASS_CONSTRUCTOR_WITH_INDEX != null) { - boolean loadClass = true; // this is the default - return newInstance(XML_CLASS_CONSTRUCTOR_WITH_INDEX, testClassName, loadClass, index); - } - return new XmlClass(testClassName); - } - - private static boolean isCliDebugOrShowErrors(List mainCliOptions) { - return mainCliOptions.contains(LOGGING_LEVEL_DEBUG) || mainCliOptions.contains(SHOW_ERRORS); - } - - private static TestMetadata findTestMetadata(Class testClass) { - TestMetadata result = new TestMetadata(); - if (HAS_TEST_ANNOTATION_ON_CLASSPATH) { - Test testAnnotation = findAnnotation(testClass, Test.class); - if (null != testAnnotation) { - if (!StringUtils.isBlank(testAnnotation.suiteName())) { - result.suiteName = testAnnotation.suiteName(); - } - - if (!StringUtils.isBlank(testAnnotation.testName())) { - result.testName = testAnnotation.testName(); - } - } - } - return result; - } - - private static T findAnnotation(Class clazz, Class annotationType) { - if (clazz == null) { - return null; - } - - T result = clazz.getAnnotation(annotationType); - if (result != null) { - return result; - } - - return findAnnotation(clazz.getSuperclass(), annotationType); - } - - private static class TestMetadata { - private String testName = DEFAULT_SUREFIRE_TEST_NAME; - - private String suiteName = DEFAULT_SUREFIRE_SUITE_NAME; - } - - private static class SuiteAndNamedTests { - private final XmlSuite xmlSuite = new XmlSuite(); - - private final Map testNameToTest = new HashMap<>(); - } - - private static void addSelector(XmlTest xmlTest, XmlMethodSelector selector) { - if (selector != null) { - xmlTest.getMethodSelectors().add(selector); - } - } - - @SuppressWarnings("checkstyle:magicnumber") - private static XmlMethodSelector createMethodNameFilteringSelector(TestListResolver methodFilter) - throws TestSetFailedException { - if (methodFilter != null && !methodFilter.isEmpty()) { - // the class is available in the testClassPath - String clazzName = "org.apache.maven.surefire.testng.utils.MethodSelector"; - try { - Class clazz = Class.forName(clazzName); - Method method = clazz.getMethod("setTestListResolver", TestListResolver.class); - method.invoke(null, methodFilter); - } catch (Exception e) { - throw new TestSetFailedException(e.getMessage(), e); - } - - XmlMethodSelector xms = new XmlMethodSelector(); - - xms.setName(clazzName); - // looks to need a high value - xms.setPriority(10000); - - return xms; - } else { - return null; - } - } - - @SuppressWarnings("checkstyle:magicnumber") - private static XmlMethodSelector createGroupMatchingSelector(Map options) - throws TestSetFailedException { - final String groups = options.get(ProviderParameterNames.TESTNG_GROUPS_PROP); - final String excludedGroups = options.get(ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP); - - if (groups == null && excludedGroups == null) { - return null; - } - - // the class is available in the testClassPath - final String clazzName = "org.apache.maven.surefire.testng.utils.GroupMatcherMethodSelector"; - try { - Class clazz = Class.forName(clazzName); - - // HORRIBLE hack, but TNG doesn't allow us to setup a method selector instance directly. - Method method = clazz.getMethod("setGroups", String.class, String.class); - method.invoke(null, groups, excludedGroups); - } catch (Exception e) { - throw new TestSetFailedException(e.getMessage(), e); - } - - XmlMethodSelector xms = new XmlMethodSelector(); - - xms.setName(clazzName); - // looks to need a high value - xms.setPriority(9999); - - return xms; - } - - static void run( - List suiteFiles, - String testSourceDirectory, - Map options, // string,string because TestNGMapConfigurator#configure() - TestNGReporter testNGReporter, - File reportsDirectory, - int skipAfterFailureCount) - throws TestSetFailedException { - TestNG testng = new TestNG(true); - Configurator configurator = getConfigurator(options.get("testng.configurator")); - configurator.configure(testng, options); - postConfigure( - testng, - testSourceDirectory, - testNGReporter, - reportsDirectory, - skipAfterFailureCount, - extractVerboseLevel(options)); - testng.setTestSuites(suiteFiles); - testng.run(); - } - - private static Configurator getConfigurator(String className) { - try { - return (Configurator) Class.forName(className).newInstance(); - } catch (ReflectiveOperationException e) { - throw new RuntimeException(e); - } - } - - private static void postConfigure( - TestNG testNG, - String sourcePath, - TestNGReporter testNGReporter, - File reportsDirectory, - int skipAfterFailureCount, - int verboseLevel) { - // 0 (default): turn off all TestNG output - testNG.setVerbose(verboseLevel); - testNG.addListener((ITestNGListener) testNGReporter); - - if (skipAfterFailureCount > 0) { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - testNG.addListener(instantiate(classLoader, FailFastNotifier.class.getName(), Object.class)); - testNG.addListener( - new FailFastListener(createStoppable(testNGReporter.getRunListener(), skipAfterFailureCount))); - } - - // FIXME: use classifier to decide if we need to pass along the source dir (only for JDK14) - if (sourcePath != null) { - testNG.setSourcePath(sourcePath); - } - - testNG.setOutputDirectory(reportsDirectory.getAbsolutePath()); - } - - private static Stoppable createStoppable(final RunListener reportManager, int skipAfterFailureCount) { - final AtomicInteger currentFaultCount = new AtomicInteger(skipAfterFailureCount); - - return () -> { - runIfZeroCountDown(() -> FailFastEventsSingleton.getInstance().setSkipOnNextTest(), currentFaultCount); - reportManager.testExecutionSkippedByUser(); - }; - } - - private static int extractVerboseLevel(Map options) throws TestSetFailedException { - try { - String verbose = options.get("surefire.testng.verbose"); - return verbose == null ? 0 : Integer.parseInt(verbose); - } catch (NumberFormatException e) { - throw new TestSetFailedException( - "Provider property 'surefire.testng.verbose' should refer to " - + "number -1 (debug mode), 0, 1 .. 10 (most detailed).", - e); - } - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java deleted file mode 100644 index 507992b901..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * 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.surefire.testng; - -import java.io.File; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.apache.maven.surefire.api.booter.Command; -import org.apache.maven.surefire.api.cli.CommandLineOption; -import org.apache.maven.surefire.api.provider.AbstractProvider; -import org.apache.maven.surefire.api.provider.CommandChainReader; -import org.apache.maven.surefire.api.provider.CommandListener; -import org.apache.maven.surefire.api.provider.ProviderParameters; -import org.apache.maven.surefire.api.report.ReporterConfiguration; -import org.apache.maven.surefire.api.report.ReporterFactory; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.apache.maven.surefire.api.suite.RunResult; -import org.apache.maven.surefire.api.testset.TestListResolver; -import org.apache.maven.surefire.api.testset.TestRequest; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.apache.maven.surefire.api.util.RunOrderCalculator; -import org.apache.maven.surefire.api.util.ScanResult; -import org.apache.maven.surefire.api.util.TestsToRun; -import org.apache.maven.surefire.testng.utils.FailFastEventsSingleton; - -import static org.apache.maven.surefire.api.report.ConsoleOutputCapture.startCapture; -import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; -import static org.apache.maven.surefire.api.testset.TestListResolver.getEmptyTestListResolver; -import static org.apache.maven.surefire.api.testset.TestListResolver.optionallyWildcardFilter; -import static org.apache.maven.surefire.api.util.TestsToRun.fromClass; - -/** - * @author Kristian Rosenvold - */ -public class TestNGProvider extends AbstractProvider { - private final Map providerProperties; - - private final ReporterConfiguration reporterConfiguration; - - private final ClassLoader testClassLoader; - - private final ScanResult scanResult; - - private final TestRequest testRequest; - - private final ProviderParameters providerParameters; - - private final RunOrderCalculator runOrderCalculator; - - private final List mainCliOptions; - - private final CommandChainReader commandsReader; - - public TestNGProvider(ProviderParameters bootParams) { - // don't start a thread in CommandReader while we are in in-plugin process - commandsReader = bootParams.isInsideFork() ? bootParams.getCommandReader() : null; - providerParameters = bootParams; - testClassLoader = bootParams.getTestClassLoader(); - runOrderCalculator = bootParams.getRunOrderCalculator(); - providerProperties = bootParams.getProviderProperties(); - testRequest = bootParams.getTestRequest(); - reporterConfiguration = bootParams.getReporterConfiguration(); - scanResult = bootParams.getScanResult(); - mainCliOptions = bootParams.getMainCliOptions(); - } - - @Override - public RunResult invoke(Object forkTestSet) throws TestSetFailedException { - if (isFailFast() && commandsReader != null) { - registerPleaseStopListener(); - } - - ReporterFactory reporterFactory = providerParameters.getReporterFactory(); - TestReportListener reporter = reporterFactory.createTestReportListener(); - - RunResult runResult; - try { - if (isTestNGXmlTestSuite(testRequest)) { - TestNGReporter testNGReporter = createTestNGReporter(reporter); - testNGReporter.setRunMode(NORMAL_RUN); - /* - * {@link org.apache.maven.surefire.api.report.ConsoleOutputCapture#startCapture(ConsoleOutputReceiver)} - * called in prior to initializing variable {@link #testsToRun} - */ - startCapture(testNGReporter); - - if (commandsReader != null) { - commandsReader.awaitStarted(); - } - TestNGXmlTestSuite testNGXmlTestSuite = newXmlSuite(); - testNGXmlTestSuite.locateTestSets(); - testNGXmlTestSuite.execute(testNGReporter); - } else { - TestNGReporter testNGReporter = createTestNGReporter(reporter); - testNGReporter.setRunMode(NORMAL_RUN); - /* - * {@link org.apache.maven.surefire.api.report.ConsoleOutputCapture#startCapture(ConsoleOutputReceiver)} - * called in prior to initializing variable {@link #testsToRun} - */ - startCapture(testNGReporter); - - final TestsToRun testsToRun; - if (forkTestSet instanceof TestsToRun) { - testsToRun = (TestsToRun) forkTestSet; - } else if (forkTestSet instanceof Class) { - testsToRun = fromClass((Class) forkTestSet); - } else { - testsToRun = scanClassPath(); - } - - if (commandsReader != null) { - registerShutdownListener(testsToRun); - commandsReader.awaitStarted(); - } - TestNGDirectoryTestSuite suite = newDirectorySuite(); - suite.execute(testsToRun, testNGReporter); - } - } finally { - runResult = reporterFactory.close(); - } - return runResult; - } - - boolean isTestNGXmlTestSuite(TestRequest testSuiteDefinition) { - Collection suiteXmlFiles = testSuiteDefinition.getSuiteXmlFiles(); - return !suiteXmlFiles.isEmpty() && !hasSpecificTests(); - } - - private boolean isFailFast() { - return providerParameters.getSkipAfterFailureCount() > 0; - } - - private int getSkipAfterFailureCount() { - return isFailFast() ? providerParameters.getSkipAfterFailureCount() : 0; - } - - private void registerShutdownListener(final TestsToRun testsToRun) { - commandsReader.addShutdownListener(new CommandListener() { - @Override - public void update(Command command) { - testsToRun.markTestSetFinished(); - } - }); - } - - private void registerPleaseStopListener() { - commandsReader.addSkipNextTestsListener(new CommandListener() { - @Override - public void update(Command command) { - FailFastEventsSingleton.getInstance().setSkipOnNextTest(); - } - }); - } - - private TestNGDirectoryTestSuite newDirectorySuite() { - return new TestNGDirectoryTestSuite( - testRequest.getTestSourceDirectory().toString(), - providerProperties, - reporterConfiguration.getReportsDirectory(), - getTestFilter(), - mainCliOptions, - getSkipAfterFailureCount()); - } - - private TestNGXmlTestSuite newXmlSuite() { - return new TestNGXmlTestSuite( - testRequest.getSuiteXmlFiles(), - testRequest.getTestSourceDirectory().toString(), - providerProperties, - reporterConfiguration.getReportsDirectory(), - getSkipAfterFailureCount()); - } - - @Override - @SuppressWarnings("unchecked") - public Iterable> getSuites() { - if (isTestNGXmlTestSuite(testRequest)) { - try { - return newXmlSuite().locateTestSets(); - } catch (TestSetFailedException e) { - throw new RuntimeException(e); - } - } else { - return scanClassPath(); - } - } - - private TestsToRun scanClassPath() { - final TestsToRun scanned = scanResult.applyFilter(null, testClassLoader); - return runOrderCalculator.orderTestClasses(scanned); - } - - private boolean hasSpecificTests() { - TestListResolver specificTestPatterns = testRequest.getTestListResolver(); - return !specificTestPatterns.isEmpty() && !specificTestPatterns.isWildcard(); - } - - private TestListResolver getTestFilter() { - TestListResolver filter = optionallyWildcardFilter(testRequest.getTestListResolver()); - return filter.isWildcard() ? getEmptyTestListResolver() : filter; - } - - // If we have access to IResultListener, return a ConfigurationAwareTestNGReporter. - // But don't cause NoClassDefFoundErrors if it isn't available; just return a regular TestNGReporter instead. - private static TestNGReporter createTestNGReporter(TestReportListener reportManager) { - try { - Class.forName("org.testng.internal.IResultListener"); - Class c = Class.forName("org.apache.maven.surefire.testng.ConfigurationAwareTestNGReporter"); - Constructor ctor = c.getConstructor(TestReportListener.class); - return (TestNGReporter) ctor.newInstance(reportManager); - } catch (InvocationTargetException e) { - throw new RuntimeException("Bug in ConfigurationAwareTestNGReporter", e.getCause()); - } catch (ClassNotFoundException e) { - return new TestNGReporter(reportManager); - } catch (Exception e) { - throw new RuntimeException("Bug in ConfigurationAwareTestNGReporter", e); - } - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java deleted file mode 100644 index ec887b792f..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * 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.surefire.testng; - -import java.util.Arrays; - -import org.apache.maven.surefire.api.report.CategorizedReportEntry; -import org.apache.maven.surefire.api.report.OutputReportEntry; -import org.apache.maven.surefire.api.report.ReportEntry; -import org.apache.maven.surefire.api.report.RunListener; -import org.apache.maven.surefire.api.report.RunMode; -import org.apache.maven.surefire.api.report.SimpleReportEntry; -import org.apache.maven.surefire.api.report.StackTraceWriter; -import org.apache.maven.surefire.api.report.TestOutputReceiver; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.apache.maven.surefire.report.ClassMethodIndexer; -import org.apache.maven.surefire.report.PojoStackTraceWriter; -import org.apache.maven.surefire.report.RunModeSetter; -import org.testng.IClass; -import org.testng.ISuite; -import org.testng.ISuiteListener; -import org.testng.ITestContext; -import org.testng.ITestListener; -import org.testng.ITestResult; - -import static org.apache.maven.surefire.api.report.SimpleReportEntry.ignored; -import static org.apache.maven.surefire.api.report.SimpleReportEntry.withException; - -/** - * Listens for and provides and adaptor layer so that - * TestNG tests can report their status to the current - * {@link RunListener}. - * - * @author jkuhnert - */ -public class TestNGReporter - implements TestOutputReceiver, ITestListener, ISuiteListener, RunModeSetter { - private final ClassMethodIndexer classMethodIndexer = new ClassMethodIndexer(); - private final TestReportListener reporter; - private volatile RunMode runMode; - - /** - * Constructs a new instance that will listen to - * test updates from a {@link org.testng.TestNG} class instance. - *
- *
It is assumed that the requisite {@link org.testng.TestNG#addListener(ITestListener)} - * method call has already associated with this instance before the test - * suite is run. - * - * @param reportManager Instance to report suite status to - */ - public TestNGReporter(TestReportListener reportManager) { - this.reporter = reportManager; - } - - protected final RunListener getRunListener() { - return reporter; - } - - @Override - public void onTestStart(ITestResult result) { - String className = result.getTestClass().getName(); - String methodName = testName(result); - long testRunId = classMethodIndexer.indexClassMethod(className, methodName); - String group = groupString(result.getMethod().getGroups(), className); - reporter.testStarting(new CategorizedReportEntry(runMode, testRunId, className, methodName, group)); - } - - @Override - public void onTestSuccess(ITestResult result) { - String className = result.getTestClass().getName(); - String methodName = testName(result); - long testRunId = classMethodIndexer.indexClassMethod(className, methodName); - ReportEntry report = new SimpleReportEntry(runMode, testRunId, className, null, methodName, null); - reporter.testSucceeded(report); - } - - @Override - public void onTestFailure(ITestResult result) { - IClass clazz = result.getTestClass(); - String className = clazz.getName(); - String methodName = testName(result); - long testRunId = classMethodIndexer.indexClassMethod(className, methodName); - StackTraceWriter stackTraceWriter = new PojoStackTraceWriter( - clazz.getRealClass().getName(), result.getMethod().getMethodName(), result.getThrowable()); - ReportEntry report = - withException(runMode, testRunId, clazz.getName(), null, methodName, null, stackTraceWriter); - - reporter.testFailed(report); - } - - @Override - public void onTestSkipped(ITestResult result) { - String className = result.getTestClass().getName(); - String methodName = testName(result); - long testRunId = classMethodIndexer.indexClassMethod(className, methodName); - //noinspection ThrowableResultOfMethodCallIgnored - Throwable t = result.getThrowable(); - String reason = t == null ? null : t.getMessage(); - ReportEntry report = ignored(runMode, testRunId, className, null, methodName, null, reason); - reporter.testSkipped(report); - } - - @Override - public void onTestFailedButWithinSuccessPercentage(ITestResult result) { - IClass clazz = result.getTestClass(); - String className = clazz.getName(); - String methodName = testName(result); - long testRunId = classMethodIndexer.indexClassMethod(className, methodName); - StackTraceWriter stackTraceWriter = new PojoStackTraceWriter( - clazz.getRealClass().getName(), result.getMethod().getMethodName(), result.getThrowable()); - ReportEntry report = withException(runMode, testRunId, className, null, methodName, null, stackTraceWriter); - reporter.testSucceeded(report); - } - - @Override - public void onStart(ITestContext context) {} - - @Override - public void onFinish(ITestContext context) {} - - @Override - public void onStart(ISuite suite) {} - - @Override - public void onFinish(ISuite suite) {} - - /** - * Creates a string out of the list of testng groups in the - * form of
"group1,group2,group3"
. - * - * @param groups The groups being run - * @param defaultValue The default to use if no groups - * @return a string describing the groups - */ - private static String groupString(String[] groups, String defaultValue) { - String retVal; - if (groups != null && groups.length > 0) { - StringBuilder str = new StringBuilder(); - for (int i = 0; i < groups.length; i++) { - str.append(groups[i]); - if (i + 1 < groups.length) { - str.append(","); - } - } - retVal = str.toString(); - } else { - retVal = defaultValue; - } - return retVal; - } - - public void onConfigurationFailure(ITestResult result) { - onTestFailure(result); - } - - public void onConfigurationSkip(ITestResult result) { - onTestSkipped(result); - } - - public void onConfigurationSuccess(ITestResult result) { - // DGF Don't record configuration successes as separate tests - // onTestSuccess( result ); - } - - /** - * Acquire a better representation of the test name that includes parameters and the invocation count, if there are - * any parameters - * - * @param result the test result to extract from - * @return a descriptive name for the test - */ - private static String testName(ITestResult result) { - Object[] parameters = result.getParameters(); - String name = result.getName(); - return parameters == null || parameters.length == 0 - ? name - : name + Arrays.toString(parameters) + "(" + result.getMethod().getCurrentInvocationCount() + ")"; - } - - @Override - public void setRunMode(RunMode runMode) { - this.runMode = runMode; - } - - @Override - public void writeTestOutput(OutputReportEntry reportEntry) { - Long testRunId = classMethodIndexer.getLocalIndex(); - reporter.writeTestOutput(new TestOutputReportEntry(reportEntry, runMode, testRunId)); - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java deleted file mode 100644 index f2c7c4acc4..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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.surefire.testng; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; - -import static org.apache.maven.surefire.testng.TestNGExecutor.run; - -/** - * Handles suite xml file definitions for TestNG. - * - * @author jkuhnert - * @author Alex Popescu - */ -final class TestNGXmlTestSuite extends TestSuite { - private final List suiteFiles; - - private List suiteFilePaths; - - private final String testSourceDirectory; - - private final Map options; - - private final File reportsDirectory; - - private final int skipAfterFailureCount; - - /** - * Creates a testng testset to be configured by the specified - * xml file(s). The XML files are suite definitions files according to TestNG DTD. - */ - TestNGXmlTestSuite( - List suiteFiles, - String testSourceDirectory, - Map confOptions, - File reportsDirectory, - int skipAfterFailureCount) { - this.suiteFiles = suiteFiles; - this.options = confOptions; - this.testSourceDirectory = testSourceDirectory; - this.reportsDirectory = reportsDirectory; - this.skipAfterFailureCount = skipAfterFailureCount; - } - - void execute(TestNGReporter testNGReporter) throws TestSetFailedException { - if (suiteFilePaths == null) { - throw new IllegalStateException("You must call locateTestSets before calling execute"); - } - startTestSuite(testNGReporter.getRunListener()); - run(suiteFilePaths, testSourceDirectory, options, testNGReporter, reportsDirectory, skipAfterFailureCount); - finishTestSuite(testNGReporter.getRunListener()); - } - - Iterable locateTestSets() throws TestSetFailedException { - if (suiteFilePaths != null) { - throw new IllegalStateException("You can't call locateTestSets twice"); - } - - if (suiteFiles.isEmpty()) { - throw new IllegalStateException("No suite files were specified"); - } - - suiteFilePaths = new ArrayList<>(suiteFiles.size()); - ArrayList testSets = new ArrayList<>(suiteFiles.size()); - - for (File suiteFile : suiteFiles) { - if (!suiteFile.isFile()) { - throw new TestSetFailedException("Suite file " + suiteFile + " is not a valid file"); - } - testSets.add(suiteFile); - suiteFilePaths.add(suiteFile.getAbsolutePath()); - } - return testSets; - } - - @Override - Map getOptions() { - return options; - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestSuite.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestSuite.java deleted file mode 100644 index 482427ac01..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestSuite.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.surefire.testng; - -import java.util.Map; - -import org.apache.maven.surefire.api.report.ReporterException; -import org.apache.maven.surefire.api.report.RunListener; -import org.apache.maven.surefire.api.report.SimpleReportEntry; - -import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; -import static org.apache.maven.surefire.api.util.internal.ObjectUtils.systemProps; - -/** - * Abstract class which implements common functions. - */ -abstract class TestSuite { - abstract Map getOptions(); - - private String getSuiteName() { - String result = getOptions().get("suitename"); - return result == null ? "TestSuite" : result; - } - - final void startTestSuite(RunListener reporterManager) { - try { - reporterManager.testSetStarting(new SimpleReportEntry(NORMAL_RUN, 0L, getSuiteName(), null, null, null)); - } catch (ReporterException e) { - // TODO: remove this exception from the report manager - } - } - - final void finishTestSuite(RunListener reporterManager) { - reporterManager.testSetCompleted( - new SimpleReportEntry(NORMAL_RUN, 0L, getSuiteName(), null, null, null, systemProps())); - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java deleted file mode 100644 index b73b9bacdf..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.maven.surefire.api.booter.ProviderParameterNames; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.testng.TestNG; -import org.testng.xml.XmlSuite; - -/** - * Configurator that relies on reflection to set parameters in TestNG - * - */ -public abstract class AbstractDirectConfigurator implements Configurator { - final Map setters; - - AbstractDirectConfigurator() { - Map options = new HashMap<>(); - // options.put( ProviderParameterNames.TESTNG_GROUPS_PROP, new Setter( "setGroups", String.class ) ); - // options.put( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP, new Setter( "setExcludedGroups", String.class - // ) ); - options.put("junit", new Setter("setJUnit", Boolean.class)); - options.put(ProviderParameterNames.THREADCOUNT_PROP, new Setter("setThreadCount", int.class)); - options.put("usedefaultlisteners", new Setter("setUseDefaultListeners", boolean.class)); - this.setters = options; - } - - @Override - public void configure(TestNG testng, Map options) throws TestSetFailedException { - System.out.println("\n\n\n\nCONFIGURING TESTNG\n\n\n\n"); - // kind of ugly, but listeners are configured differently - final String listeners = options.remove("listener"); - // DGF In 4.7, default listeners dump XML files in the surefire-reports directory, - // confusing the report plugin. This was fixed in later versions. - testng.setUseDefaultListeners(false); - configureInstance(testng, options); - // TODO: we should have the Profile so that we can decide if this is needed or not - testng.setListenerClasses(loadListenerClasses(listeners)); - } - - @Override - public void configure(XmlSuite suite, Map options) throws TestSetFailedException { - Map filtered = filterForSuite(options); - configureInstance(suite, filtered); - } - - protected Map filterForSuite(Map options) { - Map result = new HashMap<>(); - addPropIfNotNull(options, result, ProviderParameterNames.PARALLEL_PROP); - addPropIfNotNull(options, result, ProviderParameterNames.THREADCOUNT_PROP); - return result; - } - - private void addPropIfNotNull(Map options, Map result, String prop) { - if (options.containsKey(prop)) { - result.put(prop, options.get(prop)); - } - } - - private void configureInstance(Object testngInstance, Map options) { - for (Map.Entry entry : options.entrySet()) { - String key = entry.getKey(); - String val = entry.getValue(); - Setter setter = setters.get(key); - if (setter != null) { - try { - setter.invoke(testngInstance, val); - } catch (Exception e) { - throw new RuntimeException("Cannot set option " + key + " with value " + val, e); - } - } - } - } - - static List loadListenerClasses(String listenerClasses) throws TestSetFailedException { - if (listenerClasses == null || listenerClasses.trim().isEmpty()) { - return new ArrayList<>(); - } - - List classes = new ArrayList<>(); - String[] classNames = listenerClasses.split("\\s*,\\s*(\\r?\\n)?\\s*"); - for (String className : classNames) { - Class clazz = loadClass(className); - classes.add(clazz); - } - - return classes; - } - - static Class loadClass(String className) throws TestSetFailedException { - try { - return Class.forName(className); - } catch (Exception ex) { - throw new TestSetFailedException("Cannot find listener class " + className, ex); - } - } - - /** - * Describes a property setter by method name and parameter class - * - */ - public static final class Setter { - private final String setterName; - - private final Class paramClass; - - public Setter(String name, Class clazz) { - setterName = name; - paramClass = clazz; - } - - public void invoke(Object target, String value) throws Exception { - Method setter = target.getClass().getMethod(setterName, paramClass); - if (setter != null) { - setter.invoke(target, convertValue(value)); - } - } - - private Object convertValue(String value) { - if (value == null) { - return null; - } - if (paramClass.isAssignableFrom(value.getClass())) { - return value; - } - - if (Boolean.class.equals(paramClass) || boolean.class.equals(paramClass)) { - return Boolean.valueOf(value); - } - if (Integer.class.equals(paramClass) || int.class.equals(paramClass)) { - return Integer.valueOf(value); - } - - return value; - } - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/Configurator.java deleted file mode 100644 index c24bf1b2d5..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/Configurator.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.util.Map; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.testng.TestNG; -import org.testng.xml.XmlSuite; - -/** - * Configurator for passing configuration properties to TestNG - * - */ -public interface Configurator { - void configure(TestNG testng, Map options) throws TestSetFailedException; - - void configure(XmlSuite suite, Map options) throws TestSetFailedException; -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG4751Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG4751Configurator.java deleted file mode 100644 index f596b09883..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG4751Configurator.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import org.apache.maven.surefire.api.booter.ProviderParameterNames; - -/** - * TestNG 4.7 and 5.1 configurator. - *
- * Allowed options: - * -groups - * -excludedgroups - * -junit (boolean) - * -threadcount (int) - * -parallel (boolean) - *
- * - * @author Alex Popescu - */ -public class TestNG4751Configurator extends AbstractDirectConfigurator { - public TestNG4751Configurator() { - setters.put(ProviderParameterNames.PARALLEL_PROP, new Setter("setParallel", boolean.class)); - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG510Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG510Configurator.java deleted file mode 100644 index 321a850086..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG510Configurator.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.util.Map; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.testng.xml.XmlSuite; - -/** - * TestNG 5.10 configurator. Added support of dataproviderthreadcount. - * - * @since 2.19 - */ -public class TestNG510Configurator extends TestNGMapConfigurator { - - @Override - public void configure(XmlSuite suite, Map options) throws TestSetFailedException { - super.configure(suite, options); - - String dataProviderThreadCount = options.get("dataproviderthreadcount"); - if (dataProviderThreadCount != null) { - suite.setDataProviderThreadCount(Integer.parseInt(dataProviderThreadCount)); - } - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java deleted file mode 100644 index b49b0cc098..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; - -/** - * TestNG 5.13 configurator. Changed: "reporterslist" need String instead of List<ReporterConfig>. - */ -public class TestNG513Configurator extends TestNG510Configurator { - - @Override - protected Object convertReporterConfig(Object val) { - return val; - } - - @Override - protected Object convertListeners(String listenerClasses) throws TestSetFailedException { - return convertListenersString(listenerClasses); - } - - static String convertListenersString(String listenerClasses) { - if (listenerClasses == null || listenerClasses.trim().isEmpty()) { - return listenerClasses; - } - - StringBuilder sb = new StringBuilder(); - String[] classNames = listenerClasses.split("\\s*,\\s*(\\r?\\n)?\\s*"); - for (int i = 0; i < classNames.length; i++) { - String className = classNames[i]; - sb.append(className); - if (i < classNames.length - 1) { - sb.append(','); - } - } - - return sb.toString(); - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5141Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5141Configurator.java deleted file mode 100644 index cf6ba9a6c0..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5141Configurator.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; - -/** - * TestNG 5.14.1 configurator. Changed: "listener" use List instead of String. - */ -public class TestNG5141Configurator extends TestNG513Configurator { - - @Override - protected Object convertListeners(String listenerClasses) throws TestSetFailedException { - // TODO "configure(CommandLineArgs)", which should replace "configure(Map)", doesn't have the issue - throw new TestSetFailedException("Due to an internal TestNG issue, " - + "the listener feature of TestNG is not supported with 5.14.1 and 5.14.2"); - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java deleted file mode 100644 index ea9ba78083..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.util.Map; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; - -/** - * TestNG 5.14.3 configurator. Changed: "reporterslist" replaced by "reporter", - * and "listener" can use String instead of List<Class>. - */ -public class TestNG5143Configurator extends TestNG5141Configurator { - - @Override - Map getConvertedOptions(Map options) throws TestSetFailedException { - Map convertedOptions = super.getConvertedOptions(options); - for (Map.Entry entry : convertedOptions.entrySet()) { - String key = entry.getKey(); - if ("-reporterslist".equals(key)) { - convertedOptions.remove("-reporterslist"); - Object value = entry.getValue(); - convertedOptions.put("-reporter", value); - break; - } - } - return convertedOptions; - } - - @Override - protected Object convertListeners(String listenerClasses) throws TestSetFailedException { - return convertListenersString(listenerClasses); - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG52Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG52Configurator.java deleted file mode 100644 index a83ff0fd6e..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG52Configurator.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import org.apache.maven.surefire.api.booter.ProviderParameterNames; - -/** - * TestNG 5.2 configurator. - *
- * Allowed options: - * -groups - * -excludedgroups - * -junit (boolean) - * -threadcount (int) - * -parallel (String) - *
- * - * @author Alex Popescu - */ -public class TestNG52Configurator extends AbstractDirectConfigurator { - public TestNG52Configurator() { - setters.put(ProviderParameterNames.PARALLEL_PROP, new Setter("setParallel", String.class)); - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java deleted file mode 100644 index c0d144bec2..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; - -/** - * TestNG 6.0 configurator. Changed objectFactory type to String. - * Configuring -objectfactory and -testrunfactory. - * - * @author Marvin Froeder - * @since 2.13 - */ -public class TestNG60Configurator extends TestNG5143Configurator { - - @Override - Map getConvertedOptions(Map options) throws TestSetFailedException { - Map convertedOptions = super.getConvertedOptions(options); - for (Entry entry : convertedOptions.entrySet()) { - String key = entry.getKey(); - if ("-objectfactory".equals(key) || "-testrunfactory".equals(key)) { - Class value = (Class) entry.getValue(); - convertedOptions.put(key, value.getName()); - break; - } - } - return convertedOptions; - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG740Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG740Configurator.java deleted file mode 100644 index 3f1b0773f8..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG740Configurator.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.util.Map; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.testng.xml.XmlSuite; - -import static org.apache.maven.surefire.api.booter.ProviderParameterNames.PARALLEL_PROP; -import static org.apache.maven.surefire.api.util.ReflectionUtils.invokeSetter; -import static org.apache.maven.surefire.api.util.ReflectionUtils.loadClass; - -/** - * TestNG 7.4.0 configurator. Changed setParallel type to enum value. - * Uses reflection since ParallelMode enum doesn't exist in supported - * TestNG 5.x versions. - * - * @since 3.0.0-M6 - */ -public class TestNG740Configurator extends TestNG60Configurator { - /** - * Convert and apply the value of the [parallel] setting. - *

- * NOTE: Since TestNG 7.4, the value of the {@code parallel} setting of the {@link XmlSuite} class has been - * specified via a ParallelMode enumeration. This method converts the [parallel] setting specified in the - * Surefire plugin configuration to its corresponding constant and applies this to the specified suite object. - * - * @param suite TestNG {@link XmlSuite} object - * @param options Surefire plugin configuration options - * @throws TestSetFailedException if unable to convert specified [parallel] setting - */ - @Override - protected void configureParallel(XmlSuite suite, Map options) throws TestSetFailedException { - String parallel = options.get(PARALLEL_PROP); - if (parallel != null) { - Class enumClass = loadClass(XmlSuite.class.getClassLoader(), "org.testng.xml.XmlSuite$ParallelMode"); - try { - Enum parallelEnum = Enum.valueOf(enumClass, parallel.toUpperCase()); - invokeSetter(suite, "setParallel", enumClass, parallelEnum); - } catch (IllegalArgumentException e) { - throw new TestSetFailedException("Unsupported TestNG [parallel] setting: " + parallel, e); - } - } - } -} diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java deleted file mode 100755 index d91e76afc5..0000000000 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.testng.TestNG; -import org.testng.xml.XmlSuite; - -import static org.apache.maven.surefire.api.booter.ProviderParameterNames.PARALLEL_PROP; -import static org.apache.maven.surefire.api.booter.ProviderParameterNames.THREADCOUNT_PROP; -import static org.apache.maven.surefire.testng.conf.AbstractDirectConfigurator.loadListenerClasses; - -/** - * TestNG configurator for 5.3+ versions. TestNG exposes a {@link org.testng.TestNG#configure(java.util.Map)} method. - * All supported TestNG options are passed in String format, except - * {@link org.testng.TestNGCommandLineArgs#LISTENER_COMMAND_OPT} which is {@link java.util.List List>Class<}, - * {@link org.testng.TestNGCommandLineArgs#JUNIT_DEF_OPT} which is a {@link Boolean}, - * {@link org.testng.TestNGCommandLineArgs#SKIP_FAILED_INVOCATION_COUNT_OPT} which is a {@link Boolean}, - * {@link org.testng.TestNGCommandLineArgs#OBJECT_FACTORY_COMMAND_OPT} which is a {@link Class}, - * {@link org.testng.TestNGCommandLineArgs#REPORTERS_LIST} which is a {@link java.util.List List>ReporterConfig<}. - *
- * Test classes and/or suite files are not passed along as options parameters, but configured separately. - * - * @author Alex Popescu - */ -public class TestNGMapConfigurator implements Configurator { - @Override - public void configure(TestNG testng, Map options) throws TestSetFailedException { - Map convertedOptions = getConvertedOptions(options); - testng.configure(convertedOptions); - } - - @Override - public void configure(XmlSuite suite, Map options) throws TestSetFailedException { - configureThreadCount(suite, options); - configureParallel(suite, options); - } - - protected void configureThreadCount(XmlSuite suite, Map options) throws TestSetFailedException { - String threadCount = options.get(THREADCOUNT_PROP); - if (threadCount != null) { - try { - suite.setThreadCount(Integer.parseInt(threadCount)); - } catch (NumberFormatException e) { - throw new TestSetFailedException("Non-integer TestNG [threadcount] setting: " + threadCount, e); - } - } - } - - protected void configureParallel(XmlSuite suite, Map options) throws TestSetFailedException { - String parallel = options.get(PARALLEL_PROP); - if (parallel != null) { - suite.setParallel(parallel); - } - } - - Map getConvertedOptions(Map options) throws TestSetFailedException { - Map convertedOptions = new HashMap<>(); - convertedOptions.put("-mixed", false); - for (Map.Entry entry : options.entrySet()) { - String key = entry.getKey(); - Object val = entry.getValue(); - switch (key) { - case "listener": - val = convertListeners(entry.getValue()); - break; - case "objectfactory": - case "testrunfactory": - val = AbstractDirectConfigurator.loadClass(entry.getValue()); - break; - case "reporter": - // for TestNG 5.6 or higher - // TODO support multiple reporters? - val = convertReporterConfig(val); - key = "reporterslist"; - break; - case "junit": - case "skipfailedinvocationcounts": - case "mixed": - case "group-by-instances": - val = convert(val, Boolean.class); - break; - case "configfailurepolicy": - case THREADCOUNT_PROP: - val = convert(val, String.class); - break; - // for TestNG 6.9.7 or higher - case "suitethreadpoolsize": - // for TestNG 5.10 or higher - case "dataproviderthreadcount": - val = convert(val, Integer.class); - break; - default: - break; - } - - if (key.startsWith("-")) { - convertedOptions.put(key, val); - } else { - convertedOptions.put("-" + key, val); - } - } - return convertedOptions; - } - - // ReporterConfig only became available in later versions of TestNG - protected Object convertReporterConfig(Object val) { - try { - Class reporterConfig = Class.forName("org.testng.ReporterConfig"); - Method deserialize = reporterConfig.getMethod("deserialize", String.class); - Object rc = deserialize.invoke(null, val); - ArrayList reportersList = new ArrayList<>(); - reportersList.add(rc); - return reportersList; - } catch (Exception e) { - return val; - } - } - - protected Object convertListeners(String listenerClasses) throws TestSetFailedException { - return loadListenerClasses(listenerClasses); - } - - protected Object convert(Object val, Class type) { - if (val == null) { - return null; - } else if (type.isAssignableFrom(val.getClass())) { - return val; - } else if ((type == Boolean.class || type == boolean.class) && val.getClass() == String.class) { - return Boolean.valueOf((String) val); - } else if ((type == Integer.class || type == int.class) && val.getClass() == String.class) { - return Integer.valueOf((String) val); - } else if (type == String.class) { - return val.toString(); - } else { - return val; - } - } -} diff --git a/surefire-providers/surefire-testng/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider b/surefire-providers/surefire-testng/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider deleted file mode 100644 index c13f61908e..0000000000 --- a/surefire-providers/surefire-testng/src/main/resources/META-INF/services/org.apache.maven.surefire.api.provider.SurefireProvider +++ /dev/null @@ -1 +0,0 @@ -org.apache.maven.surefire.testng.TestNGProvider diff --git a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/TestNGReporterTest.java b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/TestNGReporterTest.java deleted file mode 100644 index 514ecf9f85..0000000000 --- a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/TestNGReporterTest.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * 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.surefire.testng; - -import junit.framework.TestCase; -import org.apache.maven.surefire.api.report.CategorizedReportEntry; -import org.apache.maven.surefire.api.report.SimpleReportEntry; -import org.apache.maven.surefire.api.report.TestOutputReportEntry; -import org.apache.maven.surefire.api.report.TestReportListener; -import org.mockito.ArgumentCaptor; -import org.testng.ITestClass; -import org.testng.ITestNGMethod; -import org.testng.ITestResult; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; -import static org.powermock.reflect.Whitebox.invokeMethod; - -/** - * Tests for {@link TestNGReporter}. - */ -@SuppressWarnings("checkstyle:magicnumber") -public class TestNGReporterTest extends TestCase { - public void testParameterizedTestName() throws Exception { - ITestNGMethod method = mock(ITestNGMethod.class); - when(method.getCurrentInvocationCount()).thenReturn(3); - ITestResult testResult = mock(ITestResult.class); - when(testResult.getName()).thenReturn("myTest"); - when(testResult.getParameters()).thenReturn(new String[] {"val1", "val2"}); - when(testResult.getMethod()).thenReturn(method); - String testName = invokeMethod(TestNGReporter.class, "testName", testResult); - assertThat(testName).isEqualTo("myTest[val1, val2](3)"); - } - - public void testWithoutParameterizedTestName() throws Exception { - ITestNGMethod method = mock(ITestNGMethod.class); - ITestResult testResult = mock(ITestResult.class); - when(testResult.getName()).thenReturn("myTest"); - when(testResult.getMethod()).thenReturn(method); - String testName = invokeMethod(TestNGReporter.class, "testName", testResult); - assertThat(testName).isEqualTo("myTest"); - } - - public void testOnTestStart() { - ITestClass cls = mock(ITestClass.class); - when(cls.getName()).thenReturn("pkg.MyClass"); - - ITestNGMethod method = mock(ITestNGMethod.class); - when(method.getCurrentInvocationCount()).thenReturn(3); - when(method.getGroups()).thenReturn(new String[0]); - - ITestResult testResult = mock(ITestResult.class); - when(testResult.getTestClass()).thenReturn(cls); - when(testResult.getMethod()).thenReturn(method); - when(testResult.getName()).thenReturn("myTest"); - when(testResult.getParameters()).thenReturn(new String[] {"val1", "val2"}); - - TestReportListener listener = mock(TestReportListener.class); - TestNGReporter reporter = new TestNGReporter(listener); - reporter.onTestStart(testResult); - - ArgumentCaptor reportEntry = ArgumentCaptor.forClass(CategorizedReportEntry.class); - verify(listener).testStarting(reportEntry.capture()); - verifyNoMoreInteractions(listener); - - assertThat(reportEntry.getValue().getTestRunId()).isEqualTo(0x0000000100000001L); - - assertThat(reportEntry.getValue().getSourceName()).isEqualTo("pkg.MyClass"); - - assertThat(reportEntry.getValue().getName()).isEqualTo("myTest[val1, val2](3)"); - } - - public void testOnTestSuccess() { - ITestClass cls = mock(ITestClass.class); - when(cls.getName()).thenReturn("pkg.MyClass"); - - ITestNGMethod method = mock(ITestNGMethod.class); - when(method.getCurrentInvocationCount()).thenReturn(3); - - ITestResult testResult = mock(ITestResult.class); - when(testResult.getTestClass()).thenReturn(cls); - when(testResult.getMethod()).thenReturn(method); - when(testResult.getName()).thenReturn("myTest"); - when(testResult.getParameters()).thenReturn(new String[] {"val1", "val2"}); - - TestReportListener listener = mock(TestReportListener.class); - TestNGReporter reporter = new TestNGReporter(listener); - reporter.onTestSuccess(testResult); - - ArgumentCaptor reportEntry = ArgumentCaptor.forClass(SimpleReportEntry.class); - verify(listener).testSucceeded(reportEntry.capture()); - verifyNoMoreInteractions(listener); - - assertThat(reportEntry.getValue().getTestRunId()).isEqualTo(0x0000000100000001L); - - assertThat(reportEntry.getValue().getSourceName()).isEqualTo("pkg.MyClass"); - - assertThat(reportEntry.getValue().getName()).isEqualTo("myTest[val1, val2](3)"); - } - - public void testOnTestFailure() { - Exception stackTrace = new Exception(); - - ITestClass cls = mock(ITestClass.class); - when(cls.getName()).thenReturn(getClass().getName()); - - ITestNGMethod method = mock(ITestNGMethod.class); - when(method.getCurrentInvocationCount()).thenReturn(1); - when(method.getMethodName()).thenReturn("myTest"); - - ITestResult testResult = mock(ITestResult.class); - when(testResult.getThrowable()).thenReturn(stackTrace); - when(cls.getRealClass()).thenReturn(getClass()); - when(testResult.getTestClass()).thenReturn(cls); - when(testResult.getMethod()).thenReturn(method); - when(testResult.getName()).thenReturn("myTest"); - when(testResult.getParameters()).thenReturn(new String[] {"val1", "val2"}); - - TestReportListener listener = mock(TestReportListener.class); - TestNGReporter reporter = new TestNGReporter(listener); - reporter.onTestFailure(testResult); - - ArgumentCaptor reportEntry = ArgumentCaptor.forClass(SimpleReportEntry.class); - verify(listener).testFailed(reportEntry.capture()); - verifyNoMoreInteractions(listener); - - assertThat(reportEntry.getValue().getTestRunId()).isEqualTo(0x0000000100000001L); - - assertThat(reportEntry.getValue().getSourceName()).isEqualTo(getClass().getName()); - - assertThat(reportEntry.getValue().getName()).isEqualTo("myTest[val1, val2](1)"); - - assertThat(reportEntry.getValue().getStackTraceWriter()).isNotNull(); - - assertThat(reportEntry.getValue().getStackTraceWriter().getThrowable().getTarget()) - .isSameAs(stackTrace); - } - - public void testOnSkippedTest() { - Exception stackTrace = new Exception("test skip reason"); - - ITestClass cls = mock(ITestClass.class); - when(cls.getName()).thenReturn(getClass().getName()); - - ITestNGMethod method = mock(ITestNGMethod.class); - when(method.getCurrentInvocationCount()).thenReturn(1); - - ITestResult testResult = mock(ITestResult.class); - when(testResult.getThrowable()).thenReturn(stackTrace); - when(testResult.getTestClass()).thenReturn(cls); - when(testResult.getMethod()).thenReturn(method); - when(testResult.getName()).thenReturn("myTest"); - when(testResult.getParameters()).thenReturn(new String[] {"val1", "val2"}); - - TestReportListener listener = mock(TestReportListener.class); - TestNGReporter reporter = new TestNGReporter(listener); - reporter.onTestSkipped(testResult); - - ArgumentCaptor reportEntry = ArgumentCaptor.forClass(SimpleReportEntry.class); - verify(listener).testSkipped(reportEntry.capture()); - verifyNoMoreInteractions(listener); - - assertThat(reportEntry.getValue().getTestRunId()).isEqualTo(0x0000000100000001L); - - assertThat(reportEntry.getValue().getSourceName()).isEqualTo(getClass().getName()); - - assertThat(reportEntry.getValue().getName()).isEqualTo("myTest[val1, val2](1)"); - - assertThat(reportEntry.getValue().getMessage()).isEqualTo(stackTrace.getMessage()); - } - - public void testOnTestFailedButWithinSuccessPercentage() { - Exception stackTrace = new Exception(); - - ITestClass cls = mock(ITestClass.class); - when(cls.getName()).thenReturn(getClass().getName()); - - ITestNGMethod method = mock(ITestNGMethod.class); - when(method.getCurrentInvocationCount()).thenReturn(1); - when(method.getMethodName()).thenReturn("myTest"); - - ITestResult testResult = mock(ITestResult.class); - when(testResult.getThrowable()).thenReturn(stackTrace); - when(cls.getRealClass()).thenReturn(getClass()); - when(testResult.getTestClass()).thenReturn(cls); - when(testResult.getMethod()).thenReturn(method); - when(testResult.getName()).thenReturn("myTest"); - when(testResult.getParameters()).thenReturn(new String[] {"val1", "val2"}); - - TestReportListener listener = mock(TestReportListener.class); - TestNGReporter reporter = new TestNGReporter(listener); - reporter.onTestFailedButWithinSuccessPercentage(testResult); - - ArgumentCaptor reportEntry = ArgumentCaptor.forClass(SimpleReportEntry.class); - verify(listener).testSucceeded(reportEntry.capture()); - verifyNoMoreInteractions(listener); - - assertThat(reportEntry.getValue().getTestRunId()).isEqualTo(0x0000000100000001L); - - assertThat(reportEntry.getValue().getSourceName()).isEqualTo(getClass().getName()); - - assertThat(reportEntry.getValue().getName()).isEqualTo("myTest[val1, val2](1)"); - - assertThat(reportEntry.getValue().getStackTraceWriter()).isNotNull(); - - assertThat(reportEntry.getValue().getStackTraceWriter().getThrowable().getTarget()) - .isSameAs(stackTrace); - } -} diff --git a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG513ConfiguratorTest.java b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG513ConfiguratorTest.java deleted file mode 100644 index 06fc3773d1..0000000000 --- a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG513ConfiguratorTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.util.HashMap; -import java.util.Map; - -import junit.framework.TestCase; -import org.apache.maven.surefire.api.testset.TestSetFailedException; - -import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.FIRST_LISTENER; -import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.LISTENER_PROP; -import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.SECOND_LISTENER; - -/** - * - */ -public class TestNG513ConfiguratorTest extends TestCase { - - public void testListenersOnSeparateLines() throws Exception { - String listenersOnSeveralLines = String.format("%s , %n %s", FIRST_LISTENER, SECOND_LISTENER); - Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines); - String listeners = (String) convertedOptions.get(String.format("-%s", LISTENER_PROP)); - assertEquals(FIRST_LISTENER + "," + SECOND_LISTENER, listeners); - } - - public void testListenersOnTheSameLine() throws Exception { - String listenersOnSeveralLines = String.format("%s,%s", FIRST_LISTENER, SECOND_LISTENER); - Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines); - String listeners = (String) convertedOptions.get(String.format("-%s", LISTENER_PROP)); - assertEquals(FIRST_LISTENER + "," + SECOND_LISTENER, listeners); - } - - public void testReporter() throws Exception { - Map convertedOptions = getConvertedOptions("reporter", "classname"); - String reporter = (String) convertedOptions.get("-reporterslist"); - assertEquals("classname", reporter); - } - - private Map getConvertedOptions(String key, String value) throws TestSetFailedException { - TestNGMapConfigurator testNGMapConfigurator = new TestNG513Configurator(); - Map raw = new HashMap<>(); - raw.put(key, value); - return testNGMapConfigurator.getConvertedOptions(raw); - } -} diff --git a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5141ConfiguratorTest.java b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5141ConfiguratorTest.java deleted file mode 100644 index fe127af533..0000000000 --- a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5141ConfiguratorTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import junit.framework.TestCase; -import org.apache.maven.surefire.api.testset.TestSetFailedException; - -import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.FIRST_LISTENER; -import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.LISTENER_PROP; -import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.SECOND_LISTENER; - -/** - * - */ -public class TestNG5141ConfiguratorTest extends TestCase { - - public void testListenersOnSeparateLines() { - try { - String listenersOnSeveralLines = String.format("%s , %n %s", FIRST_LISTENER, SECOND_LISTENER); - Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines); - List listeners = (List) convertedOptions.get(String.format("-%s", LISTENER_PROP)); - assertEquals(2, listeners.size()); - fail(); - } catch (TestSetFailedException e) { - // TODO remove it when surefire will use "configure(CommandLineArgs)" - } - } - - public void testListenersOnTheSameLine() { - try { - String listenersOnSeveralLines = String.format("%s,%s", FIRST_LISTENER, SECOND_LISTENER); - Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines); - List listeners = (List) convertedOptions.get(String.format("-%s", LISTENER_PROP)); - assertEquals(2, listeners.size()); - fail(); - } catch (TestSetFailedException e) { - // TODO remove it when surefire will use "configure(CommandLineArgs)" - } - } - - private Map getConvertedOptions(String key, String value) throws TestSetFailedException { - TestNGMapConfigurator testNGMapConfigurator = new TestNG5141Configurator(); - Map raw = new HashMap<>(); - raw.put(key, value); - return testNGMapConfigurator.getConvertedOptions(raw); - } -} diff --git a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5143ConfiguratorTest.java b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5143ConfiguratorTest.java deleted file mode 100644 index 5f18cd22ff..0000000000 --- a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5143ConfiguratorTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.util.HashMap; -import java.util.Map; - -import junit.framework.TestCase; -import org.apache.maven.surefire.api.testset.TestSetFailedException; - -import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.FIRST_LISTENER; -import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.LISTENER_PROP; -import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.SECOND_LISTENER; - -/** - * - */ -public class TestNG5143ConfiguratorTest extends TestCase { - public void testListenersOnSeparateLines() throws Exception { - String listenersOnSeveralLines = String.format("%s , %n %s", FIRST_LISTENER, SECOND_LISTENER); - Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines); - String listeners = (String) convertedOptions.get(String.format("-%s", LISTENER_PROP)); - assertEquals(FIRST_LISTENER + "," + SECOND_LISTENER, listeners); - } - - public void testListenersOnTheSameLine() throws Exception { - String listenersOnSeveralLines = String.format("%s,%s", FIRST_LISTENER, SECOND_LISTENER); - Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines); - String listeners = (String) convertedOptions.get(String.format("-%s", LISTENER_PROP)); - assertEquals(FIRST_LISTENER + "," + SECOND_LISTENER, listeners); - } - - public void testReporter() throws Exception { - Map convertedOptions = getConvertedOptions("reporter", "classname"); - assertNull("classname", convertedOptions.get("-reporterslist")); - String reporter = (String) convertedOptions.get("-reporter"); - assertEquals("classname", reporter); - } - - private Map getConvertedOptions(String key, String value) throws TestSetFailedException { - TestNGMapConfigurator testNGMapConfigurator = new TestNG5143Configurator(); - Map raw = new HashMap<>(); - raw.put(key, value); - return testNGMapConfigurator.getConvertedOptions(raw); - } -} diff --git a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG60ConfiguratorTest.java b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG60ConfiguratorTest.java deleted file mode 100644 index 115491f09f..0000000000 --- a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG60ConfiguratorTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.util.HashMap; -import java.util.Map; - -import junit.framework.TestCase; - -/** - * @author Marvin Froeder - */ -public class TestNG60ConfiguratorTest extends TestCase { - - public void testGetConvertedOptions() throws Exception { - TestNGMapConfigurator testNGMapConfigurator = new TestNG60Configurator(); - Map raw = new HashMap(); - raw.put("objectfactory", "java.lang.String"); - Map convertedOptions = testNGMapConfigurator.getConvertedOptions(raw); - String objectfactory = (String) convertedOptions.get("-objectfactory"); - assertNotNull(objectfactory); - } -} diff --git a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNGMapConfiguratorTest.java b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNGMapConfiguratorTest.java deleted file mode 100755 index 097a74d1ea..0000000000 --- a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNGMapConfiguratorTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.surefire.testng.conf; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import junit.framework.TestCase; -import org.apache.maven.surefire.api.testset.TestSetFailedException; -import org.testng.ReporterConfig; - -/** - * @author Kristian Rosenvold - */ -public class TestNGMapConfiguratorTest extends TestCase { - public static final String FIRST_LISTENER = "org.testng.TestListenerAdapter"; - public static final String SECOND_LISTENER = "org.testng.reporters.ExitCodeListener"; - public static final String LISTENER_PROP = "listener"; - - public void testGetConvertedOptions() throws Exception { - Map convertedOptions = getConvertedOptions("mixed", "true"); - boolean bool = (Boolean) convertedOptions.get("-mixed"); - assertTrue(bool); - } - - public void testListenersOnSeparateLines() throws Exception { - String listenersOnSeveralLines = String.format("%s , %n %s", FIRST_LISTENER, SECOND_LISTENER); - Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines); - List listeners = (List) convertedOptions.get(String.format("-%s", LISTENER_PROP)); - assertEquals(2, listeners.size()); - } - - public void testListenersOnTheSameLine() throws Exception { - String listenersOnSeveralLines = String.format("%s,%s", FIRST_LISTENER, SECOND_LISTENER); - Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines); - List listeners = (List) convertedOptions.get(String.format("-%s", LISTENER_PROP)); - assertEquals(2, listeners.size()); - } - - public void testGroupByInstances() throws Exception { - Map convertedOptions = getConvertedOptions("group-by-instances", "true"); - boolean bool = (Boolean) convertedOptions.get("-group-by-instances"); - assertTrue(bool); - } - - public void testReporter() throws Exception { - Map convertedOptions = getConvertedOptions("reporter", "classname"); - List reporter = (List) convertedOptions.get("-reporterslist"); - ReporterConfig reporterConfig = reporter.get(0); - assertEquals("classname", reporterConfig.getClassName()); - } - - private Map getConvertedOptions(String key, String value) throws TestSetFailedException { - TestNGMapConfigurator testNGMapConfigurator = new TestNGMapConfigurator(); - Map raw = new HashMap<>(); - raw.put(key, value); - return testNGMapConfigurator.getConvertedOptions(raw); - } -} diff --git a/surefire-report-parser/pom.xml b/surefire-report-parser/pom.xml index a2c1927257..2442d4abc2 100644 --- a/surefire-report-parser/pom.xml +++ b/surefire-report-parser/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-report-parser diff --git a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestSuite.java b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestSuite.java index 6e42cb44f8..c849825887 100644 --- a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestSuite.java +++ b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/ReportTestSuite.java @@ -27,6 +27,8 @@ public final class ReportTestSuite { private final List testCases = new ArrayList<>(); + private long lastModified; + private int numberOfErrors; private int numberOfFailures; @@ -161,6 +163,15 @@ ReportTestSuite setTestCases(List testCases) { return this; } + public long getLastModified() { + return lastModified; + } + + public ReportTestSuite lastModified(long lastModified) { + this.lastModified = lastModified; + return this; + } + /** * {@inheritDoc} */ diff --git a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java index c0643fd92d..6c2eec0080 100644 --- a/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java +++ b/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report/TestSuiteXmlParser.java @@ -23,9 +23,9 @@ import javax.xml.parsers.SAXParserFactory; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -66,13 +66,16 @@ public final class TestSuiteXmlParser extends DefaultHandler { private boolean parseContent; + private long lastModified; + public TestSuiteXmlParser(ConsoleLogger consoleLogger) { this.consoleLogger = consoleLogger; } public List parse(String xmlPath) throws ParserConfigurationException, SAXException, IOException { File f = new File(xmlPath); - try (InputStreamReader stream = new InputStreamReader(new FileInputStream(f), UTF_8)) { + try (InputStreamReader stream = new InputStreamReader(Files.newInputStream(f.toPath()), UTF_8)) { + this.lastModified = f.lastModified(); return parse(stream); } } @@ -220,6 +223,7 @@ public void endElement(String uri, String localName, String qName) throws SAXExc switch (qName) { case "testcase": currentSuite.getTestCases().add(testCase); + currentSuite.lastModified(this.lastModified); break; case "failure": case "error": diff --git a/surefire-shadefire/pom.xml b/surefire-shadefire/pom.xml index f7c9ba621a..b430db10f7 100644 --- a/surefire-shadefire/pom.xml +++ b/surefire-shadefire/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-shadefire diff --git a/surefire-shared-utils/pom.xml b/surefire-shared-utils/pom.xml index bf3e4c0c3e..83dc1082b6 100644 --- a/surefire-shared-utils/pom.xml +++ b/surefire-shared-utils/pom.xml @@ -23,7 +23,7 @@ org.apache.maven.surefire surefire - 3.5.5-SNAPSHOT + 3.6.0-SNAPSHOT surefire-shared-utils