Author: brett
Date: Sun Apr 30 19:29:46 2006
New Revision: 398505

URL: http://svn.apache.org/viewcvs?rev=398505&view=rev
Log:
[SUREFIRE-35] fix assertion enablement in the 4 available class loading 
scenarios

Modified:
    
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
    
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java

Modified: 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
URL: 
http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java?rev=398505&r1=398504&r2=398505&view=diff
==============================================================================
--- 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
 (original)
+++ 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkConfiguration.java
 Sun Apr 30 19:29:46 2006
@@ -141,12 +141,6 @@
             }
         }
 
-        // TODO: This shouldn't be required. See SurefireBooter, 
createClassLoader where assertion status should be set
-        // probably required in JDK 1.3
-/*
-        cli.createArgument().setValue( "-ea" );
-*/
-
         cli.createArgument().setValue( "-classpath" );
 
         cli.createArgument().setValue( StringUtils.join( classPath.iterator(), 
File.pathSeparator ) );

Modified: 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
URL: 
http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java?rev=398505&r1=398504&r2=398505&view=diff
==============================================================================
--- 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
 (original)
+++ 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
 Sun Apr 30 19:29:46 2006
@@ -68,6 +68,21 @@
 
     private static final int TESTS_FAILED_EXIT_CODE = 255;
 
+    private static boolean assertionsAvailable;
+
+    static
+    {
+        try
+        {
+            ClassLoader.class.getMethod( "setDefaultAssertionStatus", new 
Class[]{boolean.class} );
+            assertionsAvailable = true;
+        }
+        catch ( NoSuchMethodException e )
+        {
+            assertionsAvailable = false;
+        }
+    }
+
     // ----------------------------------------------------------------------
     // Accessors
     // ----------------------------------------------------------------------
@@ -517,10 +532,11 @@
         }
 
         IsolatedClassLoader classLoader = new IsolatedClassLoader( parent, 
childDelegation );
-        // TODO: for some reason, this doesn't work when forked. -ea is added 
to the command line as a workaround
-        // in forkConfiguration
-        // TODO: not available under JDK 1.3
-        //classLoader.setDefaultAssertionStatus( assertionsEnabled );
+        if ( assertionsAvailable )
+        {
+            parent.setDefaultAssertionStatus( assertionsEnabled );
+            classLoader.setDefaultAssertionStatus( assertionsEnabled );
+        }
         for ( Iterator iter = urls.iterator(); iter.hasNext(); )
         {
             URL url = (URL) iter.next();
@@ -528,7 +544,6 @@
         }
         return classLoader;
     }
-
 
     private static List processStringList( String stringList )
     {


Reply via email to