Search in sources :

Example 1 with WebSocketAddress

use of joynr.system.RoutingTypes.WebSocketAddress 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 WebSocketAddress

use of joynr.system.RoutingTypes.WebSocketAddress in project joynr by bmwcarit.

the class WebSocketTest method init.

@Before
public void init() throws IOException {
    logger.debug("INIT WebsocketTest");
    port = ServletUtil.findFreePort();
    serverAddress = new WebSocketAddress(WebSocketProtocol.WS, "localhost", port, "/test");
    Mockito.doAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            logger.debug("message arrived: " + invocationOnMock.getArguments().toString());
            return null;
        }
    }).when(messageRouterMock).route(Mockito.any(ImmutableMessage.class));
    messageFactory = new MutableMessageFactory(new ObjectMapper(), new HashSet<JoynrMessageProcessor>());
}
Also used : MutableMessageFactory(io.joynr.dispatching.MutableMessageFactory) WebSocketAddress(joynr.system.RoutingTypes.WebSocketAddress) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ImmutableMessage(joynr.ImmutableMessage) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 3 with WebSocketAddress

use of joynr.system.RoutingTypes.WebSocketAddress in project joynr by bmwcarit.

the class LibJoynrMessageRouterTest method addMulticastReceiverForNotInProcessProvider.

@Test
public void addMulticastReceiverForNotInProcessProvider() {
    WebSocketAddress mockWebSocketAddress = mock(WebSocketAddress.class);
    final String multicastId = "multicastIdTest";
    final String subscriberParticipantId = "subscriberParticipantIdTest";
    final String providerParticipantId = "providerParticipantIdTest";
    when(routingTable.get(providerParticipantId)).thenReturn(mockWebSocketAddress);
    messageRouter.addMulticastReceiver(multicastId, subscriberParticipantId, providerParticipantId);
    Mockito.verify(messageRouterParent).addMulticastReceiver(Mockito.eq(multicastId), Mockito.eq(subscriberParticipantId), Mockito.eq(providerParticipantId));
}
Also used : WebSocketAddress(joynr.system.RoutingTypes.WebSocketAddress) Test(org.junit.Test)

Aggregations

WebSocketAddress (joynr.system.RoutingTypes.WebSocketAddress)3 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 MutableMessageFactory (io.joynr.dispatching.MutableMessageFactory)1 JoynrWebSocketEndpoint (io.joynr.messaging.websocket.JoynrWebSocketEndpoint)1 WebSocketEndpointFactory (io.joynr.messaging.websocket.WebSocketEndpointFactory)1 HashSet (java.util.HashSet)1 ImmutableMessage (joynr.ImmutableMessage)1 joynr.tests.testProxy (joynr.tests.testProxy)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1