You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2012/12/17 03:31:20 UTC

git commit: o Added reuseForks parameters instead of forkmode = onceperthread

Updated Branches:
  refs/heads/master 435ef473b -> 318f8a9a4


o Added reuseForks parameters instead of forkmode = onceperthread


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/318f8a9a
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/318f8a9a
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/318f8a9a

Branch: refs/heads/master
Commit: 318f8a9a465319c63aef20e5c89a64073579a631
Parents: 435ef47
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Fri Dec 14 20:00:08 2012 +0100
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Mon Dec 17 03:30:58 2012 +0100

----------------------------------------------------------------------
 .../plugin/surefire/AbstractSurefireMojo.java      |   38 ++++++++------
 .../surefire/booterclient/ForkConfiguration.java   |   16 ++++--
 .../plugin/surefire/booterclient/ForkStarter.java  |   13 +++--
 .../booterclient/ForkConfigurationTest.java        |    6 +--
 .../org/apache/maven/surefire/util/TestsToRun.java |   18 ++++++-
 .../apache/maven/surefire/util/TestsToRunTest.java |   25 +++++++---
 surefire-integration-tests/pom.xml                 |    2 +-
 .../surefire/its/fixture/SurefireLauncher.java     |    4 +-
 .../Surefire907PerThreadWithoutThreadCountIT.java  |    2 +-
 .../surefire/junitcore/JUnitCoreParameters.java    |    9 ++++
 .../surefire/junitcore/JUnitCoreProvider.java      |    2 +-
 .../maven/surefire/junitcore/JUnitCoreWrapper.java |   38 +++++----------
 12 files changed, 105 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
----------------------------------------------------------------------
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 9636017..fd00d5f 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
@@ -329,9 +329,8 @@ public abstract class AbstractSurefireMojo
     protected Boolean failIfNoTests;
 
     /**
-     * Option to specify the forking mode. Can be "never", "once", "always", "perthread" or "onceperthread". "none" and "pertest" are also accepted
-     * for backwards compatibility. "always" forks for each test-class. "perthread" will create "threadCount" parallel forks, each executing one test-class.
-     * "onceperthread" will fork "threadCount" processes that each execute a 1/"threadCount" of all test-classes.<br/>
+     * Option to specify the forking mode. Can be "never", "once", "always", "perthread". "none" and "pertest" are also accepted
+     * for backwards compatibility. "always" forks for each test-class. "perthread" will create "threadCount" parallel forks, each executing one test-class, see also parameter reuseForks.<br/>
      * The system properties and the "argLine" of the forked processes may contain the place holder string <code>${surefire.threadNumber}</code>,
      * which is replaced with a fixed number for each thread, ranging from 1 to "threadCount".
      *
@@ -434,15 +433,25 @@ public abstract class AbstractSurefireMojo
     protected String testNGArtifactName;
 
     /**
-     * (forkMode=perthread, forkmode=onceperthread or TestNG/JUnit 4.7 provider) The attribute thread-count allows you to specify how many threads should be
-     * allocated for this execution. Only makes sense to use in conjunction with the <code>parallel</code> parameter or with forkMode=perthread
-     * or forkmode=onceperthread.
+     * (forkMode=perthread or TestNG/JUnit 4.7 provider) The attribute thread-count allows you to specify how many threads should be
+     * allocated for this execution. Only makes sense to use in conjunction with the <code>parallel</code> parameter or with forkMode=perthread.
      *
      * @since 2.2
      */
     @Parameter( property = "threadCount" )
     protected int threadCount;
 
+
+    /**
+     * Indicates if forks can be reused. Currently only meaningful
+     * when forking N parallel forks
+     *
+     * @since 2.13
+     */
+
+    @Parameter( property = "reuseForks", defaultValue = "false" )
+    private boolean reuseForks;
+
     /**
      * (JUnit 4.7 provider) Indicates that threadCount is per cpu core.
      *
@@ -783,8 +792,7 @@ public abstract class AbstractSurefireMojo
             try
             {
                 ForkStarter forkStarter =
-                    createForkStarter( provider, forkConfiguration, classLoaderConfiguration, runOrderParameters,
-                                       effectiveProperties );
+                    createForkStarter( provider, forkConfiguration, classLoaderConfiguration, runOrderParameters );
                 result = forkStarter.run( effectiveProperties, scanResult, getEffectiveForkMode() );
             }
             finally
@@ -918,6 +926,7 @@ public abstract class AbstractSurefireMojo
             getProperties().setProperty( ProviderParameterNames.THREADCOUNT_PROP,
                                          Integer.toString( this.getThreadCount() ) );
         }
+        getProperties().setProperty( "reuseForks", Boolean.toString( reuseForks ) );
         getProperties().setProperty( "perCoreThreadCount", Boolean.toString( getPerCoreThreadCount() ) );
         getProperties().setProperty( "useUnlimitedThreads", Boolean.toString( getUseUnlimitedThreads() ) );
     }
@@ -1341,8 +1350,7 @@ public abstract class AbstractSurefireMojo
 
     protected ForkStarter createForkStarter( ProviderInfo provider, ForkConfiguration forkConfiguration,
                                              ClassLoaderConfiguration classLoaderConfiguration,
-                                             RunOrderParameters runOrderParameters,
-                                             SurefireProperties effectiveSystemProperties )
+                                             RunOrderParameters runOrderParameters )
         throws MojoExecutionException, MojoFailureException
     {
         StartupConfiguration startupConfiguration = createStartupConfiguration( provider, classLoaderConfiguration );
@@ -1381,14 +1389,13 @@ public abstract class AbstractSurefireMojo
                                       getEffectiveJvm(),
                                       getWorkingDirectory() != null ? getWorkingDirectory() : getBasedir(),
                                       getArgLine(), getEnvironmentVariables(), getLog().isDebugEnabled(),
-                                      getEffectiveForkCount() );
+                                      getEffectiveForkCount(), reuseForks );
     }
 
 
     private int getEffectiveForkCount()
     {
-        return ( ForkConfiguration.FORK_PERTHREAD.equals( getEffectiveForkMode() )
-            || ForkConfiguration.FORK_ONCE_PERTHREAD.equals( getEffectiveForkMode() ) ) ? getThreadCount() : 1;
+        return ForkConfiguration.FORK_PERTHREAD.equals( getEffectiveForkMode() ) ? getThreadCount() : 1;
     }
 
     private String getEffectiveDebugForkedProcess()
@@ -1772,10 +1779,9 @@ public abstract class AbstractSurefireMojo
     void ensureThreadCountWithPerThread()
         throws MojoFailureException
     {
-        if ( ( ForkConfiguration.FORK_PERTHREAD.equals( getEffectiveForkMode() )
-            || ForkConfiguration.FORK_ONCE_PERTHREAD.equals( getEffectiveForkMode() ) ) && getThreadCount() < 1 )
+        if ( ForkConfiguration.FORK_PERTHREAD.equals( getEffectiveForkMode() ) && getThreadCount() < 1 )
         {
-            throw new MojoFailureException( "Fork modes perthread and onceperthread require a thread count" );
+            throw new MojoFailureException( "Fork mode perthread requires a thread count" );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 28c4fee..9f8780b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -54,10 +54,10 @@ public class ForkConfiguration
 
     public static final String FORK_PERTHREAD = "perthread";
 
-    public static final String FORK_ONCE_PERTHREAD = "onceperthread";
-
     private final int forkCount;
 
+    private final boolean reuseForks;
+
     private final Classpath bootClasspathConfiguration;
 
     private final String jvmExecutable;
@@ -76,7 +76,7 @@ public class ForkConfiguration
 
     public ForkConfiguration( Classpath bootClasspathConfiguration, File tmpDir, String debugLine, String jvmExecutable,
                               File workingDirectory, String argLine, Map<String, String> environmentVariables,
-                              boolean debugEnabled, int forkCount )
+                              boolean debugEnabled, int forkCount, boolean reuseForks )
     {
         this.bootClasspathConfiguration = bootClasspathConfiguration;
         this.tempDirectory = tmpDir;
@@ -87,6 +87,7 @@ public class ForkConfiguration
         this.environmentVariables = environmentVariables;
         this.debug = debugEnabled;
         this.forkCount = forkCount;
+        this.reuseForks = reuseForks;
     }
 
     public Classpath getBootClasspath()
@@ -105,8 +106,7 @@ public class ForkConfiguration
             return FORK_NEVER;
         }
         else if ( forkMode.equals( FORK_NEVER ) || forkMode.equals( FORK_ONCE ) ||
-            forkMode.equals( FORK_ALWAYS ) || forkMode.equals( FORK_PERTHREAD ) ||
-            forkMode.equals( FORK_ONCE_PERTHREAD ) )
+            forkMode.equals( FORK_ALWAYS ) || forkMode.equals( FORK_PERTHREAD ) )
         {
             return forkMode;
         }
@@ -266,4 +266,10 @@ public class ForkConfiguration
     {
         return forkCount;
     }
+
+
+    public boolean isReuseForks()
+    {
+        return reuseForks;
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
index bcd1931..590161a 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
@@ -141,11 +141,14 @@ public class ForkStarter
             }
             else if ( ForkConfiguration.FORK_PERTHREAD.equals( requestedForkMode ) )
             {
-                result = runSuitesForkPerTestSet( effectiveSystemProperties, forkConfiguration.getForkCount() );
-            }
-            else if ( ForkConfiguration.FORK_ONCE_PERTHREAD.equals( requestedForkMode ) )
-            {
-                result = runSuitesForkOncePerThread( effectiveSystemProperties, forkConfiguration.getForkCount() );
+                if ( forkConfiguration.isReuseForks() )
+                {
+                    result = runSuitesForkOncePerThread( effectiveSystemProperties, forkConfiguration.getForkCount() );
+                }
+                else
+                {
+                    result = runSuitesForkPerTestSet( effectiveSystemProperties, forkConfiguration.getForkCount() );
+                }
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
index 5c93722..b272aac 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
@@ -70,10 +70,8 @@ public class ForkConfigurationTest
     public static ForkConfiguration getForkConfiguration( String argLine, String jvm )
         throws IOException
     {
-        ForkConfiguration forkConfiguration =
-            new ForkConfiguration( new Classpath(), null, null, jvm, new File( "." ).getCanonicalFile(), argLine, null,
-                                   false, 1 );
-        return forkConfiguration;
+        return new ForkConfiguration( new Classpath(), null, null, jvm, new File( "." ).getCanonicalFile(), argLine, null,
+                               false, 1, false );
     }
 
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
index 02224ab..760907c 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
@@ -19,13 +19,13 @@ package org.apache.maven.surefire.util;
  * under the License.
  */
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
-
 import org.apache.maven.surefire.testset.TestSetFailedException;
 
 /**
@@ -118,11 +118,25 @@ public class TestsToRun
 
     /**
      * @return {@code true}, if the classes may be read eagerly. {@code false},
-     * if the classes must only be read lazy.
+     *         if the classes must only be read lazy.
      */
     public boolean allowEagerReading()
     {
         return true;
     }
 
+    public Class[] getLocatedClasses()
+    {
+        if ( !allowEagerReading() )
+        {
+            throw new IllegalStateException( "Cannot eagerly read" );
+        }
+        List result = new ArrayList();
+        Iterator it = iterator();
+        while ( it.hasNext() )
+        {
+            result.add( it.next() );
+        }
+        return (Class[]) result.toArray( new Class[result.size()] );
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java
index 165324f..c7029c0 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java
@@ -43,18 +43,28 @@ public class TestsToRunTest
         assertFalse( it.hasNext() );
     }
 
-    public void testContainsAtleast(){
+    public void testContainsAtleast()
+    {
+        TestsToRun testsToRun = new TestsToRun( Arrays.asList( new Class[]{ T1.class, T2.class } ) );
+        assertTrue( testsToRun.containsAtLeast( 2 ) );
+        assertFalse( testsToRun.containsAtLeast( 3 ) );
+    }
+
+    public void testContainsExactly()
+    {
         TestsToRun testsToRun = new TestsToRun( Arrays.asList( new Class[]{ T1.class, T2.class } ) );
-        assertTrue(testsToRun.containsAtLeast( 2 ));
-        assertFalse(testsToRun.containsAtLeast( 3 ));
+        assertFalse( testsToRun.containsExactly( 1 ) );
+        assertTrue( testsToRun.containsExactly( 2 ) );
+        assertFalse( testsToRun.containsExactly( 3 ) );
     }
 
-    public void testContainsExactly(){
+    public void testToRunArray()
+    {
         TestsToRun testsToRun = new TestsToRun( Arrays.asList( new Class[]{ T1.class, T2.class } ) );
-        assertFalse(testsToRun.containsExactly( 1 ));
-        assertTrue(testsToRun.containsExactly( 2 ));
-        assertFalse(testsToRun.containsExactly( 3 ));
+        Class[] locatedClasses = testsToRun.getLocatedClasses();
+        assertEquals( 2, locatedClasses.length );
     }
+
     class T1
     {
 
@@ -65,3 +75,4 @@ public class TestsToRunTest
 
     }
 }
+

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/surefire-integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/pom.xml b/surefire-integration-tests/pom.xml
index 431eab3..55191dd 100644
--- a/surefire-integration-tests/pom.xml
+++ b/surefire-integration-tests/pom.xml
@@ -96,7 +96,7 @@
           <threadCount>1</threadCount>
           <perCoreThreadCount>false</perCoreThreadCount>
           <forkMode>never</forkMode>
-          <argLine>-Xmx512m -XX:MaxPermSize=256m</argLine>
+          <argLine>-Xmx512m -XX:MaxPermSize=356m</argLine>
           <!-- Pass current surefire version to the main suite so that it -->
           <!-- can forward to all integration test projects. SUREFIRE-513 -->
           <systemPropertyVariables>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
index cbc0d31..1d3d983 100755
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
@@ -239,7 +239,9 @@ public class SurefireLauncher
 
     public SurefireLauncher forkOncePerThread()
     {
-        return forkMode( "onceperthread" );
+        forkPerThread();
+        mavenLauncher.sysProp( "reuseForks", true );
+        return this;
     }
 
     public SurefireLauncher threadCount( int threadCount )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire907PerThreadWithoutThreadCountIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire907PerThreadWithoutThreadCountIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire907PerThreadWithoutThreadCountIT.java
index c6cedea..96e913c 100755
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire907PerThreadWithoutThreadCountIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire907PerThreadWithoutThreadCountIT.java
@@ -30,7 +30,7 @@ public class Surefire907PerThreadWithoutThreadCountIT
     public void categoryAB()
     {
         OutputValidator validator = unpack( "fork-mode" ).forkPerThread().maven().withFailure().executeTest();
-        validator.verifyTextInLog( "Fork modes perthread and onceperthread require a thread count" );
+        validator.verifyTextInLog( "Fork mode perthread requires a thread count" );
     }
 
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
index 91a954f..4a7e70c 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
@@ -35,6 +35,8 @@ class JUnitCoreParameters
 
     private final Boolean useUnlimitedThreads;
 
+    private final boolean reuseForks;
+
     public static final String PARALLEL_KEY = ProviderParameterNames.PARALLEL_PROP;
 
     public static final String PERCORETHREADCOUNT_KEY = "perCoreThreadCount";
@@ -43,6 +45,7 @@ class JUnitCoreParameters
 
     public static final String USEUNLIMITEDTHREADS_KEY = "useUnlimitedThreads";
 
+    public static final String REUSEFORKS_KEY = "reuseForks";
 
     public JUnitCoreParameters( Properties properties )
     {
@@ -50,6 +53,7 @@ class JUnitCoreParameters
         this.perCoreThreadCount = Boolean.valueOf( properties.getProperty( PERCORETHREADCOUNT_KEY, "true" ) );
         this.threadCount = Integer.valueOf( properties.getProperty( THREADCOUNT_KEY, "2" ) );
         this.useUnlimitedThreads = Boolean.valueOf( properties.getProperty( USEUNLIMITEDTHREADS_KEY, "false" ) );
+        this.reuseForks = Boolean.valueOf( properties.getProperty( REUSEFORKS_KEY, "false" ) );
     }
 
     public boolean isParallelMethod()
@@ -92,6 +96,11 @@ class JUnitCoreParameters
         return !isNoThreading();
     }
 
+    public boolean isReuseForks()
+    {
+        return reuseForks;
+    }
+
     @Override
     public String toString()
     {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
index b880785..1f01e10 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-
 import org.apache.maven.surefire.common.junit4.JUnit4RunListenerFactory;
 import org.apache.maven.surefire.common.junit4.JUnit4TestChecker;
 import org.apache.maven.surefire.common.junit48.FilterFactory;
@@ -107,6 +106,7 @@ public class JUnitCoreProvider
             && !jUnitCoreParameters.isParallelMethod() );
     }
 
+
     public RunResult invoke( Object forkTestSet )
         throws TestSetFailedException, ReporterException
     {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/318f8a9a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
index c834e6f..4473063 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
@@ -19,14 +19,13 @@ package org.apache.maven.surefire.junitcore;
  * under the License.
  */
 
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
-
 import org.apache.maven.surefire.common.junit4.JUnit4RunListener;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.TestsToRun;
+
 import org.junit.runner.Computer;
 import org.junit.runner.JUnitCore;
 import org.junit.runner.Request;
@@ -88,29 +87,28 @@ class JUnitCoreWrapper
             {
                 exeuteLazy( testsToRun, filter, computer, junitCore );
             }
-            
         }
         finally
         {
             closeIfConfigurable( computer );
-            for ( RunListener runListener : listeners )
-            {
-                junitCore.removeListener( runListener );
-            }
         }
     }
 
-    private static void executeEager(TestsToRun testsToRun, Filter filter, Computer computer, JUnitCore junitCore)
-            throws TestSetFailedException 
+    private static JUnitCore createJUnitCore( List<RunListener> listeners )
     {
-        List<Class<?>> testList = new ArrayList<Class<?>>(500);
-        Iterator<?> classIter = testsToRun.iterator();
-
-        while ( classIter.hasNext() )
+        JUnitCore junitCore = new JUnitCore();
+        for ( RunListener runListener : listeners )
         {
-            testList.add((Class<?>) classIter.next());
+            junitCore.addListener( runListener );
         }
-        createReqestAndRun( filter, computer, junitCore, testList.toArray( new Class[ testList.size() ] ) );
+        return junitCore;
+    }
+
+    private static void executeEager(TestsToRun testsToRun, Filter filter, Computer computer, JUnitCore junitCore)
+            throws TestSetFailedException 
+    {
+        Class[] tests = testsToRun.getLocatedClasses();
+        createReqestAndRun( filter, computer, junitCore, tests );
     }
 
     private static void exeuteLazy(TestsToRun testsToRun, Filter filter, Computer computer, JUnitCore junitCore)
@@ -184,14 +182,4 @@ class JUnitCoreWrapper
         }
     }
 
-    private static JUnitCore createJUnitCore( List<RunListener> listeners )
-    {
-        JUnitCore junitCore = new JUnitCore();
-        for ( RunListener runListener : listeners )
-        {
-            junitCore.addListener( runListener );
-        }
-        return junitCore;
-    }
-
 }