maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1039777 [1/3] - 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 Sat, 27 Nov 2010 22:41:25 GMT
Author: krosenvold
Date: Sat Nov 27 22:41:23 2010
New Revision: 1039777

URL: http://svn.apache.org/viewvc?rev=1039777&view=rev
Log:
[SUREFIRE-141] Early version of an api

There's too much reflection but we're getting there.

Added:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ApiReflector.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ProviderInvoker.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ApiSerializer.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/DirectoryScannerParametersAware.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/FileScanningProvider.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderConfiguration.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderPropertiesAware.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ReporterConfigurationAware.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ReporterManagerFactoryAware.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ReportingAware.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestArtifactInfoAware.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestClassLoaderAware.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/TestSuiteDefinitionAware.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory2.java
      - copied, changed from r1039320, 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/suite/RunResult.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestArtifactInfo.java
      - copied, changed from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestSuiteDefinition.java   (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java   (with props)
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java   (with props)
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java   (with props)
Removed:
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.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/BooterConversionTest.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerTest.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/DetailedConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/FileReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ForkingConsoleReporter.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/TestSetStatistics.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SuiteDefinition.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.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/BooterConfiguration.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/ForkedBooter.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
    maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitDirectoryTestSuite.java
    maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4DirectoryTestSuite.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.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

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=1039777&r1=1039776&r2=1039777&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 Sat Nov 27 22:41:23 2010
@@ -38,14 +38,18 @@ import org.apache.maven.plugin.surefire.
 import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter;
 import org.apache.maven.surefire.booter.BooterConfiguration;
 import org.apache.maven.surefire.booter.ClasspathConfiguration;
+import org.apache.maven.surefire.providerapi.ProviderConfiguration;
 import org.apache.maven.surefire.report.BriefConsoleReporter;
 import org.apache.maven.surefire.report.BriefFileReporter;
 import org.apache.maven.surefire.report.ConsoleReporter;
 import org.apache.maven.surefire.report.DetailedConsoleReporter;
 import org.apache.maven.surefire.report.FileReporter;
 import org.apache.maven.surefire.report.ForkingConsoleReporter;
+import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.report.XMLReporter;
-import org.apache.maven.surefire.suite.SuiteDefinition;
+import org.apache.maven.surefire.testset.DirectoryScannerParameters;
+import org.apache.maven.surefire.testset.TestSuiteDefinition;
+import org.apache.maven.surefire.testset.TestArtifactInfo;
 import org.apache.maven.toolchain.Toolchain;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -103,7 +107,7 @@ public abstract class AbstractSurefireMo
      */
     private void convertTestNGParameters()
     {
-        if ( getProperties() == null )
+        if ( getProperties() == null ) // May be predefined from plugin paramaters
         {
             setProperties( new Properties() );
         }
@@ -222,9 +226,9 @@ public abstract class AbstractSurefireMo
         final ClasspathConfiguration classpathConfiguration =
             new ClasspathConfiguration( isEnableAssertions(), isChildDelegation() );
 
-        BooterConfiguration booterConfiguration =
-            new BooterConfiguration( forkConfiguration.isForking(), forkConfiguration.getClassLoaderConfiguration(), classpathConfiguration,
-                                     isRedirectTestOutputToFile() );
+        ReporterConfiguration reporterConfiguration =
+            new ReporterConfiguration( getReportsDirectory(), Boolean.valueOf( isTrimStackTrace() ) );
+
 
         Artifact surefireArtifact =
             (Artifact) getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" );
@@ -237,6 +241,7 @@ public abstract class AbstractSurefireMo
 
         Artifact junitArtifact;
         Artifact testNgArtifact;
+        String providerName;
         try
         {
             addArtifact( classpathConfiguration, surefireArtifact );
@@ -245,7 +250,7 @@ public abstract class AbstractSurefireMo
 
             testNgArtifact = getTestNgArtifact();
 
-            setCorrectProvider( classpathConfiguration, surefireArtifact, junitArtifact, testNgArtifact );
+            providerName = setCorrectProvider( classpathConfiguration, surefireArtifact, junitArtifact, testNgArtifact );
         }
         catch ( ArtifactNotFoundException e )
         {
@@ -261,75 +266,54 @@ public abstract class AbstractSurefireMo
             throw new MojoExecutionException( "Error to resolving surefire provider dependency: " + e.getMessage(), e );
         }
 
+        DirectoryScannerParameters directoryScannerParameters = null;
         final boolean isTestNg = testNgArtifact != null;
-        String providerName;
-        if ( getSuiteXmlFiles() != null && getSuiteXmlFiles().length > 0 && getTest() == null )
+        TestArtifactInfo testNg = isTestNg ? new TestArtifactInfo( testNgArtifact.getVersion(), testNgArtifact.getClassifier()) : null;
+        TestSuiteDefinition testSuiteDefinition = new TestSuiteDefinition(getSuiteXmlFiles(), null, getTestSourceDirectory(), getTest());
+        final boolean failIfNoTests;
+
+        if ( isValidSuiteXmlFileConfig() && getTest() == null )
         {
+            failIfNoTests = getFailIfNoTests() != null && getFailIfNoTests().booleanValue();
             if ( !isTestNg )
             {
                 throw new MojoExecutionException( "suiteXmlFiles is configured, but there is no TestNG dependency" );
             }
 
-            // TODO: properties should be passed in here too
-            providerName = "org.apache.maven.surefire.testng.TestNGXmlTestSuite";
-            Object[] params =
-                { getSuiteXmlFiles(), getTestSourceDirectory().getAbsolutePath(), testNgArtifact.getVersion(),
-                    testNgArtifact.getClassifier(), getProperties(), getReportsDirectory() };
-            booterConfiguration.setSuiteDefinition( new SuiteDefinition( providerName, params ) );
+            testSuiteDefinition = new TestSuiteDefinition(getSuiteXmlFiles(), getTest(), getTestSourceDirectory(), getTest());
         }
         else
         {
-            List includes = getIncludeList();
-            List excludes = getExcludeList();
-
-            if ( getTest() != null )
+            if ( isSpecificTestSpecified() && getFailIfNoTests() == null )
             {
-                if ( getFailIfNoTests() == null )
-                {
-                    setFailIfNoTests( Boolean.TRUE );
-                }
+                setFailIfNoTests( Boolean.TRUE );
             }
 
-            if ( testNgArtifact != null )
+            failIfNoTests = getFailIfNoTests() != null && getFailIfNoTests().booleanValue();
+
+            if ( isAnyConcurrencySelected() && isJunit47Compatible( junitArtifact ) )
             {
-                providerName = "org.apache.maven.surefire.testng.TestNGDirectoryTestSuite";
-                Object[] params =
-                    { getTestClassesDirectory(), includes, excludes, getTestSourceDirectory().getAbsolutePath(),
-                        testNgArtifact.getVersion(), testNgArtifact.getClassifier(), getProperties(),
-                        getReportsDirectory() };
-                booterConfiguration.setSuiteDefinition( new SuiteDefinition( providerName, params ) );
+                getLog().info( "Concurrency config is " + getProperties().toString() );
             }
-            else
-            {
-                if ( isAnyConcurrencySelected() && isJunit47Compatible( junitArtifact ) )
-                {
-                    providerName = "org.apache.maven.surefire.junitcore.JUnitCoreDirectoryTestSuite";
-                    getLog().info( "Concurrency config is " + getProperties().toString() );
-                    Object[] params = { getTestClassesDirectory(), includes, excludes, getProperties() };
-                    booterConfiguration.setSuiteDefinition( new SuiteDefinition( providerName, params ) );
-                }
-                else
-                {
-                    if ( isAnyJunit4( junitArtifact ) )
-                    {
-                        providerName = "org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite";
-                    }
-                    else
-                    {
-                        // fall back to JUnit, which also contains POJO support. Also it can run
-                        // classes compiled against JUnit since it has a dependency on JUnit itself.
-                        providerName = "org.apache.maven.surefire.junit.JUnitDirectoryTestSuite";
-                    }
-                    Object[] params = { getTestClassesDirectory(), includes, excludes };
-                    booterConfiguration.setSuiteDefinition( new SuiteDefinition( providerName, params ) );
-                }
-            }
-            // Consider querying the plugin classpath and load the class, so we can invastigate if we need
-            // these parameters or not. Right now, just play stupid and send it all across.
-            // We're talking like 200 bytes extra in a file.
-            booterConfiguration.setDirectoryScannerOptions( getTestClassesDirectory(), includes, excludes );
+
+            List includes = getIncludeList();
+            List excludes = getExcludeList();
+            directoryScannerParameters =
+                new DirectoryScannerParameters( getTestClassesDirectory(), includes, excludes, Boolean.valueOf( failIfNoTests) );
         }
 
+
+        ProviderConfiguration providerConfiguration = new ProviderConfiguration( providerName );
+        List reports = getReporters( forkConfiguration.isForking() );
+        Properties providerProperties = getProperties();
+        if (providerProperties == null) {
+            providerProperties = new Properties(  );
+        }
+        BooterConfiguration booterConfiguration =
+            new BooterConfiguration( providerProperties, forkConfiguration.isForking(), forkConfiguration.getClassLoaderConfiguration(),
+                                     classpathConfiguration, isRedirectTestOutputToFile(), reporterConfiguration, testNg, testSuiteDefinition, directoryScannerParameters, failIfNoTests, reports, providerConfiguration);
+
+
         List classpathElements;
         try
         {
@@ -370,17 +354,24 @@ public abstract class AbstractSurefireMo
             }
         }
 
-        booterConfiguration.setFailIfNoTests( getFailIfNoTests() != null && getFailIfNoTests().booleanValue() );
-
-        addReporters( booterConfiguration, forkConfiguration.isForking() );
 
         return booterConfiguration;
     }
 
+    private boolean isSpecificTestSpecified()
+    {
+        return getTest() != null;
+    }
+
+    private boolean isValidSuiteXmlFileConfig()
+    {
+        return getSuiteXmlFiles() != null && getSuiteXmlFiles().length > 0;
+    }
+
     private List getExcludeList()
     {
         List excludes;
-        if ( getTest() != null )
+        if ( isSpecificTestSpecified() )
         {
             // Check to see if we are running a single test. The raw parameter will
             // come through if it has not been set.
@@ -406,7 +397,7 @@ public abstract class AbstractSurefireMo
     private List getIncludeList()
     {
         List includes;
-        if ( getTest() != null )
+        if ( isSpecificTestSpecified() )
         {
             // Check to see if we are running a single test. The raw parameter will
             // come through if it has not been set.
@@ -443,13 +434,15 @@ public abstract class AbstractSurefireMo
         return includes;
     }
 
-    private void setCorrectProvider( ClasspathConfiguration classpathConfiguration, Artifact surefireArtifact,
+    private String setCorrectProvider( ClasspathConfiguration classpathConfiguration, Artifact surefireArtifact,
                                      Artifact junitArtifact, Artifact testNgArtifact )
         throws ArtifactNotFoundException, ArtifactResolutionException, MojoExecutionException
     {
         if ( testNgArtifact != null )
         {
             setTestNgProvider( classpathConfiguration, surefireArtifact, testNgArtifact );
+            return "org.apache.maven.surefire.testng.TestNGProvider";
+
         }
         else if ( junitArtifact != null && isAnyJunit4( junitArtifact ) )
         {
@@ -457,10 +450,12 @@ public abstract class AbstractSurefireMo
             {
                 convertJunitCoreParameters();
                 setProvider( classpathConfiguration, "surefire-junit47", surefireArtifact.getBaseVersion(), null );
+                return "org.apache.maven.surefire.junitcore.JUnitCoreProvider";
             }
             else
             {
                 setProvider( classpathConfiguration, "surefire-junit4", surefireArtifact.getBaseVersion(), null );
+                return "org.apache.maven.surefire.junit4.JUnit4Provider";
             }
         }
         else
@@ -468,6 +463,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";
         }
     }
 
@@ -844,56 +840,52 @@ public abstract class AbstractSurefireMo
      * The Reporter that will be added will be based on the value of the parameter useFile, reportFormat, and
      * printSummary.
      *
-     * @param booterConfiguration The surefire booter that will run tests.
      * @param forking             forking
+     * @return a list of reporters
      */
-    private void addReporters( BooterConfiguration booterConfiguration, boolean forking )
+    private List getReporters( boolean forking )
     {
-        Boolean trimStackTrace = Boolean.valueOf( this.isTrimStackTrace() );
+        List reports = new ArrayList(  );
         if ( isUseFile() )
         {
             if ( isPrintSummary() )
             {
                 if ( forking )
                 {
-                    booterConfiguration.addReport( ForkingConsoleReporter.class.getName(),
-                                                   new Object[]{ trimStackTrace } );
+                    reports.add( ForkingConsoleReporter.class.getName() );
                 }
                 else
                 {
-                    booterConfiguration.addReport( ConsoleReporter.class.getName(), new Object[]{ trimStackTrace } );
+                    reports.add( ConsoleReporter.class.getName() );
                 }
             }
 
             if ( BRIEF_REPORT_FORMAT.equals( getReportFormat() ) )
             {
-                booterConfiguration.addReport( BriefFileReporter.class.getName(),
-                                               new Object[]{ getReportsDirectory(), trimStackTrace } );
+                reports.add( BriefFileReporter.class.getName() );
             }
             else if ( PLAIN_REPORT_FORMAT.equals( getReportFormat() ) )
             {
-                booterConfiguration.addReport( FileReporter.class.getName(),
-                                               new Object[]{ getReportsDirectory(), trimStackTrace } );
+                reports.add( FileReporter.class.getName() );
             }
         }
         else
         {
             if ( BRIEF_REPORT_FORMAT.equals( getReportFormat() ) )
             {
-                booterConfiguration.addReport( BriefConsoleReporter.class.getName(), new Object[]{ trimStackTrace } );
+                reports.add( BriefConsoleReporter.class.getName() );
             }
             else if ( PLAIN_REPORT_FORMAT.equals( getReportFormat() ) )
             {
-                booterConfiguration.addReport( DetailedConsoleReporter.class.getName(),
-                                               new Object[]{ trimStackTrace } );
+                reports.add( DetailedConsoleReporter.class.getName() );
             }
         }
 
         if ( !isDisableXmlReport() )
         {
-            booterConfiguration.addReport( XMLReporter.class.getName(),
-                                           new Object[]{ getReportsDirectory(), trimStackTrace } );
+            reports.add( XMLReporter.class.getName() );
         }
+        return reports;
     }
 
     protected void ensureWorkingDirectoryExists()

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=1039777&r1=1039776&r2=1039777&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 Sat Nov 27 22:41:23 2010
@@ -19,7 +19,12 @@ package org.apache.maven.plugin.surefire
  */
 
 import org.apache.maven.surefire.booter.BooterConfiguration;
+import org.apache.maven.surefire.booter.BooterDeserializer;
 import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
+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.TestSuiteDefinition;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -47,32 +52,75 @@ import java.util.Properties;
  */
 public class BooterSerializer
 {
-    private static final String TEST_SUITE_PROPERTY_PREFIX = "testSuite.";
-
-    private static final String DIRSCANNER_PROPERTY_PREFIX = "dirscanner.";
-
-    private static final String REPORT_PROPERTY_PREFIX = "report.";
-
-    private static final String PARAMS_SUFIX = ".params";
-
-    private static final String TYPES_SUFIX = ".types";
-
-
-    public void setForkProperties( Properties properties, List testSuites, BooterConfiguration booterConfiguration,
+    public void setForkProperties( Properties properties, BooterConfiguration booterConfiguration,
                                    ClassLoaderConfiguration forkConfiguration )
     {
-        addPropertiesForTypeHolder( booterConfiguration.getReports(), properties, REPORT_PROPERTY_PREFIX );
-        addPropertiesForTypeHolder( testSuites, properties, TEST_SUITE_PROPERTY_PREFIX );
+        if (properties == null){
+            throw new IllegalStateException( "Properties cannot be null");
+        }
+        addList( booterConfiguration.getReports(), properties, BooterDeserializer.REPORT_PROPERTY_PREFIX );
         List params = new ArrayList();
-        params.add( new Object[]{ "directoryScannerOptions", booterConfiguration.getDirScannerParams() } ); 
-        addPropertiesForTypeHolder( params, properties, DIRSCANNER_PROPERTY_PREFIX );
+        params.add( new Object[]{ "directoryScannerOptions", booterConfiguration.getDirScannerParamsArray() } );
+        addPropertiesForTypeHolder( params, properties, BooterDeserializer.DIRSCANNER_PROPERTY_PREFIX );
 
         booterConfiguration.getClasspathConfiguration().setForkProperties( properties );
 
+        ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration();
+
+        TestArtifactInfo testNg = booterConfiguration.getTestNg();
+        if ( testNg != null )
+        {
+            if ( testNg.getVersion() != null )
+            {
+                properties.setProperty( "testNgVersion", testNg.getVersion() );
+            }
+            if ( testNg.getClassifier() != null )
+            {
+                properties.setProperty( "testNgClassifier", testNg.getClassifier() );
+            }
+        }
+
+        TestSuiteDefinition testSuiteDefinition = booterConfiguration.getTestSuiteDefinition();
+        if ( testSuiteDefinition != null )
+        {
+            if ( testSuiteDefinition.getTestForFork() != null )
+            {
+                properties.setProperty( "testSuiteDefinitionTest", testSuiteDefinition.getTestForFork() );
+            }
+            if ( testSuiteDefinition.getTestSourceDirectory() != null )
+            {
+                properties.setProperty( "testSuiteDefinitionTestSourceDirectory",
+                                        testSuiteDefinition.getTestSourceDirectory().toString() );
+            }
+            if ( testSuiteDefinition.getSuiteXmlFiles() != null )
+            {
+                properties.setProperty( "testSuiteXmlFiles", getValues( testSuiteDefinition.getSuiteXmlFiles() ) );
+            }
+            if ( testSuiteDefinition.getRequestedTest() != null )
+            {
+                properties.setProperty( "requestedTest", testSuiteDefinition.getRequestedTest() );
+            }
+        }
+
+        DirectoryScannerParameters directoryScannerParameters = booterConfiguration.getDirScannerParams();
+        if ( directoryScannerParameters != null )
+        {
+            properties.setProperty( "failIfNoTests", String.valueOf( directoryScannerParameters.isFailIfNoTests() ) );
+            addList( directoryScannerParameters.getIncludes(), properties, "includes" );
+            addList( directoryScannerParameters.getExcludes(), properties, "excludes" );
+            properties.setProperty( "testClassesDirectory",
+                                    directoryScannerParameters.getTestClassesDirectory().toString() );
+        }
+
+        Boolean rep = reporterConfiguration.isTrimStackTrace();
+        properties.setProperty( "isTrimStackTrace", rep.toString() );
+        properties.setProperty( "reportsDirectory", reporterConfiguration.getReportsDirectory().toString() );
         properties.setProperty( "useSystemClassLoader", String.valueOf( forkConfiguration.isUseSystemClassLoader() ) );
         properties.setProperty( "useManifestOnlyJar",
                                 String.valueOf( forkConfiguration.isManifestOnlyJarRequestedAndUsable() ) );
         properties.setProperty( "failIfNoTests", String.valueOf( booterConfiguration.isFailIfNoTests() ) );
+        properties.setProperty( "providerConfiguration",
+                                booterConfiguration.getProviderConfiguration().getClassName() );
     }
 
     public File writePropertiesFile( String name, Properties properties, boolean debug, File tempDirectory )
@@ -117,22 +165,48 @@ public class BooterSerializer
 
             if ( params != null )
             {
-                String paramProperty = convert( params[0] );
-                String typeProperty = params[0].getClass().getName();
-                for ( int j = 1; j < params.length; j++ )
+                String paramProperty = getValues( params );
+                String typeProperty = getTypes( params );
+                properties.setProperty( propertyPrefix + i + BooterDeserializer.PARAMS_SUFIX, paramProperty );
+                properties.setProperty( propertyPrefix + i + BooterDeserializer.TYPES_SUFIX, typeProperty );
+            }
+        }
+    }
+
+    private String getValues( Object[] params )
+    {
+        StringBuffer result = new StringBuffer();
+        if ( params != null && params.length > 0 )
+        {
+            result.append( convert( params[0] ) );
+            for ( int j = 1; j < params.length; j++ )
+            {
+                result.append( "|" );
+                if ( params[j] != null )
+                {
+                    result.append( convert( params[j] ) );
+                }
+            }
+        }
+        return result.toString();
+    }
+
+    private String getTypes( Object[] params )
+    {
+        StringBuffer result = new StringBuffer();
+        if ( params != null && params.length > 0 )
+        {
+            result.append( params[0].getClass().getName() );
+            for ( int j = 1; j < params.length; j++ )
+            {
+                result.append( "|" );
+                if ( params[j] != null )
                 {
-                    paramProperty += "|";
-                    typeProperty += "|";
-                    if ( params[j] != null )
-                    {
-                        paramProperty += convert( params[j] );
-                        typeProperty += params[j].getClass().getName();
-                    }
+                    result.append( params[j].getClass().getName() );
                 }
-                properties.setProperty( propertyPrefix + i + PARAMS_SUFIX, paramProperty );
-                properties.setProperty( propertyPrefix + i + TYPES_SUFIX, typeProperty );
             }
         }
+        return result.toString();
     }
 
     private static String convert( Object param )
@@ -161,4 +235,17 @@ public class BooterSerializer
         }
     }
 
+    private void addList( List items, Properties properties, String propertyPrefix )
+    {
+        for ( int i = 0; i < items.size(); i++ )
+        {
+            Object item = items.get( i );
+            if ( item == null )
+            {
+                throw new NullPointerException( propertyPrefix + i + " has null value" );
+            }
+            properties.setProperty( propertyPrefix + i, item.toString() );
+        }
+    }
+
 }

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=1039777&r1=1039776&r2=1039777&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 Sat Nov 27 22:41:23 2010
@@ -30,7 +30,7 @@ import org.apache.maven.plugin.surefire.
 import org.apache.maven.plugin.surefire.booterclient.output.StandardOutputConsumer;
 import org.apache.maven.plugin.surefire.booterclient.output.SupressFooterOutputConsumerProxy;
 import org.apache.maven.plugin.surefire.booterclient.output.SupressHeaderOutputConsumerProxy;
-import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.booter.*;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -41,41 +41,36 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
 
 /**
  * Starts the fork or runs in-process.
- *
+ * <p/>
  * Lives only on the plugin-side (not present in remote vms)
  * <p/>
  * Knows how to fork new vms and also how to delegate non-forking invocation to TestVmBooter directly
  *
  * @author Jason van Zyl
  * @author Emmanuel Venisse
- * @author Kristian Rosenvold    
+ * @author Kristian Rosenvold
  * @version $Id$
  */
 public class ForkStarter
 {
-
     private int forkedProcessTimeoutInSeconds = 0;
 
     private final BooterConfiguration booterConfiguration;
 
+
     private final ForkConfiguration forkConfiguration;
 
     private File reportsDirectory;
 
-
     public ForkStarter( BooterConfiguration booterConfiguration, File reportsDirectory,
-                             ForkConfiguration forkConfiguration )
+                        ForkConfiguration forkConfiguration )
     {
         this.forkConfiguration = forkConfiguration;
         this.booterConfiguration = booterConfiguration;
@@ -91,7 +86,7 @@ public class ForkStarter
         if ( ForkConfiguration.FORK_NEVER.equals( requestedForkMode ) )
         {
             SurefireStarter testVmBooter = new SurefireStarter( booterConfiguration );
-            result = testVmBooter.runSuitesInProcess();
+            result = testVmBooter.runSuitesInProcess(booterConfiguration.getProviderProperties());
         }
         else if ( ForkConfiguration.FORK_ONCE.equals( requestedForkMode ) )
         {
@@ -108,16 +103,17 @@ public class ForkStarter
         return result;
     }
 
-
     private int runSuitesForkOnce()
         throws SurefireBooterForkException
     {
-        return forkSuites( booterConfiguration.getTestSuites(), true, true );
+        return forkSuites( true, true );
     }
 
     private int runSuitesForkPerTestSet()
         throws SurefireBooterForkException
     {
+        int globalResult = 0;
+
         ClassLoader testsClassLoader;
         ClassLoader surefireClassLoader;
         try
@@ -131,27 +127,24 @@ public class ForkStarter
             throw new SurefireBooterForkException( "Unable to create classloader to find test suites", e );
         }
 
-        int globalResult = 0;
 
         boolean showHeading = true;
-        Properties properties = new Properties();
-        for ( Iterator i = booterConfiguration.getTestSuites().iterator(); i.hasNext(); )
-        {
-            Object[] testSuite = (Object[]) i.next();
+        final ProviderFactory providerFactory = new ProviderFactory( booterConfiguration, surefireClassLoader);
+        Object surefireProvider = providerFactory.createProvider(testsClassLoader);
 
-            Map testSets = getTestSets( testSuite, testsClassLoader, surefireClassLoader );
+        Properties properties = new Properties();
 
-            for ( Iterator j = testSets.keySet().iterator(); j.hasNext(); )
+        final Iterator suites = (Iterator) SurefireReflector.getSuites(surefireProvider);
+        while ( suites.hasNext() )
+        {
+            Object testSet = suites.next();
+            boolean showFooter = !suites.hasNext();
+            int result = forkSuite( testSet, showHeading, showFooter, properties );
+            if ( result > globalResult )
             {
-                Object testSet = j.next();
-                boolean showFooter = !j.hasNext() && !i.hasNext();
-                int result = forkSuite( testSuite, testSet, showHeading, showFooter, properties );
-                if ( result > globalResult )
-                {
-                    globalResult = result;
-                }
-                showHeading = false;
+                globalResult = result;
             }
+            showHeading = false;
         }
 
         return globalResult;
@@ -162,72 +155,23 @@ public class ForkStarter
         return booterConfiguration.getClasspathConfiguration();
     }
 
-    private Map getTestSets( Object[] testSuite, ClassLoader testsClassLoader, ClassLoader surefireClassLoader )
-        throws SurefireBooterForkException
-    {
-        String className = (String) testSuite[0];
-
-        Object[] params = (Object[]) testSuite[1];
-
-        Object suite;
-        try
-        {
-            suite = SurefireReflector.instantiateObject( className, params, surefireClassLoader );
-        }
-        catch ( TestSetFailedException e )
-        {
-            throw new SurefireBooterForkException( e.getMessage(), e.getCause() );
-        }
-        catch ( ClassNotFoundException e )
-        {
-            throw new SurefireBooterForkException( "Unable to find class for test suite '" + className + "'", e );
-        }
-        catch ( NoSuchMethodException e )
-        {
-            throw new SurefireBooterForkException(
-                "Unable to find appropriate constructor for test suite '" + className + "': " + e.getMessage(), e );
-        }
-
-        Map testSets;
-        try
-        {
-            Method m = suite.getClass().getMethod( "locateTestSets", new Class[]{ ClassLoader.class } );
-
-            testSets = (Map) m.invoke( suite, new Object[]{ testsClassLoader } );
-        }
-        catch ( IllegalAccessException e )
-        {
-            throw new SurefireBooterForkException( "Error obtaining test sets", e );
-        }
-        catch ( NoSuchMethodException e )
-        {
-            throw new SurefireBooterForkException( "Error obtaining test sets", e );
-        }
-        catch ( InvocationTargetException e )
-        {
-            throw new SurefireBooterForkException( e.getTargetException().getMessage(), e.getTargetException() );
-        }
-        return testSets;
-    }
-
-    private int forkSuites( List testSuites, boolean showHeading, boolean showFooter )
+    private int forkSuites( boolean showHeading, boolean showFooter )
         throws SurefireBooterForkException
     {
-        Properties properties = new Properties();
+        Properties properties = booterConfiguration.getProviderProperties();
 
         BooterSerializer booterSerializer = new BooterSerializer();
-        booterSerializer.setForkProperties( properties, testSuites, booterConfiguration,
+        booterSerializer.setForkProperties( properties, booterConfiguration,
                                             forkConfiguration.getClassLoaderConfiguration() );
 
         return fork( properties, showHeading, showFooter );
     }
 
-    private int forkSuite( Object[] testSuite, Object testSet, boolean showHeading, boolean showFooter,
-                           Properties properties )
+    private int forkSuite( Object testSet, boolean showHeading, boolean showFooter, Properties properties )
         throws SurefireBooterForkException
     {
         BooterSerializer booterSerializer = new BooterSerializer();
-        booterSerializer.setForkProperties( properties, Collections.singletonList( testSuite ), booterConfiguration,
+        booterSerializer.setForkProperties( properties, booterConfiguration,
                                             forkConfiguration.getClassLoaderConfiguration() );
 
         if ( testSet instanceof String )

Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterConversionTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterConversionTest.java?rev=1039777&r1=1039776&r2=1039777&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterConversionTest.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterConversionTest.java Sat Nov 27 22:41:23 2010
@@ -42,7 +42,7 @@ public class BooterConversionTest
         convert = BooterSerializer.class.getDeclaredMethod( "convert", new Class[]{ Object.class } );
         convert.setAccessible( true );
         constructParamObjects = BooterDeserializer.class.getDeclaredMethod( "constructParamObjects",
-                                                                          new Class[]{ String.class, String.class } );
+                                                                          new Class[]{ String.class, Class.class } );
         constructParamObjects.setAccessible( true );
     }
 
@@ -111,7 +111,7 @@ public class BooterConversionTest
         throws Exception
     {
         String serialized = serialize( o );
-        Object[] output = deserialize( serialized, o.getClass().getName() );
+        Object[] output = deserialize( serialized, o.getClass());
         Assert.assertEquals( "Wrong number of output elements: " + Arrays.asList( output ), 1, output.length );
         Assert.assertEquals( o, output[0] );
     }
@@ -120,7 +120,7 @@ public class BooterConversionTest
         throws Exception
     {
         String serialized = serialize( o );
-        Object[] output = deserialize( serialized, o.getClass().getName() );
+        Object[] output = deserialize( serialized, o.getClass() );
         Assert.assertEquals( "Wrong number of output elements: " + Arrays.asList( output ), 1, output.length );
         assertArrayEquals( "Deserialized array didn't match", o, (Object[]) output[0] );
     }
@@ -134,7 +134,7 @@ public class BooterConversionTest
         }
     }
 
-    private Object[] deserialize( String paramProperty, String typeProperty )
+    private Object[] deserialize( String paramProperty, Class typeProperty )
         throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
     {
         return (Object[]) constructParamObjects.invoke( null, new Object[]{ paramProperty, typeProperty } );

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=1039777&r1=1039776&r2=1039777&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 Sat Nov 27 22:41:23 2010
@@ -20,11 +20,15 @@ package org.apache.maven.plugin.surefire
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
-import org.apache.maven.plugin.surefire.booterclient.BooterSerializer;
 import org.apache.maven.surefire.booter.BooterConfiguration;
 import org.apache.maven.surefire.booter.BooterDeserializer;
 import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
 import org.apache.maven.surefire.booter.ClasspathConfiguration;
+import org.apache.maven.surefire.providerapi.ProviderConfiguration;
+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.TestSuiteDefinition;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -35,12 +39,16 @@ import java.util.Properties;
 
 /**
  * Performs roundtrip testing of serialization/deserialization
+ *
  * @author Kristian Rosenvold
  */
 public class BooterDeserializerTest
     extends TestCase
 {
 
+    private final String aTest = "aTest";
+    private final String aUserRequestedTest = "aUserRequestedTest";
+
     public static ClassLoaderConfiguration getForkConfiguration()
         throws IOException
     {
@@ -50,25 +58,21 @@ public class BooterDeserializerTest
     public void testDirectoryScannerParams()
         throws IOException
     {
-        ClassLoaderConfiguration forkConfiguration = getForkConfiguration();
-        BooterConfiguration booterConfiguration = getTestBooterConfiguration( forkConfiguration );
 
         File aDir = new File( "." );
         List includes = new ArrayList();
+        List excludes = new ArrayList();
         includes.add( "abc" );
         includes.add( "cde" );
-        List excludes = new ArrayList();
         excludes.add( "xx1" );
         excludes.add( "xx2" );
 
-        BooterSerializer booterSerializer = new BooterSerializer();
-        booterConfiguration.setDirectoryScannerOptions( aDir, includes, excludes );
-        Properties props = new Properties();
-        booterSerializer.setForkProperties( props, new ArrayList(), booterConfiguration, forkConfiguration );
-        final File propsTest = booterSerializer.writePropertiesFile( "propsTest", props, false, null );
+        DirectoryScannerParameters directoryScannerParameters = new DirectoryScannerParameters( aDir, includes, excludes, Boolean.TRUE );
+        ClassLoaderConfiguration forkConfiguration = getForkConfiguration();
+        BooterConfiguration booterConfiguration = getTestBooterConfiguration( forkConfiguration, directoryScannerParameters,
+                                                                              new ArrayList(  ));
+        BooterConfiguration read = saveAndReload( forkConfiguration, booterConfiguration );
 
-        BooterDeserializer booterDeserializer = new BooterDeserializer();
-        BooterConfiguration read = booterDeserializer.deserialize( new FileInputStream( propsTest ) );
 
         Assert.assertEquals( aDir, read.getBaseDir() );
         Assert.assertEquals( includes.get( 0 ), read.getIncludes().get( 0 ) );
@@ -78,11 +82,129 @@ public class BooterDeserializerTest
 
     }
 
-    private BooterConfiguration getTestBooterConfiguration( ClassLoaderConfiguration forkConfiguration )
+    public void testReports()
+        throws IOException
+    {
+        DirectoryScannerParameters directoryScannerParameters = getDirectoryScannerParameters();
+        ClassLoaderConfiguration forkConfiguration = getForkConfiguration();
+        List reports = new ArrayList(  );
+        reports.add( "abc" );
+        reports.add( "cde" );
+        reports.add( "efg" );
+
+        BooterConfiguration booterConfiguration = getTestBooterConfiguration( forkConfiguration, directoryScannerParameters, reports );
+
+        booterConfiguration.getReports().add( "abc" );
+        booterConfiguration.getReports().add( "cde" );
+        booterConfiguration.getReports().add( "efg" );
+
+        BooterConfiguration reloaded = saveAndReload( forkConfiguration, booterConfiguration );
+
+        Assert.assertEquals( "abc", reloaded.getReports().get( 0 ) );
+        Assert.assertEquals( "cde", reloaded.getReports().get( 1 ) );
+        Assert.assertEquals( "efg", reloaded.getReports().get( 2 ) );
+    }
+
+    public void testTestNgArtifact()
+        throws IOException
+    {
+        BooterConfiguration reloaded = getReloladedConfig();
+
+        Assert.assertEquals( "5.0", reloaded.getTestNg().getVersion());
+        Assert.assertEquals( "ABC", reloaded.getTestNg().getClassifier());
+    }
+
+    public void testTestSuiteDefinition()
+        throws IOException
+    {
+        BooterConfiguration reloaded = getReloladedConfig();
+
+        TestSuiteDefinition testSuiteDefinition = reloaded.getTestSuiteDefinition();
+        File[] suiteXmlFiles = testSuiteDefinition.getSuiteXmlFiles();
+        File[] expected = getSuiteXmlFiles();
+        Assert.assertEquals( expected[0], suiteXmlFiles[0] );
+        Assert.assertEquals( expected[1], suiteXmlFiles[1] );
+        Assert.assertEquals( aTest, testSuiteDefinition.getTestForFork() );
+        Assert.assertEquals( getTEstSourceDirectory(), testSuiteDefinition.getTestSourceDirectory() );
+        Assert.assertEquals( aUserRequestedTest, testSuiteDefinition.getRequestedTest() );
+
+
+    }
+    public void testProvider()
+        throws IOException
+    {
+        BooterConfiguration reloaded = getReloladedConfig();
+
+        assertEquals("com.provider", reloaded.getProviderConfiguration().getClassName());
+
+    }
+
+    public void testFailIfNoTests()
+        throws IOException
+    {
+        BooterConfiguration reloaded = getReloladedConfig();
+        assertTrue(reloaded.isFailIfNoTests().booleanValue());
+
+    }
+
+    private BooterConfiguration getReloladedConfig()
+        throws IOException
+    {
+        DirectoryScannerParameters directoryScannerParameters = getDirectoryScannerParameters();
+        ClassLoaderConfiguration forkConfiguration = getForkConfiguration();
+        BooterConfiguration booterConfiguration = getTestBooterConfiguration( forkConfiguration, directoryScannerParameters,
+                                                                              new ArrayList(  ) );
+        return saveAndReload( forkConfiguration, booterConfiguration );
+    }
+
+    private DirectoryScannerParameters getDirectoryScannerParameters()
+    {
+        File aDir = new File( "." );
+        List includes = new ArrayList();
+        List excludes = new ArrayList();
+        includes.add( "abc" );
+        includes.add( "cde" );
+        excludes.add( "xx1" );
+        excludes.add( "xx2" );
+
+        return new DirectoryScannerParameters( aDir, includes, excludes, Boolean.TRUE );
+    }
+
+    private BooterConfiguration saveAndReload( ClassLoaderConfiguration forkConfiguration,
+                                               BooterConfiguration booterConfiguration )
+        throws IOException
+    {
+        BooterSerializer booterSerializer = new BooterSerializer();
+        Properties props = new Properties();
+        booterSerializer.setForkProperties( props, booterConfiguration, forkConfiguration );
+        final File propsTest = booterSerializer.writePropertiesFile( "propsTest", props, false, null );
+        BooterDeserializer booterDeserializer = new BooterDeserializer();
+        return booterDeserializer.deserialize( new FileInputStream( propsTest ) );
+    }
+
+    private BooterConfiguration getTestBooterConfiguration( ClassLoaderConfiguration forkConfiguration,
+                                                            DirectoryScannerParameters directoryScannerParameters,
+                                                            List reports )
         throws IOException
     {
         ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( true, true );
 
-        return new BooterConfiguration( false, forkConfiguration, classpathConfiguration, false );
+        ReporterConfiguration reporterConfiguration = new ReporterConfiguration( new File( "." ), Boolean.TRUE );
+        TestSuiteDefinition testSuiteDefinition = new TestSuiteDefinition( getSuiteXmlFiles(), aTest,
+                                                                           getTEstSourceDirectory(), aUserRequestedTest );
+        ProviderConfiguration providerConfiguration = new ProviderConfiguration( "com.provider" );
+        return new BooterConfiguration( new Properties(), false, forkConfiguration, classpathConfiguration, false,
+                                        reporterConfiguration, new TestArtifactInfo( "5.0", "ABC" ),
+                                 testSuiteDefinition, directoryScannerParameters, true, reports, providerConfiguration );
+    }
+
+    private File getTEstSourceDirectory()
+    {
+        return new File( "TestSrc" );
+    }
+
+    private File[] getSuiteXmlFiles()
+    {
+        return new File[]{new File("A1"), new File("A2")};
     }
 }

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ApiReflector.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ApiReflector.java?rev=1039777&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ApiReflector.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ApiReflector.java Sat Nov 27 22:41:23 2010
@@ -0,0 +1,57 @@
+package org.apache.maven.surefire;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.providerapi.ProviderConfiguration;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class ApiReflector
+{
+    private SurefireProvider createProvider( ProviderConfiguration providerConfiguration,
+                                             ClassLoader surefireClassLoader )
+        throws TestSetFailedException
+    {
+
+        final Class aClass;
+        try
+        {
+            aClass = surefireClassLoader.loadClass( providerConfiguration.getClassName() );
+            final Object objectProvider = aClass.newInstance();
+            return (SurefireProvider) objectProvider;
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new TestSetFailedException( e );
+        }
+        catch ( InstantiationException e )
+        {
+            throw new TestSetFailedException( e );
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new TestSetFailedException( e );
+        }
+    }
+
+
+}

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

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ProviderInvoker.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ProviderInvoker.java?rev=1039777&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ProviderInvoker.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/ProviderInvoker.java Sat Nov 27 22:41:23 2010
@@ -0,0 +1,113 @@
+package org.apache.maven.surefire;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.booter.SurefireReflector;
+import org.apache.maven.surefire.providerapi.ProviderConfiguration;
+import org.apache.maven.surefire.providerapi.ReporterManagerFactoryAware;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.report.ReporterManagerFactory2;
+import org.apache.maven.surefire.report.RunStatistics;
+import org.apache.maven.surefire.suite.RunResult;
+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.TestSetFailedException;
+import org.apache.maven.surefire.testset.TestSuiteDefinition;
+
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Just outside the actual provider, always in the same classloader as the provider
+ *
+ * @author Jason van Zyl
+ * @author Kristian Rosenvold
+ * @version $Id$
+ */
+public class ProviderInvoker
+{
+
+    private static final int NO_TESTS = 254;
+
+    public int run( ReporterConfiguration reporterConfiguration, List reportDefinitions,
+                    ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Properties results,
+                    Boolean failIfNoTests, TestSuiteDefinition testSuiteDefinition, TestArtifactInfo testArtifactInfo,
+                    ProviderConfiguration providerConfiguration, DirectoryScannerParameters directoryScannerParameters )
+        throws ReporterException, TestSetFailedException
+    {
+        ReporterManagerFactory reporterManagerFactory =
+            new ReporterManagerFactory2( reportDefinitions, surefireClassLoader, reporterConfiguration );
+
+        RunStatistics runStatistics = reporterManagerFactory.getGlobalRunStatistics();
+        if ( results != null )
+        {
+            runStatistics.initResultsFromProperties( results );
+        }
+
+        int totalTests = 0;
+
+        SurefireReflector surefireReflector = new SurefireReflector( surefireClassLoader );
+        Object o = surefireReflector.newInstance( providerConfiguration );
+        SurefireProvider provider = (SurefireProvider) o;
+        surefireReflector.setIfDirScannerAware( o, directoryScannerParameters );
+        surefireReflector.setTestSuiteDefinitionAware( o, testSuiteDefinition );
+        surefireReflector.setProviderPropertiesAware( o, results );
+        surefireReflector.setReporterConfigurationAware( o, reporterConfiguration );
+        if ( o instanceof ReporterManagerFactoryAware )
+        {
+            ( (ReporterManagerFactoryAware) o ).setReporterManagerFactory( reporterManagerFactory );
+        }
+        surefireReflector.setTestClassLoaderAware( o, testsClassLoader );
+        surefireReflector.setTestArtifactInfoAware( o, testArtifactInfo );
+
+        RunResult invoke = provider.invoke();
+        int testCount = invoke.getCompletedCount(); // TODO: Verify that this is correct digit
+        if ( testCount > 0 )
+        {
+            totalTests += testCount;
+        }
+
+        if ( totalTests == 0 )
+        {
+            reporterManagerFactory.createReporterManager().writeMessage( "There are no tests to run." );
+        }
+
+        reporterManagerFactory.close();
+
+        if ( results != null )
+        {
+            runStatistics.updateResultsProperties( results );
+        }
+
+        if ( failIfNoTests.booleanValue() )
+        {
+            if ( runStatistics.getCompletedCount() == 0 )
+            {
+                return NO_TESTS;
+            }
+        }
+
+        return runStatistics.getRunResult().getBooterCode();
+    }
+}

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

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java?rev=1039777&r1=1039776&r2=1039777&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java Sat Nov 27 22:41:23 2010
@@ -35,6 +35,7 @@ import java.util.Properties;
  * @author Jason van Zyl
  * @version $Id$
  */
+// todo: Remove once we build with 2.7
 public class Surefire
 {
 
@@ -82,6 +83,7 @@ public class Surefire
 
         SuiteDefinition suiteDefinition =
             SuiteDefinition.fromBooterFormat( Collections.singletonList( testSuiteDefinition ) );
+
         RunStatistics runStatistics = reporterManagerFactory.getGlobalRunStatistics();
         if ( results != null )
         {
@@ -153,8 +155,7 @@ public class Surefire
             totalTests += testCount;
         }
 
-        if ( totalTests == 0 )
-        {
+        if ( totalTests == 0 ){
             reporterManagerFactory.createReporterManager().writeMessage( "There are no tests to run." );
         }
         else

Added: 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=1039777&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java Sat Nov 27 22:41:23 2010
@@ -0,0 +1,486 @@
+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.ProviderInvoker;
+import org.apache.maven.surefire.providerapi.DirectoryScannerParametersAware;
+import org.apache.maven.surefire.providerapi.ProviderConfiguration;
+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.TestSuiteDefinition;
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Does reflection based invocation of the surefire methods.
+ * <p/>
+ * This is to avoid compilications with linkage issues
+ *
+ * @author Kristian Rosenvold
+ */
+public class SurefireReflector
+{
+    private final ClassLoader classLoader;
+
+    private final Class providerInvoker;
+
+    private final Class reporterConfiguration;
+
+    private final Class testSuiteDefinition;
+
+    private final Class testArtifactInfo;
+
+    private final Class providerConfiguration;
+
+    private final Class testArtifactInfoAware;
+
+    private final Class directoryScannerParameters;
+
+    private final Class directoryScannerParametersAware;
+
+    private final Class testSuiteDefinitionAware;
+
+    private final Class testClassLoaderAware;
+
+    private final Class reporterConfigurationAware;
+
+    private final Class providerPropertiesAware;
+
+
+    public SurefireReflector( ClassLoader surefireClassLoader )
+    {
+        this.classLoader = surefireClassLoader;
+        try
+        {
+            providerInvoker = surefireClassLoader.loadClass( ProviderInvoker.class.getName() );
+            reporterConfiguration = surefireClassLoader.loadClass( ReporterConfiguration.class.getName() );
+            testSuiteDefinition = surefireClassLoader.loadClass( TestSuiteDefinition.class.getName() );
+            testArtifactInfo = surefireClassLoader.loadClass( TestArtifactInfo.class.getName() );
+            testArtifactInfoAware = surefireClassLoader.loadClass( TestArtifactInfoAware.class.getName() );
+            directoryScannerParameters = surefireClassLoader.loadClass( DirectoryScannerParameters.class.getName() );
+            directoryScannerParametersAware =
+                surefireClassLoader.loadClass( DirectoryScannerParametersAware.class.getName() );
+            testSuiteDefinitionAware = surefireClassLoader.loadClass( TestSuiteDefinitionAware.class.getName() );
+            testClassLoaderAware = surefireClassLoader.loadClass( TestClassLoaderAware.class.getName() );
+            reporterConfigurationAware = surefireClassLoader.loadClass( ReporterConfigurationAware.class.getName() );
+            providerPropertiesAware = surefireClassLoader.loadClass( ProviderPropertiesAware.class.getName() );
+            providerConfiguration = surefireClassLoader.loadClass( ProviderConfiguration.class.getName() );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new RuntimeException( "When loading class", e );
+        }
+    }
+
+
+    /**
+     * @noinspection UnusedDeclaration
+     */
+    class ClassLoaderProxy
+        implements InvocationHandler
+    {
+        private final Object target;
+
+        /**
+         * @param delegate a target
+         * @noinspection UnusedDeclaration
+         */
+        public ClassLoaderProxy( Object delegate )
+        {
+            this.target = delegate;
+        }
+
+        public Object invoke( Object proxy, Method method, Object[] args )
+            throws Throwable
+        {
+            Method delegateMethod = target.getClass().getMethod( method.getName(), method.getParameterTypes() );
+            return delegateMethod.invoke( target, args );
+        }
+    }
+
+
+    public int runProvider( ReporterConfiguration reporterConfiguration, List reportDefinitions,
+                            ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Properties results,
+                            Boolean failIfNoTests, TestSuiteDefinition testSuiteDefinition,
+                            TestArtifactInfo testArtifactInfo, ProviderConfiguration providerConfiguration,
+                            DirectoryScannerParameters dirScannerParams )
+    {
+        Object surefire = instantiateProviderInvoker();
+        Method run = getRunMethod(
+            new Class[]{ this.reporterConfiguration, List.class, ClassLoader.class, ClassLoader.class, Properties.class,
+                Boolean.class, this.testSuiteDefinition, this.testArtifactInfo, this.providerConfiguration,
+                this.directoryScannerParameters } );
+
+        Object[] args = { createReporterConfiguration( reporterConfiguration ), reportDefinitions, surefireClassLoader,
+            testsClassLoader, results, failIfNoTests, createTestSuiteDefinition( testSuiteDefinition ),
+            createTestArtifactInfo( testArtifactInfo ), createProviderConfiguration( providerConfiguration ),
+            createDirectoryScannerParameters( dirScannerParams ) };
+        return invokeRunMethod( surefire, run, args );
+    }
+
+    private Object createProviderConfiguration( ProviderConfiguration providerConfiguration )
+    {
+        if ( providerConfiguration == null )
+        {
+            return null;
+        }
+        Class[] arguments = { String.class };
+        Constructor constructor = getConstructor( this.providerConfiguration, arguments );
+        return newInstance( constructor, new Object[]{ providerConfiguration.getClassName() } );
+    }
+
+    Object createTestSuiteDefinition( TestSuiteDefinition suiteDefinition )
+    {
+        if ( suiteDefinition == null )
+        {
+            return null;
+        }
+        Class[] arguments = { File[].class, String.class, File.class, String.class };
+        Constructor constructor = getConstructor( this.testSuiteDefinition, arguments );
+        return newInstance( constructor,
+                            new Object[]{ suiteDefinition.getSuiteXmlFiles(), suiteDefinition.getTestForFork(),
+                                suiteDefinition.getTestSourceDirectory(), suiteDefinition.getRequestedTest() } );
+    }
+
+
+    Object createDirectoryScannerParameters( DirectoryScannerParameters directoryScannerParameters )
+    {
+        if ( directoryScannerParameters == null )
+        {
+            return null;
+        }
+        Class[] arguments = { File.class, List.class, List.class, Boolean.class };
+        Constructor constructor = getConstructor( this.directoryScannerParameters, arguments );
+        return newInstance( constructor, new Object[]{ directoryScannerParameters.getTestClassesDirectory(),
+            directoryScannerParameters.getIncludes(), directoryScannerParameters.getExcludes(),
+            directoryScannerParameters.isFailIfNoTests() } );
+    }
+
+    Object createTestArtifactInfo( TestArtifactInfo testArtifactInfo )
+    {
+        if ( testArtifactInfo == null )
+        {
+            return null;
+        }
+        Class[] arguments = { String.class, String.class };
+        Constructor constructor = getConstructor( this.testArtifactInfo, arguments );
+        return newInstance( constructor,
+                            new Object[]{ testArtifactInfo.getVersion(), testArtifactInfo.getClassifier() } );
+    }
+
+    Object createReporterConfiguration( ReporterConfiguration reporterConfiguration )
+    {
+        Constructor constructor =
+            getConstructor( this.reporterConfiguration, new Class[]{ File.class, Boolean.class } );
+        return newInstance( constructor, new Object[]{ reporterConfiguration.getReportsDirectory(),
+            reporterConfiguration.isTrimStackTrace() } );
+    }
+
+    private Constructor getConstructor( Class clazz, Class[] arguments )
+    {
+        try
+        {
+            return clazz.getConstructor( arguments );
+        }
+        catch ( NoSuchMethodException e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+
+    private Object newInstance( Constructor constructor, Object[] params )
+    {
+        try
+        {
+            return constructor.newInstance( params );
+        }
+        catch ( InvocationTargetException e )
+        {
+            throw new RuntimeException( e );
+        }
+        catch ( InstantiationException e )
+        {
+            throw new RuntimeException( e );
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+
+    public Object newInstance( ProviderConfiguration providerConfiguration )
+    {
+        try
+        {
+
+            Class clazz = classLoader.loadClass( providerConfiguration.getClassName() );
+            return clazz.newInstance();
+        }
+        catch ( InstantiationException e )
+        {
+            throw new RuntimeException( e );
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new RuntimeException( e );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+
+    public static Object getSuites( Object surefireProvider )
+    {
+        final Method getSuites = getMethod( surefireProvider, "getSuites", new Class[]{ } );
+        return invokeMethod( surefireProvider, getSuites, new Object[]{ } );
+    }
+
+
+    private int invokeRunMethod( Object surefire, Method method, Object[] args )
+        throws RuntimeException
+
+    {
+        try
+        {
+            final Integer invoke = (Integer) method.invoke( surefire, args );
+            return invoke.intValue();
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new RuntimeException( "When instantiating surefire", e );
+        }
+        catch ( InvocationTargetException e )
+        {
+            throw new RuntimeException( e.getTargetException().getMessage(), e.getTargetException() );
+        }
+
+    }
+
+    private static Object invokeSetter( Object surefire, Method method, Object value )
+
+    {
+        try
+        {
+            return method.invoke( surefire, new Object[]{ value } );
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new RuntimeException( "When instantiating surefire", e );
+        }
+        catch ( InvocationTargetException e )
+        {
+            throw new RuntimeException( e.getTargetException().getMessage(), e.getTargetException() );
+        }
+
+    }
+
+    private static Object invokeMethod( Object surefire, Method method, Object[] args )
+
+    {
+        try
+        {
+            return method.invoke( surefire, args );
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new RuntimeException( "When instantiating surefire", e );
+        }
+        catch ( InvocationTargetException e )
+        {
+            throw new RuntimeException( e.getTargetException().getMessage(), e.getTargetException() );
+        }
+
+    }
+
+    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 Method getMethod( Object instance, String methodName, Class[] parameters )
+    {
+        try
+        {
+            return instance.getClass().getMethod( methodName, parameters );
+        }
+        catch ( NoSuchMethodException e )
+        {
+            throw new RuntimeException( "When finding method " + methodName, e );
+        }
+    }
+
+    public void setIfDirScannerAware( Object o, DirectoryScannerParameters dirScannerParams )
+    {
+        if ( isDirectoryScannerParameterAware( o ) )
+        {
+            setDirectoryScannerParameters( o, dirScannerParams );
+        }
+    }
+
+    boolean isDirectoryScannerParameterAware( Object o )
+    {
+        return directoryScannerParametersAware.isAssignableFrom( o.getClass() );
+    }
+
+    public void setDirectoryScannerParameters( Object o, DirectoryScannerParameters dirScannerParams )
+    {
+        final Object param = createDirectoryScannerParameters( dirScannerParams );
+        final Method setter =
+            getMethod( o, "setDirectoryScannerParameters", new Class[]{ directoryScannerParameters } );
+        invokeSetter( o, setter, param );
+    }
+
+    public void setTestSuiteDefinitionAware( Object o, TestSuiteDefinition testSuiteDefinition2 )
+    {
+        if ( isTestSuiteDefinitionAware( o ) )
+        {
+            setTestSuiteDefinition( o, testSuiteDefinition2 );
+        }
+    }
+
+
+    boolean isTestSuiteDefinitionAware( Object o )
+    {
+        return testSuiteDefinitionAware.isAssignableFrom( o.getClass() );
+    }
+
+    void setTestSuiteDefinition( Object o, TestSuiteDefinition testSuiteDefinition1 )
+    {
+        final Object param = createTestSuiteDefinition( testSuiteDefinition1 );
+        final Method setter = getMethod( o, "setTestSuiteDefinition", new Class[]{ testSuiteDefinition } );
+        invokeSetter( o, setter, param );
+    }
+
+    public void setProviderPropertiesAware( Object o, Properties properties )
+    {
+        if ( isProviderPropertiesAware( o ) )
+        {
+            setProviderProperties( o, properties );
+        }
+    }
+
+
+    boolean isProviderPropertiesAware( Object o )
+    {
+        return providerPropertiesAware.isAssignableFrom( o.getClass() );
+    }
+
+    void setProviderProperties( Object o, Properties providerProperties )
+    {
+        final Method setter = getMethod( o, "setProviderProperties", new Class[]{ Properties.class } );
+        invokeSetter( o, setter, providerProperties );
+    }
+
+    public void setReporterConfigurationAware( Object o, ReporterConfiguration reporterConfiguration1 )
+    {
+        if ( isReporterConfigurationAwareAware( o ) )
+        {
+            setReporterConfiguration( o, reporterConfiguration1 );
+        }
+    }
+
+    boolean isReporterConfigurationAwareAware( Object o )
+    {
+        return reporterConfigurationAware.isAssignableFrom( o.getClass() );
+    }
+
+    void setReporterConfiguration( Object o, ReporterConfiguration reporterConfiguration )
+    {
+        final Object param = createReporterConfiguration( reporterConfiguration );
+        final Method setter = getMethod( o, "setReporterConfiguration", new Class[]{ this.reporterConfiguration } );
+        invokeSetter( o, setter, param );
+    }
+
+    public void setTestClassLoaderAware( Object o, ClassLoader testClassLoader )
+    {
+        if ( isTestClassLoaderAware( o ) )
+        {
+            setTestClassLoader( o, testClassLoader );
+        }
+    }
+
+    boolean isTestClassLoaderAware( Object o )
+    {
+        return testClassLoaderAware.isAssignableFrom( o.getClass() );
+    }
+
+    void setTestClassLoader( Object o, ClassLoader aClassLoader )
+    {
+        final Method setter = getMethod( o, "setTestClassLoader", new Class[]{ ClassLoader.class } );
+        invokeSetter( o, setter, aClassLoader );
+    }
+
+    public void setTestArtifactInfoAware( Object o, TestArtifactInfo testArtifactInfo1 )
+    {
+        if ( isTestArtifactInfoAware( o ) )
+        {
+            setTestArtifactInfo( o, testArtifactInfo1 );
+        }
+    }
+
+    public boolean isTestArtifactInfoAware( Object o )
+    {
+        return testArtifactInfoAware.isAssignableFrom( o.getClass() );
+    }
+
+    void setTestArtifactInfo( Object o, TestArtifactInfo testArtifactInfo )
+    {
+        final Object param = createTestArtifactInfo( testArtifactInfo );
+        final Method setter = getMethod( o, "setTestArtifactInfo", new Class[]{ this.testArtifactInfo } );
+        invokeSetter( o, setter, param );
+    }
+
+}

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

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ApiSerializer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ApiSerializer.java?rev=1039777&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ApiSerializer.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ApiSerializer.java Sat Nov 27 22:41:23 2010
@@ -0,0 +1,51 @@
+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.suite.RunResult;
+
+import java.util.Properties;
+
+public class ApiSerializer
+{
+    private static final String RESULTS_ERRORS = "errors";
+
+    private static final String RESULTS_COMPLETED_COUNT = "completedCount";
+
+    private static final String RESULTS_FAILURES = "failures";
+
+    private static final String RESULTS_SKIPPED = "skipped";
+
+    public RunResult fromProperties( Properties results )
+    {
+        int completedCount = Integer.valueOf( results.getProperty( RESULTS_COMPLETED_COUNT, "0" ) ).intValue();
+        int errors = Integer.valueOf( results.getProperty( RESULTS_ERRORS, "0" ) ).intValue();
+        int failures = Integer.valueOf( results.getProperty( RESULTS_FAILURES, "0" ) ).intValue();
+        int skipped = Integer.valueOf( results.getProperty( RESULTS_SKIPPED, "0" ) ).intValue();
+        return new RunResult( completedCount, errors, failures, skipped );
+    }
+
+    public void updateProperties( Properties results, RunResult runResult )
+    {
+        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() ) );
+    }
+}
\ No newline at end of file

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

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/DirectoryScannerParametersAware.java (from r1039320, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefConsoleReporter.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/DirectoryScannerParametersAware.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/DirectoryScannerParametersAware.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefConsoleReporter.java&r1=1039320&r2=1039777&rev=1039777&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefConsoleReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/DirectoryScannerParametersAware.java Sat Nov 27 22:41:23 2010
@@ -1,5 +1,4 @@
-package org.apache.maven.surefire.report;
-
+package org.apache.maven.surefire.providerapi;
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,18 +18,14 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
+import org.apache.maven.surefire.testset.DirectoryScannerParameters;
+import org.apache.maven.surefire.util.DirectoryScanner;
+
 /**
- * Brief format console reporter.
- *
- * @author <a href="mailto:jruiz@exist.com">Johnny R. Ruiz III</a>
- * @version $Id$
+ * @author Kristian Rosenvold
  */
-
-public class BriefConsoleReporter
-    extends AbstractConsoleReporter
+public interface DirectoryScannerParametersAware
 {
-    public BriefConsoleReporter( Boolean trimStackTrace )
-    {
-        super( BRIEF, trimStackTrace );
-    }
+    public void setDirectoryScannerParameters(
+        org.apache.maven.surefire.testset.DirectoryScannerParameters directoryScanner );
 }



Mime
View raw message