use of se.jbee.inject.Injector in project silk by jbee.
the class TestScopedBinds method thatInjectingAnInjectionScopedInstanceIntoAppScopedInstanceThrowsAnException.
@Test(expected = UnstableDependency.class)
public void thatInjectingAnInjectionScopedInstanceIntoAppScopedInstanceThrowsAnException() {
Injector injector = Bootstrap.injector(ScopedBindsModule.class);
Foo foo = injector.resolve(dependency(Foo.class));
fail("It should not be possible to create a foo but got one: " + foo);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestSpecificImplementationBinds method thatImplementationIsPickedAsSpecified.
@Test
public void thatImplementationIsPickedAsSpecified() {
Injector injector = Bootstrap.injector(SpecificImplementationBindsModule.class);
Receiver r = injector.resolve(dependency(Receiver.class));
assertEquals(ActionA.class, r.a.getClass());
assertEquals(GenericAction.class, r.b.getClass());
assertEquals(GenericAction.class, r.c.getClass());
assertEquals("this is b", r.b.doIt());
assertEquals("and this is c", r.c.doIt());
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestActionBinds method actionsDecoupleConcreteMethods.
@Test
public void actionsDecoupleConcreteMethods() {
Injector injector = Bootstrap.injector(ActionBindsModule.class);
Dependency<Action<Integer, Integer>> p1 = actionDependency(raw(Integer.class), raw(Integer.class));
Action<Integer, Integer> mul2 = injector.resolve(p1);
assertNotNull(mul2);
assertEquals(9, mul2.exec(3).intValue());
Dependency<Action<Number, Integer>> p2 = actionDependency(raw(Number.class), raw(Integer.class));
Action<Number, Integer> negate = injector.resolve(p2);
assertNotNull(mul2);
assertEquals(-3, negate.exec(3).intValue());
assertEquals(11, mul2.exec(4).intValue());
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestStateDependentBinds method assertConfigNumberResolvedToStringEnding.
private static void assertConfigNumberResolvedToStringEnding(Integer actualValue, String ending) {
Injector injector = Bootstrap.injector(StateDependentBindsModule3.class);
StatefulObject state = injector.resolve(dependency(StatefulObject.class));
state.setNumber(actualValue);
String v = injector.resolve(dependency(String.class));
assertTrue(v.endsWith(ending));
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestSupplierBinds method test.
@Test
public void test() {
Injector injector = Bootstrap.injector(SupplierBindsModule.class);
String value = injector.resolve(dependency(String.class));
assertEquals("foobar", value);
}
Aggregations