maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1035052 [1/2] - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ surefire-api/src/main/java/org/apache/maven/surefire/ surefire-api/src/main/java/org/apache/maven/surefire/suite/ surefire-api/...
Date Sun, 14 Nov 2010 19:19:02 GMT
Author: krosenvold
Date: Sun Nov 14 19:19:01 2010
New Revision: 1035052

URL: http://svn.apache.org/viewvc?rev=1035052&view=rev
Log:
o Extracted BooterSerializer from SurefireBooter

Extracted an interface for directory scanner. Minor refactorings with no functional change.

All this is initial footwork to get SUREFIRE-141 moving. It looks like it's going to be quite
a journey

Added:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SuiteDefinition.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java   (contents, props changed)
      - copied, changed from r1034027, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java   (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterSerializer.java
      - copied, changed from r1034027, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConfiguration.java
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterSerializerTest.java   (with props)
Removed:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java
Modified:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.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/suite/AbstractDirectoryTestSuite.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.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/SurefireBooter.java
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterConversionTest.java
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkConfigurationTest.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.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=1035052&r1=1035051&r2=1035052&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 Sun Nov 14 19:19:01 2010
@@ -45,6 +45,7 @@ import org.apache.maven.surefire.report.
 import org.apache.maven.surefire.report.FileReporter;
 import org.apache.maven.surefire.report.ForkingConsoleReporter;
 import org.apache.maven.surefire.report.XMLReporter;
+import org.apache.maven.surefire.suite.SuiteDefinition;
 import org.apache.maven.toolchain.Toolchain;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -306,6 +307,7 @@ public abstract class AbstractSurefireMo
             throw new MojoExecutionException( "Error to resolving surefire provider dependency: " + e.getMessage(), e );
         }
 
+        String providerName;
         if ( getSuiteXmlFiles() != null && getSuiteXmlFiles().length > 0 && getTest() == null )
         {
             if ( testNgArtifact == null )
@@ -314,11 +316,11 @@ public abstract class AbstractSurefireMo
             }
 
             // TODO: properties should be passed in here too
-            booterConfiguration.addTestSuite( "org.apache.maven.surefire.testng.TestNGXmlTestSuite",
-                                              new Object[]{ getSuiteXmlFiles(),
-                                                  getTestSourceDirectory().getAbsolutePath(),
-                                                  testNgArtifact.getVersion(), testNgArtifact.getClassifier(),
-                                                  getProperties(), getReportsDirectory() } );
+            providerName = "org.apache.maven.surefire.testng.TestNGXmlTestSuite";
+            Object[] params =
+                { getSuiteXmlFiles(), getTestSourceDirectory().getAbsolutePath(), testNgArtifact.getVersion(),
+                    testNgArtifact.getClassifier(), getProperties(), getReportsDirectory() };
+            booterConfiguration.setSuiteDefinition( new SuiteDefinition( providerName, params ) );
         }
         else
         {
@@ -375,42 +377,45 @@ public abstract class AbstractSurefireMo
 
             if ( testNgArtifact != null )
             {
-                booterConfiguration.addTestSuite( "org.apache.maven.surefire.testng.TestNGDirectoryTestSuite",
-                                                  new Object[]{ getTestClassesDirectory(), includes, excludes,
-                                                      getTestSourceDirectory().getAbsolutePath(),
-                                                      testNgArtifact.getVersion(), testNgArtifact.getClassifier(),
-                                                      getProperties(), getReportsDirectory() } );
+                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 ) );
             }
             else
             {
-                String junitDirectoryTestSuite;
                 if ( isAnyConcurrencySelected() && isJunit47Compatible( junitArtifact ) )
                 {
-                    junitDirectoryTestSuite = "org.apache.maven.surefire.junitcore.JUnitCoreDirectoryTestSuite";
+                    providerName = "org.apache.maven.surefire.junitcore.JUnitCoreDirectoryTestSuite";
                     getLog().info( "Concurrency config is " + getProperties().toString() );
-                    booterConfiguration.addTestSuite( junitDirectoryTestSuite,
-                                                      new Object[]{ getTestClassesDirectory(), includes, excludes,
-                                                          getProperties() } );
+                    Object[] params = { getTestClassesDirectory(), includes, excludes, getProperties() };
+                    booterConfiguration.setSuiteDefinition( new SuiteDefinition( providerName, params ) );
                 }
                 else
                 {
                     if ( isAnyJunit4( junitArtifact ) )
                     {
-                        junitDirectoryTestSuite = "org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite";
+                        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.
-                        junitDirectoryTestSuite = "org.apache.maven.surefire.junit.JUnitDirectoryTestSuite";
+                        providerName = "org.apache.maven.surefire.junit.JUnitDirectoryTestSuite";
                     }
-                    booterConfiguration.addTestSuite( junitDirectoryTestSuite,
-                                                      new Object[]{ getTestClassesDirectory(), includes, excludes } );
+                    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 classpathElements = null;
+        List classpathElements;
         try
         {
             classpathElements = generateTestClasspath();
@@ -466,6 +471,7 @@ public abstract class AbstractSurefireMo
         fork.setForkMode( getForkMode() );
 
         File tmpDir = new File( getReportsDirectory().getParentFile(), "surefire" );
+        //noinspection ResultOfMethodCallIgnored
         tmpDir.mkdirs();
         fork.setTempDirectory( tmpDir );
 
@@ -540,6 +546,9 @@ public abstract class AbstractSurefireMo
      *
      * @return List containing the classpath elements
      * @throws org.apache.maven.artifact.DependencyResolutionRequiredException
+     *          when dependency resolution fails
+     * @throws org.apache.maven.plugin.MojoExecutionException
+     *          upon other problems
      */
     public List generateTestClasspath()
         throws DependencyResolutionRequiredException, MojoExecutionException
@@ -593,8 +602,9 @@ public abstract class AbstractSurefireMo
     /**
      * Return a new set containing only the artifacts accepted by the given filter.
      *
-     * @param artifacts
-     * @param filter
+     * @param artifacts The unfiltered artifacts
+     * @param filter    The filter to apply
+     * @return The filtered result
      */
     private Set filterArtifacts( Set artifacts, ArtifactFilter filter )
     {
@@ -670,8 +680,9 @@ public abstract class AbstractSurefireMo
         {
             Artifact artifact = (Artifact) i.next();
 
-            getLog().debug( "Adding to " + getPluginName() + " booter test classpath: " +
-                                artifact.getFile().getAbsolutePath() + " Scope: " + artifact.getScope() );
+            getLog().debug(
+                "Adding to " + getPluginName() + " booter test classpath: " + artifact.getFile().getAbsolutePath() +
+                    " Scope: " + artifact.getScope() );
 
             classpathConfiguration.addSurefireBootClassPathUrl( artifact.getFile().getAbsolutePath() );
         }
@@ -776,7 +787,7 @@ public abstract class AbstractSurefireMo
      * printSummary.
      *
      * @param booterConfiguration The surefire booter that will run tests.
-     * @param forking
+     * @param forking             forking
      */
     private void addReporters( BooterConfiguration booterConfiguration, boolean forking )
     {

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=1035052&r1=1035051&r2=1035052&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 Sun Nov 14 19:19:01 2010
@@ -22,12 +22,11 @@ package org.apache.maven.surefire;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.report.RunStatistics;
+import org.apache.maven.surefire.suite.SuiteDefinition;
 import org.apache.maven.surefire.suite.SurefireTestSuite;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
@@ -38,24 +37,26 @@ import java.util.Properties;
  */
 public class Surefire
 {
-    
+
     private static final int SUCCESS = 0;
+
     private static final int NO_TESTS = 254;
+
     private static final int FAILURE = 255;
-    
+
     public static final String SUREFIRE_BUNDLE_NAME = "org.apache.maven.surefire.surefire";
 
     // DGF backwards compatibility
     public boolean run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
-                    ClassLoader surefireClassLoader, ClassLoader testsClassLoader )
+                        ClassLoader surefireClassLoader, ClassLoader testsClassLoader )
         throws ReporterException, TestSetFailedException
     {
         return run( reportDefinitions, testSuiteDefinition, testSetName, surefireClassLoader, testsClassLoader, null,
                     Boolean.FALSE ) == 0;
     }
-    
+
     public int run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
-                        ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Boolean failIfNoTests )
+                    ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Boolean failIfNoTests )
         throws ReporterException, TestSetFailedException
     {
         return run( reportDefinitions, testSuiteDefinition, testSetName, surefireClassLoader, testsClassLoader, null,
@@ -64,21 +65,23 @@ public class Surefire
 
     // DGF backwards compatibility
     public boolean run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
-                    ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Properties results )
+                        ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Properties results )
         throws ReporterException, TestSetFailedException
     {
-        return run( reportDefinitions, testSuiteDefinition, testSetName, surefireClassLoader, testsClassLoader,
-                    results, Boolean.FALSE ) == 0;
+        return run( reportDefinitions, testSuiteDefinition, testSetName, surefireClassLoader, testsClassLoader, results,
+                    Boolean.FALSE ) == 0;
     }
-    
+
     public int run( List reportDefinitions, Object[] testSuiteDefinition, String testSetName,
                     ClassLoader surefireClassLoader, ClassLoader testsClassLoader, Properties results,
                     Boolean failIfNoTests )
         throws ReporterException, TestSetFailedException
     {
         ReporterManagerFactory reporterManagerFactory =
-            new ReporterManagerFactory( reportDefinitions, surefireClassLoader);
+            new ReporterManagerFactory( reportDefinitions, surefireClassLoader );
 
+        SuiteDefinition suiteDefinition =
+            SuiteDefinition.fromBooterFormat( Collections.singletonList( testSuiteDefinition ) );
         RunStatistics runStatistics = reporterManagerFactory.getGlobalRunStatistics();
         if ( results != null )
         {
@@ -87,7 +90,7 @@ public class Surefire
 
         int totalTests = 0;
 
-        SurefireTestSuite suite = createSuiteFromDefinition( testSuiteDefinition, surefireClassLoader, testsClassLoader );
+        SurefireTestSuite suite = createSuiteFromDefinition( suiteDefinition, surefireClassLoader, testsClassLoader );
 
         int testCount = suite.getNumTests();
         if ( testCount > 0 )
@@ -118,7 +121,6 @@ public class Surefire
                 return NO_TESTS;
             }
         }
-        
 
         return runStatistics.isProblemFree() ? SUCCESS : FAILURE;
 
@@ -128,33 +130,27 @@ public class Surefire
                         ClassLoader testsClassLoader )
         throws ReporterException, TestSetFailedException
     {
-        return run ( reportDefinitions, testSuiteDefinitions, surefireClassLoader, testsClassLoader, Boolean.FALSE )
-               == 0;
+        return run( reportDefinitions, testSuiteDefinitions, surefireClassLoader, testsClassLoader, Boolean.FALSE ) ==
+            0;
     }
+
     public int run( List reportDefinitions, List testSuiteDefinitions, ClassLoader surefireClassLoader,
-                        ClassLoader testsClassLoader, Boolean failIfNoTests )
+                    ClassLoader testsClassLoader, Boolean failIfNoTests )
         throws ReporterException, TestSetFailedException
     {
         ReporterManagerFactory reporterManagerFactory =
-            new ReporterManagerFactory( reportDefinitions, surefireClassLoader);
+            new ReporterManagerFactory( reportDefinitions, surefireClassLoader );
 
         RunStatistics runStatistics = reporterManagerFactory.getGlobalRunStatistics();
 
-        List suites = new ArrayList();
-
         int totalTests = 0;
-        for ( Iterator i = testSuiteDefinitions.iterator(); i.hasNext(); )
-        {
-            Object[] definition = (Object[]) i.next();
+        SuiteDefinition definition = SuiteDefinition.fromBooterFormat( testSuiteDefinitions );
+        SurefireTestSuite suite = createSuiteFromDefinition( definition, surefireClassLoader, testsClassLoader );
 
-            SurefireTestSuite suite = createSuiteFromDefinition( definition, surefireClassLoader, testsClassLoader );
-
-            int testCount = suite.getNumTests();
-            if ( testCount > 0 )
-            {
-                suites.add( suite );
-                totalTests += testCount;
-            }
+        int testCount = suite.getNumTests();
+        if ( testCount > 0 )
+        {
+            totalTests += testCount;
         }
 
         if ( totalTests == 0 )
@@ -163,11 +159,7 @@ public class Surefire
         }
         else
         {
-            for ( Iterator i = suites.iterator(); i.hasNext(); )
-            {
-                SurefireTestSuite suite = (SurefireTestSuite) i.next();
-                suite.execute( reporterManagerFactory, testsClassLoader );
-            }
+            suite.execute( reporterManagerFactory, testsClassLoader );
         }
 
         reporterManagerFactory.close();
@@ -182,14 +174,11 @@ public class Surefire
         return runStatistics.isProblemFree() ? SUCCESS : FAILURE;
     }
 
-    private SurefireTestSuite createSuiteFromDefinition( Object[] definition, ClassLoader surefireClassLoader,
+    private SurefireTestSuite createSuiteFromDefinition( SuiteDefinition definition, ClassLoader surefireClassLoader,
                                                          ClassLoader testsClassLoader )
         throws TestSetFailedException
     {
-        String suiteClass = (String) definition[0];
-        Object[] params = (Object[]) definition[1];
-
-        SurefireTestSuite suite = instantiateSuite( suiteClass, params, surefireClassLoader );
+        SurefireTestSuite suite = definition.newInstance( surefireClassLoader );
 
         suite.locateTestSets( testsClassLoader );
 
@@ -199,20 +188,21 @@ public class Surefire
         // which is basically way too constrained and locked into a design that is only correct for
         // junit3 with the AbstractDirectoryTestSuite.
         // This same constraint is making it hard to put this code in the proper place.
-        if (isJunit4UpgradeCheck() && suite.getClassesSkippedByValidation().size() > 0 &&
-            suite.getClass().getName().equals( "org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite" )){
+        if ( isJunit4UpgradeCheck() && suite.getClassesSkippedByValidation().size() > 0 &&
+            suite.getClass().getName().equals( "org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite" ) )
+        {
 
-            StringBuilder reason = new StringBuilder(  );
+            StringBuilder reason = new StringBuilder();
             reason.append( "Updated check failed\n" );
             reason.append( "There are tests that would be run with junit4 / surefire 2.6 but not with [2.7,):\n" );
             for ( Iterator i = suite.getClassesSkippedByValidation().iterator(); i.hasNext(); )
             {
                 Class testClass = (Class) i.next();
-                reason.append("   ");
+                reason.append( "   " );
                 reason.append( testClass.getCanonicalName() );
-                reason.append("\n");
+                reason.append( "\n" );
             }
-            throw new TestSetFailedException(reason.toString());
+            throw new TestSetFailedException( reason.toString() );
         }
 
         return suite;
@@ -223,73 +213,4 @@ public class Surefire
         final String property = System.getProperty( "surefire.junit4.upgradecheck" );
         return property != null;
     }
-
-    // This reflection is not due to linkage issues, but only an attempt at being generic.
-    public static Object instantiateObject( String className, Object[] params, ClassLoader classLoader )
-        throws TestSetFailedException, ClassNotFoundException, NoSuchMethodException
-    {
-        Class clazz = classLoader.loadClass( className );
-
-        Object object;
-        try
-        {
-            if ( params != null )
-            {
-                Class[] paramTypes = new Class[params.length];
-
-                for ( int j = 0; j < params.length; j++ )
-                {
-                    if ( params[j] == null )
-                    {
-                        paramTypes[j] = String.class;
-                    }
-                    else
-                    {
-                        paramTypes[j] = params[j].getClass();
-                    }
-                }
-
-                Constructor constructor = clazz.getConstructor( paramTypes );
-
-                object = constructor.newInstance( params );
-            }
-            else
-            {
-                object = clazz.newInstance();
-            }
-        }
-        catch ( IllegalAccessException e )
-        {
-            throw new TestSetFailedException( "Unable to instantiate object: " + e.getMessage(), e );
-        }
-        catch ( InvocationTargetException e )
-        {
-            throw new TestSetFailedException( e.getTargetException().getMessage(), e.getTargetException() );
-        }
-        catch ( InstantiationException e )
-        {
-            throw new TestSetFailedException( "Unable to instantiate object: " + e.getMessage(), e );
-        }
-        return object;
-    }
-
-    // This reflection is not due to linkage issues, but only an attempt at being generic.
-    private static SurefireTestSuite instantiateSuite( String suiteClass, Object[] params, ClassLoader classLoader )
-        throws TestSetFailedException
-    {
-        try
-        {
-            return (SurefireTestSuite) instantiateObject( suiteClass, params, classLoader );
-        }
-        catch ( ClassNotFoundException e )
-        {
-            throw new TestSetFailedException( "Unable to find class to create suite '" + suiteClass + "'", e );
-        }
-        catch ( NoSuchMethodException e )
-        {
-            throw new TestSetFailedException(
-                "Unable to find appropriate constructor to create suite: " + e.getMessage(), e );
-        }
-    }
-
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java?rev=1035052&r1=1035051&r2=1035052&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java Sun Nov 14 19:19:01 2010
@@ -21,12 +21,13 @@ package org.apache.maven.surefire.suite;
 
 import org.apache.maven.surefire.Surefire;
 import org.apache.maven.surefire.report.ReporterManagerFactory;
-import org.apache.maven.surefire.util.SurefireDirectoryScanner;
+import org.apache.maven.surefire.util.DefaultDirectoryScanner;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManager;
 import org.apache.maven.surefire.testset.SurefireTestSet;
 import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.DirectoryScanner;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -48,16 +49,16 @@ public abstract class AbstractDirectoryT
     private int totalTests;
 
     private List classesSkippedByValidation = new ArrayList();
-    
-    private final SurefireDirectoryScanner surefireDirectoryScanner;
+
+    private final DirectoryScanner surefireDirectoryScanner;
 
 
     protected AbstractDirectoryTestSuite( File basedir, List includes, List excludes )
     {
-        this.surefireDirectoryScanner = new SurefireDirectoryScanner(basedir, includes, excludes);
+        this.surefireDirectoryScanner = new DefaultDirectoryScanner( basedir, includes, excludes );
     }
 
-    public Map locateTestSets( ClassLoader classLoader)
+    public Map locateTestSets( ClassLoader classLoader )
         throws TestSetFailedException
     {
         if ( testSets != null )
@@ -66,26 +67,26 @@ public abstract class AbstractDirectoryT
         }
         testSets = new TreeMap();
 
-        Class[] locatedClasses = surefireDirectoryScanner.locateTestClasses( classLoader);
+        Class[] locatedClasses = surefireDirectoryScanner.locateTestClasses( classLoader );
 
         for ( int i = 0; i < locatedClasses.length; i++ )
         {
             Class testClass = locatedClasses[i];
             SurefireTestSet testSet = createTestSet( testClass, classLoader );
 
-                if ( testSet == null )
-                {
-                    classesSkippedByValidation.add(  testClass );
-                    continue;
-                }
-
-                if ( testSets.containsKey( testSet.getName() ) )
-                {
-                    throw new TestSetFailedException( "Duplicate test set '" + testSet.getName() + "'" );
-                }
-                testSets.put( testSet.getName(), testSet );
+            if ( testSet == null )
+            {
+                classesSkippedByValidation.add( testClass );
+                continue;
+            }
+
+            if ( testSets.containsKey( testSet.getName() ) )
+            {
+                throw new TestSetFailedException( "Duplicate test set '" + testSet.getName() + "'" );
+            }
+            testSets.put( testSet.getName(), testSet );
 
-                totalTests++;
+            totalTests++;
         }
 
         return Collections.unmodifiableSortedMap( testSets );
@@ -152,7 +153,7 @@ public abstract class AbstractDirectoryT
 
     public List getClassesSkippedByValidation()
     {
-        return Collections.unmodifiableList(classesSkippedByValidation);
+        return Collections.unmodifiableList( classesSkippedByValidation );
     }
 
     public int getNumTests()

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SuiteDefinition.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SuiteDefinition.java?rev=1035052&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SuiteDefinition.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SuiteDefinition.java Sun Nov 14 19:19:01 2010
@@ -0,0 +1,132 @@
+package org.apache.maven.surefire.suite;
+/*
+ * 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.testset.TestSetFailedException;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
+import java.util.List;
+
+public class SuiteDefinition
+{
+    private final String suiteClassName;
+
+    private final Object[] params;
+
+    public SuiteDefinition( String suiteClassName, Object[] params )
+    {
+        this.suiteClassName = suiteClassName;
+        this.params = params;
+    }
+
+
+    public SurefireTestSuite newInstance( ClassLoader surefireClassLoader )
+        throws TestSetFailedException
+    {
+
+        return instantiateSuite( suiteClassName, params, surefireClassLoader );
+    }
+
+    public List asBooterFormat()
+    {
+        return Collections.singletonList( new Object[]{ suiteClassName, params } );
+    }
+
+    public static SuiteDefinition fromBooterFormat( List testSuiteDefinitions )
+    {
+        if ( testSuiteDefinitions.size() != 1 )
+        {
+            throw new IllegalStateException( "No more than 1 SuiteDefinition supported" );
+        }
+        Object[] item = (Object[]) testSuiteDefinitions.get( 0 );
+        String suiteClassName1 = (String) item[0];
+        return new SuiteDefinition( suiteClassName1, (Object[]) item[1] );
+    }
+
+    // This reflection is not due to linkage issues, but only an attempt at being generic.
+    private static Object instantiateObject( String className, Object[] params, ClassLoader classLoader )
+        throws TestSetFailedException, ClassNotFoundException, NoSuchMethodException
+    {
+        Class clazz = classLoader.loadClass( className );
+
+        Object object;
+        try
+        {
+            if ( params != null )
+            {
+                Class[] paramTypes = new Class[params.length];
+
+                for ( int j = 0; j < params.length; j++ )
+                {
+                    if ( params[j] == null )
+                    {
+                        paramTypes[j] = String.class;
+                    }
+                    else
+                    {
+                        paramTypes[j] = params[j].getClass();
+                    }
+                }
+
+                Constructor constructor = clazz.getConstructor( paramTypes );
+
+                object = constructor.newInstance( params );
+            }
+            else
+            {
+                object = clazz.newInstance();
+            }
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new TestSetFailedException( "Unable to instantiate object: " + e.getMessage(), e );
+        }
+        catch ( InvocationTargetException e )
+        {
+            throw new TestSetFailedException( e.getTargetException().getMessage(), e.getTargetException() );
+        }
+        catch ( InstantiationException e )
+        {
+            throw new TestSetFailedException( "Unable to instantiate object: " + e.getMessage(), e );
+        }
+        return object;
+    }
+
+    // This reflection is not due to linkage issues, but only an attempt at being generic.
+    private static SurefireTestSuite instantiateSuite( String suiteClass, Object[] params, ClassLoader classLoader )
+        throws TestSetFailedException
+    {
+        try
+        {
+            return (SurefireTestSuite) instantiateObject( suiteClass, params, classLoader );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new TestSetFailedException( "Unable to find class to create suite '" + suiteClass + "'", e );
+        }
+        catch ( NoSuchMethodException e )
+        {
+            throw new TestSetFailedException(
+                "Unable to find appropriate constructor to create suite: " + e.getMessage(), e );
+        }
+    }
+
+}

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

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java (from r1034027, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java&r1=1034027&r2=1035052&rev=1035052&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireDirectoryScanner.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java Sun Nov 14 19:19:01 2010
@@ -27,14 +27,20 @@ import java.util.List;
 
 /**
  * Scans directories looking for tests.
+ *
  * @author Karl M. Davis
  * @author Kristian Rosenvold
  */
-public class SurefireDirectoryScanner {
+public class DefaultDirectoryScanner
+    implements DirectoryScanner
+{
 
     private static final String FS = System.getProperty( "file.separator" );
+
     private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
     private static final String JAVA_SOURCE_FILE_EXTENSION = ".java";
+
     private static final String JAVA_CLASS_FILE_EXTENSION = ".class";
 
     private final File basedir;
@@ -44,16 +50,17 @@ public class SurefireDirectoryScanner {
     private final List excludes;
 
 
-    public SurefireDirectoryScanner(File basedir, List includes, List excludes) {
+    public DefaultDirectoryScanner( File basedir, List includes, List excludes )
+    {
         this.basedir = basedir;
         this.includes = includes;
         this.excludes = excludes;
     }
 
-    public Class[] locateTestClasses( ClassLoader classLoader)
+    public Class[] locateTestClasses( ClassLoader classLoader )
         throws TestSetFailedException
     {
-        String[] testClassNames =   collectTests( );
+        String[] testClassNames = collectTests();
         List result = new ArrayList();
 
         for ( int i = 0; i < testClassNames.length; i++ )
@@ -73,14 +80,14 @@ public class SurefireDirectoryScanner {
             if ( !Modifier.isAbstract( testClass.getModifiers() ) )
             {
 
-                result.add( testClass);
+                result.add( testClass );
             }
         }
-        return (Class[]) result.toArray(new Class[result.size()]);
+        return (Class[]) result.toArray( new Class[result.size()] );
     }
 
 
-    String[] collectTests( )
+    String[] collectTests()
     {
         String[] tests = EMPTY_STRING_ARRAY;
         if ( basedir.exists() )
@@ -118,15 +125,14 @@ public class SurefireDirectoryScanner {
 
         for ( int i = 0; i < incs.length; i++ )
         {
-        	String inc = (String) list.get( i );
-        	if ( inc.endsWith( JAVA_SOURCE_FILE_EXTENSION )) {
-        		inc = new StringBuffer( inc.length()
-        		                       - JAVA_SOURCE_FILE_EXTENSION.length()
-        		                       + JAVA_CLASS_FILE_EXTENSION.length() )
-        				.append( inc.substring(0, inc.lastIndexOf( JAVA_SOURCE_FILE_EXTENSION )))
-        				.append( JAVA_CLASS_FILE_EXTENSION )
-        				.toString();
-        	}
+            String inc = (String) list.get( i );
+            if ( inc.endsWith( JAVA_SOURCE_FILE_EXTENSION ) )
+            {
+                inc = new StringBuffer(
+                    inc.length() - JAVA_SOURCE_FILE_EXTENSION.length() + JAVA_CLASS_FILE_EXTENSION.length() ).append(
+                    inc.substring( 0, inc.lastIndexOf( JAVA_SOURCE_FILE_EXTENSION ) ) ).append(
+                    JAVA_CLASS_FILE_EXTENSION ).toString();
+            }
             incs[i] = inc;
 
         }
@@ -134,5 +140,4 @@ public class SurefireDirectoryScanner {
     }
 
 
-
 }

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

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

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java?rev=1035052&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java Sun Nov 14 19:19:01 2010
@@ -0,0 +1,30 @@
+package org.apache.maven.surefire.util;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public interface DirectoryScanner
+{
+    Class[] locateTestClasses( ClassLoader classLoader )
+        throws TestSetFailedException;
+}

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

Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java?rev=1035052&r1=1035051&r2=1035052&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java (original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java Sun Nov 14 19:19:01 2010
@@ -31,16 +31,20 @@ import org.apache.maven.surefire.testset
 /**
  * Test of the directory scanner.
  */
-public class SurefireDirectoryScannerTest extends TestCase {
-    public void testLocateTestClasses() throws IOException, TestSetFailedException {
-        File baseDir = new File(new File(".").getCanonicalPath());
+public class SurefireDirectoryScannerTest
+    extends TestCase
+{
+    public void testLocateTestClasses()
+        throws IOException, TestSetFailedException
+    {
+        File baseDir = new File( new File( "." ).getCanonicalPath() );
         List include = new ArrayList();
-        include.add ("**/*ZT*A.java");
+        include.add( "**/*ZT*A.java" );
         List exclude = new ArrayList();
-        
-        SurefireDirectoryScanner surefireDirectoryScanner = new SurefireDirectoryScanner(baseDir, include, exclude);
+
+        DefaultDirectoryScanner surefireDirectoryScanner = new DefaultDirectoryScanner( baseDir, include, exclude );
         String[] classNames = surefireDirectoryScanner.collectTests();
-        assertNotNull( classNames);
-        assertEquals(4, classNames.length);
-   }
+        assertNotNull( classNames );
+        assertEquals( 4, classNames.length );
+    }
 }

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConfiguration.java?rev=1035052&r1=1035051&r2=1035052&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConfiguration.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConfiguration.java Sun Nov 14 19:19:01 2010
@@ -19,27 +19,16 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
+import org.apache.maven.surefire.suite.SuiteDefinition;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
 import java.util.List;
 import java.util.Properties;
-import java.util.SortedMap;
-import java.util.TreeMap;
 
 /**
  * Represents the surefire configuration that crosses booter forks into other vms and classloaders.
  * <p/>
- * Also knows how to serialize and deserialize itself to disk, though that might some day be externalized.
  *
  * @author Jason van Zyl
  * @author Emmanuel Venisse
@@ -57,27 +46,21 @@ public class BooterConfiguration
 
     public static final int NO_TESTS_EXIT_CODE = 254;
 
-    private static final String TEST_SUITE_PROPERTY_PREFIX = "testSuite.";
-
-    private static final String REPORT_PROPERTY_PREFIX = "report.";
-
-    private static final String PARAMS_SUFIX = ".params";
-
-    private static final String TYPES_SUFIX = ".types";
-
     private final ForkConfiguration forkConfiguration;
 
     private final ClasspathConfiguration classpathConfiguration;
 
     private final List reports = new ArrayList();
 
-    private final List testSuites = new ArrayList();
+    private SuiteDefinition suiteDefinition;
 
     private boolean failIfNoTests = false;
 
     private boolean redirectTestOutputToFile = false;
 
-    private Properties properties;
+    private Properties properties; // todo: Zap out of here !
+
+    Object[] dirScannerParams;
 
     /**
      * This field is set to true if it's running from main. It's used to help decide what classloader to use.
@@ -90,319 +73,32 @@ public class BooterConfiguration
         this.classpathConfiguration = classpathConfiguration;
     }
 
-    /*
-    * Reads the config from the supplied stream. Closes the stream.
-     */
-    BooterConfiguration( InputStream config )
-        throws IOException
+    public BooterConfiguration( ForkConfiguration forkConfiguration, ClasspathConfiguration classpathConfiguration,
+                                SuiteDefinition suiteDefinition, List reports, boolean forked,
+                                Object[] dirScannerParams, boolean failIfNoTests, Properties properties )
     {
-        this.forked = true;
-        properties = loadProperties( config );
-        boolean enableAssertions = false;
-        boolean childDelegation = true;
-
-        SortedMap classPathUrls = new TreeMap();
-
-        SortedMap surefireClassPathUrls = new TreeMap();
-
-        Collection booterClassPathUrl = new ArrayList();
-
-        forkConfiguration = new ForkConfiguration();
-        forkConfiguration.setForkMode( "never" );
-
-        for ( Enumeration e = properties.propertyNames(); e.hasMoreElements(); )
-        {
-            String name = (String) e.nextElement();
-
-            if ( name.startsWith( REPORT_PROPERTY_PREFIX ) && !name.endsWith( PARAMS_SUFIX ) &&
-                !name.endsWith( TYPES_SUFIX ) )
-            {
-                String className = properties.getProperty( name );
-
-                String params = properties.getProperty( name + PARAMS_SUFIX );
-                String types = properties.getProperty( name + TYPES_SUFIX );
-                addReport( className, constructParamObjects( params, types ) );
-            }
-            else if ( name.startsWith( TEST_SUITE_PROPERTY_PREFIX ) && !name.endsWith( PARAMS_SUFIX ) &&
-                !name.endsWith( TYPES_SUFIX ) )
-            {
-                String className = properties.getProperty( name );
-
-                String params = properties.getProperty( name + PARAMS_SUFIX );
-                String types = properties.getProperty( name + TYPES_SUFIX );
-                addTestSuite( className, constructParamObjects( params, types ) );
-            }
-            else if ( name.startsWith( "classPathUrl." ) )
-            {
-                classPathUrls.put( Integer.valueOf( name.substring( name.indexOf( '.' ) + 1 ) ),
-                                   properties.getProperty( name ) );
-            }
-            else if ( name.startsWith( "surefireClassPathUrl." ) )
-            {
-                surefireClassPathUrls.put( Integer.valueOf( name.substring( name.indexOf( '.' ) + 1 ) ),
-                                           properties.getProperty( name ) );
-            }
-            else if ( name.startsWith( "surefireBootClassPathUrl." ) )
-            {
-                booterClassPathUrl.add( properties.getProperty( name ) );
-            }
-            else if ( "childDelegation".equals( name ) )
-            {
-                childDelegation = Boolean.valueOf( properties.getProperty( "childDelegation" ) ).booleanValue();
-            }
-            else if ( "enableAssertions".equals( name ) )
-            {
-                enableAssertions = Boolean.valueOf( properties.getProperty( "enableAssertions" ) ).booleanValue();
-            }
-            else if ( "useSystemClassLoader".equals( name ) )
-            {
-                boolean value = Boolean.valueOf( properties.getProperty( "useSystemClassLoader" ) ).booleanValue();
-                forkConfiguration.setUseSystemClassLoader( value );
-            }
-            else if ( "useManifestOnlyJar".equals( name ) )
-            {
-                boolean value = Boolean.valueOf( properties.getProperty( "useManifestOnlyJar" ) ).booleanValue();
-                forkConfiguration.setUseManifestOnlyJar( value );
-            }
-            else if ( "failIfNoTests".equals( name ) )
-            {
-                boolean value = Boolean.valueOf( properties.getProperty( "failIfNoTests" ) ).booleanValue();
-                setFailIfNoTests( value );
-            }
-        }
-
-        classpathConfiguration =
-            new ClasspathConfiguration( classPathUrls, surefireClassPathUrls, booterClassPathUrl, enableAssertions,
-                                        childDelegation );
+        this.forkConfiguration = forkConfiguration;
+        this.classpathConfiguration = classpathConfiguration;
+        this.suiteDefinition = suiteDefinition;
+        this.reports.addAll( reports );
+        this.forked = forked;
+        this.dirScannerParams = dirScannerParams;
+        this.failIfNoTests = failIfNoTests;
+        this.properties = properties; // Hack hack. This must go
     }
 
+
     ClasspathConfiguration getClasspathConfiguration()
     {
         return classpathConfiguration;
     }
 
-    void setForkProperties( List testSuites, Properties properties )
-    {
-        addPropertiesForTypeHolder( reports, properties, REPORT_PROPERTY_PREFIX );
-        addPropertiesForTypeHolder( testSuites, properties, TEST_SUITE_PROPERTY_PREFIX );
-
-        classpathConfiguration.setForkProperties( properties );
-
-        properties.setProperty( "useSystemClassLoader", String.valueOf( useSystemClassLoader() ) );
-        properties.setProperty( "useManifestOnlyJar",
-                                String.valueOf( forkConfiguration.isManifestOnlyJarRequestedAndUsable() ) );
-        properties.setProperty( "failIfNoTests", String.valueOf( failIfNoTests ) );
-    }
-
-    File writePropertiesFile( String name, Properties properties )
-        throws IOException
-    {
-        File file = File.createTempFile( name, "tmp", forkConfiguration.getTempDirectory() );
-        if ( !forkConfiguration.isDebug() )
-        {
-            file.deleteOnExit();
-        }
-
-        writePropertiesFile( file, name, properties );
-
-        return file;
-    }
-
-    void writePropertiesFile( File file, String name, Properties properties )
-        throws IOException
-    {
-        FileOutputStream out = new FileOutputStream( file );
-
-        try
-        {
-            properties.store( out, name );
-        }
-        finally
-        {
-            IOUtil.close( out );
-        }
-    }
-
-    private void addPropertiesForTypeHolder( List typeHolderList, Properties properties, String propertyPrefix )
-    {
-        for ( int i = 0; i < typeHolderList.size(); i++ )
-        {
-            Object[] report = (Object[]) typeHolderList.get( i );
-
-            String className = (String) report[0];
-            Object[] params = (Object[]) report[1];
-
-            properties.setProperty( propertyPrefix + i, className );
-
-            if ( params != null )
-            {
-                String paramProperty = convert( params[0] );
-                String typeProperty = params[0].getClass().getName();
-                for ( int j = 1; j < params.length; j++ )
-                {
-                    paramProperty += "|";
-                    typeProperty += "|";
-                    if ( params[j] != null )
-                    {
-                        paramProperty += convert( params[j] );
-                        typeProperty += params[j].getClass().getName();
-                    }
-                }
-                properties.setProperty( propertyPrefix + i + PARAMS_SUFIX, paramProperty );
-                properties.setProperty( propertyPrefix + i + TYPES_SUFIX, typeProperty );
-            }
-        }
-    }
-
-    private static String convert( Object param )
-    {
-        if ( param instanceof File[] )
-        {
-            File[] files = (File[]) param;
-            return "[" + StringUtils.join( files, "," ) + "]";
-        }
-        else if ( param instanceof Properties )
-        {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            try
-            {
-                ( (Properties) param ).store( baos, "" );
-                return new String( baos.toByteArray(), "8859_1" );
-            }
-            catch ( Exception e )
-            {
-                throw new RuntimeException( "bug in property conversion", e );
-            }
-        }
-        else
-        {
-            return param.toString();
-        }
-    }
-
     public boolean useSystemClassLoader()
     {
         return forkConfiguration.isUseSystemClassLoader() && ( forked || forkConfiguration.isForking() );
     }
 
 
-    private static List processStringList( String stringList )
-    {
-        String sl = stringList;
-
-        if ( sl.startsWith( "[" ) && sl.endsWith( "]" ) )
-        {
-            sl = sl.substring( 1, sl.length() - 1 );
-        }
-
-        List list = new ArrayList();
-
-        String[] stringArray = StringUtils.split( sl, "," );
-
-        for ( int i = 0; i < stringArray.length; i++ )
-        {
-            list.add( stringArray[i].trim() );
-        }
-        return list;
-    }
-
-    /*
-    Loads the properties, closes the stream
-     */
-
-    private static Properties loadProperties( InputStream inStream )
-        throws IOException
-    {
-        Properties p = new Properties();
-
-        try
-        {
-            p.load( inStream );
-        }
-        finally
-        {
-            IOUtil.close( inStream );
-        }
-
-        return p;
-    }
-
-    private static Object[] constructParamObjects( String paramProperty, String typeProperty )
-    {
-        Object[] paramObjects = null;
-        if ( paramProperty != null )
-        {
-            // bit of a glitch that it need sto be done twice to do an odd number of vertical bars (eg |||, |||||).
-            String[] params = StringUtils.split(
-                StringUtils.replace( StringUtils.replace( paramProperty, "||", "| |" ), "||", "| |" ), "|" );
-            String[] types =
-                StringUtils.split( StringUtils.replace( StringUtils.replace( typeProperty, "||", "| |" ), "||", "| |" ),
-                                   "|" );
-
-            paramObjects = new Object[params.length];
-
-            for ( int i = 0; i < types.length; i++ )
-            {
-                if ( types[i].trim().length() == 0 )
-                {
-                    params[i] = null;
-                }
-                else if ( types[i].equals( String.class.getName() ) )
-                {
-                    paramObjects[i] = params[i];
-                }
-                else if ( types[i].equals( File.class.getName() ) )
-                {
-                    paramObjects[i] = new File( params[i] );
-                }
-                else if ( types[i].equals( File[].class.getName() ) )
-                {
-                    List stringList = processStringList( params[i] );
-                    File[] fileList = new File[stringList.size()];
-                    for ( int j = 0; j < stringList.size(); j++ )
-                    {
-                        fileList[j] = new File( (String) stringList.get( j ) );
-                    }
-                    paramObjects[i] = fileList;
-                }
-                else if ( types[i].equals( ArrayList.class.getName() ) )
-                {
-                    paramObjects[i] = processStringList( params[i] );
-                }
-                else if ( types[i].equals( Boolean.class.getName() ) )
-                {
-                    paramObjects[i] = Boolean.valueOf( params[i] );
-                }
-                else if ( types[i].equals( Integer.class.getName() ) )
-                {
-                    paramObjects[i] = Integer.valueOf( params[i] );
-                }
-                else if ( types[i].equals( Properties.class.getName() ) )
-                {
-                    final Properties result = new Properties();
-                    final String value = params[i];
-                    try
-                    {
-                        ByteArrayInputStream bais = new ByteArrayInputStream( value.getBytes( "8859_1" ) );
-                        result.load( bais );
-                    }
-                    catch ( Exception e )
-                    {
-                        throw new RuntimeException( "bug in property conversion", e );
-                    }
-                    paramObjects[i] = result;
-                }
-                else
-                {
-                    // TODO: could attempt to construct with a String constructor if needed
-                    throw new IllegalArgumentException( "Unknown parameter type: " + types[i] );
-                }
-            }
-        }
-        return paramObjects;
-    }
-
-
     public List getReports()
     {
         return reports;
@@ -420,9 +116,10 @@ public class BooterConfiguration
 
     public List getTestSuites()
     {
-        return testSuites;
+        return suiteDefinition.asBooterFormat();
     }
 
+
     public Boolean isFailIfNoTests()
     {
         return ( failIfNoTests ) ? Boolean.TRUE : Boolean.FALSE;
@@ -438,11 +135,6 @@ public class BooterConfiguration
         reports.add( new Object[]{ report, constructorParams } );
     }
 
-    public void addTestSuite( String suiteClassName, Object[] constructorParams )
-    {
-        testSuites.add( new Object[]{ suiteClassName, constructorParams } );
-    }
-
     /**
      * Setting this to true will cause a failure if there are no tests to run
      *
@@ -468,5 +160,38 @@ public class BooterConfiguration
     {
         return forkConfiguration.isForking();
     }
-}
 
+    public void setDirectoryScannerOptions( File testClassesDirectory, List includes, List excludes )
+    {
+        dirScannerParams = new Object[]{ testClassesDirectory, includes, excludes };
+    }
+
+    public File getBaseDir()
+    {
+        return (File) getDirScannerParams()[0];
+    }
+
+    private Object[] getDirScannerParams()
+    {
+        if ( dirScannerParams == null )
+        {
+            throw new IllegalStateException( "Requesting paramater basedir which has not been set" );
+        }
+        return dirScannerParams;
+    }
+
+    public List getIncludes()
+    {
+        return (List) getDirScannerParams()[1];
+    }
+
+    public List getExcludes()
+    {
+        return (List) getDirScannerParams()[2];
+    }
+
+    public void setSuiteDefinition( SuiteDefinition suiteDefinition )
+    {
+        this.suiteDefinition = suiteDefinition;
+    }
+}

Copied: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterSerializer.java (from r1034027, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConfiguration.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterSerializer.java?p2=maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterSerializer.java&p1=maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConfiguration.java&r1=1034027&r2=1035052&rev=1035052&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConfiguration.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterSerializer.java Sun Nov 14 19:19:01 2010
@@ -1,5 +1,4 @@
 package org.apache.maven.surefire.booter;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,6 +18,7 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
+import org.apache.maven.surefire.suite.SuiteDefinition;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -28,6 +28,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Enumeration;
@@ -37,69 +38,43 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 
 /**
- * Represents the surefire configuration that crosses booter forks into other vms and classloaders.
+ * Knows how to serialize and deserialize the booter configuration.
+ * <p/>
+ * The internal serialization format is through a properties file. The long-term goal of this
+ * class is not to expose this implementation information to its clients. This still leaks somewhat,
+ * and there are some cases where properties are being accessed as "Properties" instead of
+ * more representative domain objects.
  * <p/>
- * Also knows how to serialize and deserialize itself to disk, though that might some day be externalized.
  *
  * @author Jason van Zyl
  * @author Emmanuel Venisse
  * @author Kristian Rosenvold
  * @version $Id$
  */
-public class BooterConfiguration
+public class BooterSerializer
 {
-    /**
-     * @noinspection UnusedDeclaration
-     */
-    public static final int TESTS_SUCCEEDED_EXIT_CODE = 0;
-
-    public static final int TESTS_FAILED_EXIT_CODE = 255;
-
-    public static final int NO_TESTS_EXIT_CODE = 254;
-
     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";
 
-    private final ForkConfiguration forkConfiguration;
-
-    private final ClasspathConfiguration classpathConfiguration;
-
-    private final List reports = new ArrayList();
-
-    private final List testSuites = new ArrayList();
-
-    private boolean failIfNoTests = false;
 
-    private boolean redirectTestOutputToFile = false;
-
-    private Properties properties;
-
-    /**
-     * This field is set to true if it's running from main. It's used to help decide what classloader to use.
-     */
-    private boolean forked;
-
-    public BooterConfiguration( ForkConfiguration forkConfiguration, ClasspathConfiguration classpathConfiguration )
-    {
-        this.forkConfiguration = forkConfiguration;
-        this.classpathConfiguration = classpathConfiguration;
-    }
-
-    /*
-    * Reads the config from the supplied stream. Closes the stream.
-     */
-    BooterConfiguration( InputStream config )
+    public BooterConfiguration deserialize( InputStream inputStream )
         throws IOException
     {
-        this.forked = true;
-        properties = loadProperties( config );
+        boolean forked = true;
+        Properties properties = loadProperties( inputStream );
+        final List reports = new ArrayList();
+        Object[] dirScannerParams = null;
         boolean enableAssertions = false;
         boolean childDelegation = true;
+        SuiteDefinition suiteDefinition = null;
+        boolean failIfNotests = false;  // todo; check this out.
 
         SortedMap classPathUrls = new TreeMap();
 
@@ -107,7 +82,7 @@ public class BooterConfiguration
 
         Collection booterClassPathUrl = new ArrayList();
 
-        forkConfiguration = new ForkConfiguration();
+        ForkConfiguration forkConfiguration = new ForkConfiguration();
         forkConfiguration.setForkMode( "never" );
 
         for ( Enumeration e = properties.propertyNames(); e.hasMoreElements(); )
@@ -121,7 +96,7 @@ public class BooterConfiguration
 
                 String params = properties.getProperty( name + PARAMS_SUFIX );
                 String types = properties.getProperty( name + TYPES_SUFIX );
-                addReport( className, constructParamObjects( params, types ) );
+                reports.add( new Object[]{ className, constructParamObjects( params, types ) } );
             }
             else if ( name.startsWith( TEST_SUITE_PROPERTY_PREFIX ) && !name.endsWith( PARAMS_SUFIX ) &&
                 !name.endsWith( TYPES_SUFIX ) )
@@ -130,7 +105,14 @@ public class BooterConfiguration
 
                 String params = properties.getProperty( name + PARAMS_SUFIX );
                 String types = properties.getProperty( name + TYPES_SUFIX );
-                addTestSuite( className, constructParamObjects( params, types ) );
+                suiteDefinition = new SuiteDefinition( className, constructParamObjects( params, types ) );
+            }
+            else if ( name.startsWith( DIRSCANNER_PROPERTY_PREFIX ) && !name.endsWith( PARAMS_SUFIX ) &&
+                !name.endsWith( TYPES_SUFIX ) )
+            {
+                String params = properties.getProperty( name + PARAMS_SUFIX );
+                String types = properties.getProperty( name + TYPES_SUFIX );
+                dirScannerParams = constructParamObjects( params, types );
             }
             else if ( name.startsWith( "classPathUrl." ) )
             {
@@ -166,35 +148,64 @@ public class BooterConfiguration
             }
             else if ( "failIfNoTests".equals( name ) )
             {
-                boolean value = Boolean.valueOf( properties.getProperty( "failIfNoTests" ) ).booleanValue();
-                setFailIfNoTests( value );
+                failIfNotests = Boolean.valueOf( properties.getProperty( "failIfNoTests" ) ).booleanValue();
             }
         }
 
-        classpathConfiguration =
+        ClasspathConfiguration classpathConfiguration =
             new ClasspathConfiguration( classPathUrls, surefireClassPathUrls, booterClassPathUrl, enableAssertions,
                                         childDelegation );
+
+        return new BooterConfiguration( forkConfiguration, classpathConfiguration, suiteDefinition, reports, forked,
+                                        dirScannerParams, failIfNotests, properties );
     }
 
-    ClasspathConfiguration getClasspathConfiguration()
+    public void serialize( BooterConfiguration booterConfiguration, List testSuites, String name )
+        throws IOException
     {
-        return classpathConfiguration;
+        final ForkConfiguration forkConfiguration = booterConfiguration.getForkConfiguration();
+        File file = File.createTempFile( name, "tmp", forkConfiguration.getTempDirectory() );
+        if ( !forkConfiguration.isDebug() )
+        {
+            file.deleteOnExit();
+        }
+    }
+
+    public void serialize( BooterConfiguration booterConfiguration, List testSuites, OutputStream outputStream )
+        throws IOException
+    {
+        Properties properties = new Properties();
+
+        BooterSerializer booterSerializer = new BooterSerializer();
+        booterSerializer.setForkProperties( properties, testSuites, booterConfiguration );
+        try
+        {
+            properties.store( outputStream, "surefire" );
+        }
+        finally
+        {
+            outputStream.close();
+        }
     }
 
-    void setForkProperties( List testSuites, Properties properties )
+    public void setForkProperties( Properties properties, List testSuites, BooterConfiguration booterConfiguration )
     {
-        addPropertiesForTypeHolder( reports, properties, REPORT_PROPERTY_PREFIX );
+        addPropertiesForTypeHolder( booterConfiguration.getReports(), properties, REPORT_PROPERTY_PREFIX );
         addPropertiesForTypeHolder( testSuites, properties, TEST_SUITE_PROPERTY_PREFIX );
+        List params = new ArrayList();
+        params.add( new Object[]{ "directoryScannerOptions", booterConfiguration.dirScannerParams } ); // todo
+        addPropertiesForTypeHolder( params, properties, DIRSCANNER_PROPERTY_PREFIX );
 
-        classpathConfiguration.setForkProperties( properties );
+        booterConfiguration.getClasspathConfiguration().setForkProperties( properties );
 
-        properties.setProperty( "useSystemClassLoader", String.valueOf( useSystemClassLoader() ) );
+        ForkConfiguration forkConfiguration = booterConfiguration.getForkConfiguration();
+        properties.setProperty( "useSystemClassLoader", String.valueOf( forkConfiguration.isUseSystemClassLoader() ) );
         properties.setProperty( "useManifestOnlyJar",
                                 String.valueOf( forkConfiguration.isManifestOnlyJarRequestedAndUsable() ) );
-        properties.setProperty( "failIfNoTests", String.valueOf( failIfNoTests ) );
+        properties.setProperty( "failIfNoTests", String.valueOf( booterConfiguration.isFailIfNoTests() ) );
     }
 
-    File writePropertiesFile( String name, Properties properties )
+    File writePropertiesFile( String name, Properties properties, ForkConfiguration forkConfiguration )
         throws IOException
     {
         File file = File.createTempFile( name, "tmp", forkConfiguration.getTempDirectory() );
@@ -280,12 +291,6 @@ public class BooterConfiguration
         }
     }
 
-    public boolean useSystemClassLoader()
-    {
-        return forkConfiguration.isUseSystemClassLoader() && ( forked || forkConfiguration.isForking() );
-    }
-
-
     private static List processStringList( String stringList )
     {
         String sl = stringList;
@@ -401,72 +406,4 @@ public class BooterConfiguration
         }
         return paramObjects;
     }
-
-
-    public List getReports()
-    {
-        return reports;
-    }
-
-    public Properties getProperties()
-    {
-        return properties;
-    }
-
-    public boolean isRedirectTestOutputToFile()
-    {
-        return redirectTestOutputToFile;
-    }
-
-    public List getTestSuites()
-    {
-        return testSuites;
-    }
-
-    public Boolean isFailIfNoTests()
-    {
-        return ( failIfNoTests ) ? Boolean.TRUE : Boolean.FALSE;
-    }
-
-    public ForkConfiguration getForkConfiguration()
-    {
-        return forkConfiguration;
-    }
-
-    public void addReport( String report, Object[] constructorParams )
-    {
-        reports.add( new Object[]{ report, constructorParams } );
-    }
-
-    public void addTestSuite( String suiteClassName, Object[] constructorParams )
-    {
-        testSuites.add( new Object[]{ suiteClassName, constructorParams } );
-    }
-
-    /**
-     * Setting this to true will cause a failure if there are no tests to run
-     *
-     * @param failIfNoTests true if we should fail with no tests
-     */
-    public void setFailIfNoTests( boolean failIfNoTests )
-    {
-        this.failIfNoTests = failIfNoTests;
-    }
-
-    /**
-     * When forking, setting this to true will make the test output to be saved in a file instead of showing it on the
-     * standard output
-     *
-     * @param redirectTestOutputToFile to redirect test output to file
-     */
-    public void setRedirectTestOutputToFile( boolean redirectTestOutputToFile )
-    {
-        this.redirectTestOutputToFile = redirectTestOutputToFile;
-    }
-
-    public boolean isForking()
-    {
-        return forkConfiguration.isForking();
-    }
 }
-

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java?rev=1035052&r1=1035051&r2=1035052&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java Sun Nov 14 19:19:01 2010
@@ -153,7 +153,7 @@ public class SurefireBooter
             }
             else
             {
-                testsClassLoader = getClasspathConfiguration().createTestClassLoader(  );
+                testsClassLoader = getClasspathConfiguration().createTestClassLoader();
             }
 
             ClassLoader surefireClassLoader = getClasspathConfiguration().createSurefireClassLoader( testsClassLoader );
@@ -236,7 +236,7 @@ public class SurefireBooter
         Object suite;
         try
         {
-            suite = Surefire.instantiateObject( className, params, surefireClassLoader );
+            suite = SurefireReflector.instantiateObject( className, params, surefireClassLoader );
         }
         catch ( TestSetFailedException e )
         {
@@ -279,7 +279,8 @@ public class SurefireBooter
     {
         Properties properties = new Properties();
 
-        booterConfiguration.setForkProperties( testSuites, properties );
+        BooterSerializer booterSerializer = new BooterSerializer();
+        booterSerializer.setForkProperties( properties, testSuites, booterConfiguration );
 
         return fork( properties, showHeading, showFooter );
     }
@@ -288,7 +289,8 @@ public class SurefireBooter
                            Properties properties )
         throws SurefireBooterForkException
     {
-        booterConfiguration.setForkProperties( Collections.singletonList( testSuite ), properties );
+        BooterSerializer booterSerializer = new BooterSerializer();
+        booterSerializer.setForkProperties( properties, Collections.singletonList( testSuite ), booterConfiguration );
 
         if ( testSet instanceof String )
         {
@@ -303,13 +305,16 @@ public class SurefireBooter
     {
         File surefireProperties;
         File systemProperties = null;
+        final ForkConfiguration forkConfiguration = booterConfiguration.getForkConfiguration();
         try
         {
-            surefireProperties = booterConfiguration.writePropertiesFile( "surefire", properties );
-            if ( booterConfiguration.getForkConfiguration().getSystemProperties() != null )
-            {
-                systemProperties = booterConfiguration.writePropertiesFile( "surefire",
-                                                                            booterConfiguration.getForkConfiguration().getSystemProperties() );
+            BooterSerializer booterSerializer = new BooterSerializer();
+            surefireProperties = booterSerializer.writePropertiesFile( "surefire", properties, forkConfiguration );
+            if ( forkConfiguration.getSystemProperties() != null )
+            {
+                systemProperties =
+                    booterSerializer.writePropertiesFile( "surefire", forkConfiguration.getSystemProperties(),
+                                                          forkConfiguration );
             }
         }
         catch ( IOException e )
@@ -319,7 +324,7 @@ public class SurefireBooter
 
         List bootClasspath = getClasspathConfiguration().getBootClasspath( booterConfiguration.useSystemClassLoader() );
 
-        Commandline cli = booterConfiguration.getForkConfiguration().createCommandLine( bootClasspath );
+        Commandline cli = forkConfiguration.createCommandLine( bootClasspath );
 
         cli.createArg().setFile( surefireProperties );
 
@@ -342,7 +347,7 @@ public class SurefireBooter
             err = getForkingStreamConsumer( showHeading, showFooter, booterConfiguration.isRedirectTestOutputToFile() );
         }
 
-        if ( booterConfiguration.getForkConfiguration().isDebug() )
+        if ( forkConfiguration.isDebug() )
         {
             System.out.println( "Forking command line: " + cli );
         }
@@ -450,7 +455,8 @@ public class SurefireBooter
 
             File surefirePropertiesFile = new File( args[0] );
             InputStream stream = surefirePropertiesFile.exists() ? new FileInputStream( surefirePropertiesFile ) : null;
-            BooterConfiguration booterConfiguration = new BooterConfiguration( stream );
+            BooterSerializer booterSerializer = new BooterSerializer();
+            BooterConfiguration booterConfiguration = booterSerializer.deserialize( stream );
             Properties p = booterConfiguration.getProperties();
 
             SurefireBooter booter = new SurefireBooter( booterConfiguration );
@@ -466,7 +472,7 @@ public class SurefireBooter
                 result = booter.runSuitesInProcess();
             }
 
-            booterConfiguration.writePropertiesFile( surefirePropertiesFile, "surefire", p );
+            booterSerializer.writePropertiesFile( surefirePropertiesFile, "surefire", p );
 
             // noinspection CallToSystemExit
             System.exit( result );

Modified: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterConversionTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterConversionTest.java?rev=1035052&r1=1035051&r2=1035052&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterConversionTest.java (original)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterConversionTest.java Sun Nov 14 19:19:01 2010
@@ -32,82 +32,114 @@ public class BooterConversionTest
     extends TestCase
 {
     Method convert, constructParamObjects;
-    public void setUp() throws Exception {
-        convert = BooterConfiguration.class.getDeclaredMethod( "convert", new Class[] { Object.class } );
+
+    public void setUp()
+        throws Exception
+    {
+        convert = BooterSerializer.class.getDeclaredMethod( "convert", new Class[]{ Object.class } );
         convert.setAccessible( true );
-        constructParamObjects = BooterConfiguration.class.getDeclaredMethod( "constructParamObjects", new Class[] { String.class, String.class } );
+        constructParamObjects = BooterSerializer.class.getDeclaredMethod( "constructParamObjects",
+                                                                          new Class[]{ String.class, String.class } );
         constructParamObjects.setAccessible( true );
     }
-    
-    public void testString() throws Exception {
+
+    public void testString()
+        throws Exception
+    {
         doTest( "Hello world!" );
     }
-    
-    public void testFile() throws Exception {
-        doTest( new File( "."));
-    }
-    
-    public void testFileArray() throws Exception {
-        doTestArray( new File[] {new File( ".")});
-    }
-    
-    public void testArrayList() throws Exception {
-        doTest(new ArrayList());
-    }
-    
-    public void testBoolean() throws Exception {
-        doTest(Boolean.TRUE);
-        doTest(Boolean.FALSE);
-    }
-    
-    public void testInteger() throws Exception {
-        doTest(new Integer(0));
+
+    public void testFile()
+        throws Exception
+    {
+        doTest( new File( "." ) );
+    }
+
+    public void testFileArray()
+        throws Exception
+    {
+        doTestArray( new File[]{ new File( "." ) } );
+    }
+
+    public void testArrayList()
+        throws Exception
+    {
+        doTest( new ArrayList() );
     }
-    
-    public void testProperties() throws Exception {
+
+    public void testBoolean()
+        throws Exception
+    {
+        doTest( Boolean.TRUE );
+        doTest( Boolean.FALSE );
+    }
+
+    public void testInteger()
+        throws Exception
+    {
+        doTest( new Integer( 0 ) );
+    }
+
+    public void testProperties()
+        throws Exception
+    {
         Properties p = new Properties();
         p.setProperty( "foo", "bar" );
-        doTest(p);
+        doTest( p );
     }
-    
-    public void testPropertiesEmpty() throws Exception {
+
+    public void testPropertiesEmpty()
+        throws Exception
+    {
         Properties p = new Properties();
-        doTest(p);
+        doTest( p );
     }
-    
-    public void testPropertiesWithComma() throws Exception {
+
+    public void testPropertiesWithComma()
+        throws Exception
+    {
         Properties p = new Properties();
         p.setProperty( "foo, comma", "bar" );
-        
-        doTest(p);
+
+        doTest( p );
     }
-    
-    public void doTest(Object o) throws Exception {
+
+    public void doTest( Object o )
+        throws Exception
+    {
         String serialized = serialize( o );
         Object[] output = deserialize( serialized, o.getClass().getName() );
-        assertEquals ( "Wrong number of output elements: " + Arrays.asList( output ), 1, output.length);
-        assertEquals ( o, output[0] );
+        assertEquals( "Wrong number of output elements: " + Arrays.asList( output ), 1, output.length );
+        assertEquals( o, output[0] );
     }
-    
-    public void doTestArray(Object[] o) throws Exception {
+
+    public void doTestArray( Object[] o )
+        throws Exception
+    {
         String serialized = serialize( o );
         Object[] output = deserialize( serialized, o.getClass().getName() );
-        assertEquals ( "Wrong number of output elements: " + Arrays.asList( output ), 1, output.length);
-        assertArrayEquals ( "Deserialized array didn't match", o, (Object[])output[0] );
+        assertEquals( "Wrong number of output elements: " + Arrays.asList( output ), 1, output.length );
+        assertArrayEquals( "Deserialized array didn't match", o, (Object[]) output[0] );
     }
-    
-    private void assertArrayEquals(String message, Object[] expected, Object[] actual) {
-        assertEquals( message + "; wrong number of elements", expected.length, actual.length);
-        for (int i = 0; i < expected.length; i++) {
-            assertEquals( message + "; element " + i + " differs", expected[i], actual[i]);
+
+    private void assertArrayEquals( String message, Object[] expected, Object[] actual )
+    {
+        assertEquals( message + "; wrong number of elements", expected.length, actual.length );
+        for ( int i = 0; i < expected.length; i++ )
+        {
+            assertEquals( message + "; element " + i + " differs", expected[i], actual[i] );
         }
     }
 
-    private Object[] deserialize (String paramProperty, String typeProperty) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
-        return (Object[]) constructParamObjects.invoke( null, new Object[] {paramProperty, typeProperty} );
+    private Object[] deserialize( String paramProperty, String typeProperty )
+        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
+    {
+        return (Object[]) constructParamObjects.invoke( null, new Object[]{ paramProperty, typeProperty } );
     }
-    
-    private String serialize(Object o) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
-        return (String) convert.invoke( null, new Object[] { o } );
+
+    private String serialize( Object o )
+        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
+    {
+        return (String) convert.invoke( null, new Object[]{ o } );
     }
 }

Added: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterSerializerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterSerializerTest.java?rev=1035052&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterSerializerTest.java (added)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterSerializerTest.java Sun Nov 14 19:19:01 2010
@@ -0,0 +1,75 @@
+package org.apache.maven.surefire.booter;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class BooterSerializerTest
+    extends TestCase
+{
+
+    public void testDirectoryScannerParams()
+        throws IOException
+    {
+        BooterConfiguration booterConfiguration = getTestBooterConfiguration();
+
+        File aDir = new File( "." );
+        List includes = 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 );
+        final File propsTest =
+            booterSerializer.writePropertiesFile( "propsTest", props, booterConfiguration.getForkConfiguration() );
+
+        BooterConfiguration read = booterSerializer.deserialize( new FileInputStream( propsTest ) );
+
+        assertEquals( aDir, read.getBaseDir() );
+        assertEquals( includes.get( 0 ), read.getIncludes().get( 0 ) );
+        assertEquals( includes.get( 1 ), read.getIncludes().get( 1 ) );
+        assertEquals( excludes.get( 0 ), read.getExcludes().get( 0 ) );
+        assertEquals( excludes.get( 1 ), read.getExcludes().get( 1 ) );
+
+    }
+
+    private BooterConfiguration getTestBooterConfiguration()
+        throws IOException
+    {
+        ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration();
+        ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( true, true );
+
+        return new BooterConfiguration( forkConfiguration, classpathConfiguration );
+    }
+}

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

Modified: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkConfigurationTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkConfigurationTest.java?rev=1035052&r1=1035051&r2=1035052&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkConfigurationTest.java (original)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkConfigurationTest.java Sun Nov 14 19:19:01 2010
@@ -41,7 +41,6 @@ public class ForkConfigurationTest
         config.setUseSystemClassLoader( true );
         config.setJvmExecutable( "java" );
 
-
         Commandline cli = config.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ),
                                                     config.isUseSystemClassLoader() );
 
@@ -58,7 +57,6 @@ public class ForkConfigurationTest
 
         forkConfiguration.setArgLine( "abc\ndef" );
 
-
         final Commandline commandLine =
             forkConfiguration.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), false );
         assertTrue( commandLine.toString().contains( "abc def" ) );
@@ -72,7 +70,7 @@ public class ForkConfigurationTest
         return cpElement;
     }
 
-    private ForkConfiguration getForkConfiguration()
+    public static ForkConfiguration getForkConfiguration()
         throws IOException
     {
         ForkConfiguration forkConfiguration = new ForkConfiguration();



Mime
View raw message