MCPcopy Create free account
hub / github.com/google/guice / testCombineSources

Method testCombineSources

core/test/com/google/inject/ModulesTest.java:45–68  ·  view source on GitHub ↗

The module returned by Modules.combine shouldn't show up in binder sources.

()

Source from the content-addressed store, hash-verified

43
44 /** The module returned by Modules.combine shouldn't show up in binder sources. */
45 public void testCombineSources() {
46 final Module m1 = newModule(1);
47 final Module m2 = newModule(2L);
48 final Module combined1 = Modules.combine(m1, m2);
49 Module skipSourcesModule =
50 new AbstractModule() {
51 @Override
52 protected void configure() {
53 install(combined1);
54 }
55 };
56 final Module combined2 = Modules.combine(skipSourcesModule); // returns skipSourcesModule
57 Injector injector = Guice.createInjector(combined2);
58 ElementSource source = (ElementSource) injector.getBinding(Integer.class).getSource();
59 assertEquals(3, source.getModuleClassNames().size());
60 assertEquals(
61 ImmutableList.of(
62 m1.getClass().getName(),
63 combined1.getClass().getName(),
64 skipSourcesModule.getClass().getName()),
65 source.getModuleClassNames());
66 StackTraceElement stackTraceElement = (StackTraceElement) source.getDeclaringSource();
67 assertEquals(skipSourcesModule.getClass().getName(), stackTraceElement.getClassName());
68 }
69
70 private <T> Module newModule(final T toBind) {
71 return new AbstractModule() {

Callers

nothing calls this directly

Calls 11

newModuleMethod · 0.95
combineMethod · 0.95
createInjectorMethod · 0.95
getBindingMethod · 0.95
getModuleClassNamesMethod · 0.95
getDeclaringSourceMethod · 0.95
getSourceMethod · 0.65
getNameMethod · 0.65
getClassNameMethod · 0.65
sizeMethod · 0.45
ofMethod · 0.45

Tested by

no test coverage detected