maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1044812 - in /maven/surefire/trunk: surefire-api/src/main/java/org/apache/maven/surefire/suite/ surefire-api/src/main/java/org/apache/maven/surefire/util/ surefire-api/src/test/java/org/apache/maven/surefire/util/ surefire-providers/surefi...
Date Sun, 12 Dec 2010 13:02:28 GMT
Author: krosenvold
Date: Sun Dec 12 13:02:27 2010
New Revision: 1044812

URL: http://svn.apache.org/viewvc?rev=1044812&view=rev
Log:
o Changed signature of DirectoryScanner slightly

Added:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
  (contents, props changed)
      - copied, changed from r1044698, maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java
  (contents, props changed)
      - copied, changed from r1044698, maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestsToRunTest.java
Removed:
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestsToRunTest.java
Modified:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java?rev=1044812&r1=1044811&r2=1044812&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
Sun Dec 12 13:02:27 2010
@@ -30,6 +30,7 @@ import org.apache.maven.surefire.testset
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.DefaultDirectoryScanner;
 import org.apache.maven.surefire.util.DirectoryScanner;
+import org.apache.maven.surefire.util.TestsToRun;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -74,8 +75,9 @@ public abstract class AbstractDirectoryT
         }
         testSets = new TreeMap();
 
-        Class[] locatedClasses =
+        final TestsToRun testsToRun =
             surefireDirectoryScanner.locateTestClasses( classLoader, new NonAbstractClassFilter()
);
+        Class[] locatedClasses = testsToRun.getLocatedClasses();
 
         for ( int i = 0; i < locatedClasses.length; i++ )
         {

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java?rev=1044812&r1=1044811&r2=1044812&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
Sun Dec 12 13:02:27 2010
@@ -55,7 +55,7 @@ public class DefaultDirectoryScanner
         this.excludes = excludes;
     }
 
-    public Class[] locateTestClasses( ClassLoader classLoader, ScannerFilter scannerFilter
)
+    public TestsToRun locateTestClasses( ClassLoader classLoader, ScannerFilter scannerFilter
)
     {
         String[] testClassNames = collectTests();
         List result = new ArrayList();
@@ -66,11 +66,12 @@ public class DefaultDirectoryScanner
 
             Class testClass = loadClass( classLoader, className );
 
-            if (scannerFilter.accept( testClass)){
+            if ( scannerFilter.accept( testClass ) )
+            {
                 result.add( testClass );
             }
         }
-        return (Class[]) result.toArray( new Class[result.size()] );
+        return new TestsToRun( result );
     }
 
     public static Class loadClass( ClassLoader classLoader, String className )

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java?rev=1044812&r1=1044811&r2=1044812&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DirectoryScanner.java
Sun Dec 12 13:02:27 2010
@@ -26,9 +26,10 @@ public interface DirectoryScanner
 {
     /**
      * Locates tests based on scanning directories
-     * @param classLoader The classloader to use when loading classes
+     *
+     * @param classLoader   The classloader to use when loading classes
      * @param scannerFilter The filter to include/exclude test classes
      * @return The found classes that match the filter
      */
-    Class[] locateTestClasses( ClassLoader classLoader, ScannerFilter scannerFilter );
+    TestsToRun locateTestClasses( ClassLoader classLoader, ScannerFilter scannerFilter );
 }

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
(from r1044698, maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java&p1=maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java&r1=1044698&r2=1044812&rev=1044812&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
Sun Dec 12 13:02:27 2010
@@ -1,3 +1,5 @@
+package org.apache.maven.surefire.util;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -16,13 +18,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.maven.surefire.junitcore;
 
 import org.apache.maven.surefire.testset.TestSetFailedException;
 
-import java.util.Collections;
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -31,18 +33,23 @@ import java.util.Set;
  *
  * @author Kristian Rosenvold (junit core adaption)
  */
-class TestsToRun
+public class TestsToRun
 {
-    private final Class[] locatedClasses;
-
-    private final Set<Class> testSets;
+    private final List locatedClasses;
 
-    public TestsToRun( Class... locatedClasses )
+    /**
+     * Constructor
+     *
+     * @param locatedClasses A list of java.lang.Class objects representing tests to run
+     */
+    public TestsToRun( List locatedClasses )
     {
         this.locatedClasses = locatedClasses;
-        testSets = new HashSet<Class>();
-        for ( Class testClass : locatedClasses )
+        Set testSets = new HashSet();
+
+        for ( Iterator iterator = locatedClasses.iterator(); iterator.hasNext(); )
         {
+            Class testClass = (Class) iterator.next();
             if ( testSets.contains( testClass ) )
             {
                 throw new RuntimeException( "Duplicate test set '" + testClass.getName()
+ "'" );
@@ -51,18 +58,12 @@ class TestsToRun
         }
     }
 
-    private TestsToRun( String className, ClassLoader classLoader )
-        throws ClassNotFoundException
-    {
-        this( classLoader.loadClass( className ) );
-    }
-
     public static TestsToRun fromClassName( String className, ClassLoader classLoader )
         throws TestSetFailedException
     {
         try
         {
-            return new TestsToRun( className, classLoader );
+            return new TestsToRun( Arrays.asList( new Class[]{ classLoader.loadClass( className
) } ) );
         }
         catch ( ClassNotFoundException e )
         {
@@ -70,23 +71,21 @@ class TestsToRun
         }
     }
 
-    public Set<Class> getTestSets()
-    {
-        return Collections.unmodifiableSet( testSets );
-    }
-
     public int size()
     {
-        return testSets.size();
+        return locatedClasses.size();
     }
 
     public Class[] getLocatedClasses()
     {
-        return locatedClasses;
+        return (Class[]) locatedClasses.toArray( new Class[locatedClasses.size()] );
     }
 
+    /**
+     * Returns an iterator over the located java.lang.Class objects
+     */
     public Iterator iterator()
     {
-        return testSets.iterator();
+        return locatedClasses.iterator();
     }
 }

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

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java
(from r1044698, maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestsToRunTest.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java?p2=maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java&p1=maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestsToRunTest.java&r1=1044698&r2=1044812&rev=1044812&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/TestsToRunTest.java
(original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java
Sun Dec 12 13:02:27 2010
@@ -1,3 +1,5 @@
+package org.apache.maven.surefire.util;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -17,30 +19,26 @@
  * under the License.
  */
 
-package org.apache.maven.surefire.junitcore;
-
-import org.junit.Test;
-
-import java.util.Set;
+import junit.framework.TestCase;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
+import java.util.Arrays;
 
 /*
- * @author Kristian Rosenvold, kristian.rosenvold@gmail com
+ * @author Kristian Rosenvold
  */
 
 public class TestsToRunTest
+    extends TestCase
 {
-    @Test
     public void testGetTestSets()
         throws Exception
     {
-        TestsToRun testsToRun = new TestsToRun( T1.class, T2.class );
+        TestsToRun testsToRun = new TestsToRun( Arrays.asList( new Class[]{ T1.class, T2.class
} ) );
         assertEquals( 2, testsToRun.size() );
-        Set<Class> stringJUnitCoreTestSetMap = testsToRun.getTestSets();
-        assertTrue( stringJUnitCoreTestSetMap.contains( T1.class ) );
-        assertEquals( 2, stringJUnitCoreTestSetMap.size() );
+        Class[] stringJUnitCoreTestSetMap = testsToRun.getLocatedClasses();
+        assertEquals( stringJUnitCoreTestSetMap[0], T1.class );
+        assertEquals( stringJUnitCoreTestSetMap[1], T2.class );
+        assertEquals( 2, stringJUnitCoreTestSetMap.length );
     }
 
     class T1

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/TestsToRunTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java?rev=1044812&r1=1044811&r2=1044812&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
Sun Dec 12 13:02:27 2010
@@ -28,6 +28,7 @@ import org.apache.maven.surefire.report.
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.DirectoryScanner;
+import org.apache.maven.surefire.util.TestsToRun;
 
 import java.util.Iterator;
 
@@ -91,12 +92,12 @@ public class JUnitCoreProvider
                                                            jUnitCoreParameters.isParallelClasses(),
                                                            jUnitCoreParameters.isParallelBoth()
);
 
-        JUnitCoreWrapper.execute( testsToRun.getLocatedClasses(), jUnitCoreParameters, listener
);
+        JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, listener );
         return reporterFactory.close();
     }
 
     private TestsToRun scanClassPath()
     {
-        return new TestsToRun( directoryScanner.locateTestClasses( testClassLoader, scannerFilter
) );
+        return directoryScanner.locateTestClasses( testClassLoader, scannerFilter );
     }
 }

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java?rev=1044812&r1=1044811&r2=1044812&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
Sun Dec 12 13:02:27 2010
@@ -20,6 +20,7 @@ package org.apache.maven.surefire.junitc
  */
 
 import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.TestsToRun;
 import org.junit.runner.Computer;
 import org.junit.runner.JUnitCore;
 
@@ -33,7 +34,7 @@ import java.util.concurrent.ExecutionExc
 
 class JUnitCoreWrapper
 {
-    public static void execute( Class[] classes, JUnitCoreParameters jUnitCoreParameters,
+    public static void execute( TestsToRun testsToRun, JUnitCoreParameters jUnitCoreParameters,
                                 ConcurrentReportingRunListener listener )
         throws TestSetFailedException
     {
@@ -42,7 +43,7 @@ class JUnitCoreWrapper
         junitCore.addListener( listener );
         try
         {
-            junitCore.run( computer, classes );
+            junitCore.run( computer, testsToRun.getLocatedClasses() );
         }
         finally
         {



Mime
View raw message