You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by ke...@apache.org on 2007/06/05 19:36:09 UTC
svn commit: r544570 - in
/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter:
ForkConfiguration.java SurefireBooter.java
Author: kenney
Date: Tue Jun 5 10:36:09 2007
New Revision: 544570
URL: http://svn.apache.org/viewvc?view=rev&rev=544570
Log:
Fixed assignment - did this on commandline so didn't notice I was assigning to a parameter.
Fix useSystemCL - make distinction between when forking and when forked. When forked,
forkmode 'never', and useSystemCl always returned false.
TODO: write some tests for this
Modified:
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
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?view=diff&rev=544570&r1=544569&r2=544570
==============================================================================
--- 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 Tue Jun 5 10:36:09 2007
@@ -92,12 +92,12 @@
public void setUseSystemClassLoader( boolean useSystemClassLoader )
{
- useSystemClassLoader= useSystemClassLoader;
+ this.useSystemClassLoader = useSystemClassLoader;
}
public boolean isUseSystemClassLoader()
{
- return useSystemClassLoader && isForking();
+ return useSystemClassLoader;
}
public void setSystemProperties( Properties systemProperties )
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?view=diff&rev=544570&r1=544569&r2=544570
==============================================================================
--- 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 Jun 5 10:36:09 2007
@@ -91,6 +91,12 @@
private File reportsDirectory;
+ /**
+ * This field is set to true if it's running from main.
+ * It's used to help decide what classloader to use.
+ */
+ private final boolean isForked;
+
static
{
try
@@ -104,6 +110,16 @@
}
}
+ public SurefireBooter()
+ {
+ isForked = false;
+ }
+
+ private SurefireBooter( boolean isForked )
+ {
+ this.isForked = isForked;
+ }
+
// ----------------------------------------------------------------------
// Accessors
// ----------------------------------------------------------------------
@@ -220,7 +236,7 @@
ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
try
{
- ClassLoader testsClassLoader = forkConfiguration.isUseSystemClassLoader() ? ClassLoader.getSystemClassLoader()
+ ClassLoader testsClassLoader = useSystemClassLoader() ? ClassLoader.getSystemClassLoader()
: createClassLoader( classPathUrls, null, childDelegation, true );
// TODO: assertions = true shouldn't be required for this CL if we had proper separation (see TestNG)
@@ -267,7 +283,7 @@
// The test classloader must be constructed first to avoid issues with commons-logging until we properly
// separate the TestNG classloader
ClassLoader testsClassLoader =
- forkConfiguration.isUseSystemClassLoader() ? getClass().getClassLoader()//ClassLoader.getSystemClassLoader()
+ useSystemClassLoader() ? getClass().getClassLoader() // ClassLoader.getSystemClassLoader()
: createClassLoader( classPathUrls, null, childDelegation, true );
ClassLoader surefireClassLoader = createClassLoader( surefireClassPathUrls, testsClassLoader, true );
@@ -422,7 +438,7 @@
addPropertiesForTypeHolder( reports, properties, "report." );
addPropertiesForTypeHolder( testSuites, properties, "testSuite." );
- for ( int i = 0; i < classPathUrls.size() && !forkConfiguration.isUseSystemClassLoader(); i++ )
+ for ( int i = 0; i < classPathUrls.size() && useSystemClassLoader(); i++ )
{
String url = (String) classPathUrls.get( i );
properties.setProperty( "classPathUrl." + i, url );
@@ -435,7 +451,7 @@
}
properties.setProperty( "childDelegation", String.valueOf( childDelegation ) );
- properties.setProperty( "useSystemClassLoader", String.valueOf( forkConfiguration.isUseSystemClassLoader() ) );
+ properties.setProperty( "useSystemClassLoader", String.valueOf( useSystemClassLoader() ) );
}
private File writePropertiesFile( String name, Properties properties )
@@ -517,6 +533,12 @@
}
}
+ private final boolean useSystemClassLoader()
+ {
+ return forkConfiguration.isUseSystemClassLoader() &&
+ ( isForked || forkConfiguration.isForking() );
+ }
+
private boolean fork( Properties properties, boolean showHeading, boolean showFooter )
throws SurefireBooterForkException
{
@@ -539,12 +561,12 @@
bootClasspath.addAll( surefireBootClassPathUrls );
- if ( forkConfiguration.isUseSystemClassLoader() )
+ if ( useSystemClassLoader() )
{
bootClasspath.addAll( classPathUrls );
}
- Commandline cli = forkConfiguration.createCommandLine( bootClasspath, forkConfiguration.isUseSystemClassLoader() );
+ Commandline cli = forkConfiguration.createCommandLine( bootClasspath, useSystemClassLoader() );
cli.createArgument().setFile( surefireProperties );
@@ -787,7 +809,7 @@
File surefirePropertiesFile = new File( args[0] );
Properties p = loadProperties( surefirePropertiesFile );
- SurefireBooter surefireBooter = new SurefireBooter();
+ SurefireBooter surefireBooter = new SurefireBooter( true );
ForkConfiguration forkConfiguration = new ForkConfiguration();
forkConfiguration.setForkMode( "never" );
@@ -890,5 +912,4 @@
return new ForkingStreamConsumer( outputConsumer );
}
}
-