Search in sources :

Example 1 with Injector

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

the class TestExample2Binds method thatInstancesAToDAreDifferent.

@Test
public void thatInstancesAToDAreDifferent() {
    Injector injector = Bootstrap.injector(Example2Module.class);
    Decoupling a = injector.resolve(dependency(instance(named("a"), raw(Decoupling.class))));
    Decoupling b = injector.resolve(dependency(instance(named("b"), raw(Decoupling.class))));
    Decoupling c = injector.resolve(dependency(instance(named("c"), raw(Decoupling.class))));
    Decoupling d = injector.resolve(dependency(instance(named("d"), raw(Decoupling.class))));
    assertNotSame(a, b);
    assertNotSame(a, c);
    assertNotSame(a, d);
    assertNotSame(b, c);
    assertNotSame(b, d);
    assertNotSame(c, d);
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 2 with Injector

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

the class TestInjectronBinds method thatInjectorIsAvailableByDefault.

@Test
public void thatInjectorIsAvailableByDefault() {
    Injector resolved = injector.resolve(dependency(Injector.class));
    assertSame(injector, resolved);
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 3 with Injector

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

the class TestIssue1 method thatBundleCanBeBootstrapped.

@Test
public void thatBundleCanBeBootstrapped() {
    Injector injector = Bootstrap.injector(Bundle1.class);
    B b = injector.resolve(dependency(B.class));
    B leftB = injector.resolve(dependency(B.class).named(left));
    assertNotSame(b, leftB);
    assertEquals(2, leftB.as.length);
    C c = injector.resolve(dependency(C.class).injectingInto(instance(left, raw(B.class))));
    D d = injector.resolve(dependency(D.class).injectingInto(instance(left, raw(B.class))));
    assertEqualSets(new A[] { c, d }, leftB.as);
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 4 with Injector

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

the class TestLambdaBinds method thatLambdasCanBeUsedToDescribeModules.

@Test
public void thatLambdasCanBeUsedToDescribeModules() {
    Injector injector = Bootstrap.injector(LambdaBindsModule.class);
    assertEquals(1, injector.resolve(dependency(int.class)).intValue());
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 5 with Injector

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

the class TestLinker method thatMonomodalModulesCanBeInstalledTwice.

/**
	 * A monomodal module has just one initial state (or no state). Therefore it can be determined
	 * that installing it twice or more does not make sense.
	 */
@Test
public void thatMonomodalModulesCanBeInstalledTwice() {
    Injector injector = Bootstrap.injector(LinkerBundle.class);
    assertEquals(42, injector.resolve(dependency(Integer.class)).intValue());
}
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