Search in sources :

Example 1 with ParentTestBean

use of com.canoo.dolphin.integration.parentchild.ParentTestBean in project dolphin-platform by canoo.

the class ParentChildControllerTest method testPreChildDestroyedNotCalledWhenNonChildControllerDestroyed.

@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test if @PreChildDestroyed is not called in controller")
public void testPreChildDestroyedNotCalledWhenNonChildControllerDestroyed(final String containerType, final String endpoint) {
    try {
        ClientContext context = connect(endpoint);
        ControllerProxy<ParentTestBean> controller = createController(context, PARENT_CONTROLLER_NAME);
        ControllerProxy<?> childController = controller.createController(DUMMY_CHILD_CONTROLLER_NAME).get();
        Property<Boolean> preDestroyProperty = controller.getModel().preChildDestroyedCalledProperty();
        Assert.assertNull(preDestroyProperty.get());
        childController.destroy();
        Assert.assertNull(preDestroyProperty.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) Test(org.testng.annotations.Test)

Example 2 with ParentTestBean

use of com.canoo.dolphin.integration.parentchild.ParentTestBean 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)

Example 3 with ParentTestBean

use of com.canoo.dolphin.integration.parentchild.ParentTestBean in project dolphin-platform by canoo.

the class ParentChildControllerTest method testPostChildCreatedCalledWhenChildControllerCreated.

@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test if @PostChildCreated is called in controller")
public void testPostChildCreatedCalledWhenChildControllerCreated(final String containerType, final String endpoint) {
    try {
        ClientContext context = connect(endpoint);
        ControllerProxy<ParentTestBean> controller = createController(context, PARENT_CONTROLLER_NAME);
        Assert.assertTrue(controller.getModel().postCreatedCalledProperty().get());
        Property<Boolean> postChildCreatedProperty = controller.getModel().postChildCreatedCalledProperty();
        Assert.assertNull(postChildCreatedProperty.get());
        controller.createController(CHILD_CONTROLLER_NAME);
        Thread.sleep(2000);
        Assert.assertTrue(postChildCreatedProperty.get());
        destroy(controller, endpoint);
        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) Test(org.testng.annotations.Test)

Example 4 with ParentTestBean

use of com.canoo.dolphin.integration.parentchild.ParentTestBean in project dolphin-platform by canoo.

the class ParentChildControllerTest method testPreChildDestroyedCalledWhenChildControllerDestroyed.

@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test if @PreChildDestroyed is called in controller")
public void testPreChildDestroyedCalledWhenChildControllerDestroyed(final String containerType, final String endpoint) {
    try {
        ClientContext context = connect(endpoint);
        ControllerProxy<ParentTestBean> controller = createController(context, PARENT_CONTROLLER_NAME);
        controller.createController(CHILD_CONTROLLER_NAME);
        Property<Boolean> preChildDestroyProperty = controller.getModel().preChildDestroyedCalledProperty();
        Assert.assertNull(preChildDestroyProperty.get());
        destroy(controller, endpoint);
        Assert.assertTrue(preChildDestroyProperty.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) Test(org.testng.annotations.Test)

Example 5 with ParentTestBean

use of com.canoo.dolphin.integration.parentchild.ParentTestBean in project dolphin-platform by canoo.

the class ParentChildControllerTest method testCreateController.

@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test if controller and model can be created")
public void testCreateController(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();
        Assert.assertNotNull(controller);
        Assert.assertNotNull(controller.getModel());
        Assert.assertEquals(controller.getModel().getClass(), ParentTestBean.class);
        Assert.assertEquals(childController.getModel().getClass(), ChildTestBean.class);
        destroy(controller, endpoint);
        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) Test(org.testng.annotations.Test)

Aggregations

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