Search in sources :

Example 16 with Command

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 + "]"));
}
Also used : ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) CallActionCommand(com.canoo.dp.impl.remoting.commands.CallActionCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) CreatePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand) EmptyCommand(com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand) Test(org.testng.annotations.Test)

Example 17 with Command

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);
}
Also used : StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) ArrayList(java.util.ArrayList) StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand)

Example 18 with Command

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);
}
Also used : PresentationModelDeletedCommand(com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand) InterruptLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) CreatePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand) PresentationModelDeletedCommand(com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand) AttributeMetadataChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.AttributeMetadataChangedCommand) DeletePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.DeletePresentationModelCommand) EmptyCommand(com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand) ChangeAttributeMetadataCommand(com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) DeletePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.DeletePresentationModelCommand) Test(org.testng.annotations.Test)

Example 19 with Command

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());
}
Also used : Command(com.canoo.dp.impl.remoting.legacy.communication.Command) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore)

Example 20 with Command

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);
}
Also used : DolphinPlatformHttpClientConnector(com.canoo.dp.impl.client.DolphinPlatformHttpClientConnector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) DefaultModelSynchronizer(com.canoo.dp.impl.client.legacy.DefaultModelSynchronizer) IOException(java.io.IOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SimpleExceptionHandler(com.canoo.dp.impl.client.legacy.communication.SimpleExceptionHandler) CreateContextCommand(com.canoo.dp.impl.remoting.commands.CreateContextCommand) HttpURLConnectionFactory(com.canoo.platform.core.http.HttpURLConnectionFactory) JsonCodec(com.canoo.dp.impl.remoting.legacy.communication.JsonCodec) CreateContextCommand(com.canoo.dp.impl.remoting.commands.CreateContextCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) CreatePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand) HeadlessToolkit(com.canoo.platform.client.HeadlessToolkit) HttpClientImpl(com.canoo.dp.impl.platform.client.http.HttpClientImpl) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) Test(org.testng.annotations.Test)

Aggregations

Command (com.canoo.dp.impl.remoting.legacy.communication.Command)43 CreatePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand)25 ValueChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand)23 Test (org.testng.annotations.Test)22 EmptyCommand (com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand)19 CallActionCommand (com.canoo.dp.impl.remoting.commands.CallActionCommand)18 StartLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand)10 InterruptLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand)8 ChangeAttributeMetadataCommand (com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand)8 ArrayList (java.util.ArrayList)8 PresentationModelDeletedCommand (com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand)7 CreateContextCommand (com.canoo.dp.impl.remoting.commands.CreateContextCommand)5 LinkedList (java.util.LinkedList)5 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)4 ClientAttribute (com.canoo.dp.impl.client.legacy.ClientAttribute)3 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)3 DestroyContextCommand (com.canoo.dp.impl.remoting.commands.DestroyContextCommand)3 AttributeMetadataChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.AttributeMetadataChangedCommand)3 DeletePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.DeletePresentationModelCommand)3 CommandHandler (com.canoo.dp.impl.server.legacy.communication.CommandHandler)3