This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch jdk-16-17
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/jdk-16-17 by this push:
     new c2027bb  fix
c2027bb is described below

commit c2027bb0670d77f14952c9a0a623afb09e2b08a1
Author: tibordigana <tibor.dig...@gmail.com>
AuthorDate: Tue Feb 23 23:25:47 2021 +0100

    fix
---
 pom.xml                                            |   3 +-
 .../maven/surefire/its/AbstractJigsawIT.java       | 111 ---------------------
 .../apache/maven/surefire/its/Java9FullApiIT.java  |  20 ++--
 .../apache/maven/surefire/its/ModulePathIT.java    |   3 +-
 .../surefire/its/MultiModuleProjectWithJPMSIT.java |   3 +-
 .../AbstractJava9PlusIT.java}                      |  50 +++++-----
 .../maven/surefire/its/fixture/MavenLauncher.java  |  61 +++++++----
 .../fixture/SurefireJUnit4IntegrationTestCase.java |  65 +++++++++++-
 .../surefire/its/fixture/SurefireLauncher.java     |  58 ++---------
 .../surefire/its/fixture/SurefireLauncherTest.java |   3 +-
 .../its/jiras/Surefire1158RemoveInfoLinesIT.java   |  14 ++-
 .../surefire/its/jiras/Surefire1265Java9IT.java    |   4 +-
 ...urefire1534ReuseForksFalseWithJavaModuleIT.java |   4 +-
 .../its/jiras/Surefire1570ModularFailsafeIT.java   |   4 +-
 ...urefire1712ExtractedModulenameWithoutASMIT.java |   4 +-
 .../surefire/its/jiras/Surefire1733JUnitIT.java    |   4 +-
 .../surefire/its/jiras/Surefire1733TestngIT.java   |   4 +-
 ...Surefire946KillMainProcessInReusableForkIT.java |   3 +-
 18 files changed, 170 insertions(+), 248 deletions(-)

diff --git a/pom.xml b/pom.xml
index 94153ea..42c0d79 100644
--- a/pom.xml
+++ b/pom.xml
@@ -106,8 +106,7 @@
     <jdk.home>${java.home}/..</jdk.home>
     <maven.compiler.testSource>1.${javaVersion}</maven.compiler.testSource>
     <maven.compiler.testTarget>1.${javaVersion}</maven.compiler.testTarget>
-    <jvm.args.tests>${jvm9ArgsTests} -Xms128m -Xmx144m 
-XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true 
-Djdk.net.URLClassPath.disableClassPathURLCheck=true</jvm.args.tests>
-<!--    <jvm9ArgsTests></jvm9ArgsTests>-->
+    <jvm.args.tests>${jvm9ArgsTests} -Xms32m -Xmx144m 
-XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true 
-Djdk.net.URLClassPath.disableClassPathURLCheck=true</jvm.args.tests>
     
<project.build.outputTimestamp>2020-06-10T18:16:37Z</project.build.outputTimestamp>
   </properties>
 
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java
deleted file mode 100644
index c8fb2d5..0000000
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package org.apache.maven.surefire.its;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
-import org.apache.maven.surefire.its.fixture.SurefireLauncher;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import static 
org.apache.maven.surefire.its.fixture.SurefireLauncher.EXT_JDK_HOME;
-import static 
org.apache.maven.surefire.its.fixture.SurefireLauncher.EXT_JDK_HOME_KEY;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
-
-/**
- * Abstract test class for Jigsaw tests.
- *
- * @author <a href="mailto:tibordig...@apache.org";>Tibor Digana (tibor17)</a>
- * @since 2.20.1
- */
-public abstract class AbstractJigsawIT
-        extends SurefireJUnit4IntegrationTestCase
-{
-    private static final double JIGSAW_JAVA_VERSION = 9.0d;
-
-    protected abstract String getProjectDirectoryName();
-
-    protected SurefireLauncher assumeJava9() throws IOException
-    {
-        assumeTrue( "There's no JDK 9 provided.",
-                          isJavaVersion9AtLeast() || EXT_JDK_HOME != null && 
isExtJavaVerion9AtLeast() );
-        // fail( EXT_JDK_HOME_KEY + " was provided with value " + EXT_JDK_HOME 
+ " but it is not Jigsaw Java 9." );
-
-        SurefireLauncher launcher = unpack();
-
-        return EXT_JDK_HOME == null ? launcher : launcher.setLauncherJavaHome( 
EXT_JDK_HOME );
-    }
-
-    protected SurefireLauncher assumeJava9Property() throws IOException
-    {
-        assumeTrue( "There's no JDK 9 provided.", EXT_JDK_HOME != null && 
isExtJavaVerion9AtLeast() );
-        return unpack();
-    }
-
-    protected String getSuffix()
-    {
-        return null;
-    }
-
-    private SurefireLauncher unpack()
-    {
-        return unpack( getProjectDirectoryName(), getSuffix() );
-    }
-
-    private static boolean isJavaVersion9AtLeast()
-    {
-        return Double.valueOf( System.getProperty( 
"java.specification.version" ) ) >= JIGSAW_JAVA_VERSION;
-    }
-
-    private static boolean isExtJavaVerion9AtLeast() throws IOException
-    {
-        File release = new File( EXT_JDK_HOME, "release" );
-        assumeTrue( EXT_JDK_HOME_KEY + " was provided with value " + 
EXT_JDK_HOME + " but file does not exist "
-                + EXT_JDK_HOME + File.separator + "release", release.exists() 
);
-
-        Properties properties = new Properties();
-        try ( InputStream is = new FileInputStream( release ) )
-        {
-            properties.load( is );
-        }
-        String javaVersion = properties.getProperty( "JAVA_VERSION" ).replace( 
"\"", "" );
-        StringTokenizer versions = new StringTokenizer( javaVersion, "._" );
-
-        if ( versions.countTokens() == 1 )
-        {
-            javaVersion = versions.nextToken();
-        }
-        else if ( versions.countTokens() >= 2 )
-        {
-            javaVersion = versions.nextToken() + "." + versions.nextToken();
-        }
-        else
-        {
-            fail( "unexpected java version format" );
-        }
-
-        return Double.valueOf( javaVersion ) >= JIGSAW_JAVA_VERSION;
-    }
-}
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/Java9FullApiIT.java 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/Java9FullApiIT.java
index 37b784b..88008f0 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/Java9FullApiIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/Java9FullApiIT.java
@@ -19,13 +19,10 @@ package org.apache.maven.surefire.its;
  * under the License.
  */
 
+import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
 import org.apache.maven.surefire.its.fixture.OutputValidator;
 import org.junit.Test;
 
-import java.io.File;
-
-import static 
org.apache.maven.surefire.its.fixture.SurefireLauncher.EXT_JDK_HOME;
-import static 
org.apache.maven.surefire.its.fixture.SurefireLauncher.EXT_JDK_HOME_KEY;
 import static org.hamcrest.Matchers.greaterThanOrEqualTo;
 import static org.hamcrest.Matchers.is;
 
@@ -37,10 +34,8 @@ import static org.hamcrest.Matchers.is;
  * @since 2.20.1
  */
 public class Java9FullApiIT
-        extends AbstractJigsawIT
+    extends AbstractJava9PlusIT
 {
-    private static final String JVM_SPEC_VERSION = System.getProperty( 
"java.specification.version" );
-
     @Test
     @SuppressWarnings( "checkstyle:methodname" )
     public void shouldLoadMultipleJavaModules_JavaHome() throws Exception
@@ -56,7 +51,7 @@ public class Java9FullApiIT
                 .verifyTextInLog( "loaded class javax.xml.bind.JAXBException" )
                 .verifyTextInLog( "loaded class 
javax.transaction.TransactionManager" )
                 .verifyTextInLog( "loaded class 
javax.transaction.InvalidTransactionException" )
-                .assertThatLogLine( is( "java.specification.version=" + 
JVM_SPEC_VERSION ),
+                .assertThatLogLine( is( "java.specification.version=" + 
JAVA_VERSION ),
                                     greaterThanOrEqualTo( 1 ) );
     }
 
@@ -64,10 +59,9 @@ public class Java9FullApiIT
     @SuppressWarnings( "checkstyle:methodname" )
     public void shouldLoadMultipleJavaModules_JvmParameter() throws Exception
     {
-        OutputValidator validator = assumeJava9Property()
+        OutputValidator validator = assumeJava9()
                                             .setForkJvm()
                                             .debugLogging()
-                                            .sysProp( EXT_JDK_HOME_KEY, new 
File( EXT_JDK_HOME ).getCanonicalPath() )
                                             .execute( "verify" )
                                             .verifyErrorFree( 1 );
 
@@ -76,7 +70,7 @@ public class Java9FullApiIT
                 .verifyTextInLog( "loaded class javax.xml.bind.JAXBException" )
                 .verifyTextInLog( "loaded class 
javax.transaction.TransactionManager" )
                 .verifyTextInLog( "loaded class 
javax.transaction.InvalidTransactionException" )
-                .assertThatLogLine( is( "java.specification.version=" + 
JVM_SPEC_VERSION ),
+                .assertThatLogLine( is( "java.specification.version=" + 
JAVA_VERSION ),
                                     greaterThanOrEqualTo( 1 ) );
     }
 
@@ -84,7 +78,7 @@ public class Java9FullApiIT
     @SuppressWarnings( "checkstyle:methodname" )
     public void shouldLoadMultipleJavaModules_ToolchainsXML() throws Exception
     {
-        OutputValidator validator = assumeJava9Property()
+        OutputValidator validator = assumeJava9()
                                             .setForkJvm()
                                             .activateProfile( "use-toolchains" 
)
                                             .addGoal( "--toolchains" )
@@ -97,7 +91,7 @@ public class Java9FullApiIT
                 .verifyTextInLog( "loaded class javax.xml.bind.JAXBException" )
                 .verifyTextInLog( "loaded class 
javax.transaction.TransactionManager" )
                 .verifyTextInLog( "loaded class 
javax.transaction.InvalidTransactionException" )
-                .assertThatLogLine( is( "java.specification.version=" + 
JVM_SPEC_VERSION ),
+                .assertThatLogLine( is( "java.specification.version=" + 
JAVA_VERSION ),
                                     greaterThanOrEqualTo( 1 ) );
     }
 
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java
index 5a716ca..c04a1ea 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.its;
  * under the License.
  */
 
+import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
 import org.junit.Test;
 
 import java.io.IOException;
@@ -27,7 +28,7 @@ import java.io.IOException;
  *
  */
 public class ModulePathIT
-        extends AbstractJigsawIT
+        extends AbstractJava9PlusIT
 {
     private String suffix;
 
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/MultiModuleProjectWithJPMSIT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/MultiModuleProjectWithJPMSIT.java
index 8b011ae..ac563b1 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/MultiModuleProjectWithJPMSIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/MultiModuleProjectWithJPMSIT.java
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.its;
  * under the License.
  */
 
+import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
 import org.apache.maven.surefire.its.fixture.OutputValidator;
 import org.junit.Test;
 
@@ -31,7 +32,7 @@ import static org.hamcrest.Matchers.is;
 /**
  * Integration test for <a 
href="https://issues.apache.org/jira/browse/SUREFIRE-1733";>SUREFIRE-1733</a>.
  */
-public class MultiModuleProjectWithJPMSIT extends AbstractJigsawIT
+public class MultiModuleProjectWithJPMSIT extends AbstractJava9PlusIT
 {
     @Test
     public void test() throws Exception
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/AbstractJava9PlusIT.java
similarity index 51%
copy from 
surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java
copy to 
surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/AbstractJava9PlusIT.java
index 5a716ca..c9c6225 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/AbstractJava9PlusIT.java
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.its;
+package org.apache.maven.surefire.its.fixture;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,50 +19,46 @@ package org.apache.maven.surefire.its;
  * under the License.
  */
 
-import org.junit.Test;
-
 import java.io.IOException;
 
+import static org.junit.Assume.assumeTrue;
+
 /**
+ * Abstract test class for Jigsaw tests.
  *
+ * @author <a href="mailto:tibordig...@apache.org";>Tibor Digana (tibor17)</a>
+ * @since 2.20.1
  */
-public class ModulePathIT
-        extends AbstractJigsawIT
+public abstract class AbstractJava9PlusIT
+        extends SurefireJUnit4IntegrationTestCase
 {
-    private String suffix;
+    protected abstract String getProjectDirectoryName();
 
-    @Test
-    public void testModulePath()
-            throws IOException
+    protected SurefireLauncher assumeJava9() throws IOException
     {
-        assumeJava9()
-                .debugLogging()
-                .executeTest()
-                .verifyErrorFreeLog()
-                .assertTestSuiteResults( 2 );
+        assumeTrue( "There's no JDK 9 provided.", IS_JAVA9_PLUS );
+        return unpack();
     }
 
-    @Test
-    public void testModulePathWithSpaces()
-            throws IOException
+    protected String getSuffix()
     {
-        suffix = " with spaces";
-        assumeJava9()
-                .debugLogging()
-                .executeTest()
-                .verifyErrorFreeLog()
-                .assertTestSuiteResults( 2 );
+        return null;
     }
 
     @Override
-    protected String getProjectDirectoryName()
+    public final SurefireLauncher unpack( String sourceName )
     {
-        return "modulepath";
+        throw new UnsupportedOperationException();
     }
 
     @Override
-    protected String getSuffix()
+    public final SurefireLauncher unpack( String sourceName, String suffix )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    private SurefireLauncher unpack()
     {
-        return suffix;
+        return unpack( getClass(), getProjectDirectoryName(), getSuffix() );
     }
 }
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 d444e35..cf0f474 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
@@ -29,10 +29,13 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
+import java.util.Map.Entry;
 
+import static java.util.Collections.singletonMap;
 import static java.util.Collections.unmodifiableList;
 
 /**
@@ -51,6 +54,8 @@ public final class MavenLauncher
 
     private final Map<String, String> envVars = new HashMap<>();
 
+    private final Map<String, String> props = new LinkedHashMap<>();
+
     private File unpackedAt;
 
     private Verifier verifier;
@@ -65,21 +70,24 @@ public final class MavenLauncher
 
     private final String[] cli;
 
+    private final boolean useIllegalJava9Access;
+
     private boolean expectFailure;
 
-    MavenLauncher( Class testClass, String resourceName, String suffix, 
String[] cli )
+    MavenLauncher( Class testClass, String resourceName, String suffix, 
String[] cli, boolean useIllegalJava9Access )
     {
         this.testCaseBeingRun = testClass;
         this.resourceName = resourceName;
         this.suffix = suffix != null ? suffix : "";
         this.cli = cli == null ? null : cli.clone();
+        this.useIllegalJava9Access = useIllegalJava9Access;
         resetGoals();
         resetCliOptions();
     }
 
     public MavenLauncher( Class testClass, String resourceName, String suffix )
     {
-        this( testClass, resourceName, suffix, null );
+        this( testClass, resourceName, suffix, null, false );
     }
 
     public File getUnpackedAt()
@@ -152,8 +160,8 @@ public final class MavenLauncher
 
     public MavenLauncher getSubProjectLauncher( String subProject )
     {
-        MavenLauncher mavenLauncher =
-            new MavenLauncher( testCaseBeingRun, resourceName + File.separator 
+ subProject, suffix, cli );
+        MavenLauncher mavenLauncher = new MavenLauncher( testCaseBeingRun,
+            resourceName + File.separator + subProject, suffix, cli, 
useIllegalJava9Access );
         mavenLauncher.unpackedAt = new File( ensureUnpacked(), subProject );
         return mavenLauncher;
     }
@@ -293,8 +301,30 @@ public final class MavenLauncher
     {
         try
         {
+            List<String> goalsAndProps = new ArrayList<>( goals );
+
+            if ( useIllegalJava9Access )
+            {
+                String argLine = props.get( "argLine" );
+                if ( argLine == null )
+                {
+                    props.put( "argLine", "--illegal-access=permit" );
+                }
+                else if ( !argLine.contains( "--illegal-access" ) )
+                {
+                    props.put( "argLine", "--illegal-access=permit " + argLine 
);
+                }
+            }
+
+            for ( Entry<String, String> e : props.entrySet() )
+            {
+                String key = e.getKey();
+                String val = e.getValue();
+                goalsAndProps.add( val == null ? "-D" + key : "-D" + key + "=" 
+ val );
+            }
+
             getVerifier().setCliOptions( cliOptions );
-            getVerifier().executeGoals( goals, envVars );
+            getVerifier().executeGoals( goalsAndProps, envVars );
             return getValidator();
         }
         catch ( VerificationException e )
@@ -312,33 +342,30 @@ public final class MavenLauncher
         return addGoal( "-P" + profile );
     }
 
-    public MavenLauncher sysProp( String variable, String value )
+    public MavenLauncher sysProp( String key, String value )
     {
-        return addGoal( "-D" + variable + "=" + value );
+        return sysProp( singletonMap( key, value ) );
     }
 
     public MavenLauncher sysProp( Map<String, String> properties )
     {
-        for ( Map.Entry<String, String> property : properties.entrySet() )
-        {
-            sysProp( property.getKey(), property.getValue() );
-        }
+        props.putAll( properties );
         return this;
     }
 
-    public MavenLauncher sysProp( String variable, boolean value )
+    public MavenLauncher sysProp( String key, boolean value )
     {
-        return addGoal( "-D" + variable + "=" + value );
+        return sysProp( singletonMap( key, Boolean.toString( value ) ) );
     }
 
-    public MavenLauncher sysProp( String variable, int value )
+    public MavenLauncher sysProp( String key, int value )
     {
-        return addGoal( "-D" + variable + "=" + value );
+        return sysProp( singletonMap( key, Integer.toString( value ) ) );
     }
 
-    public MavenLauncher sysProp( String variable, double value )
+    public MavenLauncher sysProp( String key, double value )
     {
-        return addGoal( "-D" + variable + "=" + value );
+        return sysProp( singletonMap( key, Double.toString( value ) ) );
     }
 
     public MavenLauncher showExceptionMessages()
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/SurefireJUnit4IntegrationTestCase.java
index ee04dbc..4f31ff0 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/SurefireJUnit4IntegrationTestCase.java
@@ -19,6 +19,11 @@ package org.apache.maven.surefire.its.fixture;
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+
+import static java.lang.Double.parseDouble;
+
 /**
  * Contains commonly used features for most tests, encapsulating
  * common use cases.
@@ -31,6 +36,14 @@ package org.apache.maven.surefire.its.fixture;
  */
 public abstract class SurefireJUnit4IntegrationTestCase
 {
+    private static final double JAVA9_VERSION = 9.0d;
+
+    public static final File JAVA_HOME = javaHome();
+
+    public static final double JAVA_VERSION = javaVersion();
+
+    public static final boolean IS_JAVA9_PLUS = isJDK9Plus();
+
     public OutputValidator executeErrorFreeTest( String sourceName, int total )
     {
         return unpack( sourceName ).executeTest().verifyErrorFree( total );
@@ -46,15 +59,59 @@ public abstract class SurefireJUnit4IntegrationTestCase
         return unpack( getClass(), sourceName, suffix );
     }
 
-    public static SurefireLauncher unpack( Class testClass, String sourceName, 
String suffix, String[] cli )
+    public SurefireLauncher unpack( String sourceName, String suffix, String[] 
cli )
     {
-        MavenLauncher mavenLauncher = new MavenLauncher( testClass, 
sourceName, suffix, cli );
-        return new SurefireLauncher( mavenLauncher );
+        return unpack( getClass(), sourceName, suffix, cli );
     }
 
-    public static SurefireLauncher unpack( Class testClass, String sourceName, 
String suffix )
+    public static SurefireLauncher unpack( Class<?> testClass, String 
sourceName, String suffix )
     {
         return unpack( testClass, sourceName, suffix, null );
     }
 
+    private static SurefireLauncher unpack( Class<?> testClass, String 
sourceName, String suffix, String[] cli )
+    {
+        boolean isJava9CapableTest = 
AbstractJava9PlusIT.class.isAssignableFrom( testClass );
+        boolean useIllegalJava9Access = isJDK9Plus() && !isJava9CapableTest;
+        MavenLauncher mavenLauncher = new MavenLauncher( testClass, 
sourceName, suffix, cli, useIllegalJava9Access );
+        return new SurefireLauncher( mavenLauncher, JAVA_HOME );
+    }
+
+    private static double javaVersion()
+    {
+        return parseDouble( System.getProperty( "java.specification.version" ) 
);
+    }
+
+    private static boolean isJDK9Plus()
+    {
+        return javaVersion() >= JAVA9_VERSION;
+    }
+
+    private static File javaHome()
+    {
+        String javaHome = System.getProperty( "java.home" );
+        if ( !isJDK9Plus() )
+        {
+            File jre = new File( javaHome );
+            if ( "jre".equals( jre.getName() ) )
+            {
+                javaHome = jre.getParent();
+            }
+        }
+
+        try
+        {
+            File javaHomeAsDir = new File( javaHome ).getCanonicalFile();
+            if ( !javaHomeAsDir.isDirectory() )
+            {
+                throw new RuntimeException( javaHomeAsDir.getAbsolutePath() + 
" is not a JAVA_HOME directory." );
+            }
+            System.out.println( "Using JAVA_HOME=" + 
javaHomeAsDir.getAbsolutePath() + " in forked launcher." );
+            return javaHomeAsDir;
+        }
+        catch ( IOException e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
 }
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
index 0342172..cbe02fd 100755
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
@@ -22,12 +22,9 @@ package org.apache.maven.surefire.its.fixture;
 import org.apache.maven.it.VerificationException;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import static org.apache.commons.lang3.StringUtils.isBlank;
-
 /**
  * Encapsulate all needed features to start a surefire run
  * <br>
@@ -38,19 +35,17 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
  */
 public final class SurefireLauncher
 {
-    public static final String EXT_JDK_HOME_KEY = "jdk.home";
-
-    public static final String EXT_JDK_HOME = System.getProperty( 
EXT_JDK_HOME_KEY );
-
-    private static final File JAVA_HOME = javaHome();
-
     private final MavenLauncher mavenLauncher;
 
     private final String surefireVersion = System.getProperty( 
"surefire.version" );
 
-    public SurefireLauncher( MavenLauncher mavenLauncher )
+    private final File javaHome;
+
+    public SurefireLauncher( MavenLauncher mavenLauncher, File javaHome )
     {
         this.mavenLauncher = mavenLauncher;
+        this.javaHome = javaHome;
+        mavenLauncher.addEnvVar( "JAVA_HOME", javaHome.getAbsolutePath() );
         reset();
     }
 
@@ -71,52 +66,11 @@ public final class SurefireLauncher
         {
             mavenLauncher.addGoal( s );
         }
-        setInProcessJavaHome();
-    }
-
-    private static File javaHome()
-    {
-        String javaHome = isBlank( EXT_JDK_HOME ) ? System.getenv( "JAVA_HOME" 
) : EXT_JDK_HOME;
-        if ( isBlank( javaHome ) )
-        {
-            javaHome = System.getProperty( "java.home" );
-            File jre = new File( javaHome );
-            if ( "jre".equals( jre.getName() ) )
-            {
-                javaHome = jre.getParent();
-            }
-        }
-
-        try
-        {
-            File javaHomeAsDir = new File( javaHome ).getCanonicalFile();
-            if ( !javaHomeAsDir.isDirectory() )
-            {
-                throw new RuntimeException( javaHomeAsDir.getAbsolutePath() + 
" is not a JAVA_HOME directory." );
-            }
-            System.out.println( "Using JAVA_HOME=" + 
javaHomeAsDir.getAbsolutePath() + " in forked launcher." );
-            return javaHomeAsDir;
-        }
-        catch ( IOException e )
-        {
-            throw new RuntimeException( e );
-        }
-    }
-
-    private void setInProcessJavaHome()
-    {
-        setLauncherJavaHome( JAVA_HOME.getPath() );
-    }
-
-    public SurefireLauncher setLauncherJavaHome( String javaHome )
-    {
-        mavenLauncher.addEnvVar( "JAVA_HOME", javaHome );
-        return this;
     }
 
     public SurefireLauncher getSubProjectLauncher( String subProject )
     {
-        return new SurefireLauncher( mavenLauncher.getSubProjectLauncher( 
subProject ) );
+        return new SurefireLauncher( mavenLauncher.getSubProjectLauncher( 
subProject ), javaHome );
     }
 
     public OutputValidator getSubProjectValidator( String subProject )
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java
index 801ebec..5b80c2c 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java
@@ -21,6 +21,7 @@ package org.apache.maven.surefire.its.fixture;
 
 import org.junit.Test;
 
+import static 
org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase.JAVA_HOME;
 import static org.junit.Assert.assertEquals;
 
 /**
@@ -32,7 +33,7 @@ public class SurefireLauncherTest
     public void launcherGetsProperMethodName()
     {
         MavenLauncher mavenLauncher = new MavenLauncher( 
SurefireLauncherTest.class, "foo", "" );
-        String method = new SurefireLauncher( mavenLauncher 
).getTestMethodName();
+        String method = new SurefireLauncher( mavenLauncher, JAVA_HOME 
).getTestMethodName();
         assertEquals( "launcherGetsProperMethodName", method );
 
     }
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
index 8fe2d5c..4448d67 100644
--- 
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
@@ -21,13 +21,13 @@ package org.apache.maven.surefire.its.jiras;
 
 import com.googlecode.junittoolbox.ParallelParameterized;
 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 java.util.ArrayList;
 
-import static 
org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase.unpack;
 import static org.junit.Assert.fail;
 import static org.junit.runners.Parameterized.Parameter;
 import static org.junit.runners.Parameterized.Parameters;
@@ -38,7 +38,7 @@ import static org.junit.runners.Parameterized.Parameters;
  * @since 2.19
  */
 @RunWith( ParallelParameterized.class )
-public class Surefire1158RemoveInfoLinesIT
+public class Surefire1158RemoveInfoLinesIT extends 
SurefireJUnit4IntegrationTestCase
 {
 
     @Parameters( name = "{0}" )
@@ -95,9 +95,13 @@ public class Surefire1158RemoveInfoLinesIT
     private OutputValidator assertTest() throws Exception
     {
         final String[] cli = {"--batch-mode"};
-        return unpack( getClass(), "/surefire-1158-remove-info-lines", "_" + 
description, cli ).sysProp( "provider",
-                provider ).addGoal( cliOption ).setTestToRun(
-                testToRun 
).executeTest().verifyErrorFreeLog().assertTestSuiteResults( 1, 0, 0, 0 );
+        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 )
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java
index c5d8071..9a1a446 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras;
  * under the License.
  */
 
-import org.apache.maven.surefire.its.AbstractJigsawIT;
+import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
 import org.junit.Test;
 
 import java.io.IOException;
@@ -39,7 +39,7 @@ import java.io.IOException;
  * @since 2.20.1
  */
 public class Surefire1265Java9IT
-        extends AbstractJigsawIT
+        extends AbstractJava9PlusIT
 {
     @Test
     public void shouldRunInPluginJava9() throws IOException
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1534ReuseForksFalseWithJavaModuleIT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1534ReuseForksFalseWithJavaModuleIT.java
index 23df035..523f22f 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1534ReuseForksFalseWithJavaModuleIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1534ReuseForksFalseWithJavaModuleIT.java
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras;
  * under the License.
  */
 
-import org.apache.maven.surefire.its.AbstractJigsawIT;
+import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
 import org.apache.maven.surefire.its.fixture.OutputValidator;
 import org.apache.maven.surefire.its.fixture.TestFile;
 import org.junit.Test;
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue;
  *
  */
 public class Surefire1534ReuseForksFalseWithJavaModuleIT
-        extends AbstractJigsawIT
+        extends AbstractJava9PlusIT
 {
 
     @Test
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1570ModularFailsafeIT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1570ModularFailsafeIT.java
index bb575b0..d52f64b 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1570ModularFailsafeIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1570ModularFailsafeIT.java
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras;
  * under the License.
  */
 
-import org.apache.maven.surefire.its.AbstractJigsawIT;
+import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.is;
  */
 @SuppressWarnings( "checkstyle:magicnumber" )
 public class Surefire1570ModularFailsafeIT
-    extends AbstractJigsawIT
+        extends AbstractJava9PlusIT
 {
     @Before
     public void setUp()
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1712ExtractedModulenameWithoutASMIT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1712ExtractedModulenameWithoutASMIT.java
index ce8ce68..69caf52 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1712ExtractedModulenameWithoutASMIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1712ExtractedModulenameWithoutASMIT.java
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras;
  * under the License.
  */
 
-import org.apache.maven.surefire.its.AbstractJigsawIT;
+import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.containsString;
@@ -32,7 +32,7 @@ import static org.hamcrest.CoreMatchers.is;
  * @since 3.0.0-M4
  */
 public class Surefire1712ExtractedModulenameWithoutASMIT
-        extends AbstractJigsawIT
+        extends AbstractJava9PlusIT
 {
     @Test
     public void test()
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1733JUnitIT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1733JUnitIT.java
index fe45d68..c0235eb 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1733JUnitIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1733JUnitIT.java
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras;
  * under the License.
  */
 
-import org.apache.maven.surefire.its.AbstractJigsawIT;
+import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
 import org.junit.Test;
 
 import static org.hamcrest.Matchers.containsString;
@@ -28,7 +28,7 @@ import static org.hamcrest.Matchers.is;
 /**
  * Integration test for <a 
href="https://issues.apache.org/jira/browse/SUREFIRE-1733";>SUREFIRE-1733</a>.
  */
-public class Surefire1733JUnitIT extends AbstractJigsawIT
+public class Surefire1733JUnitIT extends AbstractJava9PlusIT
 {
     @Test
     public void test() throws Exception
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1733TestngIT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1733TestngIT.java
index 53210c7..7fbf03a 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1733TestngIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1733TestngIT.java
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.its.jiras;
  * under the License.
  */
 
-import org.apache.maven.surefire.its.AbstractJigsawIT;
+import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
 import org.junit.Test;
 
 import static org.hamcrest.Matchers.containsString;
@@ -28,7 +28,7 @@ import static org.hamcrest.Matchers.is;
 /**
  * Integration test for <a 
href="https://issues.apache.org/jira/browse/SUREFIRE-1733";>SUREFIRE-1733</a>.
  */
-public class Surefire1733TestngIT extends AbstractJigsawIT
+public class Surefire1733TestngIT extends AbstractJava9PlusIT
 {
     @Test
     public void test() throws Exception
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 4be28e7..84d32da 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
@@ -90,8 +90,7 @@ public class Surefire946KillMainProcessInReusableForkIT
         synchronized ( LOCK_DEPENDENCY )
         {
             classifierOfDummyDependency = shutdownMavenMethod + 
shutdownSurefireMethod;
-            unpack( Surefire946KillMainProcessInReusableForkIT.class,
-                    "surefire-946-dummy-dependency", 
classifierOfDummyDependency )
+            unpack( "surefire-946-dummy-dependency", 
classifierOfDummyDependency )
                     .sysProp( "distinct.classifier", 
classifierOfDummyDependency )
                     .executeInstall();
         }

Reply via email to