Repository: maven-surefire Updated Branches: refs/heads/master 660a4cfab -> 7b9815c8b
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f337881f/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java index 33662d1..92253d1 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java @@ -90,7 +90,7 @@ public final class ForkedBooter { BooterDeserializer booterDeserializer = new BooterDeserializer( createSurefirePropertiesIfFileExists( tmpDir, surefirePropsFileName ) ); - // todo: print PID in debug console logger in version 2.20.2 + // todo: print PID in debug console logger in version 2.21.2 pingScheduler = isDebugging() ? null : listenToShutdownCommands( booterDeserializer.getPluginPid() ); setSystemProperties( new File( tmpDir, effectiveSystemPropertiesFileName ) ); @@ -98,20 +98,24 @@ public final class ForkedBooter DumpErrorSingleton.getSingleton().init( dumpFileName, providerConfiguration.getReporterConfiguration() ); startupConfiguration = booterDeserializer.getProviderConfiguration(); - systemExitTimeoutInSeconds = - providerConfiguration.systemExitTimeout( DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS ); + systemExitTimeoutInSeconds = providerConfiguration.systemExitTimeout( DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS ); - ClasspathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration(); - if ( startupConfiguration.isManifestOnlyJarRequestedAndUsable() ) + AbstractPathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration(); + + if ( classpathConfiguration.isClassPathConfig() ) { - classpathConfiguration.trickClassPathWhenManifestOnlyClasspath(); + if ( startupConfiguration.isManifestOnlyJarRequestedAndUsable() ) + { + classpathConfiguration.toRealPath( ClasspathConfiguration.class ) + .trickClassPathWhenManifestOnlyClasspath(); + } + startupConfiguration.writeSurefireTestClasspathProperty(); } ClassLoader classLoader = currentThread().getContextClassLoader(); classLoader.setDefaultAssertionStatus( classpathConfiguration.isEnableAssertions() ); - startupConfiguration.writeSurefireTestClasspathProperty(); - testSet = createTestSet( providerConfiguration.getTestForFork(), - providerConfiguration.isReadTestsFromInStream(), classLoader ); + boolean readTestsFromCommandReader = providerConfiguration.isReadTestsFromInStream(); + testSet = createTestSet( providerConfiguration.getTestForFork(), readTestsFromCommandReader, classLoader ); } private void execute() http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f337881f/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ModularClasspath.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ModularClasspath.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ModularClasspath.java new file mode 100644 index 0000000..0d7b8eb --- /dev/null +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ModularClasspath.java @@ -0,0 +1,70 @@ +package org.apache.maven.surefire.booter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.Collection; +import java.util.List; + +import static java.util.Collections.unmodifiableCollection; +import static java.util.Collections.unmodifiableList; + +/** + * Jigsaw class-path and module-path. + * + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @since 2.21.0.Jigsaw + */ +public final class ModularClasspath +{ + private final File moduleDescriptor; + private final List<String> modulePath; + private final Collection<String> packages; + private final File patchFile; + + public ModularClasspath( File moduleDescriptor, List<String> modulePath, Collection<String> packages, + File patchFile ) + { + this.moduleDescriptor = moduleDescriptor; + this.modulePath = modulePath; + this.packages = packages; + this.patchFile = patchFile; + } + + public File getModuleDescriptor() + { + return moduleDescriptor; + } + + public List<String> getModulePath() + { + return unmodifiableList( modulePath ); + } + + public Collection<String> getPackages() + { + return unmodifiableCollection( packages ); + } + + public File getPatchFile() + { + return patchFile; + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f337881f/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ModularClasspathConfiguration.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ModularClasspathConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ModularClasspathConfiguration.java new file mode 100644 index 0000000..655b864 --- /dev/null +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ModularClasspathConfiguration.java @@ -0,0 +1,62 @@ +package org.apache.maven.surefire.booter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @since 2.21.0.Jigsaw + */ +public class ModularClasspathConfiguration extends AbstractPathConfiguration +{ + private final ModularClasspath modularClasspath; + private final Classpath testClasspathUrls; + + public ModularClasspathConfiguration( ModularClasspath modularClasspath, Classpath testClasspathUrls, + Classpath surefireClasspathUrls, boolean enableAssertions, + boolean childDelegation ) + { + super( surefireClasspathUrls, enableAssertions, childDelegation ); + this.modularClasspath = modularClasspath; + this.testClasspathUrls = testClasspathUrls; + } + + @Override + public Classpath getTestClasspath() + { + return testClasspathUrls; + } + + @Override + public final boolean isModularPathConfig() + { + return true; + } + + @Override + public final boolean isClassPathConfig() + { + return !isModularPathConfig(); + } + + public ModularClasspath getModularClasspath() + { + return modularClasspath; + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f337881f/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java index 91530b7..7dd30ff 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java @@ -26,20 +26,15 @@ package org.apache.maven.surefire.booter; */ public class StartupConfiguration { - private final String providerClassName; - - private final ClasspathConfiguration classpathConfiguration; + private static final String SUREFIRE_TEST_CLASSPATH = "surefire.test.class.path"; + private final String providerClassName; + private final AbstractPathConfiguration classpathConfiguration; private final ClassLoaderConfiguration classLoaderConfiguration; - private final boolean isForkRequested; - private final boolean isInForkedVm; - private static final String SUREFIRE_TEST_CLASSPATH = "surefire.test.class.path"; - - - public StartupConfiguration( String providerClassName, ClasspathConfiguration classpathConfiguration, + public StartupConfiguration( String providerClassName, AbstractPathConfiguration classpathConfiguration, ClassLoaderConfiguration classLoaderConfiguration, boolean isForkRequested, boolean inForkedVm ) { @@ -63,11 +58,12 @@ public class StartupConfiguration true ); } - public ClasspathConfiguration getClasspathConfiguration() + public AbstractPathConfiguration getClasspathConfiguration() { return classpathConfiguration; } + @Deprecated public boolean useSystemClassLoader() { // todo; I am not totally convinced this logic is as simple as it could be @@ -86,11 +82,7 @@ public class StartupConfiguration public String getActualClassName() { - if ( isProviderMainClass() ) - { - return stripEnd( providerClassName, "#main" ); - } - return providerClassName; + return isProviderMainClass() ? stripEnd( providerClassName, "#main" ) : providerClassName; } /** @@ -120,7 +112,7 @@ public class StartupConfiguration } else { - while ( ( end != 0 ) && ( strip.indexOf( str.charAt( end - 1 ) ) != -1 ) ) + while ( end != 0 && strip.indexOf( str.charAt( end - 1 ) ) != -1 ) { end--; } @@ -140,8 +132,6 @@ public class StartupConfiguration public void writeSurefireTestClasspathProperty() { - ClasspathConfiguration classpathConfiguration = getClasspathConfiguration(); - classpathConfiguration.getTestClasspath().writeToSystemProperty( SUREFIRE_TEST_CLASSPATH ); + getClasspathConfiguration().getTestClasspath().writeToSystemProperty( SUREFIRE_TEST_CLASSPATH ); } - } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f337881f/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java index 6c1b808..094a418 100644 --- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java @@ -42,6 +42,7 @@ import static org.junit.Assume.assumeTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyDouble; import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.when; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.verifyStatic; @@ -339,10 +340,10 @@ public class SystemUtilsTest assertThat( SystemUtils.isJava9AtLeast( path.getAbsolutePath() ) ).isFalse(); } - verifyStatic( SystemUtils.class, Mockito.times( 0 ) ); + verifyStatic( SystemUtils.class, times( 0 ) ); SystemUtils.toJdkVersionFromReleaseFile( any( File.class ) ); - verifyStatic( SystemUtils.class, Mockito.times( 1 ) ); + verifyStatic( SystemUtils.class, times( 1 ) ); SystemUtils.isBuiltInJava9AtLeast(); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f337881f/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java new file mode 100644 index 0000000..3c3d2c6 --- /dev/null +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java @@ -0,0 +1,45 @@ +package org.apache.maven.surefire.its; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.junit.Test; + +import java.io.IOException; + +public class ModulePathIT + extends AbstractJigsawIT +{ + @Test + public void testModulePath() + throws IOException + { + assumeJigsaw() + .debugLogging() + .executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 2 ); + } + + @Override + protected String getProjectDirectoryName() + { + return "modulepath"; + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f337881f/surefire-integration-tests/src/test/resources/modulepath/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/modulepath/pom.xml b/surefire-integration-tests/src/test/resources/modulepath/pom.xml new file mode 100644 index 0000000..e4a7783 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/modulepath/pom.xml @@ -0,0 +1,45 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <groupId>foo</groupId> + <artifactId>app</artifactId> + <version>1.0.0-SNAPSHOT</version> + + <name>app</name> + + <properties> + <maven.compiler.release>9</maven.compiler.release> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.6.2</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>joda-time</groupId> + <artifactId>joda-time</artifactId> + <version>2.9.9</version> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.11</version> + <scope>test</scope> + </dependency> + </dependencies> + +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f337881f/surefire-integration-tests/src/test/resources/modulepath/src/main/java/com/app/Main.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/modulepath/src/main/java/com/app/Main.java b/surefire-integration-tests/src/test/resources/modulepath/src/main/java/com/app/Main.java new file mode 100644 index 0000000..6a44492 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/modulepath/src/main/java/com/app/Main.java @@ -0,0 +1,34 @@ +package com.app; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.joda.time.DateTime; + +public class Main +{ + public static void main( String... args ) + { + System.out.println( "module path => " + System.getProperty( "jdk.module.path" ) ); + System.out.println( " class path => " + System.getProperty( "java.class.path" ) ); + + DateTime dt = new DateTime(); + System.out.println( dt ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f337881f/surefire-integration-tests/src/test/resources/modulepath/src/main/java/module-info.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/modulepath/src/main/java/module-info.java b/surefire-integration-tests/src/test/resources/modulepath/src/main/java/module-info.java new file mode 100644 index 0000000..5f3eed4 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/modulepath/src/main/java/module-info.java @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +module com.app { + requires joda.time; +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f337881f/surefire-integration-tests/src/test/resources/modulepath/src/test/java/com/app/AppTest.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/modulepath/src/test/java/com/app/AppTest.java b/surefire-integration-tests/src/test/resources/modulepath/src/test/java/com/app/AppTest.java new file mode 100644 index 0000000..aa836a4 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/modulepath/src/test/java/com/app/AppTest.java @@ -0,0 +1,36 @@ +package com.app; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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; + +@Test +public class AppTest +{ + public void testNoop() + throws Exception + { + } + + public void testMain() + { + Main.main(); + } +}