Search in sources :

Example 21 with ClientContext

use of com.canoo.platform.remoting.client.ClientContext in project dolphin-platform by canoo.

the class PropertyControllerTest method testCreateController.

@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test if controller and model can be created")
public void testCreateController(String containerType, String endpoint) {
    try {
        ClientContext context = connect(endpoint);
        ControllerProxy<PropertyTestBean> controller = createController(context, PROPERTY_CONTROLLER_NAME);
        Assert.assertNotNull(controller);
        Assert.assertNotNull(controller.getModel());
        Assert.assertEquals(controller.getModel().getClass(), PropertyTestBean.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) PropertyTestBean(com.canoo.dolphin.integration.property.PropertyTestBean) Test(org.testng.annotations.Test)

Example 22 with ClientContext

use of com.canoo.platform.remoting.client.ClientContext in project dolphin-platform by canoo.

the class QualifierControllerTest method testQualifier2.

@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test if QualifierTestSubBean is sync when updating QualifierTestSubBeanTwo")
public void testQualifier2(String containerType, String endpoint) {
    try {
        final ClientContext context = connect(endpoint);
        final ControllerProxy<QualifierTestBean> controller = createController(context, QUALIFIER_CONTROLLER_NAME);
        // given:
        final QualifierTestSubBean qualifierTestSubBeanOne = controller.getModel().getQualifierTestSubBeanOneValue();
        final QualifierTestSubBean qualifierTestSubBeanTwo = controller.getModel().getQualifierTestSubBeanTwoValue();
        // when:
        setSubBeanValue(qualifierTestSubBeanTwo, 44, true, "Test2");
        invoke(controller, DUMMY_ACTION, containerType);
        // then:
        assertSubBeanValue(qualifierTestSubBeanOne, 44, true, "Test2");
        assertSubBeanValue(qualifierTestSubBeanTwo, 44, true, "Test2");
        // Destroy and Disconnect Controller
        destroy(controller, endpoint);
        disconnect(context, endpoint);
    } catch (Exception e) {
        Assert.fail("Can not create controller for " + containerType, e);
    }
}
Also used : QualifierTestSubBean(com.canoo.dolphin.integration.qualifier.QualifierTestSubBean) ClientContext(com.canoo.platform.remoting.client.ClientContext) QualifierTestBean(com.canoo.dolphin.integration.qualifier.QualifierTestBean) Test(org.testng.annotations.Test)

Example 23 with ClientContext

use of com.canoo.platform.remoting.client.ClientContext in project dolphin-platform by canoo.

the class QualifierControllerTest method testQualifierUnbind.

@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test Qualifier Unbind")
public void testQualifierUnbind(String containerType, String endpoint) {
    try {
        final ClientContext context = connect(endpoint);
        final ControllerProxy<QualifierTestBean> controller = createController(context, QUALIFIER_CONTROLLER_NAME);
        // given:
        final QualifierTestSubBean qualifierTestSubBeanOne = controller.getModel().getQualifierTestSubBeanOneValue();
        final QualifierTestSubBean qualifierTestSubBeanTwo = controller.getModel().getQualifierTestSubBeanTwoValue();
        // when:
        setSubBeanValue(qualifierTestSubBeanOne, 42, true, "Test1");
        invoke(controller, UNBIND_ACTION, containerType);
        setSubBeanValue(qualifierTestSubBeanOne, 44, false, "Test2");
        // then:
        assertSubBeanValue(qualifierTestSubBeanOne, 44, false, "Test2");
        assertSubBeanValue(qualifierTestSubBeanTwo, 42, true, "Test1");
        // Destroy and Disconnect Controller
        destroy(controller, endpoint);
        disconnect(context, endpoint);
    } catch (Exception e) {
        Assert.fail("Can not create controller for " + containerType, e);
    }
}
Also used : QualifierTestSubBean(com.canoo.dolphin.integration.qualifier.QualifierTestSubBean) ClientContext(com.canoo.platform.remoting.client.ClientContext) QualifierTestBean(com.canoo.dolphin.integration.qualifier.QualifierTestBean) Test(org.testng.annotations.Test)

Example 24 with ClientContext

use of com.canoo.platform.remoting.client.ClientContext in project dolphin-platform-examples by canoo.

the class Client method showApp.

private void showApp(final Stage primaryStage) throws Exception {
    final ClientConfiguration clientConfiguration = PlatformClient.getClientConfiguration();
    final ClientContextFactory contextFactory = PlatformClient.getService(ClientContextFactory.class);
    final URI endpoint = new URI("http://localhost:8080/dolphin");
    final ClientContext clientContext = contextFactory.create(clientConfiguration, endpoint);
    clientContext.connect().handle((v, e) -> {
        final UserView view = new UserView(clientContext);
        Platform.runLater(() -> {
            primaryStage.setScene(new Scene(view.getParent()));
            primaryStage.show();
        });
        return null;
    });
}
Also used : ClientContext(com.canoo.platform.remoting.client.ClientContext) Scene(javafx.scene.Scene) ClientContextFactory(com.canoo.platform.remoting.client.ClientContextFactory) URI(java.net.URI) ClientConfiguration(com.canoo.platform.client.ClientConfiguration)

Example 25 with ClientContext

use of com.canoo.platform.remoting.client.ClientContext in project dolphin-platform by canoo.

the class AbstractIntegrationTest method connect.

protected ClientContext connect(String endpoint) {
    PlatformClient.init(new IntegrationTestToolkit());
    PlatformClient.getClientConfiguration().getCookieStore().removeAll();
    try {
        waitUntilServerIsUp(endpoint, bootTimeoutInMinutes, TimeUnit.MINUTES);
        ClientContext clientContext = PlatformClient.getService(ClientContextFactory.class).create(PlatformClient.getClientConfiguration(), new URI(endpoint + "/dolphin"));
        long timeOutTime = System.currentTimeMillis() + Duration.ofMinutes(timeoutInMinutes).toMillis();
        while (System.currentTimeMillis() < timeOutTime && clientContext.getClientId() == null) {
            try {
                clientContext.connect().get(10, TimeUnit.SECONDS);
            } catch (Exception ex) {
            // do nothing since server is not up at the moment...
            }
        }
        if (clientContext.getClientId() == null) {
            throw new Exception("Client context not created....");
        }
        return clientContext;
    } catch (Exception e) {
        throw new RuntimeException("Can not create client context for endpoint " + endpoint, e);
    }
}
Also used : ClientContext(com.canoo.platform.remoting.client.ClientContext) ClientContextFactory(com.canoo.platform.remoting.client.ClientContextFactory) URI(java.net.URI) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

ClientContext (com.canoo.platform.remoting.client.ClientContext)53 Test (org.testng.annotations.Test)37 ActionTestBean (com.canoo.dolphin.integration.action.ActionTestBean)22 PropertyTestBean (com.canoo.dolphin.integration.property.PropertyTestBean)8 ParentTestBean (com.canoo.dolphin.integration.parentchild.ParentTestBean)6 QualifierTestBean (com.canoo.dolphin.integration.qualifier.QualifierTestBean)6 QualifierTestSubBean (com.canoo.dolphin.integration.qualifier.QualifierTestSubBean)6 Param (com.canoo.platform.remoting.client.Param)5 ClientContextFactory (com.canoo.platform.remoting.client.ClientContextFactory)4 EnterpriseTestBean (com.canoo.dolphin.integration.enterprise.EnterpriseTestBean)3 URI (java.net.URI)3 ClientConfiguration (com.canoo.platform.client.ClientConfiguration)2 Scene (javafx.scene.Scene)2 BeanTestBean (com.canoo.dolphin.integration.bean.BeanTestBean)1 ChildTestBean (com.canoo.dolphin.integration.parentchild.ChildTestBean)1 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)1 AbstractClientConnector (com.canoo.dp.impl.client.legacy.communication.AbstractClientConnector)1 StrictClientSessionResponseHandler (com.canoo.dp.impl.platform.client.session.StrictClientSessionResponseHandler)1 Assert (com.canoo.dp.impl.platform.core.Assert)1 OptimizedJsonCodec (com.canoo.dp.impl.remoting.codec.OptimizedJsonCodec)1