use of com.canoo.dp.impl.remoting.commands.CreateContextCommand in project dolphin-platform by canoo.
the class ClientContextImpl method connect.
@Override
public CompletableFuture<Void> connect() {
final CompletableFuture<Void> result = new CompletableFuture<>();
clientConnector.connect();
clientConfiguration.getBackgroundExecutor().execute(() -> {
dolphinCommandHandler.invokeDolphinCommand(new CreateContextCommand()).handle((Void aVoid, Throwable throwable) -> {
if (throwable != null) {
result.completeExceptionally(new ClientInitializationException("Can't call init action!", throwable));
} else {
}
result.complete(null);
return null;
});
});
return result;
}
use of com.canoo.dp.impl.remoting.commands.CreateContextCommand in project dolphin-platform by canoo.
the class TestDolphinPlatformHttpClientConnector method testBadResponse.
@Test(expectedExceptions = DolphinRemotingException.class)
public void testBadResponse() throws DolphinRemotingException, URISyntaxException {
PlatformClient.init(new HeadlessToolkit());
PlatformClient.getClientConfiguration().setHttpURLConnectionFactory(new HttpURLConnectionFactory() {
@Override
public HttpURLConnection create(URI url) throws IOException {
return new HttpURLConnection(url.toURL()) {
@Override
public void disconnect() {
}
@Override
public boolean usingProxy() {
return false;
}
@Override
public void connect() throws IOException {
}
@Override
public OutputStream getOutputStream() throws IOException {
return new ByteArrayOutputStream();
}
};
}
});
final ClientModelStore clientModelStore = new ClientModelStore(new DefaultModelSynchronizer(() -> null));
final DolphinPlatformHttpClientConnector connector = new DolphinPlatformHttpClientConnector(getDummyURL(), PlatformClient.getClientConfiguration(), clientModelStore, new JsonCodec(), new SimpleExceptionHandler(), new HttpClientImpl(new Gson(), PlatformClient.getClientConfiguration()));
final List<Command> commands = new ArrayList<>();
commands.add(new CreateContextCommand());
connector.transmit(commands);
}
Aggregations