maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1040708 [1/2] - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ maven-surefire-common/src/test/java/org/apac...
Date Tue, 30 Nov 2010 19:10:59 GMT
Author: krosenvold
Date: Tue Nov 30 19:10:57 2010
New Revision: 1040708

URL: http://svn.apache.org/viewvc?rev=1040708&view=rev
Log:
[SUREFIRE-141] Booter->provider api getting pretty close to done.

Still need provider lookup mechanism and documentation

Added:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BaseProviderFactory.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderFactory.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireClassLoadersAware.java   (contents, props changed)
      - copied, changed from r1040706, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestClassLoaderAware.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestRequestAware.java
      - copied, changed from r1040706, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3ProviderFactory.java
      - copied, changed from r1040706, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java
    maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4ProviderFactory.java   (contents, props changed)
      - copied, changed from r1040706, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProviderFactory.java
      - copied, changed from r1040706, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProviderFactory.java   (with props)
Removed:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ProviderInvoker.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/FileScanningProvider.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestClassLoaderAware.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java
Modified:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerTest.java
    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/booter/SurefireReflector.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory2.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
    maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
    maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Tue Nov 30 19:10:57 2010
@@ -227,8 +227,9 @@ public abstract class AbstractSurefireMo
         final ClasspathConfiguration classpathConfiguration =
             new ClasspathConfiguration( isEnableAssertions(), isChildDelegation() );
 
+        List reports = getReporters( forkConfiguration.isForking() );
         ReporterConfiguration reporterConfiguration =
-            new ReporterConfiguration( getReportsDirectory(), Boolean.valueOf( isTrimStackTrace() ) );
+            new ReporterConfiguration( reports, getReportsDirectory(), Boolean.valueOf( isTrimStackTrace() ) );
 
         Artifact surefireArtifact =
             (Artifact) getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" );
@@ -241,7 +242,7 @@ public abstract class AbstractSurefireMo
 
         Artifact junitArtifact;
         Artifact testNgArtifact;
-        String providerName;
+        String providerFactoryName;
         try
         {
             addArtifact( forkConfiguration.getBootClasspathConfiguration(), surefireArtifact );
@@ -250,7 +251,7 @@ public abstract class AbstractSurefireMo
 
             testNgArtifact = getTestNgArtifact();
 
-            providerName =
+            providerFactoryName =
                 setCorrectProvider( forkConfiguration.getBootClasspathConfiguration(), classpathConfiguration,
                                     surefireArtifact, junitArtifact, testNgArtifact );
         }
@@ -304,14 +305,13 @@ public abstract class AbstractSurefireMo
                                                                          Boolean.valueOf( failIfNoTests ) );
         }
 
-        List reports = getReporters( forkConfiguration.isForking() );
         Properties providerProperties = getProperties();
         if ( providerProperties == null )
         {
             providerProperties = new Properties();
         }
         ProviderConfiguration surefireStarterConfiguration =
-            new ProviderConfiguration( providerName, classpathConfiguration,
+            new ProviderConfiguration( providerFactoryName, classpathConfiguration,
                                        forkConfiguration.getClassLoaderConfiguration(), forkConfiguration.isForking(),
                                        false, isRedirectTestOutputToFile() );
 
@@ -446,7 +446,7 @@ public abstract class AbstractSurefireMo
         if ( testNgArtifact != null )
         {
             setTestNgProvider( bootClasspathConfiguration, classpathConfiguration, surefireArtifact, testNgArtifact );
-            return "org.apache.maven.surefire.testng.TestNGProvider";
+            return "org.apache.maven.surefire.testng.TestNGProviderFactory";
 
         }
         else if ( junitArtifact != null && isAnyJunit4( junitArtifact ) )
@@ -455,12 +455,12 @@ public abstract class AbstractSurefireMo
             {
                 convertJunitCoreParameters();
                 setProvider( classpathConfiguration, "surefire-junit47", surefireArtifact.getBaseVersion(), null );
-                return "org.apache.maven.surefire.junitcore.JUnitCoreProvider";
+                return "org.apache.maven.surefire.junitcore.JUnitCoreProviderFactory";
             }
             else
             {
                 setProvider( classpathConfiguration, "surefire-junit4", surefireArtifact.getBaseVersion(), null );
-                return "org.apache.maven.surefire.junit4.JUnit4Provider";
+                return "org.apache.maven.surefire.junit4.JUnit4ProviderFactory";
             }
         }
         else
@@ -468,7 +468,7 @@ public abstract class AbstractSurefireMo
             // add the JUnit provider as default - it doesn't require JUnit to be present,
             // since it supports POJO tests.
             setProvider( classpathConfiguration, "surefire-junit", surefireArtifact.getBaseVersion(), null );
-            return "org.apache.maven.surefire.junit.JUnit3Provider";
+            return "org.apache.maven.surefire.junit.JUnit3ProviderFactory";
         }
     }
 

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java Tue Nov 30 19:10:57 2010
@@ -151,7 +151,7 @@ public class BooterSerializer
         properties.setProperty( BooterConstants.FAILIFNOTESTS,
                                 String.valueOf( booterConfiguration.isFailIfNoTests() ) );
         properties.setProperty( BooterConstants.PROVIDER_CONFIGURATION,
-                                surefireStarterConfiguration.getProviderClassName() );
+                                surefireStarterConfiguration.getProviderFactoryClassName() );
     }
 
     public File writePropertiesFile( String name, Properties properties )

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java Tue Nov 30 19:10:57 2010
@@ -150,7 +150,7 @@ public class ForkStarter
             }
             showHeading = false;
         }
-
+        // At this place, show aggregated results ?
         return globalResult;
     }
 

Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerTest.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerTest.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerTest.java Tue Nov 30 19:10:57 2010
@@ -139,7 +139,7 @@ public class BooterDeserializerTest
     {
         BooterConfiguration reloaded = getReloladedConfig();
 
-        assertEquals( "com.provider", reloaded.getSurefireStarterConfiguration().getProviderClassName() );
+        assertEquals( "com.provider", reloaded.getSurefireStarterConfiguration().getProviderFactoryClassName() );
 
     }
 
@@ -193,7 +193,7 @@ public class BooterDeserializerTest
     {
         ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( true, true );
 
-        ReporterConfiguration reporterConfiguration = new ReporterConfiguration( new File( "." ), Boolean.TRUE );
+        ReporterConfiguration reporterConfiguration = new ReporterConfiguration(reports, new File( "." ), Boolean.TRUE );
         TestRequest testSuiteDefinition =
             new TestRequest( getSuiteXmlFileStrings(), getTEstSourceDirectory(), aUserRequestedTest );
         ProviderConfiguration surefireStarterConfiguration =

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=1040708&r1=1040707&r2=1040708&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 Tue Nov 30 19:10:57 2010
@@ -578,13 +578,13 @@ public class SurefirePlugin
             getLog().info(
                 StringUtils.capitalizeFirstLetter( getPluginName() ) + " report directory: " + getReportsDirectory() );
 
-            ForkStarter booter = new ForkStarter( booterConfiguration, reportsDirectory, forkConfiguration );
-            booter.setForkedProcessTimeoutInSeconds( getForkedProcessTimeoutInSeconds() );
+            ForkStarter forkStarter = new ForkStarter( booterConfiguration, reportsDirectory, forkConfiguration );
+            forkStarter.setForkedProcessTimeoutInSeconds( getForkedProcessTimeoutInSeconds() );
 
             int result;
             try
             {
-                result = booter.run();
+                result = forkStarter.run();
             }
             catch ( SurefireBooterForkException e )
             {

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java Tue Nov 30 19:10:57 2010
@@ -19,13 +19,12 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
-import org.apache.maven.surefire.ProviderInvoker;
 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.SurefireClassLoadersAware;
 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.providerapi.TestRequestAware;
 import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.DirectoryScannerParameters;
@@ -51,8 +50,6 @@ public class SurefireReflector
 {
     private final ClassLoader classLoader;
 
-    private final Class providerInvoker;
-
     private final Class reporterConfiguration;
 
     private final Class testSuiteDefinition;
@@ -77,12 +74,13 @@ public class SurefireReflector
 
     private static final Class[] noargs = new Class[0];
 
+    private static final Object[] noargsValues = new Object[0];
+
     public SurefireReflector( ClassLoader surefireClassLoader )
     {
         this.classLoader = surefireClassLoader;
         try
         {
-            providerInvoker = surefireClassLoader.loadClass( ProviderInvoker.class.getName() );
             reporterConfiguration = surefireClassLoader.loadClass( ReporterConfiguration.class.getName() );
             testSuiteDefinition = surefireClassLoader.loadClass( TestRequest.class.getName() );
             testArtifactInfo = surefireClassLoader.loadClass( TestArtifactInfo.class.getName() );
@@ -90,8 +88,8 @@ public class SurefireReflector
             directoryScannerParameters = surefireClassLoader.loadClass( DirectoryScannerParameters.class.getName() );
             directoryScannerParametersAware =
                 surefireClassLoader.loadClass( DirectoryScannerParametersAware.class.getName() );
-            testSuiteDefinitionAware = surefireClassLoader.loadClass( TestSuiteDefinitionAware.class.getName() );
-            testClassLoaderAware = surefireClassLoader.loadClass( TestClassLoaderAware.class.getName() );
+            testSuiteDefinitionAware = surefireClassLoader.loadClass( TestRequestAware.class.getName() );
+            testClassLoaderAware = surefireClassLoader.loadClass( SurefireClassLoadersAware.class.getName() );
             reporterConfigurationAware = surefireClassLoader.loadClass( ReporterConfigurationAware.class.getName() );
             providerPropertiesAware = surefireClassLoader.loadClass( ProviderPropertiesAware.class.getName() );
             runResult = surefireClassLoader.loadClass( RunResult.class.getName() );
@@ -112,8 +110,8 @@ public class SurefireReflector
         final Integer getErrors = (Integer) invokeGetter( result, "getErrors" );
         final Integer getSkipped = (Integer) invokeGetter( result, "getSkipped" );
         final Integer getFailures = (Integer) invokeGetter( result, "getFailures" );
-        return new RunResult( getCompletedCount1.intValue(), getErrors.intValue(), getSkipped.intValue(),
-                              getFailures.intValue() );
+        return new RunResult( getCompletedCount1.intValue(), getErrors.intValue(),
+                              getFailures.intValue(), getSkipped.intValue() );
 
     }
 
@@ -144,24 +142,6 @@ public class SurefireReflector
     }
 
 
-    public int runProvider( ReporterConfiguration reporterConfiguration, List reportDefinitions,
-                            ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Properties results,
-                            Boolean failIfNoTests, TestRequest testSuiteDefinition, TestArtifactInfo testArtifactInfo,
-                            String providerClassName, DirectoryScannerParameters dirScannerParams, Object forkTestSet )
-    {
-        Object surefire = instantiateProviderInvoker();
-        Method run = getRunMethod(
-            new Class[]{ this.reporterConfiguration, List.class, ClassLoader.class, ClassLoader.class, Properties.class,
-                Boolean.class, this.testSuiteDefinition, this.testArtifactInfo, String.class,
-                this.directoryScannerParameters, Object.class } );
-
-        Object[] args = { createReporterConfiguration( reporterConfiguration ), reportDefinitions, surefireClassLoader,
-            testsClassLoader, results, failIfNoTests, createTestSuiteDefinition( testSuiteDefinition ),
-            createTestArtifactInfo( testArtifactInfo ), providerClassName,
-            createDirectoryScannerParameters( dirScannerParams ), forkTestSet };
-        return invokeRunMethod( surefire, run, args );
-    }
-
     Object createTestSuiteDefinition( TestRequest suiteDefinition )
     {
         if ( suiteDefinition == null )
@@ -204,8 +184,8 @@ public class SurefireReflector
     Object createReporterConfiguration( ReporterConfiguration reporterConfiguration )
     {
         Constructor constructor =
-            getConstructor( this.reporterConfiguration, new Class[]{ File.class, Boolean.class } );
-        return newInstance( constructor, new Object[]{ reporterConfiguration.getReportsDirectory(),
+            getConstructor( this.reporterConfiguration, new Class[]{ List.class, File.class, Boolean.class } );
+        return newInstance( constructor, new Object[]{ reporterConfiguration.getReports(), reporterConfiguration.getReportsDirectory(),
             reporterConfiguration.isTrimStackTrace() } );
     }
 
@@ -241,12 +221,12 @@ public class SurefireReflector
         }
     }
 
-    public Object newInstance( String providerClassName )
+    public Object createProviderFactory( String providerFactoryClassName )
     {
         try
         {
 
-            Class clazz = classLoader.loadClass( providerClassName );
+            Class clazz = classLoader.loadClass( providerFactoryClassName );
             return clazz.newInstance();
         }
         catch ( InstantiationException e )
@@ -262,6 +242,12 @@ public class SurefireReflector
             throw new RuntimeException( e );
         }
     }
+    public Object instantiateProviderByFactory( Object providerFactory )
+    {
+
+            Method createProvider = getMethod( providerFactory, "createProvider", noargs );
+        return invokeMethod( providerFactory, createProvider, noargsValues );
+    }
 
     public static Object getSuites( Object surefireProvider )
     {
@@ -326,41 +312,11 @@ public class SurefireReflector
 
     }
 
-    public Object instantiateProviderInvoker()
-        throws RuntimeException
-    {
-        try
-        {
-            return providerInvoker.newInstance();
-        }
-        catch ( InstantiationException e )
-        {
-            throw new RuntimeException( "When instanitating surefire", e );
-        }
-        catch ( IllegalAccessException e )
-        {
-            throw new RuntimeException( "When instanitating surefire", e );
-        }
-    }
-
-    private Method getRunMethod( Class[] parameters )
-    {
-        try
-        {
-            return providerInvoker.getMethod( "run", parameters );
-        }
-        catch ( NoSuchMethodException e )
-        {
-            throw new RuntimeException( "When finding run method", e );
-        }
-    }
-
     private static Object invokeGetter( Object instance, String methodName )
     {
         try
         {
             final Method method = instance.getClass().getMethod( methodName, noargs );
-            final Object[] noargsValues = new Object[0];
             return method.invoke( instance, noargsValues );
         }
         catch ( NoSuchMethodException e )
@@ -427,7 +383,7 @@ public class SurefireReflector
     void setTestSuiteDefinition( Object o, TestRequest testSuiteDefinition1 )
     {
         final Object param = createTestSuiteDefinition( testSuiteDefinition1 );
-        final Method setter = getMethod( o, "setTestSuiteDefinition", new Class[]{ testSuiteDefinition } );
+        final Method setter = getMethod( o, "setTestRequest", new Class[]{ testSuiteDefinition } );
         invokeSetter( o, setter, param );
     }
 
@@ -459,10 +415,6 @@ public class SurefireReflector
         }
     }
 
-    boolean isReporterConfigurationAwareAware( Object o )
-    {
-        return reporterConfigurationAware.isAssignableFrom( o.getClass() );
-    }
 
     void setReporterConfiguration( Object o, ReporterConfiguration reporterConfiguration )
     {
@@ -471,11 +423,16 @@ public class SurefireReflector
         invokeSetter( o, setter, param );
     }
 
-    public void setTestClassLoaderAware( Object o, ClassLoader testClassLoader )
+    boolean isReporterConfigurationAwareAware( Object o )
+    {
+        return reporterConfigurationAware.isAssignableFrom( o.getClass() );
+    }
+
+    public void setTestClassLoaderAware( Object o, ClassLoader surefireClassLoader, ClassLoader testClassLoader)
     {
         if ( isTestClassLoaderAware( o ) )
         {
-            setTestClassLoader( o, testClassLoader );
+            setTestClassLoader( o, surefireClassLoader, testClassLoader );
         }
     }
 
@@ -484,10 +441,10 @@ public class SurefireReflector
         return testClassLoaderAware.isAssignableFrom( o.getClass() );
     }
 
-    void setTestClassLoader( Object o, ClassLoader aClassLoader )
+    void setTestClassLoader( Object o, ClassLoader surefireClassLoader, ClassLoader testClassLoader )
     {
-        final Method setter = getMethod( o, "setTestClassLoader", new Class[]{ ClassLoader.class } );
-        invokeSetter( o, setter, aClassLoader );
+        final Method setter = getMethod( o, "setClassLoaders", new Class[]{ ClassLoader.class, ClassLoader.class  } );
+        invokeMethod( o, setter, new Object[]{ surefireClassLoader, testClassLoader } );
     }
 
     public void setTestArtifactInfoAware( Object o, TestArtifactInfo testArtifactInfo1 )

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BaseProviderFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BaseProviderFactory.java?rev=1040708&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BaseProviderFactory.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BaseProviderFactory.java Tue Nov 30 19:10:57 2010
@@ -0,0 +1,124 @@
+package org.apache.maven.surefire.providerapi;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.report.ReporterManagerFactory2;
+import org.apache.maven.surefire.testset.DirectoryScannerParameters;
+import org.apache.maven.surefire.testset.TestRequest;
+import org.apache.maven.surefire.util.DefaultDirectoryScanner;
+import org.apache.maven.surefire.util.DirectoryScanner;
+
+import java.util.Properties;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public abstract class BaseProviderFactory
+    implements DirectoryScannerParametersAware, ReporterConfigurationAware, SurefireClassLoadersAware, TestRequestAware,
+    ProviderFactory, ProviderPropertiesAware
+{
+    private Properties providerProperties;
+
+    private DirectoryScannerParameters directoryScannerParameters;
+
+    private ReporterConfiguration reporterConfiguration;
+
+    private ClassLoader testClassLoader;
+
+    private ClassLoader surefireClassLoader;
+
+    private TestRequest testRequest;
+
+
+    protected DirectoryScanner getDirectoryScanner()
+    {
+        if ( directoryScannerParameters == null )
+        {
+            return null;
+        }
+        return new DefaultDirectoryScanner( directoryScannerParameters.getTestClassesDirectory(),
+                                            directoryScannerParameters.getIncludes(),
+                                            directoryScannerParameters.getExcludes() );
+    }
+
+    protected ReporterManagerFactory getReporterManagerFactory()
+    {
+        ReporterManagerFactory reporterManagerFactory =
+            new ReporterManagerFactory2( surefireClassLoader, reporterConfiguration );
+        if ( providerProperties != null )
+        {
+            reporterManagerFactory.getGlobalRunStatistics().initResultsFromProperties( providerProperties );
+        }
+        return reporterManagerFactory;
+    }
+
+    public void setDirectoryScannerParameters( DirectoryScannerParameters directoryScannerParameters )
+    {
+        this.directoryScannerParameters = directoryScannerParameters;
+    }
+
+    public void setReporterConfiguration( ReporterConfiguration reporterConfiguration )
+    {
+        this.reporterConfiguration = reporterConfiguration;
+    }
+
+    public void setClassLoaders( ClassLoader surefireClassLoader, ClassLoader testClassLoader )
+    {
+        this.surefireClassLoader = surefireClassLoader;
+        this.testClassLoader = testClassLoader;
+    }
+
+    public void setTestRequest( TestRequest testRequest )
+    {
+        this.testRequest = testRequest;
+    }
+
+    protected DirectoryScannerParameters getDirectoryScannerParameters()
+    {
+        return directoryScannerParameters;
+    }
+
+    protected ReporterConfiguration getReporterConfiguration()
+    {
+        return reporterConfiguration;
+    }
+
+    protected TestRequest getTestRequest()
+    {
+        return testRequest;
+    }
+
+    protected ClassLoader getTestClassLoader()
+    {
+        return testClassLoader;
+    }
+
+    protected ClassLoader getSurefireClassLoader()
+    {
+        return surefireClassLoader;
+    }
+
+    public void setProviderProperties( Properties providerProperties )
+    {
+        this.providerProperties = providerProperties;
+    }
+}

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

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderFactory.java?rev=1040708&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderFactory.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderFactory.java Tue Nov 30 19:10:57 2010
@@ -0,0 +1,9 @@
+package org.apache.maven.surefire.providerapi;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public interface ProviderFactory
+{
+    SurefireProvider createProvider();
+}

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

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireClassLoadersAware.java (from r1040706, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestClassLoaderAware.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireClassLoadersAware.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireClassLoadersAware.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestClassLoaderAware.java&r1=1040706&r2=1040708&rev=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestClassLoaderAware.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireClassLoadersAware.java Tue Nov 30 19:10:57 2010
@@ -22,7 +22,7 @@ package org.apache.maven.surefire.provid
 /**
  * @author Kristian Rosenvold
  */
-public interface TestClassLoaderAware
+public interface SurefireClassLoadersAware
 {
-    void setTestClassLoader( ClassLoader classLoader );
+    void setClassLoaders( ClassLoader surefireClassLoader, ClassLoader testClassLoader);
 }

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

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireClassLoadersAware.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestRequestAware.java (from r1040706, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestRequestAware.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestRequestAware.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java&r1=1040706&r2=1040708&rev=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestRequestAware.java Tue Nov 30 19:10:57 2010
@@ -24,7 +24,7 @@ import org.apache.maven.surefire.testset
 /**
  * @author Kristian Rosenvold
  */
-public interface TestSuiteDefinitionAware
+public interface TestRequestAware
 {
-    void setTestSuiteDefinition( TestRequest testSuiteDefinition );
+    void setTestRequest( TestRequest testSuiteDefinition );
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java Tue Nov 30 19:10:57 2010
@@ -20,21 +20,25 @@ package org.apache.maven.surefire.report
  */
 
 import java.io.File;
+import java.util.List;
 
 /**
  * @author Kristian Rosenvold
  */
 public class ReporterConfiguration
 {
-    final File reportsDirectory;
+    private final List reports;
+
+    private final File reportsDirectory;
 
     /**
      * A non-null Boolean value
      */
-    final Boolean trimStackTrace;
+    private final Boolean trimStackTrace;
 
-    public ReporterConfiguration( File reportsDirectory, Boolean trimStackTrace )
+    public ReporterConfiguration( List reports, File reportsDirectory, Boolean trimStackTrace )
     {
+        this.reports = reports;
         this.reportsDirectory = reportsDirectory;
         this.trimStackTrace = trimStackTrace;
     }
@@ -49,4 +53,8 @@ public class ReporterConfiguration
         return trimStackTrace;
     }
 
+    public List getReports()
+    {
+        return reports;
+    }
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java Tue Nov 30 19:10:57 2010
@@ -47,11 +47,11 @@ public class ReporterManagerFactory
 
     protected final ClassLoader surefireClassLoader;
 
-    private final RunStatistics globalRunStatistics = new RunStatistics();
+    protected final RunStatistics globalRunStatistics = new RunStatistics();
 
-    private ReporterManager first;
+    protected ReporterManager first;
 
-    private final Object lock = new Object();
+    protected final Object lock = new Object();
 
 
     public ReporterManagerFactory( List reportDefinitions, ClassLoader surefireClassLoader )

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory2.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory2.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory2.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory2.java Tue Nov 30 19:10:57 2010
@@ -19,10 +19,6 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
-import org.apache.maven.surefire.report.Reporter;
-import org.apache.maven.surefire.report.ReporterConfiguration;
-import org.apache.maven.surefire.report.ReporterManager;
-import org.apache.maven.surefire.report.RunStatistics;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 
 import java.lang.reflect.Constructor;
@@ -46,20 +42,16 @@ import java.util.List;
 public class ReporterManagerFactory2
     extends ReporterManagerFactory
 {
-    private final RunStatistics globalRunStatistics = new RunStatistics();
-
-    private ReporterManager first;
-
-    private final Object lock = new Object();
-
     private final ReporterConfiguration reporterConfiguration;
 
 
-    public ReporterManagerFactory2( List reportDefinitions, ClassLoader surefireClassLoader,
-                                    ReporterConfiguration reporterConfiguration )
+    public ReporterManagerFactory2( ClassLoader surefireClassLoader, ReporterConfiguration reporterConfiguration )
     {
-        super( reportDefinitions, surefireClassLoader );
+        super( reporterConfiguration.getReports(), surefireClassLoader );
         this.reporterConfiguration = reporterConfiguration;
+/*        if (!reporterConfiguration.getClass().getClassLoader().equals(  surefireClassLoader )){
+            throw new IllegalStateException( "Skunkt classloader stuff" + reporterConfiguration.getClass().getClassLoader() + "sfc" + surefireClassLoader + "Tread" + Thread.currentThread().getContextClassLoader());
+        }*/
     }
 
 
@@ -137,7 +129,7 @@ public class ReporterManagerFactory2
             if ( params != null )
             {
                 Class[] paramTypes = new Class[1];
-                paramTypes[0] = ReporterConfiguration.class;
+                paramTypes[0] = classLoader.loadClass(ReporterConfiguration.class.getName());
 
                 Constructor constructor = clazz.getConstructor( paramTypes );
 

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java Tue Nov 30 19:10:57 2010
@@ -19,6 +19,8 @@ package org.apache.maven.surefire.suite;
  * under the License.
  */
 
+import java.util.Properties;
+
 /**
  * Represents a test-run-result; this may be from a single test run or an aggregated result.
  *
@@ -85,4 +87,5 @@ public class RunResult
         }
         return getFailures() == 0 ? SUCCESS : FAILURE;
     }
+
 }

Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java (original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java Tue Nov 30 19:10:57 2010
@@ -19,6 +19,8 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
+import java.util.ArrayList;
+
 /**
  * Test for {@link ForkingConsoleReporter}
  *
@@ -33,8 +35,14 @@ public class ForkingConsoleReporterTest
         throws Exception
     {
         super.setUp();
-        ForkingConsoleReporter consoleReporter = new ForkingConsoleReporter( new ReporterConfiguration( null, Boolean.TRUE) );
+        ReporterConfiguration reporterConfiguration = getTestReporterConfiguration();
+        ForkingConsoleReporter consoleReporter = new ForkingConsoleReporter( reporterConfiguration );
         setConsoleReporter( consoleReporter );
     }
 
+    public static ReporterConfiguration getTestReporterConfiguration()
+    {
+        return new ReporterConfiguration( new ArrayList(), null, Boolean.TRUE );
+    }
+
 }

Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java (original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java Tue Nov 30 19:10:57 2010
@@ -37,7 +37,7 @@ public class XMLReporterTest
         throws Exception
     {
         super.setUp();
-        reporter = new XMLReporter( new ReporterConfiguration( null, Boolean.TRUE ));
+        reporter = new XMLReporter( ForkingConsoleReporterTest.getTestReporterConfiguration());
         message = "junit.framework.AssertionFailedError";
         reportEntry = new ReportEntry( this.getClass().getName(), "XMLReporterTest", message,
                                        new PojoStackTraceWriter( "", "", new AssertionFailedError() ) );

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java Tue Nov 30 19:10:57 2010
@@ -191,10 +191,11 @@ public class BooterDeserializer
         ClasspathConfiguration classpathConfiguration =
             new ClasspathConfiguration( classPathUrls, surefireClassPathUrls, enableAssertions, childDelegation );
 
+        List reports = new ArrayList( reportsMap.values() );
+
         ReporterConfiguration reporterConfiguration =
-            new ReporterConfiguration( reportsDirectory, valueOf( isTrimStackTrace ) );
+            new ReporterConfiguration( reports, reportsDirectory, valueOf( isTrimStackTrace ) );
 
-        List reports = new ArrayList( reportsMap.values() );
         ProviderConfiguration surefireStarterConfiguration =
             ProviderConfiguration.inForkedVm( providerConfiguration, classpathConfiguration, classLoaderConfiguration);
         return new BooterConfiguration( surefireStarterConfiguration, reports, dirScannerParams, failIfNotests,

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java Tue Nov 30 19:10:57 2010
@@ -114,27 +114,30 @@ public class ClasspathConfiguration
     public ClassLoader createTestClassLoaderConditionallySystem( boolean useSystemClassLoader )
         throws SurefireExecutionException
     {
-        return useSystemClassLoader
-            ? ClassLoader.getSystemClassLoader()
-            : createTestClassLoader( this.childDelegation );
+        final ClassLoader classLoader =
+            useSystemClassLoader ? ClassLoader.getSystemClassLoader() : createTestClassLoader( this.childDelegation );
+        return classLoader;
     }
 
     public ClassLoader createTestClassLoader( boolean childDelegation )
         throws SurefireExecutionException
     {
-        return createClassLoaderSEE( classpathUrls, null, childDelegation );
+        final ClassLoader classLoaderSEE = createClassLoaderSEE( classpathUrls, null, childDelegation );
+        return classLoaderSEE;
     }
 
     public ClassLoader createTestClassLoader()
         throws SurefireExecutionException
     {
-        return createClassLoaderSEE( classpathUrls, null, this.childDelegation );
+        final ClassLoader classLoaderSEE = createClassLoaderSEE( classpathUrls, null, this.childDelegation );
+        return classLoaderSEE;
     }
 
     public ClassLoader createSurefireClassLoader( ClassLoader parent )
         throws SurefireExecutionException
     {
-        return createClassLoaderSEE( surefireClasspathUrls, parent, false );
+        final ClassLoader classLoaderSEE = createClassLoaderSEE( surefireClasspathUrls, parent, false );
+        return classLoaderSEE;
     }
 
     private ClassLoader createClassLoaderSEE( Classpath classPathUrls, ClassLoader parent, boolean childDelegation )

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=1040708&r1=1040707&r2=1040708&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 Tue Nov 30 19:10:57 2010
@@ -69,13 +69,13 @@ public class ForkedBooter
             if ( forkedTestSet != null )
             {
                 result = booter.runSuitesInProcess( forkedTestSet, p );
+                booterDeserializer.writePropertiesFile( surefirePropertiesFile, "surefire", p );
             }
             else
             {
                 result = booter.runSuitesInProcess( p );
             }
 
-            booterDeserializer.writePropertiesFile( surefirePropertiesFile, "surefire", p );
 
             // noinspection CallToSystemExit
             System.exit( result );

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java?rev=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java Tue Nov 30 19:10:57 2010
@@ -26,7 +26,7 @@ package org.apache.maven.surefire.booter
  */
 public class ProviderConfiguration
 {
-    private final String providerClassName;
+    private final String providerFactoryClassName;
 
     private final ClasspathConfiguration classpathConfiguration;
 
@@ -39,11 +39,11 @@ public class ProviderConfiguration
     private final boolean redirectTestOutputToFile;
 
 
-    public ProviderConfiguration( String providerClassName, ClasspathConfiguration classpathConfiguration,
+    public ProviderConfiguration( String providerFactoryClassName, ClasspathConfiguration classpathConfiguration,
                                   ClassLoaderConfiguration classLoaderConfiguration, boolean forkRequested,
                                   boolean inForkedVm, boolean redirectTestOutputToFile )
     {
-        this.providerClassName = providerClassName;
+        this.providerFactoryClassName = providerFactoryClassName;
         this.classpathConfiguration = classpathConfiguration;
         this.classLoaderConfiguration = classLoaderConfiguration;
         isForkRequested = forkRequested;
@@ -77,9 +77,9 @@ public class ProviderConfiguration
         return redirectTestOutputToFile;
     }
 
-    public String getProviderClassName()
+    public String getProviderFactoryClassName()
     {
-        return providerClassName;
+        return providerFactoryClassName;
     }
 
 }

Modified: 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=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java Tue Nov 30 19:10:57 2010
@@ -53,17 +53,19 @@ public class ProviderFactory
         Thread.currentThread().setContextClassLoader( surefireClassLoader );
 
         ProviderConfiguration starterConfiguration = booterConfiguration.getSurefireStarterConfiguration();
-        final Object o = surefireReflector.newInstance( starterConfiguration.getProviderClassName() );
-        surefireReflector.setIfDirScannerAware( o, booterConfiguration.getDirScannerParams() );
+        final Object o =
+            surefireReflector.createProviderFactory( starterConfiguration.getProviderFactoryClassName() );
         surefireReflector.setTestSuiteDefinitionAware( o, booterConfiguration.getTestSuiteDefinition() );
         surefireReflector.setProviderPropertiesAware( o, booterConfiguration.getProviderProperties() );
         surefireReflector.setReporterConfigurationAware( o, booterConfiguration.getReporterConfiguration() );
-        surefireReflector.setTestClassLoaderAware( o, testClassLoader );
+        surefireReflector.setTestClassLoaderAware( o, surefireClassLoader, testClassLoader );
         surefireReflector.setTestArtifactInfoAware( o, booterConfiguration.getTestNg() );
+        surefireReflector.setIfDirScannerAware( o, booterConfiguration.getDirScannerParams() );
 
+        Object provider = surefireReflector.instantiateProviderByFactory( o );
         Thread.currentThread().setContextClassLoader( context );
 
-        return createClassLoaderProxy( o );
+        return createClassLoaderProxy( provider );
     }
 
     private SurefireProvider createClassLoaderProxy( Object target )
@@ -86,9 +88,18 @@ public class ProviderFactory
         public Object invoke( Object proxy, Method method, Object[] args )
             throws Throwable
         {
-            Method delegateMethod = target.getClass().getMethod( method.getName(), method.getParameterTypes() );
-            final Object result = delegateMethod.invoke( target, args );
-            return surefireReflector.convertIfRunResult(result);
+            ClassLoader original = java.lang.Thread.currentThread().getContextClassLoader();
+            Thread.currentThread().setContextClassLoader( surefireClassLoader );
+            try
+            {
+                Method delegateMethod = target.getClass().getMethod( method.getName(), method.getParameterTypes() );
+                final Object result = delegateMethod.invoke( target, args );
+                return surefireReflector.convertIfRunResult( result );
+            }
+            finally
+            {
+                Thread.currentThread().setContextClassLoader( original );
+            }
         }
     }
 

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=1040708&r1=1040707&r2=1040708&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 Tue Nov 30 19:10:57 2010
@@ -19,6 +19,11 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
+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.Properties;
 
 /**
@@ -34,6 +39,7 @@ import java.util.Properties;
  */
 public class SurefireStarter
 {
+    private static final int NO_TESTS = 254;
 
     private final BooterConfiguration booterConfiguration;
 
@@ -45,29 +51,61 @@ public class SurefireStarter
     public int runSuitesInProcess( Object testSet, Properties results )
         throws SurefireExecutionException
     {
+
         // TODO: replace with plexus
+        final ProviderConfiguration starterConfiguration = booterConfiguration.getSurefireStarterConfiguration();
+        final ClasspathConfiguration classpathConfiguration = starterConfiguration.getClasspathConfiguration();
 
-        ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
-        try
-        {
-            final ProviderConfiguration starterConfiguration = booterConfiguration.getSurefireStarterConfiguration();
-            final ClasspathConfiguration classpathConfiguration = starterConfiguration.getClasspathConfiguration();
+        ClassLoader testsClassLoader = classpathConfiguration.createTestClassLoaderConditionallySystem(
+            starterConfiguration.useSystemClassLoader() );
+
+        // TODO: assertions = true shouldn't be required for this CL if we had proper separation (see TestNG)
+        ClassLoader surefireClassLoader = classpathConfiguration.createSurefireClassLoader( testsClassLoader );
+
+        RunResult runResult = invokeProvider( testSet, testsClassLoader, surefireClassLoader );
+
+        updateResultsProperties( runResult, results );
+
+        return processRunCount( runResult, surefireClassLoader );
+    }
+
+    private static final String RESULTS_ERRORS = "errors";
+
+    private static final String RESULTS_COMPLETED_COUNT = "completedCount";
 
-            ClassLoader testsClassLoader = classpathConfiguration.createTestClassLoaderConditionallySystem(
-                starterConfiguration.useSystemClassLoader() );
+    private static final String RESULTS_FAILURES = "failures";
 
-            // TODO: assertions = true shouldn't be required for this CL if we had proper separation (see TestNG)
-            ClassLoader surefireClassLoader = classpathConfiguration.createSurefireClassLoader( testsClassLoader );
+    private static final String RESULTS_SKIPPED = "skipped";
 
-            SurefireReflector reflector = new SurefireReflector( surefireClassLoader );
-
-            Thread.currentThread().setContextClassLoader( testsClassLoader );
-            return reflector.runProvider( booterConfiguration.getReporterConfiguration(),
-                                          booterConfiguration.getReports(), surefireClassLoader, testsClassLoader,
-                                          results, booterConfiguration.isFailIfNoTests(),
-                                          booterConfiguration.getTestSuiteDefinition(),
-                                          booterConfiguration.getTestNg(), starterConfiguration.getProviderClassName(),
-                                          booterConfiguration.getDirScannerParams(), testSet );
+
+    public synchronized void updateResultsProperties( RunResult runResult, Properties results )
+    {
+        results.setProperty( RESULTS_ERRORS, String.valueOf( runResult.getErrors() ) );
+        results.setProperty( RESULTS_COMPLETED_COUNT, String.valueOf( runResult.getCompletedCount() ) );
+        results.setProperty( RESULTS_FAILURES, String.valueOf( runResult.getFailures() ) );
+        results.setProperty( RESULTS_SKIPPED, String.valueOf( runResult.getSkipped() ) );
+    }
+
+    private RunResult invokeProvider( Object testSet, ClassLoader testsClassLoader, ClassLoader surefireClassLoader )
+    {
+        ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader( surefireClassLoader );
+
+        ProviderFactory providerFactory = new ProviderFactory( booterConfiguration, surefireClassLoader );
+        final SurefireProvider provider = providerFactory.createProvider( testsClassLoader );
+
+        try
+        {
+            final RunResult invoke = provider.invoke( testSet );
+            return invoke;
+        }
+        catch ( TestSetFailedException e )
+        {
+            throw new RuntimeException( e );
+        }
+        catch ( ReporterException e )
+        {
+            throw new RuntimeException( e );
         }
         finally
         {
@@ -82,46 +120,69 @@ public class SurefireStarter
 
         ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
 
-        try
+        // The test classloader must be constructed first to avoid issues with commons-logging until we properly
+        // separate the TestNG classloader
+        ClassLoader testsClassLoader;
+        final ProviderConfiguration starterConfiguration = booterConfiguration.getSurefireStarterConfiguration();
+        final ClasspathConfiguration classpathConfiguration = starterConfiguration.getClasspathConfiguration();
+        String testClassPath = classpathConfiguration.getTestClasspath().getClassPathAsString();
+        System.setProperty( "surefire.test.class.path", testClassPath );
+        if ( starterConfiguration.isManifestOnlyJarRequestedAndUsable() )
         {
-            // The test classloader must be constructed first to avoid issues with commons-logging until we properly
-            // separate the TestNG classloader
-            ClassLoader testsClassLoader;
-            final ProviderConfiguration starterConfiguration = booterConfiguration.getSurefireStarterConfiguration();
-            final ClasspathConfiguration classpathConfiguration = starterConfiguration.getClasspathConfiguration();
-            String testClassPath = classpathConfiguration.getTestClasspath().getClassPathAsString();
-            System.setProperty( "surefire.test.class.path", testClassPath );
-            if ( starterConfiguration.isManifestOnlyJarRequestedAndUsable() )
+            testsClassLoader = getClass().getClassLoader(); // ClassLoader.getSystemClassLoader()
+            // SUREFIRE-459, trick the app under test into thinking its classpath was conventional
+            // (instead of a single manifest-only jar)
+            System.setProperty( "surefire.real.class.path", System.getProperty( "java.class.path" ) );
+            System.setProperty( "java.class.path", testClassPath );
+        }
+        else
+        {
+            testsClassLoader = classpathConfiguration.createTestClassLoader();
+        }
+
+        ClassLoader surefireClassLoader = classpathConfiguration.createSurefireClassLoader( testsClassLoader );
+
+        Thread.currentThread().setContextClassLoader( surefireClassLoader );
+        final RunResult runResult = invokeProvider( null, testsClassLoader, surefireClassLoader );
+        return processRunCount( runResult, surefireClassLoader );
+    }
+
+    /**
+     * Returns
+     *
+     * @param runCount            The run result
+     * @param surefireClassLoader The sirefore classloader
+     * @return The process result code
+     * @throws SurefireExecutionException
+     */
+    private int processRunCount( RunResult runCount, ClassLoader surefireClassLoader )
+        throws SurefireExecutionException
+    {
+        if ( runCount.getCompletedCount() == 0 )
+        {
+            // TODO: Bugbug find out WTF this means. This blows up like crap when running here ;)
+/*            ReporterManagerFactory reporterManagerFactory =
+                new ReporterManagerFactory2( surefireClassLoader, booterConfiguration.getReporterConfiguration() );
+            try
             {
-                testsClassLoader = getClass().getClassLoader(); // ClassLoader.getSystemClassLoader()
-                // SUREFIRE-459, trick the app under test into thinking its classpath was conventional
-                // (instead of a single manifest-only jar)
-                System.setProperty( "surefire.real.class.path", System.getProperty( "java.class.path" ) );
-                System.setProperty( "java.class.path", testClassPath );
+                reporterManagerFactory.createReporterManager().writeMessage( "There are no tests to run." );
             }
-            else
+            catch ( TestSetFailedException e )
             {
-                testsClassLoader = classpathConfiguration.createTestClassLoader();
+                throw new SurefireExecutionException( "While reporting error", e );
             }
-
-            ClassLoader surefireClassLoader = classpathConfiguration.createSurefireClassLoader( testsClassLoader );
-
-            SurefireReflector reflector = new SurefireReflector( surefireClassLoader );
-
-            Thread.currentThread().setContextClassLoader( testsClassLoader );
-
-            return reflector.runProvider( booterConfiguration.getReporterConfiguration(),
-                                          booterConfiguration.getReports(), surefireClassLoader, testsClassLoader, p,
-                                          booterConfiguration.isFailIfNoTests(),
-                                          booterConfiguration.getTestSuiteDefinition(), booterConfiguration.getTestNg(),
-                                          starterConfiguration.getProviderClassName(),
-                                          booterConfiguration.getDirScannerParams(), null );
-
+            finally
+            {
+                reporterManagerFactory.close();
+            }*/
         }
-        finally
+
+        if ( runCount.getCompletedCount() == 0 && booterConfiguration.isFailIfNoTests().booleanValue() )
         {
-            Thread.currentThread().setContextClassLoader( oldContextClassLoader );
+            return NO_TESTS;
         }
+
+        return runCount.getBooterCode();
     }
 
 }

Added: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java?rev=1040708&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java (added)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java Tue Nov 30 19:10:57 2010
@@ -0,0 +1,89 @@
+package org.apache.maven.surefire.booter;
+
+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.SurefireClassLoadersAware;
+import org.apache.maven.surefire.providerapi.TestArtifactInfoAware;
+import org.apache.maven.surefire.providerapi.TestRequestAware;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.testset.DirectoryScannerParameters;
+import org.apache.maven.surefire.testset.TestArtifactInfo;
+import org.apache.maven.surefire.testset.TestRequest;
+
+import java.util.Properties;
+
+/**
+* @author Kristian Rosenvold
+*/
+class Foo
+    implements DirectoryScannerParametersAware, TestRequestAware, ProviderPropertiesAware, ReporterConfigurationAware,
+    SurefireClassLoadersAware, TestArtifactInfoAware
+{
+    DirectoryScannerParameters directoryScannerParameters;
+
+    TestRequest testSuiteDefinition;
+
+    Properties providerProperties;
+
+    ReporterConfiguration reporterConfiguration;
+
+    ClassLoader surefireClassLoader;
+
+    ClassLoader testClassLoader;
+
+    TestRequest testRequest;
+
+    TestArtifactInfo testArtifactInfo;
+
+    boolean called = false;
+
+    public void setDirectoryScannerParameters( DirectoryScannerParameters directoryScanner )
+    {
+        this.directoryScannerParameters = directoryScanner;
+        this.called = true;
+    }
+
+
+    public Boolean isCalled()
+    {
+        return Boolean.valueOf( called);
+    }
+
+    public void setTestSuiteDefinition( TestRequest testSuiteDefinition )
+    {
+        this.testSuiteDefinition = testSuiteDefinition;
+        this.called = true;
+    }
+
+    public void setProviderProperties( Properties providerProperties )
+    {
+        this.providerProperties = providerProperties;
+        this.called = true;
+    }
+
+    public void setReporterConfiguration( ReporterConfiguration reporterConfiguration )
+    {
+        this.reporterConfiguration = reporterConfiguration;
+        this.called = true;
+    }
+
+    public void setClassLoaders( ClassLoader surefireClassLoader, ClassLoader testClassLoader )
+    {
+        this.testClassLoader = testClassLoader;
+        this.surefireClassLoader = surefireClassLoader;
+        this.called = true;
+    }
+
+    public void setTestRequest( TestRequest testRequest1 )
+    {
+        this.testRequest = testRequest1;
+        this.called = true;
+    }
+
+    public void setTestArtifactInfo( TestArtifactInfo testArtifactInfo )
+    {
+        this.testArtifactInfo = testArtifactInfo;
+        this.called = true;
+    }
+}

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

Modified: 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=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java (original)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java Tue Nov 30 19:10:57 2010
@@ -20,18 +20,14 @@ package org.apache.maven.surefire.booter
  */
 
 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.testset.DirectoryScannerParameters;
 import org.apache.maven.surefire.testset.TestArtifactInfo;
 import org.apache.maven.surefire.testset.TestRequest;
 
 import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Properties;
 
@@ -45,12 +41,12 @@ public class SurefireReflectorTest
         throws Exception
     {
         SurefireReflector surefireReflector = getReflector();
-        Foo foo = new Foo();
+        Object foo = getFoo();
 
         DirectoryScannerParameters directoryScannerParameters =
             new DirectoryScannerParameters( new File( "ABC" ), new ArrayList(), new ArrayList(), Boolean.FALSE );
-        assertTrue( surefireReflector.isDirectoryScannerParameterAware( foo ) );
         surefireReflector.setDirectoryScannerParameters( foo, directoryScannerParameters );
+        assertTrue( isCalled( foo ).booleanValue());
 
     }
 
@@ -58,55 +54,64 @@ public class SurefireReflectorTest
         throws Exception
     {
         SurefireReflector surefireReflector = getReflector();
-        Foo foo = new Foo();
+        Object foo = getFoo();
 
         TestRequest testSuiteDefinition =
             new TestRequest( new Object[]{  new File("file1"),new File("file2") }, new File( "TestSOurce" ), "aUserRequestedTest" );
         assertTrue( surefireReflector.isTestSuiteDefinitionAware( foo ) );
         surefireReflector.setTestSuiteDefinition( foo, testSuiteDefinition );
+        assertTrue( isCalled( foo ).booleanValue() );
     }
 
     public void testProviderProperties()
         throws Exception
     {
         SurefireReflector surefireReflector = getReflector();
-        Foo foo = new Foo();
+        Object foo = getFoo();
 
         assertTrue( surefireReflector.isProviderPropertiesAware( foo ) );
         surefireReflector.setProviderProperties( foo, new Properties() );
+        assertTrue( isCalled( foo ).booleanValue() );
     }
 
     public void testReporterConfiguration()
         throws Exception
     {
         SurefireReflector surefireReflector = getReflector();
-        Foo foo = new Foo();
+        Object foo = getFoo();
 
-        ReporterConfiguration reporterConfiguration = new ReporterConfiguration( new File( "CDE" ), Boolean.TRUE );
+        ReporterConfiguration reporterConfiguration = getReporterConfiguration();
         assertTrue( surefireReflector.isReporterConfigurationAwareAware( foo ) );
         surefireReflector.setReporterConfigurationAware( foo, reporterConfiguration );
+        assertTrue( isCalled( foo ).booleanValue() );
+    }
+
+    private ReporterConfiguration getReporterConfiguration()
+    {
+        return new ReporterConfiguration( new ArrayList(), new File( "CDE" ), Boolean.TRUE );
     }
 
     public void testTestClassLoaderAware()
         throws Exception
     {
         SurefireReflector surefireReflector = getReflector();
-        Foo foo = new Foo();
+        Object foo = getFoo();
 
-        ReporterConfiguration reporterConfiguration = new ReporterConfiguration( new File( "CDE" ), Boolean.TRUE );
         assertTrue( surefireReflector.isTestClassLoaderAware( foo ) );
-        surefireReflector.setTestClassLoader( foo, getClass().getClassLoader() );
+        surefireReflector.setTestClassLoader( foo, getClass().getClassLoader(), getClass().getClassLoader() );
+        assertTrue( isCalled( foo ).booleanValue() );
     }
 
     public void testArtifactInfoAware()
         throws Exception
     {
         SurefireReflector surefireReflector = getReflector();
-        Foo foo = new Foo();
+        Object foo = getFoo();
 
         TestArtifactInfo testArtifactInfo = new TestArtifactInfo( "12.3", "test" );
         assertTrue( surefireReflector.isTestArtifactInfoAware( foo ) );
         surefireReflector.setTestArtifactInfo( foo, testArtifactInfo );
+        assertTrue( isCalled( foo ).booleanValue() );
     }
 
     private SurefireReflector getReflector()
@@ -114,47 +119,32 @@ public class SurefireReflectorTest
         return new SurefireReflector( this.getClass().getClassLoader() );
     }
 
+    public Object getFoo()
+    { // Todo: Setup a different classloader so we can really test crossing
+        return new Foo();
+    }
 
-    class Foo
-        implements DirectoryScannerParametersAware, TestSuiteDefinitionAware, ProviderPropertiesAware,
-        ReporterConfigurationAware, TestClassLoaderAware, TestArtifactInfoAware
-    {
-        DirectoryScannerParameters directoryScannerParameters;
-
-        TestRequest testSuiteDefinition;
-
-        Properties providerProperties;
-
-        ReporterConfiguration reporterConfiguration;
 
-        public void setDirectoryScannerParameters( DirectoryScannerParameters directoryScanner )
+    private Boolean isCalled(Object foo){
+        final Method isCalled;
+        try
         {
-            this.directoryScannerParameters = directoryScanner;
+            isCalled = foo.getClass().getMethod( "isCalled", new Class[0] );
+            return (Boolean) isCalled.invoke(  foo, new Object[0] );
         }
-
-
-        public void setTestSuiteDefinition( TestRequest testSuiteDefinition )
+        catch ( IllegalAccessException e )
         {
-            this.testSuiteDefinition = testSuiteDefinition;
+            throw new RuntimeException( e );
         }
-
-        public void setProviderProperties( Properties providerProperties )
+        catch ( InvocationTargetException e )
         {
-            this.providerProperties = providerProperties;
+            throw new RuntimeException( e );
         }
-
-        public void setReporterConfiguration( ReporterConfiguration reporterConfiguration )
+        catch ( NoSuchMethodException e )
         {
-            reporterConfiguration = reporterConfiguration;
+            throw new RuntimeException( e );
         }
+    }
 
-        public void setTestClassLoader( ClassLoader classLoader )
-        {
-        }
 
-        public void setTestArtifactInfo( TestArtifactInfo testArtifactInfo )
-        {
-            //To change body of implemented methods use File | Settings | File Templates.
-        }
-    }
 }

Modified: 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=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java Tue Nov 30 19:10:57 2010
@@ -18,11 +18,12 @@ package org.apache.maven.surefire.junit;
  * 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.report.ReporterManagerFactory;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.DirectoryScanner;
 
 import java.util.Iterator;
 
@@ -31,30 +32,40 @@ import java.util.Iterator;
  * @noinspection UnusedDeclaration
  */
 public class JUnit3Provider
-    extends FileScanningProvider
     implements SurefireProvider
 {
+    private final ReporterManagerFactory reporterManagerFactory;
+    private final ClassLoader testClassLoader;
+    private final DirectoryScanner directoryScanner;
+
+    public JUnit3Provider( ReporterManagerFactory reporterManagerFactory, ClassLoader testClassLoader,
+                           DirectoryScanner directoryScanner )
+    {
+        this.reporterManagerFactory = reporterManagerFactory;
+        this.testClassLoader = testClassLoader;
+        this.directoryScanner = directoryScanner;
+    }
 
     public RunResult invoke( Object forkTestSet )
         throws TestSetFailedException, ReporterException
     {
         JUnitDirectoryTestSuite suite = getSuite();
-        suite.locateTestSets( getTestsClassLoader() );
+        suite.locateTestSets(testClassLoader);
         if ( forkTestSet != null )
         {
-            suite.execute( (String) forkTestSet, getReporterManagerFactory(),
-                           getTestsClassLoader() );
+            suite.execute( (String) forkTestSet, reporterManagerFactory, testClassLoader );
         }
         else
         {
-            suite.execute( getReporterManagerFactory(), getTestsClassLoader() );
+            suite.execute( reporterManagerFactory, testClassLoader );
         }
-        return RunResult.totalCountOnly( suite.getNumTests() );
+        reporterManagerFactory.close();
+        return reporterManagerFactory.getGlobalRunStatistics().getRunResult();
     }
 
     private JUnitDirectoryTestSuite getSuite()
     {
-        return new JUnitDirectoryTestSuite( getDirectoryScanner() );
+        return new JUnitDirectoryTestSuite( directoryScanner );
 
     }
 
@@ -62,7 +73,7 @@ public class JUnit3Provider
     {
         try
         {
-            return getSuite().locateTestSets( getTestsClassLoader() ).keySet().iterator();
+            return getSuite().locateTestSets( testClassLoader ).keySet().iterator();
         }
         catch ( TestSetFailedException e )
         {

Copied: maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3ProviderFactory.java (from r1040706, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3ProviderFactory.java?p2=maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3ProviderFactory.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java&r1=1040706&r2=1040708&rev=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3ProviderFactory.java Tue Nov 30 19:10:57 2010
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.providerapi;
+package org.apache.maven.surefire.junit;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,12 +19,16 @@ package org.apache.maven.surefire.provid
  * under the License.
  */
 
-import org.apache.maven.surefire.testset.TestRequest;
+import org.apache.maven.surefire.providerapi.BaseProviderFactory;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
 
 /**
  * @author Kristian Rosenvold
  */
-public interface TestSuiteDefinitionAware
+public class JUnit3ProviderFactory extends BaseProviderFactory
 {
-    void setTestSuiteDefinition( TestRequest testSuiteDefinition );
+    public SurefireProvider createProvider()
+    {
+        return new JUnit3Provider(getReporterManagerFactory(), getTestClassLoader(), getDirectoryScanner());
+    }
 }

Modified: 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=1040708&r1=1040707&r2=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java Tue Nov 30 19:10:57 2010
@@ -18,52 +18,56 @@ package org.apache.maven.surefire.junit4
  * 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.report.ReporterManagerFactory;
 import org.apache.maven.surefire.suite.RunResult;
-import org.apache.maven.surefire.testset.TestRequest;
 import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.DirectoryScanner;
 
 import java.util.Iterator;
-import java.util.Properties;
 
 /**
  * @author Kristian Rosenvold
  */
 @SuppressWarnings( { "UnusedDeclaration" } )
 public class JUnit4Provider
-    extends FileScanningProvider
-    implements SurefireProvider, ProviderPropertiesAware, TestSuiteDefinitionAware
+    implements SurefireProvider
 {
 
-    private Properties providerProperties;
-
-    private TestRequest testSuiteDefinition;
-
+    private final ReporterManagerFactory reporterManagerFactory;
+    private final ClassLoader testClassLoader;
+    private final DirectoryScanner directoryScanner;
+
+    public JUnit4Provider( ReporterManagerFactory reporterManagerFactory, ClassLoader testClassLoader,
+                           DirectoryScanner directoryScanner)
+    {
+        this.reporterManagerFactory = reporterManagerFactory;
+        this.testClassLoader = testClassLoader;
+        this.directoryScanner = directoryScanner;
+    }
 
     @SuppressWarnings( { "UnnecessaryUnboxing" } )
     public RunResult invoke( Object forkTestSet )
         throws TestSetFailedException, ReporterException
     {
         JUnit4DirectoryTestSuite suite = getSuite();
-        suite.locateTestSets( getTestsClassLoader() );
+        suite.locateTestSets( testClassLoader );
         if ( forkTestSet != null )
         {
-            suite.execute( (String) forkTestSet, getReporterManagerFactory(), getTestsClassLoader() );
+            suite.execute( (String) forkTestSet, reporterManagerFactory, testClassLoader );
         }
         else
         {
-            suite.execute( getReporterManagerFactory(), getTestsClassLoader() );
+            suite.execute( reporterManagerFactory, testClassLoader );
         }
-        return RunResult.totalCountOnly( suite.getNumTests() );
+        reporterManagerFactory.close();
+        return reporterManagerFactory.getGlobalRunStatistics().getRunResult();
     }
 
     private JUnit4DirectoryTestSuite getSuite()
     {
-        return new JUnit4DirectoryTestSuite( getDirectoryScanner() );
+        return new JUnit4DirectoryTestSuite( directoryScanner );
 
     }
 
@@ -71,7 +75,7 @@ public class JUnit4Provider
     {
         try
         {
-            return getSuite().locateTestSets( getTestsClassLoader() ).keySet().iterator();
+            return getSuite().locateTestSets( testClassLoader ).keySet().iterator();
         }
         catch ( TestSetFailedException e )
         {
@@ -79,18 +83,6 @@ public class JUnit4Provider
         }
     }
 
-
-    public void setProviderProperties( Properties providerProperties )
-    {
-        this.providerProperties = providerProperties;
-    }
-
-    public void setTestSuiteDefinition( TestRequest testSuiteDefinition )
-    {
-        this.testSuiteDefinition = testSuiteDefinition;
-    }
-
-
     private void upgradeCheck( JUnit4DirectoryTestSuite suite )
         throws TestSetFailedException
     {

Copied: maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4ProviderFactory.java (from r1040706, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4ProviderFactory.java?p2=maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4ProviderFactory.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java&r1=1040706&r2=1040708&rev=1040708&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4ProviderFactory.java Tue Nov 30 19:10:57 2010
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.providerapi;
+package org.apache.maven.surefire.junit4;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,12 +19,18 @@ package org.apache.maven.surefire.provid
  * under the License.
  */
 
-import org.apache.maven.surefire.testset.TestRequest;
+
+import org.apache.maven.surefire.providerapi.BaseProviderFactory;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
 
 /**
  * @author Kristian Rosenvold
  */
-public interface TestSuiteDefinitionAware
+@SuppressWarnings( { "UnusedDeclaration" } )
+public class JUnit4ProviderFactory extends BaseProviderFactory
 {
-    void setTestSuiteDefinition( TestRequest testSuiteDefinition );
+    public SurefireProvider createProvider()
+    {
+        return new JUnit4Provider(getReporterManagerFactory(), getTestClassLoader(), getDirectoryScanner());
+    }
 }

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

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4ProviderFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message