http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 8957e5a..ad94948 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 @@ -32,7 +32,7 @@ public class DefaultScanResult { private final List<String> files; - private static final String scanResultNo = "tc."; + private static final String SCAN_RESULT_NUMBER = "tc."; public DefaultScanResult( List<String> files ) { @@ -54,7 +54,7 @@ public class DefaultScanResult int size = files.size(); for ( int i = 0; i < size; i++ ) { - properties.setProperty( scanResultNo + i, files.get( i ) ); + properties.setProperty( SCAN_RESULT_NUMBER + i, files.get( i ) ); } } @@ -64,7 +64,7 @@ public class DefaultScanResult int i = 0; while ( true ) { - String item = properties.getProperty( scanResultNo + ( i++ ) ); + String item = properties.getProperty( SCAN_RESULT_NUMBER + ( i++ ) ); if ( item == null ) { return new DefaultScanResult( result ); @@ -137,7 +137,8 @@ public class DefaultScanResult return testClass; } - public DefaultScanResult append(DefaultScanResult other){ + public DefaultScanResult append( DefaultScanResult other ) + { if ( other != null ) { List<String> src = new ArrayList<String>( files ); @@ -150,5 +151,4 @@ public class DefaultScanResult } } - }
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 19c1c3f..a30ae73 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 @@ -221,6 +221,7 @@ public class ReflectionUtils return newInstance( constructor, params ); } + @SuppressWarnings( "checkstyle:emptyblock" ) public static Class tryLoadClass( ClassLoader classLoader, String className ) { try http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrderCalculator.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrderCalculator.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrderCalculator.java index a87712f..bdbc48b 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrderCalculator.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrderCalculator.java @@ -1,23 +1,23 @@ package org.apache.maven.surefire.util; /* -* 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. -*/ + * 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. + */ /** * @author Kristian Rosenvold http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java index 97da38b..69da150 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/ByteBuffer.java @@ -50,11 +50,11 @@ public class ByteBuffer data[position++] = chararcter; } - private static final byte comma = (byte) ','; + private static final byte COMMA = (byte) ','; public void comma() { - data[position++] = comma; + data[position++] = COMMA; } @@ -81,7 +81,7 @@ public class ByteBuffer int mask = radix - 1; do { - buf[--charPos] = (byte) digits[i & mask]; + buf[--charPos] = (byte) DIGITS[i & mask]; i >>>= 4; } while ( i != 0 ); @@ -89,7 +89,7 @@ public class ByteBuffer append( buf, charPos, ( 32 - charPos ) ); } - private final static char[] digits = + private static final char[] DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java index 34f25fd..f9137cf 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java @@ -126,6 +126,7 @@ public class StringUtils * @param target target string buffer. The required space will be up to {@code str.getBytes().length * 5} chars. * @param str String to escape values in, may be {@code null}. */ + @SuppressWarnings( "checkstyle:magicnumber" ) public static void escapeToPrintable( StringBuilder target, CharSequence str ) { if ( target == null ) @@ -137,7 +138,8 @@ public class StringUtils return; } - for ( int i = 0; i < str.length(); i++ ) { + for ( int i = 0; i < str.length(); i++ ) + { char c = str.charAt( i ); // handle non-nicely printable chars and the comma @@ -225,6 +227,7 @@ public class StringUtils * @param len number of bytes to copy from the input buffer * @return number of bytes written to {@code out} */ + @SuppressWarnings( "checkstyle:magicnumber" ) public static int escapeBytesToPrintable( byte[] out, int outoff, byte[] input, int off, int len ) { if ( out == null ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-api/src/test/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriterTest.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriterTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriterTest.java index 6ee357a..ab58186 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriterTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/report/LegacyPojoStackTraceWriterTest.java @@ -1,5 +1,24 @@ package org.apache.maven.surefire.report; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.PrintWriter; import junit.framework.TestCase; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java index 3c011d1..b4ddc21 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java @@ -36,7 +36,7 @@ public class RunOrderCalculatorTest { getClassesToRun(); TestsToRun testsToRun = new TestsToRun( getClassesToRun() ); - RunOrderCalculator runOrderCalculator = new DefaultRunOrderCalculator( RunOrderParameters.ALPHABETICAL(), 1 ); + RunOrderCalculator runOrderCalculator = new DefaultRunOrderCalculator( RunOrderParameters.alphabetical(), 1 ); final TestsToRun testsToRun1 = runOrderCalculator.orderTestClasses( testsToRun ); assertEquals( A.class, testsToRun1.iterator().next() ); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java index 2f637f0..f55bbb2 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java @@ -25,27 +25,31 @@ package org.apache.maven.surefire.booter; * * @author Kristian Rosenvold */ -public interface BooterConstants +public final class BooterConstants { - String SPECIFIC_TEST_PROPERTY_PREFIX = "specificTest"; - String INCLUDES_PROPERTY_PREFIX = "includes"; - String EXCLUDES_PROPERTY_PREFIX = "excludes"; - String USESYSTEMCLASSLOADER = "useSystemClassLoader"; - String USEMANIFESTONLYJAR = "useManifestOnlyJar"; - String FAILIFNOTESTS = "failIfNoTests"; - String ISTRIMSTACKTRACE = "isTrimStackTrace"; - String REPORTSDIRECTORY = "reportsDirectory"; - String TESTARTIFACT_VERSION = "testFwJarVersion"; - String TESTARTIFACT_CLASSIFIER = "testFwJarClassifier"; - String REQUESTEDTEST = "requestedTest"; - String REQUESTEDTESTMETHOD = "requestedTestMethod"; - String SOURCE_DIRECTORY = "testSuiteDefinitionTestSourceDirectory"; - String TEST_CLASSES_DIRECTORY = "testClassesDirectory"; - String RUN_ORDER = "runOrder"; - String RUN_STATISTICS_FILE = "runStatisticsFile"; - String TEST_SUITE_XML_FILES = "testSuiteXmlFiles"; - String PROVIDER_CONFIGURATION = "providerConfiguration"; - String FORKTESTSET = "forkTestSet"; - String FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM = "preferTestsFromInStream"; - String RERUN_FAILING_TESTS_COUNT = "rerunFailingTestsCount"; + private BooterConstants() + { + } + + public static final String SPECIFIC_TEST_PROPERTY_PREFIX = "specificTest"; + public static final String INCLUDES_PROPERTY_PREFIX = "includes"; + public static final String EXCLUDES_PROPERTY_PREFIX = "excludes"; + public static final String USESYSTEMCLASSLOADER = "useSystemClassLoader"; + public static final String USEMANIFESTONLYJAR = "useManifestOnlyJar"; + public static final String FAILIFNOTESTS = "failIfNoTests"; + public static final String ISTRIMSTACKTRACE = "isTrimStackTrace"; + public static final String REPORTSDIRECTORY = "reportsDirectory"; + public static final String TESTARTIFACT_VERSION = "testFwJarVersion"; + public static final String TESTARTIFACT_CLASSIFIER = "testFwJarClassifier"; + public static final String REQUESTEDTEST = "requestedTest"; + public static final String REQUESTEDTESTMETHOD = "requestedTestMethod"; + public static final String SOURCE_DIRECTORY = "testSuiteDefinitionTestSourceDirectory"; + public static final String TEST_CLASSES_DIRECTORY = "testClassesDirectory"; + public static final String RUN_ORDER = "runOrder"; + public static final String RUN_STATISTICS_FILE = "runStatisticsFile"; + public static final String TEST_SUITE_XML_FILES = "testSuiteXmlFiles"; + public static final String PROVIDER_CONFIGURATION = "providerConfiguration"; + public static final String FORKTESTSET = "forkTestSet"; + public static final String FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM = "preferTestsFromInStream"; + public static final String RERUN_FAILING_TESTS_COUNT = "rerunFailingTestsCount"; } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java index fce7c42..ae9dbce 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java @@ -29,6 +29,9 @@ import org.apache.maven.surefire.testset.RunOrderParameters; import org.apache.maven.surefire.testset.TestArtifactInfo; import org.apache.maven.surefire.testset.TestRequest; +// CHECKSTYLE_OFF: imports +import static org.apache.maven.surefire.booter.BooterConstants.*; + /** * Knows how to serialize and deserialize the booter configuration. * <p/> @@ -43,7 +46,6 @@ import org.apache.maven.surefire.testset.TestRequest; * @author Kristian Rosenvold */ public class BooterDeserializer - implements BooterConstants { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 536c077..400f141 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 @@ -48,13 +48,20 @@ public class Classpath implements Iterable<String> public static Classpath join( Classpath firstClasspath, Classpath secondClasspath ) { LinkedHashSet<String> accumulated = new LinkedHashSet<String>( ); - if (firstClasspath != null) firstClasspath.addTo( accumulated ); - if (secondClasspath != null) secondClasspath.addTo( accumulated ); + if ( firstClasspath != null ) + { + firstClasspath.addTo( accumulated ); + } + if ( secondClasspath != null ) + { + secondClasspath.addTo( accumulated ); + } return new Classpath( accumulated ); } - private void addTo(Collection<String> c){ + private void addTo( Collection<String> c ) + { c.addAll( unmodifiableElements ); } @@ -135,8 +142,9 @@ public class Classpath implements Iterable<String> Classpath classpath = (Classpath) o; - return !( unmodifiableElements - != null ? !unmodifiableElements.equals( classpath.unmodifiableElements ) : classpath.unmodifiableElements != null ); + return !( unmodifiableElements != null + ? !unmodifiableElements.equals( classpath.unmodifiableElements ) + : classpath.unmodifiableElements != null ); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java index 5dbf018..d582f3c 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java @@ -57,7 +57,8 @@ public class ClasspathConfiguration public ClasspathConfiguration( boolean enableAssertions, boolean childDelegation ) { - this( Classpath.emptyClasspath(), Classpath.emptyClasspath(), Classpath.emptyClasspath(), enableAssertions, childDelegation ); + this( Classpath.emptyClasspath(), Classpath.emptyClasspath(), Classpath.emptyClasspath(), enableAssertions, + childDelegation ); } ClasspathConfiguration( PropertiesWrapper properties ) @@ -80,7 +81,7 @@ public class ClasspathConfiguration public ClassLoader createMergedClassLoader() throws SurefireExecutionException { - return Classpath.join( inprocClasspath, classpathUrls) + return Classpath.join( inprocClasspath, classpathUrls ) .createClassLoader( null, this.childDelegation, enableAssertions, "test" ); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 7a3035b..801fb4f 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 @@ -109,14 +109,16 @@ public class ForkedBooter new LegacyPojoStackTraceWriter( "test subystem", "no method", t.getTargetException() ); StringBuilder stringBuilder = new StringBuilder(); ForkingRunListener.encode( stringBuilder, stackTraceWriter, false ); - originalOut.println( ( (char) ForkingRunListener.BOOTERCODE_ERROR ) + ",0," + stringBuilder.toString() ); + originalOut.println( ( (char) ForkingRunListener.BOOTERCODE_ERROR ) + + ",0," + stringBuilder.toString() ); } catch ( Throwable t ) { StackTraceWriter stackTraceWriter = new LegacyPojoStackTraceWriter( "test subystem", "no method", t ); StringBuilder stringBuilder = new StringBuilder(); ForkingRunListener.encode( stringBuilder, stackTraceWriter, false ); - originalOut.println( ( (char) ForkingRunListener.BOOTERCODE_ERROR ) + ",0," + stringBuilder.toString() ); + originalOut.println( ( (char) ForkingRunListener.BOOTERCODE_ERROR ) + + ",0," + stringBuilder.toString() ); } // Say bye. originalOut.println( ( (char) ForkingRunListener.BOOTERCODE_BYE ) + ",0,BYE!" ); @@ -134,7 +136,7 @@ public class ForkedBooter } } - private final static long SYSTEM_EXIT_TIMEOUT = 30 * 1000; + private static final long SYSTEM_EXIT_TIMEOUT = 30 * 1000; private static void exit( final int returnCode ) { @@ -161,6 +163,7 @@ public class ForkedBooter return SurefireReflector.createForkingReporterFactoryInCurrentClassLoader( trimStackTrace, originalSystemOut ); } + @SuppressWarnings( "checkstyle:emptyblock" ) private static void launchLastDitchDaemonShutdownThread( final int returnCode ) { Thread lastExit = new Thread( new Runnable() http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java index 393dd05..712624c 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/IsolatedClassLoader.java @@ -102,8 +102,6 @@ public class IsolatedClassLoader public String toString() { - return "IsolatedClassLoader{" + - "roleName='" + roleName + '\'' + - '}'; + return "IsolatedClassLoader{roleName='" + roleName + "'}"; } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 dd5e7e3..9decb23 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 @@ -1,4 +1,5 @@ package org.apache.maven.surefire.booter; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java index ff0f184..9efe8fa 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/LazyTestsToRun.java @@ -174,7 +174,8 @@ class LazyTestsToRun /* (non-Javadoc) * @see org.apache.maven.surefire.util.TestsToRun#allowEagerReading() */ - public boolean allowEagerReading() { + public boolean allowEagerReading() + { return false; } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 7a09352..c5d6b5b 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 @@ -96,12 +96,19 @@ public class PropertiesWrapper { String value; List<String> result = new ArrayList<String>(); - // Whoa, C !! - for ( int i = 0; ( value = getProperty( propertyPrefix + i ) ) != null; i++ ) + + int i = 0; + while ( true ) { + value = getProperty( propertyPrefix + ( i++ ) ); + + if ( value == null ) + { + return result; + } + result.add( value ); } - return result; } /** http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 67747f5..362be85 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 @@ -62,6 +62,7 @@ public class ProviderConfiguration private final boolean readTestsFromInStream; + @SuppressWarnings( "checkstyle:parameternumber" ) public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters, RunOrderParameters runOrderParameters, boolean failIfNoTests, ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact, http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java index 02454aa..f75e5a6 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java @@ -25,7 +25,6 @@ import java.lang.reflect.Method; import java.util.Iterator; import org.apache.maven.surefire.providerapi.SurefireProvider; -import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.suite.RunResult; import org.apache.maven.surefire.testset.TestSetFailedException; import org.apache.maven.surefire.util.ReflectionUtils; @@ -49,7 +48,7 @@ public class ProviderFactory private final Object reporterManagerFactory; - private static final Class[] invokeParamaters = new Class[]{ Object.class }; + private static final Class[] INVOKE_PARAMETERS = new Class[]{ Object.class }; public ProviderFactory( StartupConfiguration startupConfiguration, ProviderConfiguration providerConfiguration, @@ -117,7 +116,7 @@ public class ProviderFactory } - private class ProviderProxy + private final class ProviderProxy implements SurefireProvider { private final Object providerInOtherClassLoader; @@ -145,13 +144,13 @@ public class ProviderFactory } public RunResult invoke( Object forkTestSet ) - throws TestSetFailedException, ReporterException, InvocationTargetException + throws TestSetFailedException, InvocationTargetException { ClassLoader current = swapClassLoader( testsClassLoader ); try { final Method invoke = - ReflectionUtils.getMethod( providerInOtherClassLoader.getClass(), "invoke", invokeParamaters ); + ReflectionUtils.getMethod( providerInOtherClassLoader.getClass(), "invoke", INVOKE_PARAMETERS ); final Object result = ReflectionUtils.invokeMethodWithArray2( providerInOtherClassLoader, invoke, new Object[]{ forkTestSet } ); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java index 1c454db..ce23d3e 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java @@ -36,7 +36,7 @@ public class StartupConfiguration private final boolean isInForkedVm; - private final static String SUREFIRE_TEST_CLASSPATH = "surefire.test.class.path"; + private static final String SUREFIRE_TEST_CLASSPATH = "surefire.test.class.path"; public StartupConfiguration( String providerClassName, ClasspathConfiguration classpathConfiguration, http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java index 4b0cfb8..59c8cd2 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java @@ -1,23 +1,23 @@ 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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ import java.io.ByteArrayInputStream; import java.io.File; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 bda705b..a20f96e 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 @@ -99,7 +99,9 @@ public class PropertiesWrapperTest private Classpath createClasspathWithTwoElements() { - return Classpath.emptyClasspath().addClassPathElementUrl( FIRST_ELEMENT ).addClassPathElementUrl( SECOND_ELEMENT ); + return Classpath.emptyClasspath() + .addClassPathElementUrl( FIRST_ELEMENT ) + .addClassPathElementUrl( SECOND_ELEMENT ); } private Classpath readClasspathFromProperties() http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 cfedc8c..66901f7 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 @@ -2,8 +2,7 @@ package org.apache.maven.surefire.booter; /* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor lice -nse agreements. See the NOTICE file + * 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 http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java ---------------------------------------------------------------------- diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java index 9fbfcf2..1ffc894 100644 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java +++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java @@ -1,4 +1,5 @@ package org.apache.maven.surefire.group.match; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -20,6 +21,10 @@ package org.apache.maven.surefire.group.match; import java.util.Collection; +/** + * AND group matcher + * + */ public class AndGroupMatcher extends JoinGroupMatcher { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java ---------------------------------------------------------------------- diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java index 3eba73b..5a75b3f 100644 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java +++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java @@ -1,4 +1,5 @@ package org.apache.maven.surefire.group.match; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +19,10 @@ package org.apache.maven.surefire.group.match; * under the License. */ +/** + * Group Matcher + * + */ public interface GroupMatcher { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java ---------------------------------------------------------------------- diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java index 567c328..fe60869 100644 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java +++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java @@ -1,4 +1,5 @@ package org.apache.maven.surefire.group.match; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -19,6 +20,10 @@ package org.apache.maven.surefire.group.match; */ +/** + * Inverse group matcher + * + */ public class InverseGroupMatcher implements GroupMatcher { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java ---------------------------------------------------------------------- diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java index a96c794..ec8ac76 100644 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java +++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java @@ -1,4 +1,5 @@ package org.apache.maven.surefire.group.match; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -21,6 +22,10 @@ package org.apache.maven.surefire.group.match; import java.util.HashSet; import java.util.Set; +/** + * Joins several group matchers + * + */ public abstract class JoinGroupMatcher implements GroupMatcher { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java ---------------------------------------------------------------------- diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java index 6073b04..65122c7 100644 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java +++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java @@ -1,4 +1,5 @@ package org.apache.maven.surefire.group.match; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -20,6 +21,10 @@ package org.apache.maven.surefire.group.match; import java.util.Collection; +/** + * OR group matcher + * + */ public class OrGroupMatcher extends JoinGroupMatcher { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java ---------------------------------------------------------------------- diff --git a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java index 86021c9..7107397 100644 --- a/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java +++ b/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java @@ -18,9 +18,14 @@ package org.apache.maven.surefire.group.match; * specific language governing permissions and limitations * under the License. */ + import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; +/** + * Single group matcher + * + */ public class SingleGroupMatcher implements GroupMatcher { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47StaticInnerClassTestsIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47StaticInnerClassTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47StaticInnerClassTestsIT.java index 5bdc29f..0901d58 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47StaticInnerClassTestsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47StaticInnerClassTestsIT.java @@ -1,5 +1,24 @@ package org.apache.maven.surefire.its; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java index def9d8b..b5df941 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java @@ -1,5 +1,24 @@ package org.apache.maven.surefire.its.fixture; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.IOException; import org.apache.maven.it.VerificationException; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java index cb9c92d..3e53cca 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java @@ -1,5 +1,24 @@ package org.apache.maven.surefire.its.jiras; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import org.apache.maven.surefire.its.fixture.OutputValidator; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java ---------------------------------------------------------------------- diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java index 9c70e6a..8920b35 100644 --- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java +++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java @@ -78,7 +78,8 @@ public class PojoStackTraceWriter public SafeThrowable getThrowable() { - if ( t == null ) { + if ( t == null ) + { return null; } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java ---------------------------------------------------------------------- diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java index d1b3ff2..c97246c 100644 --- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java +++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java @@ -33,6 +33,8 @@ import org.apache.maven.shared.utils.StringUtils; public class SmartStackTraceParser { + private static final int MAX_LINE_LENGTH = 77; + private final SafeThrowable throwable; private final StackTraceElement[] stackTrace; @@ -93,7 +95,7 @@ public class SmartStackTraceParser if ( stackTraceElements.isEmpty() ) { result.append( simpleName ); - if (StringUtils.isNotEmpty( testMethodName )) + if ( StringUtils.isNotEmpty( testMethodName ) ) { result.append( "." ).append( testMethodName ); } @@ -149,7 +151,7 @@ public class SmartStackTraceParser { result.append( rootIsInclass() ? " " : " » " ); result.append( getMinimalThrowableMiniMessage( target ) ); - result.append( getTruncatedMessage( 77 - result.length() ) ); + result.append( getTruncatedMessage( MAX_LINE_LENGTH - result.length() ) ); } return result.toString(); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java ---------------------------------------------------------------------- diff --git a/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java b/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java index eec23d8..f343108 100644 --- a/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java +++ b/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java @@ -25,6 +25,10 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import org.apache.maven.surefire.util.ReflectionUtils; +/** + * Reflection facade for JUnit3 classes + * + */ public final class JUnit3Reflector { private static final String TEST_CASE = "junit.framework.Test"; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java ---------------------------------------------------------------------- diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java index 0a69703..70ae62a 100644 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java +++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4Reflector.java @@ -28,22 +28,26 @@ import org.junit.Ignore; import org.junit.runner.Description; import org.junit.runner.Request; +/** + * JUnit4 reflection helper + * + */ public final class JUnit4Reflector { - private static final Class[] params = new Class[]{ Class.class }; + private static final Class[] PARAMS = new Class[]{ Class.class }; - private static final Class[] ignoreParams = new Class[]{ Ignore.class }; + private static final Class[] IGNORE_PARAMS = new Class[]{ Ignore.class }; public Ignore getAnnotatedIgnore( Description description ) { - Method getAnnotation = ReflectionUtils.tryGetMethod( description.getClass(), "getAnnotation", params ); + Method getAnnotation = ReflectionUtils.tryGetMethod( description.getClass(), "getAnnotation", PARAMS ); if ( getAnnotation == null ) { return null; } - return (Ignore) ReflectionUtils.invokeMethodWithArray( description, getAnnotation, ignoreParams ); + return (Ignore) ReflectionUtils.invokeMethodWithArray( description, getAnnotation, IGNORE_PARAMS ); } public String getAnnotatedIgnoreValue( Description description ) @@ -54,13 +58,14 @@ public final class JUnit4Reflector public Request createRequest( Class<?>... classes ) { - try { + try + { return (Request) Request.class.getDeclaredMethod( "classes", Class[].class )// Since of JUnit 4.5 .invoke( null, new Object[]{ classes } ); } catch ( NoSuchMethodException e ) { - return Request.classes( null, classes );// Since of JUnit 4.0 + return Request.classes( null, classes ); // Since of JUnit 4.0 } catch ( InvocationTargetException e ) { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 f21ab04..b5964a8 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 @@ -31,6 +31,10 @@ import org.junit.runner.notification.Failure; import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * RunListener for JUnit4, delegates to our own RunListener + * + */ public class JUnit4RunListener extends org.junit.runner.notification.RunListener { @@ -188,7 +192,10 @@ public class JUnit4RunListener { String displayName = description.getDisplayName(); int i = displayName.indexOf( "(" ); - if (i >= 0 ) return displayName.substring( 0, i ); + if ( i >= 0 ) + { + return displayName.substring( 0, i ); + } return displayName; } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java ---------------------------------------------------------------------- diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java index 5cca0e8..473082d 100644 --- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java +++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnitTestFailureListener.java @@ -1,5 +1,24 @@ package org.apache.maven.surefire.common.junit4; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import org.junit.runner.notification.Failure; import java.util.ArrayList; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java ---------------------------------------------------------------------- diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java index 44b12c2..039a118 100644 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java +++ b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java @@ -47,8 +47,7 @@ public final class JUnit48Reflector public boolean isCategoryAnnotationPresent( Class clazz ) { - return ( category != null && - ( clazz.getAnnotation( category ) != null - || ( clazz.getSuperclass() != null && isCategoryAnnotationPresent( clazz.getSuperclass() ) ) ) ); + return clazz != null && category != null + && ( clazz.getAnnotation( category ) != null || isCategoryAnnotationPresent( clazz.getSuperclass() ) ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java ---------------------------------------------------------------------- diff --git a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java index 914c587..9da8715 100644 --- a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java +++ b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48TestChecker.java @@ -53,14 +53,16 @@ public class JUnit48TestChecker @SuppressWarnings( { "unchecked" } ) private boolean isAbstractWithEnclosedRunner( Class testClass ) { - return jUnit4TestChecker.isRunWithPresentInClassLoader() && isAbstract( testClass ) && isRunWithEnclosedRunner(testClass); + return jUnit4TestChecker.isRunWithPresentInClassLoader() + && isAbstract( testClass ) + && isRunWithEnclosedRunner( testClass ); } - private boolean isRunWithEnclosedRunner(Class testClass ) + private boolean isRunWithEnclosedRunner( Class testClass ) { @SuppressWarnings( "unchecked" ) org.junit.runner.RunWith runWithAnnotation = (org.junit.runner.RunWith) testClass.getAnnotation( org.junit.runner.RunWith.class ); - return ( runWithAnnotation != null && Enclosed.class.equals( runWithAnnotation.value())); + return ( runWithAnnotation != null && Enclosed.class.equals( runWithAnnotation.value() ) ); } private boolean isAbstract( Class testClass ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java index 22e7069..be90068 100644 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java +++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java @@ -27,7 +27,6 @@ import org.apache.maven.surefire.providerapi.ProviderParameters; import org.apache.maven.surefire.report.ConsoleOutputCapture; import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.ReportEntry; -import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.ReporterFactory; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; @@ -72,7 +71,7 @@ public class JUnit3Provider } public RunResult invoke( Object forkTestSet ) - throws TestSetFailedException, ReporterException + throws TestSetFailedException { if ( testsToRun == null ) { @@ -121,7 +120,7 @@ public class JUnit3Provider } private void executeTestSet( SurefireTestSet testSet, RunListener reporter, ClassLoader classLoader ) - throws ReporterException, TestSetFailedException + throws TestSetFailedException { ReportEntry report = new SimpleReportEntry( this.getClass().getName(), testSet.getName() ); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java index d361767..9fbc64b 100644 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java +++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnitTestSet.java @@ -26,6 +26,10 @@ import org.apache.maven.surefire.common.junit3.JUnit3Reflector; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.testset.TestSetFailedException; +/** + * JUnit3 test set + * + */ public final class JUnitTestSet implements SurefireTestSet { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java index 1fe381a..362d615 100644 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java +++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java @@ -30,6 +30,10 @@ import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; import org.apache.maven.surefire.testset.TestSetFailedException; +/** + * Executes a JUnit3 test class + * + */ public class PojoTestSet implements SurefireTestSet { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/SurefireTestSet.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/SurefireTestSet.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/SurefireTestSet.java index f2d0cdb..5f089bd 100644 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/SurefireTestSet.java +++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/SurefireTestSet.java @@ -22,6 +22,10 @@ package org.apache.maven.surefire.junit; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.testset.TestSetFailedException; +/** + * Describes a single test set + * + */ public interface SurefireTestSet { void execute( RunListener reportManager, ClassLoader loader ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java index 01e564b..c4c0f51 100644 --- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java +++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java @@ -29,6 +29,10 @@ import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; +/** + * Invocation Handler for TestListener proxies to delegate to our {@link RunListener} + * + */ public class TestListenerInvocationHandler implements InvocationHandler { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 a9b2799..93922e1 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 @@ -19,6 +19,13 @@ package org.apache.maven.surefire.junit4; * under the License. */ +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + import org.apache.maven.shared.utils.io.SelectorUtils; import org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil; import org.apache.maven.surefire.common.junit4.JUnit4RunListener; @@ -31,7 +38,6 @@ import org.apache.maven.surefire.report.ConsoleOutputCapture; import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.PojoStackTraceWriter; import org.apache.maven.surefire.report.ReportEntry; -import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.ReporterFactory; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; @@ -46,13 +52,6 @@ import org.junit.runner.Request; import org.junit.runner.Result; import org.junit.runner.notification.RunNotifier; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - /** * @author Kristian Rosenvold */ @@ -91,7 +90,7 @@ public class JUnit4Provider } public RunResult invoke( Object forkTestSet ) - throws TestSetFailedException, ReporterException + throws TestSetFailedException { if ( testsToRun == null ) { @@ -145,12 +144,12 @@ public class JUnit4Provider { if ( !StringUtils.isBlank( requestedTestMethod ) ) { - String actualTestMethod = getMethod( clazz, requestedTestMethod );//add by rainLee + String actualTestMethod = getMethod( clazz, requestedTestMethod ); String[] testMethods = StringUtils.split( actualTestMethod, "+" ); executeWithRerun( clazz, listeners, testMethods ); } else - {//the original way + { executeWithRerun( clazz, listeners, null ); } } @@ -224,7 +223,7 @@ public class JUnit4Provider return runOrderCalculator.orderTestClasses( scannedClasses ); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) private void upgradeCheck() throws TestSetFailedException { @@ -286,11 +285,11 @@ public class JUnit4Provider } /** - * this method retrive testMethods from String like "com.xx.ImmutablePairTest#testBasic,com.xx.StopWatchTest#testLang315+testStopWatchSimpleGet" - * <br> + * this method retrive testMethods from String like + * "com.xx.ImmutablePairTest#testBasic,com.xx.StopWatchTest#testLang315+testStopWatchSimpleGet" <br> * and we need to think about cases that 2 or more method in 1 class. we should choose the correct method * - * @param testClass the testclass + * @param testClass the testclass * @param testMethodStr the test method string * @return a string ;) */ @@ -299,14 +298,14 @@ public class JUnit4Provider final String className = testClass.getName(); if ( !testMethodStr.contains( "#" ) && !testMethodStr.contains( "," ) ) - {//the original way + { return testMethodStr; } - testMethodStr += ",";//for the bellow split code + testMethodStr += ","; // for the bellow split code final int beginIndex = testMethodStr.indexOf( className ); final int endIndex = testMethodStr.indexOf( ",", beginIndex ); final String classMethodStr = - testMethodStr.substring( beginIndex, endIndex );//String like "StopWatchTest#testLang315" + testMethodStr.substring( beginIndex, endIndex ); // String like "StopWatchTest#testLang315" final int index = classMethodStr.indexOf( '#' ); return index >= 0 ? classMethodStr.substring( index + 1, classMethodStr.length() ) : null; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java index f2cc672..a4a5414 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java @@ -34,7 +34,7 @@ import org.junit.runners.model.InitializationError; import org.junit.runners.model.RunnerBuilder; import org.junit.runners.model.RunnerScheduler; -/* +/** * @author Kristian Rosenvold */ public class ConfigurableParallelComputer http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/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 a145b44..06ebd20 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 @@ -36,7 +36,6 @@ import org.apache.maven.surefire.providerapi.ProviderParameters; import org.apache.maven.surefire.report.ConsoleLogger; import org.apache.maven.surefire.report.ConsoleOutputCapture; import org.apache.maven.surefire.report.ConsoleOutputReceiver; -import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.ReporterFactory; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.suite.RunResult; @@ -89,7 +88,8 @@ public class JUnitCoreProvider rerunFailingTestsCount = providerParameters.getTestRequest().getRerunFailingTestsCount(); customRunListeners = - JUnit4RunListenerFactory.createCustomListeners( providerParameters.getProviderProperties().getProperty( "listener" ) ); + JUnit4RunListenerFactory.createCustomListeners( + providerParameters.getProviderProperties().getProperty( "listener" ) ); jUnit48Reflector = new JUnit48Reflector( testClassLoader ); } @@ -110,7 +110,7 @@ public class JUnitCoreProvider } public RunResult invoke( Object forkTestSet ) - throws TestSetFailedException, ReporterException + throws TestSetFailedException { final ReporterFactory reporterFactory = providerParameters.getReporterFactory(); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java index 5c14bfb..665bcb7 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/SynchronousRunner.java @@ -1,4 +1,5 @@ package org.apache.maven.surefire.junitcore; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java index 365f4b1..42e65f5 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java @@ -47,7 +47,7 @@ public class TestSet private final List<TestMethod> testMethods = Collections.synchronizedList( new ArrayList<TestMethod>() ); - private static final InheritableThreadLocal<TestSet> testSet = new InheritableThreadLocal<TestSet>(); + private static final InheritableThreadLocal<TestSet> TEST_SET = new InheritableThreadLocal<TestSet>(); private final AtomicBoolean allScheduled = new AtomicBoolean(); @@ -152,12 +152,12 @@ public class TestSet public void attachToThread() { - testSet.set( this ); + TEST_SET.set( this ); } public static TestSet getThreadTestSet() { - return testSet.get(); + return TEST_SET.get(); } public LogicalStream getClassLevelLogicalStream() http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java index 2277bd4..873ccfd 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/Balancer.java @@ -39,12 +39,12 @@ public interface Balancer * @return <code>true</code> if current thread is <em>NOT</em> interrupted * while waiting for a permit. */ - public boolean acquirePermit(); + boolean acquirePermit(); /** * Releases a permit, returning it to the balancer. */ - public void releasePermit(); + void releasePermit(); - public void releaseAllPermits(); + void releaseAllPermits(); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java index 06c328d..6dba00d 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/InvokerStrategy.java @@ -63,7 +63,8 @@ final class InvokerStrategy protected boolean stopNow() { final boolean stopped = disable(); - for ( Thread activeThread; ( activeThread = activeThreads.poll() ) != null; ) + + for ( Thread activeThread = activeThreads.poll(); activeThread != null; activeThread = activeThreads.poll() ) { activeThread.interrupt(); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java index 483e5d9..86c958f 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java @@ -43,6 +43,8 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS; public abstract class ParallelComputer extends Computer { + private static final double NANOS_IN_A_SECOND = 1E9; + private final ShutdownStatus shutdownStatus = new ShutdownStatus(); private final ShutdownStatus forcedShutdownStatus = new ShutdownStatus(); @@ -188,7 +190,7 @@ public abstract class ParallelComputer private double nanosToSeconds( long nanos ) { - return (double) nanos / 1E9; + return (double) nanos / NANOS_IN_A_SECOND; } private boolean hasTimeout() @@ -203,7 +205,7 @@ public abstract class ParallelComputer private static long secondsToNanos( double seconds ) { - double nanos = seconds > 0 ? seconds * 1E9 : 0; + double nanos = seconds > 0 ? seconds * NANOS_IN_A_SECOND : 0; return Double.isInfinite( nanos ) || nanos >= Long.MAX_VALUE ? 0 : (long) nanos; } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java index 9353349..d18edd7 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java @@ -19,7 +19,21 @@ package org.apache.maven.surefire.junitcore.pc; * under the License. */ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumMap; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + import net.jcip.annotations.NotThreadSafe; + import org.apache.maven.surefire.junitcore.JUnitCoreParameters; import org.apache.maven.surefire.testset.TestSetFailedException; import org.junit.internal.runners.ErrorReportingRunner; @@ -33,21 +47,10 @@ import org.junit.runners.Suite; import org.junit.runners.model.InitializationError; import org.junit.runners.model.RunnerBuilder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.*; -import static org.apache.maven.surefire.junitcore.pc.Type.*; +import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.resolveConcurrency; +import static org.apache.maven.surefire.junitcore.pc.Type.CLASSES; +import static org.apache.maven.surefire.junitcore.pc.Type.METHODS; +import static org.apache.maven.surefire.junitcore.pc.Type.SUITES; /** * Executing suites, classes and methods with defined concurrency. In this example the threads which completed @@ -292,7 +295,7 @@ public final class ParallelComputerBuilder long suitesCount = suites.size(); long classesCount = classes.size() + nestedClasses.size(); long methodsCount = suiteClasses.embeddedChildrenCount + nestedClassesChildren; - if (!ParallelComputerBuilder.this.runningInTests) + if ( !ParallelComputerBuilder.this.runningInTests ) { determineThreadCounts( suitesCount, classesCount, methodsCount ); } @@ -344,7 +347,7 @@ public final class ParallelComputerBuilder allGroups.put( CLASSES, concurrency.classes ); allGroups.put( METHODS, concurrency.methods ); poolCapacity = concurrency.capacity; - splitPool &= concurrency.capacity <= 0;//fault if negative; should not happen + splitPool &= concurrency.capacity <= 0; // fault if negative; should not happen } private <T extends Runner> WrappedRunners wrapRunners( Collection<T> runners ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java index f93e9b6..028b7ba 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtil.java @@ -66,9 +66,10 @@ final class ParallelComputerUtil if ( !params.isUseUnlimitedThreads() && !hasThreadCount( params ) && !hasThreadCounts( params ) ) { - throw new TestSetFailedException( "Unspecified thread-count(s). " + - "See the parameters " + JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY - + ", " + JUnitCoreParameters.THREADCOUNT_KEY + ", " + throw new TestSetFailedException( "Unspecified thread-count(s). " + + "See the parameters " + + JUnitCoreParameters.USEUNLIMITEDTHREADS_KEY + ", " + + JUnitCoreParameters.THREADCOUNT_KEY + ", " + JUnitCoreParameters.THREADCOUNTSUITES_KEY + ", " + JUnitCoreParameters.THREADCOUNTCLASSES_KEY + ", " + JUnitCoreParameters.THREADCOUNTMETHODS_KEY + "." ); @@ -292,9 +293,9 @@ final class ParallelComputerUtil private static boolean hasThreadCounts( JUnitCoreParameters jUnitCoreParameters ) { - return jUnitCoreParameters.isParallelSuites() && jUnitCoreParameters.getThreadCountSuites() > 0 || - jUnitCoreParameters.isParallelClasses() && jUnitCoreParameters.getThreadCountClasses() > 0 || - jUnitCoreParameters.isParallelMethods() && jUnitCoreParameters.getThreadCountMethods() > 0; + return ( jUnitCoreParameters.isParallelSuites() && jUnitCoreParameters.getThreadCountSuites() > 0 ) + || ( jUnitCoreParameters.isParallelClasses() && jUnitCoreParameters.getThreadCountClasses() > 0 ) + || ( jUnitCoreParameters.isParallelMethods() && jUnitCoreParameters.getThreadCountMethods() > 0 ); } private static boolean hasThreadCount( JUnitCoreParameters jUnitCoreParameters ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java index 1ce744d..1dbbb79 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SchedulingStrategy.java @@ -19,9 +19,6 @@ package org.apache.maven.surefire.junitcore.pc; * under the License. */ -import org.junit.runners.model.RunnerScheduler; - -import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicBoolean; /** http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SharedThreadPoolStrategy.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SharedThreadPoolStrategy.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SharedThreadPoolStrategy.java index cfe6faa..325d1e9 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SharedThreadPoolStrategy.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/SharedThreadPoolStrategy.java @@ -81,13 +81,13 @@ final class SharedThreadPoolStrategy } @Override - protected final boolean stop() + protected boolean stop() { return stop( false ); } @Override - protected final boolean stopNow() + protected boolean stopNow() { return stop( true ); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e4ff0329/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownStatus.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownStatus.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownStatus.java index cf76166..6708089 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownStatus.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ShutdownStatus.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicReference; +// CHECKSTYLE_OFF: imports import static org.apache.maven.surefire.junitcore.pc.ExecutionStatus.*; /**