maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r358633 - in /maven/surefire/trunk: surefire-booter/ surefire-booter/src/main/java/org/apache/maven/surefire/ surefire/src/main/java/org/apache/maven/surefire/ surefire/src/main/java/org/apache/maven/surefire/battery/
Date Thu, 22 Dec 2005 21:20:39 GMT
Author: jvanzyl
Date: Thu Dec 22 13:20:14 2005
New Revision: 358633

URL: http://svn.apache.org/viewcvs?rev=358633&view=rev
Log:

      PR: MSUREFIRE-20
     URL: http://jira.codehaus.org/browse/MSUREFIRE-20
 Summary: forkMode=pertest fails to call setUp
Reporter: Matt Brozowski


Added:
    maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java
  (with props)
Modified:
    maven/surefire/trunk/surefire-booter/pom.xml
    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
    maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/battery/JUnitBattery.java
    maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/battery/SingleTestBattery.java

Modified: maven/surefire/trunk/surefire-booter/pom.xml
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire-booter/pom.xml?rev=358633&r1=358632&r2=358633&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/pom.xml (original)
+++ maven/surefire/trunk/surefire-booter/pom.xml Thu Dec 22 13:20:14 2005
@@ -7,7 +7,7 @@
   <modelVersion>4.0.0</modelVersion>
   <artifactId>surefire-booter</artifactId>
   <name>SureFire Booter</name>
-  <version>1.6-SNAPSHOT</version>
+  <version>1.5.2-SNAPSHOT</version>
   <dependencies>
     <dependency>
       <groupId>junit</groupId>
@@ -18,7 +18,7 @@
     <dependency>
       <groupId>org.apache.maven.surefire</groupId>
       <artifactId>surefire</artifactId>
-      <version>1.5</version>
+      <version>1.5.2-SNAPSHOT</version>
     </dependency>
   </dependencies>
-</project>
\ No newline at end of file
+</project>

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=358633&r1=358632&r2=358633&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
Thu Dec 22 13:20:14 2005
@@ -52,7 +52,7 @@
 
     private static String BATTERY_EXECUTOR = "org.apache.maven.surefire.Surefire";
 
-    private static String SINGLE_TEST_BATTERY = "org.apache.maven.surefire.battery.SingleTestBattery";
+    private static String SINGLE_TEST_BATTERY = "org.apache.maven.surefire.battery.JUnitBattery";
 
     private List batteries = new ArrayList();
 
@@ -355,7 +355,6 @@
     private List getTestClasses()
         throws Exception
     {
-
         IsolatedClassLoader classLoader = createClassLoader();
 
         List instantiatedBatteries = Surefire.instantiateBatteries( batteries, classLoader
);
@@ -388,6 +387,8 @@
     private void getForkPerTestArgs( String testClass )
         throws Exception
     {
+        //System.out.println( "SINGLE_TEST_BATTERY = " + SINGLE_TEST_BATTERY );
+
         getForkArgs( SINGLE_TEST_BATTERY + "|" + testClass );
     }
 

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=358633&r1=358632&r2=358633&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 Thu
Dec 22 13:20:14 2005
@@ -17,14 +17,11 @@
  */
 
 import org.apache.maven.surefire.battery.Battery;
-import org.apache.maven.surefire.battery.JUnitBattery;
 import org.apache.maven.surefire.battery.assertion.BatteryTestFailedException;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.Reporter;
 import org.apache.maven.surefire.report.ReporterManager;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -262,56 +259,14 @@
         {
             Object[] holder = (Object[]) batteryHolders.get( i );
 
-            Class testClass;
+            Object battery = SurefireUtils.instantiateBattery( holder, loader );
 
-            Class batteryClass;
+            System.out.println( "battery = " + battery );
 
-            try
-            {
-                testClass = loader.loadClass( (String) holder[0] );
-
-                batteryClass = loader.loadClass( "org.apache.maven.surefire.battery.Battery"
);
-            }
-            catch ( Exception e )
-            {
-                continue;
-            }
-
-            if ( Modifier.isAbstract( testClass.getModifiers() ) )
+            if ( battery != null )
             {
-                continue;
+                batteries.add( battery );
             }
-
-            Object battery = null;
-
-            if ( batteryClass.isAssignableFrom( testClass ) )
-            {
-                if ( holder[1] != null )
-                {
-                    Object[] params = (Object[]) holder[1];
-
-                    Class[] paramTypes = new Class[params.length];
-
-                    for ( int j = 0; j < params.length; j++ )
-                    {
-                        paramTypes[j] = params[j].getClass();
-                    }
-
-                    Constructor constructor = testClass.getConstructor( paramTypes );
-
-                    battery = constructor.newInstance( params );
-                }
-                else
-                {
-                    battery = testClass.newInstance();
-                }
-            }
-            else
-            {
-                battery = new JUnitBattery( testClass, loader );
-            }
-
-            batteries.add( battery );
         }
 
         return batteries;

Added: maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java?rev=358633&view=auto
==============================================================================
--- maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java
(added)
+++ maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java
Thu Dec 22 13:20:14 2005
@@ -0,0 +1,68 @@
+package org.apache.maven.surefire;
+
+import org.apache.maven.surefire.battery.JUnitBattery;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+/**
+ * @author Jason van  Zyl
+ * @version $Id:$
+ */
+public class SurefireUtils
+{
+    public static Object instantiateBattery( Object[] holder, ClassLoader loader )
+        throws Exception
+    {
+        Class testClass;
+
+        Class batteryClass;
+
+        try
+        {
+            testClass = loader.loadClass( (String) holder[0] );
+
+            batteryClass = loader.loadClass( "org.apache.maven.surefire.battery.Battery"
);
+        }
+        catch ( Exception e )
+        {
+            return null;
+        }
+
+        if ( Modifier.isAbstract( testClass.getModifiers() ) )
+        {
+            return null;
+        }
+
+        Object battery = null;
+
+        if ( batteryClass.isAssignableFrom( testClass ) )
+        {
+            if ( holder[1] != null )
+            {
+                Object[] params = (Object[]) holder[1];
+
+                Class[] paramTypes = new Class[params.length];
+
+                for ( int j = 0; j < params.length; j++ )
+                {
+                    paramTypes[j] = params[j].getClass();
+                }
+
+                Constructor constructor = testClass.getConstructor( paramTypes );
+
+                battery = constructor.newInstance( params );
+            }
+            else
+            {
+                battery = testClass.newInstance();
+            }
+        }
+        else
+        {
+            battery = new JUnitBattery( testClass, loader );
+        }
+
+        return battery;
+    }
+}

Propchange: maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/battery/JUnitBattery.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/battery/JUnitBattery.java?rev=358633&r1=358632&r2=358633&view=diff
==============================================================================
--- maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/battery/JUnitBattery.java
(original)
+++ maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/battery/JUnitBattery.java
Thu Dec 22 13:20:14 2005
@@ -63,13 +63,25 @@
 
     private Method runMethod;
 
+    public JUnitBattery( String testClassName )
+        throws Exception
+    {
+        processTestClass( getClass().getClassLoader().loadClass( testClassName ), getClass().getClassLoader()
);
+    }
+
     public JUnitBattery( final String testClass, ClassLoader loader )
         throws Exception
     {
-        this( loader.loadClass( testClass ), loader );
+        processTestClass( loader.loadClass( testClass ), loader );
     }
 
     public JUnitBattery( final Class testClass, ClassLoader loader )
+        throws Exception
+    {
+        processTestClass( testClass, loader );
+    }
+
+    public void processTestClass( final Class testClass, ClassLoader loader )
         throws Exception
     {
         if ( testClass == null )

Modified: maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/battery/SingleTestBattery.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/battery/SingleTestBattery.java?rev=358633&r1=358632&r2=358633&view=diff
==============================================================================
--- maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/battery/SingleTestBattery.java
(original)
+++ maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/battery/SingleTestBattery.java
Thu Dec 22 13:20:14 2005
@@ -17,7 +17,7 @@
  */
 
 /**
- * A battery which contains a single test class which is used primarily for running individual
tests
+ * A battery which contains a single testObject class which is used primarily for running
individual tests
  * inside a new JVM instance (fork mode).
  *
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -30,7 +30,7 @@
 
     private Class testClass;
 
-    private Object test;
+    private Object testObject;
 
     public SingleTestBattery( String testClassName )
         throws Exception
@@ -39,7 +39,7 @@
 
         this.testClass = getClass().getClassLoader().loadClass( testClassName );
 
-        this.test = testClass.newInstance();
+        this.testObject = testClass.newInstance();
     }
 
     protected Class getTestClass()
@@ -49,7 +49,7 @@
 
     protected Object getTestClassInstance()
     {
-        return test;
+        return testObject;
     }
 
     public String getBatteryName()



Mime
View raw message