Search in sources :

Example 21 with Injector

use of se.jbee.inject.Injector in project silk by jbee.

the class TestMultibindBinds method thatMultipleNamedElementsCanBeBound.

@Test
public void thatMultipleNamedElementsCanBeBound() {
    Injector injector = Bootstrap.injector(MultibindBindsBundle.class);
    Integer[] foos = injector.resolve(dependency(Integer[].class).named(foo));
    assertEqualSets(new Integer[] { 2, 3 }, foos);
    Integer[] bars = injector.resolve(dependency(Integer[].class).named(bar));
    assertEqualSets(new Integer[] { 4, 5 }, bars);
    Integer[] defaults = injector.resolve(dependency(Integer[].class).named(Name.DEFAULT));
    assertEqualSets(new Integer[] { 1, 11 }, defaults);
    Integer[] anys = injector.resolve(dependency(Integer[].class).named(Name.ANY));
    assertEqualSets(new Integer[] { 1, 2, 3, 4, 5, 11 }, anys);
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 22 with Injector

use of se.jbee.inject.Injector in project silk by jbee.

the class TestMultibindBinds method thatMultipleBoundNamedElementsCanUsedAsList.

@Test
public void thatMultipleBoundNamedElementsCanUsedAsList() {
    Injector injector = Bootstrap.injector(MultibindBindsBundle.class);
    List<Integer> foos = injector.resolve(dependency(listTypeOf(Integer.class)).named(foo));
    assertEqualSets(new Integer[] { 2, 3 }, foos.toArray());
    List<Integer> bars = injector.resolve(dependency(listTypeOf(Integer.class)).named(bar));
    assertEqualSets(new Integer[] { 4, 5 }, bars.toArray());
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 23 with Injector

use of se.jbee.inject.Injector in project silk by jbee.

the class TestMultibindBinds method thatMultipleBoundNamedElementsCanUsedAsSet.

@Test
public void thatMultipleBoundNamedElementsCanUsedAsSet() {
    Injector injector = Bootstrap.injector(MultibindBindsBundle.class);
    Set<Integer> foos = injector.resolve(dependency(setTypeOf(Integer.class)).named(foo));
    assertEqualSets(new Integer[] { 2, 3 }, foos.toArray());
    Set<Integer> bars = injector.resolve(dependency(setTypeOf(Integer.class)).named(bar));
    assertEqualSets(new Integer[] { 4, 5 }, bars.toArray());
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 24 with Injector

use of se.jbee.inject.Injector in project silk by jbee.

the class TestRequiredProvidedBinds method thatAnExplicitBindReplacesTheProvidedImplementation.

@Test
public void thatAnExplicitBindReplacesTheProvidedImplementation() {
    Injector injector = Bootstrap.injector(ExplicitBindBundle.class);
    ExampleService s = injector.resolve(dependency(ExampleService.class));
    assertTrue(s instanceof ExplicitExampleService);
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 25 with Injector

use of se.jbee.inject.Injector in project silk by jbee.

the class TestRequiredProvidedBinds method thatRequirementIsFulfilledByProvidedBind.

@Test
public void thatRequirementIsFulfilledByProvidedBind() {
    Injector injector = Bootstrap.injector(RequiredProvidedBindsBundle.class);
    assertNotNull(injector.resolve(dependency(ExampleService.class)));
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Aggregations

Injector (se.jbee.inject.Injector)44 Test (org.junit.Test)41 Shape (java.awt.Shape)3 Globals (se.jbee.inject.config.Globals)2 Options (se.jbee.inject.config.Options)2 Rectangle (java.awt.Rectangle)1 MouseListener (java.awt.event.MouseListener)1 PathIterator (java.awt.geom.PathIterator)1 Serializable (java.io.Serializable)1 EventListener (java.util.EventListener)1 Properties (java.util.Properties)1 Injectron (se.jbee.inject.Injectron)1 NoResourceForDependency (se.jbee.inject.UnresolvableDependency.NoResourceForDependency)1 Presets (se.jbee.inject.config.Presets)1