use of org.apache.deltaspike.cdise.tck.control.LockedCDIImplementation in project deltaspike by apache.
the class ContainerCtrlTckTest method testShutdownWithInactiveContexts.
@Test
@LockedCDIImplementation(versions = { @LockedVersionRange(implementation = CdiImplementation.WELD11, versionRange = "[1.1.14,1.2)"), @LockedVersionRange(implementation = CdiImplementation.WELD20, versionRange = "[2.0.1.Final,2.1)") })
public void testShutdownWithInactiveContexts() {
CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
Assert.assertNotNull(cdiContainer);
cdiContainer.boot();
cdiContainer.getContextControl().startContexts();
// now do some random stuff
BeanManager beanManager = cdiContainer.getBeanManager();
Assert.assertNotNull(beanManager);
Set<Bean<?>> beans = beanManager.getBeans(CarRepair.class);
Bean<?> bean = beanManager.resolve(beans);
CarRepair carRepair = (CarRepair) beanManager.getReference(bean, CarRepair.class, beanManager.createCreationalContext(bean));
Assert.assertNotNull(carRepair);
Car car = carRepair.getCar();
Assert.assertNotNull(car);
Assert.assertNotNull(car.getUser());
carRepair.getCar().getUser().setName("tester");
Assert.assertEquals("tester", car.getUser().getName());
Assert.assertFalse(CarRepair.isPreDestroyCalled());
Assert.assertFalse(Car.isPreDestroyCalled());
Assert.assertFalse(TestUser.isPreDestroyCalled());
cdiContainer.getContextControl().stopContexts();
Assert.assertTrue(CarRepair.isPreDestroyCalled());
Assert.assertTrue(Car.isPreDestroyCalled());
Assert.assertTrue(TestUser.isPreDestroyCalled());
cdiContainer.shutdown();
}
Aggregations