maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dfabul...@apache.org
Subject svn commit: r597761 - in /maven/surefire/trunk: surefire-api/src/main/java/org/apache/maven/surefire/suite/ surefire-integration-tests/src/test/resources/junit-notExtendingTestCase/src/test/java/ surefire-providers/surefire-junit/src/main/java/org/apac...
Date Fri, 23 Nov 2007 23:34:09 GMT
Author: dfabulich
Date: Fri Nov 23 15:34:04 2007
New Revision: 597761

URL: http://svn.apache.org/viewvc?rev=597761&view=rev
Log:
[SUREFIRE-346] Failure when we try to instantiate a POJO without a no-arg constructor.  This
isn't really a POJO test, and should not be instantiated.

Added:
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-notExtendingTestCase/src/test/java/TestHelper.java
Modified:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
    maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitDirectoryTestSuite.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=597761&r1=597760&r2=597761&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
Fri Nov 23 15:34:04 2007
@@ -94,6 +94,8 @@
             if ( !Modifier.isAbstract( testClass.getModifiers() ) )
             {
                 SurefireTestSet testSet = createTestSet( testClass, classLoader );
+                
+                if ( testSet == null ) continue;
 
                 if ( testSets.containsKey( testSet.getName() ) )
                 {

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-notExtendingTestCase/src/test/java/TestHelper.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-notExtendingTestCase/src/test/java/TestHelper.java?rev=597761&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-notExtendingTestCase/src/test/java/TestHelper.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit-notExtendingTestCase/src/test/java/TestHelper.java
Fri Nov 23 15:34:04 2007
@@ -0,0 +1,3 @@
+public class TestHelper {
+    public TestHelper(String two, String arguments) {} 
+}
\ No newline at end of file

Modified: maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitDirectoryTestSuite.java?rev=597761&r1=597760&r2=597761&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitDirectoryTestSuite.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitDirectoryTestSuite.java
Fri Nov 23 15:34:04 2007
@@ -59,10 +59,27 @@
         {
             testSet = new JUnitTestSet( testClass );
         }
-        else
+        else if (classHasPublicNoArgConstructor( testClass ))
         {
             testSet = new PojoTestSet( testClass );
         }
+        else
+        {
+            testSet = null;
+        }
         return testSet;
+    }
+    
+    private boolean classHasPublicNoArgConstructor( Class testClass )
+    {
+        try
+        {
+            testClass.getConstructor( new Class[0] );
+            return true;
+        }
+        catch ( Exception e )
+        {
+            return false;
+        }
     }
 }



Mime
View raw message