use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.
the class PromiseTest method addingNullListenerDoesNotThrow.
@Test
public void addingNullListenerDoesNotThrow() {
AbstractDeferred deferred = new AbstractDeferred() {
};
Promise<AbstractDeferred> promise = new Promise<AbstractDeferred>(deferred);
promise.then(null);
deferred.reject(new JoynrRuntimeException("test exception"));
}
use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.
the class PromiseTest method promiseNotifiesListenersOnRejection.
@Test
public void promiseNotifiesListenersOnRejection() {
AbstractDeferred deferred = new AbstractDeferred() {
};
Promise<AbstractDeferred> promise = new Promise<AbstractDeferred>(deferred);
PromiseListener listener = Mockito.mock(PromiseListener.class);
JoynrRuntimeException expectedError = new JoynrRuntimeException("test exception");
promise.then(listener);
Assert.assertFalse(promise.isSettled());
deferred.reject(expectedError);
Assert.assertTrue(promise.isRejected());
Mockito.verify(listener).onRejection(expectedError);
}
use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.
the class PromiseTest method promiseStateIsCorrectOnRejection.
@Test
public void promiseStateIsCorrectOnRejection() {
AbstractDeferred deferred = new AbstractDeferred() {
};
Promise<AbstractDeferred> promise = new Promise<AbstractDeferred>(deferred);
Assert.assertFalse(promise.isSettled());
Assert.assertFalse(promise.isRejected());
Assert.assertFalse(promise.isFulfilled());
deferred.reject(new JoynrRuntimeException());
Assert.assertTrue(promise.isSettled());
Assert.assertTrue(promise.isRejected());
Assert.assertFalse(promise.isFulfilled());
}
use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.
the class MqttMessagingSkeletonTest method testFailureActionCalledAfterExceptionFromMessageRouter.
@Test
public void testFailureActionCalledAfterExceptionFromMessageRouter() throws Exception {
ImmutableMessage rqMessage = createTestRequestMessage();
doThrow(new JoynrRuntimeException()).when(messageRouter).route(any(ImmutableMessage.class));
Semaphore semaphore = new Semaphore(0);
subject.transmit(rqMessage.getSerializedMessage(), getExpectToBeCalledAction(semaphore));
assertTrue(semaphore.tryAcquire());
}
use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.
the class RoutingTableImplTest method testGetIsGloballyVisible.
@Test
public void testGetIsGloballyVisible() {
String participantId = "participantId";
final boolean allowUpdate = false;
try {
// empty routing table
subject.getIsGloballyVisible(participantId);
fail("Expected exception was not thrown");
} catch (JoynrRuntimeException e) {
}
Address address = new Address();
final boolean isGloballyVisible = false;
final long expiryDateMs = Long.MAX_VALUE;
final boolean isSticky = false;
subject.put(participantId, address, isGloballyVisible, expiryDateMs, isSticky, allowUpdate);
assertEquals(false, subject.getIsGloballyVisible(participantId));
String participantId1 = "participantId1";
Address address1 = new Address();
final boolean isGloballyVisible1 = false;
final long expiryDateMs1 = Long.MAX_VALUE;
final boolean isSticky1 = false;
subject.put(participantId1, address1, isGloballyVisible1, expiryDateMs1, isSticky1, allowUpdate);
assertEquals(false, subject.getIsGloballyVisible(participantId1));
String participantId2 = "participantId2";
Address address2 = new Address();
final boolean isGloballyVisible2 = true;
final long expiryDateMs2 = Long.MAX_VALUE;
final boolean isSticky2 = false;
subject.put(participantId2, address2, isGloballyVisible2, expiryDateMs2, isSticky2, allowUpdate);
assertEquals(true, subject.getIsGloballyVisible(participantId2));
}
Aggregations