maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From steph...@apache.org
Subject svn commit: r895651 [1/2] - in /maven/surefire/trunk: maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/ surefire-api/src/main/java/org/apache/maven/surefire/suite/ surefire-api/src/main/java/org/apache/maven/surefire/util/ surefire-...
Date Mon, 04 Jan 2010 14:55:58 GMT
Author: stephenc
Date: Mon Jan  4 14:55:57 2010
New Revision: 895651

URL: http://svn.apache.org/viewvc?rev=895651&view=rev
Log:
[SUREFIRE-555] Add support for parallel execution of tests using JUnit 4.7 or newer
Submitted by: Kristian Rosenvold

o Some of the testdata Java source files in the patch were missing the ASL licensing headers.  I have added the headers per email discussion with Kristian (see http://mail-archives.apache.org/mod_mbox/maven-dev/201001.mbox/%3C1471388876825235259@unknownmsgid%3E for confirmation)

o There are probably additional checkstyle reformattings that could be applied to this patch, but I'd prefer to fix the formatting in one single committ rather than scatter formatting changes with other non-formatting changes

Added:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java   (with props)
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java   (with props)
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT1A.java   (with props)
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT2A.java   (with props)
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT3A.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/pom.xml   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListener.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreStackTraceWriter.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListenerTest.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestsToRunTest.java   (with props)
Modified:
    maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
    maven/surefire/trunk/surefire-integration-tests/pom.xml
    maven/surefire/trunk/surefire-providers/pom.xml

Modified: maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=895651&r1=895650&r2=895651&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java (original)
+++ maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java Mon Jan  4 14:55:57 2010
@@ -41,6 +41,7 @@
 import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
 import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
@@ -424,10 +425,28 @@
     private int threadCount;
 
     /**
+     * (junitcore only) Indicates that threadCount is per cpu core. Defaults to true
+     *
+     * @parameter expression="${perCoreThreadCount}"
+     * @since 2.5
+     */
+    private String perCoreThreadCount;
+
+    /**
+     * (junitcore only) Indicates that the thread pool will be unlimited. paralell setting and the actual number of classes/methods
+     * will decide. Setting this to true effectively disables perCoreThreadCount and  threadCount
+     *
+     * @parameter expression="${useUnlimitedThreads}"
+     * @since 2.5
+     */
+    private String useUnlimitedThreads;
+    /**
      * (TestNG only) When you use the parallel attribute, TestNG will try to run all your test methods in separate threads, except for
      * methods that depend on each other, which will be run in the same thread in order to respect their order of
      * execution.
      *
+     * JUNIT4.6 Values are classes/methods/both to run in separate threads, as controlled by threadCount.
+     *
      * @parameter expression="${parallel}"
      * @todo test how this works with forking, and console/file output parallelism
      * @since 2.2
@@ -662,6 +681,58 @@
         }
     }
 
+    /**
+     * Converts old TestNG configuration parameters over to new properties based configuration
+     * method. (if any are defined the old way)
+     */
+    private void convertJunitCoreParameters()
+    {
+        if ( properties == null )
+        {
+            properties = new Properties();
+        }
+
+        if ( this.parallel != null )
+        {
+            properties.setProperty( "parallel", this.parallel );
+        }
+        if ( this.threadCount > 0 )
+        {
+            properties.setProperty( "threadCount", new Integer( this.threadCount ).toString() );
+        }
+        if ( this.perCoreThreadCount != null )
+        {
+            properties.setProperty( "perCoreThreadCount", perCoreThreadCount);
+        }
+        if ( this.useUnlimitedThreads != null )
+        {
+            properties.setProperty( "useUnlimitedThreads", useUnlimitedThreads);
+        }
+        Artifact configurableParallelComputer = (Artifact) projectArtifactMap.get("org.jdogma.junit:configurable-parallel-computer");
+        properties.setProperty("configurableParallelComputerPresent", Boolean.toString(configurableParallelComputer != null));
+
+    }
+
+    private boolean isJunit47Compatible(Artifact artifact) throws MojoExecutionException {
+        return isWithinVersionSpec(artifact, "[4.7,)");
+    }
+    
+    private boolean isJunit40to46(Artifact artifact)  throws MojoExecutionException {
+        return isWithinVersionSpec(artifact, "[4.0,4.7)");
+    }
+
+    private boolean isWithinVersionSpec(Artifact artifact, String versionSpec) throws MojoExecutionException {
+        try {
+            VersionRange  range = VersionRange.createFromVersionSpec( versionSpec);
+            return range.containsVersion( artifact.getSelectedVersion());
+        } catch (InvalidVersionSpecificationException e) {
+            throw new MojoExecutionException("Bug in junit 4.7 plugin. Please report with stacktrace");
+        } catch (OverConstrainedVersionException e) {
+            throw new MojoExecutionException("Bug in junit 4.7 plugin. Please report with stacktrace");
+        }
+    }
+
+
     private SurefireBooter constructSurefireBooter()
         throws MojoExecutionException, MojoFailureException
     {
@@ -714,7 +785,12 @@
                 // different one since its based on the source level, not the JVM. Prune using the filter.
                 addProvider( surefireBooter, "surefire-testng", surefireArtifact.getBaseVersion(), testNgArtifact );
             }
-            else if ( junitArtifact != null && junitArtifact.getBaseVersion().startsWith( "4" ) )
+            else if ( isJunit47Compatible( junitArtifact))
+            {
+                convertJunitCoreParameters();                
+                addProvider( surefireBooter, "surefire-junit47", surefireArtifact.getBaseVersion(), null );
+            }
+            else if ( isJunit40to46( junitArtifact ))
             {
                 addProvider( surefireBooter, "surefire-junit4", surefireArtifact.getBaseVersion(), null );
             }
@@ -806,29 +882,29 @@
                 }
             }
 
-            if ( testNgArtifact != null )
-            {
-                surefireBooter.addTestSuite( "org.apache.maven.surefire.testng.TestNGDirectoryTestSuite", new Object[] {
-                    testClassesDirectory, includes, excludes, testSourceDirectory.getAbsolutePath(),
-                    testNgArtifact.getVersion(), testNgArtifact.getClassifier(), properties, reportsDirectory} );
-            }
-            else
-            {
+            if (testNgArtifact != null) {
+                surefireBooter.addTestSuite("org.apache.maven.surefire.testng.TestNGDirectoryTestSuite", new Object[]{
+                        testClassesDirectory, includes, excludes, testSourceDirectory.getAbsolutePath(),
+                        testNgArtifact.getVersion(), testNgArtifact.getClassifier(), properties, reportsDirectory});
+            } else {
                 String junitDirectoryTestSuite;
-                if ( junitArtifact != null && junitArtifact.getBaseVersion() != null &&
-                    junitArtifact.getBaseVersion().startsWith( "4" ) )
-                {
-                    junitDirectoryTestSuite = "org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite";
-                }
-                else
+                if (isJunit47Compatible(junitArtifact))
                 {
-                    junitDirectoryTestSuite = "org.apache.maven.surefire.junit.JUnitDirectoryTestSuite";
+                    junitDirectoryTestSuite = "org.apache.maven.surefire.junitcore.JUnitCoreDirectoryTestSuite";
+                    getLog().warn( "Props are" + properties.toString());
+                    surefireBooter.addTestSuite(junitDirectoryTestSuite, new Object[]{testClassesDirectory, includes, excludes, properties});
+                } else {
+                    if (isJunit40to46(junitArtifact))
+                    {
+                        junitDirectoryTestSuite = "org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite";
+                    } else {
+                        // fall back to JUnit, which also contains POJO support. Also it can run
+                        // classes compiled against JUnit since it has a dependency on JUnit itself.
+                        junitDirectoryTestSuite = "org.apache.maven.surefire.junit.JUnitDirectoryTestSuite";
+                    }
+                    surefireBooter.addTestSuite(junitDirectoryTestSuite, new Object[]{testClassesDirectory, includes, excludes});
                 }
 
-                // fall back to JUnit, which also contains POJO support. Also it can run
-                // classes compiled against JUnit since it has a dependency on JUnit itself.
-                surefireBooter.addTestSuite( junitDirectoryTestSuite, new Object[] { testClassesDirectory, includes,
-                    excludes } );
             }
         }
 

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java?rev=895651&r1=895650&r2=895651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java Mon Jan  4 14:55:57 2010
@@ -20,17 +20,14 @@
  */
 
 import org.apache.maven.surefire.Surefire;
+import org.apache.maven.surefire.util.SurefireDirectoryScanner;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManager;
 import org.apache.maven.surefire.testset.SurefireTestSet;
 import org.apache.maven.surefire.testset.TestSetFailedException;
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -43,27 +40,16 @@
 {
     protected static ResourceBundle bundle = ResourceBundle.getBundle( Surefire.SUREFIRE_BUNDLE_NAME );
 
-    private static final String FS = System.getProperty( "file.separator" );
-
-    private File basedir;
-
-    private List includes;
-
-    private List excludes;
-
     protected Map testSets;
 
     private int totalTests;
+    
+    private final SurefireDirectoryScanner surefireDirectoryScanner;
 
-    private static final String[] EMPTY_STRING_ARRAY = new String[0];
 
     protected AbstractDirectoryTestSuite( File basedir, List includes, List excludes )
     {
-        this.basedir = basedir;
-
-        this.includes = new ArrayList( includes );
-
-        this.excludes = new ArrayList( excludes );
+        this.surefireDirectoryScanner = new SurefireDirectoryScanner(basedir, includes, excludes);
     }
 
     public Map locateTestSets( ClassLoader classLoader )
@@ -75,26 +61,13 @@
         }
         testSets = new HashMap();
 
-        String[] tests = collectTests( basedir, includes, excludes );
+        Class[] locatedClasses = surefireDirectoryScanner.locateTestClasses( classLoader);
 
-        for ( int i = 0; i < tests.length; i++ )
+        for ( int i = 0; i < locatedClasses.length; i++ )
         {
-            String className = tests[i];
+            Class testClass = locatedClasses[i];
+            SurefireTestSet testSet = createTestSet( testClass, classLoader );
 
-            Class testClass;
-            try
-            {
-                testClass = classLoader.loadClass( className );
-            }
-            catch ( ClassNotFoundException e )
-            {
-                throw new TestSetFailedException( "Unable to create test class '" + className + "'", e );
-            }
-
-            if ( !Modifier.isAbstract( testClass.getModifiers() ) )
-            {
-                SurefireTestSet testSet = createTestSet( testClass, classLoader );
-                
                 if ( testSet == null )
                 {
                     continue;
@@ -107,7 +80,6 @@
                 testSets.put( testSet.getName(), testSet );
 
                 totalTests++;
-            }
         }
 
         return Collections.unmodifiableMap( testSets );
@@ -177,47 +149,4 @@
         return totalTests;
     }
 
-    private String[] collectTests( File basedir, List includes, List excludes )
-    {
-        String[] tests = EMPTY_STRING_ARRAY;
-        if ( basedir.exists() )
-        {
-            DirectoryScanner scanner = new DirectoryScanner();
-
-            scanner.setBasedir( basedir );
-
-            if ( includes != null )
-            {
-                scanner.setIncludes( processIncludesExcludes( includes ) );
-            }
-
-            if ( excludes != null )
-            {
-                scanner.setExcludes( processIncludesExcludes( excludes ) );
-            }
-
-            scanner.scan();
-
-            tests = scanner.getIncludedFiles();
-            for ( int i = 0; i < tests.length; i++ )
-            {
-                String test = tests[i];
-                test = test.substring( 0, test.indexOf( "." ) );
-                tests[i] = test.replace( FS.charAt( 0 ), '.' );
-            }
-        }
-        return tests;
-    }
-
-    private static String[] processIncludesExcludes( List list )
-    {
-        String[] incs = new String[list.size()];
-
-        for ( int i = 0; i < incs.length; i++ )
-        {
-            incs[i] = StringUtils.replace( (String) list.get( i ), "java", "class" );
-
-        }
-        return incs;
-    }
 }

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,173 @@
+package org.apache.maven.surefire.util;
+/*
+ * 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.codehaus.plexus.util.StringUtils;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.testset.SurefireTestSet;
+
+import java.util.*;
+import java.io.File;
+import java.lang.reflect.Modifier;
+
+/**
+ * Scans directories looking for tests.
+ * @author Karl M. Davis
+ * @author Kristian Rosenvold
+ */
+public class SurefireDirectoryScanner {
+
+    private static final String FS = System.getProperty( "file.separator" );
+    private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
+    private final File basedir;
+
+    private final List includes;
+
+    private final List excludes;
+
+    protected Map testSets;
+
+    private int totalTests;
+
+
+    public Map getTestSets() {
+        return testSets;
+    }
+
+    public SurefireDirectoryScanner(File basedir, List includes, List excludes) {
+        this.basedir = basedir;
+        this.includes = includes;
+        this.excludes = excludes;
+    }
+
+    public interface TestSetCreator{
+        SurefireTestSet createTestSet(Class clazz);
+    }
+
+    public Map locateTestSets( ClassLoader classLoader, TestSetCreator testSetCreator )
+        throws TestSetFailedException
+    {
+        if ( testSets != null )
+        {
+            throw new IllegalStateException( "You can't call locateTestSets twice" );
+        }
+        testSets = new HashMap();
+
+        Class[] locatedClasses = locateTestClasses( classLoader);
+
+        for ( int i = 0; i < locatedClasses.length; i++ )
+        {
+            Class testClass = locatedClasses[i];
+            SurefireTestSet testSet = testSetCreator.createTestSet( testClass);
+
+                if ( testSet == null )
+                {
+                    continue;
+                }
+
+                if ( testSets.containsKey( testSet.getName() ) )
+                {
+                    throw new TestSetFailedException( "Duplicate test set '" + testSet.getName() + "'" );
+                }
+                testSets.put( testSet.getName(), testSet );
+
+                totalTests++;
+        }
+
+        return Collections.unmodifiableMap( testSets );
+    }
+
+    public Class[] locateTestClasses( ClassLoader classLoader)
+        throws TestSetFailedException
+    {
+        String[] testClassNames =   collectTests( );
+        List result = new ArrayList();
+
+        for ( int i = 0; i < testClassNames.length; i++ )
+        {
+            String className = testClassNames[i];
+
+            Class testClass;
+            try
+            {
+                testClass = classLoader.loadClass( className );
+            }
+            catch ( ClassNotFoundException e )
+            {
+                throw new TestSetFailedException( "Unable to create test class '" + className + "'", e );
+            }
+
+            if ( !Modifier.isAbstract( testClass.getModifiers() ) )
+            {
+
+                result.add( testClass);
+            }
+        }
+        return (Class[]) result.toArray(new Class[result.size()]);
+    }
+
+
+    String[] collectTests( )
+    {
+        String[] tests = EMPTY_STRING_ARRAY;
+        if ( basedir.exists() )
+        {
+            org.codehaus.plexus.util.DirectoryScanner scanner = new org.codehaus.plexus.util.DirectoryScanner();
+
+            scanner.setBasedir( basedir );
+
+            if ( includes != null )
+            {
+                scanner.setIncludes( processIncludesExcludes( includes ) );
+            }
+
+            if ( excludes != null )
+            {
+                scanner.setExcludes( processIncludesExcludes( excludes ) );
+            }
+
+            scanner.scan();
+
+            tests = scanner.getIncludedFiles();
+            for ( int i = 0; i < tests.length; i++ )
+            {
+                String test = tests[i];
+                test = test.substring( 0, test.indexOf( "." ) );
+                tests[i] = test.replace( FS.charAt( 0 ), '.' );
+            }
+        }
+        return tests;
+    }
+
+    private static String[] processIncludesExcludes( List list )
+    {
+        String[] incs = new String[list.size()];
+
+        for ( int i = 0; i < incs.length; i++ )
+        {
+            incs[i] = StringUtils.replace( (String) list.get( i ), "java", "class" );
+
+        }
+        return incs;
+    }
+
+
+
+}

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java (added)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,46 @@
+package org.apache.maven.surefire.util;
+
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+/**
+ * Test of the directory scanner.
+ */
+public class SurefireDirectoryScannerTest extends TestCase {
+    public void testLocateTestClasses() throws IOException, TestSetFailedException {
+        File baseDir = new File(new File(".").getCanonicalPath());
+        List include = new ArrayList();
+        include.add ("**/*ZT*A.java");
+        List exclude = new ArrayList();
+        
+        SurefireDirectoryScanner surefireDirectoryScanner = new SurefireDirectoryScanner(baseDir, include, exclude);
+        String[] classNames = surefireDirectoryScanner.collectTests();
+        assertNotNull( classNames);
+        assertEquals(3, classNames.length);
+   }
+}

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT1A.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT1A.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT1A.java (added)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT1A.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.surefire.util.testdata;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: kristian
+ * Date: Jun 21, 2009
+ * Time: 8:12:27 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class DataZT1A {
+}

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT1A.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT1A.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT2A.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT2A.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT2A.java (added)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT2A.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.surefire.util.testdata;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: kristian
+ * Date: Jun 21, 2009
+ * Time: 8:12:27 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class DataZT2A {
+}

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT2A.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT2A.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT3A.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT3A.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT3A.java (added)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT3A.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.surefire.util.testdata;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: kristian
+ * Date: Jun 21, 2009
+ * Time: 8:12:27 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class DataZT3A {
+}

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT3A.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/testdata/DataZT3A.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/surefire/trunk/surefire-integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/pom.xml?rev=895651&r1=895650&r2=895651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/pom.xml (original)
+++ maven/surefire/trunk/surefire-integration-tests/pom.xml Mon Jan  4 14:55:57 2010
@@ -79,7 +79,7 @@
                <value>${maven.home}</value>
             </property>
           </systemProperties>
-          
+
         </configuration>
       </plugin>
     </plugins>

Modified: maven/surefire/trunk/surefire-providers/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/pom.xml?rev=895651&r1=895650&r2=895651&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/pom.xml (original)
+++ maven/surefire/trunk/surefire-providers/pom.xml Mon Jan  4 14:55:57 2010
@@ -36,6 +36,7 @@
   <modules>
     <module>surefire-junit</module>
     <module>surefire-junit4</module>
+    <module>surefire-junit47</module>
     <module>surefire-testng</module>
   </modules>
 

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan  4 14:55:57 2010
@@ -0,0 +1,8 @@
+target
+*.iml
+*.ipr
+*.iws
+.classpath
+.project
+.metadata
+.settings

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/pom.xml?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/pom.xml (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/pom.xml Mon Jan  4 14:55:57 2010
@@ -0,0 +1,77 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.maven.surefire</groupId>
+        <artifactId>surefire-providers</artifactId>
+        <version>2.5-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>surefire-junit47</artifactId>
+
+    <name>SureFire JUnitCore Runner</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.7</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <fork>false</fork>
+                    <compilerVersion>1.5</compilerVersion>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <jvm>${java.home}/bin/java</jvm>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListener.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListener.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListener.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.surefire.junitcore;
+
+import org.junit.runner.notification.RunListener;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+
+import java.util.*;
+
+/**
+ * Demultiplexes threaded running og tests into something that does not look threaded.
+ * Essentially makes a threaded junit core RunListener behave like something like a
+ * junit4 reporter can handle.
+ * The disadvantage of this demultiplexer is that there's no results being echoed to the
+ * console as tests are being run
+ * All results come like ketchup out of the bottle.
+ *
+ * This class is basically copied from org.jdogma.junit.DemultiplexingRunListener to keep
+ * required external dependencies minimal.
+ * @author Kristian Rosenvold, kristian.rosenvold@gmail com
+ */
+class DemultiplexingRunListener extends RunListener {
+    private final Map<String, RecordingRunListener> classList = new HashMap<String, RecordingRunListener>();
+    private final RunListener realtarget;
+
+    public DemultiplexingRunListener(RunListener realtarget) {
+        this.realtarget = realtarget;
+    }
+
+    @Override
+    public void testRunStarted(Description description) throws Exception {
+        // Do nothing. We discard this event because it's basically meaningless
+    }
+
+    @Override
+    public void testRunFinished(Result outerResult) throws Exception {
+        for (RecordingRunListener classReport : classList.values()) {
+            classReport.replay( realtarget);
+        }
+    }
+
+    @Override
+    public void testStarted(Description description) throws Exception {
+        getOrCreateClassReport(description).testStarted( description);
+    }
+
+    @Override
+    public void testFinished(Description description) throws Exception {
+        getClassReport( description).testFinished(description);
+    }
+
+    @Override
+    public void testFailure(Failure failure) throws Exception {
+        getClassReport( failure.getDescription()).testFailure( failure);
+    }
+
+    @Override
+    public void testAssumptionFailure(Failure failure) {
+        getClassReport(failure.getDescription()).testAssumptionFailure( failure);
+    }
+
+    @Override
+    public void testIgnored(Description description) throws Exception {
+        getClassReport(description).testIgnored(description);
+    }
+
+
+    RecordingRunListener getClassReport(Description description) {
+        synchronized ( classList){
+          return classList.get( description.getClassName());
+        }
+    }
+
+    private RecordingRunListener getOrCreateClassReport(Description description) throws Exception {
+        RecordingRunListener result;
+        synchronized (classList) {
+            result = classList.get(description.getClassName());
+            if (result == null) {
+                result = new RecordingRunListener();
+                result.testRunStarted( description);
+                classList.put(description.getClassName(), result);
+            }
+        }
+        return result;
+    }
+
+    public class RecordingRunListener extends RunListener {
+        private volatile Description testRunStarted;
+        private final List<Description> testStarted = Collections.synchronizedList(new ArrayList<Description>());
+        private final List<Description> testFinished =  Collections.synchronizedList(new ArrayList<Description>());
+        private final List<Failure> testFailure =  Collections.synchronizedList(new ArrayList<Failure>());
+        private final List<Failure> testAssumptionFailure =  Collections.synchronizedList(new ArrayList<Failure>());
+        private final List<Description> testIgnored =  Collections.synchronizedList(new ArrayList<Description>());
+        private final Result resultForThisClass = new Result();
+        private final RunListener classRunListener = resultForThisClass.createListener();
+
+
+
+        @Override
+        public void testRunStarted(Description description) throws Exception {
+            this.testRunStarted = description;
+        }
+
+        @Override
+        public void testRunFinished(Result result) throws Exception {
+            throw new IllegalStateException("This method should not be called on the recorder");
+        }
+
+        @Override
+        public void testStarted(Description description) throws Exception {
+            testStarted.add( description);
+            classRunListener.testStarted( description);
+        }
+
+        @Override
+        public void testFinished(Description description) throws Exception {
+            testFinished.add( description);
+            classRunListener.testFinished(description);
+        }
+
+        @Override
+        public void testFailure(Failure failure) throws Exception {
+            testFailure.add( failure);
+            classRunListener.testFailure( failure);
+        }
+
+        @Override
+        public void testAssumptionFailure(Failure failure) {
+            testAssumptionFailure.add( failure);
+        }
+
+        @Override
+        public void testIgnored(Description description) throws Exception {
+            testIgnored.add(  description);
+        }
+
+        public void replay(RunListener target) throws Exception {
+            target.testRunStarted (testRunStarted);
+
+            for( Description description : testStarted) {
+                target.testStarted( description);
+            }
+            for( Failure failure : testFailure) {
+                target.testFailure( failure);
+            }
+            for( Description description : testIgnored) {
+                target.testIgnored( description);
+            }
+            for( Failure failure : testAssumptionFailure) {
+                target.testAssumptionFailure( failure);
+            }
+            for( Description description : testFinished) {
+                target.testFinished( description);
+            }
+            target.testRunFinished( resultForThisClass);
+        }
+
+
+    }
+
+}

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

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.surefire.junitcore;
+
+import org.apache.maven.surefire.suite.SurefireTestSuite;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.util.SurefireDirectoryScanner;
+
+import java.util.*;
+import java.io.File;
+
+/**
+ * Test suite for JUnitCore based on a directory of Java test classes.
+ *
+ * @author Karl M. Davis
+ * @author Kristian Rosenvold (junit core adaption)
+ */
+public class JUnitCoreDirectoryTestSuite implements SurefireTestSuite {
+    private final SurefireDirectoryScanner directoryScanner;
+
+    private TestsToRun testsToRun;
+
+    protected Map testSets;
+    private final JUnitCoreParameters jUnitCoreParameters;
+
+
+    public JUnitCoreDirectoryTestSuite(File basedir, ArrayList includes, ArrayList excludes, Properties properties) {
+        directoryScanner = new SurefireDirectoryScanner(basedir, includes, excludes);
+        this.jUnitCoreParameters = new JUnitCoreParameters(properties);
+    }
+
+
+    public void execute(ReporterManager reporterManager, ClassLoader classLoader)
+            throws ReporterException, TestSetFailedException {
+        if (testsToRun == null) {
+            throw new IllegalStateException("You must call locateTestSets before calling execute");
+        }
+
+        JUnitCoreTestSet.execute(testsToRun.getLocatedClasses(), reporterManager, jUnitCoreParameters);
+    }
+
+    public void execute(String testSetName, ReporterManager reporterManager, ClassLoader classLoader)
+            throws ReporterException, TestSetFailedException {
+        if (testsToRun == null) {
+            throw new IllegalStateException("You must call locateTestSets before calling execute");
+        }
+        JUnitCoreTestSet testSet = testsToRun.getTestSet( testSetName);
+
+        if (testSet == null) {
+            throw new TestSetFailedException("Unable to find test set '" + testSetName + "' in suite");
+        }
+        testSet.execute(reporterManager, jUnitCoreParameters);
+    }
+
+    public Map locateTestSets(ClassLoader classLoader) throws TestSetFailedException {
+        if (testSets != null) {
+            throw new IllegalStateException("You can't call locateTestSets twice");
+        }
+
+        Class[] locatedClasses = directoryScanner.locateTestClasses(classLoader);
+        testsToRun = new TestsToRun(locatedClasses);
+        return testsToRun.getTestSets();
+    }
+
+    public int getNumTests() {
+        if (testsToRun == null) {
+            throw new IllegalStateException("You must call locateTestSets before calling getNumTests");
+        }
+        return testsToRun.size();
+    }
+}

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

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+package org.apache.maven.surefire.junitcore;
+
+import java.util.Properties;
+
+/**
+ * @author Kristian Rosenvold
+ */
+class JUnitCoreParameters {
+
+    private final String parallel;
+    private final Boolean perCoreThreadCount;
+    private final int threadCount;
+    private final Boolean useUnlimitedThreads;
+    private final Boolean configurableParallelComputerPresent;
+    public static final String PARALLEL_KEY = "parallel";
+    public static final String PERCORETHREADCOUNT_KEY = "perCoreThreadCount";
+    public static final String THREADCOUNT_KEY = "threadCount";
+    public static final String USEUNLIMITEDTHREADS_KEY = "useUnlimitedThreads";
+    public static final String CONFIGURABLEPARALLELCOMPUTERPRESENT_KEY = "configurableParallelComputerPresent";
+
+
+    public JUnitCoreParameters(Properties properties) {
+        this.parallel = properties.getProperty(PARALLEL_KEY, "none").toLowerCase();
+        this.perCoreThreadCount = Boolean.valueOf( properties.getProperty(PERCORETHREADCOUNT_KEY, "true"));
+        this.threadCount = Integer.valueOf(properties.getProperty(THREADCOUNT_KEY, "8"));
+        this.useUnlimitedThreads = Boolean.valueOf(properties.getProperty(USEUNLIMITEDTHREADS_KEY, "false").toLowerCase());
+        this.configurableParallelComputerPresent = Boolean.valueOf(properties.getProperty(CONFIGURABLEPARALLELCOMPUTERPRESENT_KEY, "false").toLowerCase());
+    }
+
+    public boolean isParallelMethod(){
+        return "methods".equals( parallel);
+    }
+    public boolean isParallelClasses(){
+        return "classes".equals( parallel);
+    }
+    public boolean isParallelBoth(){
+        return "both".equals( parallel);
+    }
+
+    public Boolean isPerCoreThreadCount() {
+        return perCoreThreadCount;
+    }
+
+    public int getThreadCount() {
+        return threadCount;
+    }
+
+    public Boolean isUseUnlimitedThreads() {
+        return useUnlimitedThreads;
+    }
+
+    public boolean isNoThreading(){
+        return !(isParallelClasses() || isParallelMethod() || isParallelBoth());
+    }
+    public boolean isAnyParallelitySelected(){
+        return !isNoThreading();
+    }
+
+    public Boolean isConfigurableParallelComputerPresent() {
+        return configurableParallelComputerPresent;
+    }
+
+    @Override
+    public String toString() {
+        return "JUnitCoreParameters{" +
+                "parallel='" + parallel + '\'' +
+                ", perCoreThreadCount=" + perCoreThreadCount +
+                ", threadCount=" + threadCount +
+                ", useUnlimitedThreads=" + useUnlimitedThreads +
+                ", configurableParallelComputerPresent=" + configurableParallelComputerPresent +
+                '}';
+    }
+}

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

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreStackTraceWriter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreStackTraceWriter.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreStackTraceWriter.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreStackTraceWriter.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+package org.apache.maven.surefire.junitcore;
+
+
+import org.apache.maven.surefire.report.StackTraceWriter;
+import org.junit.runner.notification.Failure;
+
+/**
+ * Writes out a specific {@link org.junit.runner.notification.Failure} for
+ * surefire as a stacktrace.
+ *
+ * @author Karl M. Davis
+ * @author Kristian Rosenvold (junit core adaption)
+ */
+class JUnitCoreStackTraceWriter
+    implements StackTraceWriter
+{
+    // Member Variables
+    private Failure junitFailure;
+
+    /**
+     * Constructor.
+     *
+     * @param junitFailure the {@link Failure} that this will be operating on
+     */
+    public JUnitCoreStackTraceWriter( Failure junitFailure )
+    {
+        this.junitFailure = junitFailure;
+    }
+
+    /*
+      * (non-Javadoc)
+      *
+      * @see org.apache.maven.surefire.report.StackTraceWriter#writeTraceToString()
+      */
+    public String writeTraceToString()
+    {
+        return junitFailure.getTrace();
+    }
+
+    /**
+     * At the moment, returns the same as {@link #writeTraceToString()}.
+     *
+     * @see org.apache.maven.surefire.report.StackTraceWriter#writeTrimmedTraceToString()
+     */
+    public String writeTrimmedTraceToString()
+    {
+        return junitFailure.getTrace();
+    }
+
+    /**
+     * Returns the exception associated with this failure.
+     *
+     * @see org.apache.maven.surefire.report.StackTraceWriter#getThrowable()
+     */
+    public Throwable getThrowable()
+    {
+        return junitFailure.getException();
+    }
+
+}

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

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreStackTraceWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,187 @@
+/*
+ * 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.
+ */
+package org.apache.maven.surefire.junitcore;
+
+
+import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Computer;
+import org.junit.runner.notification.RunListener;
+import org.junit.experimental.ParallelComputer;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+
+/**
+ * Writes out a specific {@link org.junit.runner.notification.Failure} for
+ * surefire as a stacktrace.
+ *
+ * @author Karl M. Davis
+ * @author Kristian Rosenvold (junit core adaption)
+ */
+
+class JUnitCoreTestSet {
+    private final Class testClass;
+    private static final String className = "org.jdogma.junit.ConfigurableParallelComputer";
+    private static final String demuxerClassName = "org.jdogma.junit.DemultiplexingRunListener";
+
+    public String getName() {
+        return testClass.getName();
+    }
+
+    Class getTestClass() {
+        return testClass;
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param testClasses the classes to be run as a test
+     */
+    protected JUnitCoreTestSet(Class testClasses) {
+        this.testClass = testClasses;
+    }
+
+    /**
+     * 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
+     * @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)
+            throws TestSetFailedException {
+
+        Class[] classes = new Class[1];
+        classes[0] = testClass;
+        execute(classes, reportManager, JUnitCoreParameters);
+    }
+
+    public static void execute(Class[] classes, ReporterManager reportManager, JUnitCoreParameters jUnitCoreParameters)
+            throws TestSetFailedException {
+        RunListener listener = new JUnitCoreTestSetReporter(reportManager);
+        if (jUnitCoreParameters.isAnyParallelitySelected()) {
+            listener = createRunListener(listener, jUnitCoreParameters.isConfigurableParallelComputerPresent());
+        }
+        Computer computer = getComputer(jUnitCoreParameters);
+        try {
+            runJunitCore(classes, computer, listener);
+        } 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);
+        }
+    }
+
+    private static void closeIfConfigurable(Computer computer) throws TestSetFailedException {
+        if (computer.getClass().getName().startsWith(className)) {
+            try {
+                Class<?> cpcClass = Class.forName(className);
+                Method method = cpcClass.getMethod("close");
+                method.invoke(computer);
+            } 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);
+            }
+        }
+    }
+
+    private static Computer getComputer(JUnitCoreParameters jUnitCoreParameters) throws TestSetFailedException {
+        if (jUnitCoreParameters.isNoThreading()) {
+            return new Computer();
+        }
+        return jUnitCoreParameters.isConfigurableParallelComputerPresent() ?
+                getConfigurableParallelComputer(jUnitCoreParameters) :
+                getParallelComputer(jUnitCoreParameters);
+    }
+
+    private static Computer getParallelComputer(JUnitCoreParameters JUnitCoreParameters) {
+        if (JUnitCoreParameters.isUseUnlimitedThreads())
+            return new ParallelComputer(true, true);
+        else {
+            return new ParallelComputer(JUnitCoreParameters.isParallelClasses(), JUnitCoreParameters.isParallelMethod());
+        }
+    }
+
+    private static Computer getConfigurableParallelComputer(JUnitCoreParameters JUnitCoreParameters) throws TestSetFailedException {
+
+        try {
+            Class<?> cpcClass = Class.forName(className);
+            if (JUnitCoreParameters.isUseUnlimitedThreads()) {
+                Constructor<?> constructor = cpcClass.getConstructor();
+                return (Computer) constructor.newInstance();
+            } else {
+                Constructor<?> constructor = cpcClass.getConstructor(boolean.class, boolean.class, Integer.class, boolean.class);
+                return (Computer) constructor.newInstance(JUnitCoreParameters.isParallelClasses(),
+                        JUnitCoreParameters.isParallelMethod(),
+                        JUnitCoreParameters.getThreadCount(), JUnitCoreParameters.isPerCoreThreadCount());
+            }
+        } catch (ClassNotFoundException e) {
+            throw new TestSetFailedException(e);
+        } catch (NoSuchMethodException e) {
+            throw new TestSetFailedException(e);
+        } catch (InvocationTargetException e) {
+            throw new TestSetFailedException(e);
+        } catch (InstantiationException e) {
+            throw new TestSetFailedException(e);
+        } catch (IllegalAccessException e) {
+            throw new TestSetFailedException(e);
+        }
+    }
+
+    private static void runJunitCore(Class[] classes, Computer computer, RunListener real) throws TestSetFailedException {
+        JUnitCore junitCore = new JUnitCore();
+        junitCore.addListener(real);
+        try {
+            junitCore.run(computer, classes);
+        } finally {
+            junitCore.removeListener(real);
+        }
+    }
+
+
+}

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

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+package org.apache.maven.surefire.junitcore;
+
+
+
+import java.util.ResourceBundle;
+
+import org.apache.maven.surefire.Surefire;
+import org.apache.maven.surefire.report.ReportEntry;
+import org.apache.maven.surefire.report.ReporterManager;
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunListener;
+
+class JUnitCoreTestSetReporter
+    extends RunListener
+{
+    // Constants
+    private static ResourceBundle bundle = ResourceBundle.getBundle( Surefire.SUREFIRE_BUNDLE_NAME );
+
+
+    private ReporterManager reportMgr;
+
+    /**
+     * This flag is set after a failure has occurred so that a <code>testSucceeded</code> event is not fired.  This is necessary because JUnit4 always fires a <code>testRunFinished</code> event-- even if there was a failure.
+     */
+    private boolean failureFlag;
+
+    /**
+     * Constructor.
+     *
+     * @param reportManager the report manager to log testing events to
+     */
+    JUnitCoreTestSetReporter(ReporterManager reportManager)
+    {
+        this.reportMgr = reportManager;
+    }
+
+    /**
+     * Called right before any tests from a specific class are run.
+     *
+     * @see org.junit.runner.notification.RunListener#testRunStarted(org.junit.runner.Description)
+     */
+    public void testRunStarted( Description description )
+        throws Exception
+    {
+        String rawString = bundle.getString( "testSetStarting" );
+        ReportEntry report = new ReportEntry( description.getClassName(), description.getDisplayName(), rawString );
+
+        this.reportMgr.testSetStarting( report );
+    }
+
+    /**
+     * Called right after all tests from a specific class are run.
+     *
+     * @see org.junit.runner.notification.RunListener#testRunFinished(org.junit.runner.Result)
+     */
+    public void testRunFinished( Result result )
+        throws Exception
+    {
+        String rawString = bundle.getString( "testSetCompletedNormally" );
+        ReportEntry report = new ReportEntry( result.getClass().getCanonicalName(), result.getClass().getName(), rawString );
+        this.reportMgr.testSetCompleted( report );
+        this.reportMgr.reset();
+    }
+
+    /**
+     * Called when a specific test has been skipped (for whatever reason).
+     *
+     * @see org.junit.runner.notification.RunListener#testIgnored(org.junit.runner.Description)
+     */
+    public void testIgnored( Description description )
+        throws Exception
+    {
+        String rawString = bundle.getString( "testSkipped" );
+        ReportEntry report = new ReportEntry( description.getTestClass().getCanonicalName(), description.getDisplayName(), rawString );
+
+        this.reportMgr.testSkipped( report );
+    }
+
+    /**
+     * Called when a specific test has started.
+     *
+     * @see org.junit.runner.notification.RunListener#testStarted(org.junit.runner.Description)
+     */
+    public void testStarted( Description description )
+        throws Exception
+    {
+        String rawString = bundle.getString( "testStarting" );
+        ReportEntry report = new ReportEntry( description.getTestClass().getCanonicalName(), description.getDisplayName(), rawString );
+
+        this.reportMgr.testStarting( report );
+
+        this.failureFlag = false;
+    }
+
+    /**
+     * Called when a specific test has failed.
+     *
+     * @see org.junit.runner.notification.RunListener#testFailure(org.junit.runner.notification.Failure)
+     */
+    public void testFailure( Failure failure )
+        throws Exception
+    {
+        String rawString = bundle.getString( "executeException" );
+        ReportEntry report =
+            new ReportEntry( failure.getDescription().getTestClass().getCanonicalName(), failure.getTestHeader(), rawString, new JUnitCoreStackTraceWriter( failure ) );
+
+        if ( failure.getException() instanceof AssertionError )
+        {
+            this.reportMgr.testFailed( report );
+        }
+        else
+        {
+            this.reportMgr.testError( report );
+        }
+
+        failureFlag = true;
+    }
+
+    /**
+     * Called after a specific test has finished.
+     *
+     * @see org.junit.runner.notification.RunListener#testFinished(org.junit.runner.Description)
+     */
+    public void testFinished( Description description )
+        throws Exception
+    {
+        if ( failureFlag == false )
+        {
+            String rawString = bundle.getString( "testSuccessful" );
+            ReportEntry report = new ReportEntry( description.getTestClass().getCanonicalName(), description.getDisplayName(), rawString );
+
+            this.reportMgr.testSucceeded( report );
+        }
+    }
+}

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

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+package org.apache.maven.surefire.junitcore;
+
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ * Contains all the tests that have been found according to specified include/exclude
+ * specification for a given surefire run.
+ * @author Kristian Rosenvold (junit core adaption)
+ */
+class TestsToRun {
+    final Class[] locatedClasses;
+    final int totalTests;
+    Map<String, JUnitCoreTestSet> testSets;
+
+    public TestsToRun(Class... locatedClasses) throws TestSetFailedException {
+        this.locatedClasses = locatedClasses;
+        testSets = new HashMap<String, JUnitCoreTestSet>();
+        int testCount = 0;
+        for (int i = 0; i < locatedClasses.length; i++) {
+            Class testClass = locatedClasses[i];
+            JUnitCoreTestSet testSet = new JUnitCoreTestSet(testClass);
+
+            if (testSets.containsKey(testSet.getName())) {
+                throw new TestSetFailedException("Duplicate test set '" + testSet.getName() + "'");
+            }
+            testSets.put(testSet.getName(), testSet);
+            testCount++;
+        }
+        this.totalTests = testCount;
+    }
+
+    public Map<String, JUnitCoreTestSet> getTestSets() {
+        return Collections.unmodifiableMap(testSets);
+    }
+
+    public int size() {
+        return testSets.size();
+    }
+
+    public Class[] getLocatedClasses() {
+        return locatedClasses;
+    }
+
+    public JUnitCoreTestSet getTestSet(String name){
+        return testSets.get( name);
+    }
+
+}

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

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListenerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListenerTest.java?rev=895651&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListenerTest.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListenerTest.java Mon Jan  4 14:55:57 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.surefire.junitcore;
+
+
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+import org.junit.runner.notification.RunListener;
+import org.junit.Test;
+import static org.mockito.Mockito.*;
+
+/*
+ * @author Kristian Rosenvold, kristian.rosenvold@gmail com
+ */
+
+public class DemultiplexingRunListenerTest {
+    @Test
+    public void testTestStarted() throws Exception {
+        RunListener real = mock(RunListener.class);
+        DemultiplexingRunListener listener = new DemultiplexingRunListener(real);
+
+        Description testRunDescription = Description.createSuiteDescription(DemultiplexingRunListenerTest.class);
+        Description description1 = Description.createTestDescription( DemultiplexingRunListenerTest.class, "testStub1");
+        Description description2 = Description.createTestDescription( Dummy.class, "testStub2");
+
+        listener.testRunStarted(testRunDescription);
+        listener.testStarted(description1);
+        listener.testStarted(description2);
+        listener.testFinished(description1);
+        listener.testFinished(description2);
+        Result temp = new Result();
+        listener.testRunFinished( temp);
+
+        verify(real).testRunStarted( description1);
+        verify(real).testStarted( description1);
+        verify(real).testRunStarted( description2);
+        verify(real).testStarted( description2);
+    }
+
+    public class Dummy {
+        @Test
+        public void testNotMuch(){
+
+        }
+
+            @Test
+        public void testStub1() {
+            // Add your code here
+        }
+        @Test
+        public void testStub2() {
+            // Add your code here
+        }
+    }
+}

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

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/DemultiplexingRunListenerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message