aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-05-26 19:01:21 +0000
committerGravatar Yue Gan <yueg@google.com>2016-05-27 08:45:22 +0000
commita4bfb3c49f164d47322b39c560a716b89788002b (patch)
treeba5d4a20f63df2ccdbe1a18b0c1526a4ba88c6cb /src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4
parenta3dedfc47b884ead416e3d3c91b675333d45da8e (diff)
Convert the Bazel JUnit4 test runner from Guice to Dagger.
-- MOS_MIGRATED_REVID=123342439
Diffstat (limited to 'src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4')
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/Args.java31
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/BUILD2
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/CancellableRequestFactory.java7
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4InstanceModules.java88
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Runner.java28
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4RunnerBaseModule.java69
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4RunnerModule.java82
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestModelBuilder.java2
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestNameListener.java7
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestStackTraceListener.java5
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestXmlListener.java7
11 files changed, 227 insertions, 101 deletions
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/Args.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/Args.java
new file mode 100644
index 0000000000..9093891307
--- /dev/null
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/Args.java
@@ -0,0 +1,31 @@
+// Copyright 2016 The Bazel Authors. All Rights Reserved.
+//
+// Licensed 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.
+
+package com.google.testing.junit.runner.junit4;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Binding annotation that indicates that the given {@code Collection<String>} or
+ * {@code String[]} represents the command-line arguments of the runner.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.PARAMETER, ElementType.METHOD})
+@Qualifier
+@interface Args {}
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 0141b76a3c..f5f2ecd855 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
@@ -21,8 +21,8 @@ java_library(
"//src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding",
"//src/java_tools/junitrunner/java/com/google/testing/junit/runner/sharding/api",
"//src/java_tools/junitrunner/java/com/google/testing/junit/runner/util",
+ "//third_party:dagger",
"//third_party:guava",
- "//third_party:guice",
"//third_party:joda_time",
"//third_party:jsr305",
"//third_party:jsr330_inject",
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/CancellableRequestFactory.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/CancellableRequestFactory.java
index e8991662e0..371f0bd71d 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/CancellableRequestFactory.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/CancellableRequestFactory.java
@@ -15,7 +15,6 @@
package com.google.testing.junit.runner.junit4;
import com.google.common.base.Preconditions;
-import com.google.inject.Singleton;
import com.google.testing.junit.junit4.runner.MemoizingRequest;
import com.google.testing.junit.junit4.runner.RunNotifierWrapper;
@@ -25,6 +24,9 @@ import org.junit.runner.Runner;
import org.junit.runner.notification.RunNotifier;
import org.junit.runner.notification.StoppedByUserException;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* Creates requests that can be cancelled.
*/
@@ -34,6 +36,9 @@ class CancellableRequestFactory {
private volatile ThreadSafeRunNotifier currentNotifier;
private volatile boolean cancelRequested = false;
+ @Inject
+ CancellableRequestFactory() {}
+
/**
* Creates a request that can be cancelled. Can only be called once.
*
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
new file mode 100644
index 0000000000..966478df83
--- /dev/null
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4InstanceModules.java
@@ -0,0 +1,88 @@
+// Copyright 2012 The Bazel Authors. All Rights Reserved.
+//
+// Licensed 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.
+
+package com.google.testing.junit.runner.junit4;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+
+import dagger.Module;
+import dagger.Provides;
+
+import java.nio.file.Path;
+
+import javax.inject.Singleton;
+
+/**
+ * Dagger modules which hold state or are, for testing purposes, implemented with non-static
+ * provider methods. These types are collected here so they can be cleanly named in the
+ * component builder, but still be obvious in module includes and component declarations.
+ */
+public final class JUnit4InstanceModules {
+
+ /**
+ * A stateful dagger module that holds the supplied test suite class.
+ */
+ @Module
+ public static final class SuiteClass {
+ private final Class<?> suiteClass;
+
+ public SuiteClass(Class<?> suiteClass) {
+ this.suiteClass = suiteClass;
+ }
+
+ @Provides
+ @TopLevelSuite
+ Class<?> topLevelSuite() {
+ return suiteClass;
+ }
+
+ @Provides
+ @TopLevelSuite
+ static String topLevelSuiteName(@TopLevelSuite Class<?> suite) {
+ return suite.getCanonicalName();
+ }
+ }
+
+ /**
+ * A module which supplies a JUnit4Config object, which can be overridden at test-time.
+ */
+ @Module
+ public static final class Config {
+ private final ImmutableList<String> args;
+
+ /**
+ * Creates a module that can provide a {@link JUnit4Config} from supplied command-line
+ * arguments
+ */
+ public Config(String... args) {
+ this.args = ImmutableList.copyOf(args);
+ }
+
+ @Provides
+ @Singleton
+ JUnit4Options options() {
+ return JUnit4Options.parse(System.getenv(), ImmutableList.copyOf(args));
+ }
+
+ @Provides
+ @Singleton
+ JUnit4Config config(JUnit4Options options) {
+ return new JUnit4Config(
+ options.getTestIncludeFilter(), options.getTestExcludeFilter(), Optional.<Path>absent());
+ }
+ }
+
+ private JUnit4InstanceModules() {}
+}
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Runner.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Runner.java
index 4134131216..10447a7b70 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Runner.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Runner.java
@@ -51,6 +51,7 @@ public class JUnit4Runner {
private final PrintStream testRunnerOut;
private final JUnit4Config config;
private final Set<RunListener> runListeners;
+ private final Set<Initializer> initializers;
private GoogleTestSecurityManager googleTestSecurityManager;
private SecurityManager previousSecurityManager;
@@ -59,15 +60,21 @@ public class JUnit4Runner {
* Creates a runner.
*/
@Inject
- private JUnit4Runner(Request request, CancellableRequestFactory requestFactory,
- Supplier<TestSuiteModel> modelSupplier, @Stdout PrintStream testRunnerOut,
- JUnit4Config config, Set<RunListener> runListeners) {
+ JUnit4Runner(
+ Request request,
+ CancellableRequestFactory requestFactory,
+ Supplier<TestSuiteModel> modelSupplier,
+ @Stdout PrintStream testRunnerOut,
+ JUnit4Config config,
+ Set<RunListener> runListeners,
+ Set<Initializer> initializers) {
this.request = request;
this.requestFactory = requestFactory;
this.modelSupplier = modelSupplier;
this.config = config;
this.testRunnerOut = testRunnerOut;
this.runListeners = runListeners;
+ this.initializers = initializers;
}
/**
@@ -79,6 +86,10 @@ public class JUnit4Runner {
testRunnerOut.println("JUnit4 Test Runner");
checkJUnitRunnerApiVersion();
+ for (Initializer init : initializers) {
+ init.initialize();
+ }
+
// Sharding
TestSuiteModel model = modelSupplier.get();
Filter shardingFilter = model.getShardingFilter();
@@ -261,4 +272,15 @@ public class JUnit4Runner {
public void run(RunNotifier notifier) {
}
}
+
+ /**
+ * A simple initializer which can be used to provide additional initialization logic in custom
+ * runners.
+ *
+ * <p>Initializers will be run in unspecified order. If an exception is thrown it will not be
+ * deemed recoverable and will cause the runner to error-out.
+ */
+ public interface Initializer {
+ void initialize();
+ }
}
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4RunnerBaseModule.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4RunnerBaseModule.java
index 28e6466067..c6742324a3 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4RunnerBaseModule.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4RunnerBaseModule.java
@@ -14,21 +14,21 @@
package com.google.testing.junit.runner.junit4;
-import static com.google.inject.multibindings.Multibinder.newSetBinder;
import static com.google.testing.junit.runner.sharding.ShardingFilters.DEFAULT_SHARDING_STRATEGY;
+import static dagger.Provides.Type.SET;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
-import com.google.inject.AbstractModule;
-import com.google.inject.Key;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
import com.google.testing.junit.junit4.runner.MemoizingRequest;
import com.google.testing.junit.runner.internal.Stdout;
+import com.google.testing.junit.runner.junit4.JUnit4InstanceModules.SuiteClass;
import com.google.testing.junit.runner.model.TestSuiteModel;
import com.google.testing.junit.runner.sharding.api.ShardingFilterFactory;
+import dagger.Module;
+import dagger.Multibindings;
+import dagger.Provides;
+
import org.junit.internal.TextListener;
import org.junit.runner.Request;
import org.junit.runner.notification.RunListener;
@@ -37,50 +37,44 @@ import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
+import java.util.Set;
+
+import javax.inject.Singleton;
/**
- * Guice module for creating {@link JUnit4Runner}. This contains the common
+ * Dagger module for creating a {@link JUnit4Runner}. This contains the common
* bindings used when either the runner runs actual tests or when we do
* integration tests of the runner itself.
*
- * <p>Note: we do not use {@code Modules.override()} to test the runner because
- * there are bindings that we use when the runner runs actual tests that set
- * global state, and we don't want to do that when we test the runner itself.
*/
-class JUnit4RunnerBaseModule extends AbstractModule {
- private final Class<?> suiteClass;
+@Module(includes = SuiteClass.class)
+public final class JUnit4RunnerBaseModule {
- public JUnit4RunnerBaseModule(Class<?> suiteClass) {
- this.suiteClass = suiteClass;
+ @Multibindings
+ interface MultiBindings {
+ Set<JUnit4Runner.Initializer> initializers();
}
- @Override
- protected void configure() {
- requireBinding(Key.get(PrintStream.class, Stdout.class));
- requireBinding(JUnit4Config.class);
- requireBinding(TestSuiteModel.Builder.class);
-
- // We require explicit bindings so we don't use an unexpected just-in-time binding
- bind(JUnit4Runner.class);
- bind(JUnit4TestModelBuilder.class);
- bind(CancellableRequestFactory.class);
-
- // Normal bindings
- bind(ShardingFilterFactory.class).toInstance(DEFAULT_SHARDING_STRATEGY);
- bindConstant().annotatedWith(TopLevelSuite.class).to(suiteClass.getCanonicalName());
+ @Provides
+ static ShardingFilterFactory shardingFilterFactory() {
+ return DEFAULT_SHARDING_STRATEGY;
+ }
- // Bind listeners
- Multibinder<RunListener> listenerBinder = newSetBinder(binder(), RunListener.class);
- listenerBinder.addBinding().to(TextListener.class);
+ @Provides(type = SET)
+ static RunListener textListener(TextListener impl) {
+ return impl;
}
- @Provides @Singleton
- Supplier<TestSuiteModel> provideTestSuiteModelSupplier(JUnit4TestModelBuilder builder) {
+
+ @Provides
+ @Singleton
+ static Supplier<TestSuiteModel> provideTestSuiteModelSupplier(JUnit4TestModelBuilder builder) {
return Suppliers.memoize(builder);
}
- @Provides @Singleton
- TextListener provideTextListener(@Stdout PrintStream testRunnerOut) {
+ @Provides
+ @Singleton
+ static TextListener provideTextListener(@Stdout PrintStream testRunnerOut) {
return new TextListener(asUtf8PrintStream(testRunnerOut));
}
@@ -92,8 +86,9 @@ class JUnit4RunnerBaseModule extends AbstractModule {
}
}
- @Provides @Singleton
- Request provideRequest() {
+ @Provides
+ @Singleton
+ static Request provideRequest(@TopLevelSuite Class<?> suiteClass) {
/*
* JUnit4Runner requests the Runner twice, once to build the model (before
* filtering) and once to run the tests (after filtering). Constructing the
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4RunnerModule.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4RunnerModule.java
index 5f15524808..91cfd1d875 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4RunnerModule.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4RunnerModule.java
@@ -14,73 +14,61 @@
package com.google.testing.junit.runner.junit4;
-import static com.google.inject.multibindings.Multibinder.newSetBinder;
+import static dagger.Provides.Type.SET;
import com.google.common.base.Optional;
import com.google.common.base.Ticker;
-import com.google.common.collect.ImmutableList;
import com.google.common.io.ByteStreams;
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
import com.google.testing.junit.runner.internal.SignalHandlers;
import com.google.testing.junit.runner.util.TestNameProvider;
+import dagger.Module;
+import dagger.Provides;
+
import org.junit.runner.notification.RunListener;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.nio.file.Path;
-import java.util.List;
+
+import javax.inject.Singleton;
/**
- * Guice module for real test runs.
+ * Dagger module for real test runs.
*/
-public class JUnit4RunnerModule extends AbstractModule {
- private final Class<?> suite;
- private final JUnit4Config config;
- private final ImmutableList<String> unparsedArgs;
-
- public static JUnit4RunnerModule create(Class<?> suite, List<String> args) {
- JUnit4Options options = JUnit4Options.parse(System.getenv(), ImmutableList.copyOf(args));
- JUnit4Config config = new JUnit4Config(
- options.getTestIncludeFilter(),
- options.getTestExcludeFilter(),
- Optional.<Path>absent());
- return new JUnit4RunnerModule(suite, config, ImmutableList.copyOf(options.getUnparsedArgs()));
+@Module(includes = {JUnit4RunnerBaseModule.class, JUnit4InstanceModules.Config.class})
+public final class JUnit4RunnerModule {
+ @Provides
+ static Ticker ticker() {
+ return Ticker.systemTicker();
}
- private JUnit4RunnerModule(
- Class<?> suite, JUnit4Config config, ImmutableList<String> unparsedArgs) {
- this.suite = suite;
- this.config = config;
- this.unparsedArgs = unparsedArgs;
+ @Provides
+ static SignalHandlers.HandlerInstaller signalHandlerInstaller() {
+ return SignalHandlers.createRealHandlerInstaller();
}
- @Override
- protected void configure() {
- install(new JUnit4RunnerBaseModule(suite));
-
- // We require explicit bindings so we don't use an unexpected just-in-time binding
- bind(SignalHandlers.class);
+ @Provides(type = SET)
+ static RunListener nameListener(JUnit4TestNameListener impl) {
+ return impl;
+ }
- // Normal bindings
- bind(JUnit4Config.class).toInstance(config);
- bind(Ticker.class).toInstance(Ticker.systemTicker());
- bind(SignalHandlers.HandlerInstaller.class).toInstance(
- SignalHandlers.createRealHandlerInstaller());
+ @Provides(type = SET)
+ static RunListener xmlListener(JUnit4TestXmlListener impl) {
+ return impl;
+ }
- // Bind listeners
- Multibinder<RunListener> listenerBinder = newSetBinder(binder(), RunListener.class);
- listenerBinder.addBinding().to(JUnit4TestNameListener.class);
- listenerBinder.addBinding().to(JUnit4TestXmlListener.class);
- listenerBinder.addBinding().to(JUnit4TestStackTraceListener.class);
+ @Provides(type = SET)
+ static RunListener stackTraceListener(JUnit4TestStackTraceListener impl) {
+ return impl;
}
- @Provides @Singleton @Xml
- OutputStream provideXmlStream() {
+
+ @Provides
+ @Singleton
+ @Xml
+ static OutputStream provideXmlStream(JUnit4Config config) {
Optional<Path> path = config.getXmlOutputPath();
if (path.isPresent()) {
@@ -103,16 +91,10 @@ public class JUnit4RunnerModule extends AbstractModule {
@Provides @Singleton
SettableCurrentRunningTest provideCurrentRunningTest() {
return new SettableCurrentRunningTest() {
+ @Override
void setGlobalTestNameProvider(TestNameProvider provider) {
testNameProvider = provider;
}
};
}
-
- /**
- * Gets the list of unparsed command line arguments.
- */
- public ImmutableList<String> getUnparsedArgs() {
- return unparsedArgs;
- }
}
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestModelBuilder.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestModelBuilder.java
index 62df88db45..5dd98e9b3b 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestModelBuilder.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestModelBuilder.java
@@ -16,7 +16,6 @@ package com.google.testing.junit.runner.junit4;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
-import com.google.inject.Singleton;
import com.google.testing.junit.runner.model.TestSuiteModel;
import com.google.testing.junit.runner.model.TestSuiteModel.Builder;
@@ -24,6 +23,7 @@ import org.junit.runner.Description;
import org.junit.runner.Request;
import javax.inject.Inject;
+import javax.inject.Singleton;
/**
* Builds a {@link TestSuiteModel} for JUnit4 tests.
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestNameListener.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestNameListener.java
index b7da73fa53..e1c2c54133 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestNameListener.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestNameListener.java
@@ -14,15 +14,16 @@
package com.google.testing.junit.runner.junit4;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
import com.google.testing.junit.runner.util.TestNameProvider;
import org.junit.runner.Description;
import org.junit.runner.notification.RunListener;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
- * A listener to get the name of a JUnit4 test.
+ * A listener to get the name of a JUnit4 test.
*/
@Singleton
class JUnit4TestNameListener extends RunListener {
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestStackTraceListener.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestStackTraceListener.java
index abb0614afd..8f62b1d99f 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestStackTraceListener.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4TestStackTraceListener.java
@@ -14,8 +14,6 @@
package com.google.testing.junit.runner.junit4;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
import com.google.testing.junit.runner.internal.SignalHandlers;
import com.google.testing.junit.runner.internal.StackTraces;
import com.google.testing.junit.runner.internal.Stderr;
@@ -28,6 +26,9 @@ import sun.misc.SignalHandler;
import java.io.PrintStream;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* A listener than dumps all stack traces when the test receives a SIGTERM.
*/
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 5e572e1e10..609591bb8d 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
@@ -15,8 +15,6 @@
package com.google.testing.junit.runner.junit4;
import com.google.common.base.Supplier;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
import com.google.testing.junit.runner.internal.SignalHandlers;
import com.google.testing.junit.runner.internal.Stderr;
import com.google.testing.junit.runner.model.TestSuiteModel;
@@ -33,12 +31,15 @@ import sun.misc.SignalHandler;
import java.io.OutputStream;
import java.io.PrintStream;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* A listener that writes the test output as XML.
*/
@Singleton
class JUnit4TestXmlListener extends RunListener {
-
+
private final Supplier<TestSuiteModel> modelSupplier;
private final CancellableRequestFactory requestFactory;
private final SignalHandlers signalHandlers;