Search in sources :

Example 11 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class ProxyTest method createProxyWithMessageQosTtlEqualMaxTtlIsOk.

@Test
public void createProxyWithMessageQosTtlEqualMaxTtlIsOk() throws Exception {
    ProxyBuilderDefaultImpl<TestInterface> proxyBuilder = getProxyBuilder(TestInterface.class);
    MessagingQos messagingQosTtlTooLarge = new MessagingQos(MAX_TTL_MS);
    proxyBuilder.setMessagingQos(messagingQosTtlTooLarge).setDiscoveryQos(discoveryQos).build();
    assertTrue(proxyBuilder.messagingQos.getRoundTripTtl_ms() == MAX_TTL_MS);
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) Test(org.junit.Test)

Example 12 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class ProxyTest method createProxyWithMessageQosLargerThanMaxTtlUsesMax.

@Test
public void createProxyWithMessageQosLargerThanMaxTtlUsesMax() throws Exception {
    ProxyBuilderDefaultImpl<TestInterface> proxyBuilder = getProxyBuilder(TestInterface.class);
    MessagingQos messagingQosTtlTooLarge = new MessagingQos(MAX_TTL_MS + 1);
    proxyBuilder.setMessagingQos(messagingQosTtlTooLarge).setDiscoveryQos(discoveryQos).build();
    assertTrue(proxyBuilder.messagingQos.getRoundTripTtl_ms() == MAX_TTL_MS);
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) Test(org.junit.Test)

Example 13 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class ProxyTest method createProxyWithMessageQosTtlSmallerThanMaxTtlIsNotModified.

@Test
public void createProxyWithMessageQosTtlSmallerThanMaxTtlIsNotModified() throws Exception {
    ProxyBuilderDefaultImpl<TestInterface> proxyBuilder = getProxyBuilder(TestInterface.class);
    long messageTtl = 5000;
    MessagingQos messagingQosTtlTooLarge = new MessagingQos(messageTtl);
    proxyBuilder.setMessagingQos(messagingQosTtlTooLarge).setDiscoveryQos(discoveryQos).build();
    assertTrue(proxyBuilder.messagingQos.getRoundTripTtl_ms() == messageTtl);
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) Test(org.junit.Test)

Example 14 with MessagingQos

use of io.joynr.messaging.MessagingQos 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 15 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class TtlUpliftTest method setUp.

@Before
public void setUp() throws NoSuchMethodException, SecurityException {
    fromParticipantId = "sender";
    toParticipantId = "receiver";
    cleanupScheduler = new ScheduledThreadPoolExecutor(1);
    cleanupSchedulerSpy = Mockito.spy(cleanupScheduler);
    Module defaultModule = Modules.override(new JoynrPropertiesModule(new Properties())).with(new JsonMessageSerializerModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_TTL_UPLIFT_MS)).toInstance(NO_TTL_UPLIFT);
            requestStaticInjection(Request.class);
            Multibinder<JoynrMessageProcessor> joynrMessageProcessorMultibinder = Multibinder.newSetBinder(binder(), new TypeLiteral<JoynrMessageProcessor>() {
            });
            joynrMessageProcessorMultibinder.addBinding().toInstance(new JoynrMessageProcessor() {

                @Override
                public MutableMessage processOutgoing(MutableMessage joynrMessage) {
                    return joynrMessage;
                }

                @Override
                public ImmutableMessage processIncoming(ImmutableMessage joynrMessage) {
                    return joynrMessage;
                }
            });
            bind(PublicationManager.class).to(PublicationManagerImpl.class);
            bind(SubscriptionRequestStorage.class).toInstance(Mockito.mock(FileSubscriptionRequestStorage.class));
            bind(AttributePollInterpreter.class).toInstance(attributePollInterpreter);
            bind(Dispatcher.class).toInstance(dispatcher);
            bind(ProviderDirectory.class).toInstance(providerDirectory);
            bind(ScheduledExecutorService.class).annotatedWith(Names.named(JoynrInjectionConstants.JOYNR_SCHEDULER_CLEANUP)).toInstance(cleanupSchedulerSpy);
        }
    });
    Injector injector = Guice.createInjector(defaultModule);
    messageFactory = injector.getInstance(MutableMessageFactory.class);
    Module ttlUpliftModule = Modules.override(defaultModule).with(new AbstractModule() {

        @Override
        protected void configure() {
            bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_TTL_UPLIFT_MS)).toInstance(TTL_UPLIFT_MS);
        }
    });
    Injector injectorWithTtlUplift = Guice.createInjector(ttlUpliftModule);
    messageFactoryWithTtlUplift = injectorWithTtlUplift.getInstance(MutableMessageFactory.class);
    requestCaller = new RequestCallerFactory().create(provider);
    when(providerContainer.getProviderProxy()).thenReturn(requestCaller.getProxy());
    when(providerContainer.getSubscriptionPublisher()).thenReturn(subscriptionPublisher);
    Deferred<String> valueToPublishDeferred = new Deferred<String>();
    valueToPublishDeferred.resolve(valueToPublish);
    Promise<Deferred<String>> valueToPublishPromise = new Promise<Deferred<String>>(valueToPublishDeferred);
    doReturn(valueToPublishPromise).when(attributePollInterpreter).execute(any(ProviderContainer.class), any(Method.class));
    Module subcriptionUpliftModule = Modules.override(defaultModule).with(new AbstractModule() {

        @Override
        protected void configure() {
            bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_TTL_UPLIFT_MS)).toInstance(SUBSCRIPTION_UPLIFT_MS);
        }
    });
    Injector injectorWithPublicationUplift = Guice.createInjector(subcriptionUpliftModule);
    publicationManager = (PublicationManagerImpl) injector.getInstance(PublicationManager.class);
    publicationManagerWithTtlUplift = (PublicationManagerImpl) injectorWithPublicationUplift.getInstance(PublicationManager.class);
    payload = "payload";
    Method method = TestProvider.class.getMethod("methodWithStrings", new Class[] { String.class });
    request = new Request(method.getName(), new String[] { payload }, method.getParameterTypes());
    messagingQos = new MessagingQos(TTL);
    expiryDate = DispatcherUtils.convertTtlToExpirationDate(messagingQos.getRoundTripTtl_ms());
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Deferred(io.joynr.provider.Deferred) JoynrMessageProcessor(io.joynr.messaging.JoynrMessageProcessor) Properties(java.util.Properties) MessagingQos(io.joynr.messaging.MessagingQos) TypeLiteral(com.google.inject.TypeLiteral) MutableMessage(joynr.MutableMessage) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) Injector(com.google.inject.Injector) PublicationManagerImpl(io.joynr.dispatching.subscription.PublicationManagerImpl) ProviderContainer(io.joynr.provider.ProviderContainer) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Multibinder(com.google.inject.multibindings.Multibinder) JsonMessageSerializerModule(io.joynr.messaging.JsonMessageSerializerModule) SubscriptionRequest(joynr.SubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) Request(joynr.Request) Method(java.lang.reflect.Method) AbstractModule(com.google.inject.AbstractModule) Promise(io.joynr.provider.Promise) ImmutableMessage(joynr.ImmutableMessage) Matchers.anyLong(org.mockito.Matchers.anyLong) Module(com.google.inject.Module) JsonMessageSerializerModule(io.joynr.messaging.JsonMessageSerializerModule) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

Aggregations

MessagingQos (io.joynr.messaging.MessagingQos)55 Test (org.junit.Test)23 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)19 MutableMessage (joynr.MutableMessage)15 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)11 Matchers.anyString (org.mockito.Matchers.anyString)11 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)9 SubscriptionRequest (joynr.SubscriptionRequest)9 Before (org.junit.Before)8 Properties (java.util.Properties)6 ImmutableMessage (joynr.ImmutableMessage)6 Request (joynr.Request)6 Injector (com.google.inject.Injector)5 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)5 MulticastSubscriptionRequest (joynr.MulticastSubscriptionRequest)5 joynr.tests.testProxy (joynr.tests.testProxy)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 AbstractModule (com.google.inject.AbstractModule)4 IOException (java.io.IOException)4 OneWayRequest (joynr.OneWayRequest)4