maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tibordig...@apache.org
Subject [2/3] maven-surefire git commit: [SUREFIRE-1262] Add modulepath support
Date Sat, 18 Nov 2017 16:22:11 GMT
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..2b47c03
--- /dev/null
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
@@ -0,0 +1,230 @@
+package org.apache.maven.plugin.surefire.booterclient;
+
+/*
+ * 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.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.surefire.booter.AbstractPathConfiguration;
+import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.ModularClasspath;
+import org.apache.maven.surefire.booter.ModularClasspathConfiguration;
+import org.apache.maven.surefire.booter.StartupConfiguration;
+import org.apache.maven.surefire.booter.SurefireBooterForkException;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ModuleVisitor;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+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.objectweb.asm.Opcodes.ASM6;
+
+/**
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.21.0.Jigsaw
+ */
+public class ModularClasspathForkConfiguration
+        extends DefaultForkConfiguration
+{
+    @SuppressWarnings( "checkstyle:parameternumber" )
+    public ModularClasspathForkConfiguration( @Nonnull Classpath bootClasspath,
+                                              @Nonnull File tempDirectory,
+                                              @Nullable String debugLine,
+                                              @Nonnull File workingDirectory,
+                                              @Nonnull Properties modelProperties,
+                                              @Nullable String argLine,
+                                              @Nonnull Map<String, String> environmentVariables,
+                                              boolean debug,
+                                              int forkCount,
+                                              boolean reuseForks,
+                                              @Nonnull Platform pluginPlatform,
+                                              @Nonnull ConsoleLogger log )
+    {
+        super( bootClasspath, tempDirectory, debugLine, workingDirectory, modelProperties, argLine,
+                environmentVariables, debug, forkCount, reuseForks, pluginPlatform, log );
+    }
+
+    @Override
+    protected void resolveClasspath( OutputStreamFlushableCommandline cli, String startClass,
+                                     StartupConfiguration config )
+            throws SurefireBooterForkException
+    {
+        try
+        {
+            AbstractPathConfiguration pathConfig = config.getClasspathConfiguration();
+
+            ModularClasspathConfiguration modularClasspathConfiguration =
+                    pathConfig.toRealPath( ModularClasspathConfiguration.class );
+
+            ModularClasspath modularClasspath = modularClasspathConfiguration.getModularClasspath();
+
+            File descriptor = modularClasspath.getModuleDescriptor();
+            List<String> modulePath = modularClasspath.getModulePath();
+            Collection<String> packages = modularClasspath.getPackages();
+            File patchFile = modularClasspath.getPatchFile();
+            List<String> classpath = toCompleteClasspath( config );
+
+            File argsFile = createArgsFile( descriptor, modulePath, classpath, packages, patchFile, startClass );
+
+            //todo what if path have spaces
+            cli.createArg().setValue( "@" + escapeToPlatformPath( argsFile.getAbsolutePath() ) );
+        }
+        catch ( IOException e )
+        {
+            throw new SurefireBooterForkException( "Error creating args file", e );
+        }
+    }
+
+    File createArgsFile( File moduleDescriptor, List<String> modulePath, List<String> classPath,
+                         Collection<String> packages, File patchFile, String startClassName )
+            throws IOException
+    {
+        File surefireArgs = createTempFile( "surefireargs", "", getTempDirectory() );
+        if ( !isDebug() )
+        {
+            surefireArgs.deleteOnExit();
+        }
+
+        BufferedWriter writer = null;
+        try
+        {
+            writer = new BufferedWriter( new FileWriter( surefireArgs ) );
+
+            if ( modulePath != null && !modulePath.isEmpty() )
+            {
+                writer.write( "--module-path" );
+                writer.newLine();
+
+                for ( Iterator<String> it = modulePath.iterator(); it.hasNext(); )
+                {
+                    writer.append( it.next() );
+                    if ( it.hasNext() )
+                    {
+                        writer.append( pathSeparatorChar );
+                    }
+                }
+
+                writer.newLine();
+            }
+
+            if ( classPath != null && !classPath.isEmpty() )
+            {
+                writer.write( "--class-path" );
+                writer.newLine();
+                for ( Iterator<String> it = classPath.iterator(); it.hasNext(); )
+                {
+                    writer.append( it.next() );
+                    if ( it.hasNext() )
+                    {
+                        writer.append( pathSeparatorChar );
+                    }
+                }
+
+                writer.newLine();
+            }
+
+            //todo may return null
+            final String moduleName = toModuleName( moduleDescriptor );
+
+            writer.write( "--patch-module" );
+            writer.newLine();
+            writer.append( moduleName )
+                    .append( '=' )
+                    .append( patchFile.getPath() );
+
+            writer.newLine();
+
+            for ( String pkg : packages )
+            {
+                writer.write( "--add-exports" );
+                writer.newLine();
+                writer.append( moduleName )
+                        .append( '/' )
+                        .append( pkg )
+                        .append( '=' )
+                        .append( "ALL-UNNAMED" );
+
+                writer.newLine();
+            }
+
+            writer.write( "--add-modules" );
+            writer.newLine();
+            writer.append( moduleName );
+
+            writer.newLine();
+
+            writer.write( "--add-reads" );
+            writer.newLine();
+            writer.append( moduleName )
+                    .append( '=' )
+                    .append( "ALL-UNNAMED" );
+
+            writer.newLine();
+
+            writer.write( startClassName );
+
+            writer.newLine();
+        }
+        finally
+        {
+            if ( writer != null )
+            {
+                writer.close();
+            }
+        }
+
+        return surefireArgs;
+    }
+
+    private static String toModuleName( File moduleDescriptor ) throws IOException
+    {
+        if ( moduleDescriptor == null || !moduleDescriptor.isFile() )
+        {
+            return null;
+        }
+
+        final StringBuilder sb = new StringBuilder();
+        new ClassReader( new FileInputStream( moduleDescriptor ) ).accept( new ClassVisitor( ASM6 )
+        {
+            @Override
+            public ModuleVisitor visitModule( String name, int access, String version )
+            {
+                sb.setLength( 0 );
+                sb.append( name );
+                return super.visitModule( name, access, version );
+            }
+        }, 0 );
+
+        return sb.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/Platform.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/Platform.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/Platform.java
index 10b16dc..4762453 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/Platform.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/Platform.java
@@ -19,6 +19,7 @@ package org.apache.maven.plugin.surefire.booterclient;
  * under the License.
  */
 
+import org.apache.maven.plugin.surefire.JdkAttributes;
 import org.apache.maven.surefire.booter.SystemUtils;
 
 import java.util.concurrent.Callable;
@@ -35,20 +36,28 @@ import static org.apache.maven.surefire.util.internal.DaemonThreadFactory.newDae
  */
 public final class Platform
 {
-    private final RunnableFuture<Long> pidJob;
+    private final RunnableFuture<Long> pluginPidJob;
+
+    private volatile JdkAttributes jdk;
 
     public Platform()
     {
         // the job may take 50 or 80 ms
-        pidJob = new FutureTask<Long>( pidJob() );
-        newDaemonThread( pidJob ).start();
+        this( new FutureTask<Long>( pidJob() ), null );
+        newDaemonThread( pluginPidJob ).start();
     }
 
-    public Long getPid()
+    private Platform( RunnableFuture<Long> pluginPidJob, JdkAttributes jdk )
+    {
+        this.pluginPidJob = pluginPidJob;
+        this.jdk = jdk;
+    }
+
+    public Long getPluginPid()
     {
         try
         {
-            return pidJob.get();
+            return pluginPidJob.get();
         }
         catch ( Exception e )
         {
@@ -56,6 +65,16 @@ public final class Platform
         }
     }
 
+    public JdkAttributes getJdkExecAttributesForTests()
+    {
+        return jdk;
+    }
+
+    public Platform withJdkExecAttributesForTests( JdkAttributes jdk )
+    {
+        return new Platform( pluginPidJob, jdk );
+    }
+
     private static Callable<Long> pidJob()
     {
         return new Callable<Long>()

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
index 2237698..9d7706b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/Relocator.java
@@ -21,47 +21,38 @@ package org.apache.maven.plugin.surefire.util;
 
 
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 
 /**
  * Relocates class names when running with relocated provider
  *
  * @author Kristian Rosenvold
  */
-public class Relocator
+public final class Relocator
 {
     private static final String RELOCATION_BASE = "org.apache.maven.surefire.";
+    private static final String PACKAGE_DELIMITER = "shadefire";
 
-    @Nullable
-    private final String relocation;
-
-    public Relocator( @Nullable String relocation )
-    {
-        this.relocation = relocation;
-    }
-
-    public Relocator()
+    private Relocator()
     {
-        relocation = "shadefire";
+        throw new IllegalStateException( "no instantiable constructor" );
     }
 
-    @Nullable private String getRelocation()
+    @Nonnull
+    public static String relocate( @Nonnull String className )
     {
-        return relocation;
-    }
-
-    @Nonnull public String relocate( @Nonnull String className )
-    {
-        if ( relocation == null )
+        if ( className.contains( PACKAGE_DELIMITER ) )
         {
             return className;
         }
-        if ( className.contains( relocation ) )
+        else
         {
-            return className;
+            if ( !className.startsWith( RELOCATION_BASE ) )
+            {
+                throw new IllegalArgumentException( "'" + className + "' should start with '" + RELOCATION_BASE + "'" );
+            }
+            String rest = className.substring( RELOCATION_BASE.length() );
+            final String s = RELOCATION_BASE + PACKAGE_DELIMITER + ".";
+            return s + rest;
         }
-        String rest = className.substring( RELOCATION_BASE.length() );
-        final String s = RELOCATION_BASE + getRelocation() + ".";
-        return s + rest;
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ServiceLoader.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ServiceLoader.java b/maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ServiceLoader.java
index 8753ff1..00b8b74 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ServiceLoader.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/surefire/providerapi/ServiceLoader.java
@@ -43,7 +43,7 @@ import static org.apache.maven.surefire.util.ReflectionUtils.getConstructor;
  *
  * @since 2.20
  */
-public class ServiceLoader
+public final class ServiceLoader
 {
 
     @Nonnull

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
----------------------------------------------------------------------
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 a44bea4..44c8fe6 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,37 +19,316 @@ package org.apache.maven.plugin.surefire;
  * under the License.
  */
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.surefire.log.PluginConsoleLogger;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
+import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.ModularClasspathConfiguration;
+import org.apache.maven.surefire.booter.StartupConfiguration;
+import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.util.DefaultScanResult;
+import org.codehaus.plexus.languages.java.jpms.LocationManager;
+import org.codehaus.plexus.languages.java.jpms.ResolvePathsRequest;
+import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult;
+import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult.ModuleNameSource;
+import org.codehaus.plexus.logging.Logger;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.Field;
 import java.nio.file.Path;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
+import static java.io.File.separatorChar;
+import static java.util.Arrays.asList;
+import static java.util.Collections.singleton;
 import static org.apache.commons.lang3.JavaVersion.JAVA_1_7;
 import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
 import static org.apache.commons.lang3.SystemUtils.isJavaVersionAtLeast;
 import static org.fest.assertions.Assertions.assertThat;
 import static org.junit.Assume.assumeTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.verify;
+import static org.powermock.api.mockito.PowerMockito.doNothing;
+import static org.powermock.api.mockito.PowerMockito.doReturn;
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.spy;
+import static org.powermock.api.mockito.PowerMockito.verifyPrivate;
+import static org.powermock.api.mockito.PowerMockito.verifyStatic;
+import static org.powermock.api.support.membermodification.MemberMatcher.field;
+import static org.powermock.reflect.Whitebox.invokeMethod;
 
 /**
  * Test for {@link AbstractSurefireMojo}.
  */
-@RunWith( MockitoJUnitRunner.class )
+@RunWith( PowerMockRunner.class )
+@PrepareForTest( { AbstractSurefireMojo.class, ResolvePathsRequest.class } )
 public class AbstractSurefireMojoTest
 {
+    private Mojo mojo;
+
     @Mock
-    private AbstractSurefireMojo mojo;
+    private LocationManager locationManager;
+
+    @Before
+    public void initMojo() throws IllegalAccessException
+    {
+        mojo = new Mojo();
+        Field f = field( AbstractSurefireMojo.class, "locationManager" );
+        f.setAccessible( true );
+        f.set( mojo, locationManager );
+    }
+
+    @Test
+    public void shouldGenerateTestClasspath() throws Exception
+    {
+        AbstractSurefireMojo mojo = spy( this.mojo );
+
+        when( mojo.getClassesDirectory() ).thenReturn( new File( "target" + separatorChar + "classes" ) );
+        when( mojo.getTestClassesDirectory() ).thenReturn( new File( "target" + separatorChar + "test-classes" ) );
+        when( mojo.getClasspathDependencyScopeExclude() ).thenReturn( "runtime" );
+        when( mojo.getClasspathDependencyExcludes() ).thenReturn( new String[]{ "g3:a3" } );
+        doReturn( mock( Artifact.class ) ).when( mojo, "getTestNgArtifact" );
+        doNothing().when( mojo, "addTestNgUtilsArtifacts", any() );
+
+        Set<Artifact> artifacts = new HashSet<Artifact>();
+
+        Artifact a1 = mock( Artifact.class );
+        when( a1.getGroupId() ).thenReturn( "g1" );
+        when( a1.getArtifactId() ).thenReturn( "a1" );
+        when( a1.getVersion() ).thenReturn( "1" );
+        when( a1.getScope() ).thenReturn( "runtime" );
+        when( a1.getDependencyConflictId() ).thenReturn( "g1:a1:jar" );
+        when( a1.getId() ).thenReturn( "g1:a1:jar:1" );
+        artifacts.add( a1 );
+
+        ArtifactHandler artifactHandler = mock( ArtifactHandler.class );
+        when( artifactHandler.isAddedToClasspath() ).thenReturn( true );
+
+        Artifact a2 = mock( Artifact.class );
+        when( a2.getGroupId() ).thenReturn( "g2" );
+        when( a2.getArtifactId() ).thenReturn( "a2" );
+        when( a2.getVersion() ).thenReturn( "2" );
+        when( a2.getScope() ).thenReturn( "test" );
+        when( a2.getDependencyConflictId() ).thenReturn( "g2:a2:jar" );
+        when( a2.getId() ).thenReturn( "g2:a2:jar:2" );
+        when( a2.getFile() ).thenReturn( new File( "a2-2.jar" ) );
+        when( a2.getArtifactHandler() ).thenReturn( artifactHandler );
+        artifacts.add( a2 );
+
+        Artifact a3 = mock( Artifact.class );
+        when( a3.getGroupId() ).thenReturn( "g3" );
+        when( a3.getArtifactId() ).thenReturn( "a3" );
+        when( a3.getVersion() ).thenReturn( "3" );
+        when( a3.getScope() ).thenReturn( "test" );
+        when( a3.getDependencyConflictId() ).thenReturn( "g3:a3:jar" );
+        when( a3.getId() ).thenReturn( "g3:a3:jar:3" );
+        when( a3.getFile() ).thenReturn( new File( "a3-3.jar" ) );
+        when( a3.getArtifactHandler() ).thenReturn( artifactHandler );
+        artifacts.add( a3 );
+
+        MavenProject project = mock( MavenProject.class );
+        when( project.getArtifacts() ).thenReturn( artifacts );
+        when( mojo.getProject() ).thenReturn( project );
+
+        Classpath cp = invokeMethod( mojo, "generateTestClasspath" );
+
+        verifyPrivate( mojo, times( 1 ) ).invoke( "generateTestClasspath" );
+        verify( mojo, times( 1 ) ).getClassesDirectory();
+        verify( mojo, times( 1 ) ).getTestClassesDirectory();
+        verify( mojo, times( 3 ) ).getClasspathDependencyScopeExclude();
+        verify( mojo, times( 2 ) ).getClasspathDependencyExcludes();
+        verify( artifactHandler, times( 1 ) ).isAddedToClasspath();
+        verifyPrivate( mojo, times( 1 ) ).invoke( "getTestNgArtifact" );
+        verifyPrivate( mojo, times( 1 ) ).invoke( "addTestNgUtilsArtifacts", eq( cp.getClassPath() ) );
+
+        assertThat( cp.getClassPath() ).hasSize( 3 );
+        assertThat( cp.getClassPath().get( 0 ) ).endsWith( "test-classes" );
+        assertThat( cp.getClassPath().get( 1 ) ).endsWith( "classes" );
+        assertThat( cp.getClassPath().get( 2 ) ).endsWith( "a2-2.jar" );
+    }
+
+    @Test
+    public void shouldHaveStartupConfigForNonModularClasspath()
+            throws Exception
+    {
+        AbstractSurefireMojo mojo = spy( this.mojo );
+        Classpath testClasspath = new Classpath( asList( "junit.jar", "hamcrest.jar" ) );
+
+        doReturn( testClasspath ).when( mojo, "generateTestClasspath" );
+        doReturn( 1 ).when( mojo, "getEffectiveForkCount" );
+        doReturn( true ).when( mojo, "effectiveIsEnableAssertions" );
+        when( mojo.isChildDelegation() ).thenReturn( false );
+
+        ClassLoaderConfiguration classLoaderConfiguration = new ClassLoaderConfiguration( false, true );
+
+        Classpath providerClasspath = new Classpath( singleton( "surefire-provider.jar" ) );
+
+        Classpath inprocClasspath =
+                new Classpath( asList( "surefire-api.jar", "surefire-common.jar", "surefire-provider.jar" ) );
+
+        Logger logger = mock( Logger.class );
+        when( logger.isDebugEnabled() ).thenReturn( true );
+        doNothing().when( logger ).debug( anyString() );
+        when( mojo.getConsoleLogger() ).thenReturn( new PluginConsoleLogger( logger ) );
+
+        StartupConfiguration conf = invokeMethod( mojo, "newStartupConfigForNonModularClasspath",
+                classLoaderConfiguration, providerClasspath, inprocClasspath, "org.asf.Provider" );
+
+        verify( mojo, times( 1 ) ).effectiveIsEnableAssertions();
+        verify( mojo, times( 1 ) ).isChildDelegation();
+        verifyPrivate( mojo, times( 1 ) ).invoke( "generateTestClasspath" );
+        verify( mojo, times( 1 ) ).getEffectiveForkCount();
+        verify( logger, times( 4 ) ).isDebugEnabled();
+        ArgumentCaptor<String> argument = ArgumentCaptor.forClass( String.class );
+        verify( logger, times( 4 ) ).debug( argument.capture() );
+        assertThat( argument.getAllValues() )
+                .containsExactly( "test classpath:  junit.jar  hamcrest.jar",
+                        "provider classpath:  surefire-provider.jar",
+                        "test(compact) classpath:  junit.jar  hamcrest.jar",
+                        "provider(compact) classpath:  surefire-provider.jar"
+                );
+
+        assertThat( conf.getClassLoaderConfiguration() )
+                .isSameAs( classLoaderConfiguration );
+
+        assertThat( ( Object ) conf.getClasspathConfiguration().getTestClasspath() )
+                .isSameAs( testClasspath );
+
+        assertThat( ( Object ) conf.getClasspathConfiguration().getProviderClasspath() )
+                .isSameAs( providerClasspath );
+
+        assertThat( ( Object ) conf.getClasspathConfiguration().isClassPathConfig() )
+                .isEqualTo( true );
+
+        assertThat( ( Object ) conf.getClasspathConfiguration().isModularPathConfig() )
+                .isEqualTo( false );
+
+        assertThat( ( Object ) conf.getClasspathConfiguration().isEnableAssertions() )
+                .isEqualTo( true );
+
+        assertThat( conf.getProviderClassName() )
+                .isEqualTo( "org.asf.Provider" );
+    }
+
+    @Test
+    public void shouldHaveStartupConfigForModularClasspath()
+            throws Exception
+    {
+        AbstractSurefireMojo mojo = spy( this.mojo );
+
+        Classpath testClasspath = new Classpath( asList( "non-modular.jar", "modular.jar",
+                "target" + separatorChar + "classes", "junit.jar", "hamcrest.jar" ) );
+
+        doReturn( testClasspath ).when( mojo, "generateTestClasspath" );
+        doReturn( 1 ).when( mojo, "getEffectiveForkCount" );
+        doReturn( true ).when( mojo, "effectiveIsEnableAssertions" );
+        when( mojo.isChildDelegation() ).thenReturn( false );
+        when( mojo.getTestClassesDirectory() ).thenReturn( new File( "target" + separatorChar + "test-classes" ) );
+
+        DefaultScanResult scanResult = mock( DefaultScanResult.class );
+        when( scanResult.getClasses() ).thenReturn( asList( "org.apache.A", "org.apache.B" ) );
+
+        ClassLoaderConfiguration classLoaderConfiguration = new ClassLoaderConfiguration( false, true );
+
+        Classpath providerClasspath = new Classpath( singleton( "surefire-provider.jar" ) );
+
+        File moduleInfo = new File( "target" + separatorChar + "classes" + separatorChar + "module-info.class" );
+
+        @SuppressWarnings( "unchecked" )
+        ResolvePathsRequest<String> req = mock( ResolvePathsRequest.class );
+        mockStatic( ResolvePathsRequest.class );
+        when( ResolvePathsRequest.withStrings( eq( testClasspath.getClassPath() ) ) ).thenReturn( req );
+        when( req.setMainModuleDescriptor( eq( moduleInfo.getAbsolutePath() ) ) ).thenReturn( req );
+
+        @SuppressWarnings( "unchecked" )
+        ResolvePathsResult<String> res = mock( ResolvePathsResult.class );
+        when( res.getClasspathElements() ).thenReturn( asList( "non-modular.jar", "junit.jar", "hamcrest.jar" ) );
+        Map<String, ModuleNameSource> mod = new LinkedHashMap<String, ModuleNameSource>();
+        mod.put( "modular.jar", null );
+        mod.put( "target" + separatorChar + "classes", null );
+        when( res.getModulepathElements() ).thenReturn( mod );
+        when( locationManager.resolvePaths( eq( req ) ) ).thenReturn( res );
+
+        Logger logger = mock( Logger.class );
+        when( logger.isDebugEnabled() ).thenReturn( true );
+        doNothing().when( logger ).debug( anyString() );
+        when( mojo.getConsoleLogger() ).thenReturn( new PluginConsoleLogger( logger ) );
+
+        StartupConfiguration conf = invokeMethod( mojo, "newStartupConfigForModularClasspath",
+                classLoaderConfiguration, providerClasspath, "org.asf.Provider", moduleInfo, scanResult );
+
+        verify( mojo, times( 1 ) ).effectiveIsEnableAssertions();
+        verify( mojo, times( 1 ) ).isChildDelegation();
+        verifyPrivate( mojo, times( 1 ) ).invoke( "generateTestClasspath" );
+        verify( mojo, times( 1 ) ).getEffectiveForkCount();
+        verify( mojo, times( 1 ) ).getTestClassesDirectory();
+        verify( scanResult, times( 1 ) ).getClasses();
+        verifyStatic( ResolvePathsRequest.class, times( 1 ) );
+        ResolvePathsRequest.withStrings( eq( testClasspath.getClassPath() ) );
+        verify( req, times( 1 ) ).setMainModuleDescriptor( eq( moduleInfo.getAbsolutePath() ) );
+        verify( res, times( 1 ) ).getClasspathElements();
+        verify( res, times( 1 ) ).getModulepathElements();
+        verify( locationManager, times( 1 ) ).resolvePaths( eq( req ) );
+        ArgumentCaptor<String> argument = ArgumentCaptor.forClass( String.class );
+        verify( logger, times( 6 ) ).debug( argument.capture() );
+        assertThat( argument.getAllValues() )
+                .containsExactly( "test classpath:  non-modular.jar  junit.jar  hamcrest.jar",
+                        "test modulepath:  modular.jar  target" + separatorChar + "classes",
+                        "provider classpath:  surefire-provider.jar",
+                        "test(compact) classpath:  non-modular.jar  junit.jar  hamcrest.jar",
+                        "test(compact) modulepath:  modular.jar  classes",
+                        "provider(compact) classpath:  surefire-provider.jar"
+                );
+
+        assertThat( conf ).isNotNull();
+        assertThat( conf.isShadefire() ).isFalse();
+        assertThat( conf.isProviderMainClass() ).isFalse();
+        assertThat( conf.isManifestOnlyJarRequestedAndUsable() ).isFalse();
+        assertThat( conf.getClassLoaderConfiguration() ).isSameAs( classLoaderConfiguration );
+        assertThat( conf.getProviderClassName() ).isEqualTo( "org.asf.Provider" );
+        assertThat( conf.getActualClassName() ).isEqualTo( "org.asf.Provider" );
+        assertThat( conf.getClasspathConfiguration() ).isNotNull();
+        assertThat( ( Object ) conf.getClasspathConfiguration().getTestClasspath() )
+                .isEqualTo( new Classpath( res.getClasspathElements() ) );
+        assertThat( ( Object ) conf.getClasspathConfiguration().getProviderClasspath() ).isSameAs( providerClasspath );
+        assertThat( conf.getClasspathConfiguration() ).isInstanceOf( ModularClasspathConfiguration.class );
+        ModularClasspathConfiguration mcc = ( ModularClasspathConfiguration ) conf.getClasspathConfiguration();
+        assertThat( mcc.getModularClasspath().getModuleDescriptor() ).isEqualTo( moduleInfo );
+        assertThat( mcc.getModularClasspath().getPackages() ).containsOnly( "org.apache" );
+        assertThat( mcc.getModularClasspath().getPatchFile() )
+                .isEqualTo( new File( "target" + separatorChar + "test-classes" ) );
+        assertThat( mcc.getModularClasspath().getModulePath() )
+                .containsExactly( "modular.jar", "target" + separatorChar + "classes" );
+        assertThat( ( Object ) mcc.getTestClasspath() ).isEqualTo( new Classpath( res.getClasspathElements() ) );
+    }
 
     @Test
     public void shouldHaveTmpDirectory() throws IOException
     {
         assumeTrue( isJavaVersionAtLeast( JAVA_1_7 ) );
 
-        Path path = (Path) AbstractSurefireMojo.createTmpDirectoryWithJava7( "surefire" );
+        Path path = ( Path ) AbstractSurefireMojo.createTmpDirectoryWithJava7( "surefire" );
 
         assertThat( path )
                 .isNotNull();
@@ -86,6 +365,7 @@ public class AbstractSurefireMojoTest
     @Test
     public void shouldExistTmpDirectory()
     {
+        AbstractSurefireMojo mojo = mock( AbstractSurefireMojo.class );
         when( mojo.getTempDir() ).thenReturn( "surefireX" );
         when( mojo.getProjectBuildDirectory() ).thenReturn( new File( System.getProperty( "user.dir" ), "target" ) );
         when( mojo.createSurefireBootDirectoryInTemp() ).thenCallRealMethod();
@@ -110,16 +390,363 @@ public class AbstractSurefireMojoTest
         assertThat( tmp ).isNotNull();
         assertThat( tmp ).exists();
         assertThat( tmp.getAbsolutePath() )
-              .startsWith( IS_OS_WINDOWS ? System.getProperty( "java.io.tmpdir" ) : System.getProperty( "user.dir" ) );
+                .startsWith(
+                        IS_OS_WINDOWS ? System.getProperty( "java.io.tmpdir" ) : System.getProperty( "user.dir" ) );
         if ( IS_OS_WINDOWS )
         {
             assertThat( tmp.getName() )
                     .startsWith( "surefireX" );
-        }
-        else
+        } else
         {
             assertThat( tmp.getName() )
                     .isEqualTo( "surefireX" );
         }
     }
+
+    public static class Mojo
+            extends AbstractSurefireMojo
+    {
+        @Override
+        protected String getPluginName()
+        {
+            return null;
+        }
+
+        @Override
+        protected int getRerunFailingTestsCount()
+        {
+            return 0;
+        }
+
+        @Override
+        public boolean isSkipTests()
+        {
+            return false;
+        }
+
+        @Override
+        public void setSkipTests( boolean skipTests )
+        {
+
+        }
+
+        @Override
+        public boolean isSkipExec()
+        {
+            return false;
+        }
+
+        @Override
+        public void setSkipExec( boolean skipExec )
+        {
+
+        }
+
+        @Override
+        public boolean isSkip()
+        {
+            return false;
+        }
+
+        @Override
+        public void setSkip( boolean skip )
+        {
+
+        }
+
+        @Override
+        public File getBasedir()
+        {
+            return null;
+        }
+
+        @Override
+        public void setBasedir( File basedir )
+        {
+
+        }
+
+        @Override
+        public File getTestClassesDirectory()
+        {
+            return null;
+        }
+
+        @Override
+        public void setTestClassesDirectory( File testClassesDirectory )
+        {
+
+        }
+
+        @Override
+        public File getClassesDirectory()
+        {
+            return null;
+        }
+
+        @Override
+        public void setClassesDirectory( File classesDirectory )
+        {
+
+        }
+
+        @Override
+        public File getReportsDirectory()
+        {
+            return null;
+        }
+
+        @Override
+        public void setReportsDirectory( File reportsDirectory )
+        {
+
+        }
+
+        @Override
+        public String getTest()
+        {
+            return null;
+        }
+
+        @Override
+        public void setTest( String test )
+        {
+
+        }
+
+        @Override
+        public List<String> getIncludes()
+        {
+            return null;
+        }
+
+        @Override
+        public File getIncludesFile()
+        {
+            return null;
+        }
+
+        @Override
+        public void setIncludes( List<String> includes )
+        {
+
+        }
+
+        @Override
+        public boolean isPrintSummary()
+        {
+            return false;
+        }
+
+        @Override
+        public void setPrintSummary( boolean printSummary )
+        {
+
+        }
+
+        @Override
+        public String getReportFormat()
+        {
+            return null;
+        }
+
+        @Override
+        public void setReportFormat( String reportFormat )
+        {
+
+        }
+
+        @Override
+        public boolean isUseFile()
+        {
+            return false;
+        }
+
+        @Override
+        public void setUseFile( boolean useFile )
+        {
+
+        }
+
+        @Override
+        public String getDebugForkedProcess()
+        {
+            return null;
+        }
+
+        @Override
+        public void setDebugForkedProcess( String debugForkedProcess )
+        {
+
+        }
+
+        @Override
+        public int getForkedProcessTimeoutInSeconds()
+        {
+            return 0;
+        }
+
+        @Override
+        public void setForkedProcessTimeoutInSeconds( int forkedProcessTimeoutInSeconds )
+        {
+
+        }
+
+        @Override
+        public int getForkedProcessExitTimeoutInSeconds()
+        {
+            return 0;
+        }
+
+        @Override
+        public void setForkedProcessExitTimeoutInSeconds( int forkedProcessTerminationTimeoutInSeconds )
+        {
+
+        }
+
+        @Override
+        public double getParallelTestsTimeoutInSeconds()
+        {
+            return 0;
+        }
+
+        @Override
+        public void setParallelTestsTimeoutInSeconds( double parallelTestsTimeoutInSeconds )
+        {
+
+        }
+
+        @Override
+        public double getParallelTestsTimeoutForcedInSeconds()
+        {
+            return 0;
+        }
+
+        @Override
+        public void setParallelTestsTimeoutForcedInSeconds( double parallelTestsTimeoutForcedInSeconds )
+        {
+
+        }
+
+        @Override
+        public boolean isUseSystemClassLoader()
+        {
+            return false;
+        }
+
+        @Override
+        public void setUseSystemClassLoader( boolean useSystemClassLoader )
+        {
+
+        }
+
+        @Override
+        public boolean isUseManifestOnlyJar()
+        {
+            return false;
+        }
+
+        @Override
+        public void setUseManifestOnlyJar( boolean useManifestOnlyJar )
+        {
+
+        }
+
+        @Override
+        public Boolean getFailIfNoSpecifiedTests()
+        {
+            return null;
+        }
+
+        @Override
+        public void setFailIfNoSpecifiedTests( boolean failIfNoSpecifiedTests )
+        {
+
+        }
+
+        @Override
+        public int getSkipAfterFailureCount()
+        {
+            return 0;
+        }
+
+        @Override
+        public String getShutdown()
+        {
+            return null;
+        }
+
+        @Override
+        public File getExcludesFile()
+        {
+            return null;
+        }
+
+        @Override
+        protected List<File> suiteXmlFiles()
+        {
+            return null;
+        }
+
+        @Override
+        protected boolean hasSuiteXmlFiles()
+        {
+            return false;
+        }
+
+        @Override
+        public File[] getSuiteXmlFiles()
+        {
+            return new File[0];
+        }
+
+        @Override
+        public void setSuiteXmlFiles( File[] suiteXmlFiles )
+        {
+
+        }
+
+        @Override
+        public String getRunOrder()
+        {
+            return null;
+        }
+
+        @Override
+        public void setRunOrder( String runOrder )
+        {
+
+        }
+
+        @Override
+        protected void handleSummary( RunResult summary, Exception firstForkException )
+                throws MojoExecutionException, MojoFailureException
+        {
+
+        }
+
+        @Override
+        protected boolean isSkipExecution()
+        {
+            return false;
+        }
+
+        @Override
+        protected String[] getDefaultIncludes()
+        {
+            return new String[0];
+        }
+
+        @Override
+        protected String getReportSchemaLocation()
+        {
+            return null;
+        }
+
+        @Override
+        protected Artifact getMojoArtifact()
+        {
+            return null;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
----------------------------------------------------------------------
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 035add0..fc00bcd 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
@@ -60,12 +60,14 @@ public class BooterDeserializerStartupConfigurationTest
     public void testClassPathConfiguration()
         throws IOException
     {
-        ClasspathConfiguration reloadedClasspathConfiguration =
+        AbstractPathConfiguration reloadedClasspathConfiguration =
             getReloadedStartupConfiguration().getClasspathConfiguration();
-        assertEquals( classpathConfiguration, reloadedClasspathConfiguration );
+
+        assertTrue( reloadedClasspathConfiguration instanceof ClasspathConfiguration );
+        assertCpConfigEquals( classpathConfiguration, (ClasspathConfiguration) reloadedClasspathConfiguration );
     }
 
-    private void assertEquals( ClasspathConfiguration expectedConfiguration,
+    private void assertCpConfigEquals( ClasspathConfiguration expectedConfiguration,
                                ClasspathConfiguration actualConfiguration )
     {
         assertEquals( expectedConfiguration.getTestClasspath().getClassPath(),

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java
new file mode 100644
index 0000000..d924aaf
--- /dev/null
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java
@@ -0,0 +1,295 @@
+package org.apache.maven.plugin.surefire.booterclient;
+
+/*
+ * 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.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.StartupConfiguration;
+import org.apache.maven.surefire.booter.SurefireBooterForkException;
+import org.fest.assertions.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.reflect.Whitebox;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import static java.util.Collections.singleton;
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.powermock.api.mockito.PowerMockito.*;
+import static org.powermock.reflect.Whitebox.invokeMethod;
+
+/**
+ * Unit tests for {@link DefaultForkConfiguration}.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.21
+ */
+@RunWith( PowerMockRunner.class )
+@PrepareForTest( DefaultForkConfiguration.class )
+public class DefaultForkConfigurationTest
+{
+    private Classpath booterClasspath;
+    private File tempDirectory;
+    private String debugLine;
+    private File workingDirectory;
+    private Properties modelProperties;
+    private String argLine;
+    private Map<String, String> environmentVariables;
+    private boolean debug;
+    private int forkCount;
+    private boolean reuseForks;
+    private Platform pluginPlatform;
+    private ConsoleLogger log;
+
+    @Before
+    public void setup()
+    {
+        booterClasspath = new Classpath( singleton( "provider.jar" ) );
+        tempDirectory = new File( "target/surefire" );
+        debugLine = "";
+        workingDirectory = new File( "." );
+        modelProperties = new Properties();
+        argLine = null;
+        environmentVariables = new HashMap<String, String>();
+        debug = true;
+        forkCount = 2;
+        reuseForks = true;
+        pluginPlatform = new Platform();
+        log = mock( ConsoleLogger.class );
+    }
+
+    @Test
+    public void shouldBeNullArgLine() throws Exception
+    {
+        DefaultForkConfiguration config = new DefaultForkConfiguration( booterClasspath, tempDirectory, debugLine,
+                workingDirectory, modelProperties, argLine, environmentVariables, debug, forkCount, reuseForks,
+                pluginPlatform, log )
+        {
+
+            @Override
+            protected void resolveClasspath( OutputStreamFlushableCommandline cli, String booterThatHasMainMethod,
+                                             StartupConfiguration config ) throws SurefireBooterForkException
+            {
+
+            }
+        };
+
+        DefaultForkConfiguration mockedConfig = spy( config );
+
+        //mockStatic( DefaultForkConfiguration.class );
+
+        //Method m = PowerMockito.method( DefaultForkConfiguration.class, "newJvmArgLine", int.class );
+        String newArgLine = invokeMethod( mockedConfig, "newJvmArgLine", new Class[] { int.class }, 2 );
+
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "interpolateArgLineWithPropertyExpressions" );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "extendJvmArgLine", eq( "" ) );
+        /*verifyStatic( DefaultForkConfiguration.class, times( 1 ) );
+        invokeMethod( mockedConfig.getClass(), "stripNewLines", "" );*/
+
+        assertThat( newArgLine ).isEmpty();
+        /*m.setAccessible( true );
+        m.invoke( config, 2 );*/
+    }
+
+    @Test
+    public void shouldBeEmptyArgLine() throws Exception
+    {
+        argLine = "";
+        DefaultForkConfiguration config = new DefaultForkConfiguration( booterClasspath, tempDirectory, debugLine,
+                workingDirectory, modelProperties, argLine, environmentVariables, debug, forkCount, reuseForks,
+                pluginPlatform, log )
+        {
+
+            @Override
+            protected void resolveClasspath( OutputStreamFlushableCommandline cli, String booterThatHasMainMethod,
+                                             StartupConfiguration config ) throws SurefireBooterForkException
+            {
+
+            }
+        };
+
+        DefaultForkConfiguration mockedConfig = spy( config );
+        String newArgLine = invokeMethod( mockedConfig, "newJvmArgLine", new Class[] { int.class }, 2 );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "interpolateArgLineWithPropertyExpressions" );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "extendJvmArgLine", eq( "" ) );
+        assertThat( newArgLine ).isEmpty();
+    }
+
+    @Test
+    public void shouldBeEmptyArgLineInsteadOfNewLines() throws Exception
+    {
+        argLine = "\n\r";
+        DefaultForkConfiguration config = new DefaultForkConfiguration( booterClasspath, tempDirectory, debugLine,
+                workingDirectory, modelProperties, argLine, environmentVariables, debug, forkCount, reuseForks,
+                pluginPlatform, log )
+        {
+
+            @Override
+            protected void resolveClasspath( OutputStreamFlushableCommandline cli, String booterThatHasMainMethod,
+                                             StartupConfiguration config ) throws SurefireBooterForkException
+            {
+
+            }
+        };
+
+        DefaultForkConfiguration mockedConfig = spy( config );
+        String newArgLine = invokeMethod( mockedConfig, "newJvmArgLine", new Class[] { int.class }, 2 );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "interpolateArgLineWithPropertyExpressions" );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "extendJvmArgLine", eq( "" ) );
+        assertThat( newArgLine ).isEmpty();
+    }
+
+    @Test
+    public void shouldBeWithoutEscaping() throws Exception
+    {
+        argLine = "-Dfile.encoding=UTF-8";
+        DefaultForkConfiguration config = new DefaultForkConfiguration( booterClasspath, tempDirectory, debugLine,
+                workingDirectory, modelProperties, argLine, environmentVariables, debug, forkCount, reuseForks,
+                pluginPlatform, log )
+        {
+
+            @Override
+            protected void resolveClasspath( OutputStreamFlushableCommandline cli, String booterThatHasMainMethod,
+                                             StartupConfiguration config ) throws SurefireBooterForkException
+            {
+
+            }
+        };
+
+        DefaultForkConfiguration mockedConfig = spy( config );
+        String newArgLine = invokeMethod( mockedConfig, "newJvmArgLine", new Class[] { int.class }, 2 );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "interpolateArgLineWithPropertyExpressions" );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "extendJvmArgLine", eq( "-Dfile.encoding=UTF-8" ) );
+        assertThat( newArgLine ).isEqualTo( "-Dfile.encoding=UTF-8" );
+    }
+
+    @Test
+    public void shouldBeWithEscaping() throws Exception
+    {
+        modelProperties.put( "encoding", "UTF-8" );
+        argLine = "-Dfile.encoding=@{encoding}";
+        DefaultForkConfiguration config = new DefaultForkConfiguration( booterClasspath, tempDirectory, debugLine,
+                workingDirectory, modelProperties, argLine, environmentVariables, debug, forkCount, reuseForks,
+                pluginPlatform, log )
+        {
+
+            @Override
+            protected void resolveClasspath( OutputStreamFlushableCommandline cli, String booterThatHasMainMethod,
+                                             StartupConfiguration config ) throws SurefireBooterForkException
+            {
+
+            }
+        };
+
+        DefaultForkConfiguration mockedConfig = spy( config );
+        String newArgLine = invokeMethod( mockedConfig, "newJvmArgLine", new Class[] { int.class }, 2 );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "interpolateArgLineWithPropertyExpressions" );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "extendJvmArgLine", eq( "-Dfile.encoding=UTF-8" ) );
+        assertThat( newArgLine ).isEqualTo( "-Dfile.encoding=UTF-8" );
+    }
+
+    @Test
+    public void shouldBeWhitespaceInsteadOfNewLines() throws Exception
+    {
+        argLine = "a\n\rb";
+        DefaultForkConfiguration config = new DefaultForkConfiguration( booterClasspath, tempDirectory, debugLine,
+                workingDirectory, modelProperties, argLine, environmentVariables, debug, forkCount, reuseForks,
+                pluginPlatform, log )
+        {
+
+            @Override
+            protected void resolveClasspath( OutputStreamFlushableCommandline cli, String booterThatHasMainMethod,
+                                             StartupConfiguration config ) throws SurefireBooterForkException
+            {
+
+            }
+        };
+
+        DefaultForkConfiguration mockedConfig = spy( config );
+        String newArgLine = invokeMethod( mockedConfig, "newJvmArgLine", new Class[] { int.class }, 2 );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "interpolateArgLineWithPropertyExpressions" );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "extendJvmArgLine", eq( "a  b" ) );
+        assertThat( newArgLine ).isEqualTo( "a  b" );
+    }
+
+    @Test
+    public void shouldEscapeThreadNumber() throws Exception
+    {
+        argLine = "-Dthread=${surefire.threadNumber}";
+        DefaultForkConfiguration config = new DefaultForkConfiguration( booterClasspath, tempDirectory, debugLine,
+                workingDirectory, modelProperties, argLine, environmentVariables, debug, forkCount, reuseForks,
+                pluginPlatform, log )
+        {
+
+            @Override
+            protected void resolveClasspath( OutputStreamFlushableCommandline cli, String booterThatHasMainMethod,
+                                             StartupConfiguration config ) throws SurefireBooterForkException
+            {
+
+            }
+        };
+
+        DefaultForkConfiguration mockedConfig = spy( config );
+        String newArgLine = invokeMethod( mockedConfig, "newJvmArgLine", new Class[] { int.class }, 2 );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "interpolateArgLineWithPropertyExpressions" );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "extendJvmArgLine", eq( "-Dthread=" + forkCount ) );
+        assertThat( newArgLine ).isEqualTo( "-Dthread=" + forkCount );
+    }
+
+    @Test
+    public void shouldEscapeForkNumber() throws Exception
+    {
+        argLine = "-Dthread=${surefire.forkNumber}";
+        DefaultForkConfiguration config = new DefaultForkConfiguration( booterClasspath, tempDirectory, debugLine,
+                workingDirectory, modelProperties, argLine, environmentVariables, debug, forkCount, reuseForks,
+                pluginPlatform, log )
+        {
+
+            @Override
+            protected void resolveClasspath( OutputStreamFlushableCommandline cli, String booterThatHasMainMethod,
+                                             StartupConfiguration config ) throws SurefireBooterForkException
+            {
+
+            }
+        };
+
+        DefaultForkConfiguration mockedConfig = spy( config );
+        String newArgLine = invokeMethod( mockedConfig, "newJvmArgLine", new Class[] { int.class }, 2 );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "interpolateArgLineWithPropertyExpressions" );
+        verifyPrivate( mockedConfig, times( 1 ) ).invoke( "extendJvmArgLine", eq( "-Dthread=" + forkCount ) );
+        assertThat( newArgLine ).isEqualTo( "-Dthread=" + forkCount );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
----------------------------------------------------------------------
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 b49e164..2d7f335 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
@@ -23,23 +23,31 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.SystemUtils;
 import org.apache.maven.plugin.surefire.JdkAttributes;
+import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
 import org.apache.maven.shared.utils.StringUtils;
 import org.apache.maven.shared.utils.cli.Commandline;
 import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.ClasspathConfiguration;
+import org.apache.maven.surefire.booter.StartupConfiguration;
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
 import org.junit.Test;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
+import java.util.List;
 import java.util.Properties;
 
+import static java.util.Collections.singletonList;
+import static org.apache.maven.surefire.booter.Classpath.emptyClasspath;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 public class ForkConfigurationTest
 {
+    private static final StartupConfiguration STARTUP_CONFIG = new StartupConfiguration( "", null, null, false, false );
+
     @Test
     public void testCreateCommandLine_UseSystemClassLoaderForkOnce_ShouldConstructManifestOnlyJar()
         throws IOException, SurefireBooterForkException
@@ -47,8 +55,11 @@ public class ForkConfigurationTest
         ForkConfiguration config = getForkConfiguration( (String) null );
         File cpElement = getTempClasspathFile();
 
-        Commandline cli =
-            config.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), true, false, null, 1 );
+        List<String> cp = singletonList( cpElement.getAbsolutePath() );
+        ClasspathConfiguration cpConfig = new ClasspathConfiguration( new Classpath( cp ), null, null, true, true );
+        StartupConfiguration startup = new StartupConfiguration( "", cpConfig, null, false, false );
+
+        Commandline cli = config.createCommandLine( startup, 1 );
 
         String line = StringUtils.join( cli.getCommandline(), " " );
         assertTrue( line.contains( "-jar" ) );
@@ -59,12 +70,14 @@ public class ForkConfigurationTest
         throws IOException, SurefireBooterForkException
     {
         // SUREFIRE-657
+        ForkConfiguration config = getForkConfiguration( "abc\ndef" );
         File cpElement = getTempClasspathFile();
-        ForkConfiguration forkConfiguration = getForkConfiguration( "abc\ndef" );
 
-        final Commandline commandLine =
-            forkConfiguration.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), false, false,
-                                                 null, 1 );
+        List<String> cp = singletonList( cpElement.getAbsolutePath() );
+        ClasspathConfiguration cpConfig = new ClasspathConfiguration( new Classpath( cp ), null, null, true, true );
+        StartupConfiguration startup = new StartupConfiguration( "", cpConfig, null, false, false );
+
+        Commandline commandLine = config.createCommandLine( startup, 1 );
         assertTrue( commandLine.toString().contains( "abc def" ) );
     }
 
@@ -80,13 +93,16 @@ public class ForkConfigurationTest
 
         File cwd = new File( baseDir, "fork_${surefire.forkNumber}" );
 
+        ClasspathConfiguration cpConfig = new ClasspathConfiguration( emptyClasspath(), null, null, true, true );
+        StartupConfiguration startup = new StartupConfiguration( "", cpConfig, null, false, false );
         ForkConfiguration config = getForkConfiguration( null, cwd.getCanonicalFile() );
-        Commandline commandLine = config.createCommandLine( Collections.<String>emptyList(), true, false, null, 1 );
+        Commandline commandLine = config.createCommandLine( startup, 1 );
 
         File forkDirectory = new File( baseDir, "fork_1" );
         forkDirectory.deleteOnExit();
-        assertTrue( forkDirectory.getCanonicalPath().equals(
-            commandLine.getShell().getWorkingDirectory().getCanonicalPath() ) );
+
+        String shellWorkDir = commandLine.getShell().getWorkingDirectory().getCanonicalPath();
+        assertEquals( shellWorkDir,  forkDirectory.getCanonicalPath() );
     }
 
     @Test
@@ -107,7 +123,7 @@ public class ForkConfigurationTest
 
         try
         {
-            config.createCommandLine( Collections.<String>emptyList(), true, false, null, 1 );
+            config.createCommandLine( STARTUP_CONFIG, 1 );
         }
         catch ( SurefireBooterForkException sbfe )
         {
@@ -137,7 +153,7 @@ public class ForkConfigurationTest
 
         try
         {
-            config.createCommandLine( Collections.<String>emptyList(), true, false, null, 1 );
+            config.createCommandLine( STARTUP_CONFIG, 1 );
         }
         catch ( SurefireBooterForkException sbfe )
         {
@@ -182,8 +198,18 @@ public class ForkConfigurationTest
     private static ForkConfiguration getForkConfiguration( String argLine, String jvm, File cwd )
         throws IOException
     {
-        return new ForkConfiguration( Classpath.emptyClasspath(), null, null, new JdkAttributes( jvm, false ),
-                                            cwd, new Properties(), argLine, null, false, 1, false, new Platform() );
+        Platform platform = new Platform().withJdkExecAttributesForTests( new JdkAttributes( jvm, false ) );
+        File tmpDir = File.createTempFile( "target", "surefire" );
+        tmpDir.delete();
+        tmpDir.mkdirs();
+        return new JarManifestForkConfiguration( emptyClasspath(), tmpDir, null,
+                cwd, new Properties(), argLine, Collections.<String, String>emptyMap(), false, 1, false,
+                platform, new NullConsoleLogger() );
+
+        /*
+        return new ClasspathForkConfiguration( emptyClasspath(), null, null,
+                cwd, new Properties(), argLine, null, false, 1, false, platform, new NullConsoleLogger() );
+                */
     }
 
     // based on http://stackoverflow.com/questions/2591083/getting-version-of-java-in-runtime

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
index aec256d..53d2f87 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
@@ -27,6 +27,7 @@ import org.apache.maven.plugin.surefire.SurefireReflectorTest;
 import org.apache.maven.plugin.surefire.SurefirePropertiesTest;
 import org.apache.maven.plugin.surefire.booterclient.BooterDeserializerProviderConfigurationTest;
 import org.apache.maven.plugin.surefire.booterclient.BooterDeserializerStartupConfigurationTest;
+import org.apache.maven.plugin.surefire.booterclient.DefaultForkConfigurationTest;
 import org.apache.maven.plugin.surefire.booterclient.ForkConfigurationTest;
 import org.apache.maven.plugin.surefire.booterclient.ForkingRunListenerTest;
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestLessInputStreamBuilderTest;
@@ -74,7 +75,8 @@ import org.junit.runners.Suite;
     SPITest.class,
     SurefireReflectorTest.class,
     SurefireHelperTest.class,
-    AbstractSurefireMojoTest.class
+    AbstractSurefireMojoTest.class,
+    DefaultForkConfigurationTest.class
 } )
 @RunWith( Suite.class )
 public class JUnit4SuiteTest

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/RelocatorTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/RelocatorTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/RelocatorTest.java
index 3cec846..4d5951a 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/RelocatorTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/RelocatorTest.java
@@ -32,15 +32,13 @@ public class RelocatorTest
 
     public void testFoo()
     {
-        Relocator relocator = new Relocator( "shadefire" );
         String cn = "org.apache.maven.surefire.report.ForkingConsoleReporter";
-        assertEquals( "org.apache.maven.surefire.shadefire.report.ForkingConsoleReporter", relocator.relocate( cn ) );
+        assertEquals( "org.apache.maven.surefire.shadefire.report.ForkingConsoleReporter", Relocator.relocate( cn ) );
     }
 
     public void testRelocation()
     {
-        Relocator relocator = new Relocator( "shadefire" );
         String org1 = "org.apache.maven.surefire.fooz.Baz";
-        assertEquals( "org.apache.maven.surefire.shadefire.fooz.Baz", relocator.relocate( org1 ) );
+        assertEquals( "org.apache.maven.surefire.shadefire.fooz.Baz", Relocator.relocate( org1 ) );
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java b/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java
index 5fa6df0..4cbbf00 100644
--- a/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java
+++ b/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java
@@ -20,7 +20,6 @@ package org.apache.maven.plugin.surefire;
 
 
 import java.lang.reflect.Field;
-import org.apache.maven.plugin.surefire.booterclient.ForkConfiguration;
 import org.apache.maven.toolchain.Toolchain;
 
 import junit.framework.TestCase;
@@ -35,7 +34,7 @@ public class SurefirePluginTest
         SurefirePlugin surefirePlugin = new SurefirePlugin();
         setFieldValue( surefirePlugin, "toolchain", new MyToolChain() );
         setFieldValue( surefirePlugin, "forkMode", "never" );
-        assertEquals( ForkConfiguration.FORK_ONCE, surefirePlugin.getEffectiveForkMode() );
+        assertEquals( "once", surefirePlugin.getEffectiveForkMode() );
     }
 
     public void testForkCountComputation()

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d73b4b5..34a0b9c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,7 +88,7 @@
   <properties>
     <mavenVersion>2.2.1</mavenVersion>
     <!-- <shadedVersion>2.12.4</shadedVersion> commented out due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
-    <mavenPluginPluginVersion>3.3</mavenPluginPluginVersion>
+    <mavenPluginPluginVersion>3.5</mavenPluginPluginVersion>
     <commonsLang3Version>3.5</commonsLang3Version>
     <commonsIoVersion>2.5</commonsIoVersion>
     <mavenSharedUtilsVersion>0.9</mavenSharedUtilsVersion>
@@ -234,10 +234,31 @@
       </dependency>
       <dependency>
         <groupId>org.apache.maven.shared</groupId>
+        <artifactId>maven-common-artifact-filters</artifactId>
+        <version>1.3</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.apache.maven.shared</groupId>
+            <artifactId>maven-plugin-testing-harness</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.fusesource.jansi</groupId>
+        <artifactId>jansi</artifactId>
+        <version>1.13</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven.shared</groupId>
         <artifactId>maven-verifier</artifactId>
         <version>1.6</version>
       </dependency>
       <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-java</artifactId>
+        <version>0.9.3</version>
+      </dependency>
+      <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-core</artifactId>
         <version>2.10.0</version>
@@ -387,15 +408,23 @@
               <goals>
                 <goal>check</goal>
               </goals>
+              <configuration>
+                <signature>
+                  <groupId>org.codehaus.mojo.signature</groupId>
+                  <artifactId>java16</artifactId>
+                  <version>1.1</version>
+                </signature>
+                <excludeDependencies>
+                  <param>org.codehaus.plexus:plexus-java</param>
+                  <param>org.ow2.asm:asm</param>
+                </excludeDependencies>
+                <ignores>
+                  <param>org.objectweb.asm.*</param>
+                  <param>org.codehaus.plexus.languages.java.jpms.*</param>
+                </ignores>
+              </configuration>
             </execution>
           </executions>
-          <configuration>
-            <signature>
-              <groupId>org.codehaus.mojo.signature</groupId>
-              <artifactId>java16</artifactId>
-              <version>1.1</version>
-            </signature>
-          </configuration>
         </plugin>
         <plugin>
           <artifactId>maven-surefire-plugin</artifactId>
@@ -416,7 +445,7 @@
         </plugin>
         <plugin>
           <artifactId>maven-shade-plugin</artifactId>
-          <version>3.0.0</version>
+          <version>3.1.0</version>
         </plugin>
         <plugin>
           <artifactId>maven-plugin-plugin</artifactId>
@@ -483,6 +512,24 @@
               </rules>
             </configuration>
           </execution>
+          <execution>
+            <id>enforce-bytecode-version</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <enforceBytecodeVersion>
+                  <maxJdkVersion>${maven.compiler.target}</maxJdkVersion>
+                  <excludes>
+                    <exclude>org.codehaus.plexus:plexus-java</exclude>
+                    <exclude>org.ow2.asm:asm</exclude>
+                  </excludes>
+                </enforceBytecodeVersion>
+              </rules>
+              <fail>true</fail>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
       <plugin>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
index a00a3b5..db04a35 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
@@ -32,33 +32,33 @@ import java.util.Set;
 public class DefaultScanResult
     implements ScanResult
 {
-    private final List<String> files;
+    private final List<String> classes;
 
     private static final String SCAN_RESULT_NUMBER = "tc.";
 
-    public DefaultScanResult( List<String> files )
+    public DefaultScanResult( List<String> classes )
     {
-        this.files = Collections.unmodifiableList( files );
+        this.classes = Collections.unmodifiableList( classes );
     }
 
     @Override
     public int size()
     {
-        return files.size();
+        return classes.size();
     }
 
     @Override
     public String getClassName( int index )
     {
-        return files.get( index );
+        return classes.get( index );
     }
 
     @Override
     public void writeTo( Map<String, String> properties )
     {
-        for ( int i = 0, size = files.size(); i < size; i++ )
+        for ( int i = 0, size = classes.size(); i < size; i++ )
         {
-            properties.put( SCAN_RESULT_NUMBER + i, files.get( i ) );
+            properties.put( SCAN_RESULT_NUMBER + i, classes.get( i ) );
         }
     }
 
@@ -79,12 +79,12 @@ public class DefaultScanResult
 
     public boolean isEmpty()
     {
-        return files.isEmpty();
+        return classes.isEmpty();
     }
 
-    public List getFiles()
+    public List<String> getClasses()
     {
-        return files;
+        return classes;
     }
 
     @Override
@@ -145,8 +145,8 @@ public class DefaultScanResult
     {
         if ( other != null )
         {
-            List<String> src = new ArrayList<String>( files );
-            src.addAll( other.files );
+            List<String> src = new ArrayList<String>( classes );
+            src.addAll( other.classes );
             return new DefaultScanResult( src );
         }
         else

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/surefire-api/src/test/java/org/apache/maven/surefire/util/ScanResultTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/ScanResultTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/ScanResultTest.java
index 02c2d22..c5fd85f 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/ScanResultTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/ScanResultTest.java
@@ -41,9 +41,9 @@ public class ScanResultTest
         scanResult.writeTo( serialized );
 
         DefaultScanResult read = DefaultScanResult.from( serialized );
-        List files1 = read.getFiles();
-        assertEquals( 2, files1.size() );
-        assertTrue( files1.contains( "abc" ) );
-        assertTrue( files1.contains( "cde" ) );
+        List classes = read.getClasses();
+        assertEquals( 2, classes.size() );
+        assertTrue( classes.contains( "abc" ) );
+        assertTrue( classes.contains( "cde" ) );
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/AbstractPathConfiguration.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/AbstractPathConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/AbstractPathConfiguration.java
new file mode 100644
index 0000000..5f0b67e
--- /dev/null
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/AbstractPathConfiguration.java
@@ -0,0 +1,115 @@
+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 static org.apache.maven.surefire.booter.Classpath.emptyClasspath;
+import static org.apache.maven.surefire.booter.Classpath.join;
+
+/**
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.21.0.Jigsaw
+ */
+public abstract class AbstractPathConfiguration
+{
+    public static final String CHILD_DELEGATION = "childDelegation";
+
+    public static final String ENABLE_ASSERTIONS = "enableAssertions";
+
+    public static final String CLASSPATH = "classPathUrl.";
+
+    public static final String SUREFIRE_CLASSPATH = "surefireClassPathUrl.";
+
+    private final Classpath surefireClasspathUrls;
+
+    /**
+     * Whether to enable assertions or not
+     * (can be affected by the fork arguments, and the ability to do so based on the JVM).
+     */
+    private final boolean enableAssertions;
+
+    // todo: @deprecated because the IsolatedClassLoader is really isolated - no parent.
+    private final boolean childDelegation;
+
+    protected AbstractPathConfiguration( Classpath surefireClasspathUrls,
+                                         boolean enableAssertions, boolean childDelegation )
+    {
+        if ( !( isClassPathConfig() ^ isModularPathConfig() ) )
+        {
+            throw new IllegalStateException( "modular path and class path should be exclusive" );
+        }
+        this.surefireClasspathUrls = surefireClasspathUrls;
+        this.enableAssertions = enableAssertions;
+        this.childDelegation = childDelegation;
+    }
+
+    public abstract Classpath getTestClasspath();
+
+    /**
+     * Must be exclusive with {@link #isClassPathConfig()}.
+     *
+     * @return {@code true} if <tt>this</tt> is {@link ModularClasspathConfiguration}.
+     */
+    public abstract boolean isModularPathConfig();
+
+    /**
+     * Must be exclusive with {@link #isModularPathConfig()}.
+     *
+     * @return {@code true} if <tt>this</tt> is {@link ClasspathConfiguration}.
+     */
+    public abstract boolean isClassPathConfig();
+
+    protected Classpath getInprocClasspath()
+    {
+        return emptyClasspath();
+    }
+
+    public <T extends AbstractPathConfiguration> T toRealPath( Class<T> type )
+    {
+        if ( isClassPathConfig() && type == ClasspathConfiguration.class
+                || isModularPathConfig() && type == ModularClasspathConfiguration.class )
+        {
+            return type.cast( this );
+        }
+        throw new IllegalStateException( "no target matched " + type );
+    }
+
+    public ClassLoader createMergedClassLoader()
+            throws SurefireExecutionException
+    {
+        return join( getInprocClasspath(), getTestClasspath() )
+                .createClassLoader( isChildDelegation(), isEnableAssertions(), "test" );
+    }
+
+    public Classpath getProviderClasspath()
+    {
+        return surefireClasspathUrls;
+    }
+
+    public boolean isEnableAssertions()
+    {
+        return enableAssertions;
+    }
+
+    @Deprecated
+    public boolean isChildDelegation()
+    {
+        return childDelegation;
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
index 7b22712..bcbed4f 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
@@ -191,34 +191,25 @@ public class Classpath implements Iterable<String>
 
     public String getLogMessage( String descriptor )
     {
-        StringBuilder result = new StringBuilder();
-        result.append( descriptor ).append( " classpath:" );
+        StringBuilder result = new StringBuilder( descriptor );
         for ( String element : unmodifiableElements )
         {
-            result.append( "  " ).append( element );
+            result.append( "  " )
+                    .append( element );
         }
         return result.toString();
     }
 
     public String getCompactLogMessage( String descriptor )
     {
-        StringBuilder result = new StringBuilder();
-        result.append( descriptor ).append( " classpath:" );
+        StringBuilder result = new StringBuilder( descriptor );
         for ( String element : unmodifiableElements )
         {
             result.append( "  " );
             if ( element != null )
             {
                 int pos = element.lastIndexOf( File.separatorChar );
-                if ( pos >= 0 )
-                {
-                    result.append( element.substring( pos + 1 ) );
-                }
-                else
-                {
-                    result.append( element );
-                }
-
+                result.append( pos == -1 ? element : element.substring( pos + 1 ) );
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
index 0e84315..a288f2a 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
@@ -19,6 +19,8 @@ package org.apache.maven.surefire.booter;
  * under the License.
  */
 
+import static org.apache.maven.surefire.booter.Classpath.emptyClasspath;
+
 /**
  * Represents the classpaths for the BooterConfiguration.
  * <br>
@@ -27,88 +29,61 @@ package org.apache.maven.surefire.booter;
  * @author Emmanuel Venisse
  * @author Kristian Rosenvold
  */
-public class ClasspathConfiguration
+public class ClasspathConfiguration extends AbstractPathConfiguration
 {
-    public static final String CHILD_DELEGATION = "childDelegation";
-
-    public static final String ENABLE_ASSERTIONS = "enableAssertions";
-
-    public static final String CLASSPATH = "classPathUrl.";
-
-    public static final String SUREFIRE_CLASSPATH = "surefireClassPathUrl.";
-
-    private final Classpath classpathUrls;
-
-    private final Classpath surefireClasspathUrls;
+    private final Classpath testClasspathUrls;
 
     /**
      * The surefire classpath to use when invoking in-process with the plugin
      */
     private final Classpath inprocClasspath;
 
-    /**
-     * Whether to enable assertions or not (can be affected by the fork arguments, and the ability to do so based on the
-     * JVM).
-     */
-    private final boolean enableAssertions;
-
-    // todo: @deprecated because the IsolatedClassLoader is really isolated - no parent.
-    private final boolean childDelegation;
-
     public ClasspathConfiguration( boolean enableAssertions, boolean childDelegation )
     {
-        this( Classpath.emptyClasspath(), Classpath.emptyClasspath(), Classpath.emptyClasspath(), enableAssertions,
-              childDelegation );
+        this( emptyClasspath(), emptyClasspath(), emptyClasspath(), enableAssertions, childDelegation );
     }
 
     ClasspathConfiguration( PropertiesWrapper properties )
     {
-        this( properties.getClasspath( CLASSPATH ), properties.getClasspath( SUREFIRE_CLASSPATH ),
-              Classpath.emptyClasspath(),
+        this( properties.getClasspath( CLASSPATH ), properties.getClasspath( SUREFIRE_CLASSPATH ), emptyClasspath(),
               properties.getBooleanProperty( ENABLE_ASSERTIONS ), properties.getBooleanProperty( CHILD_DELEGATION ) );
     }
 
-    public ClasspathConfiguration( Classpath testClasspath, Classpath surefireClassPathUrls, Classpath inprocClasspath,
-                                   boolean enableAssertions, boolean childDelegation )
+    public ClasspathConfiguration( Classpath testClasspathUrls, Classpath surefireClassPathUrls,
+                                   Classpath inprocClasspath, boolean enableAssertions, boolean childDelegation )
     {
-        this.enableAssertions = enableAssertions;
-        this.childDelegation = childDelegation;
+        super( surefireClassPathUrls, enableAssertions, childDelegation );
+        this.testClasspathUrls = testClasspathUrls;
         this.inprocClasspath = inprocClasspath;
-        this.classpathUrls = testClasspath;
-        this.surefireClasspathUrls = surefireClassPathUrls;
-    }
-
-    public ClassLoader createMergedClassLoader()
-        throws SurefireExecutionException
-    {
-        return Classpath.join( inprocClasspath, classpathUrls )
-            .createClassLoader( childDelegation, enableAssertions, "test" );
     }
 
-    public Classpath getProviderClasspath()
+    @Override
+    protected Classpath getInprocClasspath()
     {
-        return surefireClasspathUrls;
+        return inprocClasspath;
     }
 
     public Classpath getTestClasspath()
     {
-        return classpathUrls;
+        return testClasspathUrls;
     }
 
-    public void trickClassPathWhenManifestOnlyClasspath()
-        throws SurefireExecutionException
+    @Override
+    public final boolean isModularPathConfig()
     {
-            System.setProperty( "surefire.real.class.path", System.getProperty( "java.class.path" ) );
-            getTestClasspath().writeToSystemProperty( "java.class.path" );
+        return !isClassPathConfig();
     }
 
-    public boolean isEnableAssertions()
+    @Override
+    public final boolean isClassPathConfig()
     {
-        return enableAssertions;
+        return true;
     }
 
-    public boolean isChildDelegation()
+    public void trickClassPathWhenManifestOnlyClasspath()
+        throws SurefireExecutionException
     {
-        return childDelegation;
+        System.setProperty( "surefire.real.class.path", System.getProperty( "java.class.path" ) );
+        getTestClasspath().writeToSystemProperty( "java.class.path" );
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/17eb9a3b/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()


Mime
View raw message