Modified: 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java?rev=1039777&r1=1039776&r2=1039777&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
 (original)
+++ 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
 Sat Nov 27 22:41:23 2010
@@ -72,7 +72,7 @@ public class ForkedBooter
             }
             else
             {
-                result = booter.runSuitesInProcess();
+                result = booter.runSuitesInProcess(p);
             }
 
             booterDeserializer.writePropertiesFile( surefirePropertiesFile, 
"surefire", p );

Added: 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java?rev=1039777&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
 (added)
+++ 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
 Sat Nov 27 22:41:23 2010
@@ -0,0 +1,78 @@
+package org.apache.maven.surefire.booter;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.providerapi.DirectoryScannerParametersAware;
+import org.apache.maven.surefire.providerapi.ProviderConfiguration;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class ProviderFactory
+{
+    private final BooterConfiguration booterConfiguration;
+
+    private final ClassLoader surefireClassLoader;
+
+    private final Class directoryScannerParametersAware;
+
+    private final SurefireReflector surefireReflector;
+
+
+    public ProviderFactory( BooterConfiguration booterConfiguration, 
ClassLoader surefireClassLoader )
+    {
+        this.booterConfiguration = booterConfiguration;
+        this.surefireClassLoader = surefireClassLoader;
+        this.surefireReflector = new SurefireReflector( surefireClassLoader );
+        try
+        {
+            directoryScannerParametersAware =
+                surefireClassLoader.loadClass( 
DirectoryScannerParametersAware.class.getName() );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new RuntimeException( "When loading class", e );
+        }
+    }
+
+    public Object createProvider( ClassLoader testClassLoader )
+    {
+        ClassLoader context = 
java.lang.Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader( surefireClassLoader );
+
+        ProviderConfiguration providerConfiguration = 
booterConfiguration.getProviderConfiguration();
+        final Object o = surefireReflector.newInstance( providerConfiguration 
);
+        surefireReflector.setIfDirScannerAware( o, 
booterConfiguration.getDirScannerParams() );
+        surefireReflector.setTestSuiteDefinitionAware( o, 
booterConfiguration.getTestSuiteDefinition() );
+        surefireReflector.setProviderPropertiesAware( o, 
booterConfiguration.getProviderProperties() );
+        surefireReflector.setReporterConfigurationAware( o, 
booterConfiguration.getReporterConfiguration() );
+        surefireReflector.setTestClassLoaderAware( o, testClassLoader );
+        surefireReflector.setTestArtifactInfoAware( o, 
booterConfiguration.getTestNg() );
+/*
+
+        if (o instanceof ReportingAware ){
+            ReporterManagerFactory reporterManagerFactory = new 
ReporterManagerFactory2( booterConfiguration.getReports(),  
surefireClassLoader, booterConfiguration.getReporterConfiguration());
+            ((ReportingAware)o).setReporterManagerFactory( 
reporterManagerFactory );
+        }
+
+        Thread.currentThread().setContextClassLoader( context );*/
+
+        return o;
+    }
+}

Propchange: 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java?rev=1039777&r1=1039776&r2=1039777&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
 (original)
+++ 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
 Sat Nov 27 22:41:23 2010
@@ -23,7 +23,7 @@ import java.util.Properties;
 
 /**
  * Invokes surefire with the correct classloader setup.
- *
+ * <p/>
  * This part of the booter that is always guaranteed to be in the
  * same vm as the tests will be run in.
  *
@@ -44,11 +44,6 @@ public class SurefireStarter
     public int runSuitesInProcess( String testSet, Properties results )
         throws SurefireExecutionException
     {
-        if ( booterConfiguration.getTestSuites().size() != 1 )
-        {
-            throw new IllegalArgumentException( "Cannot only specify testSet 
for single test suites" );
-        }
-
         // TODO: replace with plexus
 
         ClassLoader oldContextClassLoader = 
Thread.currentThread().getContextClassLoader();
@@ -63,9 +58,13 @@ public class SurefireStarter
             SurefireReflector reflector = new SurefireReflector( 
surefireClassLoader );
 
             Thread.currentThread().setContextClassLoader( testsClassLoader );
-            return reflector.run( booterConfiguration.getReports(),
-                                  (Object[]) 
booterConfiguration.getTestSuites().get( 0 ), testSet, surefireClassLoader,
-                                  testsClassLoader, results, 
booterConfiguration.isFailIfNoTests() );
+            return reflector.runProvider( 
booterConfiguration.getReporterConfiguration(),
+                                          booterConfiguration.getReports(), 
surefireClassLoader, testsClassLoader,
+                                          results, 
booterConfiguration.isFailIfNoTests(),
+                                          
booterConfiguration.getTestSuiteDefinition( testSet ),
+                                          booterConfiguration.getTestNg(),
+                                          
booterConfiguration.getProviderConfiguration(),
+                                          
booterConfiguration.getDirScannerParams() );
         }
         finally
         {
@@ -73,7 +72,7 @@ public class SurefireStarter
         }
     }
 
-    public int runSuitesInProcess()
+    public int runSuitesInProcess( Properties p )
         throws SurefireExecutionException
     {
         // TODO: replace with plexus
@@ -106,8 +105,12 @@ public class SurefireStarter
 
             Thread.currentThread().setContextClassLoader( testsClassLoader );
 
-            return reflector.run( booterConfiguration.getReports(), 
booterConfiguration.getTestSuites(),
-                                  surefireClassLoader, testsClassLoader, 
booterConfiguration.isFailIfNoTests() );
+            return reflector.runProvider( 
booterConfiguration.getReporterConfiguration(),
+                                          booterConfiguration.getReports(), 
surefireClassLoader, testsClassLoader, p,
+                                          
booterConfiguration.isFailIfNoTests(),
+                                          
booterConfiguration.getTestSuiteDefinition(), booterConfiguration.getTestNg(),
+                                          
booterConfiguration.getProviderConfiguration(),
+                                          
booterConfiguration.getDirScannerParams() );
 
         }
         finally

Added: 
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java?rev=1039777&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
 (added)
+++ 
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
 Sat Nov 27 22:41:23 2010
@@ -0,0 +1,161 @@
+package org.apache.maven.surefire.booter;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.surefire.providerapi.DirectoryScannerParametersAware;
+import org.apache.maven.surefire.providerapi.ProviderPropertiesAware;
+import org.apache.maven.surefire.providerapi.ReporterConfigurationAware;
+import org.apache.maven.surefire.providerapi.TestArtifactInfoAware;
+import org.apache.maven.surefire.providerapi.TestClassLoaderAware;
+import org.apache.maven.surefire.providerapi.TestSuiteDefinitionAware;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.suite.SuiteDefinition;
+import org.apache.maven.surefire.testset.DirectoryScannerParameters;
+import org.apache.maven.surefire.testset.TestArtifactInfo;
+import org.apache.maven.surefire.testset.TestSuiteDefinition;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Properties;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class SurefireReflectorTest
+    extends TestCase
+{
+    public void testSetDirectoryScannerParameters()
+        throws Exception
+    {
+        SurefireReflector surefireReflector = getReflector();
+        Foo foo = new Foo();
+
+        DirectoryScannerParameters directoryScannerParameters =
+            new DirectoryScannerParameters( new File( "ABC" ), new 
ArrayList(), new ArrayList(), Boolean.FALSE );
+        assertTrue( surefireReflector.isDirectoryScannerParameterAware( foo ) 
);
+        surefireReflector.setDirectoryScannerParameters( foo, 
directoryScannerParameters );
+
+    }
+
+    public void testTestSuiteDefinition()
+        throws Exception
+    {
+        SurefireReflector surefireReflector = getReflector();
+        Foo foo = new Foo();
+
+        TestSuiteDefinition testSuiteDefinition =
+            new TestSuiteDefinition( new File[]{ new File( "file1" ), new 
File( "file2" ) }, "aForkTest",
+                                     new File( "TestSOurce" ), 
"aUserRequestedTest" );
+        assertTrue( surefireReflector.isTestSuiteDefinitionAware( foo ) );
+        surefireReflector.setTestSuiteDefinition( foo, testSuiteDefinition );
+    }
+
+    public void testProviderProperties()
+        throws Exception
+    {
+        SurefireReflector surefireReflector = getReflector();
+        Foo foo = new Foo();
+
+        assertTrue( surefireReflector.isProviderPropertiesAware( foo ) );
+        surefireReflector.setProviderProperties( foo, new Properties() );
+    }
+
+    public void testReporterConfiguration()
+        throws Exception
+    {
+        SurefireReflector surefireReflector = getReflector();
+        Foo foo = new Foo();
+
+        ReporterConfiguration reporterConfiguration = new 
ReporterConfiguration( new File( "CDE" ), Boolean.TRUE );
+        assertTrue( surefireReflector.isReporterConfigurationAwareAware( foo ) 
);
+        surefireReflector.setReporterConfigurationAware( foo, 
reporterConfiguration );
+    }
+
+    public void testTestClassLoaderAware()
+        throws Exception
+    {
+        SurefireReflector surefireReflector = getReflector();
+        Foo foo = new Foo();
+
+        ReporterConfiguration reporterConfiguration = new 
ReporterConfiguration( new File( "CDE" ), Boolean.TRUE );
+        assertTrue( surefireReflector.isTestClassLoaderAware( foo ) );
+        surefireReflector.setTestClassLoader( foo, getClass().getClassLoader() 
);
+    }
+
+    public void testArtifactInfoAware()
+        throws Exception
+    {
+        SurefireReflector surefireReflector = getReflector();
+        Foo foo = new Foo();
+
+        TestArtifactInfo testArtifactInfo = new TestArtifactInfo( "12.3", 
"test" );
+        assertTrue( surefireReflector.isTestArtifactInfoAware( foo ) );
+        surefireReflector.setTestArtifactInfo( foo, testArtifactInfo );
+    }
+
+    private SurefireReflector getReflector()
+    {
+        return new SurefireReflector( this.getClass().getClassLoader() );
+    }
+
+
+    class Foo
+        implements DirectoryScannerParametersAware, TestSuiteDefinitionAware, 
ProviderPropertiesAware,
+        ReporterConfigurationAware, TestClassLoaderAware, TestArtifactInfoAware
+    {
+        DirectoryScannerParameters directoryScannerParameters;
+
+        TestSuiteDefinition testSuiteDefinition;
+
+        Properties providerProperties;
+
+        ReporterConfiguration reporterConfiguration;
+
+        public void setDirectoryScannerParameters( DirectoryScannerParameters 
directoryScanner )
+        {
+            this.directoryScannerParameters = directoryScanner;
+        }
+
+
+        public void setTestSuiteDefinition( TestSuiteDefinition 
testSuiteDefinition )
+        {
+            this.testSuiteDefinition = testSuiteDefinition;
+        }
+
+        public void setProviderProperties( Properties providerProperties )
+        {
+            this.providerProperties = providerProperties;
+        }
+
+        public void setReporterConfiguration( ReporterConfiguration 
reporterConfiguration )
+        {
+            reporterConfiguration = reporterConfiguration;
+        }
+
+        public void setTestClassLoader( ClassLoader classLoader )
+        {
+        }
+
+        public void setTestArtifactInfo( TestArtifactInfo testArtifactInfo )
+        {
+            //To change body of implemented methods use File | Settings | File 
Templates.
+        }
+    }
+}

Propchange: 
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java?rev=1039777&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
 (added)
+++ 
maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
 Sat Nov 27 22:41:23 2010
@@ -0,0 +1,72 @@
+package org.apache.maven.surefire.junit;
+/*
+ * 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.providerapi.FileScanningProvider;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
+import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+import java.util.Iterator;
+
+/**
+ * @author Kristian Rosenvold
+ * @noinspection UnusedDeclaration
+ */
+public class JUnit3Provider
+    extends FileScanningProvider
+    implements SurefireProvider
+{
+
+    public RunResult invoke()
+        throws TestSetFailedException, ReporterException
+    {
+        JUnitDirectoryTestSuite suite = getSuite();
+        suite.locateTestSets( getTestsClassLoader() );
+        if ( getTestSuiteDefinition().getTestForFork() != null )
+        {
+            suite.execute( getTestSuiteDefinition().getTestForFork(), 
getReporterManagerFactory(),
+                           getTestsClassLoader() );
+        }
+        else
+        {
+            suite.execute( getReporterManagerFactory(), getTestsClassLoader() 
);
+        }
+        return RunResult.totalCountOnly( suite.getNumTests() );
+    }
+
+    private JUnitDirectoryTestSuite getSuite()
+    {
+        return new JUnitDirectoryTestSuite( getDirectoryScanner() );
+
+    }
+
+    public Iterator getSuites()
+    {
+        try
+        {
+            return getSuite().locateTestSets( getTestsClassLoader() 
).keySet().iterator();
+        }
+        catch ( TestSetFailedException e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+}

Propchange: 
maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitDirectoryTestSuite.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitDirectoryTestSuite.java?rev=1039777&r1=1039776&r2=1039777&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitDirectoryTestSuite.java
 (original)
+++ 
maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitDirectoryTestSuite.java
 Sat Nov 27 22:41:23 2010
@@ -24,6 +24,7 @@ import org.apache.maven.surefire.suite.A
 import org.apache.maven.surefire.testset.PojoTestSet;
 import org.apache.maven.surefire.testset.SurefireTestSet;
 import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.DirectoryScanner;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -36,6 +37,11 @@ import java.util.ArrayList;
 public class JUnitDirectoryTestSuite
     extends AbstractDirectoryTestSuite
 {
+    public JUnitDirectoryTestSuite( DirectoryScanner surefireDirectoryScanner )
+    {
+        super( surefireDirectoryScanner );
+    }
+
     public JUnitDirectoryTestSuite( File basedir, ArrayList includes, 
ArrayList excludes )
     {
         super( basedir, includes, excludes );

Modified: 
maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4DirectoryTestSuite.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4DirectoryTestSuite.java?rev=1039777&r1=1039776&r2=1039777&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4DirectoryTestSuite.java
 (original)
+++ 
maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4DirectoryTestSuite.java
 Sat Nov 27 22:41:23 2010
@@ -22,6 +22,7 @@ package org.apache.maven.surefire.junit4
 import org.apache.maven.surefire.suite.AbstractDirectoryTestSuite;
 import org.apache.maven.surefire.testset.SurefireTestSet;
 import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.DirectoryScanner;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -36,11 +37,18 @@ import java.util.ArrayList;
 public class JUnit4DirectoryTestSuite
     extends AbstractDirectoryTestSuite
 {
+    // Remove when we no longer build with surefire 2.5
     public JUnit4DirectoryTestSuite( File basedir, ArrayList includes, 
ArrayList excludes )
     {
         super( basedir, includes, excludes );
     }
 
+    public JUnit4DirectoryTestSuite( DirectoryScanner surefireDirectoryScanner 
)
+    {
+        super( surefireDirectoryScanner );
+    }
+
+
     /**
      * This method will be called for each class to be run as a test. It 
returns
      * a surefire test set that will later be executed.

Added: 
maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java?rev=1039777&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
 (added)
+++ 
maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
 Sat Nov 27 22:41:23 2010
@@ -0,0 +1,119 @@
+package org.apache.maven.surefire.junit4;
+/*
+ * 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.providerapi.FileScanningProvider;
+import org.apache.maven.surefire.providerapi.ProviderPropertiesAware;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
+import org.apache.maven.surefire.providerapi.TestSuiteDefinitionAware;
+import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.testset.TestSuiteDefinition;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+/**
+ * @author Kristian Rosenvold
+ */
+...@suppresswarnings( { "UnusedDeclaration" } )
+public class JUnit4Provider
+    extends FileScanningProvider
+    implements SurefireProvider, ProviderPropertiesAware, 
TestSuiteDefinitionAware
+{
+
+    private Properties providerProperties;
+
+    private TestSuiteDefinition testSuiteDefinition;
+
+
+    @SuppressWarnings( { "UnnecessaryUnboxing" } )
+    public RunResult invoke()
+        throws TestSetFailedException, ReporterException
+    {
+        JUnit4DirectoryTestSuite suite = getSuite();
+        suite.locateTestSets( getTestsClassLoader() );
+        if ( testSuiteDefinition.getTestForFork() != null )
+        {
+            suite.execute( testSuiteDefinition.getTestForFork(), 
getReporterManagerFactory(), getTestsClassLoader() );
+        }
+        else
+        {
+            suite.execute( getReporterManagerFactory(), getTestsClassLoader() 
);
+        }
+        return RunResult.totalCountOnly( suite.getNumTests() );
+    }
+
+    private JUnit4DirectoryTestSuite getSuite()
+    {
+        return new JUnit4DirectoryTestSuite( getDirectoryScanner() );
+
+    }
+
+    public Iterator getSuites()
+    {
+        try
+        {
+            return getSuite().locateTestSets( getTestsClassLoader() 
).keySet().iterator();
+        }
+        catch ( TestSetFailedException e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+
+
+    public void setProviderProperties( Properties providerProperties )
+    {
+        this.providerProperties = providerProperties;
+    }
+
+    public void setTestSuiteDefinition( TestSuiteDefinition 
testSuiteDefinition )
+    {
+        this.testSuiteDefinition = testSuiteDefinition;
+    }
+
+
+    private void upgradeCheck( JUnit4DirectoryTestSuite suite )
+        throws TestSetFailedException
+    {
+        if ( isJunit4UpgradeCheck() && 
suite.getClassesSkippedByValidation().size() > 0 )
+        {
+            StringBuilder reason = new StringBuilder();
+            reason.append( "Updated check failed\n" );
+            reason.append( "There are tests that would be run with junit4 / 
surefire 2.6 but not with [2.7,):\n" );
+            for ( Object o : suite.getClassesSkippedByValidation() )
+            {
+                Class testClass = (Class) o;
+                reason.append( "   " );
+                reason.append( testClass.getCanonicalName() );
+                reason.append( "\n" );
+            }
+            throw new TestSetFailedException( reason.toString() );
+        }
+    }
+
+    private boolean isJunit4UpgradeCheck()
+    {
+        final String property = System.getProperty( 
"surefire.junit4.upgradecheck" );
+        return property != null;
+    }
+
+}

Propchange: 
maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.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=1039777&r1=1039776&r2=1039777&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
 Sat Nov 27 22:41:23 2010
@@ -51,6 +51,8 @@ public class JUnitCoreDirectoryTestSuite
 
     private final JUnitCoreParameters jUnitCoreParameters;
 
+    private ReporterManagerFactory reporterManagerFactory;
+
 
     public JUnitCoreDirectoryTestSuite( File basedir, ArrayList includes, 
ArrayList excludes, Properties properties )
     {
@@ -58,6 +60,12 @@ public class JUnitCoreDirectoryTestSuite
         this.jUnitCoreParameters = new JUnitCoreParameters( properties );
     }
 
+    public JUnitCoreDirectoryTestSuite( DirectoryScanner directoryScanner, 
JUnitCoreParameters jUnitCoreParameters, ReporterManagerFactory 
reporterManagerFactory )
+    {
+        this.directoryScanner = directoryScanner;
+        this.jUnitCoreParameters = jUnitCoreParameters;
+        this.reporterManagerFactory = reporterManagerFactory;
+    }
 
     public void execute( ReporterManagerFactory reporterManagerFactory, 
ClassLoader classLoader )
         throws ReporterException, TestSetFailedException
@@ -79,6 +87,7 @@ public class JUnitCoreDirectoryTestSuite
     public void execute( String testSetName, ReporterManagerFactory 
reporterManagerFactory, ClassLoader classLoader )
         throws ReporterException, TestSetFailedException
     {
+        this.reporterManagerFactory = reporterManagerFactory;
         if ( testsToRun == null )
         {
             throw new IllegalStateException( "You must call locateTestSets 
before calling execute" );
@@ -89,7 +98,7 @@ public class JUnitCoreDirectoryTestSuite
         {
             throw new TestSetFailedException( "Unable to find test set '" + 
testSetName + "' in suite" );
         }
-        testSet.execute( reporterManagerFactory, jUnitCoreParameters );
+        testSet.execute( this.reporterManagerFactory, jUnitCoreParameters );
     }
 
     public Map locateTestSets( ClassLoader classLoader )
@@ -105,6 +114,18 @@ public class JUnitCoreDirectoryTestSuite
         return testsToRun.getTestSets();
     }
 
+    public Map locateTestSetsImpl( ClassLoader classLoader )
+    {
+        if ( testSets != null )
+        {
+            throw new IllegalStateException( "You can't call locateTestSets 
twice" );
+        }
+
+        Class[] locatedClasses = directoryScanner.locateTestClasses( 
classLoader, new NonAbstractClassScannerFilter() );
+        testsToRun = new TestsToRun( locatedClasses );
+        return testsToRun.getTestSets();
+    }
+
     public int getNumTests()
     {
         if ( testsToRun == null )

Added: 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java?rev=1039777&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
 (added)
+++ 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
 Sat Nov 27 22:41:23 2010
@@ -0,0 +1,100 @@
+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.providerapi.FileScanningProvider;
+import org.apache.maven.surefire.providerapi.ProviderPropertiesAware;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
+import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.report.RunStatistics;
+import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+/**
+ * @author Kristian Rosenvold
+ */
+...@suppresswarnings( { "UnusedDeclaration" } )
+public class JUnitCoreProvider
+    extends FileScanningProvider
+    implements SurefireProvider, ProviderPropertiesAware
+{
+    private Properties providerProperties;
+
+
+    @SuppressWarnings( { "UnnecessaryUnboxing" } )
+    public RunResult invoke()
+        throws TestSetFailedException, ReporterException
+    {
+        // Todo; Not there quite yet
+        JUnitCoreDirectoryTestSuite jUnitCoreDirectoryTestSuite = getSuite();
+
+        RunStatistics runStatistics = 
getReporterManagerFactory().getGlobalRunStatistics();
+
+        jUnitCoreDirectoryTestSuite.locateTestSets( getTestsClassLoader() );
+        int totalTests = 0;
+
+        int testCount = jUnitCoreDirectoryTestSuite.getNumTests();
+        if ( testCount > 0 )
+        {
+            totalTests += testCount;
+        }
+
+        if ( totalTests == 0 && getFailifNoTests().booleanValue() )
+        {
+            getReporterManagerFactory().createReporterManager().writeMessage( 
"There are no tests to run." );
+            return RunResult.No_Tests;
+        }
+
+        // getLog().info( "Concurrency config is " + 
getProperties().toString() );
+
+        if ( getTestSuiteDefinition().getTestForFork() != null )
+        {
+            jUnitCoreDirectoryTestSuite.execute( 
getTestSuiteDefinition().getTestForFork(), getReporterManagerFactory(),
+                                                 getTestsClassLoader() );
+        }
+        else
+        {
+            jUnitCoreDirectoryTestSuite.execute( getReporterManagerFactory(), 
getTestsClassLoader() );
+        }
+
+        jUnitCoreDirectoryTestSuite.execute( getReporterManagerFactory(), 
getTestsClassLoader() );
+
+        return runStatistics.getRunResult();
+    }
+
+    private JUnitCoreDirectoryTestSuite getSuite()
+    {
+        return new JUnitCoreDirectoryTestSuite( getDirectoryScanner(), new 
JUnitCoreParameters( providerProperties ),
+                                                getReporterManagerFactory() );
+    }
+
+    public Iterator getSuites()
+    {
+        return getSuite().locateTestSetsImpl( getTestsClassLoader() 
).entrySet().iterator();
+    }
+
+
+    public void setProviderProperties( Properties providerProperties )
+    {
+        this.providerProperties = providerProperties;
+    }
+}

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

Modified: 
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=1039777&r1=1039776&r2=1039777&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java
 (original)
+++ 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java
 Sat Nov 27 22:41:23 2010
@@ -39,7 +39,6 @@ class TestsToRun
     Map<String, JUnitCoreTestSet> testSets;
 
     public TestsToRun( Class... locatedClasses )
-        throws TestSetFailedException
     {
         this.locatedClasses = locatedClasses;
         testSets = new HashMap<String, JUnitCoreTestSet>();
@@ -50,7 +49,7 @@ class TestsToRun
 
             if ( testSets.containsKey( testSet.getName() ) )
             {
-                throw new TestSetFailedException( "Duplicate test set '" + 
testSet.getName() + "'" );
+                throw new RuntimeException( "Duplicate test set '" + 
testSet.getName() + "'" );
             }
             testSets.put( testSet.getName(), testSet );
             testCount++;

Modified: 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java?rev=1039777&r1=1039776&r2=1039777&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java
 (original)
+++ 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java
 Sat Nov 27 22:41:23 2010
@@ -23,6 +23,7 @@ package org.apache.maven.surefire.junitc
 import junit.framework.Assert;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
+import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.report.RunStatistics;
 import org.apache.maven.surefire.testset.TestSetFailedException;
@@ -32,6 +33,7 @@ import org.junit.runner.Computer;
 import org.junit.runner.JUnitCore;
 
 import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.List;
@@ -399,6 +401,7 @@ public class ConcurrentReportingRunListe
         Object[] reporter = new 
Object[]{MockReporter.class.getCanonicalName(), new Object[] {} };
         final List<Object> objects = new ArrayList();
         objects.add( reporter );
+        ReporterConfiguration reporterConfiguration = new 
ReporterConfiguration( new File( "." ), Boolean.TRUE);
         return new ReporterManagerFactory(objects, 
this.getClass().getClassLoader());
     }
 

Modified: 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java?rev=1039777&r1=1039776&r2=1039777&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java
 (original)
+++ 
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java
 Sat Nov 27 22:41:23 2010
@@ -18,6 +18,7 @@ package org.apache.maven.surefire.junitc
 
 import junit.framework.Assert;
 import org.apache.maven.surefire.report.ConsoleReporter;
+import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -26,6 +27,7 @@ import org.junit.runner.JUnitCore;
 import org.junit.runner.Result;
 import org.junit.runner.notification.Failure;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -119,6 +121,8 @@ public class MavenSurefireJUnit47RunnerT
       List reportDefinitions = new ArrayList();
       reportDefinitions.add(reportDefinition);
 
+      ReporterConfiguration reporterConfiguration = new ReporterConfiguration( 
new File( "." ), Boolean.TRUE );
+
       ReporterManagerFactory reporterManagerFactory = new 
ReporterManagerFactory(reportDefinitions, this.getClass().getClassLoader());
 
       ConcurrentReportingRunListener concurrentReportingRunListener = 
ConcurrentReportingRunListener.createInstance(

Added: 
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java?rev=1039777&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
 (added)
+++ 
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
 Sat Nov 27 22:41:23 2010
@@ -0,0 +1,137 @@
+package org.apache.maven.surefire.testng;
+/*
+ * 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.providerapi.FileScanningProvider;
+import org.apache.maven.surefire.providerapi.ProviderPropertiesAware;
+import org.apache.maven.surefire.providerapi.ReporterConfigurationAware;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
+import org.apache.maven.surefire.providerapi.TestArtifactInfoAware;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.suite.SurefireTestSuite;
+import org.apache.maven.surefire.testset.TestArtifactInfo;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.testset.TestSuiteDefinition;
+import org.apache.maven.surefire.util.DefaultDirectoryScanner;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+
+/**
+ * @author Kristian Rosenvold
+ * @noinspection UnusedDeclaration
+ */
+public class TestNGProvider
+    extends FileScanningProvider
+    implements SurefireProvider, ProviderPropertiesAware, 
TestArtifactInfoAware, ReporterConfigurationAware
+{
+    private Properties providerProperties;
+
+    private TestArtifactInfo testArtifactInfo;
+
+    private ReporterConfiguration reporterConfiguration;
+
+
+    public RunResult invoke()
+        throws TestSetFailedException, ReporterException
+    {
+        SurefireTestSuite suite = getActiveSuite();
+        suite.locateTestSets( getTestsClassLoader() );
+        if ( getTestSuiteDefinition().getTestForFork() != null )
+        {
+            suite.execute( getTestSuiteDefinition().getTestForFork(), 
getReporterManagerFactory(),
+                           getTestsClassLoader() );
+        }
+        else
+        {
+            suite.execute( getReporterManagerFactory(), getTestsClassLoader() 
);
+        }
+        return RunResult.totalCountOnly( suite.getNumTests() );
+    }
+
+    boolean isTestNGXmlTestSuite( TestSuiteDefinition testSuiteDefinition )
+    {
+        return testSuiteDefinition.getSuiteXmlFiles() != null && 
testSuiteDefinition.getSuiteXmlFiles().length > 0 &&
+            testSuiteDefinition.getRequestedTest() == null;
+
+    }
+
+    private DefaultDirectoryScanner getDefaultDirectoryScanner()
+    {
+        return (DefaultDirectoryScanner) getDirectoryScanner();  // A hack to 
get hold of parameters
+    }
+
+    private TestNGDirectoryTestSuite getDirectorySuite()
+    {
+        final DefaultDirectoryScanner defaultDirectoryScanner = 
getDefaultDirectoryScanner();
+        return new TestNGDirectoryTestSuite( 
defaultDirectoryScanner.getBasedir(),
+                                             new ArrayList( 
defaultDirectoryScanner.getIncludes() ),
+                                             new ArrayList( 
defaultDirectoryScanner.getExcludes() ),
+                                             
getTestSuiteDefinition().getTestSourceDirectory().toString(),
+                                             testArtifactInfo.getVersion(), 
testArtifactInfo.getClassifier(),
+                                             providerProperties, 
reporterConfiguration.getReportsDirectory() );
+    }
+
+    private TestNGXmlTestSuite getXmlSuite()
+    {
+        return new TestNGXmlTestSuite( 
getTestSuiteDefinition().getSuiteXmlFiles(),
+                                       
getTestSuiteDefinition().getTestSourceDirectory().toString(),
+                                       testArtifactInfo.getVersion(), 
testArtifactInfo.getClassifier(),
+                                       providerProperties, 
reporterConfiguration.getReportsDirectory() );
+    }
+
+
+    public SurefireTestSuite getActiveSuite()
+    {
+        return isTestNGXmlTestSuite( getTestSuiteDefinition() )
+            ? (SurefireTestSuite) getXmlSuite()
+            : getDirectorySuite();
+    }
+
+    public Iterator getSuites()
+    {
+        try
+        {
+            return getActiveSuite().locateTestSets( getTestsClassLoader() 
).keySet().iterator();
+        }
+        catch ( TestSetFailedException e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+
+
+    public void setProviderProperties( Properties providerProperties )
+    {
+        this.providerProperties = providerProperties;
+    }
+
+    public void setTestArtifactInfo( TestArtifactInfo testArtifactInfo )
+    {
+        this.testArtifactInfo = testArtifactInfo;
+    }
+
+    public void setReporterConfiguration( ReporterConfiguration 
reporterConfiguration )
+    {
+        this.reporterConfiguration = reporterConfiguration;
+    }
+}

Propchange: 
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to