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 2022/04/24 11:23:27 UTC

[maven-surefire] branch master updated: refactoring in TestNG740Configurator after previous [SUREFIRE-2064] cbf7df3564470e57af11c243356b93c74622befc

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/master by this push:
     new 2657a3233 refactoring in TestNG740Configurator after previous [SUREFIRE-2064] cbf7df3564470e57af11c243356b93c74622befc
2657a3233 is described below

commit 2657a32332551393beedc8a87d13a124238e8481
Author: tibor.digana <ti...@apache.org>
AuthorDate: Sun Apr 24 13:23:13 2022 +0200

    refactoring in TestNG740Configurator after previous [SUREFIRE-2064] cbf7df3564470e57af11c243356b93c74622befc
---
 .../testng/conf/TestNG740Configurator.java         | 27 ++++++----------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG740Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG740Configurator.java
index 205fc2e6f..c6118b324 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG740Configurator.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG740Configurator.java
@@ -26,7 +26,7 @@ import java.util.Map;
 
 import static org.apache.maven.surefire.api.booter.ProviderParameterNames.PARALLEL_PROP;
 import static org.apache.maven.surefire.api.util.ReflectionUtils.invokeSetter;
-import static org.apache.maven.surefire.api.util.ReflectionUtils.tryLoadClass;
+import static org.apache.maven.surefire.api.util.ReflectionUtils.loadClass;
 
 /**
  * TestNG 7.4.0 configurator. Changed setParallel type to enum value.
@@ -54,30 +54,17 @@ public class TestNG740Configurator
         throws TestSetFailedException
     {
         String parallel = options.get( PARALLEL_PROP );
-        // if [parallel] spec'd
         if ( parallel != null )
         {
-            // try to load the [ParallelMode] enumeration
-            Class enumClass = tryLoadClass( XmlSuite.class.getClassLoader(), "org.testng.xml.XmlSuite$ParallelMode" );
-            // if enumeration loaded
-            if ( enumClass != null )
+            Class enumClass = loadClass( XmlSuite.class.getClassLoader(), "org.testng.xml.XmlSuite$ParallelMode" );
+            try
             {
-                try
-                {
-                    // convert [parallel] option to corresponding constant
-                    Enum<?> parallelEnum = Enum.valueOf( enumClass, parallel.toUpperCase() );
-                    // set [XmlSuite] parallel mode to specified value
-                    invokeSetter( suite, "setParallel", enumClass, parallelEnum );
-                }
-                catch ( IllegalArgumentException e )
-                {
-                    throw new TestSetFailedException( "Unsupported TestNG [parallel] setting: " + parallel, e );
-                }
+                Enum<?> parallelEnum = Enum.valueOf( enumClass, parallel.toUpperCase() );
+                invokeSetter( suite, "setParallel", enumClass, parallelEnum );
             }
-            else
+            catch ( IllegalArgumentException e )
             {
-                throw new TestSetFailedException(
-                        "Failed loading TestNG [ParallelMode] enumeration to convert [parallel] setting: " + parallel );
+                throw new TestSetFailedException( "Unsupported TestNG [parallel] setting: " + parallel, e );
             }
         }
     }