You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2015/07/23 23:29:05 UTC

[01/19] maven-surefire git commit: [SUREFIRE] refactoring

Repository: maven-surefire
Updated Branches:
  refs/heads/master cf64b1137 -> 78dca27ef


[SUREFIRE] refactoring


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

Branch: refs/heads/master
Commit: 7d9c438defa0fe847d2b4c14173a8b4098b6c4c6
Parents: cf64b11
Author: Tibor17 <ti...@lycos.com>
Authored: Sun Jul 5 09:32:29 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:00 2015 +0200

----------------------------------------------------------------------
 .../booterclient/output/ForkClient.java         |  3 +--
 .../maven/surefire/util/DefaultScanResult.java  | 12 ++++------
 .../maven/surefire/util/ReflectionUtils.java    |  5 ++--
 .../apache/maven/surefire/util/ScanResult.java  |  2 +-
 .../common/junit4/JUnit4RunListenerFactory.java | 24 ++++++++++----------
 .../maven/surefire/junit/JUnit3Provider.java    |  2 +-
 .../maven/surefire/junit4/JUnit4Provider.java   | 19 ++++++++--------
 7 files changed, 32 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7d9c438d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
index b6bbd55..cea1824 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
@@ -209,8 +209,7 @@ public class ForkClient
         throws IOException
     {
         BufferedReader stringReader = new BufferedReader( new StringReader( s ) );
-        String s1;
-        while ( ( s1 = stringReader.readLine() ) != null )
+        for ( String s1 = stringReader.readLine(); s1 != null; s1 = stringReader.readLine() )
         {
             consumeLine( s1 );
         }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7d9c438d/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
index ae05d0d..ab4c8b2 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
@@ -102,16 +102,16 @@ public class DefaultScanResult
         return new TestsToRun( result );
     }
 
-    public List getClassesSkippedByValidation( ScannerFilter scannerFilter, ClassLoader testClassLoader )
+    public List<Class<?>> getClassesSkippedByValidation( ScannerFilter scannerFilter, ClassLoader testClassLoader )
     {
-        List<Class> result = new ArrayList<Class>();
+        List<Class<?>> result = new ArrayList<Class<?>>();
 
         int size = size();
         for ( int i = 0; i < size; i++ )
         {
             String className = getClassName( i );
 
-            Class testClass = loadClass( testClassLoader, className );
+            Class<?> testClass = loadClass( testClassLoader, className );
 
             if ( scannerFilter != null && !scannerFilter.accept( testClass ) )
             {
@@ -122,18 +122,16 @@ public class DefaultScanResult
         return result;
     }
 
-    private static Class loadClass( ClassLoader classLoader, String className )
+    private static Class<?> loadClass( ClassLoader classLoader, String className )
     {
-        Class testClass;
         try
         {
-            testClass = classLoader.loadClass( className );
+            return classLoader.loadClass( className );
         }
         catch ( ClassNotFoundException e )
         {
             throw new RuntimeException( "Unable to create test class '" + className + "'", e );
         }
-        return testClass;
     }
 
     public DefaultScanResult append( DefaultScanResult other )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7d9c438d/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
index 0d6f7dc..bba1a59 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
@@ -101,13 +101,12 @@ public class ReflectionUtils
         }
     }
 
-    public static Object instantiate( ClassLoader classLoader, String classname )
+    public static <T> T instantiate( ClassLoader classLoader, String classname, Class<T> returnType )
     {
         try
         {
-
             Class clazz = loadClass( classLoader, classname );
-            return clazz.newInstance();
+            return returnType.cast( clazz.newInstance() );
         }
         catch ( InstantiationException e )
         {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7d9c438d/surefire-api/src/main/java/org/apache/maven/surefire/util/ScanResult.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/ScanResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/ScanResult.java
index 2a73a47..5960ee6 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/ScanResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/ScanResult.java
@@ -33,7 +33,7 @@ public interface ScanResult
 
     TestsToRun applyFilter( ScannerFilter scannerFilter, ClassLoader testClassLoader );
 
-    List getClassesSkippedByValidation( ScannerFilter scannerFilter, ClassLoader testClassLoader );
+    List<Class<?>> getClassesSkippedByValidation( ScannerFilter scannerFilter, ClassLoader testClassLoader );
 
     void writeTo( Map<String, String> properties );
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7d9c438d/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerFactory.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerFactory.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerFactory.java
index 83a74a0..1cf5417 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerFactory.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerFactory.java
@@ -21,6 +21,8 @@ package org.apache.maven.surefire.common.junit4;
 
 import java.util.LinkedList;
 import java.util.List;
+
+import org.apache.maven.shared.utils.StringUtils;
 import org.apache.maven.surefire.util.ReflectionUtils;
 
 import org.junit.runner.notification.RunListener;
@@ -30,22 +32,20 @@ import org.junit.runner.notification.RunListener;
  */
 public class JUnit4RunListenerFactory
 {
-    public static List<RunListener> createCustomListeners( String listenerProperty )
+    public static List<RunListener> createCustomListeners( String listeners )
     {
         List<RunListener> result = new LinkedList<RunListener>();
-        if ( listenerProperty == null )
+        if ( StringUtils.isNotBlank( listeners ) )
         {
-            return result;
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            for ( String listener : listeners.split( "," ) )
+            {
+                if ( StringUtils.isNotBlank( listener ) )
+                {
+                    result.add( ReflectionUtils.instantiate( cl, listener, RunListener.class ) );
+                }
+            }
         }
-
-        for ( String thisListenerName : listenerProperty.split( "," ) )
-        {
-            RunListener customRunListener =
-                (RunListener) ReflectionUtils.instantiate( Thread.currentThread().getContextClassLoader(),
-                                                           thisListenerName );
-            result.add( customRunListener );
-        }
-
         return result;
     }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7d9c438d/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
index be90068..d520c4f 100644
--- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
+++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
@@ -97,7 +97,7 @@ public class JUnit3Provider
         if ( smClassName != null )
         {
             SecurityManager securityManager =
-                (SecurityManager) ReflectionUtils.instantiate( this.getClass().getClassLoader(), smClassName );
+                ReflectionUtils.instantiate( getClass().getClassLoader(), smClassName, SecurityManager.class );
             System.setSecurityManager( securityManager );
         }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7d9c438d/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
index 45b907d..7f3d1b6 100644
--- a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
+++ b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
@@ -44,6 +44,7 @@ import org.apache.maven.surefire.report.RunListener;
 import org.apache.maven.surefire.report.SimpleReportEntry;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestListResolver;
+import org.apache.maven.surefire.testset.TestRequest;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.RunOrderCalculator;
 import org.apache.maven.surefire.util.ScanResult;
@@ -87,11 +88,12 @@ public class JUnit4Provider
         testClassLoader = booterParameters.getTestClassLoader();
         scanResult = booterParameters.getScanResult();
         runOrderCalculator = booterParameters.getRunOrderCalculator();
-        customRunListeners = JUnit4RunListenerFactory.
-            createCustomListeners( booterParameters.getProviderProperties().get( "listener" ) );
+        String listeners = booterParameters.getProviderProperties().get( "listener" );
+        customRunListeners = JUnit4RunListenerFactory.createCustomListeners( listeners );
         jUnit4TestChecker = new JUnit4TestChecker( testClassLoader );
-        testResolver = booterParameters.getTestRequest().getTestListResolver();
-        rerunFailingTestsCount = booterParameters.getTestRequest().getRerunFailingTestsCount();
+        TestRequest testRequest = booterParameters.getTestRequest();
+        testResolver = testRequest.getTestListResolver();
+        rerunFailingTestsCount = testRequest.getRerunFailingTestsCount();
     }
 
     public RunResult invoke( Object forkTestSet )
@@ -176,8 +178,8 @@ public class JUnit4Provider
         {
             for ( int i = 0; i < rerunFailingTestsCount && !failureListener.getAllFailures().isEmpty(); i++ )
             {
-                Set<ClassMethod> failedTests = JUnit4ProviderUtil.generateFailingTests(
-                        failureListener.getAllFailures( ) );
+                Set<ClassMethod> failedTests =
+                    JUnit4ProviderUtil.generateFailingTests( failureListener.getAllFailures() );
                 failureListener.reset();
                 if ( !failedTests.isEmpty() )
                 {
@@ -203,7 +205,7 @@ public class JUnit4Provider
     // I am not entirely sure as to why we do this explicit freeing, it's one of those
     // pieces of code that just seem to linger on in here ;)
     private static void closeRunNotifier( org.junit.runner.notification.RunListener main,
-                                   List<org.junit.runner.notification.RunListener> others )
+                                   Iterable<org.junit.runner.notification.RunListener> others )
     {
         RunNotifier notifier = new RunNotifier();
         notifier.removeListener( main );
@@ -225,13 +227,12 @@ public class JUnit4Provider
         return runOrderCalculator.orderTestClasses( scannedClasses );
     }
 
-    @SuppressWarnings( "unchecked" )
     private void upgradeCheck()
         throws TestSetFailedException
     {
         if ( isJUnit4UpgradeCheck() )
         {
-            List<Class> classesSkippedByValidation =
+            Collection<Class<?>> classesSkippedByValidation =
                 scanResult.getClassesSkippedByValidation( jUnit4TestChecker, testClassLoader );
             if ( !classesSkippedByValidation.isEmpty() )
             {


[12/19] maven-surefire git commit: [SUREFIRE] refactoring: don't provide new test if closed stream

Posted by ti...@apache.org.
[SUREFIRE] refactoring: don't provide new test if closed stream


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

Branch: refs/heads/master
Commit: 02cdeaf85366f5abae8eb32469f9cc06b51addac
Parents: d4b495f
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Jul 13 23:56:57 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:11 2015 +0200

----------------------------------------------------------------------
 .../booterclient/lazytestprovider/TestProvidingInputStream.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/02cdeaf8/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index c82f554..39e0c4d 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -161,7 +161,10 @@ public class TestProvidingInputStream
      */
     public void provideNewTest()
     {
-        semaphore.release();
+        if ( !closed.get() )
+        {
+            semaphore.release();
+        }
     }
 
     @Override


[05/19] maven-surefire git commit: [SUREFIRE] refactoring of StringUtils

Posted by ti...@apache.org.
[SUREFIRE] refactoring of StringUtils


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

Branch: refs/heads/master
Commit: 4b35269b1e4df43464afaba1241045b46ebe9324
Parents: 1d0ac00
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Jul 13 20:53:13 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:05 2015 +0200

----------------------------------------------------------------------
 .../org/apache/maven/surefire/util/internal/StringUtils.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4b35269b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index 831c7e7..8158fb7 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -82,7 +82,7 @@ public class StringUtils
         }
 
         int listSize = tok.countTokens();
-        if ( ( max > 0 ) && ( listSize > max ) )
+        if ( max > 0 && listSize > max )
         {
             listSize = max;
         }
@@ -93,7 +93,7 @@ public class StringUtils
         int lastTokenEnd = 0;
         while ( tok.hasMoreTokens() )
         {
-            if ( ( max > 0 ) && ( i == listSize - 1 ) )
+            if ( max > 0 && i == listSize - 1 )
             {
                 // In the situation where we hit the max yet have
                 // tokens left over in our input, the last list


[03/19] maven-surefire git commit: [SUREFIRE] refactoring Class, timer with Executors.newScheduledThreadPool, public method modifiers to private.

Posted by ti...@apache.org.
[SUREFIRE] refactoring Class<?>, timer with Executors.newScheduledThreadPool, public method modifiers to private.


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

Branch: refs/heads/master
Commit: e8cd8cc8764835374ef9865ed1369fdda62f1d6a
Parents: e53ab12
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Jul 13 12:30:50 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:03 2015 +0200

----------------------------------------------------------------------
 .../surefire/booterclient/BooterSerializer.java |  1 -
 .../surefire/booterclient/ForkStarter.java      | 19 +++--------
 .../booterclient/output/ForkClient.java         | 19 +++++------
 .../output/ThreadedStreamConsumer.java          |  7 ++--
 .../runorder/RunEntryStatisticsMapTest.java     | 16 +++++----
 .../surefire/runorder/PrioritizedTest.java      |  6 ++--
 .../runorder/RunEntryStatisticsMap.java         | 25 ++++++--------
 .../runorder/ThreadedExecutionScheduler.java    | 11 +++---
 .../surefire/providerapi/SurefireProvider.java  |  3 +-
 .../surefire/util/DefaultDirectoryScanner.java  |  8 +----
 .../util/DefaultRunOrderCalculator.java         | 10 +++---
 .../maven/surefire/util/DefaultScanResult.java  |  4 +--
 .../maven/surefire/util/ReflectionUtils.java    | 15 +++------
 .../apache/maven/surefire/util/TestsToRun.java  | 31 ++++++++---------
 .../surefire/util/internal/StringUtils.java     | 14 ++++++++
 .../ThreadedExecutionSchedulerTest.java         |  2 +-
 .../surefire/util/RunOrderCalculatorTest.java   |  4 +--
 .../maven/surefire/util/TestsToRunTest.java     | 14 ++++----
 .../maven/surefire/booter/ForkedBooter.java     | 35 ++++++++++----------
 .../maven/surefire/booter/LazyTestsToRun.java   | 26 +++++++--------
 .../maven/surefire/booter/ProviderFactory.java  |  7 ++--
 .../surefire/testprovider/TestProvider.java     |  3 +-
 .../maven/surefire/junit/JUnit3Provider.java    |  5 ++-
 .../maven/surefire/junit4/JUnit4Provider.java   |  5 ++-
 .../surefire/junitcore/JUnitCoreProvider.java   |  5 ++-
 .../surefire/junitcore/JUnitCoreWrapper.java    |  2 +-
 .../testng/TestNGDirectoryTestSuite.java        |  1 -
 .../maven/surefire/testng/TestNGProvider.java   |  9 +++--
 28 files changed, 144 insertions(+), 163 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
index 4b2aeaf..0164ba9 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
@@ -41,7 +41,6 @@ import org.apache.maven.surefire.util.RunOrder;
 
 // CHECKSTYLE_OFF: imports
 import static org.apache.maven.surefire.booter.BooterConstants.*;
-import static org.apache.maven.surefire.cli.CommandLineOption.*;
 
 /**
  * Knows how to serialize and deserialize the booter configuration.

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/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 0514e47..64bce8b 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
@@ -57,8 +57,6 @@ import java.io.InputStream;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Queue;
 import java.util.concurrent.ArrayBlockingQueue;
@@ -217,20 +215,13 @@ public class ForkStarter
         {
             // Ask to the executorService to run all tasks
             RunResult globalResult = new RunResult( 0, 0, 0, 0 );
-
-            List<Class<?>> suites = new ArrayList<Class<?>>();
-            for ( Iterator<Class<?>> suitesIterator = getSuitesIterator(); suitesIterator.hasNext(); )
-            {
-                suites.add( suitesIterator.next() );
-            }
             final Queue<String> messageQueue = new ConcurrentLinkedQueue<String>();
-            for ( Class<?> clazz : suites )
+            for ( Class<?> clazz : getSuitesIterator() )
             {
                 messageQueue.add( clazz.getName() );
             }
 
-
-            for ( int forkNum = 0; forkNum < forkCount && forkNum < suites.size(); forkNum++ )
+            for ( int forkNum = 0, total = messageQueue.size(); forkNum < forkCount && forkNum < total; forkNum++ )
             {
                 Callable<RunResult> pf = new Callable<RunResult>()
                 {
@@ -303,9 +294,8 @@ public class ForkStarter
             // Ask to the executorService to run all tasks
             RunResult globalResult = new RunResult( 0, 0, 0, 0 );
 
-            for ( final Iterator<Class<?>> suites = getSuitesIterator(); suites.hasNext(); )
+            for ( final Object testSet : getSuitesIterator() )
             {
-                final Object testSet = suites.next();
                 Callable<RunResult> pf = new Callable<RunResult>()
                 {
                     public RunResult call()
@@ -532,8 +522,7 @@ public class ForkStarter
         return runResult;
     }
 
-    @SuppressWarnings( "unchecked" )
-    private Iterator<Class<?>> getSuitesIterator()
+    private Iterable<Class<?>> getSuitesIterator()
         throws SurefireBooterForkException
     {
         try

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
index 54ee5e4..8e12e04 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
@@ -82,12 +82,16 @@ public class ForkClient
 
     public void consumeLine( String s )
     {
+        if ( StringUtils.isNotBlank( s ) )
+        {
+            processLine( s );
+        }
+    }
+
+    private void processLine( String s )
+    {
         try
         {
-            if ( s.length() == 0 )
-            {
-                return;
-            }
             final byte operationId = (byte) s.charAt( 0 );
             int commma = s.indexOf( ",", 3 );
             if ( commma < 0 )
@@ -253,17 +257,12 @@ public class ForkClient
 
     private String nullableCsv( String source )
     {
-        if ( "null".equals( source ) )
-        {
-            return null;
-        }
-        return unescape( source );
+        return "null".equals( source ) ? null : unescape( source );
     }
 
     private String unescape( String source )
     {
         StringBuilder stringBuffer = new StringBuilder( source.length() );
-
         StringUtils.unescapeString( stringBuffer, source );
         return stringBuffer.toString();
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
index c7b4e66..fdb88ec 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
@@ -30,14 +30,15 @@ import java.util.concurrent.LinkedBlockingQueue;
  *
  * @author Kristian Rosenvold
  */
-public class ThreadedStreamConsumer
+public final class ThreadedStreamConsumer
     implements StreamConsumer
 {
-    private final BlockingQueue<String> items = new LinkedBlockingQueue<String>();
-
     private static final String POISON = "Pioson";
+
     private static final int ITEM_LIMIT_BEFORE_SLEEP = 10000;
 
+    private final BlockingQueue<String> items = new LinkedBlockingQueue<String>();
+
     private final Thread thread;
 
     private final Pumper pumper;

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMapTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMapTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMapTest.java
index e86ac4b..5a171ab 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMapTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMapTest.java
@@ -39,8 +39,9 @@ public class RunEntryStatisticsMapTest
         throws IOException
     {
         final RunEntryStatisticsMap runEntryStatisticsMap = RunEntryStatisticsMap.fromReader( getStatisticsFile() );
-        final List<?> list = Arrays.asList( new Class[]{ A.class, B.class, C.class } );
-        final List<?> prioritizedTestsClassRunTime = runEntryStatisticsMap.getPrioritizedTestsClassRunTime( list, 2 );
+        final List<Class<?>> list = Arrays.<Class<?>>asList( A.class, B.class, C.class );
+        final List<Class<?>> prioritizedTestsClassRunTime =
+            runEntryStatisticsMap.getPrioritizedTestsClassRunTime( list, 2 );
         assertEquals( C.class, prioritizedTestsClassRunTime.get( 0 ) );
         assertEquals( B.class, prioritizedTestsClassRunTime.get( 1 ) );
         assertEquals( A.class, prioritizedTestsClassRunTime.get( 2 ) );
@@ -50,8 +51,9 @@ public class RunEntryStatisticsMapTest
         throws IOException
     {
         final RunEntryStatisticsMap runEntryStatisticsMap = RunEntryStatisticsMap.fromReader( getStatisticsFile() );
-        final List<?> list = Arrays.asList( A.class, B.class, NewClass.class, C.class );
-        final List<?> prioritizedTestsClassRunTime = runEntryStatisticsMap.getPrioritizedTestsByFailureFirst( list );
+        final List<Class<?>> list = Arrays.<Class<?>>asList( A.class, B.class, NewClass.class, C.class );
+        final List<Class<?>> prioritizedTestsClassRunTime =
+            runEntryStatisticsMap.getPrioritizedTestsByFailureFirst( list );
         assertEquals( A.class, prioritizedTestsClassRunTime.get( 0 ) );
         assertEquals( NewClass.class, prioritizedTestsClassRunTime.get( 1 ) );
         assertEquals( C.class, prioritizedTestsClassRunTime.get( 2 ) );
@@ -73,9 +75,9 @@ public class RunEntryStatisticsMapTest
         RunEntryStatisticsMap existingEntries = RunEntryStatisticsMap.fromFile( data );
         RunEntryStatisticsMap newResults = new RunEntryStatisticsMap();
 
-        ReportEntry reportEntry1 = new SimpleReportEntry( "abc", "method1", new Integer( 42 ) );
-        ReportEntry reportEntry2 = new SimpleReportEntry( "abc", "willFail", new Integer( 17 ) );
-        ReportEntry reportEntry3 = new SimpleReportEntry( "abc", "method3", new Integer( 100 ) );
+        ReportEntry reportEntry1 = new SimpleReportEntry( "abc", "method1", 42 );
+        ReportEntry reportEntry2 = new SimpleReportEntry( "abc", "willFail", 17 );
+        ReportEntry reportEntry3 = new SimpleReportEntry( "abc", "method3", 100 );
 
         newResults.add( existingEntries.createNextGeneration( reportEntry1 ) );
         newResults.add( existingEntries.createNextGeneration( reportEntry2 ) );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/PrioritizedTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/PrioritizedTest.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/PrioritizedTest.java
index 2109a50..280d710 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/PrioritizedTest.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/PrioritizedTest.java
@@ -24,11 +24,11 @@ package org.apache.maven.plugin.surefire.runorder;
  */
 public class PrioritizedTest
 {
-    private final Class clazz;
+    private final Class<?> clazz;
 
     private final Priority priority;
 
-    public PrioritizedTest( Class clazz, Priority pri )
+    public PrioritizedTest( Class<?> clazz, Priority pri )
     {
         this.clazz = clazz;
         this.priority = pri;
@@ -45,7 +45,7 @@ public class PrioritizedTest
         return priority.getTotalRuntime();
     }
 
-    public Class getClazz()
+    public Class<?> getClazz()
     {
         return clazz;
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
index bfed9c3..9e9bf10 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
@@ -147,9 +147,9 @@ public class RunEntryStatisticsMap
         }
     }
 
-    public List<Class> getPrioritizedTestsClassRunTime( List testsToRun, int threadCount )
+    public List<Class<?>> getPrioritizedTestsClassRunTime( List<Class<?>> testsToRun, int threadCount )
     {
-        final List<PrioritizedTest> prioritizedTests = getPrioritizedTests( testsToRun, new TestRuntimeComparator() );
+        List<PrioritizedTest> prioritizedTests = getPrioritizedTests( testsToRun, new TestRuntimeComparator() );
         ThreadedExecutionScheduler threadedExecutionScheduler = new ThreadedExecutionScheduler( threadCount );
         for ( Object prioritizedTest1 : prioritizedTests )
         {
@@ -157,24 +157,22 @@ public class RunEntryStatisticsMap
         }
 
         return threadedExecutionScheduler.getResult();
-
     }
 
-    public List<Class> getPrioritizedTestsByFailureFirst( List testsToRun )
+    public List<Class<?>> getPrioritizedTestsByFailureFirst( List<Class<?>> testsToRun )
     {
-        final List prioritizedTests = getPrioritizedTests( testsToRun, new LeastFailureComparator() );
+        List<PrioritizedTest> prioritizedTests = getPrioritizedTests( testsToRun, new LeastFailureComparator() );
         return transformToClasses( prioritizedTests );
     }
 
-
-    private List<PrioritizedTest> getPrioritizedTests( List testsToRun, Comparator<Priority> priorityComparator )
+    private List<PrioritizedTest> getPrioritizedTests( List<Class<?>> testsToRun,
+                                                       Comparator<Priority> priorityComparator )
     {
         Map classPriorities = getPriorities( priorityComparator );
 
         List<PrioritizedTest> tests = new ArrayList<PrioritizedTest>();
-        for ( Object aTestsToRun : testsToRun )
+        for ( Class<?> clazz : testsToRun )
         {
-            Class clazz = (Class) aTestsToRun;
             Priority pri = (Priority) classPriorities.get( clazz.getName() );
             if ( pri == null )
             {
@@ -185,15 +183,14 @@ public class RunEntryStatisticsMap
         }
         Collections.sort( tests, new PrioritizedTestComparator() );
         return tests;
-
     }
 
-    private List<Class> transformToClasses( List tests )
+    private List<Class<?>> transformToClasses( List<PrioritizedTest> tests )
     {
-        List<Class> result = new ArrayList<Class>();
-        for ( Object test : tests )
+        List<Class<?>> result = new ArrayList<Class<?>>();
+        for ( PrioritizedTest test : tests )
         {
-            result.add( ( (PrioritizedTest) test ).getClazz() );
+            result.add( test.getClazz() );
         }
         return result;
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/ThreadedExecutionScheduler.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/ThreadedExecutionScheduler.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/ThreadedExecutionScheduler.java
index 7e77625..09ea122 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/ThreadedExecutionScheduler.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/ThreadedExecutionScheduler.java
@@ -32,8 +32,9 @@ public class ThreadedExecutionScheduler
 
     private final int runTime[];
 
-    private final List[] lists;
+    private final List<Class<?>>[] lists;
 
+    @SuppressWarnings( "unchecked" )
     public ThreadedExecutionScheduler( int numThreads )
     {
         this.numThreads = numThreads;
@@ -41,7 +42,7 @@ public class ThreadedExecutionScheduler
         lists = new List[numThreads];
         for ( int i = 0; i < numThreads; i++ )
         {
-            lists[i] = new ArrayList<Class>();
+            lists[i] = new ArrayList<Class<?>>();
         }
     }
 
@@ -53,9 +54,9 @@ public class ThreadedExecutionScheduler
         lists[leastBusySlot].add( prioritizedTest.getClazz() );
     }
 
-    public List<Class> getResult()
+    public List<Class<?>> getResult()
     {
-        List<Class> result = new ArrayList<Class>();
+        List<Class<?>> result = new ArrayList<Class<?>>();
         int index = 0;
         boolean added;
         do
@@ -65,7 +66,7 @@ public class ThreadedExecutionScheduler
             {
                 if ( lists[i].size() > index )
                 {
-                    result.add( (Class) lists[i].get( index ) );
+                    result.add( lists[i].get( index ) );
                     added = true;
                 }
             }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java
index 46c541b..9b27c1c 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java
@@ -20,7 +20,6 @@ package org.apache.maven.surefire.providerapi;
  */
 
 import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestSetFailedException;
@@ -52,7 +51,7 @@ public interface SurefireProvider
      *
      * @return An iterator that will trigger one fork per item
      */
-    Iterator getSuites();
+    Iterable<Class<?>> getSuites();
 
     /**
      * Runs a forked test

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
index f9d48c4..81a6054 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
@@ -52,8 +52,6 @@ public class DefaultDirectoryScanner
 
     private final List specificTests;
 
-    private final List<Class> classesSkippedByValidation = new ArrayList<Class>();
-
     public DefaultDirectoryScanner( File basedir, List includes, List excludes, List specificTests )
     {
         this.basedir = basedir;
@@ -65,7 +63,7 @@ public class DefaultDirectoryScanner
     public TestsToRun locateTestClasses( ClassLoader classLoader, ScannerFilter scannerFilter )
     {
         String[] testClassNames = collectTests();
-        List<Class> result = new ArrayList<Class>();
+        List<Class<?>> result = new ArrayList<Class<?>>();
 
         String[] specific = specificTests == null ? new String[0] : processIncludesExcludes( specificTests );
         SpecificTestClassFilter specificTestFilter = new SpecificTestClassFilter( specific );
@@ -84,10 +82,6 @@ public class DefaultDirectoryScanner
             {
                 result.add( testClass );
             }
-            else
-            {
-                classesSkippedByValidation.add( testClass );
-            }
         }
 
         return new TestsToRun( result );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
index 94277e2..a67052e 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
@@ -55,9 +55,9 @@ public class DefaultRunOrderCalculator
     @SuppressWarnings( "checkstyle:magicnumber" )
     public TestsToRun orderTestClasses( TestsToRun scannedClasses )
     {
-        List<Class> result = new ArrayList<Class>( 512 );
+        List<Class<?>> result = new ArrayList<Class<?>>( 512 );
 
-        for ( Class scannedClass : scannedClasses )
+        for ( Class<?> scannedClass : scannedClasses )
         {
             result.add( scannedClass );
         }
@@ -66,7 +66,7 @@ public class DefaultRunOrderCalculator
         return new TestsToRun( result );
     }
 
-    private void orderTestClasses( List<Class> testClasses, RunOrder runOrder )
+    private void orderTestClasses( List<Class<?>> testClasses, RunOrder runOrder )
     {
         if ( RunOrder.RANDOM.equals( runOrder ) )
         {
@@ -75,7 +75,7 @@ public class DefaultRunOrderCalculator
         else if ( RunOrder.FAILEDFIRST.equals( runOrder ) )
         {
             RunEntryStatisticsMap stat = RunEntryStatisticsMap.fromFile( runOrderParameters.getRunStatisticsFile() );
-            List<Class> prioritized = stat.getPrioritizedTestsByFailureFirst( testClasses );
+            List<Class<?>> prioritized = stat.getPrioritizedTestsByFailureFirst( testClasses );
             testClasses.clear();
             testClasses.addAll( prioritized );
 
@@ -83,7 +83,7 @@ public class DefaultRunOrderCalculator
         else if ( RunOrder.BALANCED.equals( runOrder ) )
         {
             RunEntryStatisticsMap stat = RunEntryStatisticsMap.fromFile( runOrderParameters.getRunStatisticsFile() );
-            List<Class> prioritized = stat.getPrioritizedTestsClassRunTime( testClasses, threadCount );
+            List<Class<?>> prioritized = stat.getPrioritizedTestsClassRunTime( testClasses, threadCount );
             testClasses.clear();
             testClasses.addAll( prioritized );
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
index ab4c8b2..e8a16c1 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
@@ -84,14 +84,14 @@ public class DefaultScanResult
 
     public TestsToRun applyFilter( ScannerFilter scannerFilter, ClassLoader testClassLoader )
     {
-        List<Class> result = new ArrayList<Class>();
+        List<Class<?>> result = new ArrayList<Class<?>>();
 
         int size = size();
         for ( int i = 0; i < size; i++ )
         {
             String className = getClassName( i );
 
-            Class testClass = loadClass( testClassLoader, className );
+            Class<?> testClass = loadClass( testClassLoader, className );
 
             if ( scannerFilter == null || scannerFilter.accept( testClass ) )
             {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
index bba1a59..2d633d8 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
@@ -26,12 +26,16 @@ import java.lang.reflect.Method;
 /**
  * @author Kristian Rosenvold
  */
-public class ReflectionUtils
+public final class ReflectionUtils
 {
     private static final Class[] NO_ARGS = new Class[0];
 
     private static final Object[] NO_ARGS_VALUES = new Object[0];
 
+    private ReflectionUtils()
+    {
+        throw new IllegalStateException( "no instantiable constructor" );
+    }
 
     public static Method getMethod( Object instance, String methodName, Class[] parameters )
     {
@@ -62,7 +66,6 @@ public class ReflectionUtils
         }
     }
 
-
     public static Object invokeGetter( Object instance, String methodName )
     {
         final Method method = getMethod( instance, methodName, NO_ARGS );
@@ -121,7 +124,6 @@ public class ReflectionUtils
     public static Object instantiateOneArg( ClassLoader classLoader, String className, Class param1Class,
                                             Object param1 )
     {
-
         try
         {
             Class aClass = loadClass( classLoader, className );
@@ -145,7 +147,6 @@ public class ReflectionUtils
     public static Object instantiateTwoArgs( ClassLoader classLoader, String className, Class param1Class,
                                              Object param1, Class param2Class, Object param2 )
     {
-
         try
         {
             Class aClass = loadClass( classLoader, className );
@@ -168,20 +169,17 @@ public class ReflectionUtils
 
 
     public static void invokeSetter( Object o, String name, Class value1clazz, Object value )
-
     {
         final Method setter = getMethod( o, name, new Class[]{ value1clazz } );
         invokeSetter( o, setter, value );
     }
 
     public static Object invokeSetter( Object target, Method method, Object value )
-
     {
         return invokeMethodWithArray( target, method, new Object[]{ value } );
     }
 
     public static Object invokeMethodWithArray( Object target, Method method, Object[] args )
-
     {
         try
         {
@@ -195,12 +193,10 @@ public class ReflectionUtils
         {
             throw new SurefireReflectionException( e.getTargetException() );
         }
-
     }
 
     public static Object invokeMethodWithArray2( Object target, Method method, Object[] args )
         throws InvocationTargetException
-
     {
         try
         {
@@ -210,7 +206,6 @@ public class ReflectionUtils
         {
             throw new SurefireReflectionException( e );
         }
-
     }
 
     public static Object instantiateObject( String className, Class[] types, Object[] params, ClassLoader classLoader )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/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 f3132da..1f88a5c 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
@@ -20,6 +20,7 @@ package org.apache.maven.surefire.util;
  */
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -33,21 +34,21 @@ import org.apache.maven.surefire.testset.TestSetFailedException;
  *
  * @author Kristian Rosenvold (junit core adaption)
  */
-public class TestsToRun implements Iterable<Class>
+public class TestsToRun implements Iterable<Class<?>>
 {
-    private final List<Class> locatedClasses;
+    private final List<Class<?>> locatedClasses;
 
     /**
      * Constructor
      *
      * @param locatedClasses A list of java.lang.Class objects representing tests to run
      */
-    public TestsToRun( List<Class> locatedClasses )
+    public TestsToRun( List<Class<?>> locatedClasses )
     {
         this.locatedClasses = Collections.unmodifiableList( locatedClasses );
-        Set<Class> testSets = new HashSet<Class>();
+        Set<Class<?>> testSets = new HashSet<Class<?>>();
 
-        for ( Class testClass : locatedClasses )
+        for ( Class<?> testClass : locatedClasses )
         {
             if ( testSets.contains( testClass ) )
             {
@@ -57,10 +58,10 @@ public class TestsToRun implements Iterable<Class>
         }
     }
 
-    public static TestsToRun fromClass( Class clazz )
+    public static TestsToRun fromClass( Class<?> clazz )
         throws TestSetFailedException
     {
-        return new TestsToRun( Collections.singletonList( clazz ) );
+        return new TestsToRun( Collections.<Class<?>>singletonList( clazz ) );
     }
 
     /**
@@ -68,7 +69,7 @@ public class TestsToRun implements Iterable<Class>
      *
      * @return an unmodifiable iterator
      */
-    public Iterator<Class> iterator()
+    public Iterator<Class<?>> iterator()
     {
         return locatedClasses.iterator();
     }
@@ -77,7 +78,7 @@ public class TestsToRun implements Iterable<Class>
     {
         StringBuilder sb = new StringBuilder();
         sb.append( "TestsToRun: [" );
-        for ( Class clazz : this )
+        for ( Class<?> clazz : this )
         {
             sb.append( " " ).append( clazz.getName() );
         }
@@ -121,18 +122,18 @@ public class TestsToRun implements Iterable<Class>
         return true;
     }
 
-    public Class[] getLocatedClasses()
+    public Class<?>[] getLocatedClasses()
     {
         if ( !allowEagerReading() )
         {
             throw new IllegalStateException( "Cannot eagerly read" );
         }
-        List<Class> result = new ArrayList<Class>();
-        for ( Class clazz : this )
+        Collection<Class<?>> result = new ArrayList<Class<?>>();
+        for ( Class<?> clazz : this )
         {
             result.add( clazz );
         }
-        return result.toArray( new Class[result.size()] );
+        return result.toArray( new Class<?>[result.size()] );
     }
 
     /**
@@ -141,9 +142,9 @@ public class TestsToRun implements Iterable<Class>
      * @param className string used to find the test class
      * @return Class object with the matching name, null if could not find a class with the matching name
      */
-    public Class getClassByName( String className )
+    public Class<?> getClassByName( String className )
     {
-        for ( Class clazz : this )
+        for ( Class<?> clazz : this )
         {
             if ( clazz.getName().equals( className ) )
             {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index 3f29f8a..324f1a0 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -128,6 +128,20 @@ public class StringUtils
     }
 
     /**
+     * <p>
+     * Checks if a (trimmed) String is not <code>null</code> and not blank.
+     * </p>
+     *
+     * @param str the String to check
+     * @return <code>true</code> if the String is not <code>null</code> and length of trimmed
+     * <code>str</code> is not zero.
+     */
+    public static boolean isNotBlank( String str )
+    {
+        return !isBlank( str );
+    }
+
+    /**
      * Escape the specified string to a representation that only consists of nicely printable characters, without any
      * newlines and without a comma.
      * <p>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/test/java/org/apache/maven/plugin/surefire/runorder/ThreadedExecutionSchedulerTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/plugin/surefire/runorder/ThreadedExecutionSchedulerTest.java b/surefire-api/src/test/java/org/apache/maven/plugin/surefire/runorder/ThreadedExecutionSchedulerTest.java
index 57a2de0..15963d7 100644
--- a/surefire-api/src/test/java/org/apache/maven/plugin/surefire/runorder/ThreadedExecutionSchedulerTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/plugin/surefire/runorder/ThreadedExecutionSchedulerTest.java
@@ -50,7 +50,7 @@ public class ThreadedExecutionSchedulerTest
     {
         ThreadedExecutionScheduler threadedExecutionScheduler = new ThreadedExecutionScheduler( 2 );
         addPrioritizedTests( threadedExecutionScheduler );
-        final List result = threadedExecutionScheduler.getResult();
+        final List<Class<?>> result = threadedExecutionScheduler.getResult();
         assertEquals( 5, result.size() );
         assertEquals( B.class, result.get( 0 ) );
         assertEquals( C.class, result.get( 1 ) );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
index b4ddc21..965417c 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
@@ -42,9 +42,9 @@ public class RunOrderCalculatorTest
 
     }
 
-    private List<Class> getClassesToRun()
+    private List<Class<?>> getClassesToRun()
     {
-        List<Class> classesToRun = new ArrayList<Class>();
+        List<Class<?>> classesToRun = new ArrayList<Class<?>>();
         classesToRun.add( B.class );
         classesToRun.add( A.class );
         return classesToRun;

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/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 d569c00..84854d8 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
@@ -34,8 +34,8 @@ public class TestsToRunTest
     public void testGetTestSets()
         throws Exception
     {
-        TestsToRun testsToRun = new TestsToRun( Arrays.asList( new Class[]{ T1.class, T2.class } ) );
-        Iterator it = testsToRun.iterator();
+        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( T1.class, T2.class ) );
+        Iterator<Class<?>> it = testsToRun.iterator();
         assertTrue( it.hasNext() );
         assertEquals( it.next(), T1.class );
         assertTrue( it.hasNext() );
@@ -45,14 +45,14 @@ public class TestsToRunTest
 
     public void testContainsAtleast()
     {
-        TestsToRun testsToRun = new TestsToRun( Arrays.asList( new Class[]{ T1.class, T2.class } ) );
+        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( 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 } ) );
+        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( T1.class, T2.class ) );
         assertFalse( testsToRun.containsExactly( 1 ) );
         assertTrue( testsToRun.containsExactly( 2 ) );
         assertFalse( testsToRun.containsExactly( 3 ) );
@@ -60,14 +60,14 @@ public class TestsToRunTest
 
     public void testToRunArray()
     {
-        TestsToRun testsToRun = new TestsToRun( Arrays.asList( new Class[]{ T1.class, T2.class } ) );
-        Class[] locatedClasses = testsToRun.getLocatedClasses();
+        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( T1.class, T2.class ) );
+        Class<?>[] locatedClasses = testsToRun.getLocatedClasses();
         assertEquals( 2, locatedClasses.length );
     }
 
     public void testGetClassByName()
     {
-        TestsToRun testsToRun = new TestsToRun( Arrays.asList( new Class[]{ T1.class, T2.class } ) );
+        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( T1.class, T2.class ) );
         assertEquals( T1.class, testsToRun.getClassByName( "org.apache.maven.surefire.util.TestsToRunTest$T1" ) );
         assertEquals( T2.class, testsToRun.getClassByName( "org.apache.maven.surefire.util.TestsToRunTest$T2" ) );
         assertEquals( null, testsToRun.getClassByName( "org.apache.maven.surefire.util.TestsToRunTest$T3" ) );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index ac73564..ca5dd26 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
@@ -24,6 +24,9 @@ import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.PrintStream;
 import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.maven.surefire.providerapi.ProviderParameters;
 import org.apache.maven.surefire.providerapi.SurefireProvider;
@@ -47,8 +50,10 @@ import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringFo
  * @author Emmanuel Venisse
  * @author Kristian Rosenvold
  */
-public class ForkedBooter
+public final class ForkedBooter
 {
+    private static final long SYSTEM_EXIT_TIMEOUT_IN_SECONDS = 30;
+
     /**
      * This method is invoked when Surefire is forked - this method parses and organizes the arguments passed to it and
      * then calls the Surefire class' run method. <p/> The system exit code will be 1 if an exception is thrown.
@@ -106,7 +111,6 @@ public class ForkedBooter
             }
             catch ( InvocationTargetException t )
             {
-
                 LegacyPojoStackTraceWriter stackTraceWriter =
                     new LegacyPojoStackTraceWriter( "test subystem", "no method", t.getTargetException() );
                 StringBuilder stringBuilder = new StringBuilder();
@@ -144,15 +148,12 @@ public class ForkedBooter
         out.write( encodeBytes, 0, encodeBytes.length );
     }
 
-    private static final long SYSTEM_EXIT_TIMEOUT = 30 * 1000;
-
     private static void exit( final int returnCode )
     {
         launchLastDitchDaemonShutdownThread( returnCode );
         System.exit( returnCode );
     }
 
-
     private static RunResult runSuitesInProcess( Object testSet, StartupConfiguration startupConfiguration,
                                                  ProviderConfiguration providerConfiguration,
                                                  PrintStream originalSystemOut )
@@ -174,23 +175,22 @@ public class ForkedBooter
     @SuppressWarnings( "checkstyle:emptyblock" )
     private static void launchLastDitchDaemonShutdownThread( final int returnCode )
     {
-        DaemonThreadFactory.newDaemonThread( new Runnable()
-        {
-            public void run()
+        ThreadFactory threadFactory =
+            DaemonThreadFactory.newDaemonThreadFactory( "last-ditch-daemon-shutdown-thread-"
+                                                            + SYSTEM_EXIT_TIMEOUT_IN_SECONDS
+                                                            + "sec" );
+
+        Executors.newScheduledThreadPool( 1, threadFactory )
+            .schedule( new Runnable()
             {
-                try
+                public void run()
                 {
-                    Thread.sleep( SYSTEM_EXIT_TIMEOUT );
                     Runtime.getRuntime().halt( returnCode );
                 }
-                catch ( InterruptedException ignore )
-                {
-                }
-            }
-        }, "last-ditch-daemon-shutdown-thread-" + SYSTEM_EXIT_TIMEOUT ).start();
+            }, SYSTEM_EXIT_TIMEOUT_IN_SECONDS, TimeUnit.SECONDS );
     }
 
-    public static RunResult invokeProviderInSameClassLoader( Object testSet, Object factory,
+    private static RunResult invokeProviderInSameClassLoader( Object testSet, Object factory,
                                                              ProviderConfiguration providerConfiguration,
                                                              boolean insideFork,
                                                              StartupConfiguration startupConfiguration1,
@@ -218,12 +218,11 @@ public class ForkedBooter
         }
     }
 
-    public static SurefireProvider createProviderInCurrentClassloader( StartupConfiguration startupConfiguration1,
+    private static SurefireProvider createProviderInCurrentClassloader( StartupConfiguration startupConfiguration1,
                                                                        boolean isInsideFork,
                                                                        ProviderConfiguration providerConfiguration,
                                                                        Object reporterManagerFactory1 )
     {
-
         BaseProviderFactory bpf = new BaseProviderFactory( (ReporterFactory) reporterManagerFactory1, isInsideFork );
         bpf.setTestRequest( providerConfiguration.getTestSuiteDefinition() );
         bpf.setReporterConfiguration( providerConfiguration.getReporterConfiguration() );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
index b0d9728..a5611c0 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
@@ -33,6 +33,7 @@ import java.util.List;
 import org.apache.maven.surefire.util.ReflectionUtils;
 import org.apache.maven.surefire.util.TestsToRun;
 
+// CHECKSTYLE_OFF: imports
 import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
 import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
 
@@ -45,16 +46,16 @@ import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringFo
  *
  * @author Andreas Gudian
  */
-class LazyTestsToRun
+final class LazyTestsToRun
     extends TestsToRun
 {
-    private final List<Class> workQueue = new ArrayList<Class>();
+    private final List<Class<?>> workQueue = new ArrayList<Class<?>>();
 
     private final BufferedReader inputReader;
 
     private final PrintStream originalOutStream;
 
-    private boolean streamClosed = false;
+    private boolean streamClosed;
 
     /**
      * C'tor
@@ -64,7 +65,7 @@ class LazyTestsToRun
      */
     public LazyTestsToRun( InputStream testSource, PrintStream originalOutStream )
     {
-        super( Collections.<Class>emptyList() );
+        super( Collections.<Class<?>>emptyList() );
 
         this.originalOutStream = originalOutStream;
 
@@ -78,7 +79,7 @@ class LazyTestsToRun
         }
     }
 
-    protected void addWorkItem( String className )
+    private void addWorkItem( String className )
     {
         synchronized ( workQueue )
         {
@@ -86,15 +87,15 @@ class LazyTestsToRun
         }
     }
 
-    protected void requestNextTest()
+    private void requestNextTest()
     {
         byte[] encoded =
             encodeStringForForkCommunication( ( (char) ForkingRunListener.BOOTERCODE_NEXT_TEST ) + ",0,want more!\n" );
         originalOutStream.write( encoded, 0, encoded.length );
     }
 
-    private class BlockingIterator
-        implements Iterator<Class>
+    private final class BlockingIterator
+        implements Iterator<Class<?>>
     {
         private int lastPos = -1;
 
@@ -112,11 +113,9 @@ class LazyTestsToRun
                     if ( needsToWaitForInput( nextPos ) )
                     {
                         requestNextTest();
-
-                        String nextClassName;
                         try
                         {
-                            nextClassName = inputReader.readLine();
+                            String nextClassName = inputReader.readLine();
                             if ( nextClassName == null )
                             {
                                 streamClosed = true;
@@ -143,7 +142,7 @@ class LazyTestsToRun
             return workQueue.size() == nextPos && !streamClosed;
         }
 
-        public Class next()
+        public Class<?> next()
         {
             synchronized ( workQueue )
             {
@@ -161,7 +160,7 @@ class LazyTestsToRun
     /* (non-Javadoc)
       * @see org.apache.maven.surefire.util.TestsToRun#iterator()
       */
-    public Iterator<Class> iterator()
+    public Iterator<Class<?>> iterator()
     {
         return new BlockingIterator();
     }
@@ -188,5 +187,4 @@ class LazyTestsToRun
     {
         return false;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
index f5d96c5..d529980 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
@@ -22,14 +22,12 @@ package org.apache.maven.surefire.booter;
 import java.io.PrintStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.Iterator;
 
 import org.apache.maven.surefire.providerapi.SurefireProvider;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.ReflectionUtils;
 
-
 /**
  * Creates the surefire provider.
  * <p/>
@@ -124,12 +122,13 @@ public class ProviderFactory
             this.testsClassLoader = testsClassLoader;
         }
 
-        public Iterator getSuites()
+        @SuppressWarnings( "unchecked" )
+        public Iterable<Class<?>> getSuites()
         {
             ClassLoader current = swapClassLoader( testsClassLoader );
             try
             {
-                return (Iterator) ReflectionUtils.invokeGetter( providerInOtherClassLoader, "getSuites" );
+                return (Iterable<Class<?>>) ReflectionUtils.invokeGetter( providerInOtherClassLoader, "getSuites" );
             }
             finally
             {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java b/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java
index 6cde650..79b2ceb 100644
--- a/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java
+++ b/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java
@@ -19,7 +19,6 @@ package org.apache.maven.surefire.testprovider;
  * under the License.
  */
 
-import java.util.Iterator;
 import org.apache.maven.surefire.providerapi.AbstractProvider;
 import org.apache.maven.surefire.providerapi.ProviderParameters;
 import org.apache.maven.surefire.report.ReporterException;
@@ -38,7 +37,7 @@ public class TestProvider
         invokeRuntimeExceptionIfSet( System.getProperty( "constructorCrash" ) );
     }
 
-    public Iterator getSuites()
+    public Iterable<Class<?>> getSuites()
     {
         invokeRuntimeExceptionIfSet( System.getProperty( "getSuitesCrash" ) );
         return null;

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
index d520c4f..470922f 100644
--- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
+++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
@@ -19,7 +19,6 @@ package org.apache.maven.surefire.junit;
  * under the License.
  */
 
-import java.util.Iterator;
 import org.apache.maven.surefire.common.junit3.JUnit3Reflector;
 import org.apache.maven.surefire.common.junit3.JUnit3TestChecker;
 import org.apache.maven.surefire.providerapi.AbstractProvider;
@@ -138,9 +137,9 @@ public class JUnit3Provider
         return runOrderCalculator.orderTestClasses( testsToRun );
     }
 
-    public Iterator getSuites()
+    public Iterable<Class<?>> getSuites()
     {
         testsToRun = scanClassPath();
-        return testsToRun.iterator();
+        return testsToRun;
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
index 7f3d1b6..e3b87af 100644
--- a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
+++ b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
@@ -22,7 +22,6 @@ package org.apache.maven.surefire.junit4;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -215,10 +214,10 @@ public class JUnit4Provider
         }
     }
 
-    public Iterator<?> getSuites()
+    public Iterable<Class<?>> getSuites()
     {
         testsToRun = scanClassPath();
-        return testsToRun.iterator();
+        return testsToRun;
     }
 
     private TestsToRun scanClassPath()

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/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 0cebc84..43b8a1e 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
@@ -19,7 +19,6 @@ package org.apache.maven.surefire.junitcore;
  * under the License.
  */
 
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -91,10 +90,10 @@ public class JUnitCoreProvider
         jUnit48Reflector = new JUnit48Reflector( testClassLoader );
     }
 
-    public Iterator getSuites()
+    public Iterable<Class<?>> getSuites()
     {
         testsToRun = scanClassPath();
-        return testsToRun.iterator();
+        return testsToRun;
     }
 
     private boolean isSingleThreaded()

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/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 ee6796c..bf2f71a 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
@@ -73,7 +73,7 @@ class JUnitCoreWrapper
                                       JUnitCoreParameters jUnitCoreParameters, JUnitCore junitCore )
         throws TestSetFailedException
     {
-        Class[] tests = testsToRun.getLocatedClasses();
+        Class<?>[] tests = testsToRun.getLocatedClasses();
         Computer computer = createComputer( logger, jUnitCoreParameters );
         createRequestAndRun( filter, computer, junitCore, tests );
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
index bb68f3a..678280f 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
@@ -364,7 +364,6 @@ public class TestNGDirectoryTestSuite
                 throw new TestSetFailedException( "Duplicate test set '" + testSet.getName() + "'" );
             }
             testSets.put( testSet.getName(), testSet );
-
         }
 
         return Collections.unmodifiableSortedMap( testSets );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e8cd8cc8/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
index 7cb11d4..d28d6ac 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
@@ -21,7 +21,6 @@ package org.apache.maven.surefire.testng;
 
 import java.io.File;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -138,14 +137,14 @@ public class TestNGProvider
                                        reporterConfiguration.getReportsDirectory() );
     }
 
-
-    public Iterator getSuites()
+    @SuppressWarnings( "unchecked" )
+    public Iterable<Class<?>> getSuites()
     {
         if ( isTestNGXmlTestSuite( testRequest ) )
         {
             try
             {
-                return getXmlSuite().locateTestSets( testClassLoader ).keySet().iterator();
+                return getXmlSuite().locateTestSets( testClassLoader ).keySet();
             }
             catch ( TestSetFailedException e )
             {
@@ -155,7 +154,7 @@ public class TestNGProvider
         else
         {
             testsToRun = scanClassPath();
-            return testsToRun.iterator();
+            return testsToRun;
         }
     }
 


[06/19] maven-surefire git commit: [SUREFIRE] refactoring with NotifiableTestStream

Posted by ti...@apache.org.
[SUREFIRE] refactoring with NotifiableTestStream


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

Branch: refs/heads/master
Commit: df7e6f3da7b3ca6924e4a5a8def3ad0df6d012b3
Parents: 4b35269
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Jul 13 21:38:17 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:06 2015 +0200

----------------------------------------------------------------------
 .../lazytestprovider/NotifiableTestStream.java  | 32 ++++++++++++++++++++
 .../TestProvidingInputStream.java               |  1 +
 .../booterclient/output/ForkClient.java         | 11 ++++---
 3 files changed, 39 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/df7e6f3d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java
new file mode 100644
index 0000000..47aa642
--- /dev/null
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/NotifiableTestStream.java
@@ -0,0 +1,32 @@
+package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
+
+/*
+ * 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.
+ */
+
+/**
+ * Forked jvm notifies master process to provide a new test.
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.19
+ * @see TestProvidingInputStream
+ */
+public interface NotifiableTestStream
+{
+    void provideNewTest();
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/df7e6f3d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index 9f40bf7..0001817 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -41,6 +41,7 @@ import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringFo
  */
 public class TestProvidingInputStream
     extends InputStream
+    implements NotifiableTestStream
 {
     private final ReentrantLock lock = new ReentrantLock();
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/df7e6f3d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
index 8e12e04..529cf1c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
@@ -29,6 +29,7 @@ import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.NotifiableTestStream;
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStream;
 import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
 import org.apache.maven.shared.utils.cli.StreamConsumer;
@@ -52,7 +53,7 @@ public class ForkClient
 {
     private final DefaultReporterFactory defaultReporterFactory;
 
-    private final TestProvidingInputStream testProvidingInputStream;
+    private final NotifiableTestStream notifiableTestStream;
 
     private final Map<Integer, RunListener> testSetReporters = new ConcurrentHashMap<Integer, RunListener>();
 
@@ -68,11 +69,11 @@ public class ForkClient
     }
 
     public ForkClient( DefaultReporterFactory defaultReporterFactory, Properties testVmSystemProperties,
-                       TestProvidingInputStream testProvidingInputStream )
+                       TestProvidingInputStream notifiableTestStream )
     {
         this.defaultReporterFactory = defaultReporterFactory;
         this.testVmSystemProperties = testVmSystemProperties;
-        this.testProvidingInputStream = testProvidingInputStream;
+        this.notifiableTestStream = notifiableTestStream;
     }
 
     public DefaultReporterFactory getDefaultReporterFactory()
@@ -151,9 +152,9 @@ public class ForkClient
                     getOrCreateConsoleLogger( channelNumber ).info( createConsoleMessage( remaining ) );
                     break;
                 case ForkingRunListener.BOOTERCODE_NEXT_TEST:
-                    if ( null != testProvidingInputStream )
+                    if ( notifiableTestStream != null )
                     {
-                        testProvidingInputStream.provideNewTest();
+                        notifiableTestStream.provideNewTest();
                     }
                     break;
                 case ForkingRunListener.BOOTERCODE_ERROR:


[13/19] maven-surefire git commit: [SUREFIRE] refactoring: help GC to free this object since it's not needed as there's no new test

Posted by ti...@apache.org.
[SUREFIRE] refactoring: help GC to free this object since it's not needed as there's no new test


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

Branch: refs/heads/master
Commit: 72c9c5ff2f89d77f5975bd0d13866fa668ba3e3d
Parents: 02cdeaf
Author: Tibor17 <ti...@lycos.com>
Authored: Tue Jul 14 20:02:09 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:12 2015 +0200

----------------------------------------------------------------------
 .../booterclient/lazytestprovider/TestProvidingInputStream.java    | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/72c9c5ff/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index 39e0c4d..31ca4d7 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -125,6 +125,8 @@ public class TestProvidingInputStream
                 }
                 else
                 {
+                    // help GC to free this object since it's not needed as there's no new test
+                    currentBuffer = null;
                     return -1;
                 }
             }


[19/19] maven-surefire git commit: [SUREFIRE-580] [SUREFIRE-524] new mechanism to dispatch commands to forked jvm

Posted by ti...@apache.org.
[SUREFIRE-580] [SUREFIRE-524] new mechanism to dispatch commands to forked jvm


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

Branch: refs/heads/master
Commit: 78dca27ef03bd939e700d7b00babaac44e7d1707
Parents: 7907ade
Author: Tibor17 <ti...@lycos.com>
Authored: Thu Jul 23 23:21:14 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:19 2015 +0200

----------------------------------------------------------------------
 maven-surefire-common/pom.xml                   |   3 +
 .../surefire/booterclient/ForkStarter.java      |  22 +-
 .../TestProvidingInputStream.java               | 105 ++++----
 .../TestProvidingInputStreamTest.java           | 141 ++++++++++
 .../apache/maven/surefire/JUnit4SuiteTest.java  |  76 ++++++
 pom.xml                                         |  11 +
 .../apache/maven/surefire/booter/Command.java   |  50 ++++
 .../surefire/booter/MasterProcessCommand.java   | 199 +++++++++++++++
 .../surefire/testset/TestListResolver.java      |  15 +-
 .../surefire/util/internal/StringUtils.java     |  20 ++
 .../booter/MasterProcessCommandTest.java        | 155 +++++++++++
 surefire-booter/pom.xml                         |   1 +
 .../maven/surefire/booter/ForkedBooter.java     |   2 +-
 .../maven/surefire/booter/LazyTestsToRun.java   | 113 +-------
 .../surefire/booter/MasterProcessListener.java  |  28 ++
 .../surefire/booter/MasterProcessReader.java    | 255 +++++++++++++++++++
 .../maven/surefire/booter/JUnit4SuiteTest.java  |   1 +
 .../booter/MasterProcessReaderTest.java         | 193 ++++++++++++++
 .../surefire/booter/NewClassLoaderRunner.java   | 191 ++++++++++++++
 .../maven/surefire/junit/JUnit3Provider.java    |   1 -
 .../maven/surefire/junit4/JUnit4Provider.java   |   8 +-
 21 files changed, 1413 insertions(+), 177 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/maven-surefire-common/pom.xml
----------------------------------------------------------------------
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index b49798a..c6303e0 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -119,6 +119,9 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <redirectTestOutputToFile>true</redirectTestOutputToFile>
+          <includes>
+            <include>**/JUnit4SuiteTest.java</include>
+          </includes>
         </configuration>
         <dependencies>
           <dependency>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/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 804a08e..4b2e184 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
@@ -35,6 +35,7 @@ import org.apache.maven.shared.utils.cli.CommandLineUtils;
 import org.apache.maven.shared.utils.cli.ShutdownHookUtils;
 import org.apache.maven.surefire.booter.Classpath;
 import org.apache.maven.surefire.booter.ClasspathConfiguration;
+import org.apache.maven.surefire.booter.Command;
 import org.apache.maven.surefire.booter.KeyValueSource;
 import org.apache.maven.surefire.booter.PropertiesWrapper;
 import org.apache.maven.surefire.booter.ProviderConfiguration;
@@ -72,6 +73,8 @@ import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.atomic.AtomicReference;
 
 import static org.apache.maven.surefire.booter.Classpath.join;
+import static org.apache.maven.surefire.booter.MasterProcessCommand.RUN_CLASS;
+import static java.lang.StrictMath.min;
 
 /**
  * Starts the fork or runs in-process.
@@ -210,18 +213,17 @@ public class ForkStarter
         ThreadPoolExecutor executorService = new ThreadPoolExecutor( forkCount, forkCount, 60, TimeUnit.SECONDS,
                                                                   new ArrayBlockingQueue<Runnable>( forkCount ) );
         executorService.setThreadFactory( threadFactory );
-        Collection<TestProvidingInputStream> testStreams = new ArrayList<TestProvidingInputStream>();
         try
         {
-            final Queue<String> messageQueue = new ConcurrentLinkedQueue<String>();
+            final Queue<Command> commands = new ConcurrentLinkedQueue<Command>();
             for ( Class<?> clazz : getSuitesIterator() )
             {
-                messageQueue.add( clazz.getName() );
+                commands.add( new Command( RUN_CLASS, clazz.getName() ) );
             }
-
-            for ( int forkNum = 0, total = messageQueue.size(); forkNum < forkCount && forkNum < total; forkNum++ )
+            Collection<TestProvidingInputStream> testStreams = new ArrayList<TestProvidingInputStream>();
+            for ( int forkNum = 0, total = min( forkCount, commands.size() ); forkNum < total; forkNum++ )
             {
-                final TestProvidingInputStream testProvidingInputStream = new TestProvidingInputStream( messageQueue );
+                final TestProvidingInputStream testProvidingInputStream = new TestProvidingInputStream( commands );
                 testStreams.add( testProvidingInputStream );
                 Callable<RunResult> pf = new Callable<RunResult>()
                 {
@@ -241,11 +243,11 @@ public class ForkStarter
                 };
                 results.add( executorService.submit( pf ) );
             }
+            dispatchTestSetFinished( testStreams );
             return awaitResultsDone( results, executorService );
         }
         finally
         {
-            closeTestStreams( testStreams );
             closeExecutor( executorService );
         }
     }
@@ -318,11 +320,11 @@ public class ForkStarter
         return globalResult;
     }
 
-    private static void closeTestStreams( Iterable<TestProvidingInputStream> testStreams )
+    private static void dispatchTestSetFinished( Iterable<TestProvidingInputStream> testStreams )
     {
-        for ( TestProvidingInputStream testStream: testStreams )
+        for ( TestProvidingInputStream testStream : testStreams )
         {
-            testStream.close();
+            testStream.testSetFinished();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index 31ca4d7..97bf24d 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -19,14 +19,17 @@ package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
  * under the License.
  */
 
-import java.io.EOFException;
+import org.apache.maven.surefire.booter.Command;
+import org.apache.maven.surefire.booter.MasterProcessCommand;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Queue;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
+import static org.apache.maven.surefire.booter.MasterProcessCommand.TEST_SET_FINISHED;
+import static org.apache.maven.surefire.util.internal.StringUtils.requireNonNull;
 
 /**
  * An {@link InputStream} that, when read, provides test class names out of a queue.
@@ -45,7 +48,7 @@ public class TestProvidingInputStream
 {
     private final Semaphore semaphore = new Semaphore( 0 );
 
-    private final Queue<String> testItemQueue;
+    private final Queue<Command> commands;
 
     private final AtomicBoolean closed = new AtomicBoolean();
 
@@ -53,16 +56,18 @@ public class TestProvidingInputStream
 
     private int currentPos;
 
+    private MasterProcessCommand lastCommand;
+
     private volatile FlushReceiverProvider flushReceiverProvider;
 
     /**
      * C'tor
      *
-     * @param testItemQueue source of the tests to be read from this stream
+     * @param commands source of the tests to be read from this stream
      */
-    public TestProvidingInputStream( Queue<String> testItemQueue )
+    public TestProvidingInputStream( Queue<Command> commands )
     {
-        this.testItemQueue = testItemQueue;
+        this.commands = commands;
     }
 
     /**
@@ -70,7 +75,12 @@ public class TestProvidingInputStream
      */
     public void setFlushReceiverProvider( FlushReceiverProvider flushReceiverProvider )
     {
-        this.flushReceiverProvider = flushReceiverProvider;
+        this.flushReceiverProvider = requireNonNull( flushReceiverProvider );
+    }
+
+    public void testSetFinished()
+    {
+        commands.add( new Command( TEST_SET_FINISHED ) );
     }
 
     /**
@@ -84,63 +94,45 @@ public class TestProvidingInputStream
     public int read()
         throws IOException
     {
-        if ( closed.get() )
-        {
-            // help GC to free this object because StreamFeeder Thread cannot read it after IOE
-            currentBuffer = null;
-            throw new EOFException( "closed unexpectedly" );
-        }
-        else
+        byte[] buffer = currentBuffer;
+        if ( buffer == null )
         {
-            // isolation of instance variable in Thread stack
-            byte[] buffer = currentBuffer;
-
-            if ( buffer == null )
+            if ( flushReceiverProvider != null )
             {
-                if ( flushReceiverProvider != null )
-                {
-                    FlushReceiver flushing = flushReceiverProvider.getFlushReceiver();
-                    if ( flushing != null )
-                    {
-                        flushing.flush();
-                    }
-                }
-
-                awaitNextTest();
-
-                if ( closed.get() )
+                FlushReceiver flushReceiver = flushReceiverProvider.getFlushReceiver();
+                if ( flushReceiver != null )
                 {
-                    // help GC to free this object because StreamFeeder Thread cannot read it after IOE
-                    currentBuffer = null;
-                    throw new EOFException( "closed unexpectedly" );
-                }
-
-                String currentElement = testItemQueue.poll();
-                if ( currentElement != null )
-                {
-                    buffer = encodeStringForForkCommunication( currentElement );
-                    // may override NULL from close(), therefore setting explicitly to NULL if IOE elsewhere
-                    currentBuffer = buffer;
-                    currentPos = 0;
-                }
-                else
-                {
-                    // help GC to free this object since it's not needed as there's no new test
-                    currentBuffer = null;
-                    return -1;
+                    flushReceiver.flush();
                 }
             }
 
-            if ( currentPos < buffer.length )
+            if ( lastCommand == TEST_SET_FINISHED || closed.get() )
             {
-                return buffer[currentPos++] & 0xff;
+                close();
+                return -1;
             }
-            else
+
+            awaitNextTest();
+
+            if ( closed.get() )
             {
-                currentBuffer = null;
-                return '\n' & 0xff;
+                return -1;
             }
+
+            Command command = commands.poll();
+            lastCommand = command.getCommandType();
+            String test = command.getData();
+            buffer = lastCommand == TEST_SET_FINISHED ? lastCommand.encode() : lastCommand.encode( test );
+        }
+
+        int b =  buffer[currentPos++] & 0xff;
+        if ( currentPos == buffer.length )
+        {
+            buffer = null;
+            currentPos = 0;
         }
+        currentBuffer = buffer;
+        return b;
     }
 
     private void awaitNextTest()
@@ -175,11 +167,8 @@ public class TestProvidingInputStream
         if ( closed.compareAndSet( false, true ) )
         {
             currentBuffer = null;
-            int permits = semaphore.drainPermits();
-            if ( permits == 0 )
-            {
-                semaphore.release();
-            }
+            semaphore.drainPermits();
+            semaphore.release();
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStreamTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStreamTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStreamTest.java
new file mode 100644
index 0000000..feca48b
--- /dev/null
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStreamTest.java
@@ -0,0 +1,141 @@
+package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.booter.Command;
+import org.apache.maven.surefire.booter.MasterProcessCommand;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.ArrayDeque;
+import java.util.Queue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+
+/**
+ * Asserts that this stream properly reads bytes from queue.
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.19
+ */
+public class TestProvidingInputStreamTest
+{
+    @Test
+    public void closedStreamShouldReturnEndOfStream()
+        throws IOException
+    {
+        Queue<Command> commands = new ArrayDeque<Command>();
+        TestProvidingInputStream is = new TestProvidingInputStream( commands );
+        is.close();
+        assertThat( is.read(), is( -1 ) );
+    }
+
+    @Test
+    public void emptyStreamShouldWaitUntilClosed()
+        throws Exception
+    {
+        Queue<Command> commands = new ArrayDeque<Command>();
+        final TestProvidingInputStream is = new TestProvidingInputStream( commands );
+        final Thread streamThread = Thread.currentThread();
+        FutureTask<Thread.State> futureTask = new FutureTask<Thread.State>( new Callable<Thread.State>()
+        {
+            public Thread.State call()
+            {
+                sleep( 1000 );
+                Thread.State state = streamThread.getState();
+                is.close();
+                return state;
+            }
+        } );
+        Thread assertionThread = new Thread( futureTask );
+        assertionThread.start();
+        assertThat( is.read(), is( -1 ) );
+        Thread.State state = futureTask.get();
+        assertThat( state, is( Thread.State.WAITING ) );
+    }
+
+    @Test
+    public void finishedTestsetShouldNotBlock()
+        throws IOException
+    {
+        Queue<Command> commands = new ArrayDeque<Command>();
+        commands.add( new Command( MasterProcessCommand.TEST_SET_FINISHED ) );
+        final TestProvidingInputStream is = new TestProvidingInputStream( commands );
+        new Thread( new Runnable()
+        {
+            public void run()
+            {
+                is.provideNewTest();
+            }
+        } ).start();
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 1 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( -1 ) );
+    }
+
+    @Test
+    public void shouldReadTest()
+        throws IOException
+    {
+        Queue<Command> commands = new ArrayDeque<Command>();
+        commands.add( new Command( MasterProcessCommand.RUN_CLASS, "Test" ) );
+        final TestProvidingInputStream is = new TestProvidingInputStream( commands );
+        new Thread( new Runnable()
+        {
+            public void run()
+            {
+                is.provideNewTest();
+            }
+        } ).start();
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 0 ) );
+        assertThat( is.read(), is( 4 ) );
+        assertThat( is.read(), is( (int) 'T' ) );
+        assertThat( is.read(), is( (int) 'e' ) );
+        assertThat( is.read(), is( (int) 's' ) );
+        assertThat( is.read(), is( (int) 't' ) );
+    }
+
+    private static void sleep( long millis )
+    {
+        try
+        {
+            TimeUnit.MILLISECONDS.sleep( millis );
+        }
+        catch ( InterruptedException e )
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
new file mode 100644
index 0000000..995e2a1
--- /dev/null
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
@@ -0,0 +1,76 @@
+package org.apache.maven.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 junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import org.apache.maven.plugin.surefire.SurefirePropertiesTest;
+import org.apache.maven.plugin.surefire.booterclient.BooterDeserializerProviderConfigurationTest;
+import org.apache.maven.plugin.surefire.booterclient.BooterDeserializerStartupConfigurationTest;
+import org.apache.maven.plugin.surefire.booterclient.ForkConfigurationTest;
+import org.apache.maven.plugin.surefire.booterclient.ForkingRunListenerTest;
+import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStreamTest;
+import org.apache.maven.plugin.surefire.report.DefaultReporterFactoryTest;
+import org.apache.maven.plugin.surefire.report.StatelessXmlReporterTest;
+import org.apache.maven.plugin.surefire.report.WrappedReportEntryTest;
+import org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMapTest;
+import org.apache.maven.plugin.surefire.util.DependenciesScannerTest;
+import org.apache.maven.plugin.surefire.util.DirectoryScannerTest;
+import org.apache.maven.plugin.surefire.util.SpecificFileFilterTest;
+import org.apache.maven.surefire.report.ConsoleOutputFileReporterTest;
+import org.apache.maven.surefire.report.FileReporterTest;
+import org.apache.maven.surefire.report.RunStatisticsTest;
+import org.apache.maven.surefire.util.RelocatorTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Adapt the JUnit4 tests which use only annotations to the JUnit3 test suite.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.19
+ */
+@Suite.SuiteClasses( {
+    RelocatorTest.class,
+    RunStatisticsTest.class,
+    FileReporterTest.class,
+    ConsoleOutputFileReporterTest.class,
+    SurefirePropertiesTest.class,
+    SpecificFileFilterTest.class,
+    DirectoryScannerTest.class,
+    DependenciesScannerTest.class,
+    RunEntryStatisticsMapTest.class,
+    WrappedReportEntryTest.class,
+    StatelessXmlReporterTest.class,
+    DefaultReporterFactoryTest.class,
+    ForkingRunListenerTest.class,
+    ForkConfigurationTest.class,
+    BooterDeserializerStartupConfigurationTest.class,
+    BooterDeserializerProviderConfigurationTest.class,
+    TestProvidingInputStreamTest.class,
+} )
+@RunWith( Suite.class )
+public class JUnit4SuiteTest
+{
+    public static Test suite()
+    {
+        return new JUnit4TestAdapter( JUnit4SuiteTest.class );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c802a4f..5eb15e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -226,6 +226,12 @@
         <scope>test</scope>
       </dependency>
       <dependency>
+        <groupId>org.hamcrest</groupId>
+        <artifactId>hamcrest-library</artifactId>
+        <version>1.3</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
         <groupId>com.google.code.findbugs</groupId>
         <artifactId>jsr305</artifactId>
         <version>2.0.1</version>
@@ -239,6 +245,11 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.hamcrest</groupId>
+      <artifactId>hamcrest-library</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-api/src/main/java/org/apache/maven/surefire/booter/Command.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/Command.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/Command.java
new file mode 100644
index 0000000..992c78c
--- /dev/null
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/Command.java
@@ -0,0 +1,50 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Encapsulates data and command sent from master to forked process.
+ */
+public final class Command
+{
+    private final MasterProcessCommand command;
+    private final String data;
+
+    public Command( MasterProcessCommand command, String data )
+    {
+        this.command = command;
+        this.data = data;
+    }
+
+    public Command( MasterProcessCommand command )
+    {
+        this( command, null );
+    }
+
+    public MasterProcessCommand getCommandType()
+    {
+        return command;
+    }
+
+    public String getData()
+    {
+        return data;
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
new file mode 100644
index 0000000..0a553f7
--- /dev/null
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessCommand.java
@@ -0,0 +1,199 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.DataInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
+import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
+import static org.apache.maven.surefire.util.internal.StringUtils.requireNonNull;
+import static java.lang.String.format;
+
+/**
+ * Commands which are sent from plugin to the forked jvm.
+ * Support and methods related to the commands.
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.19
+ */
+public enum MasterProcessCommand
+{
+    RUN_CLASS( 0, String.class ),
+    TEST_SET_FINISHED( 1, Void.class ),
+    STOP_ON_NEXT_TEST( 2, Void.class ),
+    SHUTDOWN( 3, Void.class ),
+    /** To tell a forked process that the master process is still alive. Repeated after 30 seconds. */
+    NOOP( 4, Void.class );
+
+    private final int id;
+
+    private final Class<?> dataType;
+
+    MasterProcessCommand( int id, Class<?> dataType )
+    {
+        this.id = id;
+        this.dataType = requireNonNull( dataType, "dataType cannot be null" );
+    }
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public Class<?> getDataType()
+    {
+        return dataType;
+    }
+
+    @SuppressWarnings( "checkstyle:magicnumber" )
+    public byte[] encode( String data )
+    {
+        if ( getDataType() != String.class )
+        {
+            throw new IllegalArgumentException( "Data type can be only " + getDataType() );
+        }
+        byte[] dataBytes = fromDataType( data );
+        byte[] encoded = new byte[8 + dataBytes.length];
+        int command = getId();
+        int len = dataBytes.length;
+        setCommandAndDataLength( command, len, encoded );
+        System.arraycopy( dataBytes, 0, encoded, 8, dataBytes.length );
+        return encoded;
+    }
+
+    @SuppressWarnings( "checkstyle:magicnumber" )
+    public byte[] encode()
+    {
+        if ( getDataType() != Void.class )
+        {
+            throw new IllegalArgumentException( "Data type can be only " + getDataType() );
+        }
+        byte[] encoded = new byte[8];
+        int command = getId();
+        setCommandAndDataLength( command, 0, encoded );
+        return encoded;
+    }
+
+    public static Command decode( DataInputStream is )
+        throws IOException
+    {
+        MasterProcessCommand command = resolve( is.readInt() );
+        if ( command == null )
+        {
+            return null;
+        }
+        else
+        {
+            int dataLength = is.readInt();
+            if ( dataLength > 0 )
+            {
+                byte[] buffer = new byte[dataLength];
+                int read = 0;
+                int total = 0;
+                do
+                {
+                    total += read;
+                    read = is.read( buffer, total, dataLength - total );
+                } while ( read > 0 );
+
+                if ( command.getDataType() == Void.class )
+                {
+                    // must read entire sequence to get to the next command; cannot be above the loop
+                    throw new IOException( "Command " + command + " read Void data with length " + dataLength );
+                }
+
+                if ( total != dataLength )
+                {
+                    if ( read == -1 )
+                    {
+                        throw new EOFException( "stream closed" );
+                    }
+
+                    throw new EOFException( format( "%s read %d out of %d bytes",
+                                                    MasterProcessCommand.class, total, dataLength ) );
+                }
+
+                String data = command.toDataTypeAsString( buffer );
+                return new Command( command, data );
+            }
+            else
+            {
+                return new Command( command );
+            }
+        }
+    }
+
+    String toDataTypeAsString( byte... data )
+    {
+        try
+        {
+            switch ( this )
+            {
+                case RUN_CLASS:
+                    return new String( data, FORK_STREAM_CHARSET_NAME );
+                default:
+                    return null;
+            }
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            throw new IllegalStateException( e );
+        }
+    }
+
+    byte[] fromDataType( String data )
+    {
+        switch ( this )
+        {
+            case RUN_CLASS:
+                return encodeStringForForkCommunication( data );
+            default:
+                return new byte[0];
+        }
+    }
+
+    static MasterProcessCommand resolve( int id )
+    {
+        for ( MasterProcessCommand command : values() )
+        {
+            if ( id == command.id )
+            {
+                return command;
+            }
+        }
+        return null;
+    }
+
+    @SuppressWarnings( "checkstyle:magicnumber" )
+    static void setCommandAndDataLength( int command, int dataLength, byte... encoded )
+    {
+        encoded[0] = (byte) ( command >>> 24 );
+        encoded[1] = (byte) ( command >>> 16 );
+        encoded[2] = (byte) ( command >>> 8 );
+        encoded[3] = (byte) command;
+        encoded[4] = (byte) ( dataLength >>> 24 );
+        encoded[5] = (byte) ( dataLength >>> 16 );
+        encoded[6] = (byte) ( dataLength >>> 8 );
+        encoded[7] = (byte) dataLength;
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestListResolver.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestListResolver.java b/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestListResolver.java
index b233147..6bda2ad 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestListResolver.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestListResolver.java
@@ -180,8 +180,7 @@ public class TestListResolver
 
     public boolean shouldRun( Class<?> testClass, String methodName )
     {
-        String clsFile = testClass == null ? null : testClass.getName().replace( '.', '/' ) + JAVA_CLASS_FILE_EXTENSION;
-        return shouldRun( clsFile, methodName );
+        return shouldRun( toClassFileName( testClass ), methodName );
     }
 
     public boolean shouldRun( String testClassFile, String methodName )
@@ -285,6 +284,18 @@ public class TestListResolver
         return getPluginParameterTest();
     }
 
+    public static String toClassFileName( Class<?> test )
+    {
+        return test == null ? null : toClassFileName( test.getName() );
+    }
+
+    public static String toClassFileName( String fullyQualifiedTestClass )
+    {
+        return fullyQualifiedTestClass == null
+            ? null
+            : fullyQualifiedTestClass.replace( '.', '/' ) + JAVA_CLASS_FILE_EXTENSION;
+    }
+
     static String removeExclamationMark( String s )
     {
         return s.length() != 0 && s.charAt( 0 ) == '!' ? s.substring( 1 ) : s;

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index 8158fb7..043b87b 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -350,4 +350,24 @@ public class StringUtils
            throw new RuntimeException( "The JVM must support Charset " + FORK_STREAM_CHARSET_NAME, e );
         }
     }
+
+    /*
+    * In JDK7 use java.util.Objects instead.
+    * */
+    public static <T> T requireNonNull( T obj, String message )
+    {
+        if ( obj == null )
+        {
+            throw new NullPointerException( message );
+        }
+        return obj;
+    }
+
+    /*
+    * In JDK7 use java.util.Objects instead.
+    * */
+    public static <T> T requireNonNull( T obj )
+    {
+        return requireNonNull( obj, null );
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java
new file mode 100644
index 0000000..00e7bbc
--- /dev/null
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/booter/MasterProcessCommandTest.java
@@ -0,0 +1,155 @@
+package org.apache.maven.surefire.booter;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.junit.Rule;
+import org.junit.rules.ExpectedException;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+
+import static org.apache.maven.surefire.booter.MasterProcessCommand.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.19
+ */
+public class MasterProcessCommandTest
+    extends TestCase
+{
+    @Rule
+    public final ExpectedException exception = ExpectedException.none();
+
+    public void testEncodedStreamSequence()
+    {
+        byte[] streamSequence = new byte[10];
+        streamSequence[8] = (byte) 'T';
+        streamSequence[9] = (byte) 'e';
+        setCommandAndDataLength( 256, 2, streamSequence );
+        assertEquals( streamSequence[0], (byte) 0 );
+        assertEquals( streamSequence[1], (byte) 0 );
+        assertEquals( streamSequence[2], (byte) 1 );
+        assertEquals( streamSequence[3], (byte) 0 );
+        assertEquals( streamSequence[4], (byte) 0 );
+        assertEquals( streamSequence[5], (byte) 0 );
+        assertEquals( streamSequence[6], (byte) 0 );
+        assertEquals( streamSequence[7], (byte) 2 );
+        // remain unchanged
+        assertEquals( streamSequence[8], (byte) 'T' );
+        assertEquals( streamSequence[9], (byte) 'e' );
+    }
+
+    public void testResolved()
+    {
+        for ( MasterProcessCommand command : MasterProcessCommand.values() )
+        {
+            assertThat( command, is( resolve( command.getId() ) ) );
+        }
+    }
+
+    public void testDataToByteArrayAndBack()
+    {
+        String dummyData = "pkg.Test";
+        for ( MasterProcessCommand command : MasterProcessCommand.values() )
+        {
+            switch ( command )
+            {
+                case RUN_CLASS:
+                    assertEquals( String.class, command.getDataType() );
+                    byte[] encoded = command.fromDataType( dummyData );
+                    assertThat( encoded.length, is( 8 ) );
+                    assertThat( encoded[0], is( (byte) 'p' ) );
+                    assertThat( encoded[1], is( (byte) 'k' ) );
+                    assertThat( encoded[2], is( (byte) 'g' ) );
+                    assertThat( encoded[3], is( (byte) '.' ) );
+                    assertThat( encoded[4], is( (byte) 'T' ) );
+                    assertThat( encoded[5], is( (byte) 'e' ) );
+                    assertThat( encoded[6], is( (byte) 's' ) );
+                    assertThat( encoded[7], is( (byte) 't' ) );
+                    String decoded = command.toDataTypeAsString( encoded );
+                    assertThat( decoded, is( dummyData ) );
+                    break;
+                case TEST_SET_FINISHED:
+                    assertEquals( Void.class, command.getDataType() );
+                    encoded = command.fromDataType( dummyData );
+                    assertThat( encoded.length, is( 0 ) );
+                    decoded = command.toDataTypeAsString( encoded );
+                    assertNull( decoded );
+                    break;
+                case STOP_ON_NEXT_TEST:
+                    assertEquals( Void.class, command.getDataType() );
+                    encoded = command.fromDataType( dummyData );
+                    assertThat( encoded.length, is( 0 ) );
+                    decoded = command.toDataTypeAsString( encoded );
+                    assertNull( decoded );
+                    break;
+                case SHUTDOWN:
+                    assertEquals( Void.class, command.getDataType() );
+                    encoded = command.fromDataType( dummyData );
+                    assertThat( encoded.length, is( 0 ) );
+                    decoded = command.toDataTypeAsString( encoded );
+                    assertNull( decoded );
+                    break;
+                case NOOP:
+                    assertEquals( Void.class, command.getDataType() );
+                    encoded = command.fromDataType( dummyData );
+                    assertThat( encoded.length, is( 0 ) );
+                    decoded = command.toDataTypeAsString( encoded );
+                    assertNull( decoded );
+                    break;
+                default:
+                    fail();
+            }
+            assertThat( command, is( resolve( command.getId() ) ) );
+        }
+    }
+
+    public void testEncodedDecodedIsSameForRunClass()
+        throws IOException
+    {
+        byte[] encoded = RUN_CLASS.encode( "pkg.Test" );
+        assertThat( encoded.length, is( 16 ) );
+        assertThat( encoded[0], is( (byte) 0 ) );
+        assertThat( encoded[1], is( (byte) 0 ) );
+        assertThat( encoded[2], is( (byte) 0 ) );
+        assertThat( encoded[3], is( (byte) 0 ) );
+        assertThat( encoded[4], is( (byte) 0 ) );
+        assertThat( encoded[5], is( (byte) 0 ) );
+        assertThat( encoded[6], is( (byte) 0 ) );
+        assertThat( encoded[7], is( (byte) 8 ) );
+        assertThat( encoded[8], is( (byte) 'p' ) );
+        assertThat( encoded[9], is( (byte) 'k' ) );
+        assertThat( encoded[10], is( (byte) 'g' ) );
+        assertThat( encoded[11], is( (byte) '.' ) );
+        assertThat( encoded[12], is( (byte) 'T' ) );
+        assertThat( encoded[13], is( (byte) 'e' ) );
+        assertThat( encoded[14], is( (byte) 's' ) );
+        assertThat( encoded[15], is( (byte) 't' ) );
+        Command command = decode( new DataInputStream( new ByteArrayInputStream( encoded ) ) );
+        assertNotNull( command );
+        assertThat( command.getCommandType(), is( RUN_CLASS ) );
+        assertThat( command.getData(), is( "pkg.Test" ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-booter/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml
index 50598bf..bf37966 100644
--- a/surefire-booter/pom.xml
+++ b/surefire-booter/pom.xml
@@ -50,6 +50,7 @@
           </dependency>
         </dependencies>
         <configuration>
+          <redirectTestOutputToFile>true</redirectTestOutputToFile>
           <includes>
             <include>**/JUnit4SuiteTest.java</include>
           </includes>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index ca5dd26..518c523 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
@@ -98,7 +98,7 @@ public final class ForkedBooter
             }
             else if ( readTestsFromInputStream )
             {
-                testSet = new LazyTestsToRun( System.in, originalOut );
+                testSet = new LazyTestsToRun( originalOut );
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
index a5611c0..d3e770c 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java
@@ -19,135 +19,55 @@ package org.apache.maven.surefire.booter;
  * under the License.
  */
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.PrintStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
-import java.util.List;
 
 import org.apache.maven.surefire.util.ReflectionUtils;
 import org.apache.maven.surefire.util.TestsToRun;
 
-// CHECKSTYLE_OFF: imports
-import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
-import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
-
 /**
  * A variant of TestsToRun that is provided with test class names
- * from an {@link InputStream} (e.g. {@code System.in}). The method
- * {@link #iterator()} returns an Iterator that blocks on calls to
- * {@link Iterator#hasNext()} until new classes are available, or no more
- * classes will be available.
+ * from an {@code System.in}.
+ * The method {@link #iterator()} returns an Iterator that blocks on calls to
+ * {@link Iterator#hasNext()} or {@link Iterator#next()} until new classes are available, or no more
+ * classes will be available or the internal stream is closed.
  *
  * @author Andreas Gudian
+ * @author Tibor Digana
  */
 final class LazyTestsToRun
     extends TestsToRun
 {
-    private final List<Class<?>> workQueue = new ArrayList<Class<?>>();
-
-    private final BufferedReader inputReader;
-
     private final PrintStream originalOutStream;
 
-    private boolean streamClosed;
-
     /**
      * C'tor
      *
-     * @param testSource        source to read the tests from
      * @param originalOutStream the output stream to use when requesting new new tests
      */
-    public LazyTestsToRun( InputStream testSource, PrintStream originalOutStream )
+    LazyTestsToRun( PrintStream originalOutStream )
     {
-        super( Collections.<Class<?>>emptyList() );
+        super( Collections.<Class<?>>emptySet() );
 
         this.originalOutStream = originalOutStream;
-
-        try
-        {
-            inputReader = new BufferedReader( new InputStreamReader( testSource, FORK_STREAM_CHARSET_NAME ) );
-        }
-        catch ( UnsupportedEncodingException e )
-        {
-            throw new RuntimeException( "The JVM must support Charset " + FORK_STREAM_CHARSET_NAME, e );
-        }
-    }
-
-    private void addWorkItem( String className )
-    {
-        synchronized ( workQueue )
-        {
-            workQueue.add( ReflectionUtils.loadClass( Thread.currentThread().getContextClassLoader(), className ) );
-        }
-    }
-
-    private void requestNextTest()
-    {
-        byte[] encoded =
-            encodeStringForForkCommunication( ( (char) ForkingRunListener.BOOTERCODE_NEXT_TEST ) + ",0,want more!\n" );
-        originalOutStream.write( encoded, 0, encoded.length );
     }
 
     private final class BlockingIterator
         implements Iterator<Class<?>>
     {
-        private int lastPos = -1;
+        private final Iterator<String> it =
+            MasterProcessReader.getReader().getIterableClasses( originalOutStream ).iterator();
 
         public boolean hasNext()
         {
-            int nextPos = lastPos + 1;
-            synchronized ( workQueue )
-            {
-                if ( workQueue.size() > nextPos )
-                {
-                    return true;
-                }
-                else
-                {
-                    if ( needsToWaitForInput( nextPos ) )
-                    {
-                        requestNextTest();
-                        try
-                        {
-                            String nextClassName = inputReader.readLine();
-                            if ( nextClassName == null )
-                            {
-                                streamClosed = true;
-                            }
-                            else
-                            {
-                                addWorkItem( nextClassName );
-                            }
-                        }
-                        catch ( IOException e )
-                        {
-                            streamClosed = true;
-                            return false;
-                        }
-                    }
-
-                    return workQueue.size() > nextPos;
-                }
-            }
-        }
-
-        private boolean needsToWaitForInput( int nextPos )
-        {
-            return workQueue.size() == nextPos && !streamClosed;
+            return it.hasNext();
         }
 
         public Class<?> next()
         {
-            synchronized ( workQueue )
-            {
-                return workQueue.get( ++lastPos );
-            }
+            String clazz = it.next();
+            return ReflectionUtils.loadClass( Thread.currentThread().getContextClassLoader(), clazz );
         }
 
         public void remove()
@@ -170,14 +90,7 @@ final class LazyTestsToRun
       */
     public String toString()
     {
-        StringBuilder sb = new StringBuilder( "LazyTestsToRun " );
-        synchronized ( workQueue )
-        {
-            sb.append( "(more items expected: " ).append( !streamClosed ).append( "): " );
-            sb.append( workQueue );
-        }
-
-        return sb.toString();
+        return "LazyTestsToRun";
     }
 
     /* (non-Javadoc)

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-booter/src/main/java/org/apache/maven/surefire/booter/MasterProcessListener.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/MasterProcessListener.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/MasterProcessListener.java
new file mode 100644
index 0000000..89a4f89
--- /dev/null
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/MasterProcessListener.java
@@ -0,0 +1,28 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * listener interface
+ */
+public interface MasterProcessListener
+{
+    void update( Command command );
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-booter/src/main/java/org/apache/maven/surefire/booter/MasterProcessReader.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/MasterProcessReader.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/MasterProcessReader.java
new file mode 100644
index 0000000..1d86167
--- /dev/null
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/MasterProcessReader.java
@@ -0,0 +1,255 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Queue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static java.lang.Thread.State.NEW;
+import static java.lang.Thread.State.RUNNABLE;
+import static java.lang.Thread.State.TERMINATED;
+import static org.apache.maven.surefire.booter.MasterProcessCommand.TEST_SET_FINISHED;
+import static org.apache.maven.surefire.booter.MasterProcessCommand.RUN_CLASS;
+import static org.apache.maven.surefire.booter.MasterProcessCommand.decode;
+import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
+import static org.apache.maven.surefire.util.internal.StringUtils.isNotBlank;
+import static org.apache.maven.surefire.util.internal.StringUtils.isBlank;
+import static org.apache.maven.surefire.booter.ForkingRunListener.BOOTERCODE_NEXT_TEST;
+
+/**
+ * Testing singleton {@code MasterProcessReader}.
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.19
+ */
+public final class MasterProcessReader
+{
+    private static final MasterProcessReader READER = new MasterProcessReader();
+
+    private final BlockingQueue<Command> classes = new LinkedBlockingQueue<Command>();
+
+    private final Queue<MasterProcessListener> listeners = new ConcurrentLinkedQueue<MasterProcessListener>();
+
+    private final Thread commandThread =
+        DaemonThreadFactory.newDaemonThread( new CommandRunnable(), "surefire-forkedjvm-command-thread" );
+
+    private final AtomicReference<Thread.State> state = new AtomicReference<Thread.State>( NEW );
+
+    public static MasterProcessReader getReader()
+    {
+        if ( READER.state.compareAndSet( NEW, RUNNABLE ) )
+        {
+            READER.commandThread.start();
+        }
+        return READER;
+    }
+
+    private MasterProcessReader()
+    {
+        commandThread.setDaemon( true );
+    }
+
+    Iterable<String> getIterableClasses( PrintStream originalOutStream )
+    {
+        return new ClassesIterable( originalOutStream );
+    }
+
+    void stop( boolean interruptCurrentThread )
+    {
+        if ( state.compareAndSet( NEW, TERMINATED ) || state.compareAndSet( RUNNABLE, TERMINATED ) )
+        {
+            classes.drainTo( new ArrayList<Command>() );
+            listeners.clear();
+            commandThread.interrupt();
+            if ( interruptCurrentThread )
+            {
+                Thread.currentThread().interrupt();
+            }
+        }
+    }
+
+    private final class ClassesIterable
+        implements Iterable<String>
+    {
+        private final ClassesIterator it;
+
+        public ClassesIterable( PrintStream originalOutStream )
+        {
+            it = new ClassesIterator( originalOutStream );
+        }
+
+        public Iterator<String> iterator()
+        {
+            return it;
+        }
+    }
+
+    private final class ClassesIterator
+        implements Iterator<String>
+    {
+        private final PrintStream originalOutStream;
+
+        private String clazz;
+
+        private ClassesIterator( PrintStream originalOutStream )
+        {
+            this.originalOutStream = originalOutStream;
+        }
+
+        public boolean hasNext()
+        {
+            popUnread();
+            return isNotBlank( clazz );
+        }
+
+        public String next()
+        {
+            popUnread();
+            try
+            {
+                if ( isBlank( clazz ) )
+                {
+                    throw new NoSuchElementException();
+                }
+                else
+                {
+                    return clazz;
+                }
+            }
+            finally
+            {
+                clazz = null;
+            }
+        }
+
+        public void remove()
+        {
+            throw new UnsupportedOperationException();
+        }
+
+        private void popUnread()
+        {
+            if ( state.get() == TERMINATED )
+            {
+                clazz = null;
+                return;
+            }
+
+            if ( isBlank( clazz ) )
+            {
+                requestNextTest();
+                try
+                {
+                    do
+                    {
+                        Command command = MasterProcessReader.this.classes.take();
+                        clazz = command.getCommandType() == TEST_SET_FINISHED ? null : command.getData();
+                    }
+                    while ( tryNullWhiteClass() );
+                }
+                catch ( InterruptedException e )
+                {
+                    Thread.currentThread().interrupt();
+                    clazz = null;
+                }
+            }
+
+            if ( state.get() == TERMINATED )
+            {
+                clazz = null;
+            }
+        }
+
+        private boolean tryNullWhiteClass()
+        {
+            if ( clazz != null && isBlank( clazz ) )
+            {
+                clazz = null;
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        private void requestNextTest()
+        {
+            byte[] encoded = encodeStringForForkCommunication( ( (char) BOOTERCODE_NEXT_TEST ) + ",0,want more!\n" );
+            originalOutStream.write( encoded, 0, encoded.length );
+        }
+    }
+
+    private final class CommandRunnable
+        implements Runnable
+    {
+        public void run()
+        {
+            DataInputStream stdIn = new DataInputStream( System.in );
+            try
+            {
+                while ( MasterProcessReader.this.state.get() == RUNNABLE )
+                {
+                    Command command = decode( stdIn );
+                    if ( command != null )
+                    {
+                        // command is null if stream is corrupted, i.e. the first sequence could not be recognized
+                        insert( command );
+                    }
+                }
+            }
+            catch ( IOException e )
+            {
+                // ensure fail-safe iterator as well as safe to finish in for-each loop using ClassesIterator
+                insert( new Command( TEST_SET_FINISHED ) );
+                // and let us know what has happened with the stream
+                throw new IllegalStateException( e.getLocalizedMessage(), e );
+            }
+        }
+
+        @SuppressWarnings( "unchecked" )
+        private void insert( Command cmd )
+        {
+            MasterProcessCommand commandType = cmd.getCommandType();
+            if ( commandType == RUN_CLASS || commandType == TEST_SET_FINISHED )
+            {
+                MasterProcessReader.this.classes.add( cmd );
+            }
+            else
+            {
+                for ( MasterProcessListener listener : MasterProcessReader.this.listeners )
+                {
+                    listener.update( cmd );
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java
index d426d27..5e84775 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java
@@ -32,6 +32,7 @@ import org.junit.runners.Suite;
  */
 @Suite.SuiteClasses( {
     ClasspathTest.class,
+    MasterProcessReaderTest.class,
     PropertiesWrapperTest.class,
     SurefireReflectorTest.class
 } )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-booter/src/test/java/org/apache/maven/surefire/booter/MasterProcessReaderTest.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/MasterProcessReaderTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/MasterProcessReaderTest.java
new file mode 100644
index 0000000..9440e0d
--- /dev/null
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/MasterProcessReaderTest.java
@@ -0,0 +1,193 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import static org.apache.maven.surefire.util.internal.StringUtils.FORK_STREAM_CHARSET_NAME;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+
+/**
+ * Testing singleton {@code MasterProcessReader} in multiple class loaders.
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.19
+ */
+@RunWith( NewClassLoaderRunner.class )
+public class MasterProcessReaderTest
+{
+    private final BlockingQueue<Byte> blockingStream = new LinkedBlockingQueue<Byte>();
+    private InputStream realInputStream;
+
+    @Before
+    public void init()
+        throws UnsupportedEncodingException
+    {
+        Thread.interrupted();
+        realInputStream = System.in;
+        addThisTestToPipeline( MasterProcessReaderTest.class.getName() );
+        System.setIn( new SystemInputStream() );
+    }
+
+    @After
+    public void deinit()
+    {
+        System.setIn( realInputStream );
+    }
+
+    @Test
+    public void readJustOneClass() throws Exception
+    {
+        MasterProcessReader reader = MasterProcessReader.getReader();
+        Iterator<String> it = reader.getIterableClasses( new PrintStream( new ByteArrayOutputStream() ) )
+            .iterator();
+        assertTrue( it.hasNext() );
+        assertThat( it.next(), is( getClass().getName() ) );
+        reader.stop( true );
+        assertFalse( it.hasNext() );
+        try
+        {
+            it.next();
+            fail();
+        }
+        catch ( NoSuchElementException e )
+        {
+            // expected
+        }
+    }
+
+    @Test( expected = NoSuchElementException.class )
+    public void stopBeforeReadInThread()
+        throws Throwable
+    {
+        final MasterProcessReader reader = MasterProcessReader.getReader();
+        Runnable runnable = new Runnable()
+        {
+            public void run()
+            {
+                Iterator<String> it = reader.getIterableClasses( new PrintStream( new ByteArrayOutputStream() ) )
+                    .iterator();
+                assertThat( it.next(), is( MasterProcessReaderTest.class.getName() ) );
+            }
+        };
+        FutureTask<Object> futureTask = new FutureTask<Object>( runnable, null );
+        Thread t = new Thread( futureTask );
+        reader.stop( false );
+        t.start();
+        try
+        {
+            futureTask.get();
+        }
+        catch ( ExecutionException e )
+        {
+            throw e.getCause();
+        }
+    }
+
+    @Test
+    public void readTwoClassesInThread()
+        throws Throwable
+    {
+        final MasterProcessReader reader = MasterProcessReader.getReader();
+        final CountDownLatch counter = new CountDownLatch( 1 );
+        Runnable runnable = new Runnable()
+        {
+            public void run()
+            {
+                Iterator<String> it = reader.getIterableClasses( new PrintStream( new ByteArrayOutputStream() ) )
+                    .iterator();
+                assertThat( it.next(), is( MasterProcessReaderTest.class.getName() ) );
+                counter.countDown();
+                assertThat( it.next(), is( PropertiesWrapperTest.class.getName() ) );
+            }
+        };
+        FutureTask<Object> futureTask = new FutureTask<Object>( runnable, null );
+        Thread t = new Thread( futureTask );
+        t.start();
+        counter.await();
+        addThisTestToPipeline( PropertiesWrapperTest.class.getName() );
+        try
+        {
+            futureTask.get();
+        }
+        catch ( ExecutionException e )
+        {
+            throw e.getCause();
+        }
+        finally
+        {
+            reader.stop( false );
+        }
+    }
+
+    private class SystemInputStream
+        extends InputStream
+    {
+        @Override
+        public int read()
+            throws IOException
+        {
+            try
+            {
+                return MasterProcessReaderTest.this.blockingStream.take();
+            }
+            catch ( InterruptedException e )
+            {
+                throw new IOException( e );
+            }
+        }
+    }
+
+    private void addThisTestToPipeline( String cls )
+        throws UnsupportedEncodingException
+    {
+        byte[] clazz = cls.getBytes( FORK_STREAM_CHARSET_NAME );
+        ByteBuffer buffer = ByteBuffer.allocate( 8 + clazz.length )
+            .putInt( MasterProcessCommand.RUN_CLASS.getId() )
+            .putInt( clazz.length )
+            .put( clazz );
+        buffer.rewind();
+        for ( ; buffer.hasRemaining(); )
+        {
+            blockingStream.add( buffer.get() );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-booter/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java
new file mode 100644
index 0000000..4342ec7
--- /dev/null
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/NewClassLoaderRunner.java
@@ -0,0 +1,191 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.internal.runners.model.ReflectiveCallable;
+import org.junit.internal.runners.statements.ExpectException;
+import org.junit.internal.runners.statements.Fail;
+import org.junit.internal.runners.statements.RunAfters;
+import org.junit.internal.runners.statements.RunBefores;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
+
+import java.lang.annotation.Annotation;
+import java.net.URLClassLoader;
+import java.util.List;
+
+/**
+ * JUnit runner testing methods in a separate class loader.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.19
+ */
+public class NewClassLoaderRunner
+    extends BlockJUnit4ClassRunner
+{
+    private Class<?> cls;
+
+    public NewClassLoaderRunner( Class<?> clazz )
+        throws InitializationError
+    {
+        super( clazz );
+    }
+
+    @Override
+    protected void runChild( FrameworkMethod method, RunNotifier notifier )
+    {
+        ClassLoader backup = Thread.currentThread().getContextClassLoader();
+        try
+        {
+            TestClassLoader loader = new TestClassLoader();
+            Thread.currentThread().setContextClassLoader( loader );
+            cls = getFromTestClassLoader( getTestClass().getName(), loader );
+            method = new FrameworkMethod( cls.getMethod( method.getName() ) );
+            super.runChild( method, notifier );
+        }
+        catch ( NoSuchMethodException e )
+        {
+            throw new IllegalStateException( e );
+        }
+        finally
+        {
+            Thread.currentThread().setContextClassLoader( backup );
+        }
+    }
+
+    @Override
+    protected Statement methodBlock( FrameworkMethod method )
+    {
+        try
+        {
+            Object test = new ReflectiveCallable()
+            {
+                @Override
+                protected Object runReflectiveCall()
+                    throws Throwable
+                {
+                    return createTest();
+                }
+            }.run();
+
+            Statement statement = methodInvoker( method, test );
+            statement = possiblyExpectingExceptions( method, test, statement );
+            statement = withBefores( method, test, statement );
+            statement = withAfters( method, test, statement );
+            return statement;
+        }
+        catch ( Throwable e )
+        {
+            return new Fail( e );
+        }
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    protected Statement possiblyExpectingExceptions( FrameworkMethod method, Object test, Statement next )
+    {
+        try
+        {
+            Class<? extends Annotation> t =
+                (Class<? extends Annotation>) Thread.currentThread().getContextClassLoader().loadClass(
+                    Test.class.getName() );
+            Annotation annotation = method.getAnnotation( t );
+            Class<? extends Throwable> exp =
+                (Class<? extends Throwable>) t.getMethod( "expected" ).invoke( annotation );
+            boolean isException = exp != null && !Test.None.class.getName().equals( exp.getName() );
+            return isException ? new ExpectException( next, exp ) : next;
+        }
+        catch ( Exception e )
+        {
+            throw new IllegalStateException( e );
+        }
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    protected Statement withBefores( FrameworkMethod method, Object target, Statement statement )
+    {
+        try
+        {
+            Class<? extends Annotation> before =
+                (Class<? extends Annotation>) Thread.currentThread().getContextClassLoader().loadClass(
+                    Before.class.getName() );
+            List<FrameworkMethod> befores = new TestClass( target.getClass() ).getAnnotatedMethods( before );
+            return befores.isEmpty() ? statement : new RunBefores( statement, befores, target );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new IllegalStateException( e );
+        }
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    protected Statement withAfters( FrameworkMethod method, Object target, Statement statement )
+    {
+        try
+        {
+            Class<? extends Annotation> after =
+                (Class<? extends Annotation>) Thread.currentThread().getContextClassLoader().loadClass(
+                    After.class.getName() );
+            List<FrameworkMethod> afters = new TestClass( target.getClass() ).getAnnotatedMethods( after );
+            return afters.isEmpty() ? statement : new RunAfters( statement, afters, target );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new IllegalStateException( e );
+        }
+    }
+
+    @Override
+    protected Object createTest()
+        throws Exception
+    {
+        return cls == null ? super.createTest() : cls.getConstructor().newInstance();
+    }
+
+    private static Class<?> getFromTestClassLoader( String clazz, TestClassLoader loader )
+    {
+        try
+        {
+            return Class.forName( clazz, true, loader );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new IllegalStateException( e );
+        }
+    }
+
+    public static class TestClassLoader
+        extends URLClassLoader
+    {
+        public TestClassLoader()
+        {
+            super( ( (URLClassLoader) Thread.currentThread().getContextClassLoader() ).getURLs(), null );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
index 470922f..e403a64 100644
--- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
+++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
@@ -115,7 +115,6 @@ public class JUnit3Provider
         return reflector.isJUnit3Available() && jUnit3TestChecker.accept( clazz )
             ? new JUnitTestSet( clazz, reflector )
             : new PojoTestSet( clazz );
-
     }
 
     private void executeTestSet( SurefireTestSet testSet, RunListener reporter, ClassLoader classLoader )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/78dca27e/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
index e3b87af..3f0e57f 100644
--- a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
+++ b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
@@ -55,6 +55,8 @@ import org.junit.runner.Runner;
 import org.junit.runner.manipulation.Filter;
 import org.junit.runner.notification.RunNotifier;
 
+import static org.apache.maven.surefire.testset.TestListResolver.toClassFileName;
+
 /**
  * @author Kristian Rosenvold
  */
@@ -267,8 +269,6 @@ public class JUnit4Provider
     private static void execute( Class<?> testClass, RunNotifier notifier, Filter filter )
     {
         final int classModifiers = testClass.getModifiers();
-
-        // filter.shouldRunClass( testClass )
         if ( !Modifier.isAbstract( classModifiers ) && !Modifier.isInterface( classModifiers ) )
         {
             Runner runner = Request.aClass( testClass ).filterWith( filter ).getRunner();
@@ -349,8 +349,6 @@ public class JUnit4Provider
     {
         private final TestListResolver methodFilter = JUnit4Provider.this.testResolver.createMethodFilters();
 
-        private final TestsToRun testsToRun = JUnit4Provider.this.testsToRun;
-
         @Override
         public boolean shouldRun( Description description )
         {
@@ -360,7 +358,7 @@ public class JUnit4Provider
             final boolean isValidTest = description.isTest() && cm.isValid();
             final String clazz = cm.getClazz();
             final String method = cm.getMethod();
-            return isSuite || isValidTest && methodFilter.shouldRun( testsToRun.getClassByName( clazz ), method );
+            return isSuite || isValidTest && methodFilter.shouldRun( toClassFileName( clazz ), method );
         }
 
         @Override


[08/19] maven-surefire git commit: [SUREFIRE] refactoring removed jdk6 IOException constructor

Posted by ti...@apache.org.
[SUREFIRE] refactoring removed jdk6 IOException constructor


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

Branch: refs/heads/master
Commit: 4bd7231b9881691f2300a65b74cbea7972d27e43
Parents: 81e667b
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Jul 13 23:24:03 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:08 2015 +0200

----------------------------------------------------------------------
 .../booterclient/lazytestprovider/TestProvidingInputStream.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4bd7231b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index e08edf7..eb1ab03 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -144,7 +144,7 @@ public class TestProvidingInputStream
         }
         catch ( InterruptedException e )
         {
-            throw new IOException( e );
+            throw new IOException( e.getLocalizedMessage() );
         }
     }
 


[09/19] maven-surefire git commit: [SUREFIRE] refactoring removed locks in TestProvidingInputStream

Posted by ti...@apache.org.
[SUREFIRE] refactoring removed locks in TestProvidingInputStream


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

Branch: refs/heads/master
Commit: 81e667be8892c4e49e9552c48c1f263bd92160c6
Parents: 5ea1905
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Jul 13 23:21:55 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:08 2015 +0200

----------------------------------------------------------------------
 .../TestProvidingInputStream.java               | 118 ++++++++++---------
 1 file changed, 62 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/81e667be/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index 0001817..e08edf7 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -23,8 +23,8 @@ import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Queue;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
 
@@ -43,20 +43,18 @@ public class TestProvidingInputStream
     extends InputStream
     implements NotifiableTestStream
 {
-    private final ReentrantLock lock = new ReentrantLock();
-
-    private final Condition lockCondition = lock.newCondition();
+    private final Semaphore semaphore = new Semaphore( 0 );
 
     private final Queue<String> testItemQueue;
 
+    private final AtomicBoolean closed = new AtomicBoolean();
+
     private byte[] currentBuffer;
 
     private int currentPos;
 
     private volatile FlushReceiverProvider flushReceiverProvider;
 
-    private volatile boolean closed;
-
     /**
      * C'tor
      *
@@ -75,60 +73,78 @@ public class TestProvidingInputStream
         this.flushReceiverProvider = flushReceiverProvider;
     }
 
+    /**
+     * Used by single thread in StreamFeeder.
+     *
+     * @return {@inheritDoc}
+     * @throws IOException {@inheritDoc}
+     */
     @SuppressWarnings( "checkstyle:magicnumber" )
     @Override
     public int read()
         throws IOException
     {
-        lock.lock();
-        try
+        if ( closed.get() )
         {
-            if ( closed )
-            {
-                throw new EOFException( "closed unexpectedly" );
-            }
-            else
+            throw new EOFException( "closed unexpectedly" );
+        }
+        else
+        {
+            byte[] buffer = currentBuffer;
+
+            if ( buffer == null )
             {
-                if ( null == currentBuffer )
+                if ( flushReceiverProvider != null )
                 {
-                    if ( null != flushReceiverProvider && null != flushReceiverProvider.getFlushReceiver() )
+                    FlushReceiver flushing = flushReceiverProvider.getFlushReceiver();
+                    if ( flushing != null )
                     {
-                        flushReceiverProvider.getFlushReceiver().flush();
+                        flushing.flush();
                     }
+                }
 
-                    lockCondition.awaitUninterruptibly();
-
-                    if ( closed )
-                    {
-                        throw new EOFException( "closed unexpectedly" );
-                    }
+                awaitNextTest();
 
-                    String currentElement = testItemQueue.poll();
-                    if ( currentElement != null )
-                    {
-                        currentBuffer = encodeStringForForkCommunication( currentElement );
-                        currentPos = 0;
-                    }
-                    else
-                    {
-                        return -1;
-                    }
+                if ( closed.get() )
+                {
+                    throw new EOFException( "closed unexpectedly" );
                 }
 
-                if ( currentPos < currentBuffer.length )
+                String currentElement = testItemQueue.poll();
+                if ( currentElement != null )
                 {
-                    return currentBuffer[currentPos++] & 0xff;
+                    currentBuffer = encodeStringForForkCommunication( currentElement );
+                    buffer = currentBuffer;
+                    currentPos = 0;
                 }
                 else
                 {
-                    currentBuffer = null;
-                    return '\n' & 0xff;
+                    return -1;
                 }
             }
+
+            if ( currentPos < buffer.length )
+            {
+                return buffer[currentPos++] & 0xff;
+            }
+            else
+            {
+                currentBuffer = null;
+                return '\n' & 0xff;
+            }
+        }
+    }
+
+    private void awaitNextTest()
+        throws IOException
+    {
+        try
+        {
+            semaphore.acquire();
         }
-        finally
+        catch ( InterruptedException e )
         {
-            lock.unlock();
+            throw new IOException( e );
         }
     }
 
@@ -137,30 +153,20 @@ public class TestProvidingInputStream
      */
     public void provideNewTest()
     {
-        lock.lock();
-        try
-        {
-            lockCondition.signalAll();
-        }
-        finally
-        {
-            lock.unlock();
-        }
+        semaphore.release();
     }
 
     @Override
     public void close()
     {
-        closed = true;
-        lock.lock();
-        try
+        if ( closed.compareAndSet( false, true ) )
         {
             currentBuffer = null;
-            lockCondition.signalAll();
-        }
-        finally
-        {
-            lock.unlock();
+            int permits = semaphore.drainPermits();
+            if ( permits == 0 )
+            {
+                semaphore.release();
+            }
         }
     }
 }
\ No newline at end of file


[14/19] maven-surefire git commit: [SUREFIRE] refactoring: adapt junit 3 tests to junit 4 testsuite

Posted by ti...@apache.org.
[SUREFIRE] refactoring: adapt junit 3 tests to junit 4 testsuite


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

Branch: refs/heads/master
Commit: 4d7be01f3030fed09922f2fb9b14602f8c80c278
Parents: 72c9c5f
Author: Tibor17 <ti...@lycos.com>
Authored: Tue Jul 14 22:59:14 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:13 2015 +0200

----------------------------------------------------------------------
 surefire-booter/pom.xml                         |  5 +++
 .../maven/surefire/booter/JUnit4SuiteTest.java  | 45 ++++++++++++++++++++
 surefire-providers/common-junit48/pom.xml       |  6 +--
 .../common/junit48/JUnit4SuiteTest.java         | 45 ++++++++++++++++++++
 surefire-providers/surefire-junit47/pom.xml     |  3 ++
 .../surefire/junitcore/JUnit4SuiteTest.java     | 24 +++++++----
 .../surefire/junitcore/Surefire746Test.java     |  2 +-
 7 files changed, 118 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d7be01f/surefire-booter/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml
index c1287f1..50598bf 100644
--- a/surefire-booter/pom.xml
+++ b/surefire-booter/pom.xml
@@ -49,6 +49,11 @@
             <version>2.12.4</version> <!-- ${shadedVersion}, but resolved due to http://jira.codehaus.org/browse/MRELEASE-799 -->
           </dependency>
         </dependencies>
+        <configuration>
+          <includes>
+            <include>**/JUnit4SuiteTest.java</include>
+          </includes>
+        </configuration>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d7be01f/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java
new file mode 100644
index 0000000..d426d27
--- /dev/null
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/JUnit4SuiteTest.java
@@ -0,0 +1,45 @@
+package org.apache.maven.surefire.booter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Adapt the JUnit4 tests which use only annotations to the JUnit3 test suite.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.19
+ */
+@Suite.SuiteClasses( {
+    ClasspathTest.class,
+    PropertiesWrapperTest.class,
+    SurefireReflectorTest.class
+} )
+@RunWith( Suite.class )
+public class JUnit4SuiteTest
+{
+    public static Test suite()
+    {
+        return new JUnit4TestAdapter( JUnit4SuiteTest.class );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d7be01f/surefire-providers/common-junit48/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-providers/common-junit48/pom.xml b/surefire-providers/common-junit48/pom.xml
index 8724ad3..f742c16 100644
--- a/surefire-providers/common-junit48/pom.xml
+++ b/surefire-providers/common-junit48/pom.xml
@@ -80,9 +80,9 @@
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
-          <excludes>
-            <exclude>**/fixture/**</exclude>
-          </excludes>
+          <includes>
+            <include>**/JUnit4SuiteTest.java</include>
+          </includes>
         </configuration>
       </plugin>
     </plugins>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d7be01f/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit4SuiteTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit4SuiteTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit4SuiteTest.java
new file mode 100644
index 0000000..547c381
--- /dev/null
+++ b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/JUnit4SuiteTest.java
@@ -0,0 +1,45 @@
+package org.apache.maven.surefire.common.junit48;
+
+/*
+ * 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 junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Adapt the JUnit4 tests which use only annotations to the JUnit3 test suite.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.19
+ */
+@Suite.SuiteClasses( {
+    FilterFactoryTest.class,
+    JUnit48ReflectorTest.class,
+    JUnit48TestCheckerTest.class
+} )
+@RunWith( Suite.class )
+public class JUnit4SuiteTest
+{
+    public static Test suite()
+    {
+        return new JUnit4TestAdapter( JUnit4SuiteTest.class );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d7be01f/surefire-providers/surefire-junit47/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml
index 087c01e..ca86f31 100644
--- a/surefire-providers/surefire-junit47/pom.xml
+++ b/surefire-providers/surefire-junit47/pom.xml
@@ -69,6 +69,9 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <redirectTestOutputToFile>true</redirectTestOutputToFile>
+          <includes>
+            <include>**/JUnit4SuiteTest.java</include>
+          </includes>
         </configuration>
       </plugin>
       <plugin>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d7be01f/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4SuiteTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4SuiteTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4SuiteTest.java
index 6bb58e1..c38ba0a 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4SuiteTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnit4SuiteTest.java
@@ -35,13 +35,21 @@ import org.junit.runners.Suite;
  * @since 2.16
  */
 @Suite.SuiteClasses( {
-        Surefire746Test.class,
-        Surefire813IncorrectResultTest.class,
-        ParallelComputerUtilTest.class,
-        ParallelComputerBuilderTest.class,
-        SchedulingStrategiesTest.class,
-        JUnitCoreParametersTest.class,
-        OptimizedParallelComputerTest.class
+    Surefire746Test.class,
+    Surefire813IncorrectResultTest.class,
+    ParallelComputerUtilTest.class,
+    ParallelComputerBuilderTest.class,
+    SchedulingStrategiesTest.class,
+    JUnitCoreParametersTest.class,
+    OptimizedParallelComputerTest.class,
+    ConcurrentRunListenerTest.class,
+    ConfigurableParallelComputerTest.class,
+    JUnit4Reflector481Test.class,
+    JUnitCoreParametersTest.class,
+    JUnitCoreRunListenerTest.class,
+    MavenSurefireJUnit47RunnerTest.class,
+    MavenSurefireJUnit48RunnerTest.class,
+    TestMethodTest.class
 } )
 @RunWith( Suite.class )
 public class JUnit4SuiteTest
@@ -50,4 +58,4 @@ public class JUnit4SuiteTest
     {
         return new JUnit4TestAdapter( JUnit4SuiteTest.class );
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d7be01f/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
index 4563e6d..93873bf 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
@@ -98,7 +98,7 @@ public class Surefire746Test
         RunListener listener =
             ConcurrentRunListener.createInstance( testSetMap, reporterFactory, false, false, consoleLogger );
 
-        TestsToRun testsToRun = new TestsToRun(Collections.<Class>singletonList( TestClassTest.class ) );
+        TestsToRun testsToRun = new TestsToRun( Collections.<Class<?>>singletonList( TestClassTest.class ) );
 
         org.junit.runner.notification.RunListener jUnit4RunListener = new JUnitCoreRunListener( listener, testSetMap );
 


[10/19] maven-surefire git commit: [SUREFIRE] refactoring proper happens-before relationship: read buffer happens before close

Posted by ti...@apache.org.
[SUREFIRE] refactoring proper happens-before relationship: read buffer happens before close


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

Branch: refs/heads/master
Commit: a83675e7785958871abb74487a24357149c79a33
Parents: 4bd7231
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Jul 13 23:31:36 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:09 2015 +0200

----------------------------------------------------------------------
 .../booterclient/lazytestprovider/TestProvidingInputStream.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a83675e7/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index eb1ab03..fd7d162 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -113,8 +113,8 @@ public class TestProvidingInputStream
                 String currentElement = testItemQueue.poll();
                 if ( currentElement != null )
                 {
-                    currentBuffer = encodeStringForForkCommunication( currentElement );
-                    buffer = currentBuffer;
+                    buffer = encodeStringForForkCommunication( currentElement );
+                    currentBuffer = buffer;
                     currentPos = 0;
                 }
                 else


[07/19] maven-surefire git commit: [SUREFIRE] refactoring with NotifiableTestStream

Posted by ti...@apache.org.
[SUREFIRE] refactoring with NotifiableTestStream


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

Branch: refs/heads/master
Commit: 5ea1905781ce6f165de45a3b2732bd5344dc1949
Parents: df7e6f3
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Jul 13 21:53:40 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:07 2015 +0200

----------------------------------------------------------------------
 .../maven/plugin/surefire/booterclient/output/ForkClient.java     | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5ea19057/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
index 529cf1c..aa6c64f 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
@@ -30,7 +30,6 @@ import java.util.StringTokenizer;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.NotifiableTestStream;
-import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStream;
 import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
 import org.apache.maven.shared.utils.cli.StreamConsumer;
 import org.apache.maven.surefire.booter.ForkingRunListener;
@@ -69,7 +68,7 @@ public class ForkClient
     }
 
     public ForkClient( DefaultReporterFactory defaultReporterFactory, Properties testVmSystemProperties,
-                       TestProvidingInputStream notifiableTestStream )
+                       NotifiableTestStream notifiableTestStream )
     {
         this.defaultReporterFactory = defaultReporterFactory;
         this.testVmSystemProperties = testVmSystemProperties;


[15/19] maven-surefire git commit: [SUREFIRE] refactoring + properly closing TestProvidingInputStream

Posted by ti...@apache.org.
[SUREFIRE] refactoring + properly closing TestProvidingInputStream


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

Branch: refs/heads/master
Commit: 2c04ad8b88c5a82f5e80243c3d88604ef4ab95cf
Parents: 4d7be01
Author: Tibor17 <ti...@lycos.com>
Authored: Wed Jul 15 23:12:04 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:14 2015 +0200

----------------------------------------------------------------------
 .../surefire/booterclient/ForkStarter.java      | 119 ++++++++-----------
 .../surefire/report/DefaultReporterFactory.java |   9 +-
 2 files changed, 52 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2c04ad8b/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 64bce8b..804a08e 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
@@ -135,7 +135,7 @@ public class ForkStarter
 
     private final DefaultReporterFactory defaultReporterFactory;
 
-    private final Collection<DefaultReporterFactory> defaultReporterFactoryList;
+    private final Collection<DefaultReporterFactory> defaultReporterFactories;
 
     private static volatile int systemPropertiesFileCounter = 0;
 
@@ -151,7 +151,7 @@ public class ForkStarter
         this.log = log;
         defaultReporterFactory = new DefaultReporterFactory( startupReportConfiguration );
         defaultReporterFactory.runStarting();
-        defaultReporterFactoryList = new ConcurrentLinkedQueue<DefaultReporterFactory>();
+        defaultReporterFactories = new ConcurrentLinkedQueue<DefaultReporterFactory>();
     }
 
     public RunResult run( SurefireProperties effectiveSystemProperties, DefaultScanResult scanResult )
@@ -167,7 +167,7 @@ public class ForkStarter
         }
         finally
         {
-            defaultReporterFactory.mergeFromOtherFactories( defaultReporterFactoryList );
+            defaultReporterFactory.mergeFromOtherFactories( defaultReporterFactories );
             defaultReporterFactory.close();
         }
     }
@@ -176,7 +176,7 @@ public class ForkStarter
             throws SurefireBooterForkException
     {
         DefaultReporterFactory forkedReporterFactory = new DefaultReporterFactory( startupReportConfiguration );
-        defaultReporterFactoryList.add( forkedReporterFactory );
+        defaultReporterFactories.add( forkedReporterFactory );
         final ForkClient forkClient =
                 new ForkClient( forkedReporterFactory, startupReportConfiguration.getTestVmSystemProperties() );
         return fork( null, new PropertiesWrapper( providerProperties ), forkClient, effectiveSystemProperties, null );
@@ -206,15 +206,13 @@ public class ForkStarter
     private RunResult runSuitesForkOnceMultiple( final SurefireProperties effectiveSystemProperties, int forkCount )
         throws SurefireBooterForkException
     {
-
         ArrayList<Future<RunResult>> results = new ArrayList<Future<RunResult>>( forkCount );
         ThreadPoolExecutor executorService = new ThreadPoolExecutor( forkCount, forkCount, 60, TimeUnit.SECONDS,
                                                                   new ArrayBlockingQueue<Runnable>( forkCount ) );
         executorService.setThreadFactory( threadFactory );
+        Collection<TestProvidingInputStream> testStreams = new ArrayList<TestProvidingInputStream>();
         try
         {
-            // Ask to the executorService to run all tasks
-            RunResult globalResult = new RunResult( 0, 0, 0, 0 );
             final Queue<String> messageQueue = new ConcurrentLinkedQueue<String>();
             for ( Class<?> clazz : getSuitesIterator() )
             {
@@ -223,17 +221,16 @@ public class ForkStarter
 
             for ( int forkNum = 0, total = messageQueue.size(); forkNum < forkCount && forkNum < total; forkNum++ )
             {
+                final TestProvidingInputStream testProvidingInputStream = new TestProvidingInputStream( messageQueue );
+                testStreams.add( testProvidingInputStream );
                 Callable<RunResult> pf = new Callable<RunResult>()
                 {
                     public RunResult call()
                         throws Exception
                     {
-                        TestProvidingInputStream testProvidingInputStream =
-                                new TestProvidingInputStream( messageQueue );
-
                         DefaultReporterFactory forkedReporterFactory =
                             new DefaultReporterFactory( startupReportConfiguration );
-                        defaultReporterFactoryList.add( forkedReporterFactory );
+                        defaultReporterFactories.add( forkedReporterFactory );
                         ForkClient forkClient = new ForkClient( forkedReporterFactory,
                                                                 startupReportConfiguration.getTestVmSystemProperties(),
                                                                 testProvidingInputStream );
@@ -242,47 +239,19 @@ public class ForkStarter
                                      forkClient, effectiveSystemProperties, testProvidingInputStream );
                     }
                 };
-
                 results.add( executorService.submit( pf ) );
             }
-
-            for ( Future<RunResult> result : results )
-            {
-                try
-                {
-                    RunResult cur = result.get();
-                    if ( cur != null )
-                    {
-                        globalResult = globalResult.aggregate( cur );
-                    }
-                    else
-                    {
-                        throw new SurefireBooterForkException( "No results for " + result.toString() );
-                    }
-                }
-                catch ( InterruptedException e )
-                {
-                    executorService.shutdownNow();
-                    Thread.currentThread().interrupt();
-                    throw new SurefireBooterForkException( "Interrupted", e );
-                }
-                catch ( ExecutionException e )
-                {
-                    throw new SurefireBooterForkException( "ExecutionException", e );
-                }
-            }
-            return globalResult;
-
+            return awaitResultsDone( results, executorService );
         }
         finally
         {
+            closeTestStreams( testStreams );
             closeExecutor( executorService );
         }
-
     }
 
     @SuppressWarnings( "checkstyle:magicnumber" )
-    private RunResult runSuitesForkPerTestSet( final SurefireProperties effectiveSystemProperties, final int forkCount )
+    private RunResult runSuitesForkPerTestSet( final SurefireProperties effectiveSystemProperties, int forkCount )
         throws SurefireBooterForkException
     {
         ArrayList<Future<RunResult>> results = new ArrayList<Future<RunResult>>( 500 );
@@ -291,9 +260,6 @@ public class ForkStarter
         executorService.setThreadFactory( threadFactory );
         try
         {
-            // Ask to the executorService to run all tasks
-            RunResult globalResult = new RunResult( 0, 0, 0, 0 );
-
             for ( final Object testSet : getSuitesIterator() )
             {
                 Callable<RunResult> pf = new Callable<RunResult>()
@@ -303,7 +269,7 @@ public class ForkStarter
                     {
                         DefaultReporterFactory forkedReporterFactory =
                             new DefaultReporterFactory( startupReportConfiguration );
-                        defaultReporterFactoryList.add( forkedReporterFactory );
+                        defaultReporterFactories.add( forkedReporterFactory );
                         ForkClient forkClient = new ForkClient( forkedReporterFactory,
                                                         startupReportConfiguration.getTestVmSystemProperties() );
                         return fork( testSet, new PropertiesWrapper( providerConfiguration.getProviderProperties() ),
@@ -311,42 +277,53 @@ public class ForkStarter
                     }
                 };
                 results.add( executorService.submit( pf ) );
-
             }
+            return awaitResultsDone( results, executorService );
+        }
+        finally
+        {
+            closeExecutor( executorService );
+        }
+    }
 
-            for ( Future<RunResult> result : results )
+    private static RunResult awaitResultsDone( Collection<Future<RunResult>> results, ExecutorService executorService )
+        throws SurefireBooterForkException
+    {
+        RunResult globalResult = new RunResult( 0, 0, 0, 0 );
+        for ( Future<RunResult> result : results )
+        {
+            try
             {
-                try
-                {
-                    RunResult cur = result.get();
-                    if ( cur != null )
-                    {
-                        globalResult = globalResult.aggregate( cur );
-                    }
-                    else
-                    {
-                        throw new SurefireBooterForkException( "No results for " + result.toString() );
-                    }
-                }
-                catch ( InterruptedException e )
+                RunResult cur = result.get();
+                if ( cur != null )
                 {
-                    executorService.shutdownNow();
-                    Thread.currentThread().interrupt();
-                    throw new SurefireBooterForkException( "Interrupted", e );
+                    globalResult = globalResult.aggregate( cur );
                 }
-                catch ( ExecutionException e )
+                else
                 {
-                    throw new SurefireBooterForkException( "ExecutionException", e );
+                    throw new SurefireBooterForkException( "No results for " + result.toString() );
                 }
             }
-            return globalResult;
-
+            catch ( InterruptedException e )
+            {
+                executorService.shutdownNow();
+                Thread.currentThread().interrupt();
+                throw new SurefireBooterForkException( "Interrupted", e );
+            }
+            catch ( ExecutionException e )
+            {
+                throw new SurefireBooterForkException( "ExecutionException", e );
+            }
         }
-        finally
+        return globalResult;
+    }
+
+    private static void closeTestStreams( Iterable<TestProvidingInputStream> testStreams )
+    {
+        for ( TestProvidingInputStream testStream: testStreams )
         {
-            closeExecutor( executorService );
+            testStream.close();
         }
-
     }
 
     @SuppressWarnings( "checkstyle:magicnumber" )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2c04ad8b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
index aeb3c22..2af0b40 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
@@ -30,11 +30,11 @@ import org.apache.maven.surefire.suite.RunResult;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
 
 /**
  * Provides reporting modules on the plugin side.
@@ -53,8 +53,7 @@ public class DefaultReporterFactory
 
     private final StatisticsReporter statisticsReporter;
 
-    private final List<TestSetRunListener> listeners =
-        Collections.synchronizedList( new ArrayList<TestSetRunListener>() );
+    private final Collection<TestSetRunListener> listeners = new ConcurrentLinkedQueue<TestSetRunListener>();
 
     // from "<testclass>.<testmethod>" -> statistics about all the runs for flaky tests
     private Map<String, List<TestMethodStats>> flakyTests;
@@ -97,11 +96,11 @@ public class DefaultReporterFactory
                                     reportConfiguration.isTrimStackTrace(),
                                     ConsoleReporter.PLAIN.equals( reportConfiguration.getReportFormat() ),
                                     reportConfiguration.isBriefOrPlainFormat() );
-        listeners.add( testSetRunListener );
+        addListener( testSetRunListener );
         return testSetRunListener;
     }
 
-    public void addListener( TestSetRunListener listener )
+    final void addListener( TestSetRunListener listener )
     {
         listeners.add( listener );
     }


[04/19] maven-surefire git commit: [SUREFIRE] refactoring of StringUtils

Posted by ti...@apache.org.
[SUREFIRE] refactoring of StringUtils


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

Branch: refs/heads/master
Commit: 1d0ac004e8b8015724362cc7f061e66f48173993
Parents: e8cd8cc
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Jul 13 20:50:08 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:04 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/maven/surefire/util/internal/StringUtils.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/1d0ac004/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index 324f1a0..831c7e7 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -124,7 +124,7 @@ public class StringUtils
      */
     public static boolean isBlank( String str )
     {
-        return ( ( str == null ) || ( str.trim().length() == 0 ) );
+        return str == null || str.trim().length() == 0;
     }
 
     /**


[17/19] maven-surefire git commit: [SUREFIRE] refactoring

Posted by ti...@apache.org.
[SUREFIRE] refactoring


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

Branch: refs/heads/master
Commit: 30199c9f736afa74500f874c2b18d5ad91c86c3e
Parents: f7c71a0
Author: Tibor17 <ti...@lycos.com>
Authored: Fri Jul 17 22:17:04 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:16 2015 +0200

----------------------------------------------------------------------
 .../apache/maven/surefire/junit/PojoAndJUnit3Checker.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/30199c9f/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java
index 861fad3..d3529c1 100644
--- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java
+++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoAndJUnit3Checker.java
@@ -40,15 +40,15 @@ public class PojoAndJUnit3Checker
 
     public boolean accept( Class testClass )
     {
-        return jUnit3TestChecker.accept( testClass ) || nonAbstractClassFilter.accept( testClass ) && isPojoTest(
-            testClass );
+        return jUnit3TestChecker.accept( testClass )
+            || nonAbstractClassFilter.accept( testClass ) && isPojoTest( testClass );
     }
 
-    private boolean isPojoTest( Class testClass )
+    private boolean isPojoTest( Class<?> testClass )
     {
         try
         {
-            testClass.getConstructor( new Class[0] );
+            testClass.getConstructor();
             return true;
         }
         catch ( Exception e )


[16/19] maven-surefire git commit: [SUREFIRE] refactoring + fixed typo

Posted by ti...@apache.org.
[SUREFIRE] refactoring + fixed typo


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

Branch: refs/heads/master
Commit: f7c71a02fc1db6f79139c0c3771c201acf4033a3
Parents: 2c04ad8
Author: Tibor17 <ti...@lycos.com>
Authored: Fri Jul 17 17:04:43 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:15 2015 +0200

----------------------------------------------------------------------
 .../plugin/surefire/booterclient/output/ForkClient.java | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f7c71a02/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
index aa6c64f..1778051 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
@@ -157,7 +157,7 @@ public class ForkClient
                     }
                     break;
                 case ForkingRunListener.BOOTERCODE_ERROR:
-                    errorInFork = deserializeStackStraceWriter( new StringTokenizer( remaining, "," ) );
+                    errorInFork = deserializeStackTraceWriter( new StringTokenizer( remaining, "," ) );
                     break;
                 case ForkingRunListener.BOOTERCODE_BYE:
                     saidGoodBye = true;
@@ -233,7 +233,7 @@ public class ForkClient
             String elapsedStr = tokens.nextToken();
             Integer elapsed = "null".equals( elapsedStr ) ? null : Integer.decode( elapsedStr );
             final StackTraceWriter stackTraceWriter =
-                tokens.hasMoreTokens() ? deserializeStackStraceWriter( tokens ) : null;
+                tokens.hasMoreTokens() ? deserializeStackTraceWriter( tokens ) : null;
 
             return CategorizedReportEntry.reportEntry( source, name, group, stackTraceWriter, elapsed, message );
         }
@@ -243,15 +243,15 @@ public class ForkClient
         }
     }
 
-    private StackTraceWriter deserializeStackStraceWriter( StringTokenizer tokens )
+    private StackTraceWriter deserializeStackTraceWriter( StringTokenizer tokens )
     {
         StackTraceWriter stackTraceWriter;
         String stackTraceMessage = nullableCsv( tokens.nextToken() );
         String smartStackTrace = nullableCsv( tokens.nextToken() );
         String stackTrace = tokens.hasMoreTokens() ? nullableCsv( tokens.nextToken() ) : null;
-        stackTraceWriter =
-            stackTrace != null ? new DeserializedStacktraceWriter( stackTraceMessage, smartStackTrace, stackTrace )
-                            : null;
+        stackTraceWriter = stackTrace != null
+            ? new DeserializedStacktraceWriter( stackTraceMessage, smartStackTrace, stackTrace )
+            : null;
         return stackTraceWriter;
     }
 


[02/19] maven-surefire git commit: [SUREFIRE] refactoring + improve: synchronization, use only daemon threads, using interrupted threads

Posted by ti...@apache.org.
[SUREFIRE] refactoring + improve: synchronization,use only daemon threads,using interrupted threads


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

Branch: refs/heads/master
Commit: e53ab1229add11b89532ba054312c870ef77ab3c
Parents: 7d9c438
Author: Tibor17 <ti...@lycos.com>
Authored: Sat Jul 11 16:39:44 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:01 2015 +0200

----------------------------------------------------------------------
 .../surefire/booterclient/ForkStarter.java      |  20 +++-
 .../TestProvidingInputStream.java               | 102 +++++++++++------
 .../booterclient/output/ForkClient.java         |  23 ++--
 .../output/ThreadedStreamConsumer.java          |  10 +-
 .../booterclient/ForkingRunListenerTest.java    |   4 +-
 .../surefire/booter/ForkingRunListener.java     |   8 +-
 .../util/internal/DaemonThreadFactory.java      | 112 +++++++++++++++++++
 .../maven/surefire/booter/ForkedBooter.java     |   8 +-
 .../surefire/report/RunnableTestClass1.java     |   5 +-
 .../report/SmartStackTraceParserTest.java       |   6 +-
 .../common/junit4/JUnit4RunListenerTest.java    |   3 +-
 .../junitcore/ConfigurableParallelComputer.java |  15 ++-
 .../surefire/junitcore/pc/ParallelComputer.java |   6 +-
 .../junitcore/pc/ParallelComputerBuilder.java   |  12 +-
 .../junitcore/pc/SchedulingStrategies.java      |   8 +-
 .../junitcore/pc/SingleThreadScheduler.java     |  11 +-
 .../junitcore/pc/SchedulingStrategiesTest.java  |   6 +-
 17 files changed, 263 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/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 7022bf8..0514e47 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
@@ -48,6 +48,7 @@ import org.apache.maven.surefire.report.StackTraceWriter;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestRequest;
 import org.apache.maven.surefire.util.DefaultScanResult;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 import org.apache.maven.surefire.util.internal.StringUtils;
 
 import java.io.File;
@@ -66,6 +67,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
+import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -89,6 +91,8 @@ import static org.apache.maven.surefire.booter.Classpath.join;
  */
 public class ForkStarter
 {
+    private final ThreadFactory threadFactory = DaemonThreadFactory.newDaemonThreadFactory();
+
     /**
      * Closes an InputStream
      */
@@ -206,9 +210,9 @@ public class ForkStarter
     {
 
         ArrayList<Future<RunResult>> results = new ArrayList<Future<RunResult>>( forkCount );
-        ExecutorService executorService = new ThreadPoolExecutor( forkCount, forkCount, 60, TimeUnit.SECONDS,
+        ThreadPoolExecutor executorService = new ThreadPoolExecutor( forkCount, forkCount, 60, TimeUnit.SECONDS,
                                                                   new ArrayBlockingQueue<Runnable>( forkCount ) );
-
+        executorService.setThreadFactory( threadFactory );
         try
         {
             // Ask to the executorService to run all tasks
@@ -267,6 +271,8 @@ public class ForkStarter
                 }
                 catch ( InterruptedException e )
                 {
+                    executorService.shutdownNow();
+                    Thread.currentThread().interrupt();
                     throw new SurefireBooterForkException( "Interrupted", e );
                 }
                 catch ( ExecutionException e )
@@ -288,11 +294,10 @@ public class ForkStarter
     private RunResult runSuitesForkPerTestSet( final SurefireProperties effectiveSystemProperties, final int forkCount )
         throws SurefireBooterForkException
     {
-
         ArrayList<Future<RunResult>> results = new ArrayList<Future<RunResult>>( 500 );
-        ExecutorService executorService =
+        ThreadPoolExecutor executorService =
             new ThreadPoolExecutor( forkCount, forkCount, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>() );
-
+        executorService.setThreadFactory( threadFactory );
         try
         {
             // Ask to the executorService to run all tasks
@@ -335,6 +340,8 @@ public class ForkStarter
                 }
                 catch ( InterruptedException e )
                 {
+                    executorService.shutdownNow();
+                    Thread.currentThread().interrupt();
                     throw new SurefireBooterForkException( "Interrupted", e );
                 }
                 catch ( ExecutionException e )
@@ -364,6 +371,7 @@ public class ForkStarter
         }
         catch ( InterruptedException e )
         {
+            Thread.currentThread().interrupt();
             throw new SurefireBooterForkException( "Interrupted", e );
         }
     }
@@ -439,7 +447,7 @@ public class ForkStarter
         {
             testProvidingInputStream.setFlushReceiverProvider( cli );
             inputStreamCloser = new InputStreamCloser( testProvidingInputStream );
-            inputStreamCloserHook = new Thread( inputStreamCloser );
+            inputStreamCloserHook = DaemonThreadFactory.newDaemonThread( inputStreamCloser, "input-stream-closer" );
             ShutdownHookUtils.addShutDownHook( inputStreamCloserHook );
         }
         else

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index e7a5032..9f40bf7 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -19,10 +19,12 @@ package org.apache.maven.plugin.surefire.booterclient.lazytestprovider;
  * under the License.
  */
 
+import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Queue;
-import java.util.concurrent.Semaphore;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
 
 import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
 
@@ -40,17 +42,19 @@ import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringFo
 public class TestProvidingInputStream
     extends InputStream
 {
+    private final ReentrantLock lock = new ReentrantLock();
+
+    private final Condition lockCondition = lock.newCondition();
+
     private final Queue<String> testItemQueue;
 
     private byte[] currentBuffer;
 
     private int currentPos;
 
-    private final Semaphore semaphore = new Semaphore( 0 );
-
-    private FlushReceiverProvider flushReceiverProvider;
+    private volatile FlushReceiverProvider flushReceiverProvider;
 
-    private volatile boolean closed = false;
+    private volatile boolean closed;
 
     /**
      * C'tor
@@ -72,43 +76,58 @@ public class TestProvidingInputStream
 
     @SuppressWarnings( "checkstyle:magicnumber" )
     @Override
-    public synchronized int read()
+    public int read()
         throws IOException
     {
-        if ( null == currentBuffer )
+        lock.lock();
+        try
         {
-            if ( null != flushReceiverProvider && null != flushReceiverProvider.getFlushReceiver() )
-            {
-                flushReceiverProvider.getFlushReceiver().flush();
-            }
-
-            semaphore.acquireUninterruptibly();
-
             if ( closed )
             {
-                return -1;
-            }
-
-            String currentElement = testItemQueue.poll();
-            if ( currentElement != null )
-            {
-                currentBuffer = encodeStringForForkCommunication( currentElement );
-                currentPos = 0;
+                throw new EOFException( "closed unexpectedly" );
             }
             else
             {
-                return -1;
+                if ( null == currentBuffer )
+                {
+                    if ( null != flushReceiverProvider && null != flushReceiverProvider.getFlushReceiver() )
+                    {
+                        flushReceiverProvider.getFlushReceiver().flush();
+                    }
+
+                    lockCondition.awaitUninterruptibly();
+
+                    if ( closed )
+                    {
+                        throw new EOFException( "closed unexpectedly" );
+                    }
+
+                    String currentElement = testItemQueue.poll();
+                    if ( currentElement != null )
+                    {
+                        currentBuffer = encodeStringForForkCommunication( currentElement );
+                        currentPos = 0;
+                    }
+                    else
+                    {
+                        return -1;
+                    }
+                }
+
+                if ( currentPos < currentBuffer.length )
+                {
+                    return currentBuffer[currentPos++] & 0xff;
+                }
+                else
+                {
+                    currentBuffer = null;
+                    return '\n' & 0xff;
+                }
             }
         }
-
-        if ( currentPos < currentBuffer.length )
+        finally
         {
-            return currentBuffer[currentPos++] & 0xff;
-        }
-        else
-        {
-            currentBuffer = null;
-            return '\n' & 0xff;
+            lock.unlock();
         }
     }
 
@@ -117,13 +136,30 @@ public class TestProvidingInputStream
      */
     public void provideNewTest()
     {
-        semaphore.release();
+        lock.lock();
+        try
+        {
+            lockCondition.signalAll();
+        }
+        finally
+        {
+            lock.unlock();
+        }
     }
 
     @Override
     public void close()
     {
         closed = true;
-        semaphore.release();
+        lock.lock();
+        try
+        {
+            currentBuffer = null;
+            lockCondition.signalAll();
+        }
+        finally
+        {
+            lock.unlock();
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
index cea1824..54ee5e4 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
@@ -23,12 +23,11 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.StringReader;
 import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Properties;
 import java.util.StringTokenizer;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.TestProvidingInputStream;
 import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
@@ -51,19 +50,17 @@ import org.apache.maven.surefire.util.internal.StringUtils;
 public class ForkClient
     implements StreamConsumer
 {
-
     private final DefaultReporterFactory defaultReporterFactory;
 
     private final TestProvidingInputStream testProvidingInputStream;
 
-    private final Map<Integer, RunListener> testSetReporters =
-        Collections.synchronizedMap( new HashMap<Integer, RunListener>() );
+    private final Map<Integer, RunListener> testSetReporters = new ConcurrentHashMap<Integer, RunListener>();
 
     private final Properties testVmSystemProperties;
 
-    private volatile boolean saidGoodBye = false;
+    private volatile boolean saidGoodBye;
 
-    private volatile StackTraceWriter errorInFork = null;
+    private volatile StackTraceWriter errorInFork;
 
     public ForkClient( DefaultReporterFactory defaultReporterFactory, Properties testVmSystemProperties )
     {
@@ -98,7 +95,7 @@ public class ForkClient
                 System.out.println( s );
                 return;
             }
-            final Integer channelNumber = Integer.parseInt( s.substring( 2, commma ), 16 );
+            final int channelNumber = Integer.parseInt( s.substring( 2, commma ), 16 );
             int rest = s.indexOf( ",", commma );
             final String remaining = s.substring( rest + 1 );
 
@@ -181,7 +178,7 @@ public class ForkClient
         }
     }
 
-    private void writeTestOutput( final Integer channelNumber, final String remaining, boolean isStdout )
+    private void writeTestOutput( final int channelNumber, final String remaining, boolean isStdout )
     {
         int csNameEnd = remaining.indexOf( ',' );
         String charsetName = remaining.substring( 0, csNameEnd );
@@ -277,12 +274,12 @@ public class ForkClient
      * @param channelNumber The logical channel number
      * @return A mock provider reporter
      */
-    public RunListener getReporter( Integer channelNumber )
+    public RunListener getReporter( int channelNumber )
     {
         return testSetReporters.get( channelNumber );
     }
 
-    private RunListener getOrCreateReporter( Integer channelNumber )
+    private RunListener getOrCreateReporter( int channelNumber )
     {
         RunListener reporter = testSetReporters.get( channelNumber );
         if ( reporter == null )
@@ -293,12 +290,12 @@ public class ForkClient
         return reporter;
     }
 
-    private ConsoleOutputReceiver getOrCreateConsoleOutputReceiver( Integer channelNumber )
+    private ConsoleOutputReceiver getOrCreateConsoleOutputReceiver( int channelNumber )
     {
         return (ConsoleOutputReceiver) getOrCreateReporter( channelNumber );
     }
 
-    private ConsoleLogger getOrCreateConsoleLogger( Integer channelNumber )
+    private ConsoleLogger getOrCreateConsoleLogger( int channelNumber )
     {
         return (ConsoleLogger) getOrCreateReporter( channelNumber );
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
index 7574eec..c7b4e66 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
@@ -20,7 +20,9 @@ package org.apache.maven.plugin.surefire.booterclient.output;
  */
 
 import org.apache.maven.shared.utils.cli.StreamConsumer;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 
+import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 
 /**
@@ -31,7 +33,7 @@ import java.util.concurrent.LinkedBlockingQueue;
 public class ThreadedStreamConsumer
     implements StreamConsumer
 {
-    private final java.util.concurrent.BlockingQueue<String> items = new LinkedBlockingQueue<String>();
+    private final BlockingQueue<String> items = new LinkedBlockingQueue<String>();
 
     private static final String POISON = "Pioson";
     private static final int ITEM_LIMIT_BEFORE_SLEEP = 10000;
@@ -43,14 +45,14 @@ public class ThreadedStreamConsumer
     static class Pumper
         implements Runnable
     {
-        private final java.util.concurrent.BlockingQueue<String> queue;
+        private final BlockingQueue<String> queue;
 
         private final StreamConsumer target;
 
         private volatile Throwable throwable;
 
 
-        Pumper( java.util.concurrent.BlockingQueue<String> queue, StreamConsumer target )
+        Pumper( BlockingQueue<String> queue, StreamConsumer target )
         {
             this.queue = queue;
             this.target = target;
@@ -85,7 +87,7 @@ public class ThreadedStreamConsumer
     public ThreadedStreamConsumer( StreamConsumer target )
     {
         pumper = new Pumper( items, target );
-        thread = new Thread( pumper, "ThreadedStreamConsumer" );
+        thread = DaemonThreadFactory.newDaemonThread( pumper, "ThreadedStreamConsumer" );
         thread.start();
     }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java
index fd85b44..31e511c 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java
@@ -53,9 +53,9 @@ public class ForkingRunListenerTest
 
     private final PrintStream printStream;
 
-    final Integer defaultChannel = 17;
+    final int defaultChannel = 17;
 
-    final Integer anotherChannel = 18;
+    final int anotherChannel = 18;
 
     public ForkingRunListenerTest()
     {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index 719679f..203651e 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -155,14 +155,8 @@ public class ForkingRunListener
             while ( propertyKeys.hasMoreElements() )
             {
                 String key = (String) propertyKeys.nextElement();
-
                 String value = systemProperties.getProperty( key );
-
-                if ( value == null )
-                {
-                    value = "null";
-                }
-                encodeAndWriteToTarget( toPropertyString( key, value ) );
+                encodeAndWriteToTarget( toPropertyString( key, value == null ? "null" : value ) );
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DaemonThreadFactory.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DaemonThreadFactory.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DaemonThreadFactory.java
new file mode 100644
index 0000000..29eb18d
--- /dev/null
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/DaemonThreadFactory.java
@@ -0,0 +1,112 @@
+package org.apache.maven.surefire.util.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Creates new daemon Thread.
+ */
+public final class DaemonThreadFactory
+    implements ThreadFactory
+{
+    private static final AtomicInteger POOL_NUMBER = new AtomicInteger( 1 );
+
+    private final AtomicInteger threadNumber = new AtomicInteger( 1 );
+
+    private final ThreadGroup group;
+
+    private final String namePrefix;
+
+    private DaemonThreadFactory()
+    {
+        SecurityManager s = System.getSecurityManager();
+        group = s != null ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
+        namePrefix = "pool-" + POOL_NUMBER.getAndIncrement() + "-thread-";
+    }
+
+    public Thread newThread( Runnable r )
+    {
+        Thread t = new Thread( group, r, namePrefix + threadNumber.getAndIncrement() );
+        if ( t.getPriority() != Thread.NORM_PRIORITY )
+        {
+            t.setPriority( Thread.NORM_PRIORITY );
+        }
+        t.setDaemon( true );
+        return t;
+    }
+
+    /**
+     * Should be used by thread pools.
+     */
+    public static ThreadFactory newDaemonThreadFactory()
+    {
+        return new DaemonThreadFactory();
+    }
+
+    public static ThreadFactory newDaemonThreadFactory( String name )
+    {
+        return new NamedThreadFactory( name );
+    }
+
+    public static Thread newDaemonThread( Runnable r )
+    {
+        SecurityManager s = System.getSecurityManager();
+        ThreadGroup group = s == null ? Thread.currentThread().getThreadGroup() : s.getThreadGroup();
+        Thread t = new Thread( group, r );
+        if ( t.getPriority() != Thread.NORM_PRIORITY )
+        {
+            t.setPriority( Thread.NORM_PRIORITY );
+        }
+        t.setDaemon( true );
+        return t;
+    }
+
+    public static Thread newDaemonThread( Runnable r, String name )
+    {
+        SecurityManager s = System.getSecurityManager();
+        ThreadGroup group = s == null ? Thread.currentThread().getThreadGroup() : s.getThreadGroup();
+        Thread t = new Thread( group, r, name );
+        if ( t.getPriority() != Thread.NORM_PRIORITY )
+        {
+            t.setPriority( Thread.NORM_PRIORITY );
+        }
+        t.setDaemon( true );
+        return t;
+    }
+
+    private static class NamedThreadFactory
+        implements ThreadFactory
+    {
+
+        private final String name;
+
+        private NamedThreadFactory( String name )
+        {
+            this.name = name;
+        }
+
+        public Thread newThread( Runnable r )
+        {
+            return newDaemonThread( r, name );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index f59461a..ac73564 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
@@ -33,6 +33,7 @@ import org.apache.maven.surefire.report.StackTraceWriter;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.ReflectionUtils;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 
 import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
 
@@ -48,7 +49,6 @@ import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringFo
  */
 public class ForkedBooter
 {
-
     /**
      * This method is invoked when Surefire is forked - this method parses and organizes the arguments passed to it and
      * then calls the Surefire class' run method. <p/> The system exit code will be 1 if an exception is thrown.
@@ -174,7 +174,7 @@ public class ForkedBooter
     @SuppressWarnings( "checkstyle:emptyblock" )
     private static void launchLastDitchDaemonShutdownThread( final int returnCode )
     {
-        Thread lastExit = new Thread( new Runnable()
+        DaemonThreadFactory.newDaemonThread( new Runnable()
         {
             public void run()
             {
@@ -187,9 +187,7 @@ public class ForkedBooter
                 {
                 }
             }
-        } );
-        lastExit.setDaemon( true );
-        lastExit.start();
+        }, "last-ditch-daemon-shutdown-thread-" + SYSTEM_EXIT_TIMEOUT ).start();
     }
 
     public static RunResult invokeProviderInSameClassLoader( Object testSet, Object factory,

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass1.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass1.java b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass1.java
index 58ed78d..8414903 100644
--- a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass1.java
+++ b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/RunnableTestClass1.java
@@ -1,5 +1,7 @@
 package org.apache.maven.surefire.report;
 
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
+
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.FutureTask;
@@ -24,7 +26,6 @@ import java.util.concurrent.FutureTask;
 */
 class RunnableTestClass1
     implements Callable<Object>
-
 {
     public Object call()
         throws Exception
@@ -38,7 +39,7 @@ class RunnableTestClass1
     {
         RunnableTestClass2 rt2 = new RunnableTestClass2();
         FutureTask<Object> futureTask = new FutureTask<Object>( rt2 );
-        new Thread( futureTask ).start();
+        DaemonThreadFactory.newDaemonThread( futureTask ).start();
         try
         {
             futureTask.get();

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
index 4d39184..e600718 100644
--- a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
+++ b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
@@ -27,6 +27,7 @@ import java.util.concurrent.FutureTask;
 import junit.framework.AssertionFailedError;
 import junit.framework.ComparisonFailure;
 import junit.framework.TestCase;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 
 import static org.apache.maven.surefire.report.SmartStackTraceParser.*;
 
@@ -34,7 +35,6 @@ import static org.apache.maven.surefire.report.SmartStackTraceParser.*;
 public class SmartStackTraceParserTest
     extends TestCase
 {
-
     public void testGetString()
         throws Exception
     {
@@ -306,7 +306,7 @@ public class SmartStackTraceParserTest
     public ExecutionException getSingleNested()
     {
         FutureTask<Object> futureTask = new FutureTask<Object>( new RunnableTestClass2() );
-        new Thread( futureTask ).start();
+        DaemonThreadFactory.newDaemonThread( futureTask ).start();
         try
         {
             futureTask.get();
@@ -326,7 +326,7 @@ public class SmartStackTraceParserTest
     private ExecutionException getDoubleNestedException()
     {
         FutureTask<Object> futureTask = new FutureTask<Object>( new RunnableTestClass1() );
-        new Thread( futureTask ).start();
+        DaemonThreadFactory.newDaemonThread( futureTask ).start();
         try
         {
             futureTask.get();

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
index 1bd27cb..c4765e9 100644
--- a/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
+++ b/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
@@ -23,6 +23,7 @@ import java.util.concurrent.CountDownLatch;
 import org.apache.maven.surefire.junit4.MockReporter;
 
 import junit.framework.Assert;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 import org.junit.Test;
 import org.junit.runner.Description;
 import org.junit.runner.Request;
@@ -59,7 +60,7 @@ public class JUnit4RunListenerTest
 
         jUnit4TestSetReporter.testStarted( testSomething );
 
-        new Thread( new Runnable()
+        DaemonThreadFactory.newDaemonThread( new Runnable()
         {
             public void run()
             {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java
index d664edc..0c1898b 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java
@@ -25,7 +25,9 @@ import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 import org.junit.runner.Computer;
 import org.junit.runner.Runner;
 import org.junit.runners.ParentRunner;
@@ -44,6 +46,8 @@ import org.junit.runners.model.RunnerScheduler;
 public class ConfigurableParallelComputer
     extends Computer
 {
+    private static final ThreadFactory DAEMON_THREAD_FACTORY = DaemonThreadFactory.newDaemonThreadFactory();
+
     private final boolean fClasses;
 
     private final boolean fMethods;
@@ -58,18 +62,21 @@ public class ConfigurableParallelComputer
 
     public ConfigurableParallelComputer()
     {
-        this( true, true, Executors.newCachedThreadPool(), false );
+        this( true, true, Executors.newCachedThreadPool( DAEMON_THREAD_FACTORY ), false );
     }
 
     public ConfigurableParallelComputer( boolean fClasses, boolean fMethods )
     {
-        this( fClasses, fMethods, Executors.newCachedThreadPool(), false );
+        this( fClasses, fMethods, Executors.newCachedThreadPool( DAEMON_THREAD_FACTORY ), false );
     }
 
     public ConfigurableParallelComputer( boolean fClasses, boolean fMethods, Integer numberOfThreads, boolean perCore )
     {
-        this( fClasses, fMethods, Executors.newFixedThreadPool(
-            numberOfThreads * ( perCore ? Runtime.getRuntime().availableProcessors() : 1 ) ), true );
+        this( fClasses, fMethods,
+              Executors.newFixedThreadPool(
+                  numberOfThreads * ( perCore ? Runtime.getRuntime().availableProcessors() : 1 ),
+                  DAEMON_THREAD_FACTORY ),
+              true );
     }
 
     private ConfigurableParallelComputer( boolean fClasses, boolean fMethods, ExecutorService executorService,

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java
index 5491a68..afec8a3 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java
@@ -20,6 +20,7 @@ package org.apache.maven.surefire.junitcore.pc;
  */
 
 import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 import org.junit.runner.Computer;
 import org.junit.runner.Description;
 
@@ -30,6 +31,7 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
 
 import static java.util.concurrent.TimeUnit.NANOSECONDS;
 
@@ -43,6 +45,8 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS;
 public abstract class ParallelComputer
     extends Computer
 {
+    private static final ThreadFactory DAEMON_THREAD_FACTORY = DaemonThreadFactory.newDaemonThreadFactory();
+
     private static final double NANOS_IN_A_SECOND = 1E9;
 
     private final ShutdownStatus shutdownStatus = new ShutdownStatus();
@@ -169,7 +173,7 @@ public abstract class ParallelComputer
     {
         if ( shutdownScheduler == null )
         {
-            shutdownScheduler = Executors.newScheduledThreadPool( 2 );
+            shutdownScheduler = Executors.newScheduledThreadPool( 2, DAEMON_THREAD_FACTORY );
         }
         return shutdownScheduler;
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
index 2ef3fd1..fdc4473 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
@@ -32,10 +32,12 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 
 import org.apache.maven.surefire.junitcore.JUnitCoreParameters;
 import org.apache.maven.surefire.report.ConsoleLogger;
 import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 import org.junit.internal.runners.ErrorReportingRunner;
 import org.junit.runner.Description;
 import org.junit.runner.Runner;
@@ -78,6 +80,8 @@ import static org.apache.maven.surefire.junitcore.pc.Type.SUITES;
  */
 public final class ParallelComputerBuilder
 {
+    private static final ThreadFactory DAEMON_THREAD_FACTORY = DaemonThreadFactory.newDaemonThreadFactory();
+
     private static final Class<? extends Annotation> JCIP_NOT_THREAD_SAFE = loadNotThreadSafeAnnotations();
 
     private static final Set<?> NULL_SINGLETON = Collections.singleton( null );
@@ -403,8 +407,8 @@ public final class ParallelComputerBuilder
         private ExecutorService createPool( int poolSize )
         {
             return poolSize < Integer.MAX_VALUE
-                ? Executors.newFixedThreadPool( poolSize )
-                : Executors.newCachedThreadPool();
+                ? Executors.newFixedThreadPool( poolSize, DAEMON_THREAD_FACTORY )
+                : Executors.newCachedThreadPool( DAEMON_THREAD_FACTORY );
         }
 
         private Scheduler createMaster( ExecutorService pool, int poolSize )
@@ -574,11 +578,11 @@ public final class ParallelComputerBuilder
                 ExecutorService pool = null;
                 if ( poolSize == Integer.MAX_VALUE )
                 {
-                    pool = Executors.newCachedThreadPool();
+                    pool = Executors.newCachedThreadPool( DAEMON_THREAD_FACTORY );
                 }
                 else if ( poolSize > 0 )
                 {
-                    pool = Executors.newFixedThreadPool( poolSize );
+                    pool = Executors.newFixedThreadPool( poolSize, DAEMON_THREAD_FACTORY );
                 }
                 boolean doParallel = pool != null;
                 for ( ParentRunner runner : runners )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java
index a7f45f8..6706951 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategies.java
@@ -20,9 +20,11 @@ package org.apache.maven.surefire.junitcore.pc;
  */
 
 import org.apache.maven.surefire.report.ConsoleLogger;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 
 /**
  * The factory of {@link SchedulingStrategy}.
@@ -32,6 +34,7 @@ import java.util.concurrent.Executors;
  */
 public class SchedulingStrategies
 {
+    private static final ThreadFactory DAEMON_THREAD_FACTORY = DaemonThreadFactory.newDaemonThreadFactory();
 
     /**
      * @param logger current error logger
@@ -49,7 +52,8 @@ public class SchedulingStrategies
      */
     public static SchedulingStrategy createParallelStrategy( ConsoleLogger logger, int nThreads )
     {
-        return new NonSharedThreadPoolStrategy( logger, Executors.newFixedThreadPool( nThreads ) );
+        return new NonSharedThreadPoolStrategy( logger,
+                                                Executors.newFixedThreadPool( nThreads, DAEMON_THREAD_FACTORY ) );
     }
 
     /**
@@ -58,7 +62,7 @@ public class SchedulingStrategies
      */
     public static SchedulingStrategy createParallelStrategyUnbounded( ConsoleLogger logger )
     {
-        return new NonSharedThreadPoolStrategy( logger, Executors.newCachedThreadPool() );
+        return new NonSharedThreadPoolStrategy( logger, Executors.newCachedThreadPool( DAEMON_THREAD_FACTORY ) );
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java
index c235a15..88ae625 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SingleThreadScheduler.java
@@ -20,6 +20,7 @@ package org.apache.maven.surefire.junitcore.pc;
  */
 
 import org.apache.maven.surefire.report.ConsoleLogger;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 import org.junit.runner.Description;
 import org.junit.runners.model.RunnerScheduler;
 
@@ -49,14 +50,8 @@ final class SingleThreadScheduler
 
     private static ExecutorService newPool()
     {
-        final ThreadFactory factory = new ThreadFactory()
-        {
-            public Thread newThread( Runnable r )
-            {
-                return new Thread( r, "maven-surefire-plugin@NotThreadSafe" );
-            }
-        };
-        return new ThreadPoolExecutor( 1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), factory );
+        ThreadFactory tf = DaemonThreadFactory.newDaemonThreadFactory( "maven-surefire-plugin@NotThreadSafe" );
+        return new ThreadPoolExecutor( 1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), tf );
     }
 
     SingleThreadScheduler( ConsoleLogger logger )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e53ab122/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java
index 10bb3bc..a47030c 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategiesTest.java
@@ -20,10 +20,12 @@ package org.apache.maven.surefire.junitcore.pc;
  */
 
 import org.apache.maven.surefire.junitcore.Logger;
+import org.apache.maven.surefire.util.internal.DaemonThreadFactory;
 import org.junit.Test;
 
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -44,6 +46,8 @@ import static org.junit.Assert.assertTrue;
  */
 public class SchedulingStrategiesTest
 {
+    private static final ThreadFactory DAEMON_THREAD_FACTORY = DaemonThreadFactory.newDaemonThreadFactory();
+
     @Test
     public void invokerStrategy()
         throws InterruptedException
@@ -97,7 +101,7 @@ public class SchedulingStrategiesTest
     public void sharedPoolStrategy()
         throws InterruptedException
     {
-        ExecutorService sharedPool = Executors.newCachedThreadPool();
+        ExecutorService sharedPool = Executors.newCachedThreadPool( DAEMON_THREAD_FACTORY );
 
         SchedulingStrategy strategy1 = SchedulingStrategies.createParallelSharedStrategy( new Logger(), sharedPool );
         assertTrue( strategy1.hasSharedThreadPool() );


[18/19] maven-surefire git commit: [SUREFIRE] refactoring with Java Generics

Posted by ti...@apache.org.
[SUREFIRE] refactoring with Java Generics


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

Branch: refs/heads/master
Commit: 7907adea3d3120b6a9473330f048a33b1ce8375b
Parents: 30199c9
Author: Tibor17 <ti...@lycos.com>
Authored: Sat Jul 18 00:34:05 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:17 2015 +0200

----------------------------------------------------------------------
 ...erDeserializerProviderConfigurationTest.java |  2 +-
 ...terDeserializerStartupConfigurationTest.java |  4 +--
 .../testset/DirectoryScannerParameters.java     | 20 ++++++-------
 .../surefire/util/DefaultDirectoryScanner.java  | 26 ++++++++---------
 .../util/DefaultRunOrderCalculator.java         |  3 +-
 .../maven/surefire/util/DefaultScanResult.java  |  4 ++-
 .../apache/maven/surefire/util/TestsToRun.java  | 26 +++++------------
 .../util/DefaultDirectoryScannerTest.java       |  4 +--
 .../surefire/util/RunOrderCalculatorTest.java   |  9 +++---
 .../maven/surefire/util/TestsToRunTest.java     | 30 +++++++++++++++-----
 .../surefire/booter/BooterDeserializer.java     | 10 +++----
 .../surefire/booter/SurefireReflectorTest.java  |  4 +--
 .../surefire/junitcore/Surefire746Test.java     |  2 +-
 13 files changed, 76 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
index 144b38c..113e2de 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
@@ -198,7 +198,7 @@ public class BooterDeserializerProviderConfigurationTest
         excludes.add( "xx1" );
         excludes.add( "xx2" );
 
-        return new DirectoryScannerParameters( aDir, includes, excludes, Collections.emptyList(), true,
+        return new DirectoryScannerParameters( aDir, includes, excludes, Collections.<String>emptyList(), true,
                                                RunOrder.asString( RunOrder.DEFAULT ) );
     }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
index 3b85274..89c1f3e 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
@@ -158,8 +158,8 @@ public class BooterDeserializerStartupConfigurationTest
         return new File( "TestSrc" );
     }
 
-    private Object[] getSuiteXmlFileStrings()
+    private String[] getSuiteXmlFileStrings()
     {
-        return new Object[]{ "A1", "A2" };
+        return new String[]{ "A1", "A2" };
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java b/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
index 42ce805..336ffa1 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
@@ -30,18 +30,18 @@ public class DirectoryScannerParameters
 {
     private final File testClassesDirectory;
 
-    private final List includes;
+    private final List<String> includes;
 
-    private final List excludes;
+    private final List<String> excludes;
 
-    private final List specificTests;
+    private final List<String> specificTests;
 
     private final boolean failIfNoTests;
 
     private final RunOrder[] runOrder;
 
-    private DirectoryScannerParameters( File testClassesDirectory, List includes, List excludes, List specificTests,
-                                        boolean failIfNoTests, RunOrder[] runOrder )
+    private DirectoryScannerParameters( File testClassesDirectory, List<String> includes, List<String> excludes,
+                                        List<String> specificTests, boolean failIfNoTests, RunOrder[] runOrder )
     {
         this.testClassesDirectory = testClassesDirectory;
         this.includes = includes;
@@ -51,14 +51,14 @@ public class DirectoryScannerParameters
         this.runOrder = runOrder;
     }
 
-    public DirectoryScannerParameters( File testClassesDirectory, List includes, List excludes, List specificTests,
-                                       boolean failIfNoTests, String runOrder )
+    public DirectoryScannerParameters( File testClassesDirectory, List<String> includes, List<String> excludes,
+                                       List<String> specificTests, boolean failIfNoTests, String runOrder )
     {
         this( testClassesDirectory, includes, excludes, specificTests, failIfNoTests,
               runOrder == null ? RunOrder.DEFAULT : RunOrder.valueOfMulti( runOrder ) );
     }
 
-    public List getSpecificTests()
+    public List<String> getSpecificTests()
     {
         return specificTests;
     }
@@ -78,7 +78,7 @@ public class DirectoryScannerParameters
      *
      * @return A list of patterns. May contain both source file designators and .class extensions.
      */
-    public List getIncludes()
+    public List<String> getIncludes()
     {
         return includes;
     }
@@ -88,7 +88,7 @@ public class DirectoryScannerParameters
      *
      * @return A list of patterns. May contain both source file designators and .class extensions.
      */
-    public List getExcludes()
+    public List<String> getExcludes()
     {
         return excludes;
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
index 81a6054..38dec8a 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
@@ -24,7 +24,9 @@ import org.apache.maven.surefire.SpecificTestClassFilter;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Set;
 
 /**
  * Scans directories looking for tests.
@@ -46,13 +48,14 @@ public class DefaultDirectoryScanner
 
     private final File basedir;
 
-    private final List includes;
+    private final List<String> includes;
 
-    private final List excludes;
+    private final List<String> excludes;
 
-    private final List specificTests;
+    private final List<String> specificTests;
 
-    public DefaultDirectoryScanner( File basedir, List includes, List excludes, List specificTests )
+    public DefaultDirectoryScanner( File basedir, List<String> includes, List<String> excludes,
+                                    List<String> specificTests )
     {
         this.basedir = basedir;
         this.includes = includes;
@@ -63,14 +66,14 @@ public class DefaultDirectoryScanner
     public TestsToRun locateTestClasses( ClassLoader classLoader, ScannerFilter scannerFilter )
     {
         String[] testClassNames = collectTests();
-        List<Class<?>> result = new ArrayList<Class<?>>();
+        Set<Class<?>> result = new LinkedHashSet<Class<?>>();
 
         String[] specific = specificTests == null ? new String[0] : processIncludesExcludes( specificTests );
         SpecificTestClassFilter specificTestFilter = new SpecificTestClassFilter( specific );
 
         for ( String className : testClassNames )
         {
-            Class testClass = loadClass( classLoader, className );
+            Class<?> testClass = loadClass( classLoader, className );
 
             if ( !specificTestFilter.accept( testClass ) )
             {
@@ -87,18 +90,16 @@ public class DefaultDirectoryScanner
         return new TestsToRun( result );
     }
 
-    private static Class loadClass( ClassLoader classLoader, String className )
+    private static Class<?> loadClass( ClassLoader classLoader, String className )
     {
-        Class testClass;
         try
         {
-            testClass = classLoader.loadClass( className );
+            return classLoader.loadClass( className );
         }
         catch ( ClassNotFoundException e )
         {
             throw new RuntimeException( "Unable to create test class '" + className + "'", e );
         }
-        return testClass;
     }
 
     String[] collectTests()
@@ -134,12 +135,11 @@ public class DefaultDirectoryScanner
         return tests;
     }
 
-    private static String[] processIncludesExcludes( List list )
+    private static String[] processIncludesExcludes( List<String> list )
     {
         List<String> newList = new ArrayList<String>();
-        for ( Object aList : list )
+        for ( String include : list )
         {
-            String include = (String) aList;
             String[] includes = include.split( "," );
             Collections.addAll( newList, includes );
         }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
index a67052e..7f8d9e1 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.LinkedHashSet;
 import java.util.List;
 
 /**
@@ -63,7 +64,7 @@ public class DefaultRunOrderCalculator
         }
 
         orderTestClasses( result, runOrder.length != 0 ? runOrder[0] : null );
-        return new TestsToRun( result );
+        return new TestsToRun( new LinkedHashSet<Class<?>>( result ) );
     }
 
     private void orderTestClasses( List<Class<?>> testClasses, RunOrder runOrder )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
index e8a16c1..ff75508 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
@@ -21,8 +21,10 @@ package org.apache.maven.surefire.util;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * @author Kristian Rosenvold
@@ -84,7 +86,7 @@ public class DefaultScanResult
 
     public TestsToRun applyFilter( ScannerFilter scannerFilter, ClassLoader testClassLoader )
     {
-        List<Class<?>> result = new ArrayList<Class<?>>();
+        Set<Class<?>> result = new LinkedHashSet<Class<?>>();
 
         int size = size();
         for ( int i = 0; i < size; i++ )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/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 1f88a5c..d7e4489 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
@@ -22,9 +22,7 @@ package org.apache.maven.surefire.util;
 import java.util.ArrayList;
 import java.util.Collection;
 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;
 
@@ -36,32 +34,22 @@ import org.apache.maven.surefire.testset.TestSetFailedException;
  */
 public class TestsToRun implements Iterable<Class<?>>
 {
-    private final List<Class<?>> locatedClasses;
+    private final Set<Class<?>> locatedClasses;
 
     /**
      * Constructor
      *
-     * @param locatedClasses A list of java.lang.Class objects representing tests to run
+     * @param locatedClasses A set of java.lang.Class objects representing tests to run
      */
-    public TestsToRun( List<Class<?>> locatedClasses )
+    public TestsToRun( Set<Class<?>> locatedClasses )
     {
-        this.locatedClasses = Collections.unmodifiableList( locatedClasses );
-        Set<Class<?>> testSets = new HashSet<Class<?>>();
-
-        for ( Class<?> testClass : locatedClasses )
-        {
-            if ( testSets.contains( testClass ) )
-            {
-                throw new RuntimeException( "Duplicate test set '" + testClass.getName() + "'" );
-            }
-            testSets.add( testClass );
-        }
+        this.locatedClasses = Collections.unmodifiableSet( locatedClasses );
     }
 
     public static TestsToRun fromClass( Class<?> clazz )
         throws TestSetFailedException
     {
-        return new TestsToRun( Collections.<Class<?>>singletonList( clazz ) );
+        return new TestsToRun( Collections.<Class<?>>singleton( clazz ) );
     }
 
     /**
@@ -92,7 +80,7 @@ public class TestsToRun implements Iterable<Class<?>>
         return containsAtLeast( iterator(), atLeast );
     }
 
-    private boolean containsAtLeast( Iterator it, int atLeast )
+    private boolean containsAtLeast( Iterator<Class<?>> it, int atLeast )
     {
         for ( int i = 0; i < atLeast; i++ )
         {
@@ -109,7 +97,7 @@ public class TestsToRun implements Iterable<Class<?>>
 
     public boolean containsExactly( int items )
     {
-        Iterator it = iterator();
+        Iterator<Class<?>> it = iterator();
         return containsAtLeast( it, items ) && !it.hasNext();
     }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java
index 1b4757b..4b24292 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/DefaultDirectoryScannerTest.java
@@ -41,10 +41,10 @@ public class DefaultDirectoryScannerTest
         File baseDir = new File( new File( "target" ).getCanonicalPath() );
         List<String> include = new ArrayList<String>();
         include.add( "**/*ZT*A.java" );
-        List exclude = new ArrayList();
+        List<String> exclude = new ArrayList<String>();
 
         DefaultDirectoryScanner surefireDirectoryScanner =
-            new DefaultDirectoryScanner( baseDir, include, exclude, new ArrayList() );
+            new DefaultDirectoryScanner( baseDir, include, exclude, new ArrayList<String>() );
 
         String[] classNames = surefireDirectoryScanner.collectTests();
         assertNotNull( classNames );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
index 965417c..30a7560 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
@@ -18,8 +18,9 @@ package org.apache.maven.surefire.util;
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
 import org.apache.maven.surefire.testset.RunOrderParameters;
 
 import junit.framework.TestCase;
@@ -42,9 +43,9 @@ public class RunOrderCalculatorTest
 
     }
 
-    private List<Class<?>> getClassesToRun()
+    private Set<Class<?>> getClassesToRun()
     {
-        List<Class<?>> classesToRun = new ArrayList<Class<?>>();
+        Set<Class<?>> classesToRun = new LinkedHashSet<Class<?>>();
         classesToRun.add( B.class );
         classesToRun.add( A.class );
         return classesToRun;

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/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 84854d8..ea3226a 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
@@ -19,8 +19,9 @@ package org.apache.maven.surefire.util;
  * under the License.
  */
 
-import java.util.Arrays;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
 
 import junit.framework.TestCase;
 
@@ -34,7 +35,10 @@ public class TestsToRunTest
     public void testGetTestSets()
         throws Exception
     {
-        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( T1.class, T2.class ) );
+        Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
+        classes.add( T1.class );
+        classes.add( T2.class );
+        TestsToRun testsToRun = new TestsToRun( classes );
         Iterator<Class<?>> it = testsToRun.iterator();
         assertTrue( it.hasNext() );
         assertEquals( it.next(), T1.class );
@@ -43,16 +47,22 @@ public class TestsToRunTest
         assertFalse( it.hasNext() );
     }
 
-    public void testContainsAtleast()
+    public void testContainsAtLeast()
     {
-        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( T1.class, T2.class ) );
+        Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
+        classes.add( T1.class );
+        classes.add( T2.class );
+        TestsToRun testsToRun = new TestsToRun( classes );
         assertTrue( testsToRun.containsAtLeast( 2 ) );
         assertFalse( testsToRun.containsAtLeast( 3 ) );
     }
 
     public void testContainsExactly()
     {
-        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( T1.class, T2.class ) );
+        Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
+        classes.add( T1.class );
+        classes.add( T2.class );
+        TestsToRun testsToRun = new TestsToRun( classes );
         assertFalse( testsToRun.containsExactly( 1 ) );
         assertTrue( testsToRun.containsExactly( 2 ) );
         assertFalse( testsToRun.containsExactly( 3 ) );
@@ -60,14 +70,20 @@ public class TestsToRunTest
 
     public void testToRunArray()
     {
-        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( T1.class, T2.class ) );
+        Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
+        classes.add( T1.class );
+        classes.add( T2.class );
+        TestsToRun testsToRun = new TestsToRun( classes );
         Class<?>[] locatedClasses = testsToRun.getLocatedClasses();
         assertEquals( 2, locatedClasses.length );
     }
 
     public void testGetClassByName()
     {
-        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( T1.class, T2.class ) );
+        Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
+        classes.add( T1.class );
+        classes.add( T2.class );
+        TestsToRun testsToRun = new TestsToRun( classes );
         assertEquals( T1.class, testsToRun.getClassByName( "org.apache.maven.surefire.util.TestsToRunTest$T1" ) );
         assertEquals( T2.class, testsToRun.getClassByName( "org.apache.maven.surefire.util.TestsToRunTest$T2" ) );
         assertEquals( null, testsToRun.getClassByName( "org.apache.maven.surefire.util.TestsToRunTest$T3" ) );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
index c5f7c03..5b89ed0 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
@@ -73,11 +73,11 @@ public class BooterDeserializer
         final String requestedTest = properties.getProperty( REQUESTEDTEST );
         final File sourceDirectory = properties.getFileProperty( SOURCE_DIRECTORY );
 
-        final List excludesList = properties.getStringList( EXCLUDES_PROPERTY_PREFIX );
-        final List includesList = properties.getStringList( INCLUDES_PROPERTY_PREFIX );
-        final List specificTestsList = properties.getStringList( SPECIFIC_TEST_PROPERTY_PREFIX );
+        final List<String> excludes = properties.getStringList( EXCLUDES_PROPERTY_PREFIX );
+        final List<String> includes = properties.getStringList( INCLUDES_PROPERTY_PREFIX );
+        final List<String> specificTests = properties.getStringList( SPECIFIC_TEST_PROPERTY_PREFIX );
 
-        final List testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES );
+        final List<String> testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES );
         final File testClassesDirectory = properties.getFileProperty( TEST_CLASSES_DIRECTORY );
         final String runOrder = properties.getProperty( RUN_ORDER );
         final String runStatisticsFile = properties.getProperty( RUN_STATISTICS_FILE );
@@ -85,7 +85,7 @@ public class BooterDeserializer
         final int rerunFailingTestsCount = properties.getIntProperty( RERUN_FAILING_TESTS_COUNT );
 
         DirectoryScannerParameters dirScannerParams =
-            new DirectoryScannerParameters( testClassesDirectory, includesList, excludesList, specificTestsList,
+            new DirectoryScannerParameters( testClassesDirectory, includes, excludes, specificTests,
                                             properties.getBooleanObjectProperty( FAILIFNOTESTS ), runOrder );
 
         RunOrderParameters runOrderParameters = new RunOrderParameters( runOrder, runStatisticsFile );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
index d41849d..dd2f271 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
@@ -48,8 +48,8 @@ public class SurefireReflectorTest
         Object foo = getFoo();
 
         DirectoryScannerParameters directoryScannerParameters =
-            new DirectoryScannerParameters( new File( "ABC" ), new ArrayList(), new ArrayList(), new ArrayList(),
-                                            false, "hourly" );
+            new DirectoryScannerParameters( new File( "ABC" ), new ArrayList<String>(), new ArrayList<String>(),
+                                            new ArrayList<String>(), false, "hourly" );
         surefireReflector.setDirectoryScannerParameters( foo, directoryScannerParameters );
         assertTrue( isCalled( foo ) );
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7907adea/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
index 93873bf..538b31a 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
@@ -98,7 +98,7 @@ public class Surefire746Test
         RunListener listener =
             ConcurrentRunListener.createInstance( testSetMap, reporterFactory, false, false, consoleLogger );
 
-        TestsToRun testsToRun = new TestsToRun( Collections.<Class<?>>singletonList( TestClassTest.class ) );
+        TestsToRun testsToRun = new TestsToRun( Collections.<Class<?>>singleton( TestClassTest.class ) );
 
         org.junit.runner.notification.RunListener jUnit4RunListener = new JUnitCoreRunListener( listener, testSetMap );
 


[11/19] maven-surefire git commit: [SUREFIRE] refactoring TestProvidingInputStream

Posted by ti...@apache.org.
[SUREFIRE] refactoring TestProvidingInputStream


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

Branch: refs/heads/master
Commit: d4b495f73c9aadf2e168eae1c64c95d3977e8b18
Parents: a83675e
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Jul 13 23:48:23 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jul 23 23:28:10 2015 +0200

----------------------------------------------------------------------
 .../lazytestprovider/TestProvidingInputStream.java           | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d4b495f7/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
index fd7d162..c82f554 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/lazytestprovider/TestProvidingInputStream.java
@@ -86,10 +86,13 @@ public class TestProvidingInputStream
     {
         if ( closed.get() )
         {
+            // help GC to free this object because StreamFeeder Thread cannot read it after IOE
+            currentBuffer = null;
             throw new EOFException( "closed unexpectedly" );
         }
         else
         {
+            // isolation of instance variable in Thread stack
             byte[] buffer = currentBuffer;
 
             if ( buffer == null )
@@ -107,6 +110,8 @@ public class TestProvidingInputStream
 
                 if ( closed.get() )
                 {
+                    // help GC to free this object because StreamFeeder Thread cannot read it after IOE
+                    currentBuffer = null;
                     throw new EOFException( "closed unexpectedly" );
                 }
 
@@ -114,6 +119,7 @@ public class TestProvidingInputStream
                 if ( currentElement != null )
                 {
                     buffer = encodeStringForForkCommunication( currentElement );
+                    // may override NULL from close(), therefore setting explicitly to NULL if IOE elsewhere
                     currentBuffer = buffer;
                     currentPos = 0;
                 }
@@ -144,6 +150,8 @@ public class TestProvidingInputStream
         }
         catch ( InterruptedException e )
         {
+            // help GC to free this object because StreamFeeder Thread cannot read it after IOE
+            currentBuffer = null;
             throw new IOException( e.getLocalizedMessage() );
         }
     }