maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ken...@apache.org
Subject svn commit: r544132 - in /maven/surefire/trunk: maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/ surefire-booter/src/main/java/org/apache/maven/surefire/booter/
Date Mon, 04 Jun 2007 11:51:08 GMT
Author: kenney
Date: Mon Jun  4 04:51:07 2007
New Revision: 544132

URL: http://svn.apache.org/viewvc?view=rev&rev=544132
Log:
Moved useSystemClassLoader to ForkConfiguration;
isUseSystemClassLoader only returns true if forkconfig is forking.

Modified:
    maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
    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/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?view=diff&rev=544132&r1=544131&r2=544132
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
(original)
+++ maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Mon Jun  4 04:51:07 2007
@@ -378,7 +378,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;
 
@@ -491,7 +491,7 @@
             throw new MojoExecutionException( "Unable to locate surefire-booter in the list
of plugin artifacts" );
         }
 
-        surefireArtifact.isSnapshot(); // TODO: this is ridiculous, but it fixes getBaseVersion
to be -SNAPSHOT if needed
+        //surefireArtifact.isSnapshot(); // TODO: this is ridiculous, but it fixes getBaseVersion
to be -SNAPSHOT if needed
 
         Artifact junitArtifact;
         Artifact testNgArtifact;
@@ -666,6 +666,8 @@
 
         if ( fork.isForking() )
         {
+            fork.setUseSystemClassLoader( useSystemClassLoader );
+
             fork.setSystemProperties( systemProperties );
 
             if ( jvm == null || "".equals( jvm ) )
@@ -705,8 +707,6 @@
         surefireBooter.setChildDelegation( childDelegation );
 
         surefireBooter.setReportsDirectory( reportsDirectory );
-
-        surefireBooter.setUseSystemClassLoader( useSystemClassLoader );
 
         addReporters( surefireBooter, fork.isForking() );
 

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=544132&r1=544131&r2=544132
==============================================================================
--- 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
Mon Jun  4 04:51:07 2007
@@ -51,6 +51,8 @@
 
     private String forkMode;
 
+    private boolean useSystemClassLoader;
+
     private Properties systemProperties;
 
     private String jvmExecutable;
@@ -86,6 +88,16 @@
     public boolean isForking()
     {
         return !FORK_NEVER.equals( forkMode );
+    }
+
+    public void setUseSystemClassLoader( boolean useSystemClassLoader )
+    {
+        useSystemClassLoader= useSystemClassLoader;
+    }
+
+    public boolean isUseSystemClassLoader()
+    {
+        return useSystemClassLoader && isForking();
     }
 
     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=544132&r1=544131&r2=544132
==============================================================================
--- 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
Mon Jun  4 04:51:07 2007
@@ -72,8 +72,6 @@
 
     private boolean redirectTestOutputToFile = false;
 
-    private boolean useSystemClassLoader = false;
-
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -184,11 +182,6 @@
         this.forkConfiguration = forkConfiguration;
     }
 
-    public void setUseSystemClassLoader( boolean useSystemClassLoader )
-    {
-        this.useSystemClassLoader = useSystemClassLoader;
-    }
-
     public boolean run()
         throws SurefireBooterForkException, SurefireExecutionException
     {
@@ -227,7 +220,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)
@@ -274,7 +267,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 );
@@ -429,7 +422,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 );
@@ -442,7 +435,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 )
@@ -546,12 +539,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 );
 
@@ -796,6 +789,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();
@@ -835,8 +832,8 @@
                 }
                 else if ( "useSystemClassLoader".equals( name ) )
                 {
-                    surefireBooter.useSystemClassLoader =
-                        Boolean.valueOf( p.getProperty( "useSystemClassLoader" ) ).booleanValue();
+                    surefireBooter.forkConfiguration.setUseSystemClassLoader(
+                        Boolean.valueOf( p.getProperty( "useSystemClassLoader" ) ).booleanValue()
);
                 }
             }
 



Mime
View raw message