Search in sources :

Example 1 with ChildTestBean

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);
    }
}
Also used : ClientContext(com.canoo.platform.remoting.client.ClientContext) ParentTestBean(com.canoo.dolphin.integration.parentchild.ParentTestBean) ChildTestBean(com.canoo.dolphin.integration.parentchild.ChildTestBean) Test(org.testng.annotations.Test)

Aggregations

ChildTestBean (com.canoo.dolphin.integration.parentchild.ChildTestBean)1 ParentTestBean (com.canoo.dolphin.integration.parentchild.ParentTestBean)1 ClientContext (com.canoo.platform.remoting.client.ClientContext)1 Test (org.testng.annotations.Test)1