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);
}
}
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);
}
}
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));
}
Aggregations