use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldEncodeStandardCodecCommandAndCustomCodecCommand.
@Test
public void shouldEncodeStandardCodecCommandAndCustomCodecCommand() {
final Command standardCodecCommand = createCommand();
final Command customCodecCommand = createCPMCommand();
final String actual = OptimizedJsonCodec.getInstance().encode(Arrays.asList(standardCodecCommand, customCodecCommand));
final String standardCodecCommandString = createCommandJsonString();
final String customCodecCommandString = createCPMCommandString();
assertThat(actual, is("[" + standardCodecCommandString + "," + customCodecCommandString + "]"));
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class TestDolphinContext method handle.
@Override
public List<Command> handle(final List<Command> commands) {
final List<Command> commandsWithFackedLongPool = new ArrayList<>(commands);
commandsWithFackedLongPool.add(new StartLongPollCommand());
return super.handle(commandsWithFackedLongPool);
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class ClientConnectorTests method testHandle_DeletePresentationModel.
@Test
public void testHandle_DeletePresentationModel() {
ClientPresentationModel p1 = clientModelStore.createModel("p1", null);
p1.setClientSideOnly(true);
ClientPresentationModel p2 = clientModelStore.createModel("p2", null);
clientConnector.dispatchHandle(new DeletePresentationModelCommand(null));
ClientPresentationModel model = new ClientPresentationModel("p3", Collections.<ClientAttribute>emptyList());
clientConnector.dispatchHandle(new DeletePresentationModelCommand(model.getId()));
clientConnector.dispatchHandle(new DeletePresentationModelCommand(p1.getId()));
clientConnector.dispatchHandle(new DeletePresentationModelCommand(p2.getId()));
Assert.assertNull(clientModelStore.findPresentationModelById(p1.getId()));
Assert.assertNull(clientModelStore.findPresentationModelById(p2.getId()));
syncAndWaitUntilDone();
// 3 commands will have been transferred:
// 1: delete of p1 (causes no DeletedPresentationModelNotification since client side only)
// 2: delete of p2
// 3: DeletedPresentationModelNotification caused by delete of p2
assertCommandsTransmitted(4);
int deletedPresentationModelNotificationCount = 0;
for (Command c : clientConnector.getTransmittedCommands()) {
if (c instanceof PresentationModelDeletedCommand) {
deletedPresentationModelNotificationCount = deletedPresentationModelNotificationCount + 1;
}
}
Assert.assertEquals(1, deletedPresentationModelNotificationCount);
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class AbstractDolphinBasedTest method createDolphinTestConfiguration.
protected DolphinTestConfiguration createDolphinTestConfiguration() {
DefaultInMemoryConfig config = new DefaultInMemoryConfig(DirectExecutor.getInstance());
config.getServerConnector().registerDefaultActions();
ServerModelStore store = config.getServerModelStore();
store.setCurrentResponse(new ArrayList<Command>());
return new DolphinTestConfiguration(config.getClientModelStore(), config.getServerModelStore(), config.getClientConnector(), config.getServerConnector());
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command 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