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);
}
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);
}
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);
}
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));
}
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);
}
}
Aggregations