Search in sources :

Example 66 with JoynrRuntimeException

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

the class SerializationTest method serializePublicationWithJoynrRuntimeException.

@Test
public void serializePublicationWithJoynrRuntimeException() throws JsonGenerationException, JsonMappingException, IOException {
    JoynrRuntimeException error = new JoynrRuntimeException("detail message: JoynrRuntimeException");
    String subscriptionId = "12345";
    SubscriptionPublication publication = new SubscriptionPublication(error, subscriptionId);
    String writeValueAsString = objectMapper.writeValueAsString(publication);
    SubscriptionPublication receivedPublication = objectMapper.readValue(writeValueAsString, SubscriptionPublication.class);
    Assert.assertEquals(publication, receivedPublication);
}
Also used : SubscriptionPublication(joynr.SubscriptionPublication) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 67 with JoynrRuntimeException

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

the class SerializationTest method serializeReplyWithJoynrRuntimeExceptionWithCause.

@Test
public void serializeReplyWithJoynrRuntimeExceptionWithCause() throws IOException {
    JoynrRuntimeException error = new JoynrRuntimeException("detail message: JoynrRuntimeExceptionWithCause", new IOException("cause message"));
    System.out.println("error: " + error);
    System.out.println("cause: " + ((Throwable) error).getCause());
    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 : Reply(joynr.Reply) IOException(java.io.IOException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 68 with JoynrRuntimeException

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

the class SerializationTest method serializeReplyWithJoynrRuntimeExceptionWithoutMessage.

@Test
public void serializeReplyWithJoynrRuntimeExceptionWithoutMessage() throws IOException {
    JoynrRuntimeException error = new JoynrRuntimeException();
    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 : Reply(joynr.Reply) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 69 with JoynrRuntimeException

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

the class AbstractBroadcastEnd2EndTest method subscribeAndUnsubscribeFromBroadcast.

@Ignore
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void subscribeAndUnsubscribeFromBroadcast() throws InterruptedException {
    final Semaphore broadcastReceived = new Semaphore(0);
    Future<String> subscriptionId = proxy.subscribeToLocationUpdateWithSpeedBroadcast(new testBroadcastInterface.LocationUpdateWithSpeedBroadcastAdapter() {

        @Override
        public void onReceive(GpsLocation location, Float speed) {
            assertEquals(expectedLocation, location);
            assertEquals(expectedSpeed, speed);
            broadcastReceived.release();
        }
    }, new MulticastSubscriptionQos());
    Thread.sleep(300);
    provider.fireLocationUpdateWithSpeed(expectedLocation, expectedSpeed);
    broadcastReceived.acquire();
    // unsubscribe correct subscription -> now, no more broadcast shall be received
    proxy.unsubscribeFromLocationUpdateWithSpeedBroadcast(UUID.randomUUID().toString());
    provider.fireLocationUpdateWithSpeed(expectedLocation, expectedSpeed);
    broadcastReceived.acquire();
    // unsubscribe correct subscription -> now, no more broadcast shall be received
    try {
        proxy.unsubscribeFromLocationUpdateWithSpeedBroadcast(subscriptionId.get());
    } catch (JoynrRuntimeException | ApplicationException e) {
        logger.error(e.getMessage());
    }
    Thread.sleep(300);
    provider.fireLocationUpdateWithSpeed(expectedLocation, expectedSpeed);
    assertFalse(broadcastReceived.tryAcquire(300, TimeUnit.MILLISECONDS));
}
Also used : ApplicationException(joynr.exceptions.ApplicationException) GpsLocation(joynr.types.Localisation.GpsLocation) Semaphore(java.util.concurrent.Semaphore) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) joynr.tests.testBroadcastInterface(joynr.tests.testBroadcastInterface) MulticastSubscriptionQos(joynr.MulticastSubscriptionQos) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 70 with JoynrRuntimeException

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

the class InvocationReflectionsUtils method extractOutParameterTypes.

static Class<?>[] extractOutParameterTypes(SubscriptionListener listener) {
    try {
        List<Method> onReceiveMethods = ReflectionUtils.findMethodsByName(listener.getClass(), "onReceive");
        if (onReceiveMethods.size() != 1) {
            throw new IllegalArgumentException("listener must implement a single onReceive method");
        }
        Method onReceiveListenerMethod = onReceiveMethods.get(0);
        Class<?>[] outParameterTypes = onReceiveListenerMethod.getParameterTypes();
        return outParameterTypes;
    } catch (NoSuchMethodException e) {
        String message = String.format("Unable to find \"onReceive\" method on subscription listener object of type \"%s\".", listener.getClass().getName());
        throw new JoynrRuntimeException(message, e);
    }
}
Also used : Method(java.lang.reflect.Method) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException)

Aggregations

JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)76 Test (org.junit.Test)41 ApplicationException (joynr.exceptions.ApplicationException)18 joynr.tests.testProxy (joynr.tests.testProxy)16 MessagingQos (io.joynr.messaging.MessagingQos)14 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)13 Callback (io.joynr.proxy.Callback)9 Future (io.joynr.proxy.Future)9 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)9 IOException (java.io.IOException)8 Semaphore (java.util.concurrent.Semaphore)8 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)8 InvocationOnMock (org.mockito.invocation.InvocationOnMock)8 DiscoveryException (io.joynr.exceptions.DiscoveryException)7 JoynrException (io.joynr.exceptions.JoynrException)7 DeferredVoid (io.joynr.provider.DeferredVoid)7 HashSet (java.util.HashSet)7 ProviderQos (joynr.types.ProviderQos)7 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)5 ProxyCreatedCallback (io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback)5