Author: brett
Date: Tue Nov 13 14:57:19 2007
New Revision: 594690
URL: http://svn.apache.org/viewvc?rev=594690&view=rev
Log:
[SUREFIRE-316] fix problems with properties being passed on to forked instances
Submitted by: Marat Radchenko
Modified:
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
Modified:
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java?rev=594690&r1=594689&r2=594690&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
(original)
+++
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
Tue Nov 13 14:57:19 2007
@@ -178,7 +178,7 @@
/**
* When forking, setting this to true will make the test output to be
saved in a file instead of showing it on the
* standard output
- *
+ *
* @param redirectTestOutputToFile
*/
public void setRedirectTestOutputToFile( boolean redirectTestOutputToFile )
@@ -188,7 +188,7 @@
/**
* Set the directory where reports will be saved
- *
+ *
* @param reportsDirectory the directory
*/
public void setReportsDirectory( File reportsDirectory )
@@ -804,6 +804,19 @@
{
paramObjects[i] = Integer.valueOf( params[i] );
}
+ else if (types[i].equals(Properties.class.getName())) {
+ final Properties result = new Properties();
+ final String value = params[i];
+ if (!value.startsWith("{") || !value.endsWith("}")) {
+ throw new IllegalArgumentException("Invalid input " +
value);
+ }
+ final String[] pairs = value.substring(1, value.length() -
1).split(", ");
+ for (int j = 0; j < pairs.length; j++) {
+ final String[] pair = pairs[j].split("=");
+ result.put(pair[0], pair[1]);
+ }
+ paramObjects[i] = result;
+ }
else
{
// TODO: could attempt to construct with a String
constructor if needed
@@ -817,7 +830,7 @@
/**
* This method is invoked when Surefire is forked - this method parses and
organizes the arguments passed to it and
* then calls the Surefire class' run method. <p/> The system exit code
will be 1 if an exception is thrown.
- *
+ *
* @param args
*/
public static void main( String[] args )
@@ -833,9 +846,9 @@
File surefirePropertiesFile = new File( args[0] );
Properties p = loadProperties( surefirePropertiesFile );
-
+
SortedMap classPathUrls = new TreeMap();
-
+
SortedMap surefireClassPathUrls = new TreeMap();
SurefireBooter surefireBooter = new SurefireBooter( true );
@@ -892,19 +905,18 @@
p.getProperty( "useSystemClassLoader" ) ).booleanValue() );
}
}
-
- for (Iterator cpi = classPathUrls.keySet().iterator();
cpi.hasNext();)
+
+ for (Iterator cpi = classPathUrls.keySet().iterator();
cpi.hasNext();)
{
String url = (String) classPathUrls.get(cpi.next());
surefireBooter.addClassPathUrl(url);
}
- for (Iterator scpi = surefireClassPathUrls.keySet().iterator();
scpi.hasNext();)
+ for (Iterator scpi = surefireClassPathUrls.keySet().iterator();
scpi.hasNext();)
{
String url = (String) surefireClassPathUrls.get(scpi.next());
surefireBooter.addSurefireClassPathUrl(url);
}
-
String testSet = p.getProperty( "testSet" );
boolean result;
Modified:
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java?rev=594690&r1=594689&r2=594690&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
(original)
+++
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
Tue Nov 13 14:57:19 2007
@@ -20,6 +20,7 @@
*/
import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.ReporterManager;
import org.apache.maven.surefire.suite.AbstractDirectoryTestSuite;
@@ -27,9 +28,11 @@
import org.apache.maven.surefire.testset.TestSetFailedException;
import java.io.File;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
/**
* Test suite for TestNG based on a directory of Java test classes. Can also
execute JUnit tests.
@@ -45,6 +48,13 @@
private Map options;
private String testSourceDirectory;
+
+ public TestNGDirectoryTestSuite( File basedir, ArrayList includes,
ArrayList excludes, String testSourceDirectory,
+ String artifactVersion, Properties
confOptions )
+ {
+ this( basedir, includes, excludes, testSourceDirectory, new
DefaultArtifactVersion( artifactVersion ),
+ confOptions );
+ }
public TestNGDirectoryTestSuite( File basedir, List includes, List
excludes, String testSourceDirectory,
ArtifactVersion artifactVersion, Map
confOptions )