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/05/06 09:15:21 UTC
[1/3] maven-surefire git commit: [SUREFIRE] Refactoring
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()));
}
}
}
[3/3] maven-surefire git commit: [SUREFIRE] Refactoring
Posted by ti...@apache.org.
[SUREFIRE] Refactoring
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/84fd7235
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/84fd7235
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/84fd7235
Branch: refs/heads/master
Commit: 84fd7235b6214fae9a32b44d748e0b519dde5058
Parents: c02be38
Author: Tibor17 <ti...@lycos.com>
Authored: Wed May 6 02:45:56 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Wed May 6 09:14:35 2015 +0200
----------------------------------------------------------------------
.../plugin/failsafe/IntegrationTestMojo.java | 21 +-
.../maven/plugin/failsafe/VerifyMojo.java | 2 +-
.../plugin/surefire/AbstractSurefireMojo.java | 23 +-
.../surefire/InPluginVMSurefireStarter.java | 6 +-
.../maven/plugin/surefire/ProviderList.java | 2 +-
.../surefire/SurefireExecutionParameters.java | 2 +-
.../plugin/surefire/SurefireProperties.java | 15 +-
.../surefire/SurefireReportParameters.java | 2 +-
.../surefire/booterclient/BooterSerializer.java | 2 +-
.../booterclient/ChecksumCalculator.java | 2 +-
.../surefire/booterclient/ForkStarter.java | 53 ++-
.../surefire/report/StatelessXmlReporter.java | 4 +-
...erDeserializerProviderConfigurationTest.java | 39 +--
...terDeserializerStartupConfigurationTest.java | 34 +-
.../surefire/util/DependenciesScannerTest.java | 24 +-
.../surefire/util/DirectoryScannerTest.java | 16 +-
.../maven/plugin/surefire/SurefirePlugin.java | 2 +-
.../report/AbstractSurefireReportMojo.java | 2 +-
.../report/SurefireReportGenerator.java | 189 +++++------
.../surefire/runorder/RunEntryStatistics.java | 12 +-
.../runorder/RunEntryStatisticsMap.java | 33 +-
.../surefire/booter/BaseProviderFactory.java | 42 +--
.../surefire/booter/ForkingReporterFactory.java | 4 +-
.../surefire/booter/ForkingRunListener.java | 11 +-
.../booter/ProviderPropertiesAware.java | 4 +-
.../surefire/booter/SurefireReflector.java | 47 ++-
.../providerapi/ProviderParameters.java | 5 +-
.../surefire/report/ReporterConfiguration.java | 6 +-
.../testset/DirectoryScannerParameters.java | 8 +-
.../util/DefaultRunOrderCalculator.java | 15 +-
.../maven/surefire/util/DefaultScanResult.java | 10 +-
.../maven/surefire/util/ReflectionUtils.java | 6 +-
.../apache/maven/surefire/util/ScanResult.java | 4 +-
.../apache/maven/surefire/util/TestsToRun.java | 12 +-
.../surefire/booter/SurefireReflectorTest.java | 47 +++
.../maven/surefire/util/ScanResultTest.java | 9 +-
.../apache/maven/surefire/booter/Classpath.java | 9 +-
.../maven/surefire/booter/ForkedBooter.java | 2 +-
.../maven/surefire/booter/KeyValueSource.java | 2 +-
.../surefire/booter/PropertiesWrapper.java | 93 +++---
.../surefire/booter/ProviderConfiguration.java | 13 +-
.../surefire/booter/SystemPropertyManager.java | 16 +-
.../org/apache/maven/surefire/booter/Foo.java | 6 +-
.../surefire/booter/PropertiesWrapperTest.java | 11 +-
.../surefire/booter/SurefireReflectorTest.java | 10 +-
.../surefire/its/fixture/HelperAssertions.java | 2 +-
.../surefire/testprovider/TestProvider.java | 6 -
.../common/junit4/JUnit4RunListener.java | 4 +-
.../surefire/common/junit48/FilterFactory.java | 7 +-
.../maven/surefire/junit4/JUnit4Provider.java | 2 +-
.../surefire/junit4/JUnit4ProviderTest.java | 13 +-
.../surefire/junitcore/JUnitCoreParameters.java | 55 +++-
.../surefire/junitcore/JUnitCoreProvider.java | 7 +-
.../junitcore/JUnitCoreParametersTest.java | 57 ++--
.../surefire/junitcore/Surefire746Test.java | 10 +-
.../pc/OptimizedParallelComputerTest.java | 85 ++---
.../junitcore/pc/ParallelComputerUtilTest.java | 328 +++++++++----------
.../utils/GroupMatcherMethodSelector.java | 2 +-
.../testng/TestNGDirectoryTestSuite.java | 104 +++---
.../maven/surefire/testng/TestNGExecutor.java | 50 +--
.../maven/surefire/testng/TestNGProvider.java | 25 +-
.../surefire/testng/TestNGXmlTestSuite.java | 13 +-
.../testng/conf/AbstractDirectConfigurator.java | 78 ++---
.../surefire/testng/conf/Configurator.java | 4 +-
.../testng/conf/TestNG652Configurator.java | 12 +-
.../testng/conf/TestNGMapConfigurator.java | 43 ++-
.../testng/conf/TestNGMapConfiguratorTest.java | 10 +-
.../surefire/its/StagedLocalRepoHelper.java | 13 +-
68 files changed, 860 insertions(+), 947 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
----------------------------------------------------------------------
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
index baa8a98..2c2339a 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
@@ -20,8 +20,6 @@ package org.apache.maven.plugin.failsafe;
*/
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
@@ -38,8 +36,6 @@ import org.apache.maven.shared.utils.ReaderFactory;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.surefire.suite.RunResult;
-import static org.apache.maven.shared.utils.io.IOUtil.close;
-
/**
* Run integration tests using Surefire.
*
@@ -310,16 +306,10 @@ public class IntegrationTestMojo
return rerunFailingTestsCount;
}
+ @SuppressWarnings( "unchecked" )
protected void handleSummary( RunResult summary, Exception firstForkException )
throws MojoExecutionException, MojoFailureException
{
- writeSummary( summary, firstForkException );
- }
-
- @SuppressWarnings( "unchecked" )
- private void writeSummary( RunResult summary, Exception firstForkException )
- throws MojoExecutionException
- {
File summaryFile = getSummaryFile();
if ( !summaryFile.getParentFile().isDirectory() )
{
@@ -327,8 +317,6 @@ public class IntegrationTestMojo
summaryFile.getParentFile().mkdirs();
}
- FileOutputStream fout = null;
- FileInputStream fin = null;
try
{
Object token = getPluginContext().get( FAILSAFE_IN_PROGRESS_CONTEXT_KEY );
@@ -338,11 +326,6 @@ public class IntegrationTestMojo
{
throw new MojoExecutionException( e.getMessage(), e );
}
- finally
- {
- close( fin );
- close( fout );
- }
getPluginContext().put( FAILSAFE_IN_PROGRESS_CONTEXT_KEY, FAILSAFE_IN_PROGRESS_CONTEXT_KEY );
}
@@ -606,7 +589,7 @@ public class IntegrationTestMojo
return failIfNoSpecifiedTests;
}
- public void setFailIfNoSpecifiedTests( Boolean failIfNoSpecifiedTests )
+ public void setFailIfNoSpecifiedTests( boolean failIfNoSpecifiedTests )
{
this.failIfNoSpecifiedTests = failIfNoSpecifiedTests;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
----------------------------------------------------------------------
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
index 4f9cdf2..b3b60c6 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
@@ -334,7 +334,7 @@ public class VerifyMojo
return failIfNoTests;
}
- public void setFailIfNoTests( Boolean failIfNoTests )
+ public void setFailIfNoTests( boolean failIfNoTests )
{
this.failIfNoTests = failIfNoTests;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/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 33b90bd..46256d3 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
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -35,6 +36,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -1442,7 +1444,7 @@ public abstract class AbstractSurefireMojo
specificTests, actualFailIfNoTests, getRunOrder() );
}
- Properties providerProperties = getProperties();
+ Map<String, String> providerProperties = toStringProperties( getProperties() );
return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, actualFailIfNoTests,
reporterConfiguration,
@@ -1451,6 +1453,21 @@ public abstract class AbstractSurefireMojo
false );
}
+ private static Map<String, String> toStringProperties( Properties properties )
+ {
+ Map<String, String> h = new ConcurrentHashMap<String, String>( properties.size() );
+ for ( Enumeration e = properties.keys() ; e.hasMoreElements() ; )
+ {
+ Object k = e.nextElement();
+ Object v = properties.get( k );
+ if ( k.getClass() == String.class && v.getClass() == String.class )
+ {
+ h.put( (String) k, (String) v );
+ }
+ }
+ return h;
+ }
+
public String getStatisticsFileName( String configurationHash )
{
return getReportsDirectory().getParentFile().getParentFile() + File.separator + ".surefire-"
@@ -2587,7 +2604,7 @@ public abstract class AbstractSurefireMojo
this.systemPropertiesFile = systemPropertiesFile;
}
- public Properties getProperties()
+ private Properties getProperties()
{
return properties;
}
@@ -2649,7 +2666,7 @@ public abstract class AbstractSurefireMojo
return failIfNoTests;
}
- public void setFailIfNoTests( Boolean failIfNoTests )
+ public void setFailIfNoTests( boolean failIfNoTests )
{
this.failIfNoTests = failIfNoTests;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/InPluginVMSurefireStarter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/InPluginVMSurefireStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/InPluginVMSurefireStarter.java
index ec864c3..5ab361d 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/InPluginVMSurefireStarter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/InPluginVMSurefireStarter.java
@@ -19,8 +19,6 @@ package org.apache.maven.plugin.surefire;
* under the License.
*/
-import java.lang.reflect.InvocationTargetException;
-import java.util.Properties;
import org.apache.maven.surefire.booter.ProviderConfiguration;
import org.apache.maven.surefire.booter.ProviderFactory;
import org.apache.maven.surefire.booter.StartupConfiguration;
@@ -30,6 +28,8 @@ import org.apache.maven.surefire.testset.TestSetFailedException;
import org.apache.maven.surefire.util.DefaultScanResult;
import javax.annotation.Nonnull;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
/**
* Starts the provider in the same VM as the surefire plugin.
@@ -67,7 +67,7 @@ public class InPluginVMSurefireStarter
// The test classloader must be constructed first to avoid issues with commons-logging until we properly
// separate the TestNG classloader
- Properties providerProperties = providerConfiguration.getProviderProperties();
+ Map<String, String> providerProperties = providerConfiguration.getProviderProperties();
scanResult.writeTo( providerProperties );
startupConfiguration.writeSurefireTestClasspathProperty();
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java
index 21e95d2..fe02d56 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java
@@ -51,7 +51,7 @@ public class ProviderList
List<ProviderInfo> providersToRun = new ArrayList<ProviderInfo>();
Set<String> manuallyConfiguredProviders = getManuallyConfiguredProviders();
- if ( manuallyConfiguredProviders.size() > 0 )
+ if ( !manuallyConfiguredProviders.isEmpty() )
{
for ( String name : manuallyConfiguredProviders )
{
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
index 48e3fd9..65c4062 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
@@ -117,5 +117,5 @@ public interface SurefireExecutionParameters
Boolean getFailIfNoSpecifiedTests();
- void setFailIfNoSpecifiedTests( Boolean failIfNoSpecifiedTests );
+ void setFailIfNoSpecifiedTests( boolean failIfNoSpecifiedTests );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
index 71cf121..0cb9e73 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
@@ -27,7 +27,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -108,7 +107,6 @@ public class SurefireProperties
public Iterable<Object> getStringKeySet()
{
-
//noinspection unchecked
return keySet();
}
@@ -176,16 +174,9 @@ public class SurefireProperties
}
}
- public void copyTo( Map target )
+ public void copyTo( Map<Object, Object> target )
{
- Iterator iter = keySet().iterator();
- Object key;
- while ( iter.hasNext() )
- {
- key = iter.next();
- //noinspection unchecked
- target.put( key, get( key ) );
- }
+ target.putAll( this );
}
public void setProperty( String key, File file )
@@ -206,7 +197,7 @@ public class SurefireProperties
public void addList( List items, String propertyPrefix )
{
- if ( items == null || items.size() == 0 )
+ if ( items == null || items.isEmpty() )
{
return;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java
index f47331e..2999787 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java
@@ -59,5 +59,5 @@ public interface SurefireReportParameters
Boolean getFailIfNoTests();
- void setFailIfNoTests( Boolean failIfNoTests );
+ void setFailIfNoTests( boolean failIfNoTests );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
index c8d1b3a..be9a284 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
@@ -125,7 +125,7 @@ class BooterSerializer
ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration();
- Boolean rep = reporterConfiguration.isTrimStackTrace();
+ boolean rep = reporterConfiguration.isTrimStackTrace();
properties.setProperty( BooterConstants.ISTRIMSTACKTRACE, rep );
properties.setProperty( BooterConstants.REPORTSDIRECTORY, reporterConfiguration.getReportsDirectory() );
ClassLoaderConfiguration classLoaderConfiguration = providerConfiguration.getClassLoaderConfiguration();
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
index 7f62768..cc6a808 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
@@ -45,7 +45,7 @@ public class ChecksumCalculator
public void add( boolean value )
{
- checksumItems.add( value ? Boolean.TRUE : Boolean.FALSE );
+ checksumItems.add( value );
}
public void add( int value )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
index b1755ba..7022bf8 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
@@ -19,27 +19,6 @@ package org.apache.maven.plugin.surefire.booterclient;
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Queue;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
import org.apache.maven.plugin.surefire.CommonReflector;
@@ -71,6 +50,27 @@ import org.apache.maven.surefire.testset.TestRequest;
import org.apache.maven.surefire.util.DefaultScanResult;
import org.apache.maven.surefire.util.internal.StringUtils;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.atomic.AtomicReference;
+
import static org.apache.maven.surefire.booter.Classpath.join;
/**
@@ -157,7 +157,7 @@ public class ForkStarter
{
try
{
- Properties providerProperties = providerConfiguration.getProviderProperties();
+ Map<String, String> providerProperties = providerConfiguration.getProviderProperties();
scanResult.writeTo( providerProperties );
return isForkOnce()
? run( effectiveSystemProperties, providerProperties )
@@ -170,7 +170,7 @@ public class ForkStarter
}
}
- private RunResult run( SurefireProperties effectiveSystemProperties, Properties providerProperties )
+ private RunResult run( SurefireProperties effectiveSystemProperties, Map<String, String> providerProperties )
throws SurefireBooterForkException
{
DefaultReporterFactory forkedReporterFactory = new DefaultReporterFactory( startupReportConfiguration );
@@ -215,8 +215,7 @@ public class ForkStarter
RunResult globalResult = new RunResult( 0, 0, 0, 0 );
List<Class<?>> suites = new ArrayList<Class<?>>();
- Iterator<Class<?>> suitesIterator = getSuitesIterator();
- while ( suitesIterator.hasNext() )
+ for ( Iterator<Class<?>> suitesIterator = getSuitesIterator(); suitesIterator.hasNext(); )
{
suites.add( suitesIterator.next() );
}
@@ -298,8 +297,8 @@ public class ForkStarter
{
// Ask to the executorService to run all tasks
RunResult globalResult = new RunResult( 0, 0, 0, 0 );
- final Iterator<Class<?>> suites = getSuitesIterator();
- while ( suites.hasNext() )
+
+ for ( final Iterator<Class<?>> suites = getSuitesIterator(); suites.hasNext(); )
{
final Object testSet = suites.next();
Callable<RunResult> pf = new Callable<RunResult>()
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index ae78e15..5295cc3 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -141,7 +141,7 @@ public class StatelessXmlReporter
{
throw new IllegalStateException( "Get null test method run history" );
}
- if ( methodEntryList.size() == 0 )
+ if ( methodEntryList.isEmpty() )
{
continue;
}
@@ -290,7 +290,7 @@ public class StatelessXmlReporter
{
throw new IllegalStateException( "Get null test method run history" );
}
- if ( methodEntryList.size() == 0 )
+ if ( methodEntryList.isEmpty() )
{
continue;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
index 1713476..c3a2e63 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
@@ -19,32 +19,17 @@ package org.apache.maven.plugin.surefire.booterclient;
* under the License.
*/
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-import org.apache.maven.surefire.booter.BooterDeserializer;
-import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
-import org.apache.maven.surefire.booter.ClasspathConfiguration;
-import org.apache.maven.surefire.booter.PropertiesWrapper;
-import org.apache.maven.surefire.booter.ProviderConfiguration;
-import org.apache.maven.surefire.booter.StartupConfiguration;
-import org.apache.maven.surefire.booter.TypeEncodedValue;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.maven.surefire.booter.*;
import org.apache.maven.surefire.report.ReporterConfiguration;
-import org.apache.maven.surefire.testset.DirectoryScannerParameters;
-import org.apache.maven.surefire.testset.ResolvedTest;
-import org.apache.maven.surefire.testset.RunOrderParameters;
-import org.apache.maven.surefire.testset.TestArtifactInfo;
-import org.apache.maven.surefire.testset.TestListResolver;
-import org.apache.maven.surefire.testset.TestRequest;
+import org.apache.maven.surefire.testset.*;
import org.apache.maven.surefire.util.RunOrder;
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.*;
/**
* Performs roundtrip testing of serialization/deserialization of the ProviderConfiguration
@@ -201,7 +186,7 @@ public class BooterDeserializerProviderConfigurationTest
excludes.add( "xx1" );
excludes.add( "xx2" );
- return new DirectoryScannerParameters( aDir, includes, excludes, Collections.emptyList(), Boolean.TRUE,
+ return new DirectoryScannerParameters( aDir, includes, excludes, Collections.emptyList(), true,
RunOrder.asString( RunOrder.DEFAULT ) );
}
@@ -211,7 +196,7 @@ public class BooterDeserializerProviderConfigurationTest
throws IOException
{
final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration( null, null );
- PropertiesWrapper props = new PropertiesWrapper( new Properties() );
+ PropertiesWrapper props = new PropertiesWrapper( new HashMap<String, String>() );
BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration );
Object test;
if ( readTestsFromInStream )
@@ -239,8 +224,8 @@ public class BooterDeserializerProviderConfigurationTest
rerunFailingTestsCount );
RunOrderParameters runOrderParameters = new RunOrderParameters( RunOrder.DEFAULT, null );
return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, true, reporterConfiguration,
- new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new Properties(),
- aTestTyped, readTestsFromInStream );
+ new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new HashMap<String, String>(), aTestTyped,
+ readTestsFromInStream );
}
private StartupConfiguration getTestStartupConfiguration( ClassLoaderConfiguration classLoaderConfiguration )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
index 90af606..14c5b61 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
@@ -19,28 +19,18 @@ package org.apache.maven.plugin.surefire.booterclient;
* under the License.
*/
+import junit.framework.TestCase;
+import org.apache.maven.surefire.booter.*;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.testset.*;
+import org.apache.maven.surefire.util.RunOrder;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Properties;
-import org.apache.maven.surefire.booter.BooterDeserializer;
-import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
-import org.apache.maven.surefire.booter.Classpath;
-import org.apache.maven.surefire.booter.ClasspathConfiguration;
-import org.apache.maven.surefire.booter.PropertiesWrapper;
-import org.apache.maven.surefire.booter.ProviderConfiguration;
-import org.apache.maven.surefire.booter.StartupConfiguration;
-import org.apache.maven.surefire.report.ReporterConfiguration;
-import org.apache.maven.surefire.testset.DirectoryScannerParameters;
-import org.apache.maven.surefire.testset.RunOrderParameters;
-import org.apache.maven.surefire.testset.TestArtifactInfo;
-import org.apache.maven.surefire.testset.TestListResolver;
-import org.apache.maven.surefire.testset.TestRequest;
-import org.apache.maven.surefire.util.RunOrder;
-
-import junit.framework.TestCase;
+import java.util.HashMap;
/**
* Performs roundtrip testing of serialization/deserialization of The StartupConfiguration
@@ -121,7 +111,7 @@ public class BooterDeserializerStartupConfigurationTest
throws IOException
{
final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration( null, null );
- PropertiesWrapper props = new PropertiesWrapper( new Properties() );
+ PropertiesWrapper props = new PropertiesWrapper( new HashMap<String, String>() );
BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration );
String aTest = "aTest";
final File propsTest =
@@ -136,16 +126,16 @@ public class BooterDeserializerStartupConfigurationTest
File cwd = new File( "." );
DirectoryScannerParameters directoryScannerParameters =
new DirectoryScannerParameters( cwd, new ArrayList<String>(), new ArrayList<String>(),
- new ArrayList<String>(), Boolean.TRUE, "hourly" );
- ReporterConfiguration reporterConfiguration = new ReporterConfiguration( cwd, Boolean.TRUE );
+ new ArrayList<String>(), true, "hourly" );
+ ReporterConfiguration reporterConfiguration = new ReporterConfiguration( cwd, true );
TestRequest testSuiteDefinition =
new TestRequest( Arrays.asList( getSuiteXmlFileStrings() ), getTestSourceDirectory(),
new TestListResolver( "aUserRequestedTest#aUserRequestedTestMethod" ));
RunOrderParameters runOrderParameters = new RunOrderParameters( RunOrder.DEFAULT, null );
return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, true, reporterConfiguration,
- new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new Properties(),
- BooterDeserializerProviderConfigurationTest.aTestTyped, true );
+ new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new HashMap<String, String>(),
+ BooterDeserializerProviderConfigurationTest.aTestTyped, true );
}
private StartupConfiguration getTestStartupConfiguration( ClassLoaderConfiguration classLoaderConfiguration )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java
index 3fc0976..f4eb9e8 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java
@@ -19,27 +19,19 @@ package org.apache.maven.plugin.surefire.util;
* under the License.
*/
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
import junit.framework.TestCase;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.surefire.testset.TestListResolver;
-import org.apache.maven.surefire.testset.TestSetFailedException;
import org.apache.maven.surefire.util.ScanResult;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
/**
* @author Aslak Knutsen
*/
@@ -65,7 +57,7 @@ public class DependenciesScannerTest
List<String> exclude = new ArrayList<String>();
DependencyScanner scanner = new DependencyScanner(
- DependencyScanner.filter(Arrays.asList(artifact), scanDependencies),
+ DependencyScanner.filter(Collections.singletonList(artifact), scanDependencies),
new TestListResolver( include, exclude ), new TestListResolver( "" ) );
ScanResult classNames = scanner.scan();
@@ -74,7 +66,7 @@ public class DependenciesScannerTest
assertEquals( 1, classNames.size() );
System.out.println(classNames.getClassName(0));
- Properties props = new Properties();
+ Map<String, String> props = new HashMap<String, String>();
classNames.writeTo( props );
assertEquals( 1, props.size() );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DirectoryScannerTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DirectoryScannerTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DirectoryScannerTest.java
index 4c41854..db28917 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DirectoryScannerTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DirectoryScannerTest.java
@@ -19,18 +19,12 @@ package org.apache.maven.plugin.surefire.util;
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-
+import junit.framework.TestCase;
import org.apache.maven.surefire.testset.TestListResolver;
-import org.apache.maven.surefire.testset.TestSetFailedException;
import org.apache.maven.surefire.util.ScanResult;
-import junit.framework.TestCase;
+import java.io.File;
+import java.util.*;
/**
* @author Kristian Rosenvold
@@ -52,10 +46,10 @@ public class DirectoryScannerTest
ScanResult classNames = surefireDirectoryScanner.scan();
assertNotNull( classNames );
- System.out.println( "classNames " + Arrays.asList( classNames ) );
+ System.out.println( "classNames " + Collections.singletonList(classNames));
assertEquals( 3, classNames.size() );
- Properties props = new Properties();
+ Map<String, String> props = new HashMap<String, String>();
classNames.writeTo( props );
assertEquals( 3, props.size() );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index 63441e1..4c06f6b 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -443,7 +443,7 @@ public class SurefirePlugin
return failIfNoSpecifiedTests;
}
- public void setFailIfNoSpecifiedTests( Boolean failIfNoSpecifiedTests )
+ public void setFailIfNoSpecifiedTests( boolean failIfNoSpecifiedTests )
{
this.failIfNoSpecifiedTests = failIfNoSpecifiedTests;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java
----------------------------------------------------------------------
diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java
index dcba659..aaa7cee 100644
--- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java
+++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java
@@ -243,7 +243,7 @@ public abstract class AbstractSurefireReportMojo
}
else
{
- if ( reportsDirectoryList.size() == 0 )
+ if ( reportsDirectoryList.isEmpty() )
{
reportsDirectoryList.add( getSurefireReportsDirectory( project ) );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
----------------------------------------------------------------------
diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
index 77a88c2..e4c02ec 100644
--- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
+++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
@@ -21,7 +21,6 @@ package org.apache.maven.plugins.surefire.report;
import java.io.File;
import java.text.NumberFormat;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -515,7 +514,7 @@ public class SurefireReportGenerator
sinkCell( sink, "" );
sink.tableRow_();
- List<String> detail = (List<String>) failure.get( "detail" );
+ @SuppressWarnings( "unchecked" ) List<String> detail = (List<String>) failure.get( "detail" );
if ( detail != null )
{
@@ -524,8 +523,7 @@ public class SurefireReportGenerator
sink.tableCell();
SinkEventAttributeSet atts = new SinkEventAttributeSet();
- atts.addAttribute( SinkEventAttributes.ID,
- toHtmlId( testCase.getFullName() ) + "error" );
+ atts.addAttribute( SinkEventAttributes.ID, toHtmlId( testCase.getFullName() ) + "error" );
atts.addAttribute( SinkEventAttributes.STYLE, "display:none;" );
sink.unknown( "div", new Object[]{ HtmlMarkup.TAG_TYPE_START }, atts );
@@ -560,119 +558,112 @@ public class SurefireReportGenerator
}
}
- private void constructFailureDetails( Sink sink, ResourceBundle bundle, List<ReportTestCase> failureList )
+ private void constructFailureDetails( Sink sink, ResourceBundle bundle, List<ReportTestCase> failures )
{
- Iterator<ReportTestCase> failIter = failureList.iterator();
-
- if ( failIter != null )
- {
- sink.section1();
- sink.sectionTitle1();
- sink.text( bundle.getString( "report.surefire.label.failuredetails" ) );
- sink.sectionTitle1_();
+ sink.section1();
+ sink.sectionTitle1();
+ sink.text( bundle.getString( "report.surefire.label.failuredetails" ) );
+ sink.sectionTitle1_();
- sinkAnchor( sink, "Failure_Details" );
+ sinkAnchor( sink, "Failure_Details" );
- constructHotLinks( sink, bundle );
+ constructHotLinks( sink, bundle );
- sinkLineBreak( sink );
+ sinkLineBreak( sink );
- sink.table();
+ sink.table();
- sink.tableRows( new int[]{ LEFT, LEFT }, true );
+ sink.tableRows( new int[]{ LEFT, LEFT }, true );
- while ( failIter.hasNext() )
- {
- ReportTestCase tCase = failIter.next();
+ for ( ReportTestCase tCase : failures )
+ {
+ Map<String, Object> failure = tCase.getFailure();
- Map<String, Object> failure = tCase.getFailure();
+ sink.tableRow();
- sink.tableRow();
+ sink.tableCell();
- sink.tableCell();
+ String type = (String) failure.get( "type" );
+ sinkIcon( type, sink );
- String type = (String) failure.get( "type" );
- sinkIcon( type, sink );
+ sink.tableCell_();
- sink.tableCell_();
+ sinkCellAnchor( sink, tCase.getName(), toHtmlId( tCase.getFullName() ) );
- sinkCellAnchor( sink, tCase.getName(), toHtmlId( tCase.getFullName() ) );
+ sink.tableRow_();
- sink.tableRow_();
+ String message = (String) failure.get( "message" );
- String message = (String) failure.get( "message" );
+ sink.tableRow();
- sink.tableRow();
+ sinkCell( sink, "" );
- sinkCell( sink, "" );
+ StringBuilder sb = new StringBuilder();
+ sb.append( type );
- StringBuilder sb = new StringBuilder();
- sb.append( type );
+ if ( message != null )
+ {
+ sb.append( ": " );
+ sb.append( message );
+ }
- if ( message != null )
- {
- sb.append( ": " );
- sb.append( message );
- }
+ sinkCell( sink, sb.toString() );
- sinkCell( sink, sb.toString() );
+ sink.tableRow_();
- sink.tableRow_();
+ @SuppressWarnings( "unchecked" ) List<String> detail = (List<String>) failure.get( "detail" );
+ if ( detail != null )
+ {
+ boolean firstLine = true;
- List<String> detail = (List<String>) failure.get( "detail" );
- if ( detail != null )
+ String techMessage = "";
+ for ( String line : detail )
{
- boolean firstLine = true;
-
- String techMessage = "";
- for ( String line : detail )
+ techMessage = line;
+ if ( firstLine )
{
- techMessage = line;
- if ( firstLine )
- {
- firstLine = false;
- }
- else
- {
- sink.text( " " );
- }
+ firstLine = false;
+ }
+ else
+ {
+ sink.text( " " );
}
+ }
- sink.tableRow();
+ sink.tableRow();
- sinkCell( sink, "" );
+ sinkCell( sink, "" );
- sink.tableCell();
- SinkEventAttributeSet atts = new SinkEventAttributeSet();
- atts.addAttribute( SinkEventAttributes.ID, tCase.getName() + "error" );
- sink.unknown( "div", new Object[]{ HtmlMarkup.TAG_TYPE_START }, atts );
+ sink.tableCell();
+ SinkEventAttributeSet atts = new SinkEventAttributeSet();
+ atts.addAttribute( SinkEventAttributes.ID, tCase.getName() + "error" );
+ sink.unknown( "div", new Object[]{ HtmlMarkup.TAG_TYPE_START }, atts );
- if ( xrefLocation != null )
- {
- String path = tCase.getFullClassName().replace( '.', '/' );
+ if ( xrefLocation != null )
+ {
+ String path = tCase.getFullClassName().replace( '.', '/' );
- sink.link( xrefLocation + "/" + path + ".html#"
- + getErrorLineNumber( tCase.getFullName(), techMessage ) );
- }
- sink.text(
- tCase.getFullClassName() + ":" + getErrorLineNumber( tCase.getFullName(), techMessage ) );
+ sink.link( xrefLocation + "/" + path + ".html#"
+ + getErrorLineNumber( tCase.getFullName(), techMessage ) );
+ }
+ sink.text(
+ tCase.getFullClassName() + ":" + getErrorLineNumber( tCase.getFullName(), techMessage ) );
- if ( xrefLocation != null )
- {
- sink.link_();
- }
- sink.unknown( "div", new Object[]{ HtmlMarkup.TAG_TYPE_END }, null );
+ if ( xrefLocation != null )
+ {
+ sink.link_();
+ }
+ sink.unknown( "div", new Object[]{ HtmlMarkup.TAG_TYPE_END }, null );
- sink.tableCell_();
+ sink.tableCell_();
- sink.tableRow_();
- }
+ sink.tableRow_();
}
+ }
- sink.tableRows_();
+ sink.tableRows_();
- sink.table_();
- }
+ sink.table_();
sinkLineBreak( sink );
@@ -794,28 +785,24 @@ public class SurefireReportGenerator
private static String javascriptToggleDisplayCode()
{
- final StringBuilder str = new StringBuilder( 64 );
// the javascript code is emitted within a commented CDATA section
// so we have to start with a newline and comment the CDATA closing in the end
- str.append( "\n" );
- str.append( "function toggleDisplay(elementId) {\n" );
- str.append( " var elm = document.getElementById(elementId + 'error');\n" );
- str.append( " if (elm && typeof elm.style != \"undefined\") {\n" );
- str.append( " if (elm.style.display == \"none\") {\n" );
- str.append( " elm.style.display = \"\";\n" );
- str.append( " document.getElementById(elementId + 'off').style.display = \"none\";\n" );
- str.append( " document.getElementById(elementId + 'on').style.display = \"inline\";\n" );
- str.append( " }" );
- str.append( " else if (elm.style.display == \"\") {" );
- str.append( " elm.style.display = \"none\";\n" );
- str.append( " document.getElementById(elementId + 'off').style.display = \"inline\";\n" );
- str.append( " document.getElementById(elementId + 'on').style.display = \"none\";\n" );
- str.append( " } \n" );
- str.append( " } \n" );
- str.append( " }\n" );
- str.append( "//" );
-
- return str.toString();
+
+ return "\n" + "function toggleDisplay(elementId) {\n"
+ + " var elm = document.getElementById(elementId + 'error');\n"
+ + " if (elm && typeof elm.style != \"undefined\") {\n"
+ + " if (elm.style.display == \"none\") {\n"
+ + " elm.style.display = \"\";\n"
+ + " document.getElementById(elementId + 'off').style.display = \"none\";\n"
+ + " document.getElementById(elementId + 'on').style.display = \"inline\";\n"
+ + " }" + " else if (elm.style.display == \"\") {"
+ + " elm.style.display = \"none\";\n"
+ + " document.getElementById(elementId + 'off').style.display = \"inline\";\n"
+ + " document.getElementById(elementId + 'on').style.display = \"none\";\n"
+ + " } \n"
+ + " } \n"
+ + " }\n"
+ + "//";
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatistics.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatistics.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatistics.java
index 7722943..7c794dc 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatistics.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatistics.java
@@ -71,7 +71,6 @@ public class RunEntryStatistics
return runTime;
}
-
public int getSuccessfulBuilds()
{
return successfulBuilds;
@@ -86,15 +85,10 @@ public class RunEntryStatistics
return new RunEntryStatistics( runTime, successfulBuilds, className );
}
- public String getAsString()
+ @Override
+ public String toString()
{
- StringBuilder stringBuffer = new StringBuilder();
- stringBuffer.append( successfulBuilds );
- stringBuffer.append( "," );
- stringBuffer.append( runTime );
- stringBuffer.append( "," );
- stringBuffer.append( testName );
- return stringBuffer.toString();
+ return successfulBuilds + "," + runTime + "," + testName;
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
index 5c51689..bfed9c3 100644
--- a/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
+++ b/surefire-api/src/main/java/org/apache/maven/plugin/surefire/runorder/RunEntryStatisticsMap.java
@@ -36,6 +36,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -53,7 +54,7 @@ public class RunEntryStatisticsMap
public RunEntryStatisticsMap()
{
- this( new HashMap<String, RunEntryStatistics>() );
+ runEntryStatistics = new ConcurrentHashMap<String, RunEntryStatistics>();
}
public static RunEntryStatisticsMap fromFile( File file )
@@ -62,8 +63,7 @@ public class RunEntryStatisticsMap
{
try
{
- FileReader fileReader = new FileReader( file );
- return fromReader( fileReader );
+ return fromReader( new FileReader( file ) );
}
catch ( FileNotFoundException e )
{
@@ -73,9 +73,11 @@ public class RunEntryStatisticsMap
{
throw new RuntimeException( e1 );
}
-
}
- return new RunEntryStatisticsMap();
+ else
+ {
+ return new RunEntryStatisticsMap();
+ }
}
static RunEntryStatisticsMap fromReader( Reader fileReader )
@@ -103,16 +105,13 @@ public class RunEntryStatisticsMap
PrintWriter printWriter = new PrintWriter( fos );
List<RunEntryStatistics> items = new ArrayList<RunEntryStatistics>( runEntryStatistics.values() );
Collections.sort( items, new RunCountComparator() );
- RunEntryStatistics item;
- for ( RunEntryStatistics item1 : items )
+ for ( RunEntryStatistics item : items )
{
- item = item1;
- printWriter.println( item.getAsString() );
+ printWriter.println( item.toString() );
}
printWriter.close();
}
-
public RunEntryStatistics findOrCreate( ReportEntry reportEntry )
{
final RunEntryStatistics item = runEntryStatistics.get( reportEntry.getName() );
@@ -144,11 +143,7 @@ public class RunEntryStatisticsMap
public int compare( RunEntryStatistics o, RunEntryStatistics o1 )
{
int runtime = o.getSuccessfulBuilds() - o1.getSuccessfulBuilds();
- if ( runtime == 0 )
- {
- return o.getRunTime() - o1.getRunTime();
- }
- return runtime;
+ return runtime == 0 ? o.getRunTime() - o1.getRunTime() : runtime;
}
}
@@ -269,12 +264,6 @@ public class RunEntryStatisticsMap
String extractClassName( String displayName )
{
Matcher m = PARENS.matcher( displayName );
- if ( !m.find() )
- {
- return displayName;
- }
- return m.group( 1 );
+ return m.find() ? m.group( 1 ) : displayName;
}
-
-
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
index 92cab09..7dcf1ae 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
@@ -19,7 +19,6 @@ package org.apache.maven.surefire.booter;
* under the License.
*/
-import java.util.Properties;
import org.apache.maven.surefire.providerapi.ProviderParameters;
import org.apache.maven.surefire.report.ConsoleLogger;
import org.apache.maven.surefire.report.DefaultDirectConsoleReporter;
@@ -36,6 +35,8 @@ import org.apache.maven.surefire.util.DirectoryScanner;
import org.apache.maven.surefire.util.RunOrderCalculator;
import org.apache.maven.surefire.util.ScanResult;
+import java.util.Map;
+
/**
* @author Kristian Rosenvold
*/
@@ -43,8 +44,9 @@ public class BaseProviderFactory
implements DirectoryScannerParametersAware, ReporterConfigurationAware, SurefireClassLoadersAware, TestRequestAware,
ProviderPropertiesAware, ProviderParameters, TestArtifactInfoAware, RunOrderParametersAware
{
+ private static final int ROOT_CHANNEL = 0;
- private Properties providerProperties;
+ private Map<String, String> providerProperties;
private DirectoryScannerParameters directoryScannerParameters;
@@ -58,15 +60,11 @@ public class BaseProviderFactory
private TestArtifactInfo testArtifactInfo;
- private static final Integer ROOT_CHANNEL = 0;
-
-
private final ReporterFactory reporterFactory;
private final boolean insideFork;
-
- public BaseProviderFactory( ReporterFactory reporterFactory, Boolean insideFork )
+ public BaseProviderFactory( ReporterFactory reporterFactory, boolean insideFork )
{
this.reporterFactory = reporterFactory;
this.insideFork = insideFork;
@@ -74,11 +72,8 @@ public class BaseProviderFactory
public DirectoryScanner getDirectoryScanner()
{
- if ( directoryScannerParameters == null )
- {
- return null;
- }
- return new DefaultDirectoryScanner( directoryScannerParameters.getTestClassesDirectory(),
+ return directoryScannerParameters == null
+ ? null : new DefaultDirectoryScanner( directoryScannerParameters.getTestClassesDirectory(),
directoryScannerParameters.getIncludes(),
directoryScannerParameters.getExcludes(),
directoryScannerParameters.getSpecificTests() );
@@ -91,17 +86,14 @@ public class BaseProviderFactory
private int getThreadCount()
{
- final String threadcount = (String) providerProperties.get( ProviderParameterNames.THREADCOUNT_PROP );
+ final String threadcount = providerProperties.get( ProviderParameterNames.THREADCOUNT_PROP );
return threadcount == null ? 1 : Math.max( Integer.parseInt( threadcount ), 1 );
}
public RunOrderCalculator getRunOrderCalculator()
{
- if ( directoryScannerParameters == null )
- {
- return null;
- }
- return new DefaultRunOrderCalculator( runOrderParameters, getThreadCount() );
+ return directoryScannerParameters == null
+ ? null : new DefaultRunOrderCalculator( runOrderParameters, getThreadCount() );
}
public ReporterFactory getReporterFactory()
@@ -126,12 +118,10 @@ public class BaseProviderFactory
public ConsoleLogger getConsoleLogger()
{
- if ( insideFork )
- {
- return new ForkingRunListener( reporterConfiguration.getOriginalSystemOut(), ROOT_CHANNEL,
- reporterConfiguration.isTrimStackTrace() );
- }
- return new DefaultDirectConsoleReporter( reporterConfiguration.getOriginalSystemOut() );
+ return insideFork
+ ? new ForkingRunListener( reporterConfiguration.getOriginalSystemOut(), ROOT_CHANNEL,
+ reporterConfiguration.isTrimStackTrace() )
+ : new DefaultDirectConsoleReporter( reporterConfiguration.getOriginalSystemOut() );
}
public void setTestRequest( TestRequest testRequest )
@@ -159,12 +149,12 @@ public class BaseProviderFactory
return testClassLoader;
}
- public void setProviderProperties( Properties providerProperties )
+ public void setProviderProperties( Map<String, String> providerProperties )
{
this.providerProperties = providerProperties;
}
- public Properties getProviderProperties()
+ public Map<String, String> getProviderProperties()
{
return providerProperties;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingReporterFactory.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingReporterFactory.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingReporterFactory.java
index ad8c87b..78f29e2 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingReporterFactory.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingReporterFactory.java
@@ -36,13 +36,13 @@ public class ForkingReporterFactory
implements ReporterFactory
{
- private final Boolean isTrimstackTrace;
+ private final boolean isTrimstackTrace;
private final PrintStream originalSystemOut;
private volatile int testSetChannelId = 1;
- public ForkingReporterFactory( Boolean trimstackTrace, PrintStream originalSystemOut )
+ public ForkingReporterFactory( boolean trimstackTrace, PrintStream originalSystemOut )
{
isTrimstackTrace = trimstackTrace;
this.originalSystemOut = originalSystemOut;
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index 77af0d5..719679f 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -184,12 +184,11 @@ public class ForkingRunListener
public static byte[] createHeader( byte booterCode, int testSetChannel )
{
- StringBuilder sb = new StringBuilder();
- sb.append( (char) booterCode ).append( ',' );
- sb.append( Integer.toString( testSetChannel, 16 ) ).append( ',' );
- sb.append( Charset.defaultCharset().name() ).append( ',' );
-
- return encodeStringForForkCommunication( sb.toString() );
+ return encodeStringForForkCommunication( String.valueOf( (char) booterCode )
+ + ','
+ + Integer.toString( testSetChannel, 16 )
+ + ',' + Charset.defaultCharset().name()
+ + ',' );
}
public void info( String message )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderPropertiesAware.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderPropertiesAware.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderPropertiesAware.java
index cee5e27..373e925 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderPropertiesAware.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ProviderPropertiesAware.java
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.booter;
* under the License.
*/
-import java.util.Properties;
+import java.util.Map;
/**
* @author Kristian Rosenvold
@@ -27,5 +27,5 @@ import java.util.Properties;
*/
interface ProviderPropertiesAware
{
- void setProviderProperties( Properties providerProperties );
+ void setProviderProperties( Map<String, String> providerProperties );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
index 08ff094..912babe 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
@@ -25,7 +25,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.List;
-import java.util.Properties;
+import java.util.Map;
import org.apache.maven.surefire.providerapi.ProviderParameters;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.report.ReporterFactory;
@@ -50,35 +50,35 @@ public class SurefireReflector
{
private final ClassLoader surefireClassLoader;
- private final Class reporterConfiguration;
+ private final Class<?> reporterConfiguration;
- private final Class testRequest;
+ private final Class<?> testRequest;
- private final Class testArtifactInfo;
+ private final Class<?> testArtifactInfo;
- private final Class testArtifactInfoAware;
+ private final Class<?> testArtifactInfoAware;
- private final Class directoryScannerParameters;
+ private final Class<?> directoryScannerParameters;
- private final Class runOrderParameters;
+ private final Class<?> runOrderParameters;
- private final Class directoryScannerParametersAware;
+ private final Class<?> directoryScannerParametersAware;
- private final Class testSuiteDefinitionAware;
+ private final Class<?> testSuiteDefinitionAware;
- private final Class testClassLoaderAware;
+ private final Class<?> testClassLoaderAware;
- private final Class reporterConfigurationAware;
+ private final Class<?> reporterConfigurationAware;
- private final Class providerPropertiesAware;
+ private final Class<?> providerPropertiesAware;
- private final Class runResult;
+ private final Class<?> runResult;
- private final Class booterParameters;
+ private final Class<?> booterParameters;
- private final Class reporterFactory;
+ private final Class<?> reporterFactory;
- private final Class testListResolver;
+ private final Class<?> testListResolver;
public SurefireReflector( ClassLoader surefireClassLoader )
@@ -186,7 +186,7 @@ public class SurefireReflector
return null;
}
//Can't use the constructor with the RunOrder parameter. Using it causes some integration tests to fail.
- Class[] arguments = { File.class, List.class, List.class, List.class, Boolean.class, String.class };
+ Class[] arguments = { File.class, List.class, List.class, List.class, boolean.class, String.class };
Constructor constructor = ReflectionUtils.getConstructor( this.directoryScannerParameters, arguments );
return ReflectionUtils.newInstance( constructor,
new Object[]{ directoryScannerParameters.getTestClassesDirectory(),
@@ -231,12 +231,12 @@ public class SurefireReflector
Object createReporterConfiguration( ReporterConfiguration reporterConfiguration )
{
Constructor constructor =
- ReflectionUtils.getConstructor( this.reporterConfiguration, new Class[]{ File.class, Boolean.class } );
+ ReflectionUtils.getConstructor( this.reporterConfiguration, new Class[]{ File.class, boolean.class } );
return ReflectionUtils.newInstance( constructor, new Object[]{ reporterConfiguration.getReportsDirectory(),
reporterConfiguration.isTrimStackTrace() } );
}
- public static ReporterFactory createForkingReporterFactoryInCurrentClassLoader( Boolean trimStackTrace,
+ public static ReporterFactory createForkingReporterFactoryInCurrentClassLoader( boolean trimStackTrace,
PrintStream originalSystemOut )
{
return new ForkingReporterFactory( trimStackTrace, originalSystemOut );
@@ -246,8 +246,7 @@ public class SurefireReflector
boolean insideFork )
{
return ReflectionUtils.instantiateTwoArgs( surefireClassLoader, BaseProviderFactory.class.getName(),
- reporterFactory, factoryInstance, Boolean.class,
- insideFork ? Boolean.TRUE : Boolean.FALSE );
+ reporterFactory, factoryInstance, boolean.class, insideFork );
}
public Object instantiateProvider( String providerClassName, Object booterParameters )
@@ -291,7 +290,7 @@ public class SurefireReflector
ReflectionUtils.invokeSetter( o, "setTestRequest", testRequest, param );
}
- public void setProviderPropertiesAware( Object o, Properties properties )
+ public void setProviderPropertiesAware( Object o, Map<String, String> properties )
{
if ( providerPropertiesAware.isAssignableFrom( o.getClass() ) )
{
@@ -299,9 +298,9 @@ public class SurefireReflector
}
}
- void setProviderProperties( Object o, Properties providerProperties )
+ void setProviderProperties( Object o, Map<String, String> providerProperties )
{
- ReflectionUtils.invokeSetter( o, "setProviderProperties", Properties.class, providerProperties );
+ ReflectionUtils.invokeSetter( o, "setProviderProperties", Map.class, providerProperties );
}
public void setReporterConfigurationAware( Object o, ReporterConfiguration reporterConfiguration1 )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
index cc9e91c..51b40f0 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
@@ -19,7 +19,6 @@ package org.apache.maven.surefire.providerapi;
* under the License.
*/
-import java.util.Properties;
import org.apache.maven.surefire.report.ConsoleLogger;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.report.ReporterFactory;
@@ -30,6 +29,8 @@ import org.apache.maven.surefire.util.DirectoryScanner;
import org.apache.maven.surefire.util.RunOrderCalculator;
import org.apache.maven.surefire.util.ScanResult;
+import java.util.Map;
+
/**
* Injected into the providers upon provider construction. Allows the provider to request services and data it needs.
* <p/>
@@ -119,7 +120,7 @@ public interface ProviderParameters
*
* @return the provider specific properties
*/
- Properties getProviderProperties();
+ Map<String, String> getProviderProperties();
/**
* Artifact info about the artifact used to autodetect provider
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
index a611b92..5238473 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
@@ -38,9 +38,9 @@ public class ReporterConfiguration
/**
* A non-null Boolean value
*/
- private final Boolean trimStackTrace;
+ private final boolean trimStackTrace;
- public ReporterConfiguration( File reportsDirectory, Boolean trimStackTrace )
+ public ReporterConfiguration( File reportsDirectory, boolean trimStackTrace )
{
this.reportsDirectory = reportsDirectory;
this.trimStackTrace = trimStackTrace;
@@ -68,7 +68,7 @@ public class ReporterConfiguration
*
* @return true if stacktraces should be trimmed in reporting
*/
- public Boolean isTrimStackTrace()
+ public boolean isTrimStackTrace()
{
return trimStackTrace;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java b/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
index 20864f9..42ce805 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
@@ -36,12 +36,12 @@ public class DirectoryScannerParameters
private final List specificTests;
- private final Boolean failIfNoTests;
+ private final boolean failIfNoTests;
private final RunOrder[] runOrder;
private DirectoryScannerParameters( File testClassesDirectory, List includes, List excludes, List specificTests,
- Boolean failIfNoTests, RunOrder[] runOrder )
+ boolean failIfNoTests, RunOrder[] runOrder )
{
this.testClassesDirectory = testClassesDirectory;
this.includes = includes;
@@ -52,7 +52,7 @@ public class DirectoryScannerParameters
}
public DirectoryScannerParameters( File testClassesDirectory, List includes, List excludes, List specificTests,
- Boolean failIfNoTests, String runOrder )
+ boolean failIfNoTests, String runOrder )
{
this( testClassesDirectory, includes, excludes, specificTests, failIfNoTests,
runOrder == null ? RunOrder.DEFAULT : RunOrder.valueOfMulti( runOrder ) );
@@ -98,7 +98,7 @@ public class DirectoryScannerParameters
*
* @return true if no tests should fail the build
*/
- public Boolean isFailIfNoTests()
+ public boolean isFailIfNoTests()
{
return failIfNoTests;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
index 6651a27..94277e2 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
@@ -55,8 +55,7 @@ public class DefaultRunOrderCalculator
@SuppressWarnings( "checkstyle:magicnumber" )
public TestsToRun orderTestClasses( TestsToRun scannedClasses )
{
-
- List<Class> result = new ArrayList<Class>( 500 );
+ List<Class> result = new ArrayList<Class>( 512 );
for ( Class scannedClass : scannedClasses )
{
@@ -75,19 +74,16 @@ public class DefaultRunOrderCalculator
}
else if ( RunOrder.FAILEDFIRST.equals( runOrder ) )
{
- RunEntryStatisticsMap runEntryStatisticsMap =
- RunEntryStatisticsMap.fromFile( runOrderParameters.getRunStatisticsFile() );
- final List<Class> prioritized = runEntryStatisticsMap.getPrioritizedTestsByFailureFirst( testClasses );
+ RunEntryStatisticsMap stat = RunEntryStatisticsMap.fromFile( runOrderParameters.getRunStatisticsFile() );
+ List<Class> prioritized = stat.getPrioritizedTestsByFailureFirst( testClasses );
testClasses.clear();
testClasses.addAll( prioritized );
}
else if ( RunOrder.BALANCED.equals( runOrder ) )
{
- RunEntryStatisticsMap runEntryStatisticsMap =
- RunEntryStatisticsMap.fromFile( runOrderParameters.getRunStatisticsFile() );
- final List<Class> prioritized =
- runEntryStatisticsMap.getPrioritizedTestsClassRunTime( testClasses, threadCount );
+ RunEntryStatisticsMap stat = RunEntryStatisticsMap.fromFile( runOrderParameters.getRunStatisticsFile() );
+ List<Class> prioritized = stat.getPrioritizedTestsClassRunTime( testClasses, threadCount );
testClasses.clear();
testClasses.addAll( prioritized );
@@ -140,5 +136,4 @@ public class DefaultRunOrderCalculator
}
};
}
-
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
index 2645f13..ae05d0d 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java
@@ -22,7 +22,7 @@ package org.apache.maven.surefire.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Properties;
+import java.util.Map;
/**
* @author Kristian Rosenvold
@@ -49,21 +49,21 @@ public class DefaultScanResult
return files.get( index );
}
- public void writeTo( Properties properties )
+ public void writeTo( Map<String, String> properties )
{
for ( int i = 0, size = files.size(); i < size; i++ )
{
- properties.setProperty( SCAN_RESULT_NUMBER + i, files.get( i ) );
+ properties.put( SCAN_RESULT_NUMBER + i, files.get( i ) );
}
}
- public static DefaultScanResult from( Properties properties )
+ public static DefaultScanResult from( Map<String, String> properties )
{
List<String> result = new ArrayList<String>();
int i = 0;
while ( true )
{
- String item = properties.getProperty( SCAN_RESULT_NUMBER + ( i++ ) );
+ String item = properties.get( SCAN_RESULT_NUMBER + ( i++ ) );
if ( item == null )
{
return new DefaultScanResult( result );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
index a30ae73..0d6f7dc 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
@@ -38,7 +38,7 @@ public class ReflectionUtils
return getMethod( instance.getClass(), methodName, parameters );
}
- public static Method getMethod( Class clazz, String methodName, Class[] parameters )
+ public static Method getMethod( Class<?> clazz, String methodName, Class[] parameters )
{
try
{
@@ -50,7 +50,7 @@ public class ReflectionUtils
}
}
- public static Method tryGetMethod( Class clazz, String methodName, Class[] parameters )
+ public static Method tryGetMethod( Class<?> clazz, String methodName, Class[] parameters )
{
try
{
@@ -69,7 +69,7 @@ public class ReflectionUtils
return invokeMethodWithArray( instance, method, NO_ARGS_VALUES );
}
- public static Constructor getConstructor( Class clazz, Class[] arguments )
+ public static Constructor getConstructor( Class<?> clazz, Class[] arguments )
{
try
{
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/util/ScanResult.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/ScanResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/ScanResult.java
index 79895ce..2a73a47 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/ScanResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/ScanResult.java
@@ -20,7 +20,7 @@ package org.apache.maven.surefire.util;
*/
import java.util.List;
-import java.util.Properties;
+import java.util.Map;
/**
* @author Kristian Rosenvold
@@ -35,5 +35,5 @@ public interface ScanResult
List getClassesSkippedByValidation( ScannerFilter scannerFilter, ClassLoader testClassLoader );
- void writeTo( Properties properties );
+ void writeTo( Map<String, String> properties );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
index 2c42c19..f3132da 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
@@ -20,7 +20,6 @@ package org.apache.maven.surefire.util;
*/
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
@@ -61,7 +60,7 @@ public class TestsToRun implements Iterable<Class>
public static TestsToRun fromClass( Class clazz )
throws TestSetFailedException
{
- return new TestsToRun( Arrays.<Class>asList( clazz ) );
+ return new TestsToRun( Collections.singletonList( clazz ) );
}
/**
@@ -78,10 +77,8 @@ public class TestsToRun implements Iterable<Class>
{
StringBuilder sb = new StringBuilder();
sb.append( "TestsToRun: [" );
- Iterator it = iterator();
- while ( it.hasNext() )
+ for ( Class clazz : this )
{
- Class clazz = (Class) it.next();
sb.append( " " ).append( clazz.getName() );
}
@@ -131,10 +128,9 @@ public class TestsToRun implements Iterable<Class>
throw new IllegalStateException( "Cannot eagerly read" );
}
List<Class> result = new ArrayList<Class>();
- Iterator<Class> it = iterator();
- while ( it.hasNext() )
+ for ( Class clazz : this )
{
- result.add( it.next() );
+ result.add( clazz );
}
return result.toArray( new Class[result.size()] );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
new file mode 100644
index 0000000..84a445d
--- /dev/null
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
@@ -0,0 +1,47 @@
+package org.apache.maven.surefire.booter;
+/*
+* 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.report.ReporterFactory;
+import org.apache.maven.surefire.report.RunListener;
+import org.apache.maven.surefire.suite.RunResult;
+
+public class SurefireReflectorTest
+ extends TestCase
+{
+ public void testShouldCreateFactoryWithoutException()
+ {
+ ReporterFactory factory = new ReporterFactory() {
+ public RunListener createReporter() {
+ return null;
+ }
+
+ public RunResult close() {
+ return null;
+ }
+ };
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ SurefireReflector reflector = new SurefireReflector( cl );
+ BaseProviderFactory baseProviderFactory =
+ (BaseProviderFactory) reflector.createBooterConfiguration( cl, factory, true );
+ assertNotNull( baseProviderFactory.getReporterFactory() );
+ assertSame( factory, baseProviderFactory.getReporterFactory() );
+ }
+}
[2/3] maven-surefire git commit: [SUREFIRE] Refactoring
Posted by ti...@apache.org.
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-api/src/test/java/org/apache/maven/surefire/util/ScanResultTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/ScanResultTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/ScanResultTest.java
index 7c6628a..02c2d22 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/ScanResultTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/ScanResultTest.java
@@ -19,11 +19,12 @@ package org.apache.maven.surefire.util;
* under the License.
*/
+import junit.framework.TestCase;
+
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
-import java.util.Properties;
-
-import junit.framework.TestCase;
+import java.util.Map;
/**
* @author Kristian Rosenvold
@@ -36,7 +37,7 @@ public class ScanResultTest
{
List<String> files = Arrays.asList( "abc", "cde" );
DefaultScanResult scanResult = new DefaultScanResult( files );
- Properties serialized = new Properties();
+ Map<String, String> serialized = new HashMap<String, String>();
scanResult.writeTo( serialized );
DefaultScanResult read = DefaultScanResult.from( serialized );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
index 400f141..b6d9005 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
@@ -142,10 +142,7 @@ public class Classpath implements Iterable<String>
Classpath classpath = (Classpath) o;
- return !( unmodifiableElements != null
- ? !unmodifiableElements.equals( classpath.unmodifiableElements )
- : classpath.unmodifiableElements != null );
-
+ return unmodifiableElements.equals( classpath.unmodifiableElements );
}
public ClassLoader createClassLoader( ClassLoader parent, boolean childDelegation, boolean enableAssertions,
@@ -177,7 +174,7 @@ public class Classpath implements Iterable<String>
public int hashCode()
{
- return unmodifiableElements != null ? unmodifiableElements.hashCode() : 0;
+ return unmodifiableElements.hashCode();
}
public String getLogMessage( String descriptor )
@@ -213,7 +210,7 @@ public class Classpath implements Iterable<String>
}
else
{
- result.append( element );
+ result.append( (String) null );
}
}
return result.toString();
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 4b5b5ba..1b122ce 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -167,7 +167,7 @@ public class ForkedBooter
private static ReporterFactory createForkingReporterFactory( ProviderConfiguration providerConfiguration,
PrintStream originalSystemOut )
{
- final Boolean trimStackTrace = providerConfiguration.getReporterConfiguration().isTrimStackTrace();
+ final boolean trimStackTrace = providerConfiguration.getReporterConfiguration().isTrimStackTrace();
return SurefireReflector.createForkingReporterFactoryInCurrentClassLoader( trimStackTrace, originalSystemOut );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-booter/src/main/java/org/apache/maven/surefire/booter/KeyValueSource.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/KeyValueSource.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/KeyValueSource.java
index 9decb23..cf3c629 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/KeyValueSource.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/KeyValueSource.java
@@ -26,5 +26,5 @@ import java.util.Map;
*/
public interface KeyValueSource
{
- void copyTo( Map target );
+ void copyTo( Map<Object, Object> target );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
index c5d6b5b..8fec269 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
@@ -21,23 +21,19 @@ package org.apache.maven.surefire.booter;
import java.io.File;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import org.apache.maven.surefire.util.internal.StringUtils;
/**
- * Makes java.util.Properties behave like it's 2013
- *
* @author Kristian Rosenvold
*/
public class PropertiesWrapper
implements KeyValueSource
{
- private final Properties properties;
+ private final Map<String, String> properties;
- public PropertiesWrapper( Properties properties )
+ public PropertiesWrapper( Map<String, String> properties )
{
if ( properties == null )
{
@@ -46,39 +42,37 @@ public class PropertiesWrapper
this.properties = properties;
}
- public Properties getProperties()
+ public Map<String, String> getProperties()
{
return properties;
}
public void setAsSystemProperties()
{
- for ( Object o : properties.keySet() )
+ for ( Map.Entry<String, String> entry : properties.entrySet() )
{
- String key = (String) o;
-
- System.setProperty( key, properties.getProperty( key ) );
+ System.setProperty( entry.getKey(), entry.getValue() );
}
}
public String getProperty( String key )
{
- return properties.getProperty( key );
+ return properties.get( key );
}
public boolean getBooleanProperty( String propertyName )
{
- return Boolean.valueOf( properties.getProperty( propertyName ) );
+ return Boolean.valueOf( properties.get( propertyName ) );
}
- public Boolean getBooleanObjectProperty( String propertyName )
+ public boolean getBooleanObjectProperty( String propertyName )
{
- return Boolean.valueOf( properties.getProperty( propertyName ) );
+ return Boolean.valueOf( properties.get( propertyName ) );
}
public int getIntProperty( String propertyName )
{
- return Integer.parseInt( properties.getProperty( propertyName ) );
+ return Integer.parseInt( properties.get( propertyName ) );
}
public File getFileProperty( String key )
@@ -94,13 +88,10 @@ public class PropertiesWrapper
public List<String> getStringList( String propertyPrefix )
{
- String value;
List<String> result = new ArrayList<String>();
-
- int i = 0;
- while ( true )
+ for ( int i = 0; ; i++ )
{
- value = getProperty( propertyPrefix + ( i++ ) );
+ String value = getProperty( propertyPrefix + i );
if ( value == null )
{
@@ -120,14 +111,17 @@ public class PropertiesWrapper
public TypeEncodedValue getTypeEncodedValue( String key )
{
String typeEncoded = getProperty( key );
- if ( typeEncoded == null )
+ if ( typeEncoded != null )
+ {
+ int typeSep = typeEncoded.indexOf( "|" );
+ String type = typeEncoded.substring( 0, typeSep );
+ String value = typeEncoded.substring( typeSep + 1 );
+ return new TypeEncodedValue( type, value );
+ }
+ else
{
return null;
}
- int typeSep = typeEncoded.indexOf( "|" );
- String type = typeEncoded.substring( 0, typeSep );
- String value = typeEncoded.substring( typeSep + 1 );
- return new TypeEncodedValue( type, value );
}
@@ -140,7 +134,7 @@ public class PropertiesWrapper
public void setClasspath( String prefix, Classpath classpath )
{
List classpathElements = classpath.getClassPath();
- for ( int i = 0; i < classpathElements.size(); ++i )
+ for ( int i = 0, size = classpathElements.size(); i < size; ++i )
{
String element = (String) classpathElements.get( i );
setProperty( prefix + i, element );
@@ -152,44 +146,35 @@ public class PropertiesWrapper
{
if ( value != null )
{
- properties.setProperty( key, value );
+ properties.put( key, value );
}
}
public void addList( List items, String propertyPrefix )
{
- if ( items == null || items.size() == 0 )
- {
- return;
- }
- int i = 0;
- for ( Object item : items )
+ if ( items != null && !items.isEmpty() )
{
- if ( item == null )
+ int i = 0;
+ for ( Object item : items )
{
- throw new NullPointerException( propertyPrefix + i + " has null value" );
+ if ( item == null )
+ {
+ throw new NullPointerException( propertyPrefix + i + " has null value" );
+ }
+
+ String[] stringArray = StringUtils.split( item.toString(), "," );
+
+ for ( String aStringArray : stringArray )
+ {
+ properties.put( propertyPrefix + i, aStringArray );
+ i++;
+ }
}
-
- String[] stringArray = StringUtils.split( item.toString(), "," );
-
- for ( String aStringArray : stringArray )
- {
- properties.setProperty( propertyPrefix + i, aStringArray );
- i++;
- }
-
}
}
- public void copyTo( Map target )
+ public void copyTo( Map<Object, Object> target )
{
- Iterator iter = properties.keySet().iterator();
- Object key;
- while ( iter.hasNext() )
- {
- key = iter.next();
- //noinspection unchecked
- target.put( key, properties.get( key ) );
- }
+ target.putAll( properties );
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
index 362be85..2ee0870 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
@@ -21,7 +21,7 @@ package org.apache.maven.surefire.booter;
import java.io.File;
import java.util.List;
-import java.util.Properties;
+import java.util.Map;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
import org.apache.maven.surefire.testset.RunOrderParameters;
@@ -54,7 +54,7 @@ public class ProviderConfiguration
private final RunOrderParameters runOrderParameters;
- private final Properties providerProperties;
+ private final Map<String, String> providerProperties;
private final boolean failIfNoTests;
@@ -66,7 +66,7 @@ public class ProviderConfiguration
public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters,
RunOrderParameters runOrderParameters, boolean failIfNoTests,
ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact,
- TestRequest testSuiteDefinition, Properties providerProperties,
+ TestRequest testSuiteDefinition, Map<String, String> providerProperties,
TypeEncodedValue typeEncodedTestSet, boolean readTestsFromInStream )
{
this.runOrderParameters = runOrderParameters;
@@ -87,9 +87,9 @@ public class ProviderConfiguration
}
- public Boolean isFailIfNoTests()
+ public boolean isFailIfNoTests()
{
- return ( failIfNoTests ) ? Boolean.TRUE : Boolean.FALSE;
+ return failIfNoTests;
}
public File getBaseDir()
@@ -123,7 +123,7 @@ public class ProviderConfiguration
return testSuiteDefinition;
}
- public Properties getProviderProperties()
+ public Map<String, String> getProviderProperties()
{
return providerProperties;
}
@@ -138,7 +138,6 @@ public class ProviderConfiguration
return runOrderParameters;
}
-
public boolean isReadTestsFromInStream()
{
return readTestsFromInStream;
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
index 4a624ea..17db489 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
@@ -24,7 +24,9 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
/**
* @author Kristian Rosenvold
@@ -42,18 +44,22 @@ public class SystemPropertyManager
public static PropertiesWrapper loadProperties( InputStream inStream )
throws IOException
{
- Properties p = new Properties();
-
try
{
+ Properties p = new Properties();
p.load( inStream );
+ Map<String, String> map = new ConcurrentHashMap<String, String>( p.size() );
+ // @todo use .stringPropertyNames() JDK6 instead of .keySet()
+ for ( Map.Entry<?, ?> entry : p.entrySet() )
+ {
+ map.put( (String) entry.getKey(), (String) entry.getValue() );
+ }
+ return new PropertiesWrapper( map );
}
finally
{
- close( inStream );
+ close( inStream ); // @todo use try-with-resources JDK7, search in all code
}
-
- return new PropertiesWrapper( p );
}
private static PropertiesWrapper loadProperties( File file )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java
index 82248b5..99b8564 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/Foo.java
@@ -20,7 +20,7 @@ package org.apache.maven.surefire.booter;
*/
-import java.util.Properties;
+import java.util.Map;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
import org.apache.maven.surefire.testset.RunOrderParameters;
@@ -36,7 +36,7 @@ public class Foo
{
DirectoryScannerParameters directoryScannerParameters;
- Properties providerProperties;
+ Map<String, String> providerProperties;
ReporterConfiguration reporterConfiguration;
@@ -68,7 +68,7 @@ public class Foo
return called;
}
- public void setProviderProperties( Properties providerProperties )
+ public void setProviderProperties( Map<String, String> providerProperties )
{
this.providerProperties = providerProperties;
this.called = true;
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PropertiesWrapperTest.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PropertiesWrapperTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PropertiesWrapperTest.java
index a20f96e..4567b5b 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PropertiesWrapperTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PropertiesWrapperTest.java
@@ -19,9 +19,7 @@ package org.apache.maven.surefire.booter;
* under the License.
*/
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
+import java.util.*;
import junit.framework.TestCase;
@@ -34,9 +32,7 @@ public class PropertiesWrapperTest
public void testAddList()
throws Exception
{
-
- Properties props = new Properties();
- PropertiesWrapper propertiesWrapper = new PropertiesWrapper( props );
+ PropertiesWrapper propertiesWrapper = new PropertiesWrapper( new HashMap<String, String>() );
List<String> items = new ArrayList<String>();
items.add( "String1" );
items.add( "String2,String3" );
@@ -58,8 +54,7 @@ public class PropertiesWrapperTest
private static final String SECOND_ELEMENT = "foo1";
- private final Properties properties = new Properties();
-
+ private final Map<String, String> properties = new HashMap<String, String>();
private final PropertiesWrapper mapper = new PropertiesWrapper( properties );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
index d4f48d0..d41849d 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
@@ -24,7 +24,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Properties;
+import java.util.HashMap;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
import org.apache.maven.surefire.testset.RunOrderParameters;
@@ -49,7 +49,7 @@ public class SurefireReflectorTest
DirectoryScannerParameters directoryScannerParameters =
new DirectoryScannerParameters( new File( "ABC" ), new ArrayList(), new ArrayList(), new ArrayList(),
- Boolean.FALSE, "hourly" );
+ false, "hourly" );
surefireReflector.setDirectoryScannerParameters( foo, directoryScannerParameters );
assertTrue( isCalled( foo ) );
@@ -86,7 +86,7 @@ public class SurefireReflectorTest
SurefireReflector surefireReflector = getReflector();
Object foo = getFoo();
- surefireReflector.setProviderProperties( foo, new Properties() );
+ surefireReflector.setProviderProperties( foo, new HashMap<String, String>() );
assertTrue( isCalled( foo ) );
}
@@ -103,7 +103,7 @@ public class SurefireReflectorTest
private ReporterConfiguration getReporterConfiguration()
{
- return new ReporterConfiguration( new File( "CDE" ), Boolean.TRUE );
+ return new ReporterConfiguration( new File( "CDE" ), true );
}
public void testTestClassLoaderAware()
@@ -143,7 +143,7 @@ public class SurefireReflectorTest
final Method isCalled;
try
{
- isCalled = foo.getClass().getMethod( "isCalled", new Class[0] );
+ isCalled = foo.getClass().getMethod( "isCalled" );
return (Boolean) isCalled.invoke( foo );
}
catch ( IllegalAccessException e )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
index 361aa04..4635b41 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
@@ -106,7 +106,7 @@ public class HelperAssertions
*/
public static IntegrationTestSuiteResults parseReportList( List<ReportTestSuite> reports )
{
- Assert.assertTrue( "No reports!", reports.size() > 0 );
+ Assert.assertTrue( "No reports!", !reports.isEmpty() );
int total = 0, errors = 0, failures = 0, skipped = 0, flakes = 0;
for ( ReportTestSuite report : reports )
{
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java b/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java
index 9ad7715..6cde650 100644
--- a/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java
+++ b/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java
@@ -38,12 +38,6 @@ public class TestProvider
invokeRuntimeExceptionIfSet( System.getProperty( "constructorCrash" ) );
}
-
- public Boolean isRunnable()
- {
- return Boolean.TRUE;
- }
-
public Iterator getSuites()
{
invokeRuntimeExceptionIfSet( System.getProperty( "getSuitesCrash" ) );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
index cacc691..ba5b637 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
@@ -117,7 +117,7 @@ public class JUnit4RunListener
{
this.reporter.testError( report );
}
- failureFlag.set( Boolean.TRUE );
+ failureFlag.set( true );
}
protected StackTraceWriter createStackTraceWriter( Failure failure )
@@ -129,7 +129,7 @@ public class JUnit4RunListener
public void testAssumptionFailure( Failure failure )
{
this.reporter.testAssumptionFailure( createReportEntry( failure.getDescription() ) );
- failureFlag.set( Boolean.TRUE );
+ failureFlag.set( true );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java
index 4bdd438..5dd2918 100644
--- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java
+++ b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java
@@ -27,7 +27,6 @@ import org.apache.maven.surefire.testset.TestListResolver;
import org.junit.runner.manipulation.Filter;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
/**
@@ -42,10 +41,10 @@ public class FilterFactory
this.testClassLoader = testClassLoader;
}
- public Filter createGroupFilter( Properties providerProperties )
+ public Filter createGroupFilter( Map<String, String> providerProperties )
{
- String groups = providerProperties.getProperty( ProviderParameterNames.TESTNG_GROUPS_PROP );
- String excludedGroups = providerProperties.getProperty( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP );
+ String groups = providerProperties.get( ProviderParameterNames.TESTNG_GROUPS_PROP );
+ String excludedGroups = providerProperties.get( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP );
GroupMatcher included = null;
if ( groups != null && groups.trim().length() > 0 )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
index 536da71..351e9c1 100644
--- a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
+++ b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
@@ -85,7 +85,7 @@ public class JUnit4Provider
scanResult = booterParameters.getScanResult();
runOrderCalculator = booterParameters.getRunOrderCalculator();
customRunListeners = JUnit4RunListenerFactory.
- createCustomListeners( booterParameters.getProviderProperties().getProperty( "listener" ) );
+ createCustomListeners( booterParameters.getProviderProperties().get( "listener" ) );
jUnit4TestChecker = new JUnit4TestChecker( testClassLoader );
testResolver = booterParameters.getTestRequest().getTestListResolver();
rerunFailingTestsCount = booterParameters.getTestRequest().getRerunFailingTestsCount();
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java b/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java
index a888162..8f0356c 100644
--- a/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java
+++ b/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java
@@ -22,15 +22,8 @@ package org.apache.maven.surefire.junit4;
import junit.framework.TestCase;
import org.apache.maven.surefire.booter.BaseProviderFactory;
import org.apache.maven.surefire.testset.TestRequest;
-import org.apache.maven.surefire.util.TestsToRun;
-import org.junit.runner.Description;
-import org.junit.runner.notification.Failure;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
+import java.util.HashMap;
/**
* @author Kristian Rosenvold
@@ -45,8 +38,8 @@ public class JUnit4ProviderTest
private JUnit4Provider getJUnit4Provider()
{
- BaseProviderFactory providerParameters = new BaseProviderFactory( null, Boolean.TRUE );
- providerParameters.setProviderProperties( new Properties() );
+ BaseProviderFactory providerParameters = new BaseProviderFactory( null, true );
+ providerParameters.setProviderProperties( new HashMap<String, String>() );
providerParameters.setClassLoaders( getClass().getClassLoader() );
providerParameters.setTestRequest( new TestRequest( null, null, null ) );
return new JUnit4Provider( providerParameters );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
index 04031c6..6a7a248 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
@@ -21,7 +21,7 @@ package org.apache.maven.surefire.junitcore;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Properties;
+import java.util.Map;
import org.apache.maven.surefire.booter.ProviderParameterNames;
@@ -52,7 +52,7 @@ public final class JUnitCoreParameters
private final String parallel;
- private final Boolean perCoreThreadCount;
+ private final boolean perCoreThreadCount;
private final int threadCount;
@@ -66,24 +66,22 @@ public final class JUnitCoreParameters
private final double parallelTestsTimeoutForcedInSeconds;
- private final Boolean useUnlimitedThreads;
+ private final boolean useUnlimitedThreads;
private final boolean parallelOptimization;
- public JUnitCoreParameters( Properties properties )
+ public JUnitCoreParameters( Map<String, String> properties )
{
- parallel = properties.getProperty( PARALLEL_KEY, "none" ).toLowerCase();
- perCoreThreadCount = Boolean.valueOf( properties.getProperty( PERCORETHREADCOUNT_KEY, "true" ) );
- threadCount = Integer.valueOf( properties.getProperty( THREADCOUNT_KEY, "0" ) );
- threadCountMethods = Integer.valueOf( properties.getProperty( THREADCOUNTMETHODS_KEY, "0" ) );
- threadCountClasses = Integer.valueOf( properties.getProperty( THREADCOUNTCLASSES_KEY, "0" ) );
- threadCountSuites = Integer.valueOf( properties.getProperty( THREADCOUNTSUITES_KEY, "0" ) );
- useUnlimitedThreads = Boolean.valueOf( properties.getProperty( USEUNLIMITEDTHREADS_KEY, "false" ) );
- parallelTestsTimeoutInSeconds =
- Math.max( Double.valueOf( properties.getProperty( PARALLEL_TIMEOUT_KEY, "0" ) ), 0 );
- parallelTestsTimeoutForcedInSeconds =
- Math.max( Double.valueOf( properties.getProperty( PARALLEL_TIMEOUTFORCED_KEY, "0" ) ), 0 );
- parallelOptimization = Boolean.valueOf( properties.getProperty( PARALLEL_OPTIMIZE_KEY, "true" ) );
+ parallel = property( properties, PARALLEL_KEY, "none" ).toLowerCase();
+ perCoreThreadCount = property( properties, PERCORETHREADCOUNT_KEY, true );
+ threadCount = property( properties, THREADCOUNT_KEY, 0 );
+ threadCountMethods = property( properties, THREADCOUNTMETHODS_KEY, 0 );
+ threadCountClasses = property( properties, THREADCOUNTCLASSES_KEY, 0 );
+ threadCountSuites = property( properties, THREADCOUNTSUITES_KEY, 0 );
+ useUnlimitedThreads = property( properties, USEUNLIMITEDTHREADS_KEY, false );
+ parallelTestsTimeoutInSeconds = Math.max( property( properties, PARALLEL_TIMEOUT_KEY, 0d ), 0 );
+ parallelTestsTimeoutForcedInSeconds = Math.max( property( properties, PARALLEL_TIMEOUTFORCED_KEY, 0d ), 0 );
+ parallelOptimization = property( properties, PARALLEL_OPTIMIZE_KEY, true );
}
private static Collection<String> lowerCase( String... elements )
@@ -122,12 +120,13 @@ public final class JUnitCoreParameters
* @deprecated Instead use the expression ( {@link #isParallelMethods()} && {@link #isParallelClasses()} ).
*/
@Deprecated
+ @SuppressWarnings( { "unused", "deprecation" } )
public boolean isParallelBoth()
{
return isParallelMethods() && isParallelClasses();
}
- public Boolean isPerCoreThreadCount()
+ public boolean isPerCoreThreadCount()
{
return perCoreThreadCount;
}
@@ -152,7 +151,7 @@ public final class JUnitCoreParameters
return threadCountSuites;
}
- public Boolean isUseUnlimitedThreads()
+ public boolean isUseUnlimitedThreads()
{
return useUnlimitedThreads;
}
@@ -190,4 +189,24 @@ public final class JUnitCoreParameters
+ ", threadCountClasses=" + threadCountClasses + ", threadCountMethods=" + threadCountMethods
+ ", parallelOptimization=" + parallelOptimization;
}
+
+ private static boolean property( Map<String, String> properties, String key, boolean fallback )
+ {
+ return properties.containsKey( key ) ? Boolean.valueOf( properties.get( key ) ) : fallback;
+ }
+
+ private static String property( Map<String, String> properties, String key, String fallback )
+ {
+ return properties.containsKey( key ) ? properties.get( key ) : fallback;
+ }
+
+ private static int property( Map<String, String> properties, String key, int fallback )
+ {
+ return properties.containsKey( key ) ? Integer.valueOf( properties.get( key ) ) : fallback;
+ }
+
+ private static double property( Map<String, String> properties, String key, double fallback )
+ {
+ return properties.containsKey( key ) ? Double.valueOf( properties.get( key ) ) : fallback;
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
index 66147ad..0cebc84 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
@@ -87,15 +87,10 @@ public class JUnitCoreProvider
testResolver = providerParameters.getTestRequest().getTestListResolver();
rerunFailingTestsCount = providerParameters.getTestRequest().getRerunFailingTestsCount();
customRunListeners = JUnit4RunListenerFactory.createCustomListeners(
- providerParameters.getProviderProperties().getProperty( "listener" ) );
+ providerParameters.getProviderProperties().get( "listener" ) );
jUnit48Reflector = new JUnit48Reflector( testClassLoader );
}
- public Boolean isRunnable()
- {
- return Boolean.TRUE;
- }
-
public Iterator getSuites()
{
testsToRun = scanClassPath();
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java
index acfe429..76bb7c3 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java
@@ -19,7 +19,8 @@ package org.apache.maven.surefire.junitcore;
* under the License.
*/
-import java.util.Properties;
+import java.util.HashMap;
+import java.util.Map;
import org.junit.Test;
@@ -124,54 +125,54 @@ public class JUnitCoreParametersTest
assertTrue( newTestSetBoth().isParallelismSelected() );
}
- private Properties newDefaultProperties()
+ private Map<String, String> newDefaultProperties()
{
- return new Properties();
+ return new HashMap<String, String>();
}
- private Properties newPropertiesClasses()
+ private Map<String, String> newPropertiesClasses()
{
- Properties props = new Properties();
- props.setProperty( JUnitCoreParameters.PARALLEL_KEY, "classes" );
- props.setProperty( JUnitCoreParameters.PERCORETHREADCOUNT_KEY, "false" );
- props.setProperty( JUnitCoreParameters.THREADCOUNT_KEY, "2" );
- props.setProperty( JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY, "false" );
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(JUnitCoreParameters.PARALLEL_KEY, "classes");
+ props.put(JUnitCoreParameters.PERCORETHREADCOUNT_KEY, "false");
+ props.put(JUnitCoreParameters.THREADCOUNT_KEY, "2");
+ props.put(JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY, "false");
return props;
}
- private Properties newPropertiesMethods()
+ private Map<String, String> newPropertiesMethods()
{
- Properties props = new Properties();
- props.setProperty( JUnitCoreParameters.PARALLEL_KEY, "methods" );
- props.setProperty( JUnitCoreParameters.PERCORETHREADCOUNT_KEY, "false" );
- props.setProperty( JUnitCoreParameters.THREADCOUNT_KEY, "2" );
- props.setProperty( JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY, "true" );
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(JUnitCoreParameters.PARALLEL_KEY, "methods");
+ props.put(JUnitCoreParameters.PERCORETHREADCOUNT_KEY, "false");
+ props.put(JUnitCoreParameters.THREADCOUNT_KEY, "2");
+ props.put(JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY, "true");
return props;
}
- private Properties newPropertiesBoth()
+ private Map<String, String> newPropertiesBoth()
{
- Properties props = new Properties();
- props.setProperty( JUnitCoreParameters.PARALLEL_KEY, "both" );
- props.setProperty( JUnitCoreParameters.PERCORETHREADCOUNT_KEY, "true" );
- props.setProperty( JUnitCoreParameters.THREADCOUNT_KEY, "7" );
- props.setProperty( JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY, "false" );
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(JUnitCoreParameters.PARALLEL_KEY, "both");
+ props.put(JUnitCoreParameters.PERCORETHREADCOUNT_KEY, "true");
+ props.put(JUnitCoreParameters.THREADCOUNT_KEY, "7");
+ props.put(JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY, "false");
return props;
}
- private Properties newPropertiesTimeouts( double timeout, double forcedTimeout )
+ private Map<String, String> newPropertiesTimeouts( double timeout, double forcedTimeout )
{
- Properties props = new Properties();
- props.setProperty( JUnitCoreParameters.PARALLEL_TIMEOUT_KEY, Double.toString( timeout ) );
- props.setProperty( JUnitCoreParameters.PARALLEL_TIMEOUTFORCED_KEY, Double.toString( forcedTimeout ) );
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(JUnitCoreParameters.PARALLEL_TIMEOUT_KEY, Double.toString(timeout));
+ props.put(JUnitCoreParameters.PARALLEL_TIMEOUTFORCED_KEY, Double.toString(forcedTimeout));
return props;
}
- private Properties newPropertiesOptimization( boolean optimize )
+ private Map<String, String> newPropertiesOptimization( boolean optimize )
{
- Properties props = new Properties();
- props.setProperty( JUnitCoreParameters.PARALLEL_OPTIMIZE_KEY, Boolean.toString( optimize ) );
+ Map<String, String> props = new HashMap<String, String>();
+ props.put( JUnitCoreParameters.PARALLEL_OPTIMIZE_KEY, Boolean.toString( optimize ) );
return props;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/84fd7235/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
index 1ee89ef..4563e6d 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
@@ -18,11 +18,7 @@ package org.apache.maven.surefire.junitcore;
*/
import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
import org.apache.maven.surefire.booter.BaseProviderFactory;
@@ -92,7 +88,7 @@ public class Surefire746Test
ConsoleLogger consoleLogger = new DefaultConsoleReporter( System.out );
providerParameters.setReporterConfiguration( new ReporterConfiguration( new File( "" ), false ) );
- Properties junitProps = new Properties();
+ Map<String, String> junitProps = new HashMap<String, String>();
junitProps.put( ProviderParameterNames.PARALLEL_PROP, "none" );
JUnitCoreParameters jUnitCoreParameters = new JUnitCoreParameters( junitProps );
@@ -102,7 +98,7 @@ public class Surefire746Test
RunListener listener =
ConcurrentRunListener.createInstance( testSetMap, reporterFactory, false, false, consoleLogger );
- TestsToRun testsToRun = new TestsToRun( Arrays.<Class>asList( TestClassTest.class ) );
+ TestsToRun testsToRun = new TestsToRun(Collections.<Class>singletonList( TestClassTest.class ) );
org.junit.runner.notification.RunListener jUnit4RunListener = new JUnitCoreRunListener( listener, testSetMap );
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/OptimizedParallelComputerTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/OptimizedParallelComputerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/OptimizedParallelComputerTest.java
index 67d7683..cb092a6 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/OptimizedParallelComputerTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/OptimizedParallelComputerTest.java
@@ -30,7 +30,8 @@ import org.junit.experimental.theories.Theory;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import java.util.Properties;
+import java.util.HashMap;
+import java.util.Map;
import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.*;
import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.*;
@@ -74,9 +75,9 @@ public final class OptimizedParallelComputerTest
throws TestSetFailedException
{
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 );
RunnerCounter counter = new RunnerCounter( 5, 10, 20 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -94,9 +95,9 @@ public final class OptimizedParallelComputerTest
throws TestSetFailedException
{
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 );
RunnerCounter counter = new RunnerCounter( 1, 5, 10 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -114,9 +115,9 @@ public final class OptimizedParallelComputerTest
throws TestSetFailedException
{
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 );
RunnerCounter counter = new RunnerCounter( 1, 2, 5 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -134,9 +135,9 @@ public final class OptimizedParallelComputerTest
throws TestSetFailedException
{
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 );
RunnerCounter counter = new RunnerCounter( 1, 2, 5 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -154,9 +155,9 @@ public final class OptimizedParallelComputerTest
throws TestSetFailedException
{
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 );
RunnerCounter counter = new RunnerCounter( 1, 2, 5 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -174,9 +175,9 @@ public final class OptimizedParallelComputerTest
throws TestSetFailedException
{
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 );
RunnerCounter counter = new RunnerCounter( 2, 3, 5 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -194,9 +195,9 @@ public final class OptimizedParallelComputerTest
throws TestSetFailedException
{
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 );
RunnerCounter counter = new RunnerCounter( 2, 5, 20 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -214,9 +215,9 @@ public final class OptimizedParallelComputerTest
throws TestSetFailedException
{
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 );
RunnerCounter counter = new RunnerCounter( 2, 5, 20 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -235,10 +236,10 @@ public final class OptimizedParallelComputerTest
{
// 4 * cpu to 5 * cpu threads to run test classes
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 );
RunnerCounter counter = new RunnerCounter( 3, 5, 20 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -257,10 +258,10 @@ public final class OptimizedParallelComputerTest
{
// 4 * cpu to 5 * cpu threads to run test methods
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 );
RunnerCounter counter = new RunnerCounter( 3, 5, 20 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -279,10 +280,10 @@ public final class OptimizedParallelComputerTest
{
// 4 * cpu to 5 * cpu threads to run test methods
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 );
RunnerCounter counter = new RunnerCounter( 3, 5, 20 );
Concurrency concurrency = resolveConcurrency( params, counter );
@@ -301,11 +302,11 @@ public final class OptimizedParallelComputerTest
{
// 8 * cpu to 13 * cpu threads to run test methods
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 );
RunnerCounter counter = new RunnerCounter( 3, 5, 20 );
Concurrency concurrency = resolveConcurrency( params, counter );