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