Search in sources :

Example 1 with Injectron

use of se.jbee.inject.Injectron 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);
}
Also used : Injector(se.jbee.inject.Injector) Injectron(se.jbee.inject.Injectron) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Injector (se.jbee.inject.Injector)1 Injectron (se.jbee.inject.Injectron)1