This is an automated email from the ASF dual-hosted git repository. tibordigana pushed a commit to branch SUREFIRE-1733 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 95a9b2f83bcda6834a3f5e080b44ff6a0969c630 Author: tibordigana <[email protected]> AuthorDate: Fri May 29 01:16:57 2020 +0200 not using "--add-modules ALL-MODULE-PATH" using "--add-modules" with test module name --- .../maven/plugin/surefire/AbstractSurefireMojo.java | 5 ----- .../ModularClasspathForkConfiguration.java | 19 +++++++++++++------ .../surefire/AbstractSurefireMojoJava7PlusTest.java | 15 ++++++--------- .../surefire/booterclient/ForkConfigurationTest.java | 6 ++++-- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java index 32013bd..38d34fb 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 @@ -3267,11 +3267,6 @@ public abstract class AbstractSurefireMojo List<String[]> args = new ArrayList<>(); args.add( new String[] { - "--add-modules", - "ALL-MODULE-PATH" - } ); - - args.add( new String[] { "--add-opens", "org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED" } ); diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java index 4cae9f9..16e8905 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java @@ -45,8 +45,8 @@ import java.util.Properties; import static java.io.File.createTempFile; import static java.io.File.pathSeparatorChar; import static org.apache.maven.plugin.surefire.SurefireHelper.escapeToPlatformPath; -import static org.apache.maven.surefire.shared.utils.StringUtils.replace; import static org.apache.maven.surefire.api.util.internal.StringUtils.NL; +import static org.apache.maven.surefire.shared.utils.StringUtils.replace; /** * @author <a href="mailto:[email protected]">Tibor Digana (tibor17)</a> @@ -205,14 +205,21 @@ public class ModularClasspathForkConfiguration .append( "ALL-UNNAMED" ) .append( NL ); } - - for ( String[] entries : providerJpmsArguments ) + else { - for ( String entry : entries ) + for ( String[] entries : providerJpmsArguments ) { - args.append( entry ) - .append( NL ); + for ( String entry : entries ) + { + args.append( entry ) + .append( NL ); + } } + + args.append( "--add-modules" ) + .append( NL ) + .append( moduleName ) + .append( NL ); } args.append( startClassName ); 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 4d8f92b..7d5343c 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 @@ -58,6 +58,7 @@ import static java.util.Collections.singleton; import static java.util.Collections.singletonMap; import static org.apache.maven.artifact.versioning.VersionRange.createFromVersion; import static org.fest.assertions.Assertions.assertThat; +import static org.fest.assertions.Index.atIndex; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; @@ -458,15 +459,11 @@ public class AbstractSurefireMojoJava7PlusTest List<String[]> args = providerInfo.getJpmsArguments( providerRequirements ); assertThat( args ) .isNotEmpty() - .hasSize( 3 ); - assertThat( args.get( 0 ) ) - .isEqualTo( new String[] {"--add-modules", "ALL-MODULE-PATH"} ); - assertThat( args.get( 1 ) ) - .isEqualTo( new String[] { - "--add-opens", "org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED"} ); - assertThat( args.get( 2 ) ) - .isEqualTo( new String[] { - "--add-opens", "org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED"} ); + .hasSize( 2 ) + .contains( new String[] { + "--add-opens", "org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED"}, atIndex( 0 ) ) + .contains( new String[] { + "--add-opens", "org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED"}, atIndex( 1 ) ); } private static File mockFile( String absolutePath ) diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java index 4715ccf..b1db277 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java @@ -53,6 +53,7 @@ import java.util.Properties; import static java.nio.file.Files.readAllBytes; import static java.util.Collections.singletonList; +import static org.apache.maven.surefire.api.util.internal.StringUtils.NL; import static org.apache.maven.surefire.booter.Classpath.emptyClasspath; import static org.apache.maven.surefire.booter.ProcessCheckerType.ALL; import static org.fest.assertions.Assertions.assertThat; @@ -151,7 +152,7 @@ public class ForkConfigurationTest List<String[]> providerJpmsArgs = new ArrayList<>(); providerJpmsArgs.add( new String[]{ "arg2", "arg3" } ); - ModularClasspath modulepath = new ModularClasspath( "", Collections.<String>emptyList(), + ModularClasspath modulepath = new ModularClasspath( "test.module", Collections.<String>emptyList(), Collections.<String>emptyList(), null, false ); ModularClasspathConfiguration cpConfig = new ModularClasspathConfiguration( modulepath, emptyClasspath(), emptyClasspath(), emptyClasspath(), false, true ); @@ -177,7 +178,8 @@ public class ForkConfigurationTest String argFileText = new String( readAllBytes( argFile ) ); assertThat( argFileText ) .contains( "arg2" ) - .contains( "arg3" ); + .contains( "arg3" ) + .contains( "--add-modules" + NL + "test.module" ); } @Test
