Search in sources :

Example 36 with Injector

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

the class TestCommandBinds method thatServiceCanBeResolvedWhenHavingJustOneGeneric.

@SuppressWarnings("unchecked")
@Test
public void thatServiceCanBeResolvedWhenHavingJustOneGeneric() {
    Injector injector = Bootstrap.injector(CommandBindsModule.class);
    @SuppressWarnings("rawtypes") Dependency<Command> dependency = dependency(raw(Command.class).parametized(Integer.class));
    Command<Integer> square = injector.resolve(dependency);
    assertEquals(9L, square.calc(3).longValue());
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 37 with Injector

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

the class TestBootstrapper method thatBundlesAreNotBootstrappedMultipleTimesEvenWhenTheyAreMutual.

/**
	 * The assert itself doesn't play such huge role here. we just want to reach this code.
	 */
@Test(timeout = 50)
public void thatBundlesAreNotBootstrappedMultipleTimesEvenWhenTheyAreMutual() {
    Injector injector = Bootstrap.injector(OneMutualDependentBundle.class);
    assertNotNull(injector);
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 38 with Injector

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

the class TestBootstrapper method thatDependencyCyclesAreDetected.

@Test(expected = DependencyCycle.class, timeout = 50)
public void thatDependencyCyclesAreDetected() {
    Injector injector = Bootstrap.injector(CyclicBindsModule.class);
    Foo foo = injector.resolve(dependency(Foo.class));
    fail("foo should not be resolvable but was: " + foo);
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 39 with Injector

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

the class TestBootstrapper method thatDependencyCyclesInCirclesAreDetected.

@Test(expected = DependencyCycle.class, timeout = 50)
public void thatDependencyCyclesInCirclesAreDetected() {
    Injector injector = Bootstrap.injector(CircularBindsModule.class);
    A a = injector.resolve(dependency(A.class));
    fail("A should not be resolvable but was: " + a);
}
Also used : Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 40 with Injector

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

the class TestBootstrapper method thatEagerSingeltonsCanBeCreated.

@Test
public void thatEagerSingeltonsCanBeCreated() {
    Injector injector = Bootstrap.injector(EagerSingletonsBindsModule.class);
    int before = EagerSingletonsBindsModule.eagers;
    Bootstrap.eagerSingletons(injector);
    assertEquals(before + 1, EagerSingletonsBindsModule.eagers);
}
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