Author: fgiust
Date: Sun Sep  3 07:31:41 2006
New Revision: 439783

URL: http://svn.apache.org/viewvc?rev=439783&view=rev
Log:
see SUREFIRE-54
reverting the change that removed the System classloader during tests. This 
broke the TestNG support, we will have to reapply this patch when a solution 
for TestNG is found.

Modified:
    
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/SurefireBooter.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java?rev=439783&r1=439782&r2=439783&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
 Sun Sep  3 07:31:41 2006
@@ -204,7 +204,7 @@
             ClassLoader surefireClassLoader =
                 createClassLoader( surefireClassPathUrls, 
getClass().getClassLoader(), true );
 
-            ClassLoader testsClassLoader = createClassLoader( classPathUrls, 
null, childDelegation, true );
+            ClassLoader testsClassLoader = getTestClassLoader( childDelegation 
);
 
             Class surefireClass = surefireClassLoader.loadClass( 
Surefire.class.getName() );
 
@@ -247,7 +247,7 @@
         {
             // The test classloader must be constructed first to avoid issues 
with commons-logging until we properly
             // separate the TestNG classloader
-            ClassLoader testsClassLoader = createClassLoader( classPathUrls, 
null, childDelegation, true );
+            ClassLoader testsClassLoader = getTestClassLoader( childDelegation 
);
 
             ClassLoader surefireClassLoader =
                 createClassLoader( surefireClassPathUrls, 
getClass().getClassLoader(), true );
@@ -294,7 +294,7 @@
         ClassLoader surefireClassLoader;
         try
         {
-            testsClassLoader = createClassLoader( classPathUrls, null, false, 
true );
+            testsClassLoader = getTestClassLoader( false );
             // TODO: assertions = true shouldn't be required if we had proper 
separation (see TestNG)
             surefireClassLoader = createClassLoader( surefireClassPathUrls, 
false, true );
         }
@@ -552,6 +552,21 @@
         }
 
         return returnCode == 0;
+    }
+
+    /**
+     * This method actually calls <code>createClassLoader( classPathUrls, 
ClassLoader.getSystemClassLoader(), 
+     * childDelegation, true );</code> and it's here to handle the use of a 
parent classloader consistently.
+     */
+    private ClassLoader getTestClassLoader( boolean childDelegation )
+        throws MalformedURLException
+    {
+        // warning, parent should probably be set to null, but at this moment 
this totally breaks TestNG
+        // Comment from Kenney:
+        // If this is not done, the System classloader is added, in this case 
an AppClassloader containing everything in
+        // the root classpath. For instance, in maven, everything in core/ is 
available.This can cause clashes with the
+        // plexus-utils used in maven itself.
+        return createClassLoader( classPathUrls, 
ClassLoader.getSystemClassLoader(), childDelegation, true );
     }
 
     private static ClassLoader createClassLoader( List classPathUrls, 
ClassLoader parent, boolean assertionsEnabled )


Reply via email to