}
@Test(dataProvider = "builders")
public void testUsingIn(LifecycleInjectorBuilder lifecycleInjectorBuilder)
{
Injector injector = lifecycleInjectorBuilder
.withModules
(
new Module()
{
@Override
public void configure(Binder binder)
{
binder.bind(LazySingletonObject.class).in(LazySingletonScope.get());
}
}
)
.createInjector();
Assert.assertEquals(LazySingletonObject.constructorCount.get(), 0);
Assert.assertEquals(LazySingletonObject.postConstructCount.get(), 0);
LazySingletonObject instance = injector.getInstance(LazySingletonObject.class);
Assert.assertEquals(LazySingletonObject.constructorCount.get(), 1);
Assert.assertEquals(LazySingletonObject.postConstructCount.get(), 1);
LazySingletonObject instance2 = injector.getInstance(LazySingletonObject.class);
Assert.assertEquals(LazySingletonObject.constructorCount.get(), 1);
Assert.assertEquals(LazySingletonObject.postConstructCount.get(), 1);
Assert.assertSame(instance, instance2);
}