maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r957320 [1/2] - in /maven/surefire/trunk: surefire-api/src/main/java/org/apache/maven/surefire/ surefire-api/src/main/java/org/apache/maven/surefire/report/ surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ surefire-in...
Date Wed, 23 Jun 2010 19:40:01 GMT
Author: krosenvold
Date: Wed Jun 23 19:39:59 2010
New Revision: 957320

URL: http://svn.apache.org/viewvc?rev=957320&view=rev
Log:
[SUREFIRE-621] JUnit4.7 provider test counting and reporting does not work with Junit 3 suite

Added:
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire621TestCountingJunit3InParallelIT.java
      - copied, changed from r954518, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest1.java   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest2.java   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest3.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentPrintStream.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListener.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java   (with props)
Removed:
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListener.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListenerTest.java
Modified:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/MulticastingReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/Reporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManager.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SystemStreamCapturer.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetStatistics.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/pom.xml
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test1.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test2.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java Wed Jun 23 19:39:59 2010
@@ -1,312 +1,265 @@
-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 org.apache.maven.surefire.report.Reporter;
-import org.apache.maven.surefire.report.ReporterException;
-import org.apache.maven.surefire.report.ReporterManager;
-import org.apache.maven.surefire.report.ReporterManagerFactory;
-import org.apache.maven.surefire.report.RunStatistics;
-import org.apache.maven.surefire.suite.SurefireTestSuite;
-import org.apache.maven.surefire.testset.TestSetFailedException;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.ResourceBundle;
-
-/**
- * @author Jason van Zyl
- * @version $Id$
- */
-public class Surefire
-{
-    
-    private static final int SUCCESS = 0;
-    private static final int NO_TESTS = 254;
-    private static final int FAILURE = 255;
-    
-    private ResourceBundle bundle = ResourceBundle.getBundle( SUREFIRE_BUNDLE_NAME );
-
-    public static final String SUREFIRE_BUNDLE_NAME = "org.apache.maven.surefire.surefire";
-
-    // DGF backwards compatibility
-    public boolean run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
-                    ClassLoader surefireClassLoader, ClassLoader testsClassLoader )
-        throws ReporterException, TestSetFailedException
-    {
-        return run( reportDefinitions, testSuiteDefinition, testSetName, surefireClassLoader, testsClassLoader, null,
-                    Boolean.FALSE ) == 0;
-    }
-    
-    public int run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
-                        ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Boolean failIfNoTests )
-        throws ReporterException, TestSetFailedException
-    {
-        return run( reportDefinitions, testSuiteDefinition, testSetName, surefireClassLoader, testsClassLoader, null,
-                    failIfNoTests );
-    }
-
-    // DGF backwards compatibility
-    public boolean run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
-                    ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Properties results )
-        throws ReporterException, TestSetFailedException
-    {
-        return run( reportDefinitions, testSuiteDefinition, testSetName, surefireClassLoader, testsClassLoader,
-                    results, Boolean.FALSE ) == 0;
-    }
-    
-    public int run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
-                    ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Properties results,
-                    Boolean failIfNoTests )
-        throws ReporterException, TestSetFailedException
-    {
-        ReporterManagerFactory reporterManagerFactory =
-            new ReporterManagerFactory( reportDefinitions, surefireClassLoader);
-
-        RunStatistics runStatistics = reporterManagerFactory.getGlobalRunStatistics();
-        if ( results != null )
-        {
-            runStatistics.initResultsFromProperties( results );
-        }
-
-        int totalTests = 0;
-
-        SurefireTestSuite suite = createSuiteFromDefinition( testSuiteDefinition, surefireClassLoader, testsClassLoader );
-
-        int testCount = suite.getNumTests();
-        if ( testCount > 0 )
-        {
-            totalTests += testCount;
-        }
-
-        if ( totalTests == 0 )
-        {
-            reporterManagerFactory.createReporterManager().writeMessage( "There are no tests to run." );
-        }
-        else
-        {
-            suite.execute( testSetName, reporterManagerFactory, testsClassLoader );
-        }
-
-        reporterManagerFactory.close();
-
-        if ( results != null )
-        {
-            runStatistics.updateResultsProperties( results );
-        }
-
-        if ( failIfNoTests.booleanValue() )
-        {
-            if ( runStatistics.getCompletedCount() == 0 )
-            {
-                return NO_TESTS;
-            }
-        }
-        
-
-        return runStatistics.isProblemFree() ? SUCCESS : FAILURE;
-
-    }
-
-    public boolean run( List reportDefinitions, List testSuiteDefinitions, ClassLoader surefireClassLoader,
-                        ClassLoader testsClassLoader )
-        throws ReporterException, TestSetFailedException
-    {
-        return run ( reportDefinitions, testSuiteDefinitions, surefireClassLoader, testsClassLoader, Boolean.FALSE )
-               == 0;
-    }
-    public int run( List reportDefinitions, List testSuiteDefinitions, ClassLoader surefireClassLoader,
-                        ClassLoader testsClassLoader, Boolean failIfNoTests )
-        throws ReporterException, TestSetFailedException
-    {
-        ReporterManagerFactory reporterManagerFactory =
-            new ReporterManagerFactory( reportDefinitions, surefireClassLoader);
-
-        RunStatistics runStatistics = reporterManagerFactory.getGlobalRunStatistics();
-
-        List suites = new ArrayList();
-
-        int totalTests = 0;
-        for ( Iterator i = testSuiteDefinitions.iterator(); i.hasNext(); )
-        {
-            Object[] definition = (Object[]) i.next();
-
-            SurefireTestSuite suite = createSuiteFromDefinition( definition, surefireClassLoader, testsClassLoader );
-
-            int testCount = suite.getNumTests();
-            if ( testCount > 0 )
-            {
-                suites.add( suite );
-                totalTests += testCount;
-            }
-        }
-
-        if ( totalTests == 0 )
-        {
-            reporterManagerFactory.createReporterManager().writeMessage( "There are no tests to run." );
-        }
-        else
-        {
-            for ( Iterator i = suites.iterator(); i.hasNext(); )
-            {
-                SurefireTestSuite suite = (SurefireTestSuite) i.next();
-                suite.execute( reporterManagerFactory, testsClassLoader );
-            }
-        }
-
-        reporterManagerFactory.close();
-        if ( failIfNoTests.booleanValue() )
-        {
-            if ( runStatistics.getCompletedCount() == 0 )
-            {
-                return NO_TESTS;
-            }
-        }
-
-        return runStatistics.isProblemFree() ? SUCCESS : FAILURE;
-    }
-
-    private SurefireTestSuite createSuiteFromDefinition( Object[] definition, ClassLoader surefireClassLoader,
-                                                         ClassLoader testsClassLoader )
-        throws TestSetFailedException
-    {
-        String suiteClass = (String) definition[0];
-        Object[] params = (Object[]) definition[1];
-
-        SurefireTestSuite suite = instantiateSuite( suiteClass, params, surefireClassLoader );
-
-        suite.locateTestSets( testsClassLoader );
-
-        return suite;
-    }
-
-    private List instantiateReports( List reportDefinitions, ClassLoader classLoader )
-        throws TestSetFailedException
-    {
-        List reports = new ArrayList();
-
-        for ( Iterator i = reportDefinitions.iterator(); i.hasNext(); )
-        {
-            Object[] definition = (Object[]) i.next();
-
-            String className = (String) definition[0];
-            Object[] params = (Object[]) definition[1];
-
-            Reporter report = instantiateReport( className, params, classLoader );
-
-            reports.add( report );
-        }
-
-        return reports;
-    }
-
-    private static Reporter instantiateReport( String className, Object[] params, ClassLoader classLoader )
-        throws TestSetFailedException
-    {
-        try
-        {
-            return (Reporter) instantiateObject( className, params, classLoader );
-        }
-        catch ( ClassNotFoundException e )
-        {
-            throw new TestSetFailedException( "Unable to find class to create report '" + className + "'", e );
-        }
-        catch ( NoSuchMethodException e )
-        {
-            throw new TestSetFailedException(
-                "Unable to find appropriate constructor to create report: " + e.getMessage(), e );
-        }
-    }
-
-    public static Object instantiateObject( String className, Object[] params, ClassLoader classLoader )
-        throws TestSetFailedException, ClassNotFoundException, NoSuchMethodException
-    {
-        Class clazz = classLoader.loadClass( className );
-
-        Object object;
-        try
-        {
-            if ( params != null )
-            {
-                Class[] paramTypes = new Class[params.length];
-
-                for ( int j = 0; j < params.length; j++ )
-                {
-                    if ( params[j] == null )
-                    {
-                        paramTypes[j] = String.class;
-                    }
-                    else
-                    {
-                        paramTypes[j] = params[j].getClass();
-                    }
-                }
-
-                Constructor constructor = clazz.getConstructor( paramTypes );
-
-                object = constructor.newInstance( params );
-            }
-            else
-            {
-                object = clazz.newInstance();
-            }
-        }
-        catch ( IllegalAccessException e )
-        {
-            throw new TestSetFailedException( "Unable to instantiate object: " + e.getMessage(), e );
-        }
-        catch ( InvocationTargetException e )
-        {
-            throw new TestSetFailedException( e.getTargetException().getMessage(), e.getTargetException() );
-        }
-        catch ( InstantiationException e )
-        {
-            throw new TestSetFailedException( "Unable to instantiate object: " + e.getMessage(), e );
-        }
-        return object;
-    }
-
-    private static SurefireTestSuite instantiateSuite( String suiteClass, Object[] params, ClassLoader classLoader )
-        throws TestSetFailedException
-    {
-        try
-        {
-            return (SurefireTestSuite) instantiateObject( suiteClass, params, classLoader );
-        }
-        catch ( ClassNotFoundException e )
-        {
-            throw new TestSetFailedException( "Unable to find class to create suite '" + suiteClass + "'", e );
-        }
-        catch ( NoSuchMethodException e )
-        {
-            throw new TestSetFailedException(
-                "Unable to find appropriate constructor to create suite: " + e.getMessage(), e );
-        }
-    }
-
-    public String getResourceString( String key )
-    {
-        return bundle.getString( key );
-    }
-}
+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 org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.report.RunStatistics;
+import org.apache.maven.surefire.suite.SurefireTestSuite;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @author Jason van Zyl
+ * @version $Id$
+ */
+public class Surefire
+{
+    
+    private static final int SUCCESS = 0;
+    private static final int NO_TESTS = 254;
+    private static final int FAILURE = 255;
+    
+    public static final String SUREFIRE_BUNDLE_NAME = "org.apache.maven.surefire.surefire";
+
+    // DGF backwards compatibility
+    public boolean run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
+                    ClassLoader surefireClassLoader, ClassLoader testsClassLoader )
+        throws ReporterException, TestSetFailedException
+    {
+        return run( reportDefinitions, testSuiteDefinition, testSetName, surefireClassLoader, testsClassLoader, null,
+                    Boolean.FALSE ) == 0;
+    }
+    
+    public int run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
+                        ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Boolean failIfNoTests )
+        throws ReporterException, TestSetFailedException
+    {
+        return run( reportDefinitions, testSuiteDefinition, testSetName, surefireClassLoader, testsClassLoader, null,
+                    failIfNoTests );
+    }
+
+    // DGF backwards compatibility
+    public boolean run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
+                    ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Properties results )
+        throws ReporterException, TestSetFailedException
+    {
+        return run( reportDefinitions, testSuiteDefinition, testSetName, surefireClassLoader, testsClassLoader,
+                    results, Boolean.FALSE ) == 0;
+    }
+    
+    public int run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
+                    ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Properties results,
+                    Boolean failIfNoTests )
+        throws ReporterException, TestSetFailedException
+    {
+        ReporterManagerFactory reporterManagerFactory =
+            new ReporterManagerFactory( reportDefinitions, surefireClassLoader);
+
+        RunStatistics runStatistics = reporterManagerFactory.getGlobalRunStatistics();
+        if ( results != null )
+        {
+            runStatistics.initResultsFromProperties( results );
+        }
+
+        int totalTests = 0;
+
+        SurefireTestSuite suite = createSuiteFromDefinition( testSuiteDefinition, surefireClassLoader, testsClassLoader );
+
+        int testCount = suite.getNumTests();
+        if ( testCount > 0 )
+        {
+            totalTests += testCount;
+        }
+
+        if ( totalTests == 0 )
+        {
+            reporterManagerFactory.createReporterManager().writeMessage( "There are no tests to run." );
+        }
+        else
+        {
+            suite.execute( testSetName, reporterManagerFactory, testsClassLoader );
+        }
+
+        reporterManagerFactory.close();
+
+        if ( results != null )
+        {
+            runStatistics.updateResultsProperties( results );
+        }
+
+        if ( failIfNoTests.booleanValue() )
+        {
+            if ( runStatistics.getCompletedCount() == 0 )
+            {
+                return NO_TESTS;
+            }
+        }
+        
+
+        return runStatistics.isProblemFree() ? SUCCESS : FAILURE;
+
+    }
+
+    public boolean run( List reportDefinitions, List testSuiteDefinitions, ClassLoader surefireClassLoader,
+                        ClassLoader testsClassLoader )
+        throws ReporterException, TestSetFailedException
+    {
+        return run ( reportDefinitions, testSuiteDefinitions, surefireClassLoader, testsClassLoader, Boolean.FALSE )
+               == 0;
+    }
+    public int run( List reportDefinitions, List testSuiteDefinitions, ClassLoader surefireClassLoader,
+                        ClassLoader testsClassLoader, Boolean failIfNoTests )
+        throws ReporterException, TestSetFailedException
+    {
+        ReporterManagerFactory reporterManagerFactory =
+            new ReporterManagerFactory( reportDefinitions, surefireClassLoader);
+
+        RunStatistics runStatistics = reporterManagerFactory.getGlobalRunStatistics();
+
+        List suites = new ArrayList();
+
+        int totalTests = 0;
+        for ( Iterator i = testSuiteDefinitions.iterator(); i.hasNext(); )
+        {
+            Object[] definition = (Object[]) i.next();
+
+            SurefireTestSuite suite = createSuiteFromDefinition( definition, surefireClassLoader, testsClassLoader );
+
+            int testCount = suite.getNumTests();
+            if ( testCount > 0 )
+            {
+                suites.add( suite );
+                totalTests += testCount;
+            }
+        }
+
+        if ( totalTests == 0 )
+        {
+            reporterManagerFactory.createReporterManager().writeMessage( "There are no tests to run." );
+        }
+        else
+        {
+            for ( Iterator i = suites.iterator(); i.hasNext(); )
+            {
+                SurefireTestSuite suite = (SurefireTestSuite) i.next();
+                suite.execute( reporterManagerFactory, testsClassLoader );
+            }
+        }
+
+        reporterManagerFactory.close();
+        if ( failIfNoTests.booleanValue() )
+        {
+            if ( runStatistics.getCompletedCount() == 0 )
+            {
+                return NO_TESTS;
+            }
+        }
+
+        return runStatistics.isProblemFree() ? SUCCESS : FAILURE;
+    }
+
+    private SurefireTestSuite createSuiteFromDefinition( Object[] definition, ClassLoader surefireClassLoader,
+                                                         ClassLoader testsClassLoader )
+        throws TestSetFailedException
+    {
+        String suiteClass = (String) definition[0];
+        Object[] params = (Object[]) definition[1];
+
+        SurefireTestSuite suite = instantiateSuite( suiteClass, params, surefireClassLoader );
+
+        suite.locateTestSets( testsClassLoader );
+
+        return suite;
+    }
+
+    public static Object instantiateObject( String className, Object[] params, ClassLoader classLoader )
+        throws TestSetFailedException, ClassNotFoundException, NoSuchMethodException
+    {
+        Class clazz = classLoader.loadClass( className );
+
+        Object object;
+        try
+        {
+            if ( params != null )
+            {
+                Class[] paramTypes = new Class[params.length];
+
+                for ( int j = 0; j < params.length; j++ )
+                {
+                    if ( params[j] == null )
+                    {
+                        paramTypes[j] = String.class;
+                    }
+                    else
+                    {
+                        paramTypes[j] = params[j].getClass();
+                    }
+                }
+
+                Constructor constructor = clazz.getConstructor( paramTypes );
+
+                object = constructor.newInstance( params );
+            }
+            else
+            {
+                object = clazz.newInstance();
+            }
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new TestSetFailedException( "Unable to instantiate object: " + e.getMessage(), e );
+        }
+        catch ( InvocationTargetException e )
+        {
+            throw new TestSetFailedException( e.getTargetException().getMessage(), e.getTargetException() );
+        }
+        catch ( InstantiationException e )
+        {
+            throw new TestSetFailedException( "Unable to instantiate object: " + e.getMessage(), e );
+        }
+        return object;
+    }
+
+    private static SurefireTestSuite instantiateSuite( String suiteClass, Object[] params, ClassLoader classLoader )
+        throws TestSetFailedException
+    {
+        try
+        {
+            return (SurefireTestSuite) instantiateObject( suiteClass, params, classLoader );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new TestSetFailedException( "Unable to find class to create suite '" + suiteClass + "'", e );
+        }
+        catch ( NoSuchMethodException e )
+        {
+            throw new TestSetFailedException(
+                "Unable to find appropriate constructor to create suite: " + e.getMessage(), e );
+        }
+    }
+
+}

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/MulticastingReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/MulticastingReporter.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/MulticastingReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/MulticastingReporter.java Wed Jun 23 19:39:59 2010
@@ -120,6 +120,17 @@ public class MulticastingReporter
         }
     }
 
+    public void writeConsoleMessage( String message )
+    {
+        for ( Iterator it = target.iterator(); it.hasNext(); )
+        {
+            Reporter reporter = ( (Reporter) it.next() );
+            // Todo: Really need to find out how the surefire4.x provider manages to avoid printing to this one.
+            if (!(reporter instanceof BriefFileReporter)){
+               reporter.writeMessage( message);
+            }
+        }
+    }
 
     public void writeMessage( String message )
     {

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/Reporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/Reporter.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/Reporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/Reporter.java Wed Jun 23 19:39:59 2010
@@ -43,21 +43,21 @@ public interface Reporter
     /**
      * Event fired when a test is about to start
      *
-     * @param report
+     * @param report The report entry to log for
      */
     void testStarting( ReportEntry report );
 
     /**
      * Event fired when a test ended successfully
      *
-     * @param report
+     * @param report The report entry to log for
      */
     void testSucceeded( ReportEntry report );
 
     /**
      * Event fired when a test ended with an error (non anticipated problem)
      *
-     * @param report
+     * @param report The report entry to log for
      * @param stdOut standard output from the test case
      * @param stdErr error output from the test case
      */
@@ -66,7 +66,7 @@ public interface Reporter
     /**
      * Event fired when a test ended with a failure (anticipated problem)
      *
-     * @param report
+     * @param report The report entry to log for
      * @param stdOut standard output from the test case
      * @param stdErr error output from the test case
      */

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManager.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManager.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManager.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManager.java Wed Jun 23 19:39:59 2010
@@ -52,22 +52,27 @@ import java.util.List;
  */
 public class ReporterManager
 {
-    private final RunStatistics runStatistics;
+    private final RunStatistics runStatisticsForThis;
 
     private final MulticastingReporter multicastingReporter;
 
     private final SystemStreamCapturer consoleCapturer = new SystemStreamCapturer();
 
-    public ReporterManager( List reports, RunStatistics runStatistics )
+    public ReporterManager( List reports, RunStatistics runStatisticsForThis )
     {
         multicastingReporter = new MulticastingReporter( reports );
-        this.runStatistics = runStatistics;
+        this.runStatisticsForThis = runStatisticsForThis;
     }
 
     public synchronized void writeMessage( String message )
     {
         multicastingReporter.writeMessage( message );
     }
+    
+    public synchronized void writeConsoleMessage( String message )
+    {
+        multicastingReporter.writeConsoleMessage( message );
+    }
 
     // ----------------------------------------------------------------------
     // Run
@@ -84,29 +89,30 @@ public class ReporterManager
         multicastingReporter.writeFooter( "" );
         multicastingReporter.writeFooter( "Results :" );
         multicastingReporter.writeFooter( "" );
-        if ( runStatistics.hadFailures() )
+        if ( runStatisticsForThis.hadFailures() )
         {
             multicastingReporter.writeFooter( "Failed tests: " );
-            for ( Iterator iterator = this.runStatistics.getFailureSources().iterator(); iterator.hasNext(); )
+            for ( Iterator iterator = this.runStatisticsForThis.getFailureSources().iterator(); iterator.hasNext(); )
             {
                 multicastingReporter.writeFooter( "  " + iterator.next() );
             }
             multicastingReporter.writeFooter( "" );
         }
-        if ( runStatistics.hadErrors() )
+        if ( runStatisticsForThis.hadErrors() )
         {
             writeFooter( "Tests in error: " );
-            for ( Iterator iterator = this.runStatistics.getErrorSources().iterator(); iterator.hasNext(); )
+            for ( Iterator iterator = this.runStatisticsForThis.getErrorSources().iterator(); iterator.hasNext(); )
             {
                 multicastingReporter.writeFooter( "  " + iterator.next() );
             }
             multicastingReporter.writeFooter( "" );
         }
-        multicastingReporter.writeFooter( runStatistics.getSummary() );
+        multicastingReporter.writeFooter( runStatisticsForThis.getSummary() );
         multicastingReporter.writeFooter( "" );
+        consoleCapturer.restoreStreams();
     }
 
-    private synchronized void writeFooter( String footer )
+    public synchronized void writeFooter( String footer )
     {
         multicastingReporter.writeFooter( footer );
     }
@@ -129,31 +135,43 @@ public class ReporterManager
 
     public synchronized void testStarting( ReportEntry report )
     {
-        consoleCapturer.startCapture();
         multicastingReporter.testStarting( report );
     }
 
     public synchronized void testSucceeded( ReportEntry report )
     {
-        consoleCapturer.resetStreams();
-        runStatistics.incrementCompletedCount();
+        consoleCapturer.clearCapturedContent();
+        runStatisticsForThis.incrementCompletedCount();
         multicastingReporter.testSucceeded( report );
     }
 
     public synchronized void testError( ReportEntry reportEntry )
     {
-        multicastingReporter.testError( reportEntry, consoleCapturer.getStdOutLog(), consoleCapturer.getStdErrLog() );
-        runStatistics.incrementErrorsCount();
-        runStatistics.addErrorSource( reportEntry.getName() );
-        consoleCapturer.resetStreams();
+        testError( reportEntry, consoleCapturer.getStdOutLog(), consoleCapturer.getStdErrLog() );
+    }
+
+    public synchronized void testError( ReportEntry reportEntry, String stdOutLog, String stdErrLog )
+    {
+        multicastingReporter.testError( reportEntry, stdOutLog, stdErrLog );
+        runStatisticsForThis.incrementErrorsCount();
+        runStatisticsForThis.incrementCompletedCount();
+        runStatisticsForThis.addErrorSource( reportEntry.getName() );
+        consoleCapturer.clearCapturedContent();
     }
 
     public synchronized void testFailed( ReportEntry reportEntry )
     {
-        multicastingReporter.testFailed( reportEntry, consoleCapturer.getStdOutLog(), consoleCapturer.getStdErrLog() );
-        runStatistics.incrementFailureCount();
-        runStatistics.addFailureSource( reportEntry.getName() );
-        consoleCapturer.resetStreams();
+        testFailed( reportEntry, consoleCapturer.getStdOutLog(), consoleCapturer.getStdErrLog() );
+    }
+
+
+    public synchronized void testFailed( ReportEntry reportEntry, String stdOutLog, String stdErrLog )
+    {
+        multicastingReporter.testFailed( reportEntry, stdOutLog, stdErrLog );
+        runStatisticsForThis.incrementFailureCount();
+        runStatisticsForThis.incrementCompletedCount();
+        runStatisticsForThis.addFailureSource( reportEntry.getName() );
+        consoleCapturer.clearCapturedContent();
     }
 
     // ----------------------------------------------------------------------
@@ -162,9 +180,9 @@ public class ReporterManager
 
     public synchronized void testSkipped( ReportEntry report )
     {
-        consoleCapturer.resetStreams();
-
-        runStatistics.incrementSkippedCount();
+        consoleCapturer.clearCapturedContent();
+        runStatisticsForThis.incrementSkippedCount();
+        runStatisticsForThis.incrementCompletedCount();
         multicastingReporter.testSkipped( report );
     }
 

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java Wed Jun 23 19:39:59 2010
@@ -69,6 +69,8 @@ public class ReporterManagerFactory
         throws TestSetFailedException
     {
         final List reports = instantiateReports( reportDefinitions, surefireClassLoader );
+        // Note, if we ever start making >1 reporter Managers, we have to aggregate run statistics
+        // i.e. we cannot use a single "globalRunStatistics"
         final ReporterManager reporterManager = new ReporterManager( reports, globalRunStatistics );
         if ( first == null )
         {
@@ -181,6 +183,4 @@ public class ReporterManagerFactory
         }
         return object;
     }
-
-
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SystemStreamCapturer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SystemStreamCapturer.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SystemStreamCapturer.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SystemStreamCapturer.java Wed Jun 23 19:39:59 2010
@@ -27,31 +27,31 @@ import java.io.PrintStream;
 
 /**
  * Captures System.out/System.err streams to buffers.
- *
+ * <p/>
  * Please note that this design is inherently single-threaded test-linear, and is intended only
  * for use with ReporterManager, which is also test-linear. While it will capture
  * output in a multi-threaded scenario, there's no way to associate ouput with the correct
  * test/thread.
- *
+ * <p/>
  * Note; this class does not need synchronization because all of these methods are serially invoked on
  * the same thread. Or maybe not. See notes inside ReporterManager about the general improperness
  * of this design in multithreading.
  */
 public class SystemStreamCapturer
 {
-    private PrintStream oldOut;
+    private final PrintStream oldOut;
 
-    private PrintStream oldErr;
+    private final PrintStream oldErr;
 
-    private PrintStream newErr;
+    private final PrintStream newErr;
 
-    private PrintStream newOut;
+    private final PrintStream newOut;
 
-    private ByteArrayOutputStream stdOut;
+    private final ByteArrayOutputStream stdOut;
 
-    private ByteArrayOutputStream stdErr;
+    private final ByteArrayOutputStream stdErr;
 
-    public void startCapture()
+    public SystemStreamCapturer()
     {
         stdOut = new ByteArrayOutputStream();
 
@@ -72,7 +72,8 @@ public class SystemStreamCapturer
         System.setErr( tee );
     }
 
-    public void resetStreams()
+
+    public void restoreStreams()
     {
         // Note that the fields can be null if the test hasn't even started yet (an early error)
         if ( oldOut != null )
@@ -88,6 +89,18 @@ public class SystemStreamCapturer
         IOUtil.close( newErr );
     }
 
+    public void clearCapturedContent()
+    {
+        if ( stdOut != null )
+        {
+            stdOut.reset();
+        }
+        if ( stdErr != null )
+        {
+            stdErr.reset();
+        }
+    }
+
     public String getStdOutLog()
     {
         // Note that the fields can be null if the test hasn't even started yet (an early error)

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetStatistics.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetStatistics.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetStatistics.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetStatistics.java Wed Jun 23 19:39:59 2010
@@ -22,7 +22,7 @@ package org.apache.maven.surefire.report
 import java.util.Properties;
 
 /**
- * Run-statistcis for a testset
+ * Run-statistics for a testset
  *
  * @author Kristian Rosenvold
  *         Note; synchronization is questionable. Whiled this class alone is ok, there's a higher level concern about
@@ -87,6 +87,11 @@ public class TestSetStatistics
         return completedCount;
     }
 
+    public int getSkipped()
+    {
+        return skipped;
+    }
+
     public synchronized void initResultsFromProperties( Properties results )
     {
         errors = Integer.valueOf( results.getProperty( RESULTS_ERRORS, "0" ) ).intValue();

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java Wed Jun 23 19:39:59 2010
@@ -45,6 +45,11 @@ public class Surefire613TestCountInParal
         this.executeGoal( verifier, "test" );
         verifier.resetStreams();
 
-        HelperAssertions.assertTestSuiteResults( 7, 1, 2, 1, testDir );
+        verifier.verifyTextInLog("testAllok to stdout");
+        verifier.verifyTextInLog("testAllok to stderr");
+        verifier.verifyTextInLog("testWithException1 to stdout");
+        verifier.verifyTextInLog("testWithException1 to stderr");
+
+        HelperAssertions.assertTestSuiteResults( 15, 8, 4, 2, testDir );
     }
 }
\ No newline at end of file

Copied: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire621TestCountingJunit3InParallelIT.java (from r954518, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire621TestCountingJunit3InParallelIT.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire621TestCountingJunit3InParallelIT.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java&r1=954518&r2=957320&rev=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire621TestCountingJunit3InParallelIT.java Wed Jun 23 19:39:59 2010
@@ -27,24 +27,24 @@ import java.util.ArrayList;
 import java.util.Arrays;
 
 /**
- * SUREFIRE-613 Asserts proper test counts when running in parallel
+ * SUREFIRE-621 Asserts proper test counts when running junit 3 tests in parallel
  *
  * @author Kristian Rosenvold
  */
-public class Surefire613TestCountInParallelIT
+public class Surefire621TestCountingJunit3InParallelIT
     extends AbstractSurefireIntegrationTestClass
 {
-    public void testPaallelBuildResultCount()
+    public void testJunit3ParallelBuildResultCount()
         throws Exception
     {
-        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/surefire-613-testCount-in-parallel" );
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/surefire-621-testCounting-junit3-in-parallel" );
 
         Verifier verifier = new Verifier( testDir.getAbsolutePath() );
         String[] opts = { "-fn" };
         verifier.setCliOptions( new ArrayList( Arrays.asList( opts ) ) );
-        this.executeGoal( verifier, "test" );
+        this.executeGoal( verifier, "install" );
         verifier.resetStreams();
 
-        HelperAssertions.assertTestSuiteResults( 7, 1, 2, 1, testDir );
+        HelperAssertions.assertTestSuiteResults( 6, 0, 0, 0, testDir );
     }
 }
\ No newline at end of file

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/pom.xml?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/pom.xml (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/pom.xml Wed Jun 23 19:39:59 2010
@@ -29,6 +29,7 @@
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${surefire.version}</version>
            <configuration>
+             <forkMode>once</forkMode>
              <parallel>methods</parallel>
              <threadCount>10</threadCount>
              <includes>

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test1.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test1.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test1.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test1.java Wed Jun 23 19:39:59 2010
@@ -4,29 +4,68 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assume.*;
 public class Test1
 {
     @Test
-    public void test2_1()
-        throws InterruptedException
-    {
-        Thread.currentThread().sleep( 1200 );
+    public void testWithFailingAssumption1() {
+        assumeThat( 2, is(3));
     }
-
     @Test
-    public void test2_2()
-        throws InterruptedException
-    {
-        Thread.currentThread().sleep( 1200 );
-        assertTrue(false);
-        fail( "We expect failure" );
+    public void testWithFailingAssumption2() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption3() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption4() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption5() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption6() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption7() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption8() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption9() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption10() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption11() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption12() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption13() {
+        assumeThat( 2, is(3));
+    }
+    @Test
+    public void testWithFailingAssumption14() {
+        assumeThat( 2, is(3));
     }
-
     @Test
-    public void test2_3()
-        throws InterruptedException
-    {
-        Thread.currentThread().sleep( 1200 );
+    public void testWithFailingAssumption15() {
+        assumeThat( 2, is(3));
     }
 }
\ No newline at end of file

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test2.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test2.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test2.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-613-testCount-in-parallel/src/test/java/surefire163/Test2.java Wed Jun 23 19:39:59 2010
@@ -12,25 +12,73 @@ import static junit.framework.Assert.fai
  */
 public class Test2
 {
+    @Test
+    public void testAllok(){
+        System.out.println("testAllok to stdout");
+        System.err.println("testAllok to stderr");
+    }
+
+
+    @Ignore
+    @Test
+    public void testWithIgnore1(){
+    }
+
     @Ignore
     @Test
-    public void testWithIgnore(){
+    public void testWithIgnore2(){
     }
 
     @Test
-    public void testiWithFail(){
+    public void testiWithFail1(){
+        fail("We excpect this");
+    }
+    @Test
+    public void testiWithFail2(){
+        fail("We excpect this");
+    }
+    @Test
+    public void testiWithFail3(){
+        fail("We excpect this");
+    }
+    @Test
+    public void testiWithFail4(){
         fail("We excpect this");
-
     }
 
     @Test
-    public void testWithException() {
+    public void testWithException1() {
+        System.out.println("testWithException1 to stdout");
+        System.err.println("testWithException1 to stderr");
         throw new RuntimeException("We expect this");
     }
-
     @Test
-    public void testWithFailingAssumption() {
-        assumeThat( 2, is(3));
+    public void testWithException2() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException3() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException4() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException5() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException6() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException7() {
+        throw new RuntimeException("We expect this");
+    }
+    @Test
+    public void testWithException8() {
+        throw new RuntimeException("We expect this");
     }
 
 }
\ No newline at end of file

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml Wed Jun 23 19:39:59 2010
@@ -0,0 +1,66 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>mho</groupId>
+    <artifactId>surefire-test</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0-SNAPSHOT</version>
+    <name>junit-test</name>
+    <url>http://maven.apache.org</url>
+    <properties>
+      <junit.version>4.8.1</junit.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <testSourceDirectory>src/it/java</testSourceDirectory>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.version}</version>
+                <configuration>
+                    <skip>true</skip>
+                    <parallel>classes</parallel>
+                    <threadCount>10</threadCount>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>surefire-it</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <skip>false</skip>
+
+                            <testFailureIgnore>true</testFailureIgnore>
+                            <includes>
+                                <include>**/MySuiteTest1.java</include>
+                                <include>**/MySuiteTest2.java</include>
+                                <include>**/MySuiteTest3.java</include>
+                            </includes>
+                            <excludes>
+                            </excludes>
+                            <forkMode>once</forkMode>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest1.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest1.java?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest1.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest1.java Wed Jun 23 19:39:59 2010
@@ -0,0 +1,35 @@
+package mho;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yyit927b
+ * Date: 26.05.2010
+ * Time: 11:02:06
+ * To change this template use File | Settings | File Templates.
+ */
+public class MySuiteTest1 extends TestCase {
+
+    public static Test suite () {
+        TestSuite suite = new TestSuite();
+
+        suite.addTest (new MySuiteTest1("testMe", 1));
+
+        return suite;
+    }
+
+    private int number;
+
+    public MySuiteTest1(String name, int number) {
+        super (name);
+        this.number = number;
+    }
+
+    public void testMe() {
+        System.out.println ("### "+ this.getClass().getName()+":"+this.getName()+" - number "+number);
+        assertTrue (true);
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest1.java
------------------------------------------------------------------------------
    svn:executable = *

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest2.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest2.java?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest2.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest2.java Wed Jun 23 19:39:59 2010
@@ -0,0 +1,36 @@
+package mho;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yyit927b
+ * Date: 26.05.2010
+ * Time: 11:02:06
+ * To change this template use File | Settings | File Templates.
+ */
+public class MySuiteTest2 extends TestCase {
+
+    public static Test suite () {
+        TestSuite suite = new TestSuite();
+
+        suite.addTest (new MySuiteTest2("testMe", 1));
+        suite.addTest (new MySuiteTest2("testMe", 2));
+
+        return suite;
+    }
+
+    private int number;
+
+    public MySuiteTest2(String name, int number) {
+        super (name);
+        this.number = number;
+    }
+
+    public void testMe() {
+        System.out.println ("### "+ this.getClass().getName()+":"+this.getName()+" - number "+number);
+        assertTrue (true);
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest2.java
------------------------------------------------------------------------------
    svn:executable = *

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest3.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest3.java?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest3.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest3.java Wed Jun 23 19:39:59 2010
@@ -0,0 +1,37 @@
+package mho;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yyit927b
+ * Date: 26.05.2010
+ * Time: 11:27:42
+ * To change this template use File | Settings | File Templates.
+ */
+public class MySuiteTest3 extends TestCase {
+
+    public static Test suite () {
+        TestSuite suite = new TestSuite();
+
+        suite.addTest (new MySuiteTest3("testMe", 1));
+        suite.addTest (new MySuiteTest3("testMe", 2));
+        suite.addTest (new MySuiteTest3("testMe", 3));
+
+        return suite;
+    }
+
+    private int number;
+
+    public MySuiteTest3(String name, int number) {
+        super (name);
+        this.number = number;
+    }
+
+    public void testMe() {
+        System.out.println ("### "+ this.getClass().getName()+":"+this.getName()+" - number "+number);
+        assertTrue (true);
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest3.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-621-testCounting-junit3-in-parallel/src/it/java/mho/MySuiteTest3.java
------------------------------------------------------------------------------
    svn:executable = *

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentPrintStream.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentPrintStream.java?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentPrintStream.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentPrintStream.java Wed Jun 23 19:39:59 2010
@@ -0,0 +1,60 @@
+package org.apache.maven.surefire.junitcore;
+/*
+ * 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.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+class ConcurrentPrintStream
+    extends PrintStream
+{
+    private final boolean isStdout;
+
+    ConcurrentPrintStream( boolean stdout )
+    {
+        super( new ByteArrayOutputStream() );
+        isStdout = stdout;
+    }
+
+
+    public void write( byte[] buf, int off, int len )
+    {
+
+        final TestMethod threadTestMethod = TestMethod.getThreadTestMethod();
+        if ( threadTestMethod != null )
+        {
+            threadTestMethod.getLogicalStream().write( isStdout, buf, off, len );
+        }
+        else
+        {
+           ( (ByteArrayOutputStream) out ).write( buf, off, len );
+        }
+    }
+
+    public void close()
+    {
+
+    }
+
+    public void flush()
+    {
+    }
+
+
+}

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentPrintStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListener.java?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListener.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListener.java Wed Jun 23 19:39:59 2010
@@ -0,0 +1,198 @@
+package org.apache.maven.surefire.junitcore;
+/*
+ * 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.report.ReporterManager;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunListener;
+
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public abstract class ConcurrentReportingRunListener
+    extends RunListener
+{
+    private final PrintStream orgSystemOut = System.out;
+
+    private final PrintStream orgSystemErr = System.err;
+
+    protected Map<Class, TestSet> classMethodCounts = new ConcurrentHashMap<Class, TestSet>();
+
+    protected final ReporterManager reporterManager;
+
+    protected final boolean reportImmediately;
+
+    public ConcurrentReportingRunListener( ReporterManagerFactory reporterFactory, boolean reportImmediately )
+        throws TestSetFailedException
+    {
+        this.reportImmediately = reportImmediately;
+        reporterManager = reporterFactory.createReporterManager();
+        // Important: We must capture System.out/System.err AFTER the  reportManager captures stdout/stderr
+        // because we know how to demultiplex correctly. The redirection in reporterManager is basically
+        // ignored/unused because we use ConcurrentPrintStream.
+        System.setOut( new ConcurrentPrintStream( true ) );
+        System.setErr( new ConcurrentPrintStream( false ) );
+    }
+
+    @Override
+    public void testRunStarted( Description description )
+        throws Exception
+    {
+        TestMethod.fillTestCountMap( description, classMethodCounts );
+    }
+
+    @Override
+    public void testRunFinished( Result result )
+        throws Exception
+    {
+        for ( TestSet testSet : classMethodCounts.values() )
+        {
+            testSet.replay( reporterManager );
+        }
+        System.setOut( orgSystemOut );
+        System.setErr( orgSystemErr );
+    }
+
+    protected TestMethod getTestMethod()
+    {
+        return TestMethod.getThreadTestMethod();
+    }
+
+    protected void detachTestMethodFromThread()
+    {
+        TestMethod.detachFromCurrentThread();
+    }
+
+    protected TestSet getTestSet( Description description )
+    {
+        return classMethodCounts.get( description.getTestClass() );
+    }
+
+    @Override
+    public void testFailure( Failure failure )
+        throws Exception
+    {
+        TestMethod.getThreadTestMethod().testFailure( failure );
+    }
+
+    @Override
+    public void testAssumptionFailure( Failure failure )
+    {
+        TestMethod.getThreadTestMethod().testAssumptionFailure( failure );
+    }
+
+    @Override
+    public void testIgnored( Description description )
+        throws Exception
+    {
+        TestSet testSet = getTestSet( description );
+        testSet.createTestMethod( description ).testIgnored( description );
+        testSet.incrementFinishedTests( reporterManager, reportImmediately );
+    }
+
+    @Override
+    public void testStarted( Description description )
+        throws Exception
+    {
+        TestSet testSet = getTestSet( description );
+        testSet.createTestMethod( description ).attachToThread();
+        checkIfTestSetCanBeReported( testSet );
+        testSet.attachToThread();
+    }
+
+    public abstract void checkIfTestSetCanBeReported( TestSet testSetForTest );
+
+    @Override
+    public void testFinished( Description description )
+        throws Exception
+    {
+        getTestMethod().testFinished();
+        TestSet.getThreadTestSet().incrementFinishedTests( reporterManager, reportImmediately );
+        detachTestMethodFromThread();
+    }
+
+    public static ConcurrentReportingRunListener createInstance( ReporterManagerFactory reporterManagerFactory,
+                                                                 boolean parallelClasses, boolean parallelBoth )
+        throws TestSetFailedException
+    {
+        if ( parallelClasses )
+        {
+            return new ClassesParallelRunListener( reporterManagerFactory );
+        }
+        return new MethodsParallelRunListener( reporterManagerFactory, !parallelBoth );
+    }
+
+    public static class ClassesParallelRunListener
+        extends ConcurrentReportingRunListener
+    {
+        public ClassesParallelRunListener( ReporterManagerFactory reporterFactory )
+            throws TestSetFailedException
+        {
+            super( reporterFactory, false );
+        }
+
+        @Override
+        public void checkIfTestSetCanBeReported( TestSet testSetForTest )
+        {
+            TestSet currentlyAttached = TestSet.getThreadTestSet();
+            if ( currentlyAttached != null && currentlyAttached != testSetForTest )
+            {
+                currentlyAttached.setAllScheduled( reporterManager );
+            }
+        }
+    }
+
+    public static class MethodsParallelRunListener
+        extends ConcurrentReportingRunListener
+    {
+        private volatile TestSet lastStarted;
+
+        private final Object lock = new Object();
+
+        public MethodsParallelRunListener( ReporterManagerFactory reporterFactory, boolean reportImmediately )
+            throws TestSetFailedException
+        {
+            super( reporterFactory, reportImmediately );
+        }
+
+        @Override
+        public void checkIfTestSetCanBeReported( TestSet testSetForTest )
+        {
+            synchronized ( lock )
+            {
+                if ( testSetForTest != lastStarted )
+                {
+                    if ( lastStarted != null )
+                    {
+                        lastStarted.setAllScheduled( reporterManager );
+                    }
+                    lastStarted = testSetForTest;
+                }
+            }
+        }
+    }
+}

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java Wed Jun 23 19:39:59 2010
@@ -20,7 +20,6 @@
 package org.apache.maven.surefire.junitcore;
 
 import org.apache.maven.surefire.report.ReporterException;
-import org.apache.maven.surefire.report.ReporterManager;
 import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.suite.SurefireTestSuite;
 import org.apache.maven.surefire.testset.TestSetFailedException;
@@ -37,6 +36,7 @@ import java.util.Properties;
  * @author Karl M. Davis
  * @author Kristian Rosenvold (junit core adaption)
  */
+@SuppressWarnings( { "UnusedDeclaration" } )
 public class JUnitCoreDirectoryTestSuite
     implements SurefireTestSuite
 {
@@ -64,8 +64,7 @@ public class JUnitCoreDirectoryTestSuite
             throw new IllegalStateException( "You must call locateTestSets before calling execute" );
         }
 
-        final ReporterManager reporterManager = reporterManagerFactory.createReporterManager();
-        JUnitCoreTestSet.execute( testsToRun.getLocatedClasses(), reporterManager, jUnitCoreParameters );
+        JUnitCoreTestSet.execute( testsToRun.getLocatedClasses(), reporterManagerFactory, jUnitCoreParameters );
     }
 
     public void execute( String testSetName, ReporterManagerFactory reporterManagerFactory, ClassLoader classLoader )
@@ -82,7 +81,7 @@ public class JUnitCoreDirectoryTestSuite
         {
             throw new TestSetFailedException( "Unable to find test set '" + testSetName + "' in suite" );
         }
-        testSet.execute( reporterManagerFactory.createReporterManager(), jUnitCoreParameters );
+        testSet.execute( reporterManagerFactory, jUnitCoreParameters );
     }
 
     public Map locateTestSets( ClassLoader classLoader )

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java Wed Jun 23 19:39:59 2010
@@ -19,7 +19,7 @@
 package org.apache.maven.surefire.junitcore;
 
 
-import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.junit.experimental.ParallelComputer;
 import org.junit.runner.Computer;
@@ -45,8 +45,6 @@ class JUnitCoreTestSet
 
     private static final String className = "org.jdogma.junit.ConfigurableParallelComputer";
 
-    private static final String demuxerClassName = "org.jdogma.junit.DemultiplexingRunListener";
-
     public String getName()
     {
         return testClass.getName();
@@ -70,12 +68,12 @@ class JUnitCoreTestSet
     /**
      * Actually runs the test and adds the tests results to the <code>reportManager</code>.
      *
-     * @param JUnitCoreParameters The parameters for this test
      * @param reportManager       The report manager
+     * @param JUnitCoreParameters The parameters for this test
      * @throws TestSetFailedException If something fails
      * @see org.apache.maven.surefire.testset.SurefireTestSet#execute(org.apache.maven.surefire.report.ReporterManager,java.lang.ClassLoader)
      */
-    public void execute( ReporterManager reportManager, JUnitCoreParameters JUnitCoreParameters )
+    public void execute( ReporterManagerFactory reportManager, JUnitCoreParameters JUnitCoreParameters )
         throws TestSetFailedException
     {
 
@@ -84,13 +82,13 @@ class JUnitCoreTestSet
         execute( classes, reportManager, JUnitCoreParameters );
     }
 
-    public static void execute( Class[] classes, ReporterManager reportManager,
+    public static void execute( Class[] classes, ReporterManagerFactory reporterManagerFactory,
                                 JUnitCoreParameters jUnitCoreParameters )
         throws TestSetFailedException
     {
-        RunListener realTarget = new JUnitCoreTestSetReporter( reportManager );
-        RunListener listener =
-            createRunListener( realTarget, jUnitCoreParameters.isConfigurableParallelComputerPresent() );
+        final ConcurrentReportingRunListener listener =
+            ConcurrentReportingRunListener.createInstance( reporterManagerFactory, jUnitCoreParameters.isParallelClasses(),
+                                                      jUnitCoreParameters.isParallelBoth() );
         Computer computer = getComputer( jUnitCoreParameters );
         try
         {
@@ -99,42 +97,6 @@ class JUnitCoreTestSet
         finally
         {
             closeIfConfigurable( computer );
-            reportManager.reset();
-        }
-    }
-
-    private static RunListener createRunListener( RunListener realTarget, boolean configurableParallelComputerPresent )
-        throws TestSetFailedException
-    {
-        if ( !configurableParallelComputerPresent )
-        {
-            return new DemultiplexingRunListener( realTarget );
-        }
-        try
-        {
-            Class<?> cpcClass = Class.forName( demuxerClassName );
-            Constructor constructor = cpcClass.getConstructor( RunListener.class );
-            return (RunListener) constructor.newInstance( realTarget );
-        }
-        catch ( ClassNotFoundException e )
-        {
-            throw new TestSetFailedException( e );
-        }
-        catch ( NoSuchMethodException e )
-        {
-            throw new TestSetFailedException( e );
-        }
-        catch ( InvocationTargetException e )
-        {
-            throw new TestSetFailedException( e );
-        }
-        catch ( IllegalAccessException e )
-        {
-            throw new TestSetFailedException( e );
-        }
-        catch ( InstantiationException e )
-        {
-            throw new TestSetFailedException( e );
         }
     }
 

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java Wed Jun 23 19:39:59 2010
@@ -0,0 +1,105 @@
+package org.apache.maven.surefire.junitcore;
+/*
+ * 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.report.ReporterManager;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A stream-like object that preserves ordering between stdout/stderr
+ */
+public class LogicalStream
+{
+
+    private final List<Entry> output = new ArrayList<Entry>();
+
+    class Entry
+    {
+        final boolean stdout;
+
+        final String value;
+
+        Entry( boolean stdout, byte[] b, int off, int len )
+        {
+            this.stdout = stdout;
+            value = new String( b, off, len ).intern();
+        }
+
+        public boolean isStdout()
+        {
+            return stdout;
+        }
+
+        public void writeTo( StringBuilder stringBuilder )
+        {
+            stringBuilder.append( value );
+        }
+
+
+        public void writeToConsole( ReporterManager reporter )
+        {
+            reporter.writeConsoleMessage( value );
+        }
+
+        @Override
+        public String toString()
+        {
+            return value;
+        }
+
+        public boolean isBlankLine()
+        {
+            return "\n".equals( value );
+        }
+    }
+
+    public synchronized void write( boolean stdout, byte b[], int off, int len )
+    {
+        Entry entry = new Entry( stdout, b, off, len );
+        if ( !entry.isBlankLine() )
+        {
+            output.add( entry );
+        }
+    }
+
+
+    public void writeToConsole( ReporterManager reporter )
+    {
+        for ( Entry entry : output )
+        {
+            entry.writeToConsole( reporter );
+        }
+    }
+
+    public String getOutput( boolean stdOut )
+    {
+        StringBuilder stringBuilder = new StringBuilder();
+        for ( Entry entry : output )
+        {
+            if ( stdOut == entry.isStdout() )
+            {
+                entry.writeTo( stringBuilder );
+            }
+        }
+        return stringBuilder.toString();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message