use of com.canoo.dolphin.integration.parentchild.ChildTestBean in project dolphin-platform by canoo.
the class ParentChildControllerTest method testPreDestroyInParentIsCalledFirstWhenParentIsDestroyed.
@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test if @PreDestroyed in parent is called first")
public void testPreDestroyInParentIsCalledFirstWhenParentIsDestroyed(final String containerType, final String endpoint) {
try {
ClientContext context = connect(endpoint);
ControllerProxy<ParentTestBean> controller = createController(context, PARENT_CONTROLLER_NAME);
ControllerProxy<?> childController = controller.createController(CHILD_CONTROLLER_NAME).get();
Property<Boolean> childPreDestroyCalledProperty = ((ChildTestBean) childController.getModel()).preDestroyedCalledProperty();
Property<Boolean> parentPreDestroyCalledProperty = controller.getModel().preDestroyedCalledProperty();
Assert.assertNull(parentPreDestroyCalledProperty.get());
Assert.assertNull(childPreDestroyCalledProperty.get());
destroy(controller, endpoint);
Assert.assertTrue(parentPreDestroyCalledProperty.get());
Assert.assertTrue(childPreDestroyCalledProperty.get());
disconnect(context, endpoint);
} catch (Exception e) {
Assert.fail("Can not create controller for " + containerType, e);
}
}
Aggregations