use of se.jbee.inject.Injector in project silk by jbee.
the class TestLoggerBinds method thatEachClassGetsTheLoggerWithItsCanonicalName.
@Test
public void thatEachClassGetsTheLoggerWithItsCanonicalName() {
Injector injector = Bootstrap.injector(LoggerBindsBundle.class);
Foo foo = injector.resolve(dependency(Foo.class));
assertSame(Logger.getLogger(Foo.class.getCanonicalName()), foo.logger);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestMacroBinds method thatCustomInitialisationCanBeAdded.
@Test
public void thatCustomInitialisationCanBeAdded() {
Injector injector = injectorWithMacro(MacroBindsModule.class, new InitialisationMacro());
assertEquals("answer", injector.resolve(dependency(Bar.class)).s);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestMacroBinds method thatAllConstructorParameterTypesCanBeMadeRequired.
@Test(expected = NoResourceForDependency.class)
public void thatAllConstructorParameterTypesCanBeMadeRequired() {
Macro<?> required = new RequiredConstructorParametersMacro();
Injector injector = injectorWithMacro(MacroBindsModule.class, required);
assertNull("we should not get here", injector);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestMockingBinds method methodOfMocksByDefaultReturnNullOtherwise.
@Test
public void methodOfMocksByDefaultReturnNullOtherwise() {
// when no custom binding or mocking available
Injector injector = Bootstrap.injector(TestMockingBindsModule.class);
Shape shape = injector.resolve(dependency(Shape.class));
assertNull(shape.getBounds2D());
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestMockingBinds method wildcardBindsDoFallBackToMostGeneralIfRequired.
@Test
public void wildcardBindsDoFallBackToMostGeneralIfRequired() {
Injector injector = Bootstrap.injector(TestMockingBindsModule.class);
Serializable mock = injector.resolve(dependency(Serializable.class));
assertTrue(isProxyClass(mock.getClass()));
assertEquals(Object.class.getCanonicalName(), mock.toString());
}
Aggregations