You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2013/04/12 16:05:46 UTC

git commit: o Moved testng version resolution logic out of testng provider to reduce dependencies on forked classpath

Updated Branches:
  refs/heads/master 9b609fe7a -> 5dbb88844


o Moved testng version resolution logic out of testng provider to reduce dependencies on forked classpath


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/5dbb8884
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/5dbb8884
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/5dbb8884

Branch: refs/heads/master
Commit: 5dbb88844be17bb6b8cc5426b75451041d9ee680
Parents: 9b609fe
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Fri Apr 12 16:05:17 2013 +0200
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Fri Apr 12 16:05:17 2013 +0200

----------------------------------------------------------------------
 .../plugin/surefire/AbstractSurefireMojo.java      |   53 +++++++++-
 .../apache/maven/plugin/surefire/ProviderInfo.java |    3 +-
 .../plugin/surefire/booterclient/ForkStarter.java  |    1 +
 .../apache/maven/surefire/booter/Classpath.java    |   19 ++++
 surefire-providers/surefire-testng/pom.xml         |    5 -
 .../surefire/testng/TestNGDirectoryTestSuite.java  |   42 +++-----
 .../maven/surefire/testng/TestNGExecutor.java      |   78 +++++---------
 .../maven/surefire/testng/TestNGProvider.java      |    9 +--
 .../maven/surefire/testng/TestNGReporter.java      |    2 +-
 .../maven/surefire/testng/TestNGXmlTestSuite.java  |   24 ++---
 10 files changed, 127 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5dbb8884/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 815c4fa..a73c429 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -44,6 +44,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.VersionRange;
@@ -879,7 +880,7 @@ public abstract class AbstractSurefireMojo
      * Converts old TestNG configuration parameters over to new properties based configuration
      * method. (if any are defined the old way)
      */
-    private void convertTestNGParameters()
+    private void convertTestNGParameters() throws MojoExecutionException
     {
         if ( this.getParallel() != null )
         {
@@ -901,9 +902,51 @@ public abstract class AbstractSurefireMojo
             getProperties().setProperty( "testng.test.classpath", getTestClassesDirectory().getAbsolutePath() );
         }
 
+        Artifact testNgArtifact = getTestNgArtifact();
+        if ( testNgArtifact != null){
 
+            DefaultArtifactVersion defaultArtifactVersion = new DefaultArtifactVersion( testNgArtifact.getVersion() );
+            getProperties().setProperty( "testng.configurator", getConfiguratorName( defaultArtifactVersion ) );
+        }
+
+
+    }
+
+    private static String getConfiguratorName( ArtifactVersion version )
+        throws MojoExecutionException
+    {
+        try
+        {
+            VersionRange range = VersionRange.createFromVersionSpec( "[4.7,5.1]" );
+            if ( range.containsVersion( version ) )
+            {
+                return "org.apache.maven.surefire.testng.conf.TestNG4751Configurator";
+            }
+            range = VersionRange.createFromVersionSpec( "[5.2]" );
+            if ( range.containsVersion( version ) )
+            {
+                return "org.apache.maven.surefire.testng.conf.TestNG52Configurator";
+            }
+            range = VersionRange.createFromVersionSpec( "[5.3,6.4]" );
+            if ( range.containsVersion( version ) )
+            {
+                return "org.apache.maven.surefire.testng.conf.TestNGMapConfigurator";
+            }
+            range = VersionRange.createFromVersionSpec( "[6.5,)" );
+            if ( range.containsVersion( version ) )
+            {
+                return "org.apache.maven.surefire.testng.conf.TestNG652Configurator";
+            }
+
+            throw new MojoExecutionException( "Unknown TestNG version " + version );
+        }
+        catch ( InvalidVersionSpecificationException invsex )
+        {
+            throw new MojoExecutionException( "Bug in plugin. Please report it with the attached stacktrace", invsex );
+        }
     }
 
+
     private void convertGroupParameters()
     {
         if ( this.getExcludedGroups() != null )
@@ -1099,6 +1142,10 @@ public abstract class AbstractSurefireMojo
 
             getLog().debug( testClasspath.getLogMessage( "test" ) );
             getLog().debug( providerClasspath.getLogMessage( "provider" ) );
+
+            getLog().debug( testClasspath.getCompactLogMessage( "test(compact)" ) );
+            getLog().debug( providerClasspath.getCompactLogMessage( "provider(compact)" ) );
+
             final ClasspathConfiguration classpathConfiguration =
                 new ClasspathConfiguration( testClasspath, providerClasspath, inprocClassPath,
                                             effectiveIsEnableAssertions(), isChildDelegation() );
@@ -1906,7 +1953,7 @@ public abstract class AbstractSurefireMojo
             return testNgArtifact != null;
         }
 
-        public void addProviderProperties()
+        public void addProviderProperties() throws MojoExecutionException
         {
             convertTestNGParameters();
         }
@@ -2056,7 +2103,7 @@ public abstract class AbstractSurefireMojo
             return true;
         }
 
-        public void addProviderProperties()
+        public void addProviderProperties() throws MojoExecutionException
         {
             // Ok this is a bit lazy.
             convertJunitCoreParameters();

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5dbb8884/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java
index a75ad1e..57069d8 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java
@@ -21,6 +21,7 @@ package org.apache.maven.plugin.surefire;
 
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.surefire.booter.Classpath;
 
 /**
@@ -35,5 +36,5 @@ public interface ProviderInfo
     Classpath getProviderClasspath()
         throws ArtifactResolutionException, ArtifactNotFoundException;
 
-    void addProviderProperties();
+    void addProviderProperties() throws MojoExecutionException;
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5dbb8884/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
index 6203609..a21ce3c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
@@ -402,6 +402,7 @@ public class ForkStarter
         if ( log.isDebugEnabled() )
         {
             log.debug( bootClasspath.getLogMessage( "boot" ) );
+            log.debug( bootClasspath.getCompactLogMessage( "boot(compact)" ) );
         }
         OutputStreamFlushableCommandline cli =
             forkConfiguration.createCommandLine( bootClasspath.getClassPath(), startupConfiguration, forkNumber );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5dbb8884/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
index 286752d..93c3f00 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
@@ -178,4 +178,23 @@ public class Classpath
         }
         return result.toString();
     }
+    public String getCompactLogMessage( String descriptor )
+    {
+        StringBuilder result = new StringBuilder();
+        result.append( descriptor ).append( " classpath:" );
+        for ( String element : elements )
+        {
+            result.append( "  " );
+            if (element != null){
+                int pos = element.lastIndexOf( File.separatorChar );
+                if (pos >= 0){
+                result.append(  element.substring(  pos + 1) );
+                } else
+                    result.append( element);
+
+            } else result.append(element);
+        }
+        return result.toString();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5dbb8884/surefire-providers/surefire-testng/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/pom.xml b/surefire-providers/surefire-testng/pom.xml
index 7578437..8c86f42 100644
--- a/surefire-providers/surefire-testng/pom.xml
+++ b/surefire-providers/surefire-testng/pom.xml
@@ -33,11 +33,6 @@
 
   <dependencies>
     <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-artifact</artifactId>
-      <version>2.0</version>
-    </dependency>
-    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.2</version>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5dbb8884/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
index d04e77c..b0d4631 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
@@ -29,8 +29,6 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.SortedMap;
 import java.util.TreeMap;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.surefire.NonAbstractClassFilter;
 import org.apache.maven.surefire.report.ConsoleOutputCapture;
 import org.apache.maven.surefire.report.ConsoleOutputReceiver;
@@ -40,7 +38,6 @@ import org.apache.maven.surefire.report.ReporterFactory;
 import org.apache.maven.surefire.report.RunListener;
 import org.apache.maven.surefire.report.SimpleReportEntry;
 import org.apache.maven.surefire.testset.TestSetFailedException;
-import org.apache.maven.surefire.util.LazyTestsToRun;
 import org.apache.maven.surefire.util.RunOrderCalculator;
 import org.apache.maven.surefire.util.ScanResult;
 import org.apache.maven.surefire.util.TestsToRun;
@@ -54,7 +51,6 @@ import org.apache.maven.surefire.util.TestsToRun;
 public class TestNGDirectoryTestSuite
     implements TestNgTestSuite
 {
-    private final ArtifactVersion version;
 
     private final Map options;
 
@@ -64,7 +60,7 @@ public class TestNGDirectoryTestSuite
 
     private final File reportsDirectory;
 
-    private SortedMap testSets;
+    private SortedMap<String, TestNGTestSet> testSets;
 
     private final ScanResult scanResult;
 
@@ -74,8 +70,7 @@ public class TestNGDirectoryTestSuite
 
     private final Class junitTestClass;
 
-    public TestNGDirectoryTestSuite( String testSourceDirectory, String artifactVersion, Properties confOptions,
-                                     File reportsDirectory, String testMethodPattern,
+    public TestNGDirectoryTestSuite( String testSourceDirectory, Properties confOptions, File reportsDirectory, String testMethodPattern,
                                      RunOrderCalculator runOrderCalculator, ScanResult scanResult )
     {
 
@@ -86,7 +81,6 @@ public class TestNGDirectoryTestSuite
         this.testSourceDirectory = testSourceDirectory;
         this.reportsDirectory = reportsDirectory;
         this.scanResult = scanResult;
-        this.version = new DefaultArtifactVersion( artifactVersion );
         this.testMethodPattern = testMethodPattern;
         this.junitTestClass = findJUnitTestClass();
         this.junitOptions = createJUnitOptions();
@@ -106,7 +100,7 @@ public class TestNGDirectoryTestSuite
         }
         else if ( testsToRun.containsAtLeast( 1 ) )
         {
-            Class testClass = (Class) testsToRun.iterator().next();
+            Class testClass = testsToRun.iterator().next();
             executeSingleClass( reporterManagerFactory, testClass );
         }
     }
@@ -123,7 +117,7 @@ public class TestNGDirectoryTestSuite
 
         final Map optionsToUse = isJUnitTest( testClass ) ? junitOptions : options;
 
-        TestNGExecutor.run( new Class[]{ testClass }, testSourceDirectory, optionsToUse, version, reporter, this,
+        TestNGExecutor.run( new Class[]{ testClass }, testSourceDirectory, optionsToUse, reporter, this,
                             reportsDirectory, testMethodPattern );
 
         finishTestSuite( reporter, this );
@@ -133,9 +127,8 @@ public class TestNGDirectoryTestSuite
         throws ReporterException, TestSetFailedException
     {
 
-        for ( Iterator testClassIt = testsToRun.iterator(); testClassIt.hasNext(); )
+        for ( Class c : testsToRun )
         {
-            Class c = (Class) testClassIt.next();
             executeSingleClass( reporterFactory, c );
         }
     }
@@ -157,11 +150,10 @@ public class TestNGDirectoryTestSuite
     public void executeMulti( TestsToRun testsToRun, ReporterFactory reporterFactory )
         throws ReporterException, TestSetFailedException
     {
-        List testNgTestClasses = new ArrayList();
-        List junitTestClasses = new ArrayList();
-        for ( Iterator it = testsToRun.iterator(); it.hasNext(); )
+        List<Class> testNgTestClasses = new ArrayList<Class>();
+        List<Class> junitTestClasses = new ArrayList<Class>();
+        for ( Class c : testsToRun )
         {
-            Class c = (Class) it.next();
             if ( isJUnitTest( c ) )
             {
                 junitTestClasses.add( c );
@@ -184,16 +176,16 @@ public class TestNGDirectoryTestSuite
         ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporterManager );
         startTestSuite( reporterManager, this );
 
-        Class[] testClasses = (Class[]) testNgTestClasses.toArray( new Class[testNgTestClasses.size()] );
+        Class[] testClasses = testNgTestClasses.toArray( new Class[testNgTestClasses.size()] );
 
-        TestNGExecutor.run( testClasses, this.testSourceDirectory, options, version, reporterManager, this,
+        TestNGExecutor.run( testClasses, this.testSourceDirectory, options, reporterManager, this,
                             testNgReportsDirectory, testMethodPattern );
 
         if ( junitTestClasses.size() > 0 )
         {
-            testClasses = (Class[]) junitTestClasses.toArray( new Class[junitTestClasses.size()] );
+            testClasses = junitTestClasses.toArray( new Class[junitTestClasses.size()] );
 
-            TestNGExecutor.run( testClasses, testSourceDirectory, junitOptions, version, reporterManager, this,
+            TestNGExecutor.run( testClasses, testSourceDirectory, junitOptions, reporterManager, this,
                                 junitReportsDirectory, testMethodPattern );
         }
 
@@ -220,7 +212,7 @@ public class TestNGDirectoryTestSuite
         {
             throw new IllegalStateException( "You must call locateTestSets before calling execute" );
         }
-        TestNGTestSet testSet = (TestNGTestSet) testSets.get( testSetName );
+        TestNGTestSet testSet = testSets.get( testSetName );
 
         if ( testSet == null )
         {
@@ -232,8 +224,7 @@ public class TestNGDirectoryTestSuite
 
         startTestSuite( reporter, this );
 
-        TestNGExecutor.run( new Class[]{ testSet.getTestClass() }, this.testSourceDirectory, this.options, this.version,
-                            reporter, this, reportsDirectory, testMethodPattern );
+        TestNGExecutor.run( new Class[]{ testSet.getTestClass() }, this.testSourceDirectory, this.options, reporter, this, reportsDirectory, testMethodPattern );
 
         finishTestSuite( reporter, this );
     }
@@ -296,15 +287,14 @@ public class TestNGDirectoryTestSuite
         {
             throw new IllegalStateException( "You can't call locateTestSets twice" );
         }
-        testSets = new TreeMap();
+        testSets = new TreeMap<String, TestNGTestSet>();
 
         final TestsToRun scanned = scanResult.applyFilter( new NonAbstractClassFilter(), classLoader );
 
         final TestsToRun testsToRun = runOrderCalculator.orderTestClasses( scanned );
 
-        for ( Iterator it = testsToRun.iterator(); it.hasNext(); )
+        for ( Class testClass : testsToRun )
         {
-            Class testClass = (Class) it.next();
             TestNGTestSet testSet = new TestNGTestSet( testClass );
 
             if ( testSets.containsKey( testSet.getName() ) )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5dbb8884/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
index b2029bd..d4a6ac8 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
@@ -19,28 +19,21 @@ package org.apache.maven.surefire.testng;
  * under the License.
  */
 
-import java.io.File;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.surefire.booter.ProviderParameterNames;
 import org.apache.maven.surefire.report.RunListener;
 import org.apache.maven.surefire.testng.conf.Configurator;
-import org.apache.maven.surefire.testng.conf.TestNG4751Configurator;
-import org.apache.maven.surefire.testng.conf.TestNG52Configurator;
-import org.apache.maven.surefire.testng.conf.TestNG652Configurator;
-import org.apache.maven.surefire.testng.conf.TestNGMapConfigurator;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.NestedRuntimeException;
 import org.apache.maven.surefire.util.internal.StringUtils;
-
 import org.testng.TestNG;
 
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+
 /**
  * Contains utility methods for executing TestNG.
  *
@@ -56,9 +49,8 @@ public class TestNGExecutor
         // noop
     }
 
-    public static void run( Class[] testClasses, String testSourceDirectory, Map options, ArtifactVersion version,
-                            RunListener reportManager, TestNgTestSuite suite, File reportsDirectory,
-                            final String methodNamePattern )
+    public static void run( Class[] testClasses, String testSourceDirectory, Map options, RunListener reportManager,
+                            TestNgTestSuite suite, File reportsDirectory, final String methodNamePattern )
         throws TestSetFailedException
     {
         TestNG testng = new TestNG( true );
@@ -69,7 +61,7 @@ public class TestNGExecutor
             applyMethodNameFiltering( testng, methodNamePattern );
         }
 
-        Configurator configurator = getConfigurator( version );
+        Configurator configurator = getConfigurator( (String) options.get("testng.configurator" ) );
         System.out.println( "Configuring TestNG with: " + configurator.getClass().getSimpleName() );
         configurator.configure( testng, options );
         postConfigure( testng, testSourceDirectory, reportManager, suite, reportsDirectory );
@@ -89,7 +81,7 @@ public class TestNGExecutor
             Class clazz = Class.forName( clazzName );
 
             Method method = clazz.getMethod( "setMethodName", new Class[]{ String.class } );
-            method.invoke( null, new Object[]{ methodNamePattern } );
+            method.invoke( null, methodNamePattern );
         }
         catch ( ClassNotFoundException e )
         {
@@ -138,7 +130,7 @@ public class TestNGExecutor
 
             // HORRIBLE hack, but TNG doesn't allow us to setup a method selector instance directly.
             Method method = clazz.getMethod( "setGroups", new Class[]{ String.class, String.class } );
-            method.invoke( null, new Object[]{ groups, excludedGroups } );
+            method.invoke( null, groups, excludedGroups );
         }
         catch ( ClassNotFoundException e )
         {
@@ -166,49 +158,35 @@ public class TestNGExecutor
         }
     }
 
-    public static void run( List suiteFiles, String testSourceDirectory, Map options, ArtifactVersion version,
-                            RunListener reportManager, TestNgTestSuite suite, File reportsDirectory )
+    public static void run( List<String> suiteFiles, String testSourceDirectory, Map options, RunListener reportManager,
+                            TestNgTestSuite suite, File reportsDirectory )
         throws TestSetFailedException
     {
         TestNG testng = new TestNG( true );
-        Configurator configurator = getConfigurator( version );
+        Configurator configurator = getConfigurator( (String) options.get("testng.configurator" ) );
         configurator.configure( testng, options );
         postConfigure( testng, testSourceDirectory, reportManager, suite, reportsDirectory );
         testng.setTestSuites( suiteFiles );
         testng.run();
     }
 
-    private static Configurator getConfigurator( ArtifactVersion version )
-        throws TestSetFailedException
+    private static Configurator getConfigurator( String className )
     {
         try
         {
-            VersionRange range = VersionRange.createFromVersionSpec( "[4.7,5.1]" );
-            if ( range.containsVersion( version ) )
-            {
-                return new TestNG4751Configurator();
-            }
-            range = VersionRange.createFromVersionSpec( "[5.2]" );
-            if ( range.containsVersion( version ) )
-            {
-                return new TestNG52Configurator();
-            }
-            range = VersionRange.createFromVersionSpec( "[5.3,6.4]" );
-            if ( range.containsVersion( version ) )
-            {
-                return new TestNGMapConfigurator();
-            }
-            range = VersionRange.createFromVersionSpec( "[6.5,)" );
-            if ( range.containsVersion( version ) )
-            {
-                return new TestNG652Configurator();
-            }
-
-            throw new TestSetFailedException( "Unknown TestNG version " + version );
+            return (Configurator) Class.forName( className ).newInstance();
+        }
+        catch ( InstantiationException e )
+        {
+            throw new RuntimeException( e );
         }
-        catch ( InvalidVersionSpecificationException invsex )
+        catch ( IllegalAccessException e )
+        {
+            throw new RuntimeException( e );
+        }
+        catch ( ClassNotFoundException e )
         {
-            throw new TestSetFailedException( "Bug in plugin. Please report it with the attached stacktrace", invsex );
+            throw new RuntimeException( e );
         }
     }
 
@@ -243,7 +221,7 @@ public class TestNGExecutor
             try
             {
                 Constructor ctor = c.getConstructor( new Class[]{ RunListener.class, TestNgTestSuite.class } );
-                return (TestNGReporter) ctor.newInstance( new Object[]{ reportManager, suite } );
+                return (TestNGReporter) ctor.newInstance( reportManager, suite );
             }
             catch ( Exception e )
             {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5dbb8884/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
index a24e683..ff3eaac 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
@@ -27,7 +27,6 @@ import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterFactory;
 import org.apache.maven.surefire.suite.RunResult;
-import org.apache.maven.surefire.testset.TestArtifactInfo;
 import org.apache.maven.surefire.testset.TestRequest;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.NestedRuntimeException;
@@ -44,8 +43,6 @@ public class TestNGProvider
 {
     private final Properties providerProperties;
 
-    private final TestArtifactInfo testArtifactInfo;
-
     private final ReporterConfiguration reporterConfiguration;
 
     private final ClassLoader testClassLoader;
@@ -67,7 +64,6 @@ public class TestNGProvider
         this.runOrderCalculator = booterParameters.getRunOrderCalculator();
         this.providerProperties = booterParameters.getProviderProperties();
         this.testRequest = booterParameters.getTestRequest();
-        testArtifactInfo = booterParameters.getTestArtifactInfo();
         reporterConfiguration = booterParameters.getReporterConfiguration();
         this.scanResult = booterParameters.getScanResult();
     }
@@ -130,8 +126,7 @@ public class TestNGProvider
 
     private TestNGDirectoryTestSuite getDirectorySuite()
     {
-        return new TestNGDirectoryTestSuite( testRequest.getTestSourceDirectory().toString(),
-                                             testArtifactInfo.getVersion(), providerProperties,
+        return new TestNGDirectoryTestSuite( testRequest.getTestSourceDirectory().toString(), providerProperties,
                                              reporterConfiguration.getReportsDirectory(),
                                              testRequest.getRequestedTestMethod(), runOrderCalculator, scanResult );
     }
@@ -139,7 +134,7 @@ public class TestNGProvider
     private TestNGXmlTestSuite getXmlSuite()
     {
         return new TestNGXmlTestSuite( testRequest.getSuiteXmlFiles(), testRequest.getTestSourceDirectory().toString(),
-                                       testArtifactInfo.getVersion(), providerProperties,
+                                       providerProperties,
                                        reporterConfiguration.getReportsDirectory() );
     }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5dbb8884/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
index 2e979d3..cf3df4b 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGReporter.java
@@ -163,7 +163,7 @@ public class TestNGReporter
         String retVal;
         if ( groups != null && groups.length > 0 )
         {
-            StringBuffer str = new StringBuffer();
+            StringBuilder str = new StringBuilder();
             for ( int i = 0; i < groups.length; i++ )
             {
                 str.append( groups[i] );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/5dbb8884/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
index 48b6011..8448a2d 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
@@ -22,12 +22,9 @@ package org.apache.maven.surefire.testng;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.surefire.report.ConsoleOutputCapture;
 import org.apache.maven.surefire.report.ConsoleOutputReceiver;
 import org.apache.maven.surefire.report.ReporterException;
@@ -46,32 +43,27 @@ public class TestNGXmlTestSuite
 {
     private final List suiteFiles;
 
-    private List suiteFilePaths;
+    private List<String> suiteFilePaths;
 
     private final String testSourceDirectory;
 
-    private final ArtifactVersion version;
-
     private final Map options;
 
     private final File reportsDirectory;
 
     // Not really used
-    private Map testSets;
+    private Map<File,String> testSets;
 
     /**
      * Creates a testng testset to be configured by the specified
      * xml file(s). The XML files are suite definitions files according to TestNG DTD.
      */
-    public TestNGXmlTestSuite( List<File> suiteFiles, String testSourceDirectory, String artifactVersion,
-                               Properties confOptions, File reportsDirectory )
+    public TestNGXmlTestSuite( List<File> suiteFiles, String testSourceDirectory, Properties confOptions, File reportsDirectory )
     {
         this.suiteFiles = suiteFiles;
 
         this.options = confOptions;
 
-        this.version = new DefaultArtifactVersion( artifactVersion );
-
         this.testSourceDirectory = testSourceDirectory;
 
         this.reportsDirectory = reportsDirectory;
@@ -89,7 +81,7 @@ public class TestNGXmlTestSuite
         ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter );
 
         TestNGDirectoryTestSuite.startTestSuite( reporter, this );
-        TestNGExecutor.run( this.suiteFilePaths, this.testSourceDirectory, this.options, this.version, reporter, this,
+        TestNGExecutor.run( this.suiteFilePaths, this.testSourceDirectory, this.options, reporter, this,
                             reportsDirectory );
         TestNGDirectoryTestSuite.finishTestSuite( reporter, this );
     }
@@ -113,12 +105,12 @@ public class TestNGXmlTestSuite
             throw new IllegalStateException( "No suite files were specified" );
         }
 
-        this.testSets = new HashMap();
-        this.suiteFilePaths = new ArrayList();
+        this.testSets = new HashMap<File,String>();
+        this.suiteFilePaths = new ArrayList<String>();
 
-        for ( Iterator i = suiteFiles.iterator(); i.hasNext(); )
+        for ( Object suiteFile : suiteFiles )
         {
-            File file = (File) i.next();
+            File file = (File) suiteFile;
             if ( !file.exists() || !file.isFile() )
             {
                 throw new TestSetFailedException( "Suite file " + file + " is not a valid file" );