use of se.jbee.inject.Injector in project silk by jbee.
the class TestMockingBinds method methodsOfMocksByDefaultReturnMocksIfPossible.
@Test
public void methodsOfMocksByDefaultReturnMocksIfPossible() {
Injector injector = Bootstrap.injector(TestMockingBindsModule.class);
Shape shape = injector.resolve(dependency(Shape.class));
PathIterator iter = shape.getPathIterator(null);
assertNotNull(iter);
assertTrue(isProxyClass(iter.getClass()));
assertFalse(iter.isDone());
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestMockingBinds method bindsCanBeUsedToMockReturnValuesOfMockMethods.
@Test
public void bindsCanBeUsedToMockReturnValuesOfMockMethods() {
Injector injector = Bootstrap.injector(TestMockingBindsModule.class);
Shape shape = injector.resolve(dependency(Shape.class));
Rectangle bounds = shape.getBounds();
assertNotNull(bounds);
assertTrue(shape instanceof Mock);
Mock mock = (Mock) shape;
assertEquals(1, mock.timesInvoked());
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestMockingBinds method moreSpecificUpperBoundTypesAreMorePrecise.
@Test
public void moreSpecificUpperBoundTypesAreMorePrecise() {
Injector injector = Bootstrap.injector(TestMockingBindsModule.class);
MouseListener mock = injector.resolve(dependency(MouseListener.class));
assertTrue(isProxyClass(mock.getClass()));
assertEquals(EventListener.class.getCanonicalName(), mock.toString());
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestServiceBinds method servicesAreResolvable.
@Test
public void servicesAreResolvable() {
Injector injector = Bootstrap.injector(ServiceBindsModule.class);
@SuppressWarnings({ "rawtypes" }) Dependency<Service> dependency = dependency(raw(Service.class).parametized(Integer.class, Long.class));
@SuppressWarnings("unchecked") Service<Integer, Long> square = injector.resolve(dependency);
assertEquals(4L, square.calc(2).longValue());
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestBootstrapper method thatCustomInspectorIsUsedToPickConstructor.
@Test
public void thatCustomInspectorIsUsedToPickConstructor() {
Injector injector = Bootstrap.injector(CustomInspectedBundle.class);
assertEquals("will be passed to D", injector.resolve(dependency(D.class)).s);
}
Aggregations