Search in sources :

Example 51 with ClientContext

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

the class QualifierControllerTest method testQualifierRebind.

@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test Qualifier Rebind")
public void testQualifierRebind(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:
        invoke(controller, UNBIND_ACTION, containerType);
        setSubBeanValue(qualifierTestSubBeanTwo, 42, true, "Test1");
        invoke(controller, BIND_ACTION, containerType);
        // then:
        assertSubBeanValue(qualifierTestSubBeanOne, null, null, null);
        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 52 with ClientContext

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

the class QualifierControllerTest method testQualifierChangeAfterRebind.

@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test Qualifier Change After Rebind")
public void testQualifierChangeAfterRebind(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:
        invoke(controller, UNBIND_ACTION, containerType);
        setSubBeanValue(qualifierTestSubBeanOne, 42, true, "Test1");
        invoke(controller, BIND_ACTION, containerType);
        setSubBeanValue(qualifierTestSubBeanTwo, 44, false, "Test2");
        // then:
        assertSubBeanValue(qualifierTestSubBeanOne, 44, false, "Test2");
        assertSubBeanValue(qualifierTestSubBeanTwo, 44, false, "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 53 with ClientContext

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

the class ClientContextFactoryImpl method create.

/**
 * Create a {@link ClientContext} based on the given configuration. This method doesn't block and returns a
 * {@link CompletableFuture} to receive its result. If the {@link ClientContext} can't be created the
 * {@link CompletableFuture#get()} will throw a {@link ClientInitializationException}.
 *
 * @param clientConfiguration the configuration
 * @return the future
 */
public ClientContext create(final ClientConfiguration clientConfiguration, final URI endpoint) {
    Assert.requireNonNull(clientConfiguration, "clientConfiguration");
    final HttpClient httpClient = PlatformClient.getService(HttpClient.class);
    final HttpURLConnectionHandler clientSessionCheckResponseHandler = new StrictClientSessionResponseHandler(endpoint);
    httpClient.addResponseHandler(clientSessionCheckResponseHandler);
    final Function<ClientModelStore, AbstractClientConnector> connectionProvider = s -> {
        return new DolphinPlatformHttpClientConnector(endpoint, clientConfiguration, s, OptimizedJsonCodec.getInstance(), e -> {
        }, httpClient);
    };
    return new ClientContextImpl(clientConfiguration, endpoint, connectionProvider, PlatformClient.getService(ClientSessionStore.class));
}
Also used : ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) Assert(com.canoo.dp.impl.platform.core.Assert) ClientContextFactory(com.canoo.platform.remoting.client.ClientContextFactory) HttpClient(com.canoo.platform.core.http.HttpClient) AbstractClientConnector(com.canoo.dp.impl.client.legacy.communication.AbstractClientConnector) CompletableFuture(java.util.concurrent.CompletableFuture) API(org.apiguardian.api.API) ClientContext(com.canoo.platform.remoting.client.ClientContext) ClientInitializationException(com.canoo.platform.remoting.client.ClientInitializationException) Function(java.util.function.Function) INTERNAL(org.apiguardian.api.API.Status.INTERNAL) PlatformClient(com.canoo.platform.client.PlatformClient) HttpURLConnectionHandler(com.canoo.platform.core.http.HttpURLConnectionHandler) StrictClientSessionResponseHandler(com.canoo.dp.impl.platform.client.session.StrictClientSessionResponseHandler) URI(java.net.URI) ClientSessionStore(com.canoo.platform.client.session.ClientSessionStore) OptimizedJsonCodec(com.canoo.dp.impl.remoting.codec.OptimizedJsonCodec) ClientConfiguration(com.canoo.platform.client.ClientConfiguration) StrictClientSessionResponseHandler(com.canoo.dp.impl.platform.client.session.StrictClientSessionResponseHandler) ClientSessionStore(com.canoo.platform.client.session.ClientSessionStore) HttpClient(com.canoo.platform.core.http.HttpClient) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) HttpURLConnectionHandler(com.canoo.platform.core.http.HttpURLConnectionHandler) AbstractClientConnector(com.canoo.dp.impl.client.legacy.communication.AbstractClientConnector)

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