diff options
18 files changed, 37 insertions, 57 deletions
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/BUILD b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/BUILD index b99b06c55c..baa4ee8c2a 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/BUILD +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/BUILD @@ -21,7 +21,6 @@ java_library( "//third_party:dagger", "//third_party:guava", "//third_party:joda_time", - "//third_party:jsr305", "//third_party:junit4", ], ) diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/internal/BUILD b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/internal/BUILD index 149420bbff..2c9a488008 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/internal/BUILD +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/internal/BUILD @@ -5,8 +5,6 @@ java_library( srcs = glob(["*.java"]), deps = [ "//third_party:guava", - "//third_party:joda_time", - "//third_party:jsr305", "//third_party:jsr330_inject", "//third_party:junit4", ], diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/BUILD b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/BUILD index f5f2ecd855..819ad9fb91 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/BUILD +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/BUILD @@ -23,7 +23,6 @@ java_library( "//src/java_tools/junitrunner/java/com/google/testing/junit/runner/util", "//third_party:dagger", "//third_party:guava", - "//third_party:joda_time", "//third_party:jsr305", "//third_party:jsr330_inject", "//third_party:junit4", diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Config.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Config.java index a25d3a3746..9f76bd89bb 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Config.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Config.java @@ -15,7 +15,6 @@ package com.google.testing.junit.runner.junit4; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.base.Preconditions; @@ -74,16 +73,11 @@ class JUnit4Config { */ public Optional<Path> getXmlOutputPath() { if (!xmlOutputPath.isPresent()) { - Optional<String> envXmlOutputPath = - Optional.fromNullable(System.getenv(XML_OUTPUT_FILE_ENV_VAR)); - return envXmlOutputPath.transform(new Function<String, Path>() { - @Override - public Path apply(String path) { - return FileSystems.getDefault().getPath(path); - } - }); + String envXmlOutputPath = System.getenv(XML_OUTPUT_FILE_ENV_VAR); + return envXmlOutputPath == null + ? Optional.<Path>absent() + : Optional.of(FileSystems.getDefault().getPath(envXmlOutputPath)); } - return xmlOutputPath; } diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4InstanceModules.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4InstanceModules.java index 966478df83..10f7a72c9d 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4InstanceModules.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4InstanceModules.java @@ -73,12 +73,12 @@ public final class JUnit4InstanceModules { @Provides @Singleton JUnit4Options options() { - return JUnit4Options.parse(System.getenv(), ImmutableList.copyOf(args)); + return JUnit4Options.parse(System.getenv(), args); } @Provides @Singleton - JUnit4Config config(JUnit4Options options) { + static JUnit4Config config(JUnit4Options options) { return new JUnit4Config( options.getTestIncludeFilter(), options.getTestExcludeFilter(), Optional.<Path>absent()); } diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Options.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Options.java index d421774a3c..13e6e574c4 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Options.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Options.java @@ -15,9 +15,9 @@ package com.google.testing.junit.runner.junit4; import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Maps; +import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -44,8 +44,8 @@ class JUnit4Options { * object representing the parsed arguments. */ static JUnit4Options parse(Map<String, String> envVars, List<String> args) { - ImmutableList.Builder<String> unparsedArgsBuilder = ImmutableList.builder(); - Map<String, String> optionsMap = Maps.newHashMap(); + List<String> unparsedArgs = new ArrayList<>(); + Map<String, String> optionsMap = new HashMap<>(); optionsMap.put(TEST_INCLUDE_FILTER_OPTION, null); optionsMap.put(TEST_EXCLUDE_FILTER_OPTION, null); @@ -68,7 +68,7 @@ class JUnit4Options { optionsMap.put(arg, it.next()); continue; } - unparsedArgsBuilder.add(arg); + unparsedArgs.add(arg); } // If TESTBRIDGE_TEST_ONLY is set in the environment, forward it to the // --test_filter flag. @@ -77,10 +77,9 @@ class JUnit4Options { optionsMap.put(TEST_INCLUDE_FILTER_OPTION, testFilter); } - ImmutableList<String> unparsedArgs = unparsedArgsBuilder.build(); return new JUnit4Options(optionsMap.get(TEST_INCLUDE_FILTER_OPTION), optionsMap.get(TEST_EXCLUDE_FILTER_OPTION), - unparsedArgs.toArray(new String[unparsedArgs.size()])); + unparsedArgs.toArray(new String[0])); } private final String testIncludeFilter; diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestXmlListener.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestXmlListener.java index 609591bb8d..d76c7f6f0c 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestXmlListener.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestXmlListener.java @@ -39,7 +39,6 @@ import javax.inject.Singleton; */ @Singleton class JUnit4TestXmlListener extends RunListener { - private final Supplier<TestSuiteModel> modelSupplier; private final CancellableRequestFactory requestFactory; private final SignalHandlers signalHandlers; diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestCaseNode.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestCaseNode.java index 98a6cb1761..3d18567597 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestCaseNode.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestCaseNode.java @@ -24,8 +24,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.ListMultimap; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.google.common.collect.Multimaps; import com.google.common.collect.Multiset; import com.google.testing.junit.runner.model.TestResult.Status; @@ -35,9 +33,11 @@ import org.joda.time.Interval; import org.junit.runner.Description; import java.util.Collections; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Queue; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import javax.annotation.Nullable; @@ -47,7 +47,7 @@ import javax.annotation.Nullable; */ class TestCaseNode extends TestNode implements TestPropertyExporter.Callback { private final TestSuiteNode parent; - private final Map<String, String> properties = Maps.newConcurrentMap(); + private final Map<String, String> properties = new ConcurrentHashMap<>(); private final Multiset<String> repeatedPropertyNames = ConcurrentHashMultiset.create(); private final Queue<Throwable> globalFailures = new ConcurrentLinkedQueue<>(); private final ListMultimap<Description, Throwable> dynamicTestToFailures = @@ -177,7 +177,7 @@ class TestCaseNode extends TestNode implements TestPropertyExporter.Callback { // For now, we give each dynamic test an empty properties map and the same // run time and status as its parent test case, but this may change. - List<TestResult> childResults = Lists.newLinkedList(); + List<TestResult> childResults = new LinkedList<>(); for (Description dynamicTest : getDescription().getChildren()) { childResults.add(buildDynamicResult(dynamicTest, getRuntime(), getTestResultStatus())); } diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestSuiteModel.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestSuiteModel.java index 758ab35957..a7f14abda1 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestSuiteModel.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestSuiteModel.java @@ -24,7 +24,6 @@ import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Ticker; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import com.google.testing.junit.junit4.runner.DynamicTestException; import com.google.testing.junit.runner.sharding.ShardingEnvironment; import com.google.testing.junit.runner.sharding.ShardingFilters; @@ -37,6 +36,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.StringWriter; import java.util.Collection; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -285,7 +285,7 @@ public class TestSuiteModel { } private Filter getShardingFilter(Description... topLevelSuites) { - Collection<Description> tests = Lists.newLinkedList(); + Collection<Description> tests = new LinkedList<>(); for (Description suite : topLevelSuites) { collectTests(suite, tests); } diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestSuiteNode.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestSuiteNode.java index f6656e4fb6..265c2c00fa 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestSuiteNode.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/TestSuiteNode.java @@ -18,12 +18,12 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import com.google.testing.junit.runner.model.TestResult.Status; import org.joda.time.Interval; import org.junit.runner.Description; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -32,8 +32,7 @@ import java.util.List; * A parent node in the test suite model. */ class TestSuiteNode extends TestNode { - - private final List<TestNode> children = Lists.newArrayList(); + private final List<TestNode> children = new ArrayList<>(); TestSuiteNode(Description description) { super(description); @@ -97,7 +96,7 @@ class TestSuiteNode extends TestNode { protected TestResult buildResult() { Interval runTime = null; int numTests = 0, numFailures = 0; - LinkedList<TestResult> childResults = Lists.newLinkedList(); + LinkedList<TestResult> childResults = new LinkedList<>(); for (TestNode child : children) { TestResult childResult = child.getResult(); diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/XmlWriter.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/XmlWriter.java index 97636edb05..ed373144ba 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/XmlWriter.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/XmlWriter.java @@ -19,7 +19,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.base.Strings; -import com.google.common.collect.Lists; import com.google.common.xml.XmlEscapers; import java.io.IOException; @@ -27,6 +26,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; +import java.util.ArrayList; import java.util.List; /** @@ -40,7 +40,7 @@ class XmlWriter { private final Writer writer; private boolean started; private boolean inElement; - private final List<String> elementStack = Lists.newArrayList(); + private final List<String> elementStack = new ArrayList<>(); /** * Creates an XML writer that writes to the given {@code OutputStream}. diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/HashBackedShardingFilter.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/HashBackedShardingFilter.java index 9225ca2d86..aa641a497e 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/HashBackedShardingFilter.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/HashBackedShardingFilter.java @@ -23,8 +23,7 @@ import org.junit.runner.manipulation.Filter; * Sharding filter that uses the hashcode of the test description to * assign it to a shard. */ -class HashBackedShardingFilter extends Filter { - +final class HashBackedShardingFilter extends Filter { private final int shardIndex; private final int totalShards; diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/RoundRobinShardingFilter.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/RoundRobinShardingFilter.java index 38d9f110b7..09c9e31951 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/RoundRobinShardingFilter.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/RoundRobinShardingFilter.java @@ -16,15 +16,15 @@ package com.google.testing.junit.runner.sharding; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import org.junit.runner.Description; import org.junit.runner.manipulation.Filter; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -40,7 +40,6 @@ import java.util.Map; * sharding, but are done so that this filter can be compared in tests. */ public final class RoundRobinShardingFilter extends Filter { - @VisibleForTesting final Map<Description, Integer> testToShardMap; @VisibleForTesting @@ -63,11 +62,11 @@ public final class RoundRobinShardingFilter extends Filter { */ private static Map<Description, Integer> buildTestToShardMap( Collection<Description> testDescriptions) { - Map<Description, Integer> map = Maps.newHashMap(); + Map<Description, Integer> map = new HashMap<>(); // Sorting this list is incredibly important to correctness. Otherwise, // "shuffled" suites would break the sharding protocol. - List<Description> sortedDescriptions = Lists.newArrayList(testDescriptions); + List<Description> sortedDescriptions = new ArrayList<>(testDescriptions); Collections.sort(sortedDescriptions, new DescriptionComparator()); // If we get two descriptions that are equal, the shard number for the second @@ -110,5 +109,4 @@ public final class RoundRobinShardingFilter extends Filter { return d1.getDisplayName().compareTo(d2.getDisplayName()); } } - } diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/api/ShardingFilterFactory.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/api/ShardingFilterFactory.java index 71cb9ea5f3..5e6da3d232 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/api/ShardingFilterFactory.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/api/ShardingFilterFactory.java @@ -24,7 +24,6 @@ import java.util.Collection; * no-argument constructor. */ public interface ShardingFilterFactory { - /** * Creates a test sharding filter. * diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/api/WeightStrategy.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/api/WeightStrategy.java index 3ee6458b61..567bc23682 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/api/WeightStrategy.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/api/WeightStrategy.java @@ -20,7 +20,6 @@ import org.junit.runner.Description; * Extracts the weight associated with a test for use by sharding filters. */ public interface WeightStrategy { - /** * Returns the weight of a test extracted from its description. * diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/testing/RoundRobinShardingFilterFactory.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/testing/RoundRobinShardingFilterFactory.java index 45af5deb1e..d6c4cc267c 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/testing/RoundRobinShardingFilterFactory.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/testing/RoundRobinShardingFilterFactory.java @@ -25,11 +25,10 @@ import java.util.Collection; /** * Creates a {@link RoundRobinShardingFilter} for use in tests. */ -public class RoundRobinShardingFilterFactory implements ShardingFilterFactory { - - @Override - public Filter createFilter( - Collection<Description> testDescriptions, int shardIndex, int totalShards) { - return new RoundRobinShardingFilter(testDescriptions, shardIndex, totalShards); - } +public final class RoundRobinShardingFilterFactory implements ShardingFilterFactory { + @Override + public Filter createFilter( + Collection<Description> testDescriptions, int shardIndex, int totalShards) { + return new RoundRobinShardingFilter(testDescriptions, shardIndex, totalShards); + } } diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/testing/ShardingFilterTestCase.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/testing/ShardingFilterTestCase.java index 1cffdb7676..668c790135 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/testing/ShardingFilterTestCase.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/testing/ShardingFilterTestCase.java @@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ListMultimap; -import com.google.common.collect.Lists; import com.google.testing.junit.runner.sharding.api.ShardingFilterFactory; import junit.framework.TestCase; @@ -29,13 +28,13 @@ import org.junit.runner.Description; import org.junit.runner.manipulation.Filter; import java.util.Deque; +import java.util.LinkedList; import java.util.List; /** * Common base class for all sharding filter tests. */ public abstract class ShardingFilterTestCase extends TestCase { - static final List<Description> TEST_DESCRIPTIONS = createGenericTestCaseDescriptions(6); /** @@ -166,7 +165,7 @@ public abstract class ShardingFilterTestCase extends TestCase { if (descriptions.isEmpty()) { return ArrayListMultimap.create(); } - Deque<Description> mutatingDescriptions = Lists.newLinkedList(descriptions); + Deque<Description> mutatingDescriptions = new LinkedList<>(descriptions); ListMultimap<Filter, Description> descriptionsRun = ArrayListMultimap.create(); for (Filter filter : filters) { diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/util/TestNameProvider.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/util/TestNameProvider.java index 3767e6466a..6348ebf80e 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/util/TestNameProvider.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/util/TestNameProvider.java @@ -24,5 +24,5 @@ public interface TestNameProvider { /** * Gets the description of the current test. */ - public Description get(); + Description get(); } |