Search in sources :

Example 1 with WebSocketEndpointFactory

use of io.joynr.messaging.websocket.WebSocketEndpointFactory in project joynr by bmwcarit.

the class WebSocketProviderProxyEnd2EndTest method testWebsocketReconnect.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void testWebsocketReconnect() throws InterruptedException {
    int result;
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    // Test rpc before connection is lost
    result = proxy.addNumbers(6, 3, 2);
    assertEquals(11, result);
    // simulate losing connection
    WebSocketEndpointFactory ccWebSocketServerFactory = injectorCC.getInstance(WebSocketEndpointFactory.class);
    WebSocketAddress serverAddress = injectorCC.getInstance(Key.get(WebSocketAddress.class, Names.named(WebsocketModule.WEBSOCKET_SERVER_ADDRESS)));
    JoynrWebSocketEndpoint ccWebSocketServer = ccWebSocketServerFactory.create(serverAddress);
    ccWebSocketServer.shutdown();
    Thread.sleep(1000);
    ccWebSocketServer.start();
    Thread.sleep(1000);
    result = proxy.addNumbers(7, 8, 1);
    assertEquals(16, result);
}
Also used : WebSocketEndpointFactory(io.joynr.messaging.websocket.WebSocketEndpointFactory) WebSocketAddress(joynr.system.RoutingTypes.WebSocketAddress) joynr.tests.testProxy(joynr.tests.testProxy) JoynrWebSocketEndpoint(io.joynr.messaging.websocket.JoynrWebSocketEndpoint) JoynrWebSocketEndpoint(io.joynr.messaging.websocket.JoynrWebSocketEndpoint) Test(org.junit.Test)

Example 2 with WebSocketEndpointFactory

use of io.joynr.messaging.websocket.WebSocketEndpointFactory in project joynr by bmwcarit.

the class WebSocketTest method configure.

private void configure(int maxMessageSize, long reconnectDelay, long websocketIdleTimeout, Set<JoynrMessageProcessor> messageProcessor) {
    ObjectMapper objectMapper = new ObjectMapper();
    WebSocketEndpointFactory webSocketJettyServerFactory = new WebSocketJettyServerFactory(maxMessageSize, objectMapper);
    ccWebSocketMessagingSkeleton = new WebSocketMessagingSkeleton(serverAddress, webSocketJettyServerFactory, messageRouterMock, new WebSocketMessagingSkeleton.MainTransportFlagBearer(), messageProcessor);
    ownAddress = new WebSocketClientAddress(UUID.randomUUID().toString());
    webSocketJettyClientFactory = new WebSocketJettyClientFactory(ownAddress, maxMessageSize, reconnectDelay, websocketIdleTimeout, objectMapper);
    webSocketMessagingStub = new WebSocketMessagingStub(serverAddress, webSocketJettyClientFactory.create(serverAddress));
    libWebSocketMessagingSkeleton = new WebSocketMessagingSkeleton(serverAddress, webSocketJettyClientFactory, messageRouterMock, new WebSocketMessagingSkeleton.MainTransportFlagBearer(), messageProcessor);
    ccWebSocketMessagingSkeleton.init();
    libWebSocketMessagingSkeleton.init();
}
Also used : WebSocketEndpointFactory(io.joynr.messaging.websocket.WebSocketEndpointFactory) WebSocketJettyServerFactory(io.joynr.messaging.websocket.server.WebSocketJettyServerFactory) WebSocketJettyClientFactory(io.joynr.messaging.websocket.jetty.client.WebSocketJettyClientFactory) WebSocketMessagingStub(io.joynr.messaging.websocket.WebSocketMessagingStub) WebSocketClientAddress(joynr.system.RoutingTypes.WebSocketClientAddress) WebSocketMessagingSkeleton(io.joynr.messaging.websocket.WebSocketMessagingSkeleton) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

WebSocketEndpointFactory (io.joynr.messaging.websocket.WebSocketEndpointFactory)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JoynrWebSocketEndpoint (io.joynr.messaging.websocket.JoynrWebSocketEndpoint)1 WebSocketMessagingSkeleton (io.joynr.messaging.websocket.WebSocketMessagingSkeleton)1 WebSocketMessagingStub (io.joynr.messaging.websocket.WebSocketMessagingStub)1 WebSocketJettyClientFactory (io.joynr.messaging.websocket.jetty.client.WebSocketJettyClientFactory)1 WebSocketJettyServerFactory (io.joynr.messaging.websocket.server.WebSocketJettyServerFactory)1 WebSocketAddress (joynr.system.RoutingTypes.WebSocketAddress)1 WebSocketClientAddress (joynr.system.RoutingTypes.WebSocketClientAddress)1 joynr.tests.testProxy (joynr.tests.testProxy)1 Test (org.junit.Test)1