use of com.google.inject.Exposed in project guice by google.
the class ModuleAnnotatedMethodScannerTest method testPrivateModuleInheritScanner_usingPrivateModule.
public void testPrivateModuleInheritScanner_usingPrivateModule() {
Injector injector = Guice.createInjector(NamedMunger.module(), new PrivateModule() {
@Override
protected void configure() {
}
@Exposed
@TestProvides
@Named("foo")
String foo() {
return "foo";
}
});
assertMungedBinding(injector, String.class, "foo", "foo");
}
use of com.google.inject.Exposed in project guice by google.
the class ModuleAnnotatedMethodScannerTest method testPrivateModuleScannersDontImpactSiblings_usingPrivateModule.
public void testPrivateModuleScannersDontImpactSiblings_usingPrivateModule() {
Injector injector = Guice.createInjector(new PrivateModule() {
@Override
protected void configure() {
install(NamedMunger.module());
}
@Exposed
@TestProvides
@Named("foo")
String foo() {
return "foo";
}
}, new PrivateModule() {
@Override
protected void configure() {
}
// ignored! (because the scanner doesn't run over this module)
@Exposed
@TestProvides
@Named("foo")
String foo() {
return "foo";
}
});
assertMungedBinding(injector, String.class, "foo", "foo");
}
use of com.google.inject.Exposed in project guice by google.
the class ModuleAnnotatedMethodScannerTest method scannerSourceForPrivateModule.
@Test
public void scannerSourceForPrivateModule() {
Module module = new AbstractModule() {
@Override
protected void configure() {
install(new PrivateModule() {
@Override
protected void configure() {
}
@Exposed
@TestProvides
@Foo
String privateString() {
return "bar";
}
});
}
};
TestScanner scanner = new TestScanner(TestProvides.class);
Injector injector = Guice.createInjector(module, scannerModule(scanner));
assertThat(getSourceScanner(injector.getBinding(Key.get(String.class, Foo.class)))).isEqualTo(scanner);
}
use of com.google.inject.Exposed in project guice by google.
the class ModuleAnnotatedMethodScannerTest method privateModuleScannersDontImpactSiblings_usingPrivateModule.
@Test
public void privateModuleScannersDontImpactSiblings_usingPrivateModule() {
Injector injector = Guice.createInjector(new PrivateModule() {
@Override
protected void configure() {
install(scannerModule(new NamedMunger()));
}
@Exposed
@TestProvides
@Named("foo")
String foo() {
return "foo";
}
}, new PrivateModule() {
@Override
protected void configure() {
}
// ignored! (because the scanner doesn't run over this module)
@Exposed
@TestProvides
@Named("foo")
String foo() {
return "foo";
}
});
assertMungedBinding(injector, String.class, "foo", "foo");
}
use of com.google.inject.Exposed in project guice by google.
the class ModuleAnnotatedMethodScannerTest method privateModuleInheritsScanner_scannerInstalledAfterPrivateModule.
@Test
public void privateModuleInheritsScanner_scannerInstalledAfterPrivateModule() {
Injector injector = Guice.createInjector(new PrivateModule() {
@Override
protected void configure() {
}
@Exposed
@TestProvides
@Named("foo")
String foo() {
return "foo";
}
}, // Scanner installed after private module.
scannerModule(new NamedMunger()));
assertMungedBinding(injector, String.class, "foo", "foo");
}
Aggregations