use of se.jbee.inject.Injector in project silk by jbee.
the class TestBootstrapper method thatBindingsAreReplacedByMorePreciseOnes.
/**
* In the example {@link Number} is {@link DeclarationType#AUTO} bound for {@link Integer} and
* {@link Float} but an {@link DeclarationType#EXPLICIT} bind done overrides these automatic
* binds. They are removed and no {@link Injectron} is created for them.
*/
@Test
public void thatBindingsAreReplacedByMorePreciseOnes() {
Injector injector = Bootstrap.injector(ReplacingBindsModule.class);
assertEquals(6, injector.resolve(dependency(Number.class)));
Injectron<?>[] injectrons = injector.resolve(dependency(Injectron[].class));
// 3x Comparable, Float, Double, Integer and Number (3x Serializable has been nullified)
assertEquals(7, injectrons.length);
Injectron<Number>[] numberInjectrons = injector.resolve(dependency(injectronsTypeOf(Number.class)));
assertEquals(1, numberInjectrons.length);
@SuppressWarnings("rawtypes") Injectron<Comparable>[] compareableInjectrons = injector.resolve(dependency(injectronsTypeOf(Comparable.class)));
assertEquals(3, compareableInjectrons.length);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestExample1Binds method constructorArgumentsCanBeResolvedUsingNamedInstances.
@Test
public void constructorArgumentsCanBeResolvedUsingNamedInstances() {
Injector injector = Bootstrap.injector(Example1Module2.class);
MyClass obj = injector.resolve(Dependency.dependency(MyClass.class));
assertEquals(12, obj.twelve);
assertEquals("abc", obj.abc);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestMacroBinds method thatBindingsCanJustBeCounted.
@Test
public void thatBindingsCanJustBeCounted() {
CountMacro count = new CountMacro();
Injector injector = injectorWithMacro(MacroBindsModule.class, count);
assertEquals(6, count.expands);
assertEquals(0, injector.resolve(Dependency.dependency(Injectron[].class)).length);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestStateDependentBinds method thatStateChangeIsResolvedToAnotherImplementation2.
@Test
public void thatStateChangeIsResolvedToAnotherImplementation2() {
Injector injector = Bootstrap.injector(StateDependentBindsModule2.class);
assertStateChangeIsResolvedToAnotherImplementation(injector);
}
Aggregations