Author: brett
Date: Sat Feb 25 23:03:08 2006
New Revision: 381067

URL: http://svn.apache.org/viewcvs?rev=381067&view=rev
Log:
[MSUREFIRE-23] first cut of testng support. Not quite there yet.

Added:
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/pom.xml   
(with props)
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test/
    
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test-data/
    
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test-data/testng.xml
   (with props)
    
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test/java/
    
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test/java/TestNGSuiteTest.java
   (with props)
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/pom.xml   
(with props)
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/src/
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/src/test/
    
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/src/test/java/
    
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/src/test/java/TestNGJavadocTest.java
   (with props)
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/pom.xml   
(with props)
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/
    maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/
    
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/
    
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/JunitTest.java
   (with props)
    
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/TestNGTest.java
   (with props)
Modified:
    maven/plugins/branches/maven-surefire-plugin-testng/pom.xml
    
maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/test/SurefirePlugin.java

Modified: maven/plugins/branches/maven-surefire-plugin-testng/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/pom.xml?rev=381067&r1=381066&r2=381067&view=diff
==============================================================================
--- maven/plugins/branches/maven-surefire-plugin-testng/pom.xml (original)
+++ maven/plugins/branches/maven-surefire-plugin-testng/pom.xml Sat Feb 25 
23:03:08 2006
@@ -4,14 +4,11 @@
     <groupId>org.apache.maven.plugins</groupId>
     <version>2.0.1</version>
   </parent>
-  <properties>
-    <revision>$Rev$</revision>
-  </properties>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>maven-surefire-plugin</artifactId>
   <packaging>maven-plugin</packaging>
   <name>Maven Surefire Plugin</name>
-  <version>2.1.3-SNAPSHOT</version>
+  <version>2.2-SNAPSHOT</version>
   <contributors>
     <contributor>
       <name>Joakim Erdfelt</name>
@@ -28,12 +25,12 @@
     <dependency>
       <groupId>org.apache.maven.surefire</groupId>
       <artifactId>surefire-booter</artifactId>
-      <version>1.5.3-SNAPSHOT</version>
+      <version>1.6-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.surefire</groupId>
       <artifactId>surefire</artifactId>
-      <version>1.5.3-SNAPSHOT</version>
+      <version>1.6-SNAPSHOT</version>
       <scope>runtime</scope>
     </dependency>
     <dependency>

Added: maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/pom.xml?rev=381067&view=auto
==============================================================================
--- maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/pom.xml 
(added)
+++ maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/pom.xml 
Sat Feb 25 23:03:08 2006
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+   <modelVersion>4.0.0</modelVersion>
+
+   <groupId>org.apache.maven.plugins.surefire</groupId>
+   <artifactId>test4</artifactId>
+   <version>1.0-SNAPSHOT</version>
+   <name>TestNG Suites</name>
+   <description>Uses suite xml file definitions to invoke testng 
tests</description>
+   
+   <dependencies>
+      <dependency>
+         <groupId>junit</groupId>
+         <artifactId>junit</artifactId>
+         <version>3.8.1</version>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.testng</groupId>
+         <artifactId>testng-jdk15</artifactId>
+         <version>4.4.7</version>
+         <scope>test</scope>
+      </dependency>
+   </dependencies>
+   
+   <build>
+      <plugins>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+               <suiteXmlFiles>
+                  <file>src/test-data/testng.xml</file>
+               </suiteXmlFiles>
+            </configuration>
+         </plugin>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-compiler-plugin</artifactId>
+            <configuration>
+               <source>1.5</source>
+               <target>1.5</target>
+            </configuration>
+         </plugin>
+      </plugins>
+   </build>
+
+</project>

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test-data/testng.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test-data/testng.xml?rev=381067&view=auto
==============================================================================
--- 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test-data/testng.xml
 (added)
+++ 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test-data/testng.xml
 Sat Feb 25 23:03:08 2006
@@ -0,0 +1,11 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"; >
+ 
+<suite name="Suite 1 Test" verbose="1" >
+
+  <test name="Sample Test"  >
+    <classes>
+      <class name="TestNGSuiteTest"  />
+    </classes>
+  </test>
+
+</suite>
\ No newline at end of file

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test-data/testng.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test-data/testng.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test/java/TestNGSuiteTest.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test/java/TestNGSuiteTest.java?rev=381067&view=auto
==============================================================================
--- 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test/java/TestNGSuiteTest.java
 (added)
+++ 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test/java/TestNGSuiteTest.java
 Sat Feb 25 23:03:08 2006
@@ -0,0 +1,34 @@
+import org.testng.annotations.Configuration;
+import org.testng.annotations.Test;
+import org.testng.internal.Utils;
+
+
+/**
+ * Tests that forcing testng to run tests via the 
+ * <code>"${maven.test.forcetestng}"</code> configuration option
+ * works.
+ * 
+ * @author jkuhnert
+ */
+public class TestNGSuiteTest {
+
+       /**
+        * Sets up testObject
+        */
+       @Configuration(beforeTestClass = true)
+       public void configureTest()
+       {
+               testObject = new Object();
+       }
+       
+       Object testObject;
+       
+       /**
+        * Tests reporting an error
+        */
+       @Test
+       public void isTestObjectNull()
+       {
+               assert testObject != null : "testObject is null";
+       }
+}
\ No newline at end of file

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test/java/TestNGSuiteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test4/src/test/java/TestNGSuiteTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/pom.xml?rev=381067&view=auto
==============================================================================
--- maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/pom.xml 
(added)
+++ maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/pom.xml 
Sat Feb 25 23:03:08 2006
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+   <modelVersion>4.0.0</modelVersion>
+
+   <groupId>org.apache.maven.plugins.surefire</groupId>
+   <artifactId>test5</artifactId>
+   <version>1.0-SNAPSHOT</version>
+   <name>Test for testng jdk14 integration</name>
+   <description>calls testng jdk14 javadoc based tests</description>
+   
+   <dependencies>
+      <dependency>
+         <groupId>junit</groupId>
+         <artifactId>junit</artifactId>
+         <version>3.8.1</version>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.testng</groupId>
+         <artifactId>testng-jdk14</artifactId>
+         <version>4.4.7</version>
+         <scope>test</scope>
+      </dependency>
+   </dependencies>
+   
+   <build>
+    <testSourceDirectory>src/test/java</testSourceDirectory>
+      <plugins>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+               <groups>functional</groups>
+            </configuration>
+         </plugin>
+      </plugins>
+   </build>
+
+</project>

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/src/test/java/TestNGJavadocTest.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/src/test/java/TestNGJavadocTest.java?rev=381067&view=auto
==============================================================================
--- 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/src/test/java/TestNGJavadocTest.java
 (added)
+++ 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/src/test/java/TestNGJavadocTest.java
 Sat Feb 25 23:03:08 2006
@@ -0,0 +1,42 @@
+import org.testng.Assert;
+
+
+/**
+ * Tests that forcing testng to run tests via the 
+ * <code>"${maven.test.forcetestng}"</code> configuration option
+ * works.
+ * 
+ * @author jkuhnert
+ */
+public class TestNGJavadocTest {
+
+       /**
+        * Sets up testObject
+        * @testng.configuration beforeTestClass = "true"
+        *                                               groups = "functional"
+        */
+       public void configureTest()
+       {
+               testObject = new Object();
+       }
+       
+       Object testObject;
+       
+       /**
+        * Tests reporting an error
+        * @testng.test groups = "functional, notincluded"
+        */
+       public void isTestObjectNull()
+       {
+               Assert.assertNotNull(testObject, "testObject is null");
+       }
+       
+       /**
+        * Sample method that shouldn't be run by test suite.
+        * @testng.test groups = "notincluded"
+        */
+       public void shouldNotRun()
+       {
+               Assert.assertTrue(false, "Group specified by test shouldnt be 
run.");
+       }
+}
\ No newline at end of file

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/src/test/java/TestNGJavadocTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test5/src/test/java/TestNGJavadocTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/pom.xml?rev=381067&view=auto
==============================================================================
--- maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/pom.xml 
(added)
+++ maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/pom.xml 
Sat Feb 25 23:03:08 2006
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+   <modelVersion>4.0.0</modelVersion>
+
+   <groupId>org.apache.maven.plugins.surefire</groupId>
+   <artifactId>test6</artifactId>
+   <version>1.0-SNAPSHOT</version>
+   <name>Test for testng integration</name>
+   <description>calls testng test</description>
+   
+   <dependencies>
+      <dependency>
+         <groupId>junit</groupId>
+         <artifactId>junit</artifactId>
+         <version>3.8.1</version>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.testng</groupId>
+         <artifactId>testng-jdk15</artifactId>
+         <version>4.4.7</version>
+         <scope>test</scope>
+      </dependency>
+   </dependencies>
+   
+   <build>
+      <plugins>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+               <groups>functional</groups>
+               <threadCount>3</threadCount>
+               <parallel>true</parallel>
+            </configuration>
+         </plugin>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-compiler-plugin</artifactId>
+            <configuration>
+               <source>1.5</source>
+               <target>1.5</target>
+            </configuration>
+         </plugin>
+      </plugins>
+   </build>
+
+</project>

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/JunitTest.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/JunitTest.java?rev=381067&view=auto
==============================================================================
--- 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/JunitTest.java
 (added)
+++ 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/JunitTest.java
 Sat Feb 25 23:03:08 2006
@@ -0,0 +1,29 @@
+import junit.framework.TestCase;
+
+/**
+ * Provided to ensure both junit and testng tests can run happily
+ * together.
+ * 
+ * @author jkuhnert
+ */
+public class JunitTest extends TestCase {
+
+       Object testObject;
+       
+       /**
+        * Creats an object instance
+        */
+       public void setUp()
+       {
+               testObject = new Object();
+       }
+       
+       /**
+        * Tests that object created in setup 
+        * isn't null.
+        */
+       public void testJunitObject()
+       {
+               assertNotNull(testObject);
+       }
+}

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/JunitTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/JunitTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/TestNGTest.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/TestNGTest.java?rev=381067&view=auto
==============================================================================
--- 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/TestNGTest.java
 (added)
+++ 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/TestNGTest.java
 Sat Feb 25 23:03:08 2006
@@ -0,0 +1,43 @@
+import org.testng.annotations.Configuration;
+import org.testng.annotations.Test;
+import org.testng.internal.Utils;
+
+
+/**
+ * Tests that forcing testng to run tests via the 
+ * <code>"${maven.test.forcetestng}"</code> configuration option
+ * works.
+ * 
+ * @author jkuhnert
+ */
+public class TestNGTest {
+
+       /**
+        * Sets up testObject
+        */
+       @Configuration(beforeTestClass = true, groups = "functional")
+       public void configureTest()
+       {
+               testObject = new Object();
+       }
+       
+       Object testObject;
+       
+       /**
+        * Tests reporting an error
+        */
+       @Test(groups = {"functional", "notincluded"})
+       public void isTestObjectNull()
+       {
+               assert testObject != null : "testObject is null";
+       }
+       
+       /**
+        * Sample method that shouldn't be run by test suite.
+        */
+       @Test(groups = "notincluded")
+       public void shouldNotRun()
+       {
+               assert false == true : "Group specified by test shouldnt be 
run.";
+       }
+}
\ No newline at end of file

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/TestNGTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/branches/maven-surefire-plugin-testng/src/it/test6/src/test/java/TestNGTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: 
maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/test/SurefirePlugin.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/test/SurefirePlugin.java?rev=381067&r1=381066&r2=381067&view=diff
==============================================================================
--- 
maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/test/SurefirePlugin.java
 (original)
+++ 
maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/test/SurefirePlugin.java
 Sat Feb 25 23:03:08 2006
@@ -52,7 +52,15 @@
      * @parameter expression="${maven.test.skip}"
      */
     private boolean skip;
-
+    
+    /**
+     * Set this to 'true' to force all tests to be run using TestNG. This 
should be safe to do in almost all
+     * circumstances as TestNG is capable of running JUnit and TestNG tests.
+     * 
+     * @parameter expression="${maven.test.forcetestng}"
+     */
+    private boolean forceTestNG;
+    
     /**
      * Set this to true to ignore a failure during testing. Its use is NOT 
RECOMMENDED, but quite convenient on occasion.
      *
@@ -101,6 +109,14 @@
     private String reportsDirectory;
 
     /**
+     * The test source directory containing test class sources.
+     * 
+     * @parameter expression="${project.build.testSourceDirectory}"
+     * @required
+     */
+    private File testSourceDirectory;
+    
+    /**
      * Specify this parameter if you want to use the test regex notation to 
select tests to run.
      * The regular expression will be used to create an include pattern 
formatted like <code>**&#47;${test}.java</code>
      * When used, the <code>includes</code> and <code>excludes</code> patterns 
parameters are ignored
@@ -220,7 +236,51 @@
      * default-value="true"
      */
     private boolean childDelegation;
-
+    
+    /**
+     * TestNG included groups for this test. Only classes/methods/etc 
decorated with one of the 
+     * groups specified here will be included in test run, if specified.
+     * 
+     * @parameter expression="${groups}"
+     */
+    private String groups;
+    
+    /**
+     * TestNG excluded groups. Any methods/classes/etc with one of the groups 
specified in this
+     * list will specifically not be run.
+     * 
+     * @parameter expression="${excludedGroups}"
+     */
+    private String excludedGroups;
+    
+    /**
+     * List of TestNG suite xml file locations, seperated by commas. It should 
be noted that
+     * if suiteXmlFiles is specified, <b>no</b> other tests will be run, 
effectively making
+     * any other parameters, like include/exclude useless.
+     * 
+     * @parameter
+     */
+    private List suiteXmlFiles;
+    
+    /**
+     * The attribute thread-count allows you to specify how many threads 
should be allocated 
+     * for this execution. Makes most sense to use in conjunction with 
parallel.
+     * 
+     * @parameter expression="${threadCount}"
+     * default-value="0"
+     */
+    private int threadCount;
+    
+    /**
+     * When you use the parallel attribute, TestNG will try to run all your 
test methods in 
+     * separate threads, except for methods that depend on each other, which 
will be run in 
+     * the same thread in order to respect their order of execution.
+     * 
+     * @parameter expression="${parallel}"
+     * default-value="false"
+     */
+    private boolean parallel;
+    
     public void execute()
         throws MojoExecutionException
     {
@@ -245,13 +305,64 @@
         SurefireBooter surefireBooter = new SurefireBooter();
 
         // 
----------------------------------------------------------------------
+        // Forking
+        // 
----------------------------------------------------------------------        
+
+        surefireBooter.setForkMode( forkMode );
+
+        if ( !forkMode.equals( "none" ) )
+        {
+            surefireBooter.setSystemProperties( systemProperties );
+
+            surefireBooter.setJvm( jvm );
+
+            surefireBooter.setBasedir( basedir.getAbsolutePath() );
+
+            surefireBooter.setArgLine( argLine );
+            
+            surefireBooter.setEnvironmentVariables( environmentVariables );
+            
+            surefireBooter.setWorkingDirectory( workingDirectory );
+
+            surefireBooter.setChildDelegation( childDelegation );
+
+            if ( getLog().isDebugEnabled() )
+            {
+                surefireBooter.setDebug( true );
+            }
+        }
+        
+        surefireBooter.setForceTestNG(forceTestNG);
+        
+        surefireBooter.setGroups(groups);
+        
+        surefireBooter.setExcludedGroups(excludedGroups);
+        
+        surefireBooter.setThreadCount(threadCount);
+        
+        surefireBooter.setParallel(parallel);
+        
+        surefireBooter.setTestSourceDirectory(testSourceDirectory.getPath());
+        
+        // 
----------------------------------------------------------------------
         // Reporting
         // 
----------------------------------------------------------------------          
      
 
         getLog().info( "Setting reports dir: " + reportsDirectory );
 
         surefireBooter.setReportsDirectory( reportsDirectory );
-
+        
+        if (suiteXmlFiles != null && suiteXmlFiles.size() > 0) {
+                       for (int i = 0; i < suiteXmlFiles.size(); i++) {
+                               String filePath = (String)suiteXmlFiles.get(i);
+                               File file = new File(filePath);
+                               if (file.exists()) {
+                                       
surefireBooter.addBattery("org.apache.maven.surefire.battery.TestNGXMLBattery",
+                                                       new Object[] { file });
+                               }
+                       }
+        }
+        
         // 
----------------------------------------------------------------------
         // Check to see if we are running a single test. The raw parameter will
         // come through if it has not been set.
@@ -274,7 +385,8 @@
 
             surefireBooter.addBattery( 
"org.apache.maven.surefire.battery.DirectoryBattery", new 
Object[]{testClassesDirectory, includes, excludes} );
         }
-        else
+        //Only if testng suites aren't being run
+        else if (suiteXmlFiles == null || suiteXmlFiles.size() < 1)
         {
             // defaults here, qdox doesn't like the end javadoc value
             // Have to wrap in an ArrayList as surefire expects an ArrayList 
instead of a List for some reason
@@ -286,7 +398,7 @@
             {
                 excludes = new ArrayList( Arrays.asList( new 
String[]{"**/Abstract*Test.java", "**/Abstract*TestCase.java", "**/*$*"} ) );
             }
-
+            
             surefireBooter.addBattery( 
"org.apache.maven.surefire.battery.DirectoryBattery", new 
Object[]{testClassesDirectory, includes, excludes} );
         }
 
@@ -294,6 +406,25 @@
         //
         // 
----------------------------------------------------------------------
 
+        System.setProperty( "basedir", basedir.getAbsolutePath() );
+
+        System.setProperty( "localRepository", localRepository.getBasedir() );
+
+        // Add all system properties configured by the user
+        if ( systemProperties != null )
+        {
+            Enumeration propertyKeys = systemProperties.propertyNames();
+            
+            while ( propertyKeys.hasMoreElements() )
+            {
+                String key = (String) propertyKeys.nextElement();
+
+                System.setProperty( key, systemProperties.getProperty( key ) );
+
+                getLog().debug( "Setting system property [" + key + "]=[" + 
systemProperties.getProperty( key ) + "]" );
+            }
+        }
+
         getLog().debug( "Test Classpath :" );
 
         getLog().debug( testClassesDirectory.getPath() );
@@ -312,26 +443,33 @@
 
             surefireBooter.addClassPathUrl( classpathElement );
         }
-
+        
+        boolean jvm15 = false;
+        if (System.getProperty("java.version").indexOf("1.5") > -1) jvm15 = 
true;
+        
         for ( Iterator i = pluginArtifacts.iterator(); i.hasNext(); )
         {
             Artifact artifact = (Artifact) i.next();
-
+            
             // TODO: this is crude for now. We really want to get 
"surefire-booter" and all its dependencies, but the
             // artifacts don't keep track of their children. We could just 
throw all of them in, but that would add an
             // unnecessary maven-artifact dependency which is precisely the 
reason we are isolating the classloader
             if ( "junit".equals( artifact.getArtifactId() ) || 
"surefire".equals( artifact.getArtifactId() ) ||
                 "surefire-booter".equals( artifact.getArtifactId() ) ||
-                "plexus-utils".equals( artifact.getArtifactId() ) )
+                "plexus-utils".equals( artifact.getArtifactId() ) ||
+                ("testng-jdk14".equals( artifact.getArtifactId() ) 
+                               && !jvm15) ||
+                               ("testng-jdk15".equals( 
artifact.getArtifactId() ) 
+                                               && jvm15) )
             {
                 getLog().debug( "Adding to surefire test classpath: " + 
artifact.getFile().getAbsolutePath() );
-
+                
                 surefireBooter.addClassPathUrl( 
artifact.getFile().getAbsolutePath() );
             }
         }
-
+        
         addReporters( surefireBooter );
-
+        
         processSystemProperties();
 
         // 
----------------------------------------------------------------------
@@ -375,7 +513,7 @@
 
         if ( !success )
         {
-            String msg = "There are some test failure.";
+            String msg = "There are some test failures.";
 
             if ( testFailureIgnore )
             {


Reply via email to