Author: krosenvold
Date: Thu Nov 18 11:03:03 2010
New Revision: 1036402

URL: http://svn.apache.org/viewvc?rev=1036402&view=rev
Log:
o Further cleanups that were made possible by splitting booter in 3

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/booter/PluginSideBooter.java
    
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booter/PluginsideForkConfiguration.java
    
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booter/PluginsideForkConfigurationTest.java
    
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterSerializer.java
    
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
    
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterSerializerTest.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=1036402&r1=1036401&r2=1036402&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 Nov 18 11:03:03 2010
@@ -38,7 +38,6 @@ import org.apache.maven.plugin.surefire.
 import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter;
 import org.apache.maven.surefire.booter.BooterConfiguration;
 import org.apache.maven.surefire.booter.ClasspathConfiguration;
-import org.apache.maven.surefire.booter.ForkConfiguration;
 import org.apache.maven.surefire.report.BriefConsoleReporter;
 import org.apache.maven.surefire.report.BriefFileReporter;
 import org.apache.maven.surefire.report.ConsoleReporter;
@@ -214,7 +213,7 @@ public abstract class AbstractSurefireMo
 
     protected boolean isForkModeNever()
     {
-        return ForkConfiguration.FORK_NEVER.equals( getForkMode() );
+        return PluginsideForkConfiguration.FORK_NEVER.equals( getForkMode() );
     }
 
     protected BooterConfiguration createBooterConfiguration( 
PluginsideForkConfiguration forkConfiguration )
@@ -444,7 +443,7 @@ public abstract class AbstractSurefireMo
             getLog().info( "Toolchain in " + getPluginName() + "-plugin: " + 
tc );
             if ( isForkModeNever() )
             {
-                setForkMode( ForkConfiguration.FORK_ONCE );
+                setForkMode( PluginsideForkConfiguration.FORK_ONCE );
             }
             if ( getJvm() != null )
             {

Modified: 
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booter/PluginSideBooter.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booter/PluginSideBooter.java?rev=1036402&r1=1036401&r2=1036402&view=diff
==============================================================================
--- 
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booter/PluginSideBooter.java
 (original)
+++ 
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booter/PluginSideBooter.java
 Thu Nov 18 11:03:03 2010
@@ -22,7 +22,6 @@ package org.apache.maven.plugin.surefire
 import org.apache.maven.surefire.booter.BooterConfiguration;
 import org.apache.maven.surefire.booter.BooterSerializer;
 import org.apache.maven.surefire.booter.ClasspathConfiguration;
-import org.apache.maven.surefire.booter.ForkConfiguration;
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
 import org.apache.maven.surefire.booter.SurefireExecutionException;
 import org.apache.maven.surefire.booter.SurefireReflector;
@@ -88,16 +87,16 @@ public class PluginSideBooter
         int result;
 
         final String requestedForkMode = forkConfiguration.getForkMode();
-        if ( ForkConfiguration.FORK_NEVER.equals( requestedForkMode ) )
+        if ( PluginsideForkConfiguration.FORK_NEVER.equals( requestedForkMode 
) )
         {
             TestVmBooter testVmBooter = new TestVmBooter( booterConfiguration 
);
             result = testVmBooter.runSuitesInProcess();
         }
-        else if ( ForkConfiguration.FORK_ONCE.equals( requestedForkMode ) )
+        else if ( PluginsideForkConfiguration.FORK_ONCE.equals( 
requestedForkMode ) )
         {
             result = runSuitesForkOnce();
         }
-        else if ( ForkConfiguration.FORK_ALWAYS.equals( requestedForkMode ) )
+        else if ( PluginsideForkConfiguration.FORK_ALWAYS.equals( 
requestedForkMode ) )
         {
             result = runSuitesForkPerTestSet();
         }
@@ -246,13 +245,15 @@ public class PluginSideBooter
         try
         {
             BooterSerializer booterSerializer = new BooterSerializer();
-            surefireProperties = booterSerializer.writePropertiesFile( 
"surefire", properties,
-                                                                       
forkConfiguration.getBooterForkConfiguration() );
+            surefireProperties =
+                booterSerializer.writePropertiesFile( "surefire", properties, 
forkConfiguration.isDebug(),
+                                                      
forkConfiguration.getTempDirectory() );
             if ( forkConfiguration.getSystemProperties() != null )
             {
                 systemProperties =
                     booterSerializer.writePropertiesFile( "surefire", 
forkConfiguration.getSystemProperties(),
-                                                          
forkConfiguration.getBooterForkConfiguration() );
+                                                          
forkConfiguration.isDebug(),
+                                                          
forkConfiguration.getTempDirectory() );
             }
         }
         catch ( IOException e )

Modified: 
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booter/PluginsideForkConfiguration.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booter/PluginsideForkConfiguration.java?rev=1036402&r1=1036401&r2=1036402&view=diff
==============================================================================
--- 
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booter/PluginsideForkConfiguration.java
 (original)
+++ 
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booter/PluginsideForkConfiguration.java
 Thu Nov 18 11:03:03 2010
@@ -51,7 +51,7 @@ public class PluginsideForkConfiguration
 
     public static final String FORK_ALWAYS = "always";
 
-    public static final String FORK_NEVER = "never";
+    public static final String FORK_NEVER = ForkConfiguration.FORK_NEVER;
 
     private String forkMode;
 
@@ -77,12 +77,7 @@ public class PluginsideForkConfiguration
 
     public ForkConfiguration getBooterForkConfiguration()
     {
-        ForkConfiguration forkConfiguration = new ForkConfiguration();
-        forkConfiguration.setUseSystemClassLoader( isUseSystemClassLoader() );
-        forkConfiguration.setUseManifestOnlyJar( isUseManifestOnlyJar() );
-        forkConfiguration.setTempDirectory( tempDirectory );
-        forkConfiguration.setDebug( debug );
-        return forkConfiguration;
+        return new ForkConfiguration(isUseSystemClassLoader() , 
isUseManifestOnlyJar(), forkMode);
     }
 
     public void setForkMode( String forkMode )
@@ -316,4 +311,10 @@ public class PluginsideForkConfiguration
     {
         return debugLine;
     }
+
+
+    public File getTempDirectory()
+    {
+        return tempDirectory;
+    }
 }

Modified: 
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booter/PluginsideForkConfigurationTest.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booter/PluginsideForkConfigurationTest.java?rev=1036402&r1=1036401&r2=1036402&view=diff
==============================================================================
--- 
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booter/PluginsideForkConfigurationTest.java
 (original)
+++ 
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booter/PluginsideForkConfigurationTest.java
 Thu Nov 18 11:03:03 2010
@@ -20,7 +20,6 @@ package org.apache.maven.plugin.surefire
  */
 
 import junit.framework.TestCase;
-import org.apache.maven.surefire.booter.ForkConfiguration;
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -38,7 +37,7 @@ public class PluginsideForkConfiguration
     {
         PluginsideForkConfiguration config = getForkConfiguration();
         File cpElement = getTempClasspathFile();
-        config.setForkMode( ForkConfiguration.FORK_ONCE );
+        config.setForkMode( PluginsideForkConfiguration.FORK_ONCE );
         config.setUseSystemClassLoader( true );
         config.setUseSystemClassLoader( true );
         config.setJvmExecutable( "java" );

Modified: 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterSerializer.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterSerializer.java?rev=1036402&r1=1036401&r2=1036402&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterSerializer.java
 (original)
+++ 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterSerializer.java
 Thu Nov 18 11:03:03 2010
@@ -22,8 +22,19 @@ import org.apache.maven.surefire.suite.S
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.*;
-import java.util.*;
+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;
 
 /**
  * Knows how to serialize and deserialize the booter configuration.
@@ -55,7 +66,6 @@ public class BooterSerializer
     public BooterConfiguration deserialize( InputStream inputStream )
         throws IOException
     {
-        boolean forked = true;
         Properties properties = loadProperties( inputStream );
         final List reports = new ArrayList();
         Object[] dirScannerParams = null;
@@ -63,6 +73,8 @@ public class BooterSerializer
         boolean childDelegation = true;
         SuiteDefinition suiteDefinition = null;
         boolean failIfNotests = false;  // todo; check this out.
+        boolean useSystemClassLoader = false; // todo check default value
+        boolean useManifestOnlyJar = false; // todo check default value
 
         SortedMap classPathUrls = new TreeMap();
 
@@ -70,9 +82,6 @@ public class BooterSerializer
 
         Collection booterClassPathUrl = new ArrayList();
 
-        ForkConfiguration forkConfiguration = new ForkConfiguration();
-        forkConfiguration.setForkMode( "never" );
-
         for ( Enumeration e = properties.propertyNames(); e.hasMoreElements(); 
)
         {
             String name = (String) e.nextElement();
@@ -126,13 +135,12 @@ public class BooterSerializer
             }
             else if ( "useSystemClassLoader".equals( name ) )
             {
-                boolean value = Boolean.valueOf( properties.getProperty( 
"useSystemClassLoader" ) ).booleanValue();
-                forkConfiguration.setUseSystemClassLoader( value );
+                useSystemClassLoader =
+                    Boolean.valueOf( properties.getProperty( 
"useSystemClassLoader" ) ).booleanValue();
             }
             else if ( "useManifestOnlyJar".equals( name ) )
             {
-                boolean value = Boolean.valueOf( properties.getProperty( 
"useManifestOnlyJar" ) ).booleanValue();
-                forkConfiguration.setUseManifestOnlyJar( value );
+                useManifestOnlyJar = Boolean.valueOf( properties.getProperty( 
"useManifestOnlyJar" ) ).booleanValue();
             }
             else if ( "failIfNoTests".equals( name ) )
             {
@@ -140,10 +148,15 @@ public class BooterSerializer
             }
         }
 
+        // todo check out this "never" value
+        ForkConfiguration forkConfiguration =
+            new ForkConfiguration( useSystemClassLoader, useManifestOnlyJar, 
"never" );
+
         ClasspathConfiguration classpathConfiguration =
             new ClasspathConfiguration( classPathUrls, surefireClassPathUrls, 
booterClassPathUrl, enableAssertions,
                                         childDelegation );
 
+        boolean forked = true;
         return new BooterConfiguration( forkConfiguration, 
classpathConfiguration, suiteDefinition, reports, forked,
                                         dirScannerParams, failIfNotests, 
properties );
     }
@@ -165,11 +178,11 @@ public class BooterSerializer
         properties.setProperty( "failIfNoTests", String.valueOf( 
booterConfiguration.isFailIfNoTests() ) );
     }
 
-    public File writePropertiesFile( String name, Properties properties, 
ForkConfiguration forkConfiguration )
+    public File writePropertiesFile( String name, Properties properties, 
boolean debug, File tempDirectory )
         throws IOException
     {
-        File file = File.createTempFile( name, "tmp", 
forkConfiguration.getTempDirectory() );
-        if ( !forkConfiguration.isDebug() )
+        File file = File.createTempFile( name, "tmp", tempDirectory );
+        if ( !debug )
         {
             file.deleteOnExit();
         }

Modified: 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java?rev=1036402&r1=1036401&r2=1036402&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
 (original)
+++ 
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
 Thu Nov 18 11:03:03 2010
@@ -19,8 +19,6 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
-import java.io.File;
-
 /**
  * Configuration for forking tests.
  *
@@ -29,40 +27,19 @@ import java.io.File;
  */
 public class ForkConfiguration
 {
-    public static final String FORK_ONCE = "once";
-
-    public static final String FORK_ALWAYS = "always";
-
     public static final String FORK_NEVER = "never";
 
-    private String forkMode;
-
-    private boolean useSystemClassLoader;
+    private final String forkMode;
 
-    private boolean useManifestOnlyJar;
+    private final boolean useSystemClassLoader;
 
-    private File tempDirectory;
+    private final boolean useManifestOnlyJar;
 
-    private boolean debug;
-
-    public void setForkMode( String forkMode )
+    public ForkConfiguration( boolean useSystemClassLoader, boolean 
useManifestOnlyJar, String forkMode )
     {
-        if ( "pertest".equalsIgnoreCase( forkMode ) )
-        {
-            this.forkMode = FORK_ALWAYS;
-        }
-        else if ( "none".equalsIgnoreCase( forkMode ) )
-        {
-            this.forkMode = FORK_NEVER;
-        }
-        else if ( forkMode.equals( FORK_NEVER ) || forkMode.equals( FORK_ONCE 
) || forkMode.equals( FORK_ALWAYS ) )
-        {
-            this.forkMode = forkMode;
-        }
-        else
-        {
-            throw new IllegalArgumentException( "Fork mode " + forkMode + " is 
not a legal value" );
-        }
+        this.useSystemClassLoader = useSystemClassLoader;
+        this.useManifestOnlyJar = useManifestOnlyJar;
+        this.forkMode = forkMode;
     }
 
     public boolean isForking()
@@ -70,49 +47,14 @@ public class ForkConfiguration
         return !FORK_NEVER.equals( forkMode );
     }
 
-    public void setUseSystemClassLoader( boolean useSystemClassLoader )
-    {
-        this.useSystemClassLoader = useSystemClassLoader;
-    }
-
     public boolean isUseSystemClassLoader()
     {
         return useSystemClassLoader;
     }
 
-    public void setTempDirectory( File tempDirectory )
-    {
-        this.tempDirectory = tempDirectory;
-    }
-
-    public File getTempDirectory()
-    {
-        return tempDirectory;
-    }
-
-    public void setDebug( boolean debug )
-    {
-        this.debug = debug;
-    }
-
-    public boolean isDebug()
-    {
-        return debug;
-    }
-
-    public void setUseManifestOnlyJar( boolean useManifestOnlyJar )
-    {
-        this.useManifestOnlyJar = useManifestOnlyJar;
-    }
-
-    public boolean isUseManifestOnlyJar()
-    {
-        return useManifestOnlyJar;
-    }
-
     public boolean isManifestOnlyJarRequestedAndUsable()
     {
-        return isUseSystemClassLoader() && isUseManifestOnlyJar();
+        return isUseSystemClassLoader() && useManifestOnlyJar;
     }
 
 }

Modified: 
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=1036402&r1=1036401&r2=1036402&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterSerializerTest.java
 (original)
+++ 
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/BooterSerializerTest.java
 Thu Nov 18 11:03:03 2010
@@ -37,7 +37,7 @@ public class BooterSerializerTest
     public static ForkConfiguration getForkConfiguration()
         throws IOException
     {
-        return new ForkConfiguration();
+        return new ForkConfiguration( true, false, 
ForkConfiguration.FORK_NEVER );
     }
 
     public void testDirectoryScannerParams()
@@ -58,7 +58,7 @@ public class BooterSerializerTest
         booterConfiguration.setDirectoryScannerOptions( aDir, includes, 
excludes );
         Properties props = new Properties();
         booterSerializer.setForkProperties( props, new ArrayList(), 
booterConfiguration, forkConfiguration );
-        final File propsTest = booterSerializer.writePropertiesFile( 
"propsTest", props, forkConfiguration );
+        final File propsTest = booterSerializer.writePropertiesFile( 
"propsTest", props, false, null );
 
         BooterConfiguration read = booterSerializer.deserialize( new 
FileInputStream( propsTest ) );
 


Reply via email to