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/04 14:18:06 UTC

svn commit: r544140 - in /maven/surefire/branches/surefire-2.3.x: maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/ surefire-booter/src/main/java/org/apache/maven/surefire/booter/

Author: kenney
Date: Mon Jun  4 05:18:05 2007
New Revision: 544140

URL: http://svn.apache.org/viewvc?view=rev&rev=544140
Log:
Merged revisions r543422, r544132, r544136 from https://svn.apache.org/repos/asf/maven/surefire/trunk:

	------------------------------------------------------------------------
	r544136 | kenney | 2007-06-04 14:08:04 +0200 (Mon, 04 Jun 2007) | 1 line
	Changed paths:
	   M /maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java

	revert comment out - accidently committed it
	------------------------------------------------------------------------
	r544132 | kenney | 2007-06-04 13:51:07 +0200 (Mon, 04 Jun 2007) | 3 lines
	Changed paths:
	   M /maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
	   M /maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
	   M /maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java

	Moved useSystemClassLoader to ForkConfiguration;
	isUseSystemClassLoader only returns true if forkconfig is forking.

	------------------------------------------------------------------------
	r543888 | kenney | 2007-06-03 15:03:29 +0200 (Sun, 03 Jun 2007) | 1 line
	Changed paths:
	   M /maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java

	Added note: class-path entries that are directories MUST end in a / - this is no longer explicit in this code.



Modified:
    maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
    maven/surefire/branches/surefire-2.3.x/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
    maven/surefire/branches/surefire-2.3.x/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java

Modified: maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewvc/maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?view=diff&rev=544140&r1=544139&r2=544140
==============================================================================
--- maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java (original)
+++ maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java Mon Jun  4 05:18:05 2007
@@ -379,7 +379,7 @@
      * forking. Prevents problems with JDKs which implement the service provider lookup mechanism by using
      * the system's classloader.
      *
-     * @parameter expression="${surefire.useSystemClassLoader}" default-value="true"
+     * @parameter expression="${surefire.useSystemClassLoader}" default-value="false"
      */
     private boolean useSystemClassLoader;
 
@@ -641,6 +641,8 @@
 
         if ( fork.isForking() )
         {
+            fork.setUseSystemClassLoader( useSystemClassLoader );
+
             fork.setSystemProperties( systemProperties );
 
             if ( jvm == null || "".equals( jvm ) )
@@ -680,8 +682,6 @@
         surefireBooter.setChildDelegation( childDelegation );
 
         surefireBooter.setReportsDirectory( reportsDirectory );
-
-        surefireBooter.setUseSystemClassLoader( useSystemClassLoader );
 
         addReporters( surefireBooter, fork.isForking() );
 

Modified: maven/surefire/branches/surefire-2.3.x/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/branches/surefire-2.3.x/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java?view=diff&rev=544140&r1=544139&r2=544140
==============================================================================
--- maven/surefire/branches/surefire-2.3.x/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java (original)
+++ maven/surefire/branches/surefire-2.3.x/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java Mon Jun  4 05:18:05 2007
@@ -50,6 +50,8 @@
 
     private String forkMode;
 
+    private boolean useSystemClassLoader;
+
     private Properties systemProperties;
 
     private String jvmExecutable;
@@ -87,6 +89,16 @@
         return !FORK_NEVER.equals( forkMode );
     }
 
+    public void setUseSystemClassLoader( boolean useSystemClassLoader )
+    {
+        useSystemClassLoader= useSystemClassLoader;
+    }
+
+    public boolean isUseSystemClassLoader()
+    {
+        return useSystemClassLoader && isForking();
+    }
+
     public void setSystemProperties( Properties systemProperties )
     {
         this.systemProperties = (Properties) systemProperties.clone();
@@ -229,6 +241,7 @@
         for ( Iterator it = classPath.iterator(); it.hasNext(); )
         {
             String el = (String) it.next();
+            // NOTE: if File points to a directory, this entry MUST end in '/'.
             cp += UrlUtils.getURL( new File( el ) ).toExternalForm() + " ";
         }
 

Modified: maven/surefire/branches/surefire-2.3.x/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
URL: http://svn.apache.org/viewvc/maven/surefire/branches/surefire-2.3.x/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java?view=diff&rev=544140&r1=544139&r2=544140
==============================================================================
--- maven/surefire/branches/surefire-2.3.x/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java (original)
+++ maven/surefire/branches/surefire-2.3.x/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java Mon Jun  4 05:18:05 2007
@@ -71,8 +71,6 @@
 
     private boolean redirectTestOutputToFile = false;
 
-    private boolean useSystemClassLoader = false;
-
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -183,11 +181,6 @@
         this.forkConfiguration = forkConfiguration;
     }
 
-    public void setUseSystemClassLoader( boolean useSystemClassLoader )
-    {
-        this.useSystemClassLoader = useSystemClassLoader;
-    }
-
     public boolean run()
         throws SurefireBooterForkException, SurefireExecutionException
     {
@@ -226,7 +219,7 @@
         ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
         try
         {
-            ClassLoader testsClassLoader = useSystemClassLoader ? ClassLoader.getSystemClassLoader()
+            ClassLoader testsClassLoader = forkConfiguration.isUseSystemClassLoader() ? ClassLoader.getSystemClassLoader()
                 : createClassLoader( classPathUrls, null, childDelegation, true );
 
             // TODO: assertions = true shouldn't be required for this CL if we had proper separation (see TestNG)
@@ -273,7 +266,7 @@
             // The test classloader must be constructed first to avoid issues with commons-logging until we properly
             // separate the TestNG classloader
             ClassLoader testsClassLoader =
-                useSystemClassLoader ? getClass().getClassLoader()//ClassLoader.getSystemClassLoader()
+                forkConfiguration.isUseSystemClassLoader() ? getClass().getClassLoader()//ClassLoader.getSystemClassLoader()
                     : createClassLoader( classPathUrls, null, childDelegation, true );
 
             ClassLoader surefireClassLoader = createClassLoader( surefireClassPathUrls, testsClassLoader, true );
@@ -428,7 +421,7 @@
         addPropertiesForTypeHolder( reports, properties, "report." );
         addPropertiesForTypeHolder( testSuites, properties, "testSuite." );
 
-        for ( int i = 0; i < classPathUrls.size() && !useSystemClassLoader; i++ )
+        for ( int i = 0; i < classPathUrls.size() && !forkConfiguration.isUseSystemClassLoader(); i++ )
         {
             String url = (String) classPathUrls.get( i );
             properties.setProperty( "classPathUrl." + i, url );
@@ -441,7 +434,7 @@
         }
 
         properties.setProperty( "childDelegation", String.valueOf( childDelegation ) );
-        properties.setProperty( "useSystemClassLoader", String.valueOf( useSystemClassLoader ) );
+        properties.setProperty( "useSystemClassLoader", String.valueOf( forkConfiguration.isUseSystemClassLoader() ) );
     }
 
     private File writePropertiesFile( String name, Properties properties )
@@ -523,12 +516,12 @@
 
         bootClasspath.addAll( surefireBootClassPathUrls );
 
-        if ( useSystemClassLoader )
+        if ( forkConfiguration.isUseSystemClassLoader() )
         {
             bootClasspath.addAll( classPathUrls );
         }
 
-        Commandline cli = forkConfiguration.createCommandLine( bootClasspath, useSystemClassLoader );
+        Commandline cli = forkConfiguration.createCommandLine( bootClasspath, forkConfiguration.isUseSystemClassLoader() );
 
         cli.createArgument().setFile( surefireProperties );
 
@@ -763,6 +756,10 @@
 
             SurefireBooter surefireBooter = new SurefireBooter();
 
+            ForkConfiguration forkConfiguration = new ForkConfiguration();
+            forkConfiguration.setForkMode( "never" );
+            surefireBooter.setForkConfiguration( forkConfiguration );
+
             for ( Enumeration e = p.propertyNames(); e.hasMoreElements(); )
             {
                 String name = (String) e.nextElement();
@@ -802,8 +799,8 @@
                 }
                 else if ( "useSystemClassLoader".equals( name ) )
                 {
-                    surefireBooter.useSystemClassLoader =
-                        Boolean.valueOf( p.getProperty( "useSystemClassLoader" ) ).booleanValue();
+                    surefireBooter.forkConfiguration.setUseSystemClassLoader(
+                        Boolean.valueOf( p.getProperty( "useSystemClassLoader" ) ).booleanValue() );
                 }
             }