You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2015/12/15 01:30:38 UTC

[1/2] maven-surefire git commit: [SUREFIRE-1194] reporter argument does not work for TestNG 5.14.3 and later

Repository: maven-surefire
Updated Branches:
  refs/heads/master af4414138 -> 2261bcea6


[SUREFIRE-1194] reporter argument does not work for TestNG 5.14.3 and later

Improve tests
Change type for the reporter param
Run unit tests for TestNG

Typo in TestNG513ConfiguratorTest

Fix tests

Update documentation

Fail or warn with bad TestNG versions


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

Branch: refs/heads/master
Commit: 7fe7a2a3b7c725a6d1e9f920dffcbd05013ade03
Parents: af44141
Author: Julien Herr <ju...@herr.fr>
Authored: Fri Nov 20 22:56:52 2015 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Tue Dec 15 01:29:31 2015 +0100

----------------------------------------------------------------------
 .../plugin/surefire/AbstractSurefireMojo.java   | 31 +++++++-
 .../src/site/apt/examples/testng.apt.vm         | 10 +++
 .../its/CheckTestNgListenerReporterIT.java      | 50 +++++++++++--
 .../resources/testng-listener-reporter/pom.xml  |  7 ++
 surefire-providers/surefire-testng/pom.xml      | 11 ---
 .../testng/conf/TestNG513Configurator.java      | 64 ++++++++++++++++
 .../testng/conf/TestNG5141Configurator.java     | 38 ++++++++++
 .../testng/conf/TestNG5143Configurator.java     | 58 +++++++++++++++
 .../testng/conf/TestNG60Configurator.java       |  2 +-
 .../testng/conf/TestNGMapConfigurator.java      | 12 ++-
 .../testng/conf/TestNG513ConfiguratorTest.java  | 72 ++++++++++++++++++
 .../testng/conf/TestNG5141ConfiguratorTest.java | 78 ++++++++++++++++++++
 .../testng/conf/TestNG5143ConfiguratorTest.java | 72 ++++++++++++++++++
 .../testng/conf/TestNGMapConfiguratorTest.java  | 14 +++-
 14 files changed, 493 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/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 ca3a4be..3e0d840 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
@@ -1116,11 +1116,12 @@ public abstract class AbstractSurefireMojo
         if ( testNgArtifact != null )
         {
             DefaultArtifactVersion defaultArtifactVersion = new DefaultArtifactVersion( testNgArtifact.getVersion() );
-            getProperties().setProperty( "testng.configurator", getConfiguratorName( defaultArtifactVersion ) );
+            getProperties().setProperty( "testng.configurator", getConfiguratorName( defaultArtifactVersion,
+                                                                                     getLog() ) );
         }
     }
 
-    private static String getConfiguratorName( ArtifactVersion version )
+    private static String getConfiguratorName( ArtifactVersion version, Log log )
         throws MojoExecutionException
     {
         try
@@ -1140,11 +1141,35 @@ public abstract class AbstractSurefireMojo
             {
                 return "org.apache.maven.surefire.testng.conf.TestNGMapConfigurator";
             }
-            range = VersionRange.createFromVersionSpec( "[5.10,6.5)" );
+            range = VersionRange.createFromVersionSpec( "[5.10,5.13)" );
             if ( range.containsVersion( version ) )
             {
                 return "org.apache.maven.surefire.testng.conf.TestNG510Configurator";
             }
+            range = VersionRange.createFromVersionSpec( "[5.13,5.14.1)" );
+            if ( range.containsVersion( version ) )
+            {
+                return "org.apache.maven.surefire.testng.conf.TestNG513Configurator";
+            }
+            range = VersionRange.createFromVersionSpec( "[5.14.1,5.14.3)" );
+            if ( range.containsVersion( version ) )
+            {
+                return "org.apache.maven.surefire.testng.conf.TestNG5141Configurator";
+            }
+            range = VersionRange.createFromVersionSpec( "[5.14.3,6.0)" );
+            if ( range.containsVersion( version ) )
+            {
+                if ( version.equals( new DefaultArtifactVersion( "5.14.3" ) ) )
+                {
+                    throw new MojoExecutionException( "Due to a bad formatted pom.xml, "
+                                                      + "TestNG 5.14.3 is not supported" );
+                }
+                if ( VersionRange.createFromVersionSpec( "[5.14.4,5.14.5]" ).containsVersion( version ) )
+                {
+                    log.warn( "Due to a bad formatted pom.xml, TestNG 5.14.4 and 5.14.5 may not work" );
+                }
+                return "org.apache.maven.surefire.testng.conf.TestNG5143Configurator";
+            }
             range = VersionRange.createFromVersionSpec( "[6.0,)" );
             if ( range.containsVersion( version ) )
             {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
index be19905..85a6349 100644
--- a/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
@@ -28,6 +28,11 @@
 
 Using TestNG
 
+* Unsupported TestNG versions
+
+  - TestNG 5.14.3: Bad formatted pom.xml.
+  - TestNG 5.14.4 and 5.14.5: TestNG is using a missing dependency (org.testng:guice:2.0). Excluding it, may break some features.
+
 * Configuring TestNG
 
   To get started with TestNG, include the following dependency in your project (replacing the version with the one you wish to use):
@@ -230,6 +235,11 @@ Using TestNG
   TestNG provides support for attaching custom listeners, reporters, annotation transformers and method interceptors to your tests.
   By default, TestNG attaches a few basic listeners to generate HTML and XML reports.
 
+  Unsupported versions:
+    - TestNG 5.14.1 and 5.14.2: Due to an internal TestNG issue, listeners and reporters are not working with TestNG.
+           Please upgrade TestNG to version 5.14.9 or higher.
+           Note: It may be fixed in a future surefire version.
+
   You can configure multiple custom listeners like this:
 
 +---+

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
index af46906..8e25e5d 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
@@ -21,7 +21,13 @@ package org.apache.maven.surefire.its;
 
 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
+import org.junit.After;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+import java.util.Collection;
 
 /**
  * Test simple TestNG listener and reporter
@@ -29,16 +35,48 @@ import org.junit.Test;
  * @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
  * @author <a href="mailto:krosenvold@apache.org">Kristian Rosenvold</a>
  */
+@RunWith(Parameterized.class)
 public class CheckTestNgListenerReporterIT
     extends SurefireJUnit4IntegrationTestCase
 {
-    @Test
-    public void TestNgListenerReporter()
+
+    @Parameterized.Parameters(name = "{index}: TestNG {0}")
+    public static Collection<Object[]> data()
     {
-        final SurefireLauncher verifierStarter = unpack( "testng-listener-reporter" );
-        verifierStarter.executeTest().verifyErrorFree( 1 ).getTargetFile(
-            "resultlistener-output.txt" ).assertFileExists().getTargetFile(
-            "suitelistener-output.txt" ).assertFileExists().getTargetFile( "reporter-output.txt" ).assertFileExists();
+        return Arrays.asList(new Object[][] {
+            { "5.6" }, // First TestNG version with reporter support
+            { "5.7" }, // default version from pom of the test case
+            { "5.10" },
+            { "5.13" }, // "reporterslist" param becomes String instead of List<ReporterConfig>
+                        // "listener" param becomes String instead of List<Class>
+            //{ "5.14.1" }, // "listener" param becomes List instead of String
+                            // Fails: Issue with 5.14.1 and 5.14.2 => join with <space>, split with ","
+                            // TODO will work with "configure(CommandLineArgs)"
+            //{ "5.14.2" }, // ReporterConfig is not available
+            //{ "5.14.3" }, // TestNG uses "reporter" instead of "reporterslist"
+                          // Both String or List are possible for "listener"
+                          // Fails: Bad formatted pom => transitive dependencies are missing
+            { "5.14.4" }, // Usage of org.testng:guice
+                          // Caution: Some TestNG features may fail with 5.14.4 and 5.14.5 due to missing dependency
+            { "5.14.6" }, // Usage of org.testng:guice removed
+            { "5.14.9" }, // Latest 5.14.x TestNG version
+            { "6.0" },
+            { "6.9.9" } // Current latest TestNG version
+        });
     }
 
+    @Parameterized.Parameter
+    public String version;
+    private SurefireLauncher verifierStarter;
+
+    @Test
+    public void testNgListenerReporter()
+    {
+        verifierStarter = unpack( "testng-listener-reporter", "_" + version );
+        verifierStarter.resetInitialGoals( version );
+        verifierStarter.executeTest().verifyErrorFree( 1 )
+            .getTargetFile( "resultlistener-output.txt" ).assertFileExists()
+            .getTargetFile( "suitelistener-output.txt" ).assertFileExists()
+            .getTargetFile( "reporter-output.txt" ).assertFileExists();
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml b/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml
index 3235638..b39c11b 100644
--- a/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml
+++ b/surefire-integration-tests/src/test/resources/testng-listener-reporter/pom.xml
@@ -53,6 +53,13 @@
           <groupId>org.testng</groupId>
           <artifactId>testng</artifactId>
           <version>${testNgVersion}</version>
+          <exclusions>
+            <exclusion>
+              <!-- Excluded for 5.14.3, 5.14.4 and 5.14.5 which depend on this artifact -->
+              <groupId>org.testng</groupId>
+              <artifactId>guice</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
       </dependencies>
     </profile>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-providers/surefire-testng/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/pom.xml b/surefire-providers/surefire-testng/pom.xml
index ebff6c4..baa9f76 100644
--- a/surefire-providers/surefire-testng/pom.xml
+++ b/surefire-providers/surefire-testng/pom.xml
@@ -64,16 +64,5 @@
         <targetPath>META-INF</targetPath>
       </resource>
     </resources>
-
-    <plugins>
-      <plugin>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <!-- DGF There are no tests in this project currently, and this
-            resolves SUREFIRE-414 -->
-          <skipExec>true</skipExec>
-        </configuration>
-      </plugin>
-    </plugins>
   </build>
 </project>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
new file mode 100644
index 0000000..f38df08
--- /dev/null
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
@@ -0,0 +1,64 @@
+package org.apache.maven.surefire.testng.conf;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+/**
+ * TestNG 5.13 configurator. Changed: "reporterslist" need String instead of List<ReporterConfig>.
+ */
+public class TestNG513Configurator
+    extends TestNG510Configurator
+{
+
+    @Override
+    protected Object convertReporterConfig( String val )
+    {
+        return val;
+    }
+
+    @Override
+    protected Object convertListeners( String listenerClasses ) throws TestSetFailedException
+    {
+        return convertListenersString( listenerClasses );
+    }
+
+    static String convertListenersString( String listenerClasses )
+    {
+        if ( listenerClasses == null || "".equals( listenerClasses.trim() ) )
+        {
+            return listenerClasses;
+        }
+
+        StringBuilder sb = new StringBuilder();
+        String[] classNames = listenerClasses.split( "\\s*,\\s*(\\r?\\n)?\\s*" );
+        for ( int i = 0; i < classNames.length; i++ )
+        {
+            String className = classNames[i];
+            sb.append( className );
+            if ( i < classNames.length - 1 )
+            {
+                sb.append( ',' );
+            }
+        }
+
+        return sb.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5141Configurator.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5141Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5141Configurator.java
new file mode 100644
index 0000000..49f0579
--- /dev/null
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5141Configurator.java
@@ -0,0 +1,38 @@
+package org.apache.maven.surefire.testng.conf;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+/**
+ * TestNG 5.14.1 configurator. Changed: "listener" use List instead of String.
+ */
+public class TestNG5141Configurator
+    extends TestNG513Configurator
+{
+
+    @Override
+    protected Object convertListeners( String listenerClasses ) throws TestSetFailedException
+    {
+        // TODO "configure(CommandLineArgs)", which should replace "configure(Map)", doesn't have the issue
+        throw new TestSetFailedException( "Due to an internal TestNG issue, "
+                                          + "the listener feature of TestNG is not supported with 5.14.1 and 5.14.2" );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java
new file mode 100644
index 0000000..5575ccf
--- /dev/null
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG5143Configurator.java
@@ -0,0 +1,58 @@
+package org.apache.maven.surefire.testng.conf;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+/**
+ * TestNG 5.14.3 configurator. Changed: "reporterslist" replaced by "reporter",
+ *                                       and "listener" can use String instead of List<Class>.
+ */
+public class TestNG5143Configurator
+    extends TestNG5141Configurator
+{
+
+    @Override
+    Map<String, Object> getConvertedOptions( Map<String, String> options )
+            throws TestSetFailedException
+    {
+        Map<String, Object> convertedOptions = super.getConvertedOptions( options );
+        for ( Map.Entry<String, Object> entry : convertedOptions.entrySet() )
+        {
+            String key = entry.getKey();
+            if ( "-reporterslist".equals( key ) )
+            {
+                convertedOptions.remove( "-reporterslist" );
+                Object value = entry.getValue();
+                convertedOptions.put( "-reporter", value );
+                break;
+            }
+        }
+        return convertedOptions;
+    }
+
+
+    @Override
+    protected Object convertListeners( String listenerClasses ) throws TestSetFailedException
+    {
+        return convertListenersString( listenerClasses );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java
index 531d85e..e374001 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG60Configurator.java
@@ -31,7 +31,7 @@ import org.apache.maven.surefire.testset.TestSetFailedException;
  * @since 2.13
  */
 public class TestNG60Configurator
-    extends TestNG510Configurator
+    extends TestNG5143Configurator
 {
 
     Map<String, Object> getConvertedOptions( Map<String, String> options )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
index 50c1047..fcf9a91 100755
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
@@ -77,7 +77,7 @@ public class TestNGMapConfigurator
             Object val = entry.getValue();
             if ( "listener".equals( key ) )
             {
-                val = AbstractDirectConfigurator.loadListenerClasses( entry.getValue() );
+                val = convertListeners( entry.getValue() );
             }
             else if ( "objectfactory".equals( key ) )
             {
@@ -89,8 +89,9 @@ public class TestNGMapConfigurator
             }
             else if ( "reporter".equals( key ) )
             {
+                // for TestNG 5.6 or higher
                 // TODO support multiple reporters?
-                val = convertReporterConfig( val );
+                val = convertReporterConfig( entry.getValue() );
                 key = "reporterslist";
             }
             else if ( "junit".equals( key ) )
@@ -141,7 +142,7 @@ public class TestNGMapConfigurator
     }
 
     // ReporterConfig only became available in later versions of TestNG
-    private Object convertReporterConfig( Object val )
+    protected Object convertReporterConfig( String val )
     {
         final String reporterConfigClassName = "org.testng.ReporterConfig";
         try
@@ -159,6 +160,11 @@ public class TestNGMapConfigurator
         }
     }
 
+    protected Object convertListeners( String listenerClasses ) throws TestSetFailedException
+    {
+        return AbstractDirectConfigurator.loadListenerClasses( listenerClasses );
+    }
+
     protected Object convert( Object val, Class<?> type )
     {
         if ( val == null )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG513ConfiguratorTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG513ConfiguratorTest.java b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG513ConfiguratorTest.java
new file mode 100644
index 0000000..1fbcda1
--- /dev/null
+++ b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG513ConfiguratorTest.java
@@ -0,0 +1,72 @@
+package org.apache.maven.surefire.testng.conf;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.FIRST_LISTENER;
+import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.LISTENER_PROP;
+import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.SECOND_LISTENER;
+
+public class TestNG513ConfiguratorTest
+    extends TestCase
+{
+
+    public void testListenersOnSeparateLines()
+            throws Exception
+    {
+        String listenersOnSeveralLines = String.format( "%s , %n %s",
+                FIRST_LISTENER, SECOND_LISTENER );
+        Map convertedOptions = getConvertedOptions( LISTENER_PROP, listenersOnSeveralLines );
+        String listeners = (String) convertedOptions.get( String.format( "-%s", LISTENER_PROP ) );
+        assertEquals( FIRST_LISTENER + "," + SECOND_LISTENER, listeners );
+    }
+
+    public void testListenersOnTheSameLine()
+            throws Exception
+    {
+        String listenersOnSeveralLines = String.format( "%s,%s",
+                FIRST_LISTENER, SECOND_LISTENER );
+        Map convertedOptions = getConvertedOptions( LISTENER_PROP, listenersOnSeveralLines );
+        String listeners = (String) convertedOptions.get( String.format( "-%s", LISTENER_PROP ) );
+        assertEquals( FIRST_LISTENER + "," + SECOND_LISTENER, listeners );
+    }
+
+    public void testReporter()
+            throws Exception
+    {
+        Map<String, Object> convertedOptions = getConvertedOptions( "reporter", "classname" );
+        String reporter = (String) convertedOptions.get( "-reporterslist" );
+        assertEquals( "classname", reporter );
+    }
+
+    private Map getConvertedOptions( String key, String value )
+            throws TestSetFailedException
+    {
+        TestNGMapConfigurator testNGMapConfigurator = new TestNG513Configurator();
+        Map<String, String> raw = new HashMap<String, String>();
+        raw.put( key, value );
+        return testNGMapConfigurator.getConvertedOptions( raw );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5141ConfiguratorTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5141ConfiguratorTest.java b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5141ConfiguratorTest.java
new file mode 100644
index 0000000..e253f3f
--- /dev/null
+++ b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5141ConfiguratorTest.java
@@ -0,0 +1,78 @@
+package org.apache.maven.surefire.testng.conf;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.*;
+
+public class TestNG5141ConfiguratorTest
+    extends TestCase
+{
+
+    public void testListenersOnSeparateLines()
+            throws Exception
+    {
+        try
+        {
+            String listenersOnSeveralLines = String.format("%s , %n %s",
+                                                           FIRST_LISTENER, SECOND_LISTENER);
+            Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines);
+            List listeners = (List) convertedOptions.get(String.format("-%s", LISTENER_PROP));
+            assertEquals(2, listeners.size());
+            fail();
+        }
+        catch ( TestSetFailedException e )
+        {
+            // TODO remove it when surefire will use "configure(CommandLineArgs)"
+        }
+    }
+
+    public void testListenersOnTheSameLine()
+            throws Exception
+    {
+        try {
+            String listenersOnSeveralLines = String.format("%s,%s",
+                                                           FIRST_LISTENER, SECOND_LISTENER);
+            Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines);
+            List listeners = (List) convertedOptions.get(String.format("-%s", LISTENER_PROP));
+            assertEquals(2, listeners.size());
+            fail();
+        }
+        catch ( TestSetFailedException e )
+        {
+            // TODO remove it when surefire will use "configure(CommandLineArgs)"
+        }
+    }
+
+    private Map getConvertedOptions( String key, String value )
+            throws TestSetFailedException
+    {
+        TestNGMapConfigurator testNGMapConfigurator = new TestNG5141Configurator();
+        Map<String, String> raw = new HashMap<String, String>();
+        raw.put( key, value );
+        return testNGMapConfigurator.getConvertedOptions( raw );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5143ConfiguratorTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5143ConfiguratorTest.java b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5143ConfiguratorTest.java
new file mode 100644
index 0000000..2ea5398
--- /dev/null
+++ b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNG5143ConfiguratorTest.java
@@ -0,0 +1,72 @@
+package org.apache.maven.surefire.testng.conf;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
+import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.FIRST_LISTENER;
+import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.LISTENER_PROP;
+import static org.apache.maven.surefire.testng.conf.TestNGMapConfiguratorTest.SECOND_LISTENER;
+
+public class TestNG5143ConfiguratorTest
+    extends TestCase
+{
+    public void testListenersOnSeparateLines()
+            throws Exception
+    {
+        String listenersOnSeveralLines = String.format( "%s , %n %s",
+                FIRST_LISTENER, SECOND_LISTENER);
+        Map convertedOptions = getConvertedOptions(LISTENER_PROP, listenersOnSeveralLines);
+        String listeners = (String) convertedOptions.get( String.format("-%s", LISTENER_PROP));
+        assertEquals(FIRST_LISTENER + "," + SECOND_LISTENER, listeners);
+    }
+
+    public void testListenersOnTheSameLine()
+            throws Exception
+    {
+        String listenersOnSeveralLines = String.format( "%s,%s",
+                FIRST_LISTENER, SECOND_LISTENER);
+        Map convertedOptions = getConvertedOptions( LISTENER_PROP, listenersOnSeveralLines);
+        String listeners = (String) convertedOptions.get( String.format("-%s", LISTENER_PROP));
+        assertEquals(FIRST_LISTENER + "," + SECOND_LISTENER, listeners);
+    }
+
+    public void testReporter()
+            throws Exception
+    {
+        Map<String, Object> convertedOptions = getConvertedOptions( "reporter", "classname" );
+        assertNull( "classname", convertedOptions.get( "-reporterslist" ) );
+        String reporter = (String) convertedOptions.get("-reporter" );
+        assertEquals( "classname", reporter );
+    }
+
+    private Map getConvertedOptions( String key, String value )
+            throws TestSetFailedException
+    {
+        TestNGMapConfigurator testNGMapConfigurator = new TestNG5143Configurator();
+        Map<String, String> raw = new HashMap<String, String>();
+        raw.put( key, value );
+        return testNGMapConfigurator.getConvertedOptions( raw );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7fe7a2a3/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNGMapConfiguratorTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNGMapConfiguratorTest.java b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNGMapConfiguratorTest.java
index 06cf30d..28bba7c 100755
--- a/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNGMapConfiguratorTest.java
+++ b/surefire-providers/surefire-testng/src/test/java/org/apache/maven/surefire/testng/conf/TestNGMapConfiguratorTest.java
@@ -26,6 +26,7 @@ import java.util.Map;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 
 import junit.framework.TestCase;
+import org.testng.ReporterConfig;
 
 /**
  * @author Kristian Rosenvold
@@ -33,8 +34,8 @@ import junit.framework.TestCase;
 public class TestNGMapConfiguratorTest
     extends TestCase
 {
-    private static final String FIRST_LISTENER = "org.testng.TestListenerAdapter";
-    private static final String SECOND_LISTENER = "org.testng.reporters.ExitCodeListener";
+    public static final String FIRST_LISTENER = "org.testng.TestListenerAdapter";
+    public static final String SECOND_LISTENER = "org.testng.reporters.ExitCodeListener";
     public static final String LISTENER_PROP = "listener";
 
     public void testGetConvertedOptions()
@@ -73,6 +74,15 @@ public class TestNGMapConfiguratorTest
         assertTrue( bool );
     }
 
+    public void testReporter()
+        throws Exception
+    {
+        Map<String, Object> convertedOptions = getConvertedOptions( "reporter", "classname" );
+        List<ReporterConfig> reporter = (List) convertedOptions.get( "-reporterslist" );
+        ReporterConfig reporterConfig = reporter.get( 0 );
+        assertEquals( "classname", reporterConfig.getClassName() );
+    }
+
     private Map getConvertedOptions( String key, String value )
         throws TestSetFailedException
     {


[2/2] maven-surefire git commit: [SUREFIRE-1194] reporter argument does not work for TestNG

Posted by ti...@apache.org.
[SUREFIRE-1194] reporter argument does not work for TestNG


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

Branch: refs/heads/master
Commit: 2261bcea68d4cf1dbae437afa6be0b4a06916b35
Parents: 7fe7a2a
Author: Tibor17 <ti...@lycos.com>
Authored: Tue Dec 15 01:28:02 2015 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Tue Dec 15 01:29:32 2015 +0100

----------------------------------------------------------------------
 .../plugin/surefire/AbstractSurefireMojo.java   | 11 ++---
 .../src/site/apt/examples/testng.apt.vm         |  2 +-
 .../its/CheckTestNgListenerReporterIT.java      | 42 ++++++++++++--------
 .../testng/conf/TestNG513Configurator.java      |  2 +-
 .../testng/conf/TestNGMapConfigurator.java      |  4 +-
 5 files changed, 33 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2261bcea/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 3e0d840..f169446 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
@@ -1154,19 +1154,16 @@ public abstract class AbstractSurefireMojo
             range = VersionRange.createFromVersionSpec( "[5.14.1,5.14.3)" );
             if ( range.containsVersion( version ) )
             {
+                log.warn( "The 'reporter' or 'listener' may not work properly in TestNG 5.14.1 and 5.14.2." );
                 return "org.apache.maven.surefire.testng.conf.TestNG5141Configurator";
             }
             range = VersionRange.createFromVersionSpec( "[5.14.3,6.0)" );
             if ( range.containsVersion( version ) )
             {
-                if ( version.equals( new DefaultArtifactVersion( "5.14.3" ) ) )
+                if ( version.equals( new DefaultArtifactVersion( "[5.14.3,5.14.5]" ) ) )
                 {
-                    throw new MojoExecutionException( "Due to a bad formatted pom.xml, "
-                                                      + "TestNG 5.14.3 is not supported" );
-                }
-                if ( VersionRange.createFromVersionSpec( "[5.14.4,5.14.5]" ).containsVersion( version ) )
-                {
-                    log.warn( "Due to a bad formatted pom.xml, TestNG 5.14.4 and 5.14.5 may not work" );
+                    throw new MojoExecutionException( "TestNG 5.14.3-5.14.5 is not supported. "
+                            + "System dependency org.testng:guice missed path." );
                 }
                 return "org.apache.maven.surefire.testng.conf.TestNG5143Configurator";
             }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2261bcea/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
index 85a6349..765e564 100644
--- a/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
@@ -286,7 +286,7 @@ Using TestNG
   You can implement TestNG listener interface <<<org.testng.ITestListener>>> in
   a separate test artifact <<<your-testng-listener-artifact>>> with scope=test, or in project test source code
   <<<src/test/java>>>. You can filter test artifacts by the parameter <<<dependenciesToScan>>> to load its classes
-  in current ClassLoader of surefire-testng provider.
+  in current ClassLoader of surefire-testng provider. The TestNG reporter class should implement <<<org.testng.IReporter>>>.
 
 * The level of verbosity
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2261bcea/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
index 8e25e5d..3558bce 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
@@ -20,8 +20,6 @@ package org.apache.maven.surefire.its;
  */
 
 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
-import org.apache.maven.surefire.its.fixture.SurefireLauncher;
-import org.junit.After;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -29,18 +27,20 @@ import org.junit.runners.Parameterized;
 import java.util.Arrays;
 import java.util.Collection;
 
+import static org.junit.runners.Parameterized.Parameter;
+import static org.junit.runners.Parameterized.Parameters;
+
 /**
  * Test simple TestNG listener and reporter
  *
  * @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
  * @author <a href="mailto:krosenvold@apache.org">Kristian Rosenvold</a>
  */
-@RunWith(Parameterized.class)
+@RunWith( Parameterized.class )
 public class CheckTestNgListenerReporterIT
     extends SurefireJUnit4IntegrationTestCase
 {
-
-    @Parameterized.Parameters(name = "{index}: TestNG {0}")
+    @Parameters( name = "{index}: TestNG {0}" )
     public static Collection<Object[]> data()
     {
         return Arrays.asList(new Object[][] {
@@ -49,34 +49,42 @@ public class CheckTestNgListenerReporterIT
             { "5.10" },
             { "5.13" }, // "reporterslist" param becomes String instead of List<ReporterConfig>
                         // "listener" param becomes String instead of List<Class>
+
+                // configure(Map) in 5.14.1 and 5.14.2 is transforming List<Class> into a String with a space as separator.
+                // Then configure(CommandLineArgs) splits this String into a List<String> with , or ; as separator => fail.
+                // If we used configure(CommandLineArgs), we would not have the problem with white spaces.
             //{ "5.14.1" }, // "listener" param becomes List instead of String
                             // Fails: Issue with 5.14.1 and 5.14.2 => join with <space>, split with ","
                             // TODO will work with "configure(CommandLineArgs)"
             //{ "5.14.2" }, // ReporterConfig is not available
+
             //{ "5.14.3" }, // TestNG uses "reporter" instead of "reporterslist"
                           // Both String or List are possible for "listener"
-                          // Fails: Bad formatted pom => transitive dependencies are missing
-            { "5.14.4" }, // Usage of org.testng:guice
-                          // Caution: Some TestNG features may fail with 5.14.4 and 5.14.5 due to missing dependency
+                          // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI
+                          // ClassNotFoundException: com.beust.jcommander.ParameterException
+
+            //{ "5.14.4" }, { "5.14.5" }, // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI
+                                        // ClassNotFoundException: com.beust.jcommander.ParameterException
+
             { "5.14.6" }, // Usage of org.testng:guice removed
             { "5.14.9" }, // Latest 5.14.x TestNG version
             { "6.0" },
-            { "6.9.9" } // Current latest TestNG version
+            { "6.9.9" } // Currently latest TestNG version
         });
     }
 
-    @Parameterized.Parameter
+    @Parameter
     public String version;
-    private SurefireLauncher verifierStarter;
 
     @Test
     public void testNgListenerReporter()
     {
-        verifierStarter = unpack( "testng-listener-reporter", "_" + version );
-        verifierStarter.resetInitialGoals( version );
-        verifierStarter.executeTest().verifyErrorFree( 1 )
-            .getTargetFile( "resultlistener-output.txt" ).assertFileExists()
-            .getTargetFile( "suitelistener-output.txt" ).assertFileExists()
-            .getTargetFile( "reporter-output.txt" ).assertFileExists();
+        unpack( "testng-listener-reporter", "_" + version )
+                .resetInitialGoals( version )
+                .executeTest()
+                .verifyErrorFree( 1 )
+                .getTargetFile( "resultlistener-output.txt" ).assertFileExists()
+                .getTargetFile( "suitelistener-output.txt" ).assertFileExists()
+                .getTargetFile( "reporter-output.txt" ).assertFileExists();
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2261bcea/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
index f38df08..ce44dd4 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG513Configurator.java
@@ -29,7 +29,7 @@ public class TestNG513Configurator
 {
 
     @Override
-    protected Object convertReporterConfig( String val )
+    protected Object convertReporterConfig( Object val )
     {
         return val;
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2261bcea/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
index fcf9a91..96e0b85 100755
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
@@ -91,7 +91,7 @@ public class TestNGMapConfigurator
             {
                 // for TestNG 5.6 or higher
                 // TODO support multiple reporters?
-                val = convertReporterConfig( entry.getValue() );
+                val = convertReporterConfig( val );
                 key = "reporterslist";
             }
             else if ( "junit".equals( key ) )
@@ -142,7 +142,7 @@ public class TestNGMapConfigurator
     }
 
     // ReporterConfig only became available in later versions of TestNG
-    protected Object convertReporterConfig( String val )
+    protected Object convertReporterConfig( Object val )
     {
         final String reporterConfigClassName = "org.testng.ReporterConfig";
         try