maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1044121 - 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/apache/mav...
Date Thu, 09 Dec 2010 20:35:10 GMT
Author: krosenvold
Date: Thu Dec  9 20:35:09 2010
New Revision: 1044121

URL: http://svn.apache.org/viewvc?rev=1044121&view=rev
Log:
o Simplified booter serialization/deserialization significantly further

Test coverage improved too.

Added:
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java   (contents, props changed)
      - copied, changed from r1043721, maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerTest.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java   (with props)
Removed:
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerTest.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/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestRequest.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/ClassLoaderConfiguration.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.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=1044121&r1=1044120&r2=1044121&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 Thu Dec  9 20:35:09 2010
@@ -268,7 +268,8 @@ public abstract class AbstractSurefireMo
         final boolean isTestNg = testNgArtifact != null;
         TestArtifactInfo testNg =
             isTestNg ? new TestArtifactInfo( testNgArtifact.getVersion(), testNgArtifact.getClassifier() ) : null;
-        TestRequest testSuiteDefinition = new TestRequest( getSuiteXmlFiles(), getTestSourceDirectory(), getTest() );
+        List testXml = getSuiteXmlFiles() != null ? Arrays.asList( getSuiteXmlFiles() ) : null;
+        TestRequest testSuiteDefinition = new TestRequest( testXml, getTestSourceDirectory(), getTest() );
         final boolean failIfNoTests;
 
         if ( isValidSuiteXmlFileConfig() && getTest() == null )

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=1044121&r1=1044120&r2=1044121&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 Thu Dec  9 20:35:09 2010
@@ -20,6 +20,7 @@ package org.apache.maven.plugin.surefire
 
 import org.apache.maven.surefire.booter.BooterConstants;
 import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
+import org.apache.maven.surefire.booter.PropertiesWrapper;
 import org.apache.maven.surefire.booter.ProviderConfiguration;
 import org.apache.maven.surefire.booter.StartupConfiguration;
 import org.apache.maven.surefire.booter.SystemPropertyManager;
@@ -54,71 +55,40 @@ public class BooterSerializer
 {
     private final ForkConfiguration forkConfiguration;
 
-    public BooterSerializer( ForkConfiguration forkConfiguration )
+    private final PropertiesWrapper properties;
+
+    public BooterSerializer( ForkConfiguration forkConfiguration, Properties properties )
     {
         this.forkConfiguration = forkConfiguration;
+        this.properties = new PropertiesWrapper( properties );
     }
 
 
-    public File serialize( Properties properties, ProviderConfiguration booterConfiguration,
-                           StartupConfiguration providerConfiguration, Object testSet )
+    public File serialize( ProviderConfiguration booterConfiguration, StartupConfiguration providerConfiguration,
+                           Object testSet )
         throws IOException
     {
-        setForkProperties( properties, booterConfiguration, providerConfiguration, testSet );
-
-        return SystemPropertyManager.writePropertiesFile( properties, forkConfiguration.getTempDirectory(), "surefire",
-                                                          forkConfiguration.isDebug() );
-    }
-
-    private void setForkProperties( Properties properties, ProviderConfiguration booterConfiguration,
-                                    StartupConfiguration providerConfiguration, Object testSet )
-    {
-        if ( properties == null )
-        {
-            throw new IllegalStateException( "Properties cannot be null" );
-        }
         List params = new ArrayList();
         params.add(
             new Object[]{ BooterConstants.DIRSCANNER_OPTIONS, booterConfiguration.getDirScannerParamsArray() } );
-        addPropertiesForTypeHolder( params, properties, BooterConstants.DIRSCANNER_PROPERTY_PREFIX );
+        addPropertiesForTypeHolder( params, properties.getProperties(), BooterConstants.DIRSCANNER_PROPERTY_PREFIX );
 
-        providerConfiguration.getClasspathConfiguration().setForkProperties( properties );
+        providerConfiguration.getClasspathConfiguration().setForkProperties( properties.getProperties() );
 
         TestArtifactInfo testNg = booterConfiguration.getTestArtifact();
         if ( testNg != null )
         {
-            if ( testNg.getVersion() != null )
-            {
-                properties.setProperty( BooterConstants.TESTARTIFACT_VERSION, testNg.getVersion() );
-            }
-            if ( testNg.getClassifier() != null )
-            {
-                properties.setProperty( BooterConstants.TESTARTIFACT_CLASSIFIER, testNg.getClassifier() );
-            }
-        }
-
-        if ( testSet != null )
-        {
-            properties.setProperty( BooterConstants.FORKTESTSET, getTypeEncoded( testSet ) );
+            properties.setProperty( BooterConstants.TESTARTIFACT_VERSION, testNg.getVersion() );
+            properties.setProperty( BooterConstants.TESTARTIFACT_CLASSIFIER, testNg.getClassifier() );
         }
 
+        properties.setProperty( BooterConstants.FORKTESTSET, getTypeEncoded( testSet ) );
         TestRequest testSuiteDefinition = booterConfiguration.getTestSuiteDefinition();
         if ( testSuiteDefinition != null )
         {
-            if ( testSuiteDefinition.getTestSourceDirectory() != null )
-            {
-                properties.setProperty( BooterConstants.SOURCE_DIRECTORY,
-                                        testSuiteDefinition.getTestSourceDirectory().toString() );
-            }
-            if ( testSuiteDefinition.getSuiteXmlFiles() != null )
-            {
-                properties.setProperty( BooterConstants.TEST_SUITE_XML_FILES,
-                                        getValues( testSuiteDefinition.getSuiteXmlFiles() ) );
-            }
-            if ( testSuiteDefinition.getRequestedTest() != null )
-            {
-                properties.setProperty( BooterConstants.REQUESTEDTEST, testSuiteDefinition.getRequestedTest() );
-            }
+            properties.setProperty( BooterConstants.SOURCE_DIRECTORY, testSuiteDefinition.getTestSourceDirectory() );
+            properties.addList( testSuiteDefinition.getSuiteXmlFiles(), BooterConstants.TEST_SUITE_XML_FILES );
+            properties.setProperty( BooterConstants.REQUESTEDTEST, testSuiteDefinition.getRequestedTest() );
         }
 
         DirectoryScannerParameters directoryScannerParameters = booterConfiguration.getDirScannerParams();
@@ -126,35 +96,41 @@ public class BooterSerializer
         {
             properties.setProperty( BooterConstants.FAILIFNOTESTS,
                                     String.valueOf( directoryScannerParameters.isFailIfNoTests() ) );
-            addList( directoryScannerParameters.getIncludes(), properties, BooterConstants.INCLUDES_PROPERTY_PREFIX );
-            addList( directoryScannerParameters.getExcludes(), properties, BooterConstants.EXCLUDES_PROPERTY_PREFIX );
+            properties.addList( directoryScannerParameters.getIncludes(), BooterConstants.INCLUDES_PROPERTY_PREFIX );
+            properties.addList( directoryScannerParameters.getExcludes(), BooterConstants.EXCLUDES_PROPERTY_PREFIX );
             properties.setProperty( BooterConstants.TEST_CLASSES_DIRECTORY,
-                                    directoryScannerParameters.getTestClassesDirectory().toString() );
+                                    directoryScannerParameters.getTestClassesDirectory() );
         }
 
         ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration();
-        addList( reporterConfiguration.getReports(), properties, BooterConstants.REPORT_PROPERTY_PREFIX );
+        addList( reporterConfiguration.getReports(), properties.getProperties(),
+                 BooterConstants.REPORT_PROPERTY_PREFIX );
 
         Boolean rep = reporterConfiguration.isTrimStackTrace();
-        properties.setProperty( BooterConstants.ISTRIMSTACKTRACE, rep.toString() );
+        properties.setProperty( BooterConstants.ISTRIMSTACKTRACE, rep );
         properties.setProperty( BooterConstants.REPORTSDIRECTORY,
-                                reporterConfiguration.getReportsDirectory().toString() );
+                                reporterConfiguration.getReportsDirectory());
         ClassLoaderConfiguration classLoaderConfiguration = providerConfiguration.getClassLoaderConfiguration();
         properties.setProperty( BooterConstants.USESYSTEMCLASSLOADER,
                                 String.valueOf( classLoaderConfiguration.isUseSystemClassLoader() ) );
-        // Note that using isManifestOnlyJarRequestedAndUsable has a really nasty code smell to it.
-        // Should probably be using the staright "isManifestOnlyJar" attribute.
-        // But this actually still does the correct thing as is.
         properties.setProperty( BooterConstants.USEMANIFESTONLYJAR,
-                                String.valueOf( classLoaderConfiguration.isManifestOnlyJarRequestedAndUsable() ) );
+                                String.valueOf( classLoaderConfiguration.isUseManifestOnlyJar() ) );
         properties.setProperty( BooterConstants.FAILIFNOTESTS,
                                 String.valueOf( booterConfiguration.isFailIfNoTests() ) );
         properties.setProperty( BooterConstants.PROVIDER_CONFIGURATION, providerConfiguration.getProviderClassName() );
+
+        return SystemPropertyManager.writePropertiesFile( properties.getProperties(),
+                                                          forkConfiguration.getTempDirectory(), "surefire",
+                                                          forkConfiguration.isDebug() );
     }
 
 
     private String getTypeEncoded( Object value )
     {
+        if ( value == null )
+        {
+            return null;
+        }
         return value.getClass().getName() + "|" + value.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=1044121&r1=1044120&r2=1044121&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 Thu Dec  9 20:35:09 2010
@@ -165,10 +165,10 @@ public class ForkStarter
         File systemProperties = null;
         try
         {
-            BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration );
+            BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, properties );
 
             surefireProperties =
-                booterSerializer.serialize( properties, providerConfiguration, startupConfiguration, testSet );
+                booterSerializer.serialize( providerConfiguration, startupConfiguration, testSet );
 
             if ( forkConfiguration.getSystemProperties() != null )
             {

Copied: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java (from r1043721, 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/BooterDeserializerProviderConfigurationTest.java?p2=maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java&p1=maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerTest.java&r1=1043721&r2=1044121&rev=1044121&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/BooterDeserializerProviderConfigurationTest.java Thu Dec  9 20:35:09 2010
@@ -36,15 +36,16 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
 
 /**
- * Performs roundtrip testing of serialization/deserialization
+ * Performs roundtrip testing of serialization/deserialization of the ProviderConfiguration
  *
  * @author Kristian Rosenvold
  */
-public class BooterDeserializerTest
+public class BooterDeserializerProviderConfigurationTest
     extends TestCase
 {
 
@@ -58,6 +59,7 @@ public class BooterDeserializerTest
         return new ClassLoaderConfiguration( true, false );
     }
 
+    // ProviderConfiguration methods
     public void testDirectoryScannerParams()
         throws IOException
     {
@@ -70,13 +72,10 @@ public class BooterDeserializerTest
         excludes.add( "xx1" );
         excludes.add( "xx2" );
 
-        DirectoryScannerParameters directoryScannerParameters =
-            new DirectoryScannerParameters( aDir, includes, excludes, Boolean.TRUE );
         ClassLoaderConfiguration forkConfiguration = getForkConfiguration();
-        final StartupConfiguration testProviderConfiguration = getTestProviderConfiguration( forkConfiguration );
-        ProviderConfiguration booterConfiguration =
-            getTestBooterConfiguration( forkConfiguration, directoryScannerParameters, new ArrayList() );
-        ProviderConfiguration read = saveAndReload( booterConfiguration, testProviderConfiguration );
+        final StartupConfiguration testStartupConfiguration = getTestStartupConfiguration( forkConfiguration );
+        ProviderConfiguration providerConfiguration = getReloadedProviderConfiguration(new ArrayList(  ) );
+        ProviderConfiguration read = saveAndReload( providerConfiguration, testStartupConfiguration );
 
         Assert.assertEquals( aDir, read.getBaseDir() );
         Assert.assertEquals( includes.get( 0 ), read.getIncludes().get( 0 ) );
@@ -86,7 +85,7 @@ public class BooterDeserializerTest
 
     }
 
-    public void testReports()
+    public void testReporterConfiguration()
         throws IOException
     {
         DirectoryScannerParameters directoryScannerParameters = getDirectoryScannerParameters();
@@ -99,16 +98,15 @@ public class BooterDeserializerTest
         reports.add( second );
         reports.add( third );
 
-        ProviderConfiguration booterConfiguration =
-            getTestBooterConfiguration( forkConfiguration, directoryScannerParameters, reports );
+        ProviderConfiguration providerConfiguration = getTestProviderConfiguration( directoryScannerParameters, reports );
 
-        final ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration();
+        final ReporterConfiguration reporterConfiguration = providerConfiguration.getReporterConfiguration();
         reporterConfiguration.getReports().add( first );
         reporterConfiguration.getReports().add( second );
         reporterConfiguration.getReports().add( third );
 
-        final StartupConfiguration testProviderConfiguration = getTestProviderConfiguration( forkConfiguration );
-        ProviderConfiguration reloaded = saveAndReload( booterConfiguration, testProviderConfiguration );
+        final StartupConfiguration testProviderConfiguration = getTestStartupConfiguration( forkConfiguration );
+        ProviderConfiguration reloaded = saveAndReload( providerConfiguration, testProviderConfiguration );
 
         Assert.assertEquals( first, reloaded.getReporterConfiguration().getReports().get( 0 ) );
         Assert.assertEquals( second, reloaded.getReporterConfiguration().getReports().get( 1 ) );
@@ -118,62 +116,52 @@ public class BooterDeserializerTest
     public void testTestArtifact()
         throws IOException
     {
-        ProviderConfiguration reloaded = getReloadedProviderConfiguration();
+        ProviderConfiguration reloaded = getReloadedProviderConfiguration( new ArrayList() );
 
         Assert.assertEquals( "5.0", reloaded.getTestArtifact().getVersion() );
         Assert.assertEquals( "ABC", reloaded.getTestArtifact().getClassifier() );
     }
 
-    public void testTestSuiteDefinition()
+    public void testTestRequest()
         throws IOException
     {
-        ProviderConfiguration reloaded = getReloadedProviderConfiguration();
+        ProviderConfiguration reloaded = getReloadedProviderConfiguration(new ArrayList(  ) );
 
         TestRequest testSuiteDefinition = reloaded.getTestSuiteDefinition();
-        File[] suiteXmlFiles = testSuiteDefinition.getSuiteXmlFiles();
+        List suiteXmlFiles = testSuiteDefinition.getSuiteXmlFiles();
         File[] expected = getSuiteXmlFiles();
-        Assert.assertEquals( expected[0], suiteXmlFiles[0] );
-        Assert.assertEquals( expected[1], suiteXmlFiles[1] );
-        Assert.assertEquals( aTest, reloaded.getTestForForkString() );
-        Assert.assertEquals( getTEstSourceDirectory(), testSuiteDefinition.getTestSourceDirectory() );
+        Assert.assertEquals( expected[0], suiteXmlFiles.get(0) );
+        Assert.assertEquals( expected[1], suiteXmlFiles.get(1) );
+        Assert.assertEquals( getTestSourceDirectory(), testSuiteDefinition.getTestSourceDirectory() );
         Assert.assertEquals( aUserRequestedTest, testSuiteDefinition.getRequestedTest() );
-
-
     }
 
-    public void testProvider()
+    public void testTestForFork()
         throws IOException
     {
-        assertEquals( "com.provider", getReloadedStartupConfiguration().getProviderClassName() );
+        final ProviderConfiguration reloaded = getReloadedProviderConfiguration( new ArrayList() );
+        Assert.assertEquals( aTest, reloaded.getTestForForkString() );
 
     }
 
     public void testFailIfNoTests()
         throws IOException
     {
-        ProviderConfiguration reloaded = getReloadedProviderConfiguration();
+        ProviderConfiguration reloaded = getReloadedProviderConfiguration( new ArrayList() );
         assertTrue( reloaded.isFailIfNoTests().booleanValue() );
 
     }
 
-    private ProviderConfiguration getReloadedProviderConfiguration()
+    private ProviderConfiguration getReloadedProviderConfiguration( ArrayList reports )
         throws IOException
     {
         DirectoryScannerParameters directoryScannerParameters = getDirectoryScannerParameters();
         ClassLoaderConfiguration forkConfiguration = getForkConfiguration();
-        ProviderConfiguration booterConfiguration =
-            getTestBooterConfiguration( forkConfiguration, directoryScannerParameters, new ArrayList() );
-        final StartupConfiguration testProviderConfiguration = getTestProviderConfiguration( forkConfiguration );
+        ProviderConfiguration booterConfiguration = getTestProviderConfiguration( directoryScannerParameters, reports );
+        final StartupConfiguration testProviderConfiguration = getTestStartupConfiguration( forkConfiguration );
         return saveAndReload( booterConfiguration, testProviderConfiguration );
     }
 
-    private StartupConfiguration getReloadedStartupConfiguration()
-        throws IOException
-    {
-        ClassLoaderConfiguration forkConfiguration = getForkConfiguration();
-        return getTestProviderConfiguration( forkConfiguration );
-    }
-
     private DirectoryScannerParameters getDirectoryScannerParameters()
     {
         File aDir = new File( "." );
@@ -192,34 +180,30 @@ public class BooterDeserializerTest
         throws IOException
     {
         final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration();
-        BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration );
         Properties props = new Properties();
-        booterSerializer.serialize( props, booterConfiguration, testProviderConfiguration, aTest );
+        BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, props );
+        booterSerializer.serialize( booterConfiguration, testProviderConfiguration, aTest );
         final File propsTest =
             SystemPropertyManager.writePropertiesFile( props, forkConfiguration.getTempDirectory(), "propsTest", true );
         BooterDeserializer booterDeserializer = new BooterDeserializer( new FileInputStream( propsTest ) );
         return booterDeserializer.deserialize();
     }
 
-    private ProviderConfiguration getTestBooterConfiguration( ClassLoaderConfiguration classLoaderConfiguration,
-                                                              DirectoryScannerParameters directoryScannerParameters,
-                                                              List reports )
+    private ProviderConfiguration getTestProviderConfiguration( DirectoryScannerParameters directoryScannerParameters,
+                                                                List reports )
         throws IOException
     {
-        ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( true, true );
 
-        ReporterConfiguration reporterConfiguration =
-            new ReporterConfiguration( reports, new File( "." ), Boolean.TRUE );
+        File cwd = new File( "." );
+        ReporterConfiguration reporterConfiguration = new ReporterConfiguration( reports, cwd, Boolean.TRUE );
         TestRequest testSuiteDefinition =
-            new TestRequest( getSuiteXmlFileStrings(), getTEstSourceDirectory(), aUserRequestedTest );
-        StartupConfiguration surefireStarterConfiguration = getTestProviderConfiguration( classLoaderConfiguration );
-
+            new TestRequest( getSuiteXmlFileStrings(), getTestSourceDirectory(), aUserRequestedTest );
         return new ProviderConfiguration( directoryScannerParameters, true, reporterConfiguration,
                                           new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new Properties(),
                                           aTest );
     }
 
-    private StartupConfiguration getTestProviderConfiguration( ClassLoaderConfiguration classLoaderConfiguration )
+    private StartupConfiguration getTestStartupConfiguration( ClassLoaderConfiguration classLoaderConfiguration )
     {
         ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( true, true );
 
@@ -227,7 +211,7 @@ public class BooterDeserializerTest
                                          false );
     }
 
-    private File getTEstSourceDirectory()
+    private File getTestSourceDirectory()
     {
         return new File( "TestSrc" );
     }
@@ -237,8 +221,8 @@ public class BooterDeserializerTest
         return new File[]{ new File( "A1" ), new File( "A2" ) };
     }
 
-    private Object[] getSuiteXmlFileStrings()
+    private List getSuiteXmlFileStrings()
     {
-        return new Object[]{ "A1", "A2" };
+        return Arrays.asList( new Object[]{ "A1", "A2" });
     }
 }

Propchange: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java?rev=1044121&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java Thu Dec  9 20:35:09 2010
@@ -0,0 +1,161 @@
+package org.apache.maven.plugin.surefire.booterclient;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.surefire.booter.BooterConstants;
+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.booter.ProviderConfiguration;
+import org.apache.maven.surefire.booter.StartupConfiguration;
+import org.apache.maven.surefire.booter.SystemPropertyManager;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.testset.DirectoryScannerParameters;
+import org.apache.maven.surefire.testset.TestArtifactInfo;
+import org.apache.maven.surefire.testset.TestRequest;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Properties;
+
+/**
+ * Performs roundtrip testing of serialization/deserialization of The StartupConfiguration
+ *
+ * @author Kristian Rosenvold
+ */
+public class BooterDeserializerStartupConfigurationTest
+    extends TestCase
+{
+
+    private final String aTest = "aTest";
+
+    private final String aUserRequestedTest = "aUserRequestedTest";
+
+    public void testProvider()
+        throws IOException
+    {
+        assertEquals( "com.provider", getReloadedStartupConfiguration().getProviderClassName() );
+    }
+
+    public void testClassPathConfiguration()
+        throws IOException
+    {
+        final ClasspathConfiguration classpathConfiguration =
+            getReloadedStartupConfiguration().getClasspathConfiguration();
+        Properties props = new Properties();
+        classpathConfiguration.setForkProperties( props );
+        assertEquals( "true", props.get( BooterConstants.ENABLE_ASSERTIONS ) );
+        assertEquals( "true", props.get( BooterConstants.CHILD_DELEGATION ) );
+        assertEquals( "CP1", classpathConfiguration.getTestClasspath().get( 0 ) );
+        assertEquals( "CP2", classpathConfiguration.getTestClasspath().get( 1 ) );
+        assertEquals( "SP1", props.get( BooterConstants.SUREFIRE_CLASSPATHURL + "0" ));
+        assertEquals( "SP2", props.get( BooterConstants.SUREFIRE_CLASSPATHURL + "1" ));
+    }
+
+    public void testClassLoaderConfiguration()
+        throws IOException
+    {
+        assertFalse( getReloadedStartupConfiguration().isManifestOnlyJarRequestedAndUsable() );
+    }
+
+    public void testClassLoaderConfigurationTrues()
+        throws IOException
+    {
+        final StartupConfiguration testStartupConfiguration =
+            getTestStartupConfiguration( getManifestOnlyJarForkConfiguration() );
+        boolean current = testStartupConfiguration.isManifestOnlyJarRequestedAndUsable();
+        assertEquals( current, saveAndReload( testStartupConfiguration ).isManifestOnlyJarRequestedAndUsable() );
+    }
+
+
+    public static ClassLoaderConfiguration getSystemClassLoaderConfiguration()
+        throws IOException
+    {
+        return new ClassLoaderConfiguration( true, false );
+    }
+
+    public static ClassLoaderConfiguration getManifestOnlyJarForkConfiguration()
+        throws IOException
+    {
+        return new ClassLoaderConfiguration( true, true );
+    }
+
+
+    private StartupConfiguration getReloadedStartupConfiguration()
+        throws IOException
+    {
+        ClassLoaderConfiguration classLoaderConfiguration = getSystemClassLoaderConfiguration();
+        return saveAndReload( getTestStartupConfiguration( classLoaderConfiguration ) );
+    }
+
+    private StartupConfiguration saveAndReload( StartupConfiguration startupConfiguration )
+        throws IOException
+    {
+        final ForkConfiguration forkConfiguration =
+            ForkConfigurationTest.getForkConfiguration();
+        Properties props = new Properties();
+        BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, props );
+        booterSerializer.serialize( getProviderConfiguration(), startupConfiguration, aTest );
+        final File propsTest =
+            SystemPropertyManager.writePropertiesFile( props, forkConfiguration.getTempDirectory(), "propsTest", true );
+        BooterDeserializer booterDeserializer = new BooterDeserializer( new FileInputStream( propsTest ) );
+        return booterDeserializer.getProviderConfiguration();
+    }
+
+    private ProviderConfiguration getProviderConfiguration()
+        throws IOException
+    {
+
+        File cwd = new File( "." );
+        DirectoryScannerParameters directoryScannerParameters =
+            new DirectoryScannerParameters( cwd, new ArrayList(), new ArrayList(), Boolean.TRUE );
+        ReporterConfiguration reporterConfiguration = new ReporterConfiguration( new ArrayList(), cwd, Boolean.TRUE );
+        TestRequest testSuiteDefinition =
+            new TestRequest( Arrays.asList( getSuiteXmlFileStrings()), getTestSourceDirectory(), aUserRequestedTest );
+        return new ProviderConfiguration( directoryScannerParameters, true, reporterConfiguration,
+                                          new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new Properties(),
+                                          aTest );
+    }
+
+    private StartupConfiguration getTestStartupConfiguration( ClassLoaderConfiguration classLoaderConfiguration )
+    {
+        ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( true, true );
+        classpathConfiguration.addClasspathUrl( "CP1" );
+        classpathConfiguration.addClasspathUrl( "CP2" );
+        classpathConfiguration.addSurefireClasspathUrl( "SP1" );
+        classpathConfiguration.addSurefireClasspathUrl( "SP2" );
+        return new StartupConfiguration( "com.provider", classpathConfiguration, classLoaderConfiguration, false, false,
+                                         false );
+    }
+
+    private File getTestSourceDirectory()
+    {
+        return new File( "TestSrc" );
+    }
+
+    private Object[] getSuiteXmlFileStrings()
+    {
+        return new Object[]{ "A1", "A2" };
+    }
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java?rev=1044121&r1=1044120&r2=1044121&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java Thu Dec  9 20:35:09 2010
@@ -54,7 +54,7 @@ public class SurefireReflector
 
     private final Class reporterConfiguration;
 
-    private final Class testSuiteDefinition;
+    private final Class testRequest;
 
     private final Class testArtifactInfo;
 
@@ -86,7 +86,7 @@ public class SurefireReflector
         try
         {
             reporterConfiguration = surefireClassLoader.loadClass( ReporterConfiguration.class.getName() );
-            testSuiteDefinition = surefireClassLoader.loadClass( TestRequest.class.getName() );
+            testRequest = surefireClassLoader.loadClass( TestRequest.class.getName() );
             testArtifactInfo = surefireClassLoader.loadClass( TestArtifactInfo.class.getName() );
             testArtifactInfoAware = surefireClassLoader.loadClass( TestArtifactInfoAware.class.getName() );
             directoryScannerParameters = surefireClassLoader.loadClass( DirectoryScannerParameters.class.getName() );
@@ -153,8 +153,8 @@ public class SurefireReflector
         {
             return null;
         }
-        Class[] arguments = { Object[].class, File.class, String.class };
-        Constructor constructor = getConstructor( this.testSuiteDefinition, arguments );
+        Class[] arguments = { List.class, File.class, String.class };
+        Constructor constructor = getConstructor( this.testRequest, arguments );
         return newInstance( constructor,
                             new Object[]{ suiteDefinition.getSuiteXmlFiles(), suiteDefinition.getTestSourceDirectory(),
                                 suiteDefinition.getRequestedTest() } );
@@ -382,7 +382,7 @@ public class SurefireReflector
     void setTestSuiteDefinition( Object o, TestRequest testSuiteDefinition1 )
     {
         final Object param = createTestSuiteDefinition( testSuiteDefinition1 );
-        final Method setter = getMethod( o, "setTestRequest", new Class[]{ testSuiteDefinition } );
+        final Method setter = getMethod( o, "setTestRequest", new Class[]{ testRequest } );
         invokeSetter( o, setter, param );
     }
 

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestRequest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestRequest.java?rev=1044121&r1=1044120&r2=1044121&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestRequest.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestRequest.java Thu Dec  9 20:35:09 2010
@@ -20,6 +20,8 @@ package org.apache.maven.surefire.testse
  */
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Information about the requested test.
@@ -28,20 +30,20 @@ import java.io.File;
  */
 public class TestRequest
 {
-    private final File[] suiteXmlFiles;
+    private final List suiteXmlFiles;
 
     private final File testSourceDirectory;
 
     private final String requestedTest;
 
-    public TestRequest( Object[] suiteXmlFiles, File testSourceDirectory, String requestedTest )
+    public TestRequest( List suiteXmlFiles, File testSourceDirectory, String requestedTest )
     {
         this.suiteXmlFiles = createFiles( suiteXmlFiles );
         this.testSourceDirectory = testSourceDirectory;
         this.requestedTest = requestedTest;
     }
 
-    public File[] getSuiteXmlFiles()
+    public List getSuiteXmlFiles()
     {
         return suiteXmlFiles;
     }
@@ -56,16 +58,16 @@ public class TestRequest
         return requestedTest;
     }
 
-    private static File[] createFiles( Object[] suiteXmlFiles )
+    private static List createFiles( List suiteXmlFiles )
     {
         if ( suiteXmlFiles != null )
         {
-            File[] files = new File[suiteXmlFiles.length];
+            List files = new ArrayList();
             Object element;
-            for ( int i = 0; i < suiteXmlFiles.length; i++ )
+            for ( int i = 0; i < suiteXmlFiles.size(); i++ )
             {
-                element = suiteXmlFiles[i];
-                files[i] = element instanceof String ? new File( (String) element ) : (File) element;
+                element = suiteXmlFiles.get(i);
+                files.add( element instanceof String ? new File( (String) element ) : (File) element);
             }
             return files;
         }

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java?rev=1044121&r1=1044120&r2=1044121&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java Thu Dec  9 20:35:09 2010
@@ -27,12 +27,7 @@ import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-import java.util.SortedMap;
-import java.util.TreeMap;
+import java.util.*;
 
 /**
  * Knows how to serialize and deserialize the booter configuration.
@@ -64,158 +59,55 @@ public class BooterDeserializer
     public ProviderConfiguration deserialize()
         throws IOException
     {
-        DirectoryScannerParameters dirScannerParams;
-        boolean failIfNotests = false;  // todo; check this out.
 
-        SortedMap reportsMap = new TreeMap();
+        final File reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) );
+        final String testNgVersion = properties.getProperty( TESTARTIFACT_VERSION );
+        final String testArtifactClassifier = properties.getProperty( TESTARTIFACT_CLASSIFIER );
+        final Object testForFork = properties.getTypeDecoded( FORKTESTSET );
+        final String requestedTest = properties.getProperty( REQUESTEDTEST );
+        final File sourceDirectory =
+            (File) getParamValue( properties.getProperty( SOURCE_DIRECTORY ), File.class.getName() );
+
+        final List reports = properties.getStringList( REPORT_PROPERTY_PREFIX );
+        final List excludesList = properties.getStringList( EXCLUDES_PROPERTY_PREFIX );
+        final List includesList = properties.getStringList( INCLUDES_PROPERTY_PREFIX );
+
+        List testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES );
+        final File testClassesDirectory = properties.getFileProperty( TEST_CLASSES_DIRECTORY );
+
+        DirectoryScannerParameters dirScannerParams =
+            new DirectoryScannerParameters( testClassesDirectory, includesList, excludesList,
+                                            valueOf( properties.getBooleanProperty( FAILIFNOTESTS ) ) );
 
-        boolean isTrimStackTrace = false;
-        File reportsDirectory = null;
-
-        String testNgVersion = null;
-        String testNgClassifier = null;
-        Object testForFork = null;
-        String requestedTest = null;
-        File sourceDirectory = null;
-        Object[] testSuiteXmlFiles = null;
-        SortedMap includes = new TreeMap();
-        SortedMap excludes = new TreeMap();
-        File testClassesDirectory = null;
-
-        for ( Enumeration e = properties.propertyNames(); e.hasMoreElements(); )
-        {
-            String name = (String) e.nextElement();
-
-            if ( name.startsWith( REPORT_PROPERTY_PREFIX ) && !isTypeHolderProperty( name ) )
-            {
-                String className = properties.getProperty( name );
-                reportsMap.put( name, className );
-            }
-            else if ( name.startsWith( INCLUDES_PROPERTY_PREFIX ) && !isTypeHolderProperty( name ) )
-            {
-                String className = properties.getProperty( name );
-                includes.put( name, className );
-            }
-            else if ( name.startsWith( EXCLUDES_PROPERTY_PREFIX ) && !isTypeHolderProperty( name ) )
-            {
-                String className = properties.getProperty( name );
-                excludes.put( name, className );
-            }
-            else if ( FAILIFNOTESTS.equals( name ) )
-            {
-                failIfNotests = properties.getBooleanProperty( FAILIFNOTESTS );
-            }
-            else if ( ISTRIMSTACKTRACE.equals( name ) )
-            {
-                failIfNotests = properties.getBooleanProperty( ISTRIMSTACKTRACE );
-            }
-            else if ( REPORTSDIRECTORY.equals( name ) )
-            {
-                reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) );
-            }
-            else if ( TESTARTIFACT_VERSION.equals( name ) )
-            {
-                testNgVersion = properties.getProperty( TESTARTIFACT_VERSION );
-            }
-            else if ( TESTARTIFACT_CLASSIFIER.equals( name ) )
-            {
-                testNgClassifier = properties.getProperty( TESTARTIFACT_CLASSIFIER );
-            }
-            else if ( FORKTESTSET.equals( name ) )
-            {
-                testForFork = getTypeDecoded( properties.getProperty( FORKTESTSET ) );
-            }
-            else if ( REQUESTEDTEST.equals( name ) )
-            {
-                requestedTest = properties.getProperty( REQUESTEDTEST );
-            }
-            else if ( SOURCE_DIRECTORY.equals( name ) )
-            {
-                sourceDirectory =
-                    (File) getParamValue( properties.getProperty( SOURCE_DIRECTORY ), File.class.getName() );
-            }
-            else if ( TEST_CLASSES_DIRECTORY.equals( name ) )
-            {
-                testClassesDirectory =
-                    (File) getParamValue( properties.getProperty( TEST_CLASSES_DIRECTORY ), File.class.getName() );
-            }
-            else if ( TEST_SUITE_XML_FILES.equals( name ) )
-            {
-                testSuiteXmlFiles = constructParamObjects( properties.getProperty( TEST_SUITE_XML_FILES ), File.class );
-            }
-        }
-
-        dirScannerParams = new DirectoryScannerParameters( testClassesDirectory, new ArrayList( includes.values() ),
-                                                           new ArrayList( excludes.values() ),
-                                                           valueOf( failIfNotests ) );
-
-        TestArtifactInfo testNg = new TestArtifactInfo( testNgVersion, testNgClassifier );
+        TestArtifactInfo testNg = new TestArtifactInfo( testNgVersion, testArtifactClassifier );
         TestRequest testSuiteDefinition = new TestRequest( testSuiteXmlFiles, sourceDirectory, requestedTest );
 
-        List reports = new ArrayList( reportsMap.values() );
-
-        ReporterConfiguration reporterConfiguration =
-            new ReporterConfiguration( reports, reportsDirectory, valueOf( isTrimStackTrace ) );
+        ReporterConfiguration reporterConfiguration = new ReporterConfiguration( reports, reportsDirectory, valueOf(
+            properties.getBooleanProperty( ISTRIMSTACKTRACE ) ) );
 
-        return new ProviderConfiguration( dirScannerParams, failIfNotests, reporterConfiguration, testNg,
-                                          testSuiteDefinition, properties.getProperties(), testForFork );
+        return new ProviderConfiguration( dirScannerParams, properties.getBooleanProperty( FAILIFNOTESTS ),
+                                          reporterConfiguration, testNg, testSuiteDefinition,
+                                          properties.getProperties(), testForFork );
     }
 
     public StartupConfiguration getProviderConfiguration()
         throws IOException
     {
-        boolean enableAssertions = false;
-        boolean childDelegation = true;
-        boolean useSystemClassLoader = false; // todo check default value
-        boolean useManifestOnlyJar = false; // todo check default value
+        boolean enableAssertions = properties.getBooleanProperty( ENABLE_ASSERTIONS );
+        boolean childDelegation = properties.getBooleanProperty( CHILD_DELEGATION );
+        boolean useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER );
+        boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR );
+        String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION );
 
-        SortedMap classPathUrls = new TreeMap();
 
-        SortedMap surefireClassPathUrls = new TreeMap();
-
-        String providerConfiguration = null;
-
-        for ( Enumeration e = properties.propertyNames(); e.hasMoreElements(); )
-        {
-            String name = (String) e.nextElement();
-
-            if ( name.startsWith( CLASSPATH_URL ) )
-            {
-                classPathUrls.put( Integer.valueOf( name.substring( name.indexOf( '.' ) + 1 ) ),
-                                   properties.getProperty( name ) );
-            }
-            else if ( name.startsWith( SUREFIRE_CLASSPATHURL ) )
-            {
-                surefireClassPathUrls.put( Integer.valueOf( name.substring( name.indexOf( '.' ) + 1 ) ),
-                                           properties.getProperty( name ) );
-            }
-            else if ( CHILD_DELEGATION.equals( name ) )
-            {
-                childDelegation = properties.getBooleanProperty( CHILD_DELEGATION );
-            }
-            else if ( ENABLE_ASSERTIONS.equals( name ) )
-            {
-                enableAssertions = properties.getBooleanProperty( ENABLE_ASSERTIONS );
-            }
-            else if ( USESYSTEMCLASSLOADER.equals( name ) )
-            {
-                useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER );
-            }
-            else if ( USEMANIFESTONLYJAR.equals( name ) )
-            {
-                useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR );
-            }
-            else if ( PROVIDER_CONFIGURATION.equals( name ) )
-            {
-                providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION );
-            }
-        }
+        final List classpath = properties.getStringList( CLASSPATH_URL );
+        final List sureFireClasspath = properties.getStringList( SUREFIRE_CLASSPATHURL );
 
         ClassLoaderConfiguration classLoaderConfiguration =
             new ClassLoaderConfiguration( useSystemClassLoader, useManifestOnlyJar );
 
         ClasspathConfiguration classpathConfiguration =
-            new ClasspathConfiguration( classPathUrls, surefireClassPathUrls, enableAssertions, childDelegation );
+            new ClasspathConfiguration( classpath, sureFireClasspath, enableAssertions, childDelegation );
 
         return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration,
                                                 classLoaderConfiguration );
@@ -226,11 +118,6 @@ public class BooterDeserializer
         return aBoolean ? Boolean.TRUE : Boolean.FALSE;
     }
 
-    private boolean isTypeHolderProperty( String name )
-    {
-        return name.endsWith( PARAMS_SUFIX ) || name.endsWith( TYPES_SUFIX );
-    }
-
     private static List processStringList( String stringList )
     {
         String sl = stringList;
@@ -271,14 +158,6 @@ public class BooterDeserializer
         return paramObjects;
     }
 
-    private static Object getTypeDecoded( String typeEncoded )
-    {
-        int typeSep = typeEncoded.indexOf( "|" );
-        String type = typeEncoded.substring( 0, typeSep );
-        String value = typeEncoded.substring( typeSep + 1 );
-        return getParamValue( value, type );
-    }
-
     private static Object getParamValue( String param, String typeName )
     {
         if ( typeName.trim().length() == 0 )

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClassLoaderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClassLoaderConfiguration.java?rev=1044121&r1=1044120&r2=1044121&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClassLoaderConfiguration.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClassLoaderConfiguration.java Thu Dec  9 20:35:09 2010
@@ -43,6 +43,11 @@ public class ClassLoaderConfiguration
         return useSystemClassLoader;
     }
 
+    public boolean isUseManifestOnlyJar()
+    {
+        return useManifestOnlyJar;
+    }
+
     public boolean isManifestOnlyJarRequestedAndUsable()
     {
         return isUseSystemClassLoader() && useManifestOnlyJar;

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java?rev=1044121&r1=1044120&r2=1044121&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java Thu Dec  9 20:35:09 2010
@@ -21,15 +21,14 @@ package org.apache.maven.surefire.booter
 
 import org.apache.maven.surefire.util.NestedRuntimeException;
 
-import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
-import java.util.SortedMap;
 
 /**
  * Represents the classpaths for the BooterConfiguration.
@@ -43,9 +42,9 @@ import java.util.SortedMap;
 public class ClasspathConfiguration
 {
 
-    private final Classpath classpathUrls = new Classpath();
+    private final Classpath classpathUrls;
 
-    private final Classpath surefireClasspathUrls = new Classpath();
+    private final Classpath surefireClasspathUrls;
 
     /**
      * Whether to enable assertions or not (can be affected by the fork arguments, and the ability to do so based on the
@@ -59,30 +58,28 @@ public class ClasspathConfiguration
 
     public ClasspathConfiguration( boolean enableAssertions, boolean childDelegation )
     {
-        this.enableAssertions = enableAssertions;
-        this.childDelegation = childDelegation;
+        this( new ArrayList(), new ArrayList(), enableAssertions, childDelegation);
     }
 
     /*
    * Reads the config from the supplied stream. Closes the stream.
     */
-    public ClasspathConfiguration( SortedMap classPathUrls, SortedMap surefireClassPathUrls, boolean enableAssertions,
+    public ClasspathConfiguration( List classPathUrls, List surefireClassPathUrls, boolean enableAssertions,
                                    boolean childDelegation )
-        throws IOException
     {
 
         this.enableAssertions = enableAssertions;
         this.childDelegation = childDelegation;
-        for ( Iterator cpi = classPathUrls.keySet().iterator(); cpi.hasNext(); )
+        this.classpathUrls = new Classpath();
+        for ( Iterator cpi = classPathUrls.iterator(); cpi.hasNext(); )
         {
-            String url = (String) classPathUrls.get( cpi.next() );
-            this.classpathUrls.addClassPathElementUrl( url );
+            this.classpathUrls.addClassPathElementUrl( (String) cpi.next() );
         }
 
-        for ( Iterator scpi = surefireClassPathUrls.keySet().iterator(); scpi.hasNext(); )
+        this.surefireClasspathUrls = new Classpath();
+        for ( Iterator scpi = surefireClassPathUrls.iterator(); scpi.hasNext(); )
         {
-            String url = (String) surefireClassPathUrls.get( scpi.next() );
-            this.surefireClasspathUrls.addClassPathElementUrl( url );
+            this.surefireClasspathUrls.addClassPathElementUrl( (String) scpi.next() );
         }
     }
 

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java?rev=1044121&r1=1044120&r2=1044121&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java Thu Dec  9 20:35:09 2010
@@ -19,9 +19,9 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Properties;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.util.*;
 
 /**
  * @author Kristian Rosenvold
@@ -32,6 +32,10 @@ public class PropertiesWrapper
 
     public PropertiesWrapper( Properties properties )
     {
+        if ( properties == null )
+        {
+            throw new IllegalStateException( "Properties cannot be null" );
+        }
         this.properties = properties;
     }
 
@@ -55,13 +59,181 @@ public class PropertiesWrapper
         return properties.getProperty( key );
     }
 
-    public boolean getBooleanProperty(String propertyName){
+    public boolean getBooleanProperty( String propertyName )
+    {
         final Boolean aBoolean = Boolean.valueOf( properties.getProperty( propertyName ) );
         return aBoolean.booleanValue();
     }
 
-    public Enumeration propertyNames()
+    public File getFileProperty( String key )
+    {
+        final String property = getProperty( key );
+        if ( property == null )
+        {
+            return null;
+        }
+        return (File) getParamValue( property, File.class.getName() );
+    }
+
+    public List getListOfTypedObjects( String propertyPrefix )
+    {
+        String type;
+        String value;
+        List result = new ArrayList();
+        for ( int i = 0; ( type = getProperty( propertyPrefix + i + BooterConstants.TYPES_SUFIX ) ) != null; i++ )
+        {
+            value = getProperty( propertyPrefix + i + BooterConstants.PARAMS_SUFIX );
+            result.add( getParamValue( value, type ) );
+        }
+        return result;
+    }
+
+    public List getStringList( String propertyPrefix )
+    {
+        String value;
+        List result = new ArrayList();
+        // Whoa, C !!
+        for ( int i = 0; ( value = getProperty( propertyPrefix + i ) ) != null; i++ )
+        {
+            result.add( value );
+        }
+        return result;
+    }
+
+    /**
+     * Retrieves as single object that is persisted with type encoding
+     *
+     * @param key The key for the propery
+     * @return The object, of a supported type
+     */
+    public Object getTypeDecoded( String key )
+    {
+        String typeEncoded = getProperty( key );
+        if ( typeEncoded == null )
+        {
+            return null;
+        }
+        int typeSep = typeEncoded.indexOf( "|" );
+        String type = typeEncoded.substring( 0, typeSep );
+        String value = typeEncoded.substring( typeSep + 1 );
+        return getParamValue( value, type );
+    }
+
+    private Object getParamValue( String param, String typeName )
+    {
+        if ( typeName.trim().length() == 0 )
+        {
+            return null;
+        }
+        else if ( typeName.equals( String.class.getName() ) )
+        {
+            return param;
+        }
+        else if ( typeName.equals( File.class.getName() ) )
+        {
+            return new File( param );
+        }
+        else if ( typeName.equals( File[].class.getName() ) )
+        {
+            List stringList = processStringList( param );
+            File[] fileList = new File[stringList.size()];
+            for ( int j = 0; j < stringList.size(); j++ )
+            {
+                fileList[j] = new File( (String) stringList.get( j ) );
+            }
+            return fileList;
+        }
+        else if ( typeName.equals( ArrayList.class.getName() ) )
+        {
+            return processStringList( param );
+        }
+        else if ( typeName.equals( Boolean.class.getName() ) )
+        {
+            return Boolean.valueOf( param );
+        }
+        else if ( typeName.equals( Integer.class.getName() ) )
+        {
+            return Integer.valueOf( param );
+        }
+        else if ( typeName.equals( Properties.class.getName() ) )
+        {
+            final Properties result = new Properties();
+            try
+            {
+                ByteArrayInputStream bais = new ByteArrayInputStream( param.getBytes( "8859_1" ) );
+                result.load( bais );
+            }
+            catch ( Exception e )
+            {
+                throw new RuntimeException( "bug in property conversion", e );
+            }
+            return result;
+        }
+        else
+        {
+            // TODO: could attempt to construct with a String constructor if needed
+            throw new IllegalArgumentException( "Unknown parameter type: " + typeName );
+        }
+    }
+
+    private static List processStringList( String stringList )
     {
-        return properties.propertyNames();
+        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;
     }
+
+    public void setProperty( String key, File file )
+    {
+        if ( file != null )
+        {
+            setProperty( key, file.toString() );
+        }
+    }
+    public void setProperty( String key, Boolean aBoolean )
+    {
+        if ( aBoolean != null )
+        {
+            setProperty( key, aBoolean.toString() );
+        }
+    }
+
+    public void setProperty( String key, String value )
+    {
+        if ( value != null )
+        {
+            properties.setProperty( key, value );
+        }
+    }
+
+    public void addList( List items, String propertyPrefix )
+    {
+        if ( items == null || items.size() == 0 )
+        {
+            return;
+        }
+        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/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java?rev=1044121&r1=1044120&r2=1044121&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java Thu Dec  9 20:35:09 2010
@@ -41,20 +41,20 @@ public class SurefireStarter
 {
     private static final int NO_TESTS = 254;
 
-    private final ProviderConfiguration booterConfiguration;
+    private final ProviderConfiguration providerConfiguration;
 
-    private final StartupConfiguration providerConfiguration;
+    private final StartupConfiguration startupConfiguration;
 
-    public SurefireStarter( StartupConfiguration providerConfiguration, ProviderConfiguration booterConfiguration )
+    public SurefireStarter( StartupConfiguration startupConfiguration, ProviderConfiguration providerConfiguration )
     {
-        this.booterConfiguration = booterConfiguration;
         this.providerConfiguration = providerConfiguration;
+        this.startupConfiguration = startupConfiguration;
     }
 
     public RunResult runSuitesInProcess( Object testSet )
         throws SurefireExecutionException
     {
-        final StartupConfiguration starterConfiguration = providerConfiguration;
+        final StartupConfiguration starterConfiguration = startupConfiguration;
         final ClasspathConfiguration classpathConfiguration = starterConfiguration.getClasspathConfiguration();
 
         ClassLoader testsClassLoader = classpathConfiguration.createTestClassLoaderConditionallySystem(
@@ -73,7 +73,7 @@ public class SurefireStarter
         ClassLoader testsClassLoader = createInProcessTestClassLoader();
 
         final ClasspathConfiguration classpathConfiguration =
-            providerConfiguration.getClasspathConfiguration();
+            startupConfiguration.getClasspathConfiguration();
 
         ClassLoader surefireClassLoader = classpathConfiguration.createSurefireClassLoader( testsClassLoader );
 
@@ -85,12 +85,12 @@ public class SurefireStarter
     {
         ClassLoader testsClassLoader;
 
-        final ClasspathConfiguration classpathConfiguration = providerConfiguration.getClasspathConfiguration();
+        final ClasspathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration();
 
         String testClassPath = classpathConfiguration.getTestClasspath().getClassPathAsString();
 
         System.setProperty( "surefire.test.class.path", testClassPath );
-        if ( providerConfiguration.isManifestOnlyJarRequestedAndUsable() )
+        if ( startupConfiguration.isManifestOnlyJarRequestedAndUsable() )
         {
             testsClassLoader = getClass().getClassLoader(); // ClassLoader.getSystemClassLoader()
             // SUREFIRE-459, trick the app under test into thinking its classpath was conventional
@@ -124,7 +124,7 @@ public class SurefireStarter
 
     private RunResult invokeProvider( Object testSet, ClassLoader testsClassLoader, ClassLoader surefireClassLoader )
     {
-        ProviderFactory providerFactory = new ProviderFactory( providerConfiguration, booterConfiguration,
+        ProviderFactory providerFactory = new ProviderFactory( startupConfiguration, providerConfiguration,
                                                                surefireClassLoader );
         final SurefireProvider provider = providerFactory.createProvider( testsClassLoader );
 
@@ -153,7 +153,7 @@ public class SurefireStarter
         throws SurefireExecutionException
     {
 
-        if ( runCount.getCompletedCount() == 0 && booterConfiguration.isFailIfNoTests().booleanValue() )
+        if ( runCount.getCompletedCount() == 0 && providerConfiguration.isFailIfNoTests().booleanValue() )
         {
             return NO_TESTS;
         }

Modified: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java?rev=1044121&r1=1044120&r2=1044121&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java (original)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java Thu Dec  9 20:35:09 2010
@@ -29,6 +29,7 @@ import java.io.File;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Properties;
 
 /**
@@ -57,7 +58,7 @@ public class SurefireReflectorTest
         Object foo = getFoo();
 
         TestRequest testSuiteDefinition =
-            new TestRequest( new Object[]{  new File("file1"),new File("file2") }, new File( "TestSOurce" ), "aUserRequestedTest" );
+            new TestRequest( Arrays.asList( new File[]{new File("file1"),new File("file2")} ), new File( "TestSOurce" ), "aUserRequestedTest" );
         assertTrue( surefireReflector.isTestSuiteDefinitionAware( foo ) );
         surefireReflector.setTestSuiteDefinition( foo, testSuiteDefinition );
         assertTrue( isCalled( foo ).booleanValue() );

Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java?rev=1044121&r1=1044120&r2=1044121&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java Thu Dec  9 20:35:09 2010
@@ -95,7 +95,7 @@ public class TestNGProvider
 
     boolean isTestNGXmlTestSuite( TestRequest testSuiteDefinition )
     {
-        return testSuiteDefinition.getSuiteXmlFiles() != null && testSuiteDefinition.getSuiteXmlFiles().length > 0 &&
+        return testSuiteDefinition.getSuiteXmlFiles() != null && testSuiteDefinition.getSuiteXmlFiles().size() > 0 &&
             testSuiteDefinition.getRequestedTest() == null;
 
     }

Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java?rev=1044121&r1=1044120&r2=1044121&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java Thu Dec  9 20:35:09 2010
@@ -45,7 +45,7 @@ import org.apache.maven.surefire.testset
 public class TestNGXmlTestSuite
     implements SurefireTestSuite
 {
-    private File[] suiteFiles;
+    private List suiteFiles;
 
     private List suiteFilePaths;
 
@@ -66,7 +66,7 @@ public class TestNGXmlTestSuite
      * Creates a testng testset to be configured by the specified
      * xml file(s). The XML files are suite definitions files according to TestNG DTD.
      */
-    public TestNGXmlTestSuite( File[] suiteFiles, String testSourceDirectory, String artifactVersion,
+    public TestNGXmlTestSuite( List suiteFiles, String testSourceDirectory, String artifactVersion,
                                String artifactClassifier, Properties confOptions, File reportsDirectory )
     {
         this.suiteFiles = suiteFiles;
@@ -105,7 +105,7 @@ public class TestNGXmlTestSuite
 
     public int getNumTests()
     {
-        return suiteFiles.length;
+        return suiteFiles.size();
     }
 
     public List getClassesSkippedByValidation()
@@ -129,7 +129,7 @@ public class TestNGXmlTestSuite
         this.testSets = new HashMap();
         this.suiteFilePaths = new ArrayList();
 
-        for ( Iterator i = Arrays.asList( suiteFiles ).iterator(); i.hasNext(); )
+        for ( Iterator i = suiteFiles.iterator(); i.hasNext(); )
         {
             File file = (File) i.next();
             if ( !file.exists() || !file.isFile() )



Mime
View raw message