[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 <tibo...@lycos.com> Authored: Wed May 6 02:45:56 2015 +0200 Committer: Tibor17 <tibo...@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() ); + } +}