Search in sources :

Example 51 with JoynrRuntimeException

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"));
}
Also used : JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 52 with JoynrRuntimeException

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);
}
Also used : JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 53 with JoynrRuntimeException

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());
}
Also used : JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 54 with JoynrRuntimeException

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());
}
Also used : ImmutableMessage(joynr.ImmutableMessage) Semaphore(java.util.concurrent.Semaphore) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 55 with JoynrRuntimeException

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));
}
Also used : Address(joynr.system.RoutingTypes.Address) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

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