Repository: maven-surefire Updated Branches: refs/heads/master c02be388b -> 84fd7235b
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java index 4b0ef2e..a19c8c8 100644 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java +++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java @@ -36,7 +36,9 @@ import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.RunWith; -import java.util.Properties; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ExecutionException; import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.*; @@ -86,18 +88,16 @@ public final class ParallelComputerUtilTest assertFalse( Thread.currentThread().isInterrupted() ); } - private static Properties parallel( String parallel ) + private static Map<String, String> parallel( String parallel ) { - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, parallel ); - return properties; + return Collections.singletonMap( PARALLEL_KEY, parallel ); } @Test public void unknownParallel() throws TestSetFailedException { - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); exception.expect( TestSetFailedException.class ); resolveConcurrency( new JUnitCoreParameters( properties ), null ); } @@ -203,9 +203,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suites" ); - properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suites"); + properties.put(USEUNLIMITEDTHREADS_KEY, "true"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -216,7 +216,7 @@ public final class ParallelComputerUtilTest assertThat( concurrency.classes, is( 0 ) ); assertThat( concurrency.methods, is( 0 ) ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); + properties.put(THREADCOUNTSUITES_KEY, "5"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -233,9 +233,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "classes" ); - properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "classes"); + properties.put(USEUNLIMITEDTHREADS_KEY, "true"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -246,7 +246,7 @@ public final class ParallelComputerUtilTest assertThat( concurrency.classes, is( Integer.MAX_VALUE ) ); assertThat( concurrency.methods, is( 0 ) ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "5" ); + properties.put(THREADCOUNTCLASSES_KEY, "5"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -263,9 +263,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "methods" ); - properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "methods"); + properties.put(USEUNLIMITEDTHREADS_KEY, "true"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -276,7 +276,7 @@ public final class ParallelComputerUtilTest assertThat( concurrency.classes, is( 0 ) ); assertThat( concurrency.methods, is( Integer.MAX_VALUE ) ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "5" ); + properties.put(THREADCOUNTMETHODS_KEY, "5"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -293,9 +293,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suitesAndClasses" ); - properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suitesAndClasses"); + properties.put(USEUNLIMITEDTHREADS_KEY, "true"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -306,8 +306,8 @@ public final class ParallelComputerUtilTest assertThat( concurrency.classes, is( Integer.MAX_VALUE ) ); assertThat( concurrency.methods, is( 0 ) ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "15" ); + properties.put(THREADCOUNTSUITES_KEY, "5"); + properties.put(THREADCOUNTCLASSES_KEY, "15"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -324,9 +324,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suitesAndMethods" ); - properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suitesAndMethods"); + properties.put(USEUNLIMITEDTHREADS_KEY, "true"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -337,8 +337,8 @@ public final class ParallelComputerUtilTest assertThat( concurrency.classes, is( 0 ) ); assertThat( concurrency.methods, is( Integer.MAX_VALUE ) ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "15" ); + properties.put(THREADCOUNTSUITES_KEY, "5"); + properties.put(THREADCOUNTMETHODS_KEY, "15"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -355,9 +355,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "classesAndMethods" ); - properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "classesAndMethods"); + properties.put(USEUNLIMITEDTHREADS_KEY, "true"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -368,8 +368,8 @@ public final class ParallelComputerUtilTest assertThat( concurrency.classes, is( Integer.MAX_VALUE ) ); assertThat( concurrency.methods, is( Integer.MAX_VALUE ) ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "5" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "15" ); + properties.put(THREADCOUNTCLASSES_KEY, "5"); + properties.put(THREADCOUNTMETHODS_KEY, "15"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -386,9 +386,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "all" ); - properties.setProperty( USEUNLIMITEDTHREADS_KEY, "true" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "all"); + properties.put(USEUNLIMITEDTHREADS_KEY, "true"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -399,9 +399,9 @@ public final class ParallelComputerUtilTest assertThat( concurrency.classes, is( Integer.MAX_VALUE ) ); assertThat( concurrency.methods, is( Integer.MAX_VALUE ) ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "15" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "30" ); + properties.put(THREADCOUNTSUITES_KEY, "5"); + properties.put(THREADCOUNTCLASSES_KEY, "15"); + properties.put(THREADCOUNTMETHODS_KEY, "30"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -418,9 +418,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suites" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suites"); + properties.put(THREADCOUNT_KEY, "3"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -437,9 +437,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "classes" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "classes"); + properties.put(THREADCOUNT_KEY, "3"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -456,9 +456,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "methods" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "methods"); + properties.put(THREADCOUNT_KEY, "3"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -475,9 +475,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "both" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "both"); + properties.put(THREADCOUNT_KEY, "3"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -494,9 +494,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "classesAndMethods" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "classesAndMethods"); + properties.put(THREADCOUNT_KEY, "3"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -513,9 +513,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suitesAndMethods" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suitesAndMethods"); + properties.put(THREADCOUNT_KEY, "3"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -532,9 +532,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suitesAndClasses" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suitesAndClasses"); + properties.put(THREADCOUNT_KEY, "3"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -551,9 +551,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "all" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "all"); + properties.put(THREADCOUNT_KEY, "3"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -570,12 +570,12 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suitesAndClasses" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suitesAndClasses"); + properties.put(THREADCOUNT_KEY, "3"); // % percentage ratio - properties.setProperty( THREADCOUNTSUITES_KEY, "34" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "66" ); + properties.put(THREADCOUNTSUITES_KEY, "34"); + properties.put(THREADCOUNTCLASSES_KEY, "66"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -593,12 +593,12 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suitesAndMethods" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suitesAndMethods"); + properties.put(THREADCOUNT_KEY, "3"); // % percentage ratio - properties.setProperty( THREADCOUNTSUITES_KEY, "34" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "66" ); + properties.put(THREADCOUNTSUITES_KEY, "34"); + properties.put(THREADCOUNTMETHODS_KEY, "66"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -616,12 +616,12 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "classesAndMethods" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "classesAndMethods"); + properties.put(THREADCOUNT_KEY, "3"); // % percentage ratio - properties.setProperty( THREADCOUNTCLASSES_KEY, "34" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "66" ); + properties.put(THREADCOUNTCLASSES_KEY, "34"); + properties.put(THREADCOUNTMETHODS_KEY, "66"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -639,13 +639,13 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "all" ); - properties.setProperty( THREADCOUNT_KEY, "3" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "all"); + properties.put(THREADCOUNT_KEY, "3"); // % percentage ratio - properties.setProperty( THREADCOUNTSUITES_KEY, "17" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "34" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "49" ); + properties.put(THREADCOUNTSUITES_KEY, "17"); + properties.put(THREADCOUNTCLASSES_KEY, "34"); + properties.put(THREADCOUNTMETHODS_KEY, "49"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -665,10 +665,10 @@ public final class ParallelComputerUtilTest { // 4 * cpu to 5 * cpu threads to run test classes ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suitesAndClasses" ); - properties.setProperty( THREADCOUNT_KEY, "6" ); - properties.setProperty( THREADCOUNTSUITES_KEY, "2" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suitesAndClasses"); + properties.put(THREADCOUNT_KEY, "6"); + properties.put(THREADCOUNTSUITES_KEY, "2"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -686,10 +686,10 @@ public final class ParallelComputerUtilTest { // 4 * cpu to 5 * cpu threads to run test methods ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suitesAndMethods" ); - properties.setProperty( THREADCOUNT_KEY, "6" ); - properties.setProperty( THREADCOUNTSUITES_KEY, "2" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suitesAndMethods"); + properties.put(THREADCOUNT_KEY, "6"); + properties.put(THREADCOUNTSUITES_KEY, "2"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -707,10 +707,10 @@ public final class ParallelComputerUtilTest { // 4 * cpu to 5 * cpu threads to run test methods ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "classesAndMethods" ); - properties.setProperty( THREADCOUNT_KEY, "6" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "2" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "classesAndMethods"); + properties.put(THREADCOUNT_KEY, "6"); + properties.put(THREADCOUNTCLASSES_KEY, "2"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -728,11 +728,11 @@ public final class ParallelComputerUtilTest { // 8 * cpu to 13 * cpu threads to run test methods ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "all" ); - properties.setProperty( THREADCOUNT_KEY, "14" ); - properties.setProperty( THREADCOUNTSUITES_KEY, "2" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "4" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "all"); + properties.put(THREADCOUNT_KEY, "14"); + properties.put(THREADCOUNTSUITES_KEY, "2"); + properties.put(THREADCOUNTCLASSES_KEY, "4"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -749,9 +749,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suites" ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suites"); + properties.put(THREADCOUNTSUITES_KEY, "5"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -768,9 +768,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "classes" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "5" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "classes"); + properties.put(THREADCOUNTCLASSES_KEY, "5"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -787,9 +787,9 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "methods" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "5" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "methods"); + properties.put(THREADCOUNTMETHODS_KEY, "5"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -806,11 +806,11 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); - properties.setProperty( PARALLEL_KEY, "suitesAndClasses" ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "15" ); + properties.put(PARALLEL_KEY, "suitesAndClasses"); + properties.put(THREADCOUNTSUITES_KEY, "5"); + properties.put(THREADCOUNTCLASSES_KEY, "15"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -823,9 +823,9 @@ public final class ParallelComputerUtilTest // Warning: this case works but is not enabled in AbstractSurefireMojo // Instead use the 'useUnlimitedThreads' parameter. - properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suitesAndClasses" ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); + properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suitesAndClasses"); + properties.put(THREADCOUNTSUITES_KEY, "5"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -842,11 +842,11 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); - properties.setProperty( PARALLEL_KEY, "suitesAndMethods" ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "15" ); + properties.put(PARALLEL_KEY, "suitesAndMethods"); + properties.put(THREADCOUNTSUITES_KEY, "5"); + properties.put(THREADCOUNTMETHODS_KEY, "15"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -859,9 +859,9 @@ public final class ParallelComputerUtilTest // Warning: this case works but is not enabled in AbstractSurefireMojo // Instead use the 'useUnlimitedThreads' parameter. - properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "suitesAndMethods" ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); + properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "suitesAndMethods"); + properties.put(THREADCOUNTSUITES_KEY, "5"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -878,11 +878,11 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); - properties.setProperty( PARALLEL_KEY, "classesAndMethods" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "5" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "15" ); + properties.put(PARALLEL_KEY, "classesAndMethods"); + properties.put(THREADCOUNTCLASSES_KEY, "5"); + properties.put(THREADCOUNTMETHODS_KEY, "15"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -895,9 +895,9 @@ public final class ParallelComputerUtilTest // Warning: this case works but is not enabled in AbstractSurefireMojo // Instead use the 'useUnlimitedThreads' parameter. - properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "classesAndMethods" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "5" ); + properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "classesAndMethods"); + properties.put(THREADCOUNTCLASSES_KEY, "5"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertFalse( params.isParallelSuites() ); @@ -914,12 +914,12 @@ public final class ParallelComputerUtilTest throws TestSetFailedException { ParallelComputerUtil.overrideAvailableProcessors( cpu ); - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); - properties.setProperty( PARALLEL_KEY, "all" ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "15" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "30" ); + properties.put(PARALLEL_KEY, "all"); + properties.put(THREADCOUNTSUITES_KEY, "5"); + properties.put(THREADCOUNTCLASSES_KEY, "15"); + properties.put(THREADCOUNTMETHODS_KEY, "30"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); Concurrency concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -932,10 +932,10 @@ public final class ParallelComputerUtilTest // Warning: these cases work but they are not enabled in AbstractSurefireMojo // Instead use the 'useUnlimitedThreads' parameter. - properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "all" ); - properties.setProperty( THREADCOUNTSUITES_KEY, "5" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "15" ); + properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "all"); + properties.put(THREADCOUNTSUITES_KEY, "5"); + properties.put(THREADCOUNTCLASSES_KEY, "15"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -946,9 +946,9 @@ public final class ParallelComputerUtilTest assertThat( concurrency.classes, is( 15 * cpu ) ); assertThat( concurrency.methods, is( Integer.MAX_VALUE ) ); - properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "all" ); - properties.setProperty( THREADCOUNTCLASSES_KEY, "15" ); + properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "all"); + properties.put(THREADCOUNTCLASSES_KEY, "15"); params = new JUnitCoreParameters( properties ); concurrency = resolveConcurrency( params, null ); assertTrue( params.isParallelSuites() ); @@ -964,9 +964,9 @@ public final class ParallelComputerUtilTest public void withoutShutdown() throws TestSetFailedException, ExecutionException, InterruptedException { - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "methods" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "2" ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "methods"); + properties.put(THREADCOUNTMETHODS_KEY, "2"); JUnitCoreParameters params = new JUnitCoreParameters( properties ); ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( new Logger(), params ); ParallelComputer pc = pcBuilder.buildComputer(); @@ -987,10 +987,10 @@ public final class ParallelComputerUtilTest { // The JUnitCore returns after 2.5s. // The test-methods in TestClass are NOT interrupted, and return normally after 5s. - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "methods" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "2" ); - properties.setProperty( PARALLEL_TIMEOUT_KEY, Double.toString( 2.5d ) ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "methods"); + properties.put(THREADCOUNTMETHODS_KEY, "2"); + properties.put(PARALLEL_TIMEOUT_KEY, Double.toString(2.5d)); JUnitCoreParameters params = new JUnitCoreParameters( properties ); ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( new Logger(), params ); ParallelComputer pc = pcBuilder.buildComputer(); @@ -1010,10 +1010,10 @@ public final class ParallelComputerUtilTest throws TestSetFailedException, ExecutionException, InterruptedException { // The JUnitCore returns after 2.5s, and the test-methods in TestClass are interrupted. - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "methods" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "2" ); - properties.setProperty( PARALLEL_TIMEOUTFORCED_KEY, Double.toString( 2.5d ) ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "methods"); + properties.put(THREADCOUNTMETHODS_KEY, "2"); + properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString(2.5d)); JUnitCoreParameters params = new JUnitCoreParameters( properties ); ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( new Logger(), params ); ParallelComputer pc = pcBuilder.buildComputer(); @@ -1035,11 +1035,11 @@ public final class ParallelComputerUtilTest // The JUnitCore returns after 3.5s and the test-methods in TestClass are timed out after 2.5s. // No new test methods are scheduled for execution after 2.5s. // Interruption of test methods after 3.5s. - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "methods" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "2" ); - properties.setProperty( PARALLEL_TIMEOUT_KEY, Double.toString( 2.5d ) ); - properties.setProperty( PARALLEL_TIMEOUTFORCED_KEY, Double.toString( 3.5d ) ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "methods"); + properties.put(THREADCOUNTMETHODS_KEY, "2"); + properties.put(PARALLEL_TIMEOUT_KEY, Double.toString(2.5d)); + properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString(3.5d)); JUnitCoreParameters params = new JUnitCoreParameters( properties ); ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( new Logger(), params ); ParallelComputer pc = pcBuilder.buildComputer(); @@ -1059,11 +1059,11 @@ public final class ParallelComputerUtilTest throws TestSetFailedException, ExecutionException, InterruptedException { // The JUnitCore returns after 3.5s and the test-methods in TestClass are interrupted after 3.5s. - Properties properties = new Properties(); - properties.setProperty( PARALLEL_KEY, "methods" ); - properties.setProperty( THREADCOUNTMETHODS_KEY, "2" ); - properties.setProperty( PARALLEL_TIMEOUTFORCED_KEY, Double.toString( 3.5d ) ); - properties.setProperty( PARALLEL_TIMEOUT_KEY, Double.toString( 4.0d ) ); + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PARALLEL_KEY, "methods"); + properties.put(THREADCOUNTMETHODS_KEY, "2"); + properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString(3.5d)); + properties.put(PARALLEL_TIMEOUT_KEY, Double.toString(4.0d)); JUnitCoreParameters params = new JUnitCoreParameters( properties ); ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( new Logger(), params ); ParallelComputer pc = pcBuilder.buildComputer(); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java index ffc8ad7..db3bb41 100644 --- a/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java +++ b/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java @@ -48,7 +48,7 @@ public class GroupMatcherMethodSelector public boolean includeMethod( IMethodSelectorContext context, ITestNGMethod method, boolean isTestMethod ) { - Boolean result = (Boolean) answers.get( method ); + Boolean result = answers.get( method ); if ( result != null ) { return result; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/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 32511bf..4636e14 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 @@ -27,7 +27,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Properties; import java.util.SortedMap; import java.util.TreeMap; @@ -55,9 +54,9 @@ public class TestNGDirectoryTestSuite implements TestNgTestSuite { - private final Map options; + private final Map<String, String> options; - private final Map junitOptions; + private final Map<String, String> junitOptions; private final String testSourceDirectory; @@ -71,21 +70,18 @@ public class TestNGDirectoryTestSuite private final RunOrderCalculator runOrderCalculator; - private final Class junitTestClass; + private final Class<?> junitTestClass; private Class<? extends Annotation> junitRunWithAnnotation; private Class<? extends Annotation> junitTestAnnotation; - public TestNGDirectoryTestSuite( String testSourceDirectory, Properties confOptions, File reportsDirectory, + public TestNGDirectoryTestSuite( String testSourceDirectory, Map<String, String> confOptions, File reportsDirectory, TestListResolver methodFilter, RunOrderCalculator runOrderCalculator, ScanResult scanResult ) { - this.runOrderCalculator = runOrderCalculator; - this.options = confOptions; - this.testSourceDirectory = testSourceDirectory; this.reportsDirectory = reportsDirectory; this.scanResult = scanResult; @@ -110,12 +106,12 @@ public class TestNGDirectoryTestSuite } else if ( testsToRun.containsAtLeast( 1 ) ) { - Class testClass = testsToRun.iterator().next(); + Class<?> testClass = testsToRun.iterator().next(); executeSingleClass( reporterManagerFactory, testClass ); } } - private void executeSingleClass( ReporterFactory reporterManagerFactory, Class testClass ) + private void executeSingleClass( ReporterFactory reporterManagerFactory, Class<?> testClass ) throws TestSetFailedException { this.options.put( "suitename", testClass.getName() ); @@ -125,9 +121,9 @@ public class TestNGDirectoryTestSuite startTestSuite( reporter, this ); - final Map optionsToUse = isJUnitTest( testClass ) ? junitOptions : options; + final Map<String, String> optionsToUse = isJUnitTest( testClass ) ? junitOptions : options; - TestNGExecutor.run( new Class[]{ testClass }, testSourceDirectory, optionsToUse, reporter, this, + TestNGExecutor.run( new Class<?>[]{ testClass }, testSourceDirectory, optionsToUse, reporter, this, reportsDirectory, methodFilter ); finishTestSuite( reporter, this ); @@ -136,31 +132,45 @@ public class TestNGDirectoryTestSuite public void executeLazy( TestsToRun testsToRun, ReporterFactory reporterFactory ) throws TestSetFailedException { - - for ( Class c : testsToRun ) + for ( Class<?> c : testsToRun ) { executeSingleClass( reporterFactory, c ); } } - private Class findJUnitTestClass() + private Class<?> findJUnitTestClass() { return lookupClass( "junit.framework.Test" ); } - private Class findJUnitRunWithAnnotation() + private Class<Annotation> findJUnitRunWithAnnotation() + { + return lookupAnnotation( "org.junit.runner.RunWith" ); + } + + private Class<Annotation> findJUnitTestAnnotation() { - return lookupClass( "org.junit.runner.RunWith" ); + return lookupAnnotation( "org.junit.Test" ); } - private Class findJUnitTestAnnotation() + @SuppressWarnings( "unchecked" ) + private static Class<Annotation> lookupAnnotation( String className ) { - return lookupClass( "org.junit.Test" ); + Class<Annotation> junitClass; + try + { + junitClass = (Class<Annotation>) Class.forName( className ); + } + catch ( ClassNotFoundException e ) + { + junitClass = null; + } + return junitClass; } - private Class lookupClass( String className ) + private static Class<?> lookupClass( String className ) { - Class junitClass; + Class<?> junitClass; try { junitClass = Class.forName( className ); @@ -175,9 +185,9 @@ public class TestNGDirectoryTestSuite public void executeMulti( TestsToRun testsToRun, ReporterFactory reporterFactory ) throws TestSetFailedException { - List<Class> testNgTestClasses = new ArrayList<Class>(); - List<Class> junitTestClasses = new ArrayList<Class>(); - for ( Class c : testsToRun ) + List<Class<?>> testNgTestClasses = new ArrayList<Class<?>>(); + List<Class<?>> junitTestClasses = new ArrayList<Class<?>>(); + for ( Class<?> c : testsToRun ) { if ( isJUnitTest( c ) ) { @@ -191,7 +201,7 @@ public class TestNGDirectoryTestSuite File testNgReportsDirectory = reportsDirectory, junitReportsDirectory = reportsDirectory; - if ( junitTestClasses.size() > 0 && testNgTestClasses.size() > 0 ) + if ( !junitTestClasses.isEmpty() && !testNgTestClasses.isEmpty() ) { testNgReportsDirectory = new File( reportsDirectory, "testng-native-results" ); junitReportsDirectory = new File( reportsDirectory, "testng-junit-results" ); @@ -201,12 +211,12 @@ public class TestNGDirectoryTestSuite ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporterManager ); startTestSuite( reporterManager, this ); - Class[] testClasses = testNgTestClasses.toArray( new Class[testNgTestClasses.size()] ); + Class<?>[] testClasses = testNgTestClasses.toArray( new Class<?>[testNgTestClasses.size()] ); - TestNGExecutor.run( testClasses, this.testSourceDirectory, options, reporterManager, this, + TestNGExecutor.run( testClasses, testSourceDirectory, options, reporterManager, this, testNgReportsDirectory, methodFilter ); - if ( junitTestClasses.size() > 0 ) + if ( !junitTestClasses.isEmpty() ) { testClasses = junitTestClasses.toArray( new Class[junitTestClasses.size()] ); @@ -217,22 +227,22 @@ public class TestNGDirectoryTestSuite finishTestSuite( reporterManager, this ); } - private boolean isJUnitTest( Class c ) + private boolean isJUnitTest( Class<?> c ) { return isJunit3Test( c ) || isJunit4Test( c ); } - private boolean isJunit4Test( Class c ) + private boolean isJunit4Test( Class<?> c ) { return hasJunit4RunWithAnnotation( c ) || hasJunit4TestAnnotation( c ); } - private boolean hasJunit4RunWithAnnotation( Class c ) + private boolean hasJunit4RunWithAnnotation( Class<?> c ) { return junitRunWithAnnotation != null && c.getAnnotation( junitRunWithAnnotation ) != null; } - private boolean hasJunit4TestAnnotation( Class c ) + private boolean hasJunit4TestAnnotation( Class<?> c ) { if ( junitTestAnnotation != null ) { @@ -248,15 +258,15 @@ public class TestNGDirectoryTestSuite return false; } - private boolean isJunit3Test( Class c ) + private boolean isJunit3Test( Class<?> c ) { return junitTestClass != null && junitTestClass.isAssignableFrom( c ); } - private Map createJUnitOptions() + private Map<String, String> createJUnitOptions() { - Map junitOptions = new HashMap( this.options ); - junitOptions.put( "junit", Boolean.TRUE ); + Map<String, String> junitOptions = new HashMap<String, String>( this.options ); + junitOptions.put( "junit", "true" ); return junitOptions; } @@ -280,7 +290,7 @@ public class TestNGDirectoryTestSuite startTestSuite( reporter, this ); - TestNGExecutor.run( new Class[] { testSet.getTestClass() }, this.testSourceDirectory, this.options, reporter, + TestNGExecutor.run( new Class<?>[] { testSet.getTestClass() }, testSourceDirectory, options, reporter, this, reportsDirectory, methodFilter ); finishTestSuite( reporter, this ); @@ -309,28 +319,20 @@ public class TestNGDirectoryTestSuite public String getSuiteName() { - String result = (String) options.get( "suitename" ); - if ( result == null ) - { - result = "TestSuite"; - } - return result; + String result = options.get( "suitename" ); + return result == null ? "TestSuite" : result; } private static String getSuiteName( Object suite ) { - String result; + String result = "TestSuite"; if ( suite instanceof TestNGDirectoryTestSuite ) { - return ( (TestNGDirectoryTestSuite) suite ).getSuiteName(); + result = ( (TestNGDirectoryTestSuite) suite ).getSuiteName(); } else if ( suite instanceof TestNGXmlTestSuite ) { - return ( (TestNGXmlTestSuite) suite ).getSuiteName(); - } - else - { - result = "TestSuite"; + result = ( (TestNGXmlTestSuite) suite ).getSuiteName(); } return result; @@ -349,7 +351,7 @@ public class TestNGDirectoryTestSuite final TestsToRun testsToRun = runOrderCalculator.orderTestClasses( scanned ); - for ( Class testClass : testsToRun ) + for ( Class<?> testClass : testsToRun ) { TestNGTestSet testSet = new TestNGTestSet( testClass ); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/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 fcabbc7..cb0e4a6 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 @@ -36,6 +36,7 @@ import org.testng.xml.XmlTest; import java.io.File; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; @@ -64,13 +65,15 @@ public class TestNGExecutor // noop } - public static void run( Class[] testClasses, String testSourceDirectory, Map options, RunListener reportManager, - TestNgTestSuite suite, File reportsDirectory, TestListResolver methodFilter ) + public static void run( Class<?>[] testClasses, String testSourceDirectory, + Map<String, String> options, // string,string because TestNGMapConfigurator#configure() + RunListener reportManager, TestNgTestSuite suite, File reportsDirectory, + TestListResolver methodFilter ) throws TestSetFailedException { TestNG testng = new TestNG( true ); - Configurator configurator = getConfigurator( (String) options.get( "testng.configurator" ) ); + Configurator configurator = getConfigurator( options.get( "testng.configurator" ) ); System.out.println( "Configuring TestNG with: " + configurator.getClass().getSimpleName() ); XmlMethodSelector groupMatchingSelector = createGroupMatchingSelector( options ); @@ -79,7 +82,7 @@ public class TestNGExecutor Map<String, SuiteAndNamedTests> suitesNames = new HashMap<String, SuiteAndNamedTests>(); List<XmlSuite> xmlSuites = new ArrayList<XmlSuite>(); - for ( Class testClass : testClasses ) + for ( Class<?> testClass : testClasses ) { TestMetadata metadata = findTestMetadata( testClass ); @@ -115,7 +118,7 @@ public class TestNGExecutor testng.run(); } - private static TestMetadata findTestMetadata( Class testClass ) + private static TestMetadata findTestMetadata( Class<?> testClass ) { TestMetadata result = new TestMetadata(); if ( HAS_TEST_ANNOTATION_ON_CLASSPATH ) @@ -209,11 +212,11 @@ public class TestNGExecutor } @SuppressWarnings( "checkstyle:magicnumber" ) - private static XmlMethodSelector createGroupMatchingSelector( Map options ) + private static XmlMethodSelector createGroupMatchingSelector( Map<String, String> options ) throws TestSetFailedException { - String groups = (String) options.get( ProviderParameterNames.TESTNG_GROUPS_PROP ); - String excludedGroups = (String) options.get( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP ); + final String groups = options.get( ProviderParameterNames.TESTNG_GROUPS_PROP ); + final String excludedGroups = options.get( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP ); if ( groups == null && excludedGroups == null ) { @@ -221,13 +224,13 @@ public class TestNGExecutor } // the class is available in the testClassPath - String clazzName = "org.apache.maven.surefire.testng.utils.GroupMatcherMethodSelector"; + final String clazzName = "org.apache.maven.surefire.testng.utils.GroupMatcherMethodSelector"; try { - Class clazz = Class.forName( clazzName ); + Class<?> clazz = Class.forName( clazzName ); // 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 method = clazz.getMethod( "setGroups", String.class, String.class ); method.invoke( null, groups, excludedGroups ); } catch ( Exception e ) @@ -244,12 +247,13 @@ public class TestNGExecutor return xms; } - public static void run( List<String> suiteFiles, String testSourceDirectory, Map options, + public static void run( List<String> suiteFiles, String testSourceDirectory, + Map<String, String> options, // string,string because TestNGMapConfigurator#configure() RunListener reportManager, TestNgTestSuite suite, File reportsDirectory ) throws TestSetFailedException { TestNG testng = new TestNG( true ); - Configurator configurator = getConfigurator( (String) options.get( "testng.configurator" ) ); + Configurator configurator = getConfigurator( options.get( "testng.configurator" ) ); configurator.configure( testng, options ); postConfigure( testng, testSourceDirectory, reportManager, suite, reportsDirectory ); testng.setTestSuites( suiteFiles ); @@ -303,20 +307,22 @@ public class TestNGExecutor { Class.forName( "org.testng.internal.IResultListener" ); Class c = Class.forName( "org.apache.maven.surefire.testng.ConfigurationAwareTestNGReporter" ); - try - { - Constructor ctor = c.getConstructor( new Class[] { RunListener.class, TestNgTestSuite.class } ); - return (TestNGReporter) ctor.newInstance( reportManager, suite ); - } - catch ( Exception e ) - { - throw new RuntimeException( "Bug in ConfigurationAwareTestNGReporter", e ); - } + @SuppressWarnings( "unchecked" ) Constructor<?> ctor = + c.getConstructor( RunListener.class, TestNgTestSuite.class ); + return (TestNGReporter) ctor.newInstance( reportManager, suite ); + } + catch ( InvocationTargetException e ) + { + throw new RuntimeException( "Bug in ConfigurationAwareTestNGReporter", e.getCause() ); } catch ( ClassNotFoundException e ) { return new TestNGReporter( reportManager ); } + catch ( Exception e ) + { + throw new RuntimeException( "Bug in ConfigurationAwareTestNGReporter", e ); + } } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/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 c9bed46..7b432d9 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 @@ -22,7 +22,7 @@ package org.apache.maven.surefire.testng; import java.io.File; import java.util.Collection; import java.util.Iterator; -import java.util.Properties; +import java.util.Map; import org.apache.maven.surefire.providerapi.AbstractProvider; import org.apache.maven.surefire.providerapi.ProviderParameters; import org.apache.maven.surefire.report.ReporterConfiguration; @@ -42,7 +42,7 @@ import org.apache.maven.surefire.util.TestsToRun; public class TestNGProvider extends AbstractProvider { - private final Properties providerProperties; + private final Map<String, String> providerProperties; private final ReporterConfiguration reporterConfiguration; @@ -54,24 +54,19 @@ public class TestNGProvider private final ProviderParameters providerParameters; - private TestsToRun testsToRun; - private final RunOrderCalculator runOrderCalculator; + private TestsToRun testsToRun; + public TestNGProvider( ProviderParameters booterParameters ) { - this.providerParameters = booterParameters; - this.testClassLoader = booterParameters.getTestClassLoader(); - this.runOrderCalculator = booterParameters.getRunOrderCalculator(); - this.providerProperties = booterParameters.getProviderProperties(); - this.testRequest = booterParameters.getTestRequest(); + providerParameters = booterParameters; + testClassLoader = booterParameters.getTestClassLoader(); + runOrderCalculator = booterParameters.getRunOrderCalculator(); + providerProperties = booterParameters.getProviderProperties(); + testRequest = booterParameters.getTestRequest(); reporterConfiguration = booterParameters.getReporterConfiguration(); - this.scanResult = booterParameters.getScanResult(); - } - - public Boolean isRunnable() - { - return Boolean.TRUE; + scanResult = booterParameters.getScanResult(); } public RunResult invoke( Object forkTestSet ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/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 590b699..552e482 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 @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Properties; import org.apache.maven.surefire.report.ConsoleOutputCapture; import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.ReporterFactory; @@ -46,7 +45,7 @@ public class TestNGXmlTestSuite private final String testSourceDirectory; - private final Map options; + private final Map<String, String> options; private final File reportsDirectory; @@ -57,7 +56,7 @@ public class TestNGXmlTestSuite * 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, Properties confOptions, + public TestNGXmlTestSuite( List<File> suiteFiles, String testSourceDirectory, Map<String, String> confOptions, File reportsDirectory ) { this.suiteFiles = suiteFiles; @@ -124,11 +123,7 @@ public class TestNGXmlTestSuite public String getSuiteName() { - String result = (String) options.get( "suitename" ); - if ( result == null ) - { - result = "TestSuite"; - } - return result; + String result = options.get( "suitename" ); + return result == null ? "TestSuite" : result; } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java index 1c77c83..a9cdc50 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java @@ -22,7 +22,6 @@ package org.apache.maven.surefire.testng.conf; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -38,11 +37,11 @@ import org.testng.xml.XmlSuite; public abstract class AbstractDirectConfigurator implements Configurator { - final Map setters; + final Map<String, Setter> setters; AbstractDirectConfigurator() { - Map options = new HashMap(); + Map<String, Setter> options = new HashMap<String, Setter>(); // options.put( ProviderParameterNames.TESTNG_GROUPS_PROP, new Setter( "setGroups", String.class ) ); // options.put( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP, new Setter( "setExcludedGroups", String.class // ) ); @@ -52,12 +51,12 @@ public abstract class AbstractDirectConfigurator this.setters = options; } - public void configure( TestNG testng, Map options ) + public void configure( TestNG testng, Map<String, String> options ) throws TestSetFailedException { System.out.println( "\n\n\n\nCONFIGURING TESTNG\n\n\n\n" ); // kind of ugly, but listeners are configured differently - final String listeners = (String) options.remove( "listener" ); + final String listeners = options.remove( "listener" ); // DGF In 4.7, default listeners dump XML files in the surefire-reports directory, // confusing the report plugin. This was fixed in later versions. testng.setUseDefaultListeners( false ); @@ -66,23 +65,22 @@ public abstract class AbstractDirectConfigurator testng.setListenerClasses( loadListenerClasses( listeners ) ); } - public void configure( XmlSuite suite, Map options ) + public void configure( XmlSuite suite, Map<String, String> options ) throws TestSetFailedException { - Map filtered = filterForSuite( options ); + Map<String, String> filtered = filterForSuite( options ); configureInstance( suite, filtered ); } - - protected Map filterForSuite( Map options ) + protected Map<String, String> filterForSuite( Map<String, String> options ) { - Map result = new HashMap(); + Map<String, String> result = new HashMap<String, String>(); addPropIfNotNull( options, result, ProviderParameterNames.PARALLEL_PROP ); addPropIfNotNull( options, result, ProviderParameterNames.THREADCOUNT_PROP ); return result; } - private void addPropIfNotNull( Map options, Map result, String prop ) + private void addPropIfNotNull( Map<String, String> options, Map<String, String> result, String prop ) { if ( options.containsKey( prop ) ) { @@ -90,51 +88,47 @@ public abstract class AbstractDirectConfigurator } } - private void configureInstance( Object testngInstance, Map options ) + private void configureInstance( Object testngInstance, Map<String, String> options ) { - for ( Iterator it = options.entrySet().iterator(); it.hasNext(); ) + for ( Map.Entry<String, String> entry : options.entrySet() ) { - Map.Entry entry = (Map.Entry) it.next(); - String key = (String) entry.getKey(); - Object val = entry.getValue(); - - Setter setter = (Setter) setters.get( key ); + String key = entry.getKey(); + String val = entry.getValue(); + Setter setter = setters.get( key ); if ( setter != null ) { try { setter.invoke( testngInstance, val ); } - catch ( Exception ex ) + catch ( Exception e ) { - throw new RuntimeException( "Cannot set option " + key + " with value " + val, ex ); + throw new RuntimeException( "Cannot set option " + key + " with value " + val, e ); } - } } } - public static List loadListenerClasses( String listenerClasses ) + static List<Class> loadListenerClasses( String listenerClasses ) throws TestSetFailedException { if ( listenerClasses == null || "".equals( listenerClasses.trim() ) ) { - return new ArrayList(); + return new ArrayList<Class>(); } - List classes = new ArrayList(); + List<Class> classes = new ArrayList<Class>(); String[] classNames = listenerClasses.split( "\\s*,\\s*(\\r?\\n)?\\s*" ); - for ( int i = 0; i < classNames.length; i++ ) + for ( String className : classNames ) { - String className = classNames[i]; - Class clazz = loadClass( className ); + Class<?> clazz = loadClass( className ); classes.add( clazz ); } return classes; } - public static Class loadClass( String className ) + static Class<?> loadClass( String className ) throws TestSetFailedException { try @@ -155,42 +149,42 @@ public abstract class AbstractDirectConfigurator { private final String setterName; - private final Class paramClass; + private final Class<?> paramClass; - public Setter( String name, Class clazz ) + public Setter( String name, Class<?> clazz ) { - this.setterName = name; - this.paramClass = clazz; + setterName = name; + paramClass = clazz; } - public void invoke( Object target, Object value ) + public void invoke( Object target, String value ) throws Exception { - Method setter = target.getClass().getMethod( this.setterName, new Class[]{ this.paramClass } ); + Method setter = target.getClass().getMethod( setterName, paramClass ); if ( setter != null ) { - setter.invoke( target, new Object[]{ convertValue( value ) } ); + setter.invoke( target, convertValue( value ) ); } } - Object convertValue( Object value ) + private Object convertValue( String value ) { if ( value == null ) { - return value; + return null; } - if ( this.paramClass.isAssignableFrom( value.getClass() ) ) + if ( paramClass.isAssignableFrom( value.getClass() ) ) { return value; } - if ( Boolean.class.equals( this.paramClass ) || boolean.class.equals( this.paramClass ) ) + if ( Boolean.class.equals( paramClass ) || boolean.class.equals( paramClass ) ) { - return Boolean.valueOf( value.toString() ); + return Boolean.valueOf( value ); } - if ( Integer.class.equals( this.paramClass ) || int.class.equals( this.paramClass ) ) + if ( Integer.class.equals( paramClass ) || int.class.equals( paramClass ) ) { - return new Integer( value.toString() ); + return new Integer( value ); } return value; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/Configurator.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/Configurator.java index ddad3d9..ba23dc8 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/Configurator.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/Configurator.java @@ -31,9 +31,9 @@ import org.testng.xml.XmlSuite; */ public interface Configurator { - void configure( TestNG testng, Map options ) + void configure( TestNG testng, Map<String, String> options ) throws TestSetFailedException; - void configure ( XmlSuite suite, Map options ) + void configure ( XmlSuite suite, Map<String, String> options ) throws TestSetFailedException; } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java index 9c6abd4..a14dcaf 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG652Configurator.java @@ -19,7 +19,6 @@ package org.apache.maven.surefire.testng.conf; * under the License. */ -import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import org.apache.maven.surefire.testset.TestSetFailedException; @@ -34,14 +33,13 @@ public class TestNG652Configurator extends TestNGMapConfigurator { - Map getConvertedOptions( Map options ) + Map<String, Object> getConvertedOptions( Map<String, String> options ) throws TestSetFailedException { - Map convertedOptions = super.getConvertedOptions( options ); - for ( Iterator iterator = convertedOptions.entrySet().iterator(); iterator.hasNext(); ) + Map<String, Object> convertedOptions = super.getConvertedOptions( options ); + for ( Entry<String, Object> entry : convertedOptions.entrySet() ) { - Entry entry = (Entry) iterator.next(); - String key = (String) entry.getKey(); + String key = entry.getKey(); if ( "-objectfactory".equals( key ) ) { Class value = (Class) entry.getValue(); @@ -51,4 +49,4 @@ public class TestNG652Configurator } return convertedOptions; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/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 004004f..ff7378d 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 @@ -22,7 +22,6 @@ package org.apache.maven.surefire.testng.conf; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import org.apache.maven.surefire.booter.ProviderParameterNames; @@ -46,53 +45,51 @@ import org.testng.xml.XmlSuite; public class TestNGMapConfigurator implements Configurator { - public void configure( TestNG testng, Map options ) + public void configure( TestNG testng, Map<String, String> options ) throws TestSetFailedException { Map convertedOptions = getConvertedOptions( options ); testng.configure( convertedOptions ); } - public void configure( XmlSuite suite, Map options ) + public void configure( XmlSuite suite, Map<String, String> options ) throws TestSetFailedException { - String threadCountString = (String) options.get( ProviderParameterNames.THREADCOUNT_PROP ); + String threadCountString = options.get( ProviderParameterNames.THREADCOUNT_PROP ); int threadCount = ( null != threadCountString ) ? Integer.parseInt( threadCountString ) : 1; suite.setThreadCount( threadCount ); - String parallel = (String) options.get( ProviderParameterNames.PARALLEL_PROP ); + String parallel = options.get( ProviderParameterNames.PARALLEL_PROP ); if ( parallel != null ) { suite.setParallel( parallel ); } } - Map getConvertedOptions( Map options ) + Map<String, Object> getConvertedOptions( Map<String, String> options ) throws TestSetFailedException { - Map convertedOptions = new HashMap(); - convertedOptions.put( "-mixed", Boolean.FALSE ); - for ( Iterator it = options.entrySet().iterator(); it.hasNext(); ) + Map<String, Object> convertedOptions = new HashMap<String, Object>(); + convertedOptions.put( "-mixed", false ); + for ( Map.Entry<String, String> entry : options.entrySet() ) { - Map.Entry entry = (Map.Entry) it.next(); - String key = (String) entry.getKey(); + String key = entry.getKey(); Object val = entry.getValue(); if ( "listener".equals( key ) ) { - val = AbstractDirectConfigurator.loadListenerClasses( (String) val ); + val = AbstractDirectConfigurator.loadListenerClasses( entry.getValue() ); } - if ( "objectfactory".equals( key ) ) + else if ( "objectfactory".equals( key ) ) { - val = AbstractDirectConfigurator.loadClass( (String) val ); + val = AbstractDirectConfigurator.loadClass( entry.getValue() ); } - if ( "reporter".equals( key ) ) + else if ( "reporter".equals( key ) ) { // TODO support multiple reporters? val = convertReporterConfig( val ); key = "reporterslist"; - } - if ( "junit".equals( key ) ) + else if ( "junit".equals( key ) ) { val = convert( val, Boolean.class ); } @@ -114,7 +111,7 @@ public class TestNGMapConfigurator } else if ( ProviderParameterNames.THREADCOUNT_PROP.equals( key ) ) { - val = convert( val, String.class ); + val = convert ( val, String.class ); } // TODO objectfactory... not even documented, does it work? if ( key.startsWith( "-" ) ) @@ -135,10 +132,10 @@ public class TestNGMapConfigurator final String reporterConfigClassName = "org.testng.ReporterConfig"; try { - Class reporterConfig = Class.forName( reporterConfigClassName ); - Method deserialize = reporterConfig.getMethod( "deserialize", new Class[]{ String.class } ); - Object rc = deserialize.invoke( null, new Object[]{ val } ); - ArrayList reportersList = new ArrayList(); + Class<?> reporterConfig = Class.forName( reporterConfigClassName ); + Method deserialize = reporterConfig.getMethod( "deserialize", String.class ); + Object rc = deserialize.invoke( null, val ); + ArrayList<Object> reportersList = new ArrayList<Object>(); reportersList.add( rc ); return reportersList; } @@ -148,7 +145,7 @@ public class TestNGMapConfigurator } } - protected Object convert( Object val, Class type ) + protected Object convert( Object val, Class<?> type ) { if ( val == null ) { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/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 556ebea..06cf30d 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 @@ -41,8 +41,8 @@ public class TestNGMapConfiguratorTest throws Exception { Map convertedOptions = getConvertedOptions( "mixed", "true" ); - Boolean bool = (Boolean) convertedOptions.get( "-mixed" ); - assertTrue( bool.booleanValue() ); + boolean bool = (Boolean) convertedOptions.get( "-mixed" ); + assertTrue( bool ); } public void testListenersOnSeparateLines() @@ -69,15 +69,15 @@ public class TestNGMapConfiguratorTest throws Exception { Map convertedOptions = getConvertedOptions( "group-by-instances", "true" ); - Boolean bool = (Boolean) convertedOptions.get( "-group-by-instances" ); - assertTrue( bool.booleanValue() ); + boolean bool = (Boolean) convertedOptions.get( "-group-by-instances" ); + assertTrue( bool ); } private Map getConvertedOptions( String key, String value ) throws TestSetFailedException { TestNGMapConfigurator testNGMapConfigurator = new TestNGMapConfigurator(); - Map raw = new HashMap(); + 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/84fd7235/surefire-setup-integration-tests/src/test/java/org/apache/maven/surefire/its/StagedLocalRepoHelper.java ---------------------------------------------------------------------- diff --git a/surefire-setup-integration-tests/src/test/java/org/apache/maven/surefire/its/StagedLocalRepoHelper.java b/surefire-setup-integration-tests/src/test/java/org/apache/maven/surefire/its/StagedLocalRepoHelper.java index 58ce57d..1252553 100644 --- a/surefire-setup-integration-tests/src/test/java/org/apache/maven/surefire/its/StagedLocalRepoHelper.java +++ b/surefire-setup-integration-tests/src/test/java/org/apache/maven/surefire/its/StagedLocalRepoHelper.java @@ -21,7 +21,6 @@ package org.apache.maven.surefire.its; import java.io.File; import java.io.IOException; -import java.util.Iterator; import java.util.List; import java.util.Random; import org.apache.maven.settings.Profile; @@ -116,9 +115,9 @@ public final class StagedLocalRepoHelper settings.addActiveProfile( profile.getId() ); settings.setLocalRepository( stagedLocalRepo.getAbsolutePath() ); - for ( Iterator<Profile> it = settings.getProfiles().iterator(); it.hasNext(); ) + for ( Object o : settings.getProfiles() ) { - profile = it.next(); + profile = (Profile) o; disableUpdates( profile.getRepositories() ); disableUpdates( profile.getPluginRepositories() ); } @@ -137,11 +136,9 @@ public final class StagedLocalRepoHelper { if ( repositories != null ) { - for ( Iterator<Repository> it = repositories.iterator(); it.hasNext(); ) - { - Repository repo = it.next(); - repo.setReleases( disableUpdates( repo.getReleases() ) ); - repo.setSnapshots( disableUpdates( repo.getSnapshots() ) ); + for (Repository repo : repositories) { + repo.setReleases(disableUpdates(repo.getReleases())); + repo.setSnapshots(disableUpdates(repo.getSnapshots())); } } }