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

sor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/master by this push:
     new 242c0e8  [SUREFIRE-1564] Can't override platform version through 
project/plugin dependencies
242c0e8 is described below

commit 242c0e8a70be5a2a839ab00062c645f0d7b81137
Author: Christian Stein <sormu...@gmail.com>
AuthorDate: Fri Sep 14 05:51:56 2018 +0200

    [SUREFIRE-1564] Can't override platform version through project/plugin 
dependencies
---
 .../plugin/surefire/AbstractSurefireMojo.java      | 220 +++++++++------------
 .../maven/plugin/surefire/ClasspathCache.java      |  17 ++
 .../apache/maven/plugin/surefire/ProviderInfo.java |  10 +-
 .../surefire/SurefireDependencyResolver.java       |  64 +++---
 .../maven/plugin/surefire/TestClassPath.java       | 111 +++++++++++
 .../AbstractSurefireMojoJava7PlusTest.java         |  74 +++++--
 .../plugin/surefire/AbstractSurefireMojoTest.java  | 172 +++++++++++++---
 .../apache/maven/surefire/booter/Classpath.java    |   8 +-
 .../surefire/booter/ClasspathConfiguration.java    |   1 -
 .../apache/maven/surefire/booter/ForkedBooter.java |   2 +-
 .../maven/surefire/its/JUnitPlatformEnginesIT.java | 160 +++++++++++++++
 .../apache/maven/surefire/its/JUnitPlatformIT.java |  48 ++---
 .../apache/maven/surefire/its/fixture/IsRegex.java | 100 ++++++++++
 .../surefire/its/fixture/OutputValidator.java      |  29 +--
 .../Surefire1082ParallelJUnitParameterizedIT.java  |  61 +-----
 .../test/resources/junit-platform-1.1.1/pom.xml    |  60 ------
 .../JUnitPlatform_1_1_1_Test.java                  |  37 ----
 .../test/resources/junit-platform-1.2.0/pom.xml    |  60 ------
 .../JUnitPlatform_1_2_0_Test.java                  |  37 ----
 .../pom.xml                                        |  17 +-
 .../java/junitplatform/JUnitPlatformTest.java}     |   5 +-
 surefire-providers/surefire-junit-platform/pom.xml |   4 +-
 .../junitplatform/RunListenerAdapterTest.java      |   5 +-
 .../junitplatform/TestMethodFilterTest.java        |   5 +-
 24 files changed, 786 insertions(+), 521 deletions(-)

diff --git 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index fa4f257..4253b8c 100644
--- 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -761,6 +761,7 @@ public abstract class AbstractSurefireMojo
     private ToolchainManager toolchainManager;
 
     // todo use in 3.0.0 with java 1.7 and substitute new LocationManager() 
with component in underneath code
+    // todo exclusions of plexus-java not needed in pom.xml - see the 
m-enforcer-p
     // @Component
     // private LocationManager locationManager;
 
@@ -1712,88 +1713,112 @@ public abstract class AbstractSurefireMojo
     private StartupConfiguration createStartupConfiguration( @Nonnull 
ProviderInfo provider, boolean isInprocess,
                                                              @Nonnull 
ClassLoaderConfiguration classLoaderConfiguration,
                                                              @Nonnull 
DefaultScanResult scanResult )
-        throws MojoExecutionException, MojoFailureException
+        throws MojoExecutionException
     {
         try
         {
-            // cache the provider lookup
-            String providerName = provider.getProviderName();
-            Classpath providerClasspath = ClasspathCache.getCachedClassPath( 
providerName );
-            if ( providerClasspath == null )
-            {
-                // todo: 100 milli seconds, try to fetch List<String> within 
classpath asynchronously
-                providerClasspath = provider.getProviderClasspath();
-                ClasspathCache.setCachedClasspath( providerName, 
providerClasspath );
-            }
-            Artifact surefireArtifact = getCommonArtifact();
-            Classpath inprocClassPath =
-                    providerClasspath.addClassPathElementUrl( 
surefireArtifact.getFile().getAbsolutePath() )
-                            .addClassPathElementUrl( 
getApiArtifact().getFile().getAbsolutePath() );
-
             File moduleDescriptor = getModuleDescriptor();
-
+            Set<Artifact> providerArtifacts = provider.getProviderClasspath();
+            String providerName = provider.getProviderName();
             if ( moduleDescriptor.exists() && !isInprocess )
             {
-                return newStartupConfigForModularClasspath( 
classLoaderConfiguration, providerClasspath, providerName,
+                return newStartupConfigWithModularPath( 
classLoaderConfiguration, providerArtifacts, providerName,
                         moduleDescriptor, scanResult );
             }
             else
             {
-                return newStartupConfigForNonModularClasspath( 
classLoaderConfiguration, providerClasspath,
-                        inprocClassPath, providerName );
+                return newStartupConfigWithClasspath( 
classLoaderConfiguration, providerArtifacts, providerName );
             }
         }
         catch ( AbstractArtifactResolutionException e )
         {
             throw new MojoExecutionException( "Unable to generate classpath: " 
+ e, e );
         }
-        catch ( InvalidVersionSpecificationException e )
-        {
-            throw new MojoExecutionException( "Unable to generate classpath: " 
+ e, e );
-        }
         catch ( IOException e )
         {
             throw new MojoExecutionException( e.getMessage(), e );
         }
     }
 
-    private StartupConfiguration newStartupConfigForNonModularClasspath(
-            @Nonnull ClassLoaderConfiguration classLoaderConfiguration, 
@Nonnull Classpath providerClasspath,
-            @Nonnull Classpath inprocClasspath, @Nonnull String providerName )
-            throws MojoExecutionException, MojoFailureException, 
InvalidVersionSpecificationException,
-            AbstractArtifactResolutionException
+    private StartupConfiguration newStartupConfigWithClasspath(
+            @Nonnull ClassLoaderConfiguration classLoaderConfiguration, 
@Nonnull Set<Artifact> providerArtifacts,
+            @Nonnull String providerName )
     {
-        Classpath testClasspath = generateTestClasspath();
+        TestClassPath testClasspathWrapper = generateTestClasspath();
+        Classpath testClasspath = testClasspathWrapper.toClasspath();
+
+        testClasspathWrapper.avoidArtifactDuplicates( providerArtifacts );
+
+        Classpath providerClasspath = ClasspathCache.getCachedClassPath( 
providerName );
+        if ( providerClasspath == null )
+        {
+            providerClasspath = ClasspathCache.setCachedClasspath( 
providerName, providerArtifacts );
+        }
 
         getConsoleLogger().debug( testClasspath.getLogMessage( "test 
classpath:" ) );
         getConsoleLogger().debug( providerClasspath.getLogMessage( "provider 
classpath:" ) );
         getConsoleLogger().debug( testClasspath.getCompactLogMessage( 
"test(compact) classpath:" ) );
         getConsoleLogger().debug( providerClasspath.getCompactLogMessage( 
"provider(compact) classpath:" ) );
 
+        Artifact[] additionalInProcArtifacts = { getCommonArtifact(), 
getApiArtifact() };
+        Set<Artifact> inProcArtifacts = retainInProcArtifactsUnique( 
providerArtifacts, additionalInProcArtifacts );
+        Classpath inProcClasspath = createInProcClasspath( providerClasspath, 
inProcArtifacts );
+        getConsoleLogger().debug( inProcClasspath.getLogMessage( "in-process 
classpath:" ) );
+        getConsoleLogger().debug( inProcClasspath.getCompactLogMessage( 
"in-process(compact) classpath:" ) );
+
         ClasspathConfiguration classpathConfiguration = new 
ClasspathConfiguration( testClasspath, providerClasspath,
-                inprocClasspath, effectiveIsEnableAssertions(), 
isChildDelegation() );
+                inProcClasspath, effectiveIsEnableAssertions(), 
isChildDelegation() );
 
         return new StartupConfiguration( providerName, classpathConfiguration, 
classLoaderConfiguration, isForking(),
                 false );
     }
 
+    private static Set<Artifact> retainInProcArtifactsUnique( Set<Artifact> 
providerArtifacts,
+                                                         Artifact... 
inPluginArtifacts )
+    {
+        Set<Artifact> result = new LinkedHashSet<Artifact>();
+        addAll( result, inPluginArtifacts );
+        result.removeAll( providerArtifacts );
+        return result;
+    }
+
+    private static Classpath createInProcClasspath( Classpath 
providerClasspath, Set<Artifact> newArtifacts )
+    {
+        Classpath inprocClasspath = providerClasspath.clone();
+        for ( Artifact newArtifact : newArtifacts )
+        {
+            inprocClasspath = inprocClasspath.addClassPathElementUrl( 
newArtifact.getFile().getAbsolutePath() );
+        }
+        return inprocClasspath;
+    }
+
     private Object getLocationManager()
     {
         return new LocationManager();
     }
 
-    private StartupConfiguration newStartupConfigForModularClasspath(
-            @Nonnull ClassLoaderConfiguration classLoaderConfiguration, 
@Nonnull Classpath providerClasspath,
+    private StartupConfiguration newStartupConfigWithModularPath(
+            @Nonnull ClassLoaderConfiguration classLoaderConfiguration, 
@Nonnull Set<Artifact> providerArtifacts,
             @Nonnull String providerName, @Nonnull File moduleDescriptor, 
@Nonnull DefaultScanResult scanResult )
-            throws MojoExecutionException, MojoFailureException, 
InvalidVersionSpecificationException,
-            AbstractArtifactResolutionException, IOException
+            throws IOException
     {
-        ResolvePathsRequest<String> req = ResolvePathsRequest.withStrings( 
generateTestClasspath().getClassPath() )
+        TestClassPath testClasspathWrapper = generateTestClasspath();
+        Classpath testClasspath = testClasspathWrapper.toClasspath();
+
+        testClasspathWrapper.avoidArtifactDuplicates( providerArtifacts );
+
+        Classpath providerClasspath = ClasspathCache.getCachedClassPath( 
providerName );
+        if ( providerClasspath == null )
+        {
+            providerClasspath = ClasspathCache.setCachedClasspath( 
providerName, providerArtifacts );
+        }
+
+        ResolvePathsRequest<String> req = ResolvePathsRequest.ofStrings( 
testClasspath.getClassPath() )
                 .setMainModuleDescriptor( moduleDescriptor.getAbsolutePath() );
 
         ResolvePathsResult<String> result = ( (LocationManager) 
getLocationManager() ).resolvePaths( req );
 
-        Classpath testClasspath = new Classpath( result.getClasspathElements() 
);
+        testClasspath = new Classpath( result.getClasspathElements() );
         Classpath testModulepath = new Classpath( 
result.getModulepathElements().keySet() );
 
         SortedSet<String> packages = new TreeSet<String>();
@@ -2094,13 +2119,13 @@ public abstract class AbstractSurefireMojo
     }
 
     private InPluginVMSurefireStarter createInprocessStarter( @Nonnull 
ProviderInfo provider,
-                                                             @Nonnull 
ClassLoaderConfiguration classLoaderConfiguration,
+                                                              @Nonnull 
ClassLoaderConfiguration classLoaderConfig,
                                                               @Nonnull 
RunOrderParameters runOrderParameters,
                                                               @Nonnull 
DefaultScanResult scanResult )
         throws MojoExecutionException, MojoFailureException
     {
         StartupConfiguration startupConfiguration =
-                createStartupConfiguration( provider, true, 
classLoaderConfiguration, scanResult );
+                createStartupConfiguration( provider, true, classLoaderConfig, 
scanResult );
         String configChecksum = getConfigChecksum();
         StartupReportConfiguration startupReportConfiguration = 
getStartupReportConfiguration( configChecksum, false );
         ProviderConfiguration providerConfiguration = 
createProviderConfiguration( runOrderParameters );
@@ -2425,25 +2450,12 @@ public abstract class AbstractSurefireMojo
     }
 
     /**
-     * Generate the test classpath.
+     * Generates the test classpath.
      *
-     * @return List containing the classpath elements
-     * @throws InvalidVersionSpecificationException
-     *                                     when it happens
-     * @throws MojoFailureException        when it happens
-     * @throws ArtifactNotFoundException   when it happens
-     * @throws ArtifactResolutionException when it happens
+     * @return the classpath elements
      */
-    private Classpath generateTestClasspath()
-        throws InvalidVersionSpecificationException, MojoFailureException, 
ArtifactResolutionException,
-        ArtifactNotFoundException, MojoExecutionException
+    private TestClassPath generateTestClasspath()
     {
-        List<String> classpath = new ArrayList<String>( 2 + 
getProject().getArtifacts().size() );
-
-        classpath.add( getTestClassesDirectory().getAbsolutePath() );
-
-        classpath.add( getClassesDirectory().getAbsolutePath() );
-
         @SuppressWarnings( "unchecked" ) Set<Artifact> classpathArtifacts = 
getProject().getArtifacts();
 
         if ( getClasspathDependencyScopeExclude() != null && 
!getClasspathDependencyScopeExclude().isEmpty() )
@@ -2459,61 +2471,8 @@ public abstract class AbstractSurefireMojo
             classpathArtifacts = filterArtifacts( classpathArtifacts, 
dependencyFilter );
         }
 
-        for ( Artifact artifact : classpathArtifacts )
-        {
-            if ( artifact.getArtifactHandler().isAddedToClasspath() )
-            {
-                File file = artifact.getFile();
-                if ( file != null )
-                {
-                    classpath.add( file.getPath() );
-                }
-            }
-        }
-
-        // Add additional configured elements to the classpath
-        if ( getAdditionalClasspathElements() != null )
-        {
-            for ( String classpathElement : getAdditionalClasspathElements() )
-            {
-                if ( classpathElement != null )
-                {
-                    addAll( classpath, split( classpathElement, "," ) );
-                }
-            }
-        }
-
-        // adding TestNG MethodSelector to the classpath
-        // Todo: move
-        if ( getTestNgArtifact() != null )
-        {
-            addTestNgUtilsArtifacts( classpath );
-        }
-
-        return new Classpath( classpath );
-    }
-
-    private void addTestNgUtilsArtifacts( List<String> classpath )
-        throws ArtifactResolutionException, ArtifactNotFoundException
-    {
-        Artifact surefireArtifact = getPluginArtifactMap().get( 
"org.apache.maven.surefire:surefire-booter" );
-        String surefireVersion = surefireArtifact.getBaseVersion();
-
-        Artifact[] extraTestNgArtifacts = {
-            getArtifactFactory().createArtifact( "org.apache.maven.surefire", 
"surefire-testng-utils", surefireVersion,
-                                                 "runtime", "jar" ),
-
-            getArtifactFactory().createArtifact( "org.apache.maven.surefire", 
"surefire-grouper", surefireVersion,
-                                                 "runtime", "jar" )
-        };
-
-        for ( Artifact artifact : extraTestNgArtifacts )
-        {
-            getArtifactResolver().resolve( artifact, getRemoteRepositories(), 
getLocalRepository() );
-
-            String path = artifact.getFile().getPath();
-            classpath.add( path );
-        }
+        return new TestClassPath( classpathArtifacts, getClassesDirectory(),
+                getTestClassesDirectory(), getAdditionalClasspathElements(), 
logger );
     }
 
     /**
@@ -2836,12 +2795,12 @@ public abstract class AbstractSurefireMojo
 
         @Override
         @Nonnull
-        public Classpath getProviderClasspath()
+        public Set<Artifact> getProviderClasspath()
             throws ArtifactResolutionException, ArtifactNotFoundException
         {
             Artifact surefireArtifact = getPluginArtifactMap().get( 
"org.apache.maven.surefire:surefire-booter" );
-            return dependencyResolver.getProviderClasspath( "surefire-testng", 
surefireArtifact.getBaseVersion(),
-                                                            testNgArtifact );
+            String version = surefireArtifact.getBaseVersion();
+            return dependencyResolver.getProviderClasspath( "surefire-testng", 
version, testNgArtifact );
         }
     }
 
@@ -2867,14 +2826,13 @@ public abstract class AbstractSurefireMojo
 
         @Override
         @Nonnull
-        public Classpath getProviderClasspath()
+        public Set<Artifact> getProviderClasspath()
             throws ArtifactResolutionException, ArtifactNotFoundException
         {
             // add the JUnit provider as default - it doesn't require JUnit to 
be present,
             // since it supports POJO tests.
-            return dependencyResolver.getProviderClasspath( "surefire-junit3", 
surefireBooterArtifact.getBaseVersion(),
-                                                            null );
-
+            String version = surefireBooterArtifact.getBaseVersion();
+            return dependencyResolver.getProviderClasspath( "surefire-junit3", 
version, null );
         }
     }
 
@@ -2910,13 +2868,12 @@ public abstract class AbstractSurefireMojo
 
         @Override
         @Nonnull
-        public Classpath getProviderClasspath()
+        public Set<Artifact> getProviderClasspath()
             throws ArtifactResolutionException, ArtifactNotFoundException
         {
-            return dependencyResolver.getProviderClasspath( "surefire-junit4", 
surefireBooterArtifact.getBaseVersion(),
-                                                            null );
+            String version = surefireBooterArtifact.getBaseVersion();
+            return dependencyResolver.getProviderClasspath( "surefire-junit4", 
version, null );
         }
-
     }
 
     final class JUnitPlatformProviderInfo
@@ -2929,27 +2886,32 @@ public abstract class AbstractSurefireMojo
             this.junitArtifact = junitArtifact;
         }
 
-        @Nonnull public String getProviderName()
+        @Override
+        @Nonnull
+        public String getProviderName()
         {
             return 
"org.apache.maven.surefire.junitplatform.JUnitPlatformProvider";
         }
 
+        @Override
         public boolean isApplicable()
         {
             return junitArtifact != null;
         }
 
+        @Override
         public void addProviderProperties() throws MojoExecutionException
         {
             convertGroupParameters();
         }
 
-        public Classpath getProviderClasspath()
+        @Override
+        @Nonnull
+        public Set<Artifact> getProviderClasspath()
             throws ArtifactResolutionException, ArtifactNotFoundException
         {
-            return dependencyResolver.getProviderClasspath( 
"surefire-junit-platform",
-                                                            
surefireBooterArtifact.getBaseVersion(),
-                                                            null );
+            String version = surefireBooterArtifact.getBaseVersion();
+            return dependencyResolver.getProviderClasspath( 
"surefire-junit-platform", version, null );
         }
     }
 
@@ -2994,11 +2956,11 @@ public abstract class AbstractSurefireMojo
 
         @Override
         @Nonnull
-        public Classpath getProviderClasspath()
+        public Set<Artifact> getProviderClasspath()
             throws ArtifactResolutionException, ArtifactNotFoundException
         {
-            return dependencyResolver.getProviderClasspath( 
"surefire-junit47", surefireBooterArtifact.getBaseVersion(),
-                                                            null );
+            String version = surefireBooterArtifact.getBaseVersion();
+            return dependencyResolver.getProviderClasspath( 
"surefire-junit47", version, null );
         }
     }
 
@@ -3044,7 +3006,7 @@ public abstract class AbstractSurefireMojo
 
         @Override
         @Nonnull
-        public Classpath getProviderClasspath()
+        public Set<Artifact> getProviderClasspath()
             throws ArtifactResolutionException, ArtifactNotFoundException
         {
             return dependencyResolver.addProviderToClasspath( 
pluginArtifactMap, getMojoArtifact() );
diff --git 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ClasspathCache.java
 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ClasspathCache.java
index b8b2e2d..3bb1ac2 100644
--- 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ClasspathCache.java
+++ 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ClasspathCache.java
@@ -19,7 +19,12 @@ package org.apache.maven.plugin.surefire;
  * under the License.
  */
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.surefire.booter.Classpath;
 
 import javax.annotation.Nonnull;
@@ -41,4 +46,16 @@ public class ClasspathCache
     {
         CLASSPATHS.put( key, classpath );
     }
+
+    public static Classpath setCachedClasspath( @Nonnull String key, @Nonnull 
Set<Artifact> artifacts )
+    {
+        Collection<String> files = new ArrayList<String>();
+        for ( Artifact artifact : artifacts )
+        {
+            files.add( artifact.getFile().getAbsolutePath() );
+        }
+        Classpath classpath = new Classpath( files );
+        setCachedClasspath( key, classpath );
+        return classpath;
+    }
 }
diff --git 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java
 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java
index a3fb88e..e99cc82 100644
--- 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java
+++ 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java
@@ -19,12 +19,12 @@ package org.apache.maven.plugin.surefire;
  * under the License.
  */
 
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.surefire.booter.Classpath;
 
 import javax.annotation.Nonnull;
+import java.util.Set;
 
 /**
  * @author Kristian Rosenvold
@@ -37,8 +37,8 @@ public interface ProviderInfo
     boolean isApplicable();
 
     @Nonnull
-    Classpath getProviderClasspath()
-        throws ArtifactResolutionException, ArtifactNotFoundException;
+    Set<Artifact> getProviderClasspath()
+        throws AbstractArtifactResolutionException;
 
     void addProviderProperties() throws MojoExecutionException;
 }
diff --git 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java
 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java
index a43c4de..f33a316 100644
--- 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java
+++ 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java
@@ -19,10 +19,6 @@ package org.apache.maven.plugin.surefire;
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -37,11 +33,19 @@ import 
org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import 
org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
 import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.surefire.booter.Classpath;
 import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static java.util.Collections.singleton;
+import static org.apache.maven.artifact.Artifact.SCOPE_TEST;
+import static 
org.apache.maven.artifact.versioning.VersionRange.createFromVersion;
 
 /**
  * Does dependency resolution and artifact handling for the surefire plugin.
@@ -123,65 +127,55 @@ public class SurefireDependencyResolver
 
         Artifact originatingArtifact = artifactFactory.createBuildArtifact( 
"dummy", "dummy", "1.0", "jar" );
 
-        return artifactResolver.resolveTransitively( Collections.singleton( 
providerArtifact ), originatingArtifact,
+        return artifactResolver.resolveTransitively( singleton( 
providerArtifact ), originatingArtifact,
                                                      localRepository, 
remoteRepositories, artifactMetadataSource,
                                                      filter );
     }
 
     @Nonnull
-    public Classpath getProviderClasspath( String provider, String version, 
Artifact filteredArtifact )
+    @SuppressWarnings( "unchecked" )
+    public Set<Artifact> getProviderClasspath( String provider, String 
version, Artifact filteredArtifact )
         throws ArtifactNotFoundException, ArtifactResolutionException
     {
-        Classpath classPath = ClasspathCache.getCachedClassPath( provider );
-        if ( classPath == null )
-        {
-            Artifact providerArtifact = 
artifactFactory.createDependencyArtifact( "org.apache.maven.surefire", provider,
-                                                                               
   VersionRange.createFromVersion(
-                                                                               
       version ), "jar", null,
-                                                                               
   Artifact.SCOPE_TEST );
-            ArtifactResolutionResult result = resolveArtifact( 
filteredArtifact, providerArtifact );
-            List<String> files = new ArrayList<String>();
+        Artifact providerArtifact = artifactFactory.createDependencyArtifact( 
"org.apache.maven.surefire",
+                provider, createFromVersion( version ), "jar", null, 
SCOPE_TEST );
+
+        ArtifactResolutionResult result = resolveArtifact( filteredArtifact, 
providerArtifact );
 
+        if ( log.isDebugEnabled() )
+        {
             for ( Object o : result.getArtifacts() )
             {
                 Artifact artifact = (Artifact) o;
-
-                log.debug(
-                    "Adding to " + pluginName + " test classpath: " + 
artifact.getFile().getAbsolutePath() + " Scope: "
-                        + artifact.getScope() );
-
-                files.add( artifact.getFile().getAbsolutePath() );
+                String artifactPath = artifact.getFile().getAbsolutePath();
+                String scope = artifact.getScope();
+                log.debug( "Adding to " + pluginName + " test classpath: " + 
artifactPath + " Scope: " + scope );
             }
-            classPath = new Classpath( files );
-            ClasspathCache.setCachedClasspath( provider, classPath );
         }
-        return classPath;
+
+        return result.getArtifacts();
     }
 
-    public Classpath addProviderToClasspath( Map<String, Artifact> 
pluginArtifactMap, Artifact surefireArtifact )
+    public Set<Artifact> addProviderToClasspath( Map<String, Artifact> 
pluginArtifactMap, Artifact surefireArtifact )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
-        List<String> files = new ArrayList<String>();
+        Set<Artifact> providerArtifacts = new LinkedHashSet<Artifact>();
         if ( surefireArtifact != null )
         {
-            final ArtifactResolutionResult artifactResolutionResult = 
resolveArtifact( null, surefireArtifact );
+            ArtifactResolutionResult artifactResolutionResult = 
resolveArtifact( null, surefireArtifact );
             for ( Artifact artifact : pluginArtifactMap.values() )
             {
                 if ( !artifactResolutionResult.getArtifacts().contains( 
artifact ) )
                 {
-                    files.add( artifact.getFile().getAbsolutePath() );
+                    providerArtifacts.add( artifact );
                 }
             }
         }
         else
         {
             // Bit of a brute force strategy if not found. Should probably be 
improved
-            for ( Artifact artifact : pluginArtifactMap.values() )
-            {
-                files.add( artifact.getFile().getPath() );
-            }
+            providerArtifacts.addAll( pluginArtifactMap.values() );
         }
-        return new Classpath( files );
+        return providerArtifacts;
     }
-
 }
diff --git 
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
new file mode 100644
index 0000000..22c2011
--- /dev/null
+++ 
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
@@ -0,0 +1,111 @@
+package org.apache.maven.plugin.surefire;
+
+/*
+ * 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.artifact.Artifact;
+import org.apache.maven.surefire.booter.Classpath;
+import org.codehaus.plexus.logging.Logger;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import static java.util.Collections.addAll;
+import static org.apache.maven.shared.utils.StringUtils.split;
+
+final class TestClassPath
+{
+    private final Iterable<Artifact> artifacts;
+    private final File classesDirectory;
+    private final File testClassesDirectory;
+    private final String[] additionalClasspathElements;
+    private final Logger logger;
+
+    TestClassPath( Iterable<Artifact> artifacts,
+                   File classesDirectory,
+                   File testClassesDirectory,
+                   String[] additionalClasspathElements,
+                   Logger logger )
+    {
+        this.artifacts = artifacts;
+        this.classesDirectory = classesDirectory;
+        this.testClassesDirectory = testClassesDirectory;
+        this.additionalClasspathElements = additionalClasspathElements;
+        this.logger = logger;
+    }
+
+    void avoidArtifactDuplicates( Set<Artifact> providerArtifacts )
+    {
+        for ( Artifact artifact : artifacts )
+        {
+            Iterator<Artifact> it = providerArtifacts.iterator();
+            while ( it.hasNext() )
+            {
+                Artifact providerArtifact = it.next();
+                String classifier1 = providerArtifact.getClassifier();
+                String classifier2 = artifact.getClassifier();
+                if ( providerArtifact.getGroupId().equals( 
artifact.getGroupId() )
+                        && providerArtifact.getArtifactId().equals( 
artifact.getArtifactId() )
+                        && providerArtifact.getType().equals( 
artifact.getType() )
+                        && ( classifier1 == null ? classifier2 == null : 
classifier1.equals( classifier2 ) ) )
+                {
+                    it.remove();
+                    if ( logger.isDebugEnabled() )
+                    {
+                        logger.debug( "Removed artifact " + providerArtifact + 
" from provider. "
+                                + "Already appears in test classpath." );
+                    }
+                }
+            }
+        }
+    }
+
+    Classpath toClasspath()
+    {
+        List<String> classpath = new ArrayList<String>();
+        classpath.add( testClassesDirectory.getAbsolutePath() );
+        classpath.add( classesDirectory.getAbsolutePath() );
+        for ( Artifact artifact : artifacts )
+        {
+            if ( artifact.getArtifactHandler().isAddedToClasspath() )
+            {
+                File file = artifact.getFile();
+                if ( file != null )
+                {
+                    classpath.add( file.getAbsolutePath() );
+                }
+            }
+        }
+        if ( additionalClasspathElements != null )
+        {
+            for ( String additionalClasspathElement : 
additionalClasspathElements )
+            {
+                if ( additionalClasspathElement != null )
+                {
+                    addAll( classpath, split( additionalClasspathElement, "," 
) );
+                }
+            }
+        }
+
+        return new Classpath( classpath );
+    }
+}
diff --git 
a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
 
b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
index 8310fe3..96a2a5c 100644
--- 
a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
+++ 
b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
@@ -20,6 +20,9 @@ package org.apache.maven.plugin.surefire;
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.surefire.log.PluginConsoleLogger;
@@ -32,6 +35,7 @@ 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.BeforeClass;
 import org.junit.Test;
@@ -47,12 +51,13 @@ import java.nio.file.Path;
 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.JavaVersion.JAVA_RECENT;
+import static 
org.apache.maven.artifact.versioning.VersionRange.createFromVersion;
 import static 
org.apache.maven.surefire.booter.SystemUtils.isBuiltInJava7AtLeast;
 import static org.fest.assertions.Assertions.assertThat;
 import static org.junit.Assume.assumeTrue;
@@ -78,6 +83,9 @@ import static org.powermock.reflect.Whitebox.invokeMethod;
 public class AbstractSurefireMojoJava7PlusTest
 {
     @Mock
+    private ArtifactHandler handler;
+
+    @Mock
     private LocationManager locationManager;
 
     @BeforeClass
@@ -94,36 +102,62 @@ public class AbstractSurefireMojoJava7PlusTest
         doReturn( locationManager )
                 .when( mojo, "getLocationManager" );
 
-        Classpath testClasspath = new Classpath( asList( "non-modular.jar", 
"modular.jar",
-                "target" + separatorChar + "classes", "junit.jar", 
"hamcrest.jar" ) );
+        when( handler.isAddedToClasspath() ).thenReturn( true );
+
+        VersionRange v1 = createFromVersion( "1" );
+        Artifact modular = new DefaultArtifact( "x", "modular", v1, "compile", 
"jar", "", handler );
+        modular.setFile( mockFile( "modular.jar" ) );
+
+        VersionRange v2 = createFromVersion( "1" );
+        Artifact nonModular = new DefaultArtifact( "x", "non-modular", v2, 
"test", "jar", "", handler );
+        nonModular.setFile( mockFile( "non-modular.jar" ) );
+
+        VersionRange v3 = createFromVersion( "4.12" );
+        Artifact junit = new DefaultArtifact( "junit", "junit", v3, "test", 
"jar", "", handler );
+        junit.setFile( mockFile( "junit.jar" ) );
+
+        VersionRange v4 = createFromVersion( "1.3.0" );
+        Artifact hamcrest = new DefaultArtifact( "org.hamcrest", 
"hamcrest-core", v4, "test", "jar", "", handler );
+        hamcrest.setFile( mockFile( "hamcrest.jar" ) );
+
+        File classesDir = mockFile( "classes" );
+        File testClassesDir = mockFile( "test-classes" );
+
+        TestClassPath testClasspath =
+                new TestClassPath( asList( modular, nonModular, junit, 
hamcrest ), classesDir, testClassesDir,
+                        null, null );
 
         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" ) );
+        when( mojo.getTestClassesDirectory() ).thenReturn( testClassesDir );
 
         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" ) );
+        VersionRange v5 = createFromVersion( "1" );
+        Artifact provider = new DefaultArtifact( "org.apache.maven.surefire", 
"surefire-provider", v5, "runtime",
+                "jar", "", handler );
+        provider.setFile( mockFile( "surefire-provider.jar" ) );
+        Set<Artifact> providerClasspath = singleton( provider );
 
-        File moduleInfo = new File( "target" + separatorChar + "classes" + 
separatorChar + "module-info.class" );
+        File moduleInfo = mockFile( "classes/module-info.class" );
 
         @SuppressWarnings( "unchecked" )
         ResolvePathsRequest<String> req = mock( ResolvePathsRequest.class );
         mockStatic( ResolvePathsRequest.class );
-        when( ResolvePathsRequest.withStrings( eq( 
testClasspath.getClassPath() ) ) ).thenReturn( req );
+        when( ResolvePathsRequest.ofStrings( eq( 
testClasspath.toClasspath().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, ResolvePathsResult.ModuleNameSource> mod = new 
LinkedHashMap<String, ResolvePathsResult.ModuleNameSource>();
+        Map<String, ModuleNameSource> mod = new LinkedHashMap<String, 
ModuleNameSource>();
         mod.put( "modular.jar", null );
-        mod.put( "target" + separatorChar + "classes", null );
+        mod.put( "classes", null );
         when( res.getModulepathElements() ).thenReturn( mod );
         when( locationManager.resolvePaths( eq( req ) ) ).thenReturn( res );
 
@@ -132,7 +166,7 @@ public class AbstractSurefireMojoJava7PlusTest
         doNothing().when( logger ).debug( anyString() );
         when( mojo.getConsoleLogger() ).thenReturn( new PluginConsoleLogger( 
logger ) );
 
-        StartupConfiguration conf = invokeMethod( mojo, 
"newStartupConfigForModularClasspath",
+        StartupConfiguration conf = invokeMethod( mojo, 
"newStartupConfigWithModularPath",
                 classLoaderConfiguration, providerClasspath, 
"org.asf.Provider", moduleInfo, scanResult );
 
         verify( mojo, times( 1 ) ).effectiveIsEnableAssertions();
@@ -142,7 +176,7 @@ public class AbstractSurefireMojoJava7PlusTest
         verify( mojo, times( 1 ) ).getTestClassesDirectory();
         verify( scanResult, times( 1 ) ).getClasses();
         verifyStatic( ResolvePathsRequest.class, times( 1 ) );
-        ResolvePathsRequest.withStrings( eq( testClasspath.getClassPath() ) );
+        ResolvePathsRequest.ofStrings( eq( 
testClasspath.toClasspath().getClassPath() ) );
         verify( req, times( 1 ) ).setMainModuleDescriptor( eq( 
moduleInfo.getAbsolutePath() ) );
         verify( res, times( 1 ) ).getClasspathElements();
         verify( res, times( 1 ) ).getModulepathElements();
@@ -151,7 +185,7 @@ public class AbstractSurefireMojoJava7PlusTest
         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",
+                        "test modulepath:  modular.jar  classes",
                         "provider classpath:  surefire-provider.jar",
                         "test(compact) classpath:  non-modular.jar  junit.jar  
hamcrest.jar",
                         "test(compact) modulepath:  modular.jar  classes",
@@ -168,15 +202,16 @@ public class AbstractSurefireMojoJava7PlusTest
         assertThat( conf.getClasspathConfiguration() ).isNotNull();
         assertThat( ( Object ) 
conf.getClasspathConfiguration().getTestClasspath() )
                 .isEqualTo( new Classpath( res.getClasspathElements() ) );
-        assertThat( ( Object ) 
conf.getClasspathConfiguration().getProviderClasspath() ).isSameAs( 
providerClasspath );
+        assertThat( ( Object ) 
conf.getClasspathConfiguration().getProviderClasspath() )
+                .isEqualTo( new Classpath( singleton( "surefire-provider.jar" 
) ) );
         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().getPatchFile().getAbsolutePath() 
)
+                .isEqualTo( "test-classes" );
         assertThat( mcc.getModularClasspath().getModulePath() )
-                .containsExactly( "modular.jar", "target" + separatorChar + 
"classes" );
+                .containsExactly( "modular.jar", "classes" );
         assertThat( ( Object ) mcc.getTestClasspath() ).isEqualTo( new 
Classpath( res.getClasspathElements() ) );
     }
 
@@ -222,6 +257,13 @@ public class AbstractSurefireMojoJava7PlusTest
                 .isTrue();
     }
 
+    private static File mockFile( String absolutePath )
+    {
+        File f = mock( File.class );
+        when( f.getAbsolutePath() ).thenReturn( absolutePath );
+        return f;
+    }
+
     public static class Mojo
             extends AbstractSurefireMojo
     {
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 481d91e..22c3f52 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
@@ -20,9 +20,9 @@ package org.apache.maven.plugin.surefire;
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
 import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.plugin.surefire.log.PluginConsoleLogger;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
@@ -33,23 +33,29 @@ import org.codehaus.plexus.logging.Logger;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 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.SystemUtils.IS_OS_WINDOWS;
+import static 
org.apache.maven.artifact.versioning.VersionRange.createFromVersion;
+import static 
org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec;
 import static org.fest.assertions.Assertions.assertThat;
 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;
@@ -67,9 +73,75 @@ import static org.powermock.reflect.Whitebox.invokeMethod;
 @PrepareForTest( AbstractSurefireMojo.class )
 public class AbstractSurefireMojoTest
 {
+    @Mock
+    private ArtifactHandler handler;
+
     private final Mojo mojo = new Mojo();
 
     @Test
+    public void shouldRetainInPluginArtifacts() throws Exception
+    {
+        Artifact provider = new DefaultArtifact( "g", "a", 
createFromVersionSpec( "1" ), "compile", "jar", "", null );
+        Artifact common = new DefaultArtifact( "g", "c", 
createFromVersionSpec( "1" ), "compile", "jar", "", null );
+        Artifact api = new DefaultArtifact( "g", "a", createFromVersionSpec( 
"1" ), "compile", "jar", "", null );
+
+        Set<Artifact> providerArtifacts = singleton( provider );
+        Artifact[] inPluginArtifacts = { common, api };
+        Set<Artifact> inPluginClasspath = invokeMethod( 
AbstractSurefireMojo.class,
+                "retainInProcArtifactsUnique", providerArtifacts, 
inPluginArtifacts );
+
+        assertThat( inPluginClasspath )
+                .containsOnly( common );
+    }
+
+    @Test
+    public void shouldRetainInProcArtifactsUnique() throws Exception
+    {
+        Artifact provider = new DefaultArtifact( "g", "p", 
createFromVersionSpec( "1" ), "compile", "jar", "", null );
+        Artifact common = new DefaultArtifact( "g", "c", 
createFromVersionSpec( "1" ), "compile", "jar", "", null );
+        Artifact api = new DefaultArtifact( "g", "a", createFromVersionSpec( 
"1" ), "compile", "jar", "", null );
+
+        Set<Artifact> providerArtifacts = singleton( provider );
+        Artifact[] inPluginArtifacts = { common, api };
+        Set<Artifact> inPluginClasspath = invokeMethod( 
AbstractSurefireMojo.class,
+                "retainInProcArtifactsUnique", providerArtifacts, 
inPluginArtifacts );
+
+        assertThat( inPluginClasspath )
+                .containsOnly( common, api );
+    }
+
+    @Test
+    public void shouldCreateInProcClasspath() throws Exception
+    {
+        Artifact provider = new DefaultArtifact( "g", "p", 
createFromVersionSpec( "1" ), "compile", "jar", "", null );
+        provider.setFile( mockFile( "provider.jar" ) );
+
+        Artifact common = new DefaultArtifact( "g", "c", 
createFromVersionSpec( "1" ), "compile", "jar", "", null );
+        common.setFile( mockFile( "maven-surefire-common.jar" ) );
+
+        Artifact api = new DefaultArtifact( "g", "a", createFromVersionSpec( 
"1" ), "compile", "jar", "", null );
+        api.setFile( mockFile( "surefire-api.jar" ) );
+
+        Set<Artifact> newArtifacts = new LinkedHashSet<Artifact>();
+        newArtifacts.add( common );
+        newArtifacts.add( api );
+
+        Classpath providerClasspath = new Classpath( singleton( 
provider.getFile().getAbsolutePath() ) );
+
+        Classpath inPluginClasspath = invokeMethod( AbstractSurefireMojo.class,
+                "createInProcClasspath", providerClasspath, newArtifacts );
+
+        Classpath expectedClasspath =
+                new Classpath( asList( provider.getFile().getAbsolutePath(),
+                                       common.getFile().getAbsolutePath(),
+                                       api.getFile().getAbsolutePath() ) );
+
+        assertThat( (Object ) inPluginClasspath )
+                .isEqualTo( expectedClasspath );
+
+    }
+
+    @Test
     public void shouldGenerateTestClasspath() throws Exception
     {
         AbstractSurefireMojo mojo = spy( this.mojo );
@@ -79,7 +151,6 @@ public class AbstractSurefireMojoTest
         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>();
 
@@ -121,21 +192,19 @@ public class AbstractSurefireMojoTest
         when( project.getArtifacts() ).thenReturn( artifacts );
         when( mojo.getProject() ).thenReturn( project );
 
-        Classpath cp = invokeMethod( mojo, "generateTestClasspath" );
+        TestClassPath 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" );
+        verify( mojo, times( 1 ) ).getAdditionalClasspathElements();
+
+        assertThat( cp.toClasspath().getClassPath() ).hasSize( 3 );
+        assertThat( cp.toClasspath().getClassPath().get( 0 ) ).endsWith( 
"test-classes" );
+        assertThat( cp.toClasspath().getClassPath().get( 1 ) ).endsWith( 
"classes" );
+        assertThat( cp.toClasspath().getClassPath().get( 2 ) ).endsWith( 
"a2-2.jar" );
     }
 
     @Test
@@ -143,7 +212,37 @@ public class AbstractSurefireMojoTest
             throws Exception
     {
         AbstractSurefireMojo mojo = spy( this.mojo );
-        Classpath testClasspath = new Classpath( asList( "junit.jar", 
"hamcrest.jar" ) );
+
+        Artifact common = new DefaultArtifact( "org.apache.maven.surefire", 
"maven-surefire-common",
+                createFromVersion( "1" ), "runtime", "jar", "", handler );
+        common.setFile( mockFile( "maven-surefire-common.jar" ) );
+
+
+        Artifact api = new DefaultArtifact( "org.apache.maven.surefire", 
"surefire-api",
+                createFromVersion( "1" ), "runtime", "jar", "", handler );
+        api.setFile( mockFile( "surefire-api.jar" ) );
+
+        Map<String, Artifact> providerArtifactsMap = new HashMap<String, 
Artifact>();
+        providerArtifactsMap.put( 
"org.apache.maven.surefire:maven-surefire-common", common );
+        providerArtifactsMap.put( "org.apache.maven.surefire:surefire-api", 
api );
+
+        when( mojo.getPluginArtifactMap() )
+                .thenReturn( providerArtifactsMap );
+
+        when( handler.isAddedToClasspath() ).thenReturn( true );
+
+        VersionRange v1 = createFromVersion( "4.12" );
+        Artifact junit = new DefaultArtifact( "junit", "junit", v1, "test", 
"jar", "", handler );
+        junit.setFile( mockFile( "junit.jar" ) );
+
+        VersionRange v2 = createFromVersion( "1.3.0" );
+        Artifact hamcrest = new DefaultArtifact( "org.hamcrest", 
"hamcrest-core", v2, "test", "jar", "", handler );
+        hamcrest.setFile( mockFile( "hamcrest.jar" ) );
+
+        File classesDir = mockFile( "classes" );
+        File testClassesDir = mockFile( "test-classes" );
+        TestClassPath testClasspath =
+                new TestClassPath( asList( junit, hamcrest ), classesDir, 
testClassesDir, null, null );
 
         doReturn( testClasspath ).when( mojo, "generateTestClasspath" );
         doReturn( 1 ).when( mojo, "getEffectiveForkCount" );
@@ -152,41 +251,48 @@ public class AbstractSurefireMojoTest
 
         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" ) );
+        VersionRange v3 = createFromVersion( "1" );
+        Artifact provider = new DefaultArtifact( "x", "surefire-provider", v3, 
"runtime", "jar", "", handler );
+        provider.setFile( mockFile( "surefire-provider.jar" ) );
+        Set<Artifact> providerArtifacts = singleton( provider );
 
         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" );
+        StartupConfiguration conf = invokeMethod( mojo, 
"newStartupConfigWithClasspath",
+                classLoaderConfiguration, providerArtifacts, 
"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();
+        verify( logger, times( 6 ) ).isDebugEnabled();
         ArgumentCaptor<String> argument = ArgumentCaptor.forClass( 
String.class );
-        verify( logger, times( 4 ) ).debug( argument.capture() );
+        verify( logger, times( 6 ) ).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"
+                .containsExactly( "test classpath:  test-classes  classes  
junit.jar  hamcrest.jar",
+                "provider classpath:  surefire-provider.jar",
+                "test(compact) classpath:  test-classes  classes  junit.jar  
hamcrest.jar",
+                "provider(compact) classpath:  surefire-provider.jar",
+                "in-process classpath:  surefire-provider.jar  
maven-surefire-common.jar  surefire-api.jar",
+                "in-process(compact) classpath:  surefire-provider.jar  
maven-surefire-common.jar  surefire-api.jar"
                 );
 
         assertThat( conf.getClassLoaderConfiguration() )
                 .isSameAs( classLoaderConfiguration );
 
         assertThat( ( Object ) 
conf.getClasspathConfiguration().getTestClasspath() )
-                .isSameAs( testClasspath );
+                .isEqualTo( testClasspath.toClasspath() );
 
+        Collection<String> files = new ArrayList<String>();
+        for ( Artifact providerArtifact : providerArtifacts )
+        {
+            files.add( providerArtifact.getFile().getAbsolutePath() );
+        }
         assertThat( ( Object ) 
conf.getClasspathConfiguration().getProviderClasspath() )
-                .isSameAs( providerClasspath );
+                .isEqualTo( new Classpath( files ) );
 
         assertThat( ( Object ) 
conf.getClasspathConfiguration().isClassPathConfig() )
                 .isEqualTo( true );
@@ -573,7 +679,6 @@ public class AbstractSurefireMojoTest
 
         @Override
         protected void handleSummary( RunResult summary, Exception 
firstForkException )
-                throws MojoExecutionException, MojoFailureException
         {
 
         }
@@ -602,4 +707,11 @@ public class AbstractSurefireMojoTest
             return null;
         }
     }
+
+    private static File mockFile( String absolutePath )
+    {
+        File f = mock( File.class );
+        when( f.getAbsolutePath() ).thenReturn( absolutePath );
+        return f;
+    }
 }
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 42218ee..988d2ee 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
@@ -42,7 +42,7 @@ import static 
org.apache.maven.surefire.util.internal.UrlUtils.toURL;
  *
  * @author Kristian Rosenvold
  */
-public final class Classpath implements Iterable<String>
+public final class Classpath implements Iterable<String>, Cloneable
 {
     private final List<String> unmodifiableElements;
 
@@ -224,4 +224,10 @@ public final class Classpath implements Iterable<String>
     {
         return unmodifiableElements.iterator();
     }
+
+    @Override
+    public Classpath clone()
+    {
+        return new Classpath( unmodifiableElements );
+    }
 }
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 e6ebece..21cb82c 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
@@ -84,7 +84,6 @@ public class ClasspathConfiguration extends 
AbstractPathConfiguration
     }
 
     public void trickClassPathWhenManifestOnlyClasspath()
-        throws SurefireExecutionException
     {
         System.setProperty( "surefire.real.class.path", System.getProperty( 
"java.class.path" ) );
         getTestClasspath().writeToSystemProperty( "java.class.path" );
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 03ef036..580132a 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
@@ -86,7 +86,7 @@ public final class ForkedBooter
 
     private void setupBooter( String tmpDir, String dumpFileName, String 
surefirePropsFileName,
                               String effectiveSystemPropertiesFileName )
-            throws IOException, SurefireExecutionException
+            throws IOException
     {
         BooterDeserializer booterDeserializer =
                 new BooterDeserializer( createSurefirePropertiesIfFileExists( 
tmpDir, surefirePropsFileName ) );
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java
new file mode 100644
index 0000000..42a2b63
--- /dev/null
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java
@@ -0,0 +1,160 @@
+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.it.VerificationException;
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static 
org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
+import static org.apache.maven.surefire.its.fixture.IsRegex.regex;
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.util.Collections.set;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.junit.Assert.assertThat;
+
+@RunWith( Parameterized.class )
+public class JUnitPlatformEnginesIT
+        extends SurefireJUnit4IntegrationTestCase
+{
+    @Parameter
+    public String platform;
+
+    @Parameter( 1 )
+    public String jupiter;
+
+    @Parameter( 2 )
+    public String opentest;
+
+    @Parameter( 3 )
+    public String apiguardian;
+
+    @Parameters(name = "{0}")
+    public static Iterable<Object[]> regexVersions()
+    {
+        ArrayList<Object[]> args = new ArrayList<Object[]>();
+        args.add( new Object[] { "1.0.0", "5.0.0", "1.0.0", "1.0.0" } );
+        args.add( new Object[] { "1.1.1", "5.1.1", "1.0.0", "1.0.0" } );
+        args.add( new Object[] { "1.2.0", "5.2.0", "1.1.0", "1.0.0" } );
+        args.add( new Object[] { "1.3.1", "5.3.1", "1.1.1", "1.0.0" } );
+        args.add( new Object[] { "1.4.0-SNAPSHOT", "5.4.0-SNAPSHOT", "1.1.1", 
"1.0.0" } );
+        return args;
+    }
+
+    @Before
+    public void setUp()
+    {
+        assumeJavaVersion( 1.8d );
+    }
+
+    @Test
+    public void testToRegex()
+    {
+        String regex = toRegex( ".[]()*" );
+        assertThat( regex )
+                .isEqualTo( "\\.\\[\\]\\(\\).*" );
+    }
+
+    @Test
+    public void platform() throws VerificationException
+    {
+        OutputValidator validator = unpack( "junit-platform", '-' + platform )
+                .sysProp( "jupiter.version", jupiter )
+                .addGoal( "-X" )
+                .executeTest()
+                .verifyErrorFree( 1 );
+
+        String testClasspath = "[DEBUG] test(compact) classpath:"
+                + "  test-classes"
+                + "  classes"
+                + "  junit-jupiter-engine-" + jupiter + ".jar"
+                + "  apiguardian-api-" + apiguardian + ".jar"
+                + "  junit-platform-engine-" + platform + ".jar"
+                + "  junit-platform-commons-" + platform + ".jar"
+                + "  opentest4j-" + opentest + ".jar"
+                + "  junit-jupiter-api-" + jupiter + ".jar";
+
+        List<String> lines = validator.loadLogLines( startsWith( "[DEBUG] 
test(compact) classpath" ) );
+
+        assertThat( lines )
+                .hasSize( 1 );
+
+        String line = lines.get( 0 );
+
+        assertThat( set( line ), regex( toRegex( testClasspath ) ) );
+
+        String providerClasspath = "[DEBUG] provider(compact) classpath:"
+                + "  surefire-junit-platform-*.jar"
+                + "  junit-platform-launcher-1.3.1.jar"
+                + "  surefire-api-*.jar"
+                + "  surefire-logger-api-*.jar";
+
+        lines = validator.loadLogLines( startsWith( "[DEBUG] provider(compact) 
classpath" ) );
+
+        assertThat( lines )
+                .hasSize( 1 );
+
+        line = lines.get( 0 );
+
+        assertThat( set( line ), regex( toRegex( providerClasspath ) ) );
+
+        String bootClasspath = "[DEBUG] boot(compact) classpath:"
+                + "  surefire-booter-*.jar"
+                + "  surefire-api-*.jar"
+                + "  surefire-logger-api-*.jar"
+                + "  test-classes"
+                + "  classes"
+                + "  junit-jupiter-engine-" + jupiter + ".jar"
+                + "  apiguardian-api-" + apiguardian + ".jar"
+                + "  junit-platform-engine-" + platform + ".jar"
+                + "  junit-platform-commons-" + platform + ".jar"
+                + "  opentest4j-" + opentest + ".jar"
+                + "  junit-jupiter-api-" + jupiter + ".jar"
+                + "  surefire-junit-platform-*.jar"
+                + "  junit-platform-launcher-1.3.1.jar";
+
+        lines = validator.loadLogLines( startsWith( "[DEBUG] boot(compact) 
classpath" ) );
+
+        assertThat( lines )
+                .hasSize( 1 );
+
+        line = lines.get( 0 );
+
+        assertThat( set( line ), regex( toRegex( bootClasspath ) ) );
+    }
+
+    private static String toRegex(String text) {
+        return text.replaceAll( "\\.", "\\\\." )
+                .replaceAll( "\\[", "\\\\[" )
+                .replaceAll( "]", "\\\\]" )
+                .replaceAll( "\\(", "\\\\(" )
+                .replaceAll( "\\)", "\\\\)" )
+                .replaceAll( "\\*", ".*" );
+    }
+}
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformIT.java 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformIT.java
index e1b808f..6c8d29d 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformIT.java
@@ -23,66 +23,54 @@ import 
org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
 import org.junit.Before;
 import org.junit.Test;
 
-import static java.lang.System.getProperty;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assume.assumeThat;
+import static 
org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
 
 public class JUnitPlatformIT
-    extends SurefireJUnit4IntegrationTestCase
+        extends SurefireJUnit4IntegrationTestCase
 {
     @Before
     public void setUp()
     {
-        assumeThat( "java.specification.version: ",
-                    getProperty( "java.specification.version" ), is( 
greaterThanOrEqualTo( "1.8" ) ) );
+        assumeJavaVersion( 1.8d );
     }
 
     @Test
     public void testJupiterEngine()
     {
-        unpack( "/junit-platform-engine-jupiter" 
).executeTest().verifyErrorFree( 5 );
+        unpack( "/junit-platform-engine-jupiter" )
+                .executeTest()
+                .verifyErrorFree( 5 );
     }
 
     @Test
     public void testVintageEngine()
     {
-        unpack( "/junit-platform-engine-vintage" 
).executeTest().verifyErrorFree( 1 );
+        unpack( "/junit-platform-engine-vintage" )
+                .executeTest()
+                .verifyErrorFree( 1 );
     }
 
     @Test
     public void testJQwikEngine()
     {
-        unpack( "/junit-platform-engine-jqwik" 
).executeTest().verifyErrorFree( 1 );
+        unpack( "/junit-platform-engine-jqwik" )
+                .executeTest()
+                .verifyErrorFree( 1 );
     }
 
     @Test
     public void testMultipleEngines()
     {
-        unpack( "/junit-platform-multiple-engines" 
).executeTest().verifyErrorFree( 7 );
-    }
-
-    @Test
-    public void testJUnitPlatform_1_0_0()
-    {
-        unpack( "/junit-platform-1.0.0" ).executeTest().verifyErrorFree( 1 );
-    }
-
-    @Test
-    public void testJUnitPlatform_1_1_1()
-    {
-        unpack( "/junit-platform-1.1.1" ).executeTest().verifyErrorFree( 1 );
-    }
-
-    @Test
-    public void testJUnitPlatform_1_2_0()
-    {
-        unpack( "/junit-platform-1.2.0" ).executeTest().verifyErrorFree( 1 );
+        unpack( "/junit-platform-multiple-engines" )
+                .executeTest()
+                .verifyErrorFree( 7 );
     }
 
     @Test
     public void testTags()
     {
-        unpack( "/junit-platform-tags" ).executeTest().verifyErrorFree( 2 );
+        unpack( "/junit-platform-tags" )
+                .executeTest()
+                .verifyErrorFree( 2 );
     }
 }
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/IsRegex.java 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/IsRegex.java
new file mode 100644
index 0000000..09e8d0d
--- /dev/null
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/IsRegex.java
@@ -0,0 +1,100 @@
+package org.apache.maven.surefire.its.fixture;
+
+/*
+ * 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.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Set;
+
+import static java.util.Collections.singleton;
+
+/**
+ * Java Hamcrest Matcher with Regex.
+ */
+public final class IsRegex
+        extends BaseMatcher<Set<String>>
+{
+    public static Matcher<Set<String>> regex( Set<String> expectedRegex )
+    {
+        return new IsRegex( expectedRegex );
+    }
+
+    public static Matcher<Set<String>> regex( String expectedRegex )
+    {
+        return new IsRegex( expectedRegex );
+    }
+
+    private final Set<String> expectedRegex;
+
+    private IsRegex( String expectedRegex )
+    {
+        this.expectedRegex = singleton( expectedRegex );
+    }
+
+    private IsRegex( Set<String> expectedRegex )
+    {
+        this.expectedRegex = expectedRegex;
+    }
+
+    @Override
+    public boolean matches( Object o )
+    {
+        if ( o != null
+                && expectedRegex.size() == 1 ? isStringOrSet( o ) : isSet( o ) 
)
+        {
+            //noinspection unchecked
+            Set<String> actual = isSet( o ) ? ( Set<String> ) o : singleton( ( 
String ) o );
+            boolean matches = actual.size() == expectedRegex.size();
+            Iterator<String> regex = expectedRegex.iterator();
+            for ( String s : actual )
+            {
+                if ( s == null || !regex.hasNext() || !s.matches( regex.next() 
) )
+                {
+                    matches = false;
+                }
+            }
+            return matches;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    @Override
+    public void describeTo( Description description )
+    {
+        description.appendValue( expectedRegex );
+    }
+
+    private static boolean isStringOrSet( Object o )
+    {
+        return o instanceof String || o instanceof Set;
+    }
+
+    private static boolean isSet( Object o )
+    {
+        return o instanceof Set;
+    }
+}
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java
index 882ed9c..56046f1 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java
@@ -22,7 +22,7 @@ package org.apache.maven.surefire.its.fixture;
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.Charset;
-import java.util.Collection;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.io.FileUtils;
@@ -39,9 +39,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
  */
 public class OutputValidator
 {
-    protected final Verifier verifier;
+    final Verifier verifier;
 
-    protected final File baseDir;
+    private final File baseDir;
 
     public OutputValidator( Verifier verifier )
     {
@@ -93,14 +93,7 @@ public class OutputValidator
     public OutputValidator assertThatLogLine( Matcher<String> line, 
Matcher<Integer> nTimes )
         throws VerificationException
     {
-        int counter = 0;
-        for ( String log : loadLogLines() )
-        {
-            if ( line.matches( log ) )
-            {
-                counter++;
-            }
-        }
+        int counter = loadLogLines( line ).size();
         assertThat( "log pattern does not match nTimes", counter, nTimes );
         return this;
     }
@@ -111,6 +104,20 @@ public class OutputValidator
         return verifier.loadFile( verifier.getBasedir(), 
verifier.getLogFileName(), false );
     }
 
+    public List<String> loadLogLines( Matcher<String> line )
+            throws VerificationException
+    {
+        List<String> matchedLines = new ArrayList<String>();
+        for ( String log : loadLogLines() )
+        {
+            if ( line.matches( log ) )
+            {
+                matchedLines.add( log );
+            }
+        }
+        return matchedLines;
+    }
+
     public List<String> loadFile( File file, Charset charset )
     {
         //noinspection unchecked
diff --git 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java
 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java
index 2669b2f..2209061 100644
--- 
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java
+++ 
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java
@@ -24,17 +24,15 @@ import 
org.apache.maven.surefire.its.fixture.OutputValidator;
 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
 import org.apache.maven.surefire.its.fixture.TestFile;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
 import org.junit.Test;
 
 import java.nio.charset.Charset;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.Set;
 import java.util.TreeSet;
 
+import static org.apache.maven.surefire.its.fixture.IsRegex.regex;
+import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.core.AnyOf.anyOf;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.core.StringContains.containsString;
@@ -48,14 +46,7 @@ import static org.junit.Assert.assertThat;
 public class Surefire1082ParallelJUnitParameterizedIT
     extends SurefireJUnit4IntegrationTestCase
 {
-    private static Set<String> printOnlyTestLinesFromConsole( OutputValidator 
validator )
-            throws VerificationException
-    {
-        return printOnlyTestLines( validator.loadLogLines() );
-    }
-
     private static Set<String> printOnlyTestLinesFromOutFile( OutputValidator 
validator )
-            throws VerificationException
     {
         TestFile report = validator.getSurefireReportsFile( 
"jiras.surefire1082.Jira1082Test-output.txt" );
         report.assertFileExists();
@@ -63,7 +54,6 @@ public class Surefire1082ParallelJUnitParameterizedIT
     }
 
     private static Set<String> printOnlyTestLines( Collection<String> logs )
-        throws VerificationException
     {
         Set<String> log = new TreeSet<String>();
         for ( String line : logs )
@@ -76,11 +66,6 @@ public class Surefire1082ParallelJUnitParameterizedIT
         return log;
     }
 
-    private static Matcher<Set<String>> regex( Set<String> r )
-    {
-        return new IsRegex( r );
-    }
-
     private static void assertParallelRun( Set<String> log )
     {
         assertThat( log.size(), is( 4 ) );
@@ -115,7 +100,7 @@ public class Surefire1082ParallelJUnitParameterizedIT
 
         validator.assertThatLogLine( containsString( "Running 
jiras.surefire1082.Jira1082Test" ), is( 1 ) );
 
-        Set<String> log = printOnlyTestLinesFromConsole( validator );
+        Set<String> log = new TreeSet<String>( validator.loadLogLines( 
startsWith( "class jiras.surefire1082." ) ) );
         assertParallelRun( log );
     }
 
@@ -169,44 +154,4 @@ public class Surefire1082ParallelJUnitParameterizedIT
     {
         return unpack( "surefire-1082-parallel-junit-parameterized" );
     }
-
-    private static class IsRegex
-        extends BaseMatcher<Set<String>>
-    {
-        private final Set<String> expectedRegex;
-
-        IsRegex( Set<String> expectedRegex )
-        {
-            this.expectedRegex = expectedRegex;
-        }
-
-        @Override
-        public boolean matches( Object o )
-        {
-            if ( o != null && o instanceof Set )
-            {
-                Set<String> actual = (Set<String>) o;
-                boolean matches = actual.size() == expectedRegex.size();
-                Iterator<String> regex = expectedRegex.iterator();
-                for ( String s : actual )
-                {
-                    if ( s == null || !regex.hasNext() || !s.matches( 
regex.next() ) )
-                    {
-                        matches = false;
-                    }
-                }
-                return matches;
-            }
-            else
-            {
-                return false;
-            }
-        }
-
-        @Override
-        public void describeTo( Description description )
-        {
-            description.appendValue( expectedRegex );
-        }
-    }
 }
diff --git a/surefire-its/src/test/resources/junit-platform-1.1.1/pom.xml 
b/surefire-its/src/test/resources/junit-platform-1.1.1/pom.xml
deleted file mode 100644
index 2555d8b..0000000
--- a/surefire-its/src/test/resources/junit-platform-1.1.1/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0";
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
-    <modelVersion>4.0.0</modelVersion>
-
-    <groupId>org.apache.maven.plugins.surefire</groupId>
-    <artifactId>junit-platform-1.1.1</artifactId>
-    <version>1.0</version>
-    <name>Test for JUnit 5: Platform 1.1.1 + Jupiter 5.1.1</name>
-
-    <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
-    </properties>
-
-    <!--
-        Declare "junit-jupiter-engine" dependency because the
-        Jupiter Engine is needed at test runtime. Artifacts
-        needed for test compilation, like "junit-jupiter-api",
-        are pulled-in via transitive dependency resolution.
-    -->
-    <dependencies>
-        <dependency>
-            <groupId>org.junit.jupiter</groupId>
-            <artifactId>junit-jupiter-engine</artifactId>
-            <version>5.1.1</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${surefire.version}</version>
-            </plugin>
-        </plugins>
-    </build>
-</project>
diff --git 
a/surefire-its/src/test/resources/junit-platform-1.1.1/src/test/java/junitplatform_1_1_1/JUnitPlatform_1_1_1_Test.java
 
b/surefire-its/src/test/resources/junit-platform-1.1.1/src/test/java/junitplatform_1_1_1/JUnitPlatform_1_1_1_Test.java
deleted file mode 100644
index e1bc05e..0000000
--- 
a/surefire-its/src/test/resources/junit-platform-1.1.1/src/test/java/junitplatform_1_1_1/JUnitPlatform_1_1_1_Test.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package junitplatform_1_1_1;
-
-/*
- * 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.junit.jupiter.api.Assertions.assertEquals;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInfo;
-
-class JUnitPlatform_1_1_1_Test
-{
-
-    @Test
-    void test(TestInfo info)
-    {
-        assertEquals( "test(TestInfo)", info.getDisplayName(), "display name 
mismatch" );
-    }
-
-
-}
diff --git a/surefire-its/src/test/resources/junit-platform-1.2.0/pom.xml 
b/surefire-its/src/test/resources/junit-platform-1.2.0/pom.xml
deleted file mode 100644
index 8bc5638..0000000
--- a/surefire-its/src/test/resources/junit-platform-1.2.0/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0";
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
-    <modelVersion>4.0.0</modelVersion>
-
-    <groupId>org.apache.maven.plugins.surefire</groupId>
-    <artifactId>junit-platform-1.2.0</artifactId>
-    <version>1.0</version>
-    <name>Test for JUnit 5: Platform 1.2.0 + Jupiter 5.2.0</name>
-
-    <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
-    </properties>
-
-    <!--
-        Declare "junit-jupiter-engine" dependency because the
-        Jupiter Engine is needed at test runtime. Artifacts
-        needed for test compilation, like "junit-jupiter-api",
-        are pulled-in via transitive dependency resolution.
-    -->
-    <dependencies>
-        <dependency>
-            <groupId>org.junit.jupiter</groupId>
-            <artifactId>junit-jupiter-engine</artifactId>
-            <version>5.2.0</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${surefire.version}</version>
-            </plugin>
-        </plugins>
-    </build>
-</project>
diff --git 
a/surefire-its/src/test/resources/junit-platform-1.2.0/src/test/java/junitplatform_1_2_0/JUnitPlatform_1_2_0_Test.java
 
b/surefire-its/src/test/resources/junit-platform-1.2.0/src/test/java/junitplatform_1_2_0/JUnitPlatform_1_2_0_Test.java
deleted file mode 100644
index c6ccbfc..0000000
--- 
a/surefire-its/src/test/resources/junit-platform-1.2.0/src/test/java/junitplatform_1_2_0/JUnitPlatform_1_2_0_Test.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package junitplatform_1_2_0;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInfo;
-
-class JUnitPlatform_1_2_0_Test
-{
-
-    @Test
-    void test(TestInfo info)
-    {
-        assertEquals( "test(TestInfo)", info.getDisplayName(), "display name 
mismatch" );
-    }
-
-
-}
diff --git a/surefire-its/src/test/resources/junit-platform-1.0.0/pom.xml 
b/surefire-its/src/test/resources/junit-platform/pom.xml
similarity index 80%
rename from surefire-its/src/test/resources/junit-platform-1.0.0/pom.xml
rename to surefire-its/src/test/resources/junit-platform/pom.xml
index 1b6fd59..02e5c00 100644
--- a/surefire-its/src/test/resources/junit-platform-1.0.0/pom.xml
+++ b/surefire-its/src/test/resources/junit-platform/pom.xml
@@ -26,7 +26,7 @@
     <groupId>org.apache.maven.plugins.surefire</groupId>
     <artifactId>junit-platform-1.0.0</artifactId>
     <version>1.0</version>
-    <name>Test for JUnit 5: Platform 1.0.0 + Jupiter 5.0.0</name>
+    <name>Test for JUnit 5: Platform + Jupiter</name>
 
     <properties>
         <maven.compiler.source>1.8</maven.compiler.source>
@@ -43,7 +43,7 @@
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-engine</artifactId>
-            <version>5.0.0</version>
+            <version>${jupiter.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
@@ -57,4 +57,17 @@
             </plugin>
         </plugins>
     </build>
+
+    <repositories>
+        <repository>
+            <id>oss-sonatype</id>
+            <name>oss-sonatype</name>
+            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
+            <snapshots>
+                <enabled>true</enabled>
+                <updatePolicy>always</updatePolicy>
+                <checksumPolicy>ignore</checksumPolicy>
+            </snapshots>
+        </repository>
+    </repositories>
 </project>
diff --git 
a/surefire-its/src/test/resources/junit-platform-1.0.0/src/test/java/junitplatform_1_0_0/JUnitPlatform_1_0_0_Test.java
 
b/surefire-its/src/test/resources/junit-platform/src/test/java/junitplatform/JUnitPlatformTest.java
similarity index 97%
rename from 
surefire-its/src/test/resources/junit-platform-1.0.0/src/test/java/junitplatform_1_0_0/JUnitPlatform_1_0_0_Test.java
rename to 
surefire-its/src/test/resources/junit-platform/src/test/java/junitplatform/JUnitPlatformTest.java
index 760d874..68bbe02 100644
--- 
a/surefire-its/src/test/resources/junit-platform-1.0.0/src/test/java/junitplatform_1_0_0/JUnitPlatform_1_0_0_Test.java
+++ 
b/surefire-its/src/test/resources/junit-platform/src/test/java/junitplatform/JUnitPlatformTest.java
@@ -24,14 +24,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInfo;
 
-class JUnitPlatform_1_0_0_Test
+class JUnitPlatformTest
 {
-
     @Test
     void test(TestInfo info)
     {
         assertEquals( "test(TestInfo)", info.getDisplayName(), "display name 
mismatch" );
     }
-
-
 }
diff --git a/surefire-providers/surefire-junit-platform/pom.xml 
b/surefire-providers/surefire-junit-platform/pom.xml
index 18be313..4a57646 100644
--- a/surefire-providers/surefire-junit-platform/pom.xml
+++ b/surefire-providers/surefire-junit-platform/pom.xml
@@ -86,12 +86,12 @@
         <dependency>
             <groupId>org.junit.platform</groupId>
             <artifactId>junit-platform-launcher</artifactId>
-            <version>1.2.0</version>
+            <version>1.3.1</version>
         </dependency>
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-engine</artifactId>
-            <version>5.2.0</version>
+            <version>5.3.1</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git 
a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
 
b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
index 0cf526c..0ccb4fe 100644
--- 
a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
+++ 
b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
@@ -48,6 +48,7 @@ import org.junit.Test;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.engine.descriptor.ClassTestDescriptor;
 import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor;
+import org.junit.platform.engine.ConfigurationParameters;
 import org.junit.platform.engine.TestDescriptor;
 import org.junit.platform.engine.TestDescriptor.Type;
 import org.junit.platform.engine.TestExecutionResult;
@@ -68,6 +69,8 @@ import org.mockito.InOrder;
  */
 public class RunListenerAdapterTest
 {
+    private static final ConfigurationParameters CONFIG_PARAMS = 
mock(ConfigurationParameters.class);
+
     private RunListener listener;
 
     private RunListenerAdapter adapter;
@@ -444,7 +447,7 @@ public class RunListenerAdapterTest
 
     private static TestDescriptor newClassDescriptor()
     {
-        return new ClassTestDescriptor( UniqueId.root( "class", 
MyTestClass.class.getName() ), MyTestClass.class );
+        return new ClassTestDescriptor( UniqueId.root( "class", 
MyTestClass.class.getName() ), MyTestClass.class, CONFIG_PARAMS );
     }
 
     private static TestIdentifier newSourcelessChildIdentifierWithParent(
diff --git 
a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
 
b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
index efb0589..6d4394e 100644
--- 
a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
+++ 
b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
@@ -31,6 +31,7 @@ import org.apache.maven.surefire.testset.TestListResolver;
 import org.junit.Test;
 import org.junit.jupiter.engine.descriptor.ClassTestDescriptor;
 import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor;
+import org.junit.platform.engine.ConfigurationParameters;
 import org.junit.platform.engine.FilterResult;
 import org.junit.platform.engine.UniqueId;
 
@@ -41,6 +42,8 @@ import org.junit.platform.engine.UniqueId;
  */
 public class TestMethodFilterTest
 {
+    private static final ConfigurationParameters CONFIG_PARAMS = 
mock(ConfigurationParameters.class);
+
     private final TestListResolver resolver = mock( TestListResolver.class );
 
     private final TestMethodFilter filter = new TestMethodFilter( 
this.resolver );
@@ -90,7 +93,7 @@ public class TestMethodFilterTest
     private static ClassTestDescriptor newClassTestDescriptor()
     {
         UniqueId uniqueId = UniqueId.forEngine( "class" );
-        return new ClassTestDescriptor( uniqueId, TestClass.class );
+        return new ClassTestDescriptor( uniqueId, TestClass.class, 
CONFIG_PARAMS );
     }
 
     public static class TestClass

Reply via email to