Search in sources :

Example 1 with JoynrWaitExpiredException

use of io.joynr.exceptions.JoynrWaitExpiredException in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method asyncMethodCallWithTtlExpiring.

@Ignore
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void asyncMethodCallWithTtlExpiring() throws DiscoveryException, JoynrIllegalStateException, InterruptedException, ApplicationException {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    long ttl = 2000L;
    MessagingQos testMessagingQos = new MessagingQos(ttl);
    DiscoveryQos testDiscoveryQos = new DiscoveryQos(30000, ArbitrationStrategy.HighestPriority, Long.MAX_VALUE);
    testProxy proxyShortTll = proxyBuilder.setMessagingQos(testMessagingQos).setDiscoveryQos(testDiscoveryQos).build();
    // the provider waits ttl before responding, causing a ttl
    boolean timeoutExceptionThrown = false;
    // the ttl parameter tells the provider to wait this long before
    // replying, thereby forcing a ttl exception
    Future<String> waitTooLongFuture = proxyShortTll.waitTooLong(callback, ttl * 2);
    try {
        // should never have to wait
        waitTooLongFuture.get(10 * ttl);
    // this long
    // the JoynWaitExpiredException should not be thrown.
    } catch (JoynrWaitExpiredException e) {
        timeoutExceptionThrown = false;
    } catch (JoynrTimeoutException e) {
        timeoutExceptionThrown = true;
    }
    assertEquals(true, timeoutExceptionThrown);
    assertEquals(RequestStatusCode.ERROR, waitTooLongFuture.getStatus().getCode());
    verify(callback).onFailure(any(JoynrRuntimeException.class));
    verifyNoMoreInteractions(callback);
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) JoynrTimeoutException(io.joynr.exceptions.JoynrTimeoutException) joynr.tests.testProxy(joynr.tests.testProxy) JoynrWaitExpiredException(io.joynr.exceptions.JoynrWaitExpiredException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with JoynrWaitExpiredException

use of io.joynr.exceptions.JoynrWaitExpiredException in project joynr by bmwcarit.

the class SerializationTest method serializeReplyWithJoynrWaitExpiredException.

@Test
public void serializeReplyWithJoynrWaitExpiredException() throws IOException {
    JoynrWaitExpiredException error = new JoynrWaitExpiredException();
    Reply reply = new Reply(UUID.randomUUID().toString(), error);
    String writeValueAsString = objectMapper.writeValueAsString(reply);
    Reply receivedReply = objectMapper.readValue(writeValueAsString, Reply.class);
    Assert.assertEquals(reply, receivedReply);
}
Also used : JoynrWaitExpiredException(io.joynr.exceptions.JoynrWaitExpiredException) Reply(joynr.Reply) Test(org.junit.Test)

Aggregations

JoynrWaitExpiredException (io.joynr.exceptions.JoynrWaitExpiredException)2 Test (org.junit.Test)2 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)1 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 JoynrTimeoutException (io.joynr.exceptions.JoynrTimeoutException)1 MessagingQos (io.joynr.messaging.MessagingQos)1 Reply (joynr.Reply)1 joynr.tests.testProxy (joynr.tests.testProxy)1 Ignore (org.junit.Ignore)1