Author: jkuhnert
Date: Sat Mar 17 11:11:43 2007
New Revision: 519380

URL: http://svn.apache.org/viewvc?view=rev&rev=519380
Log:
Updated all relevant sections to bring surefire compatibility up to version 5.1 
of TestNG. 

-) Modified core TestNGDirectorySuite/ XmlSuite executors to use some testng 
internal annotation helpers in order to 
correctly operate in 1.4 or >= 1.5 jre's. 

-) Modified TestNGReporter to properly handle failures after a test suite has 
finished. 

Still have more changes on reporting, and then attack the biggest pita of all 
of finding a way to prevent all those silly breaks.

Added:
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/src/test/java/Test1.java
      - copied, changed from r519351, 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/src/test/java/SurefireTest1.java
Removed:
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/src/test/java/SurefireTest1.java
Modified:
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/pom.xml
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/pom.xml
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test3/pom.xml
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test4/pom.xml
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test4/src/test/java/TestNGSuiteTest.java
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test5/pom.xml
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test5/src/test/java/TestNGJavadocTest.java
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test6/pom.xml
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test6/src/test/java/TestNGTest.java
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test7/
   (props changed)
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test7/pom.xml
    
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
    maven/sandbox/branches/surefire/surefire-collaboration/pom.xml
    
maven/sandbox/branches/surefire/surefire-collaboration/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
    
maven/sandbox/branches/surefire/surefire-collaboration/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
    
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/pom.xml
    
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java
    
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
    
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
    
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/pom.xml?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/pom.xml
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/pom.xml
 Sat Mar 17 11:11:43 2007
@@ -98,7 +98,7 @@
     <dependency>
       <groupId>org.apache.maven.surefire</groupId>
       <artifactId>surefire-booter</artifactId>
-      <version>2.3</version>
+      <version>2.4-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/pom.xml?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/pom.xml
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/pom.xml
 Sat Mar 17 11:11:43 2007
@@ -36,6 +36,6 @@
       <version>3.8.1</version>
       <scope>test</scope>
     </dependency>
-  </dependencies>
+  </dependencies>
 
 </project>

Copied: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/src/test/java/Test1.java
 (from r519351, 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/src/test/java/SurefireTest1.java)
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/src/test/java/Test1.java?view=diff&rev=519380&p1=maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/src/test/java/SurefireTest1.java&r1=519351&p2=maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/src/test/java/Test1.java&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/src/test/java/SurefireTest1.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test1/src/test/java/Test1.java
 Sat Mar 17 11:11:43 2007
@@ -3,7 +3,7 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-public class SurefireTest1
+public class Test1
     extends TestCase
 {
 
@@ -11,7 +11,7 @@
 
     private static boolean tearDownCalled = false;
 
-    public SurefireTest1( String name, String extraName )
+    public Test1( String name, String extraName )
     {
         super( name );
     }
@@ -19,7 +19,7 @@
     public static Test suite()
     {
         TestSuite suite = new TestSuite();
-        Test test = new SurefireTest1( "testSetUp", "dummy" );
+        Test test = new Test1( "testSetUp", "dummy" );
         suite.addTest( test );
         TestSetup setup = new TestSetup( suite )
         {

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test3/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test3/pom.xml?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test3/pom.xml
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test3/pom.xml
 Sat Mar 17 11:11:43 2007
@@ -43,7 +43,6 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.1</version>
         <configuration>
           <testFailureIgnore>true</testFailureIgnore>
         </configuration>

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test4/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test4/pom.xml?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test4/pom.xml
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test4/pom.xml
 Sat Mar 17 11:11:43 2007
@@ -33,7 +33,7 @@
     <dependency>
       <groupId>org.testng</groupId>
       <artifactId>testng</artifactId>
-      <version>5.0.1</version>
+      <version>5.1</version>
       <classifier>jdk15</classifier>
       <scope>test</scope>
     </dependency>

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test4/src/test/java/TestNGSuiteTest.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test4/src/test/java/TestNGSuiteTest.java?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test4/src/test/java/TestNGSuiteTest.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test4/src/test/java/TestNGSuiteTest.java
 Sat Mar 17 11:11:43 2007
@@ -6,8 +6,6 @@
  * Tests that forcing testng to run tests via the 
  * <code>"${maven.test.forcetestng}"</code> configuration option
  * works.
- * 
- * @author jkuhnert
  */
 public class TestNGSuiteTest {
 
@@ -30,4 +28,4 @@
        {
                assert testObject != null : "testObject is null";
        }
-}
\ No newline at end of file
+}

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test5/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test5/pom.xml?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test5/pom.xml
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test5/pom.xml
 Sat Mar 17 11:11:43 2007
@@ -39,7 +39,7 @@
     <dependency>
       <groupId>org.testng</groupId>
       <artifactId>testng</artifactId>
-      <version>5.0.1</version>
+      <version>5.1</version>
       <classifier>jdk14</classifier>
       <scope>test</scope>
     </dependency>
@@ -52,6 +52,7 @@
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
+          <jvm>/usr/local/j2sdk1.4.2_13/bin/java</jvm>
           <groups>functional</groups>
         </configuration>
       </plugin>

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test5/src/test/java/TestNGJavadocTest.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test5/src/test/java/TestNGJavadocTest.java?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test5/src/test/java/TestNGJavadocTest.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test5/src/test/java/TestNGJavadocTest.java
 Sat Mar 17 11:11:43 2007
@@ -2,11 +2,7 @@
 
 
 /**
- * Tests that forcing testng to run tests via the 
- * <code>"${maven.test.forcetestng}"</code> configuration option
- * works.
- * 
- * @author jkuhnert
+ * Simple javadoc based 1.4 jre unit test.
  */
 public class TestNGJavadocTest {
 

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test6/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test6/pom.xml?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test6/pom.xml
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test6/pom.xml
 Sat Mar 17 11:11:43 2007
@@ -33,7 +33,7 @@
     <dependency>
       <groupId>org.testng</groupId>
       <artifactId>testng</artifactId>
-      <version>5.0.1</version>
+      <version>5.1</version>
       <classifier>jdk15</classifier>
       <scope>test</scope>
     </dependency>

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test6/src/test/java/TestNGTest.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test6/src/test/java/TestNGTest.java?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test6/src/test/java/TestNGTest.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test6/src/test/java/TestNGTest.java
 Sat Mar 17 11:11:43 2007
@@ -1,3 +1,6 @@
+
+import static org.testng.Assert.*;
+
 import org.testng.annotations.AfterSuite;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -21,11 +24,11 @@
                testObject = new Object();
        }
        
-       @AfterSuite(alwaysRun = true, groups = "functional")
+       @AfterSuite(groups = "functional")
        public void check_Test_Count()
        {
                System.out.println("check_Test_Count(): " + m_testCount);
-               
+        
                assert m_testCount == 3 : "Expected 3 tests to be run but local 
count was " + m_testCount;
        }
        
@@ -49,4 +52,4 @@
        {
                assert false == true : "Group specified by test shouldnt be 
run.";
        }
-}
\ No newline at end of file
+}

Propchange: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test7/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Mar 17 11:11:43 2007
@@ -0,0 +1 @@
+target

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test7/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test7/pom.xml?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test7/pom.xml
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/it/test7/pom.xml
 Sat Mar 17 11:11:43 2007
@@ -39,7 +39,7 @@
     <dependency>
       <groupId>org.testng</groupId>
       <artifactId>testng</artifactId>
-      <version>5.0.1</version>
+      <version>5.1</version>
       <classifier>jdk15</classifier>
       <scope>test</scope>
     </dependency>

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
 Sat Mar 17 11:11:43 2007
@@ -573,7 +573,7 @@
                 if ( includes == null || includes.size() == 0 )
                 {
                     includes = new ArrayList(
-                        Arrays.asList( new String[]{"**/Test*.java", 
"**/*Test.java", "**/*TestCase.java"} ) );
+                        Arrays.asList( new String[]{"**/*Test*.java", 
"**/*Test.java", "**/*TestCase.java"} ) );
                 }
                 if ( excludes == null || excludes.size() == 0 )
                 {

Modified: maven/sandbox/branches/surefire/surefire-collaboration/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/pom.xml?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- maven/sandbox/branches/surefire/surefire-collaboration/pom.xml (original)
+++ maven/sandbox/branches/surefire/surefire-collaboration/pom.xml Sat Mar 17 
11:11:43 2007
@@ -94,7 +94,7 @@
         <plugin>
           <artifactId>maven-surefire-plugin</artifactId>
           <!-- Require the latest version so that tests in surefire-api pass 
due to an API change -->
-          <version>2.3-SNAPSHOT</version>
+          <version>2.4-SNAPSHOT</version>
         </plugin>
         <plugin>
           <artifactId>maven-release-plugin</artifactId>

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
 Sat Mar 17 11:11:43 2007
@@ -144,7 +144,7 @@
     {
         String suiteClass = (String) definition[0];
         Object[] params = (Object[]) definition[1];
-
+System.out.println("createSuiteFromDefinintion() : suiteClass " + suiteClass);
         SurefireTestSuite suite = instantiateSuite( suiteClass, params, 
surefireClassLoader );
 
         suite.locateTestSets( testsClassLoader );

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
 Sat Mar 17 11:11:43 2007
@@ -192,7 +192,7 @@
         throws SurefireBooterForkException, SurefireExecutionException
     {
         boolean result = false;
-
+        
         if ( ForkConfiguration.FORK_NEVER.equals( 
forkConfiguration.getForkMode() ) )
         {
             result = runSuitesInProcess();
@@ -219,7 +219,7 @@
         {
             throw new IllegalArgumentException( "Cannot only specify testSet 
for single test suites" );
         }
-
+        
         // TODO: replace with plexus
 
         //noinspection CatchGenericClass,OverlyBroadCatchBlock
@@ -267,7 +267,7 @@
 
         //noinspection CatchGenericClass,OverlyBroadCatchBlock
         ClassLoader oldContextClassLoader = 
Thread.currentThread().getContextClassLoader();
-
+        
         try
         {
             // The test classloader must be constructed first to avoid issues 
with commons-logging until we properly
@@ -289,7 +289,7 @@
 
             Boolean result = (Boolean) run.invoke( surefire, new 
Object[]{reports, testSuites, surefireClassLoader,
                 testsClassLoader} );
-
+System.out.println("Surefirebooter finished");
             return result.booleanValue();
         }
         catch ( InvocationTargetException e )

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/pom.xml?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/pom.xml
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/pom.xml
 Sat Mar 17 11:11:43 2007
@@ -37,7 +37,7 @@
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>surefire-api</artifactId>
-      <version>2.3-SNAPSHOT</version>
+      <version>2.4-SNAPSHOT</version>
       <!-- commenting this due to MNG-2339
             <version>${project.version}</version>
       -->

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java
 Sat Mar 17 11:11:43 2007
@@ -108,7 +108,7 @@
             Class[] addListenerParamTypes = 
interfacesImplementedByDynamicProxy;
 
             addListenerMethod = testResultClass.getMethod( 
ADD_LISTENER_METHOD, addListenerParamTypes );
-
+            
             if ( testInterface.isAssignableFrom( testClass ) 
)//testObject.getClass() ) )
             {
                 countTestCasesMethod = testInterface.getMethod( 
COUNT_TEST_CASES_METHOD, EMPTY_CLASS_ARRAY );

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
 Sat Mar 17 11:11:43 2007
@@ -27,6 +27,7 @@
 import org.testng.ISuiteListener;
 import org.testng.ITestListener;
 import org.testng.TestNG;
+import org.testng.internal.annotations.AnnotationConfiguration;
 import org.testng.xml.XmlClass;
 import org.testng.xml.XmlSuite;
 import org.testng.xml.XmlTest;
@@ -177,21 +178,35 @@
         testNG.setXmlSuites( Collections.singletonList( suite ) );
 
         testNG.setListenerClasses( new ArrayList() );
-
+        
         TestNGReporter reporter = new TestNGReporter( reporterManager, this );
         testNG.addListener( (ITestListener) reporter );
         testNG.addListener( (ISuiteListener) reporter );
-
+        
+        String jre = System.getProperty("java.vm.version");
+        if (jre.indexOf("1.4") > -1) {
+            
AnnotationConfiguration.getInstance().initialize(AnnotationConfiguration.JVM_14_CONFIG);
+            
AnnotationConfiguration.getInstance().getAnnotationFinder().addSourceDirs(new 
String[]{testSourceDirectory});
+        } else {
+            
AnnotationConfiguration.getInstance().initialize(AnnotationConfiguration.JVM_15_CONFIG);
+        }
+        
         // Set source path so testng can find javadoc annotations if not in 
1.5 jvm
         if ( testSourceDirectory != null )
         {
             testNG.setSourcePath( testSourceDirectory );
         }
-
+        
         // workaround for SUREFIRE-49
         // TestNG always creates an output directory, and if not set the name 
for the directory is "null"
         testNG.setOutputDirectory( System.getProperty( "java.io.tmpdir" ) );
-
+        
         testNG.runSuitesLocally();
+        
+        // need to execute report end after testng has completely finished as 
the 
+        // reporter methods don't get called in the order that would allow for 
capturing
+        // failures that happen in before/after suite configuration methods
+        
+        reporter.cleanupAfterTestsRun();
     }
 }

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
 Sat Mar 17 11:11:43 2007
@@ -24,6 +24,7 @@
 import org.testng.ISuiteListener;
 import org.testng.ITestListener;
 import org.testng.TestNG;
+import org.testng.internal.annotations.AnnotationConfiguration;
 import org.testng.xml.XmlSuite;
 
 import java.util.ArrayList;
@@ -56,17 +57,30 @@
         testNG.addListener( (ITestListener) reporter );
         testNG.addListener( (ISuiteListener) reporter );
 
+        String jre = System.getProperty("java.vm.version");
+        if (jre.indexOf("1.4") > -1) {
+            
AnnotationConfiguration.getInstance().initialize(AnnotationConfiguration.JVM_14_CONFIG);
+            
AnnotationConfiguration.getInstance().getAnnotationFinder().addSourceDirs(new 
String[]{testSourceDirectory});
+        } else {
+            
AnnotationConfiguration.getInstance().initialize(AnnotationConfiguration.JVM_15_CONFIG);
+        }
+        
         // Set source path so testng can find javadoc annotations if not in 
1.5 jvm
         if ( testSourceDirectory != null )
         {
             testNG.setSourcePath( testSourceDirectory );
         }
-
-        // TODO: Doesn't find testng.xml based suites when these are 
un-commented
-        // TestNG ~also~ looks for the currentThread context classloader
-        // ClassLoader oldClassLoader = 
Thread.currentThread().getContextClassLoader();
-        // Thread.currentThread().setContextClassLoader( 
suite.getClass().getClassLoader() );
+        
+        // workaround for SUREFIRE-49
+        // TestNG always creates an output directory, and if not set the name 
for the directory is "null"
+        testNG.setOutputDirectory( System.getProperty( "java.io.tmpdir" ) );
+        
         testNG.runSuitesLocally();
-        //Thread.currentThread().setContextClassLoader( oldClassLoader );
+        
+        // need to execute report end after testng has completely finished as 
the 
+        // reporter methods don't get called in the order that would allow for 
capturing
+        // failures that happen in before/after suite configuration methods
+        
+        reporter.cleanupAfterTestsRun();
     }
 }

Modified: 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java?view=diff&rev=519380&r1=519379&r2=519380
==============================================================================
--- 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
 (original)
+++ 
maven/sandbox/branches/surefire/surefire-collaboration/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
 Sat Mar 17 11:11:43 2007
@@ -37,8 +37,6 @@
  * Listens for and provides and adaptor layer so that
  * TestNG tests can report their status to the current
  * [EMAIL PROTECTED] org.apache.maven.surefire.report.ReporterManager}.
- *
- * @author jkuhnert
  */
 public class TestNGReporter
     implements ITestListener, ISuiteListener
@@ -52,6 +50,10 @@
 
     private Object source;
 
+    private boolean testStarted = false;
+    
+    private ITestContext _finishContext;
+    
     /**
      * Constructs a new instance that will listen to
      * test updates from a [EMAIL PROTECTED] TestNG} class instance.
@@ -76,6 +78,8 @@
 
     public void onTestStart( ITestResult result )
     {
+        testStarted = true;
+        
         String rawString = bundle.getString( "testStarting" );
         String group = groupString( result.getMethod().getGroups(), 
result.getTestClass().getName() );
         ReportEntry report = new ReportEntry( source, getUserFriendlyTestName( 
result ), group, rawString );
@@ -85,6 +89,7 @@
 
     public void onTestSuccess( ITestResult result )
     {
+        testStarted = false;
         ReportEntry report =
             new ReportEntry( source, getUserFriendlyTestName( result ), 
bundle.getString( "testSuccessful" ) );
         reportManager.testSucceeded( report );
@@ -92,11 +97,22 @@
 
     public void onTestFailure( ITestResult result )
     {
+        // methods run after/before suite and other similar tests don't get 
explicit test started calls
+        // because they are considered configuration methods, but if one of 
them fails we need to change the
+        // test count and start it in case it wasn't already started so that 
all failures / tests are properly
+        // reported
+        
+        if (!testStarted) {
+            
+            onTestStart(result);
+        }
+        
+        testStarted = false;
         String rawString = bundle.getString( "executeException" );
 
         ReportEntry report = new ReportEntry( source, getUserFriendlyTestName( 
result ), rawString,
                                               new TestNGStackTraceWriter( 
result ) );
-
+        
         reportManager.testFailed( report );
     }
 
@@ -108,6 +124,7 @@
 
     public void onTestSkipped( ITestResult result )
     {
+        testStarted = false;
         ReportEntry report =
             new ReportEntry( source, getUserFriendlyTestName( result ), 
bundle.getString( "testSkipped" ) );
 
@@ -118,6 +135,7 @@
     {
         String rawString = bundle.getString( "executeException" );
 
+        testStarted = false;
         ReportEntry report = new ReportEntry( source, getUserFriendlyTestName( 
result ), rawString,
                                               new TestNGStackTraceWriter( 
result ) );
 
@@ -144,14 +162,7 @@
 
     public void onFinish( ITestContext context )
     {
-        String rawString = bundle.getString( "testSetCompletedNormally" );
-
-        ReportEntry report =
-            new ReportEntry( source, context.getName(), groupString( 
context.getIncludedGroups(), null ), rawString );
-
-        reportManager.testSetCompleted( report );
-
-        reportManager.reset();
+        _finishContext = context;
     }
 
     public void onFinish( ISuite suite )
@@ -161,7 +172,25 @@
     public void onStart( ISuite suite )
     {
     }
+    
+    /**
+     * Should <em>always</em> be run after the entire TestNG suite has 
finished running so that the 
+     * report set correctly captures all failures / success within the suite - 
especially those that happen in
+     * before/after suite configuration methods that would normally report 0 
tests but have to be included as a test
+     * when they fail.
+     */
+    public void cleanupAfterTestsRun()
+    {
+        String rawString = bundle.getString( "testSetCompletedNormally" );
+
+        ReportEntry report =
+            new ReportEntry( source, _finishContext.getName(), groupString( 
_finishContext.getIncludedGroups(), null ), rawString );
 
+        reportManager.testSetCompleted( report );
+
+        reportManager.reset();
+    }
+    
     /**
      * Creates a string out of the list of testng groups in the
      * form of <pre>"group1,group2,group3"</pre>.


Reply via email to