maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r356674 - in /maven/surefire/trunk: surefire-booter/src/main/java/org/apache/maven/surefire/ surefire/src/main/java/org/apache/maven/surefire/
Date Wed, 14 Dec 2005 01:24:03 GMT
Author: jvanzyl
Date: Tue Dec 13 17:23:54 2005
New Revision: 356674

URL: http://svn.apache.org/viewcvs?rev=356674&view=rev
Log:
o allow the specificication of childDelegation in the classloader used for running the tests.
the
  default is to use child delegation but it can now be turned off which fixes MNG-1303
o allow a debug mode in the surefire booter so the command line can be viewed when forking

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

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/IsolatedClassLoader.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/IsolatedClassLoader.java?rev=356674&r1=356673&r2=356674&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/IsolatedClassLoader.java
(original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/IsolatedClassLoader.java
Tue Dec 13 17:23:54 2005
@@ -28,11 +28,20 @@
 
     private Set urls = new HashSet();
 
+    private boolean childDelegation = true;
+
     public IsolatedClassLoader()
     {
         super( new URL[0], null );
     }
 
+    public IsolatedClassLoader( ClassLoader parent, boolean childDelegation )
+    {
+        super( new URL[0], parent );
+
+        this.childDelegation = childDelegation;
+    }
+
     public IsolatedClassLoader( ClassLoader parent )
     {
         super( new URL[0], parent );
@@ -53,30 +62,39 @@
     public synchronized Class loadClass( String className )
         throws ClassNotFoundException
     {
-        Class c = findLoadedClass( className );
-
-        ClassNotFoundException ex = null;
+        Class c;
 
-        if ( c == null )
+        if( childDelegation )
         {
-            try
-            {
-                c = findClass( className );
-            }
-            catch ( ClassNotFoundException e )
-            {
-                ex = e;
+            c = findLoadedClass( className );
 
-                if ( parent != null )
+            ClassNotFoundException ex = null;
+
+            if ( c == null )
+            {
+                try
                 {
-                    c = parent.loadClass( className );
+                    c = findClass( className );
+                }
+                catch ( ClassNotFoundException e )
+                {
+                    ex = e;
+
+                    if ( parent != null )
+                    {
+                        c = parent.loadClass( className );
+                    }
                 }
             }
-        }
 
-        if ( c == null )
+            if ( c == null )
+            {
+                throw ex;
+            }
+        }
+        else
         {
-            throw ex;
+            c = super.loadClass( className );
         }
 
         return c;

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=356674&r1=356673&r2=356674&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
Tue Dec 13 17:23:54 2005
@@ -72,6 +72,10 @@
 
     private String argLine;
 
+    private boolean childDelegation;
+
+    private boolean debug;
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -167,6 +171,16 @@
         this.basedir = basedir;
     }
 
+    public void setChildDelegation( boolean childDelegation )
+    {
+        this.childDelegation = childDelegation;
+    }
+
+    public void setDebug( boolean debug )
+    {
+        this.debug = debug;
+    }
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -195,7 +209,7 @@
     private IsolatedClassLoader createClassLoader()
         throws Exception
     {
-        IsolatedClassLoader surefireClassLoader = new IsolatedClassLoader( ClassLoader.getSystemClassLoader()
);
+        IsolatedClassLoader surefireClassLoader = new IsolatedClassLoader( ClassLoader.getSystemClassLoader(),
childDelegation );
 
         for ( Iterator i = classpathUrls.iterator(); i.hasNext(); )
         {
@@ -290,7 +304,10 @@
 
         cli.createArgument().setValue( basedir );
 
-        System.out.println( Commandline.toString( cli.getCommandline() ) );
+        if ( debug )
+        {
+            System.out.println( Commandline.toString( cli.getCommandline() ) );
+        }
 
         Writer stringWriter = new StringWriter();
 
@@ -449,16 +466,6 @@
         reports.clear();
 
         classpathUrls.clear();
-    }
-
-    private String quotedPathArgument( String value )
-    {
-        if ( !StringUtils.isEmpty( value ) )
-        {
-            return "'" + value.replace( '\\', '/' ) + "'";
-        }
-
-        return value;
     }
 
     private String getListOfStringsAsString ( List listOfStrings, String delimiterParm )

Modified: maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/Surefire.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/Surefire.java?rev=356674&r1=356673&r2=356674&view=diff
==============================================================================
--- maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/Surefire.java (original)
+++ maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/Surefire.java Tue
Dec 13 17:23:54 2005
@@ -29,6 +29,10 @@
 import java.util.List;
 import java.util.ResourceBundle;
 
+/**
+ * @uathor Jason van Zyl
+ * @version $Id:$
+ */
 public class Surefire
 {
     private static ResourceBundle resources = ResourceBundle.getBundle( "org.apache.maven.surefire.surefire"
);



Mime
View raw message