maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r355984 - in /maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire: ForkedSurefireRunner.java SurefireBooter.java
Date Sun, 11 Dec 2005 18:01:06 GMT
Author: jvanzyl
Date: Sun Dec 11 10:01:03 2005
New Revision: 355984

URL: http://svn.apache.org/viewcvs?rev=355984&view=rev
Log:
o adding system property handling

Modified:
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/ForkedSurefireRunner.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/ForkedSurefireRunner.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/ForkedSurefireRunner.java?rev=355984&r1=355983&r2=355984&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/ForkedSurefireRunner.java
(original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/ForkedSurefireRunner.java
Sun Dec 11 10:01:03 2005
@@ -68,6 +68,9 @@
             String[] mapArgs = args[i].split( "=" );
 
             argMap.put( mapArgs[0], mapArgs[1] );
+
+            System.out.println( "mapArgs[0] = " + mapArgs[0] );
+            System.out.println( "mapArgs[1] = " + mapArgs[1] );
         }
 
         return argMap;

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java?rev=355984&r1=355983&r2=355984&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java
(original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java
Sun Dec 11 10:01:03 2005
@@ -29,9 +29,13 @@
 import java.io.StringWriter;
 import java.io.Writer;
 import java.lang.reflect.Method;
+import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Properties;
+import java.util.Enumeration;
+import java.util.Arrays;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -64,6 +68,8 @@
 
     private String jvm;
 
+    private Properties systemProperties;
+
     private String argLine;
 
     // ----------------------------------------------------------------------
@@ -122,6 +128,11 @@
         this.jvm = jvm;
     }
 
+    public void setSystemProperties( Properties systemProperties )
+    {
+        this.systemProperties = systemProperties;
+    }
+
     public void setArgLine( String argLine )
     {
         this.argLine = argLine;
@@ -239,14 +250,7 @@
 
         cli.addArguments( args );
 
-        String[] s = cli.getShellCommandline();
-
-        for ( int i = 0; i < s.length; i++ )
-        {
-            System.out.println( s[i] + " " );
-        }
-
-        System.out.println();
+        System.out.println( Commandline.toString( cli.getCommandline() ) );
 
         Writer stringWriter = new StringWriter();
 
@@ -262,10 +266,14 @@
         }
         catch ( CommandLineException e )
         {
+            e.printStackTrace();
+
             throw new Exception( "Error while executing forked tests.", e );
         }
         catch ( Exception e )
         {
+            e.printStackTrace();
+
             throw new SurefireBooterForkException( "Error while executing forked tests.",
e );
         }
 
@@ -333,23 +341,52 @@
     private String[] getForkArgs( String batteryConfig )
         throws Exception
     {
-        //String classpathEntries =  quotedPathArgument( makeClasspath( classpathUrls ) );
+        String reportClassNames = getListOfStringsAsString( reports, "," );
 
-        String classpathEntries =  makeClasspath( classpathUrls );
+        String classpathEntries = makeClasspath( classpathUrls );
 
-        String reportClassNames = getListOfStringsAsString( reports, "," );
+        List args = new ArrayList();
 
-        return new String[]
+        args.add( "-classpath" );
+
+        args.add( classpathEntries );
+
+        // ----------------------------------------------------------------------
+        // Add some system propeties
+        // ----------------------------------------------------------------------
+
+        if ( systemProperties != null )
+        {
+            Enumeration propertyKeys = systemProperties.propertyNames();
+
+            while ( propertyKeys.hasMoreElements() )
             {
-                "-classpath",
-                classpathEntries,
-                RUNNER,
-                "reportClassNames=" + reportClassNames,
-                "reportsDirectory=" + reportsDirectory,
-                "batteryExecutorName=" + BATTERY_EXECUTOR,
-                "forkMode=" + forkMode,
-                "batteryConfig=" + batteryConfig
-            };
+                String key = (String) propertyKeys.nextElement();
+
+                args.add( "-D" + key + "=" + systemProperties.getProperty( key ) );
+            }
+        }
+
+        args.add( RUNNER );
+
+        args.add( "reportClassNames=" + reportClassNames );
+
+        args.add( "reportsDirectory=" + reportsDirectory );
+
+        args.add( "batteryExecutorName=" + BATTERY_EXECUTOR );
+
+        args.add( "forkMode=" + forkMode );
+
+        args.add( "batteryConfig=" + batteryConfig );
+
+        String[] s = new String[args.size()];
+
+        for ( int i = 0; i < s.length; i++ )
+        {
+            s[i] = (String) args.get( i );
+        }
+
+        return s;
     }
 
     public void reset()
@@ -387,7 +424,7 @@
         return value;
     }
 
-    private String getListOfStringsAsString( List listOfStrings, String delimiterParm )
+    private String getListOfStringsAsString ( List listOfStrings, String delimiterParm )
     {
         StringBuffer stringBuffer = new StringBuffer();
 



Mime
View raw message