Author: carlos
Date: Wed Apr  5 17:24:03 2006
New Revision: 391865

URL: http://svn.apache.org/viewcvs?rev=391865&view=rev
Log:
[MSUREFIRE-86] Make surefire compile under Java 1.3, merged in r391731, 
r391781, r391783, r391863 from trunk

Added:
    maven/surefire/branches/surefire-testng/surefire-booter/src/test/
      - copied from r391783, maven/surefire/trunk/surefire-booter/src/test/
    maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/
      - copied from r391783, maven/surefire/trunk/surefire-booter/src/test/java/
    maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/
      - copied from r391783, 
maven/surefire/trunk/surefire-booter/src/test/java/org/
    
maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/
      - copied from r391783, 
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/
    
maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/maven/
      - copied from r391783, 
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/
    
maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/maven/surefire/
      - copied from r391783, 
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/
    
maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/maven/surefire/booter/
    
maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireBooterTest.java
   (with props)
Modified:
    
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
    
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java
    
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireExecutionException.java

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=391865&r1=391864&r2=391865&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
 Wed Apr  5 17:24:03 2006
@@ -519,7 +519,8 @@
         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
-        classLoader.setDefaultAssertionStatus( assertionsEnabled );
+        // TODO: not available under JDK 1.3
+        //classLoader.setDefaultAssertionStatus( assertionsEnabled );
         for ( Iterator iter = urls.iterator(); iter.hasNext(); )
         {
             URL url = (URL) iter.next();
@@ -540,7 +541,7 @@
 
         List list = new ArrayList();
 
-        String[] stringArray = sl.split( "," );
+        String[] stringArray = split( sl, "," );
 
         for ( int i = 0; i < stringArray.length; i++ )
         {
@@ -588,8 +589,8 @@
         Object[] paramObjects = null;
         if ( paramProperty != null )
         {
-            String[] params = paramProperty.split( "\\|" );
-            String[] types = typeProperty.split( "\\|" );
+            String[] params = split( paramProperty, "\\|" );
+            String[] types = split( typeProperty, "\\|" );
 
             paramObjects = new Object[params.length];
 
@@ -697,6 +698,36 @@
 
         //noinspection CallToSystemExit
         System.exit( result ? TESTS_SUCCEEDED_EXIT_CODE : 
TESTS_FAILED_EXIT_CODE );
+    }
+
+    /**
+     * Split a string in a List of Strings using a delimiter. Same as Java 1.4 
String.split( String )
+     * 
+     * @since 1.5.4
+     * @param s the string to be splitted
+     * @param delim the delimiter to be used
+     * @return an array with the Strings between the delimiters
+     */
+    public static String[] split( String s, String delim )
+    {
+        if ( s.equals(delim) )
+        {
+            return new String[0];
+        }
+        List tokens = new ArrayList();
+        int i = 0;
+        int j = s.indexOf( delim, i );
+        while ( j > -1 )
+        {
+            tokens.add( s.substring( i, j ) );
+            i = j + delim.length();
+            j = s.indexOf( delim, i );
+        }
+        if ( i < s.length() || ( i == 0 ) )
+        {
+            tokens.add( s.substring( i ) );
+        }
+        return (String[]) tokens.toArray( new String[0] );
     }
 }
 

Modified: 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java
URL: 
http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java?rev=391865&r1=391864&r2=391865&view=diff
==============================================================================
--- 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java
 (original)
+++ 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java
 Wed Apr  5 17:24:03 2006
@@ -1,5 +1,7 @@
 package org.apache.maven.surefire.booter;
 
+import org.apache.maven.surefire.testset.NestedCheckedException;
+
 /*
  * Copyright 2001-2006 The Apache Software Foundation.
  *
@@ -16,8 +18,13 @@
  * limitations under the License.
  */
 
+/**
+ * Encapsulates exceptions thrown during Surefire forking.
+ * 
+ * @version $Id$ 
+ */
 public class SurefireBooterForkException
-    extends Exception
+    extends NestedCheckedException
 {
     public SurefireBooterForkException( String message )
     {

Modified: 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireExecutionException.java
URL: 
http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireExecutionException.java?rev=391865&r1=391864&r2=391865&view=diff
==============================================================================
--- 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireExecutionException.java
 (original)
+++ 
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireExecutionException.java
 Wed Apr  5 17:24:03 2006
@@ -1,5 +1,7 @@
 package org.apache.maven.surefire.booter;
 
+import org.apache.maven.surefire.testset.NestedCheckedException;
+
 /*
  * Copyright 2001-2006 The Apache Software Foundation.
  *
@@ -22,7 +24,7 @@
  * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
  */
 public class SurefireExecutionException
-    extends Exception
+    extends NestedCheckedException
 {
     public SurefireExecutionException( String message, Throwable nested )
     {

Added: 
maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireBooterTest.java
URL: 
http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireBooterTest.java?rev=391865&view=auto
==============================================================================
--- 
maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireBooterTest.java
 (added)
+++ 
maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireBooterTest.java
 Wed Apr  5 17:24:03 2006
@@ -0,0 +1,94 @@
+package org.apache.maven.surefire.booter;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.surefire.SurefireBooter;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class SurefireBooterTest
+    extends TestCase
+{
+
+    public void testSplit()
+    {
+        String s, d;
+        d = ":";
+        s = "x1:y2:z;j:f";
+        List list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Arrays.asList( new String[] { "x1", "y2", "z;j", "f" } 
), list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+
+        s = "x1";
+        list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Arrays.asList( new String[] { "x1" } ), list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+
+        s = "x1:";
+        list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Arrays.asList( new String[] { "x1" } ), list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+
+        s = "";
+        list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Arrays.asList( new String[] { "" } ), list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+
+        s = ":";
+        list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Collections.EMPTY_LIST, list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+
+        d = "::";
+        s = "x1::y2::z;j::f";
+        list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Arrays.asList( new String[] { "x1", "y2", "z;j", "f" } 
), list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+
+        s = "x1";
+        list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Arrays.asList( new String[] { "x1" } ), list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+
+        s = "x1::";
+        list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Arrays.asList( new String[] { "x1" } ), list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+
+        s = "";
+        list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Arrays.asList( new String[] { "" } ), list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+
+        s = ":";
+        list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Arrays.asList( new String[] { ":" } ), list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+
+        s = "::";
+        list = Arrays.asList( SurefireBooter.split( s, d ) );
+        assertEquals( Collections.EMPTY_LIST, list );
+        assertEquals( Arrays.asList( s.split( d ) ), list );
+    }
+
+}

Propchange: 
maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireBooterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/surefire/branches/surefire-testng/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireBooterTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"


Reply via email to