Search in sources :

Example 1 with NoOpRawMessagingPreprocessor

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

the class DefaultJoynrRuntimeFactoryTest method createFixture.

@SuppressWarnings("unchecked")
private void createFixture(Instance<Properties> joynrProperties, Instance<String> joynrLocalDomain) throws Exception {
    Instance<RawMessagingPreprocessor> rawMessageProcessor = mock(Instance.class);
    when(rawMessageProcessor.get()).thenReturn(new NoOpRawMessagingPreprocessor());
    BeanManager beanManager = mock(BeanManager.class);
    Bean<JoynrMessageProcessor> bean = mock(Bean.class);
    when(bean.create(Mockito.any())).thenReturn(new JoynrMessageProcessorTest());
    when(beanManager.getBeans(Mockito.<Type>eq(JoynrMessageProcessor.class), Mockito.<Annotation>any())).thenReturn(Sets.newHashSet(bean));
    final String mqttClientId = "someTestMqttClientId";
    MqttClientIdProvider mqttClientIdProvider = mock(MqttClientIdProvider.class);
    when(mqttClientIdProvider.getClientId()).thenReturn(mqttClientId);
    Instance<MqttClientIdProvider> mqttClientIdProviderInstance = mock(Instance.class);
    when(mqttClientIdProviderInstance.get()).thenReturn(mqttClientIdProvider);
    fixture = new DefaultJoynrRuntimeFactory(joynrProperties, joynrLocalDomain, rawMessageProcessor, mqttClientIdProviderInstance, beanManager, mock(StatusReceiver.class), mock(MqttStatusReceiver.class));
    scheduledExecutorService = mock(ScheduledExecutorService.class);
    Field executorField = DefaultJoynrRuntimeFactory.class.getDeclaredField("scheduledExecutorService");
    executorField.setAccessible(true);
    executorField.set(fixture, scheduledExecutorService);
}
Also used : NoOpRawMessagingPreprocessor(io.joynr.messaging.NoOpRawMessagingPreprocessor) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) MqttClientIdProvider(io.joynr.messaging.mqtt.MqttClientIdProvider) JoynrMessageProcessor(io.joynr.messaging.JoynrMessageProcessor) NoOpRawMessagingPreprocessor(io.joynr.messaging.NoOpRawMessagingPreprocessor) RawMessagingPreprocessor(io.joynr.messaging.RawMessagingPreprocessor) Field(java.lang.reflect.Field) DefaultJoynrRuntimeFactory(io.joynr.jeeintegration.DefaultJoynrRuntimeFactory) BeanManager(javax.enterprise.inject.spi.BeanManager)

Example 2 with NoOpRawMessagingPreprocessor

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

the class MqttMessagingSkeletonTest method testJoynrMessageProcessorIsCalled.

@Test
public void testJoynrMessageProcessorIsCalled() throws Exception {
    JoynrMessageProcessor processorMock = mock(JoynrMessageProcessor.class);
    when(processorMock.processIncoming(any(ImmutableMessage.class))).then(returnsFirstArg());
    subject = new MqttMessagingSkeleton(ownAddress, maxIncomingMqttRequests, messageRouter, mqttClientFactory, mqttTopicPrefixProvider, new NoOpRawMessagingPreprocessor(), Sets.newHashSet(processorMock), mqttStatusReceiver);
    ImmutableMessage rqMessage = createTestRequestMessage();
    subject.transmit(rqMessage.getSerializedMessage(), failIfCalledAction);
    ArgumentCaptor<ImmutableMessage> argCaptor = ArgumentCaptor.forClass(ImmutableMessage.class);
    verify(processorMock).processIncoming(argCaptor.capture());
    Assert.assertArrayEquals(rqMessage.getSerializedMessage(), argCaptor.getValue().getSerializedMessage());
}
Also used : NoOpRawMessagingPreprocessor(io.joynr.messaging.NoOpRawMessagingPreprocessor) ImmutableMessage(joynr.ImmutableMessage) JoynrMessageProcessor(io.joynr.messaging.JoynrMessageProcessor) Test(org.junit.Test)

Example 3 with NoOpRawMessagingPreprocessor

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

the class SharedSubscriptionsMqttMessagingSkeletonTest method createAndInitSkeleton.

private void createAndInitSkeleton(String channelId) {
    subject = new SharedSubscriptionsMqttMessagingSkeleton(ownAddress, maxMqttMessagesInQueue, backpressureEnabled, backpressureIncomingMqttRequestsUpperThreshold, backpressureIncomingMqttRequestsLowerThreshold, replyToAddress, messageRouter, mqttClientFactory, channelId, mqttTopicPrefixProvider, new NoOpRawMessagingPreprocessor(), new HashSet<JoynrMessageProcessor>(), mqttStatusReceiver);
    subject.init();
    verify(mqttClient).subscribe(startsWith("$share:"));
}
Also used : NoOpRawMessagingPreprocessor(io.joynr.messaging.NoOpRawMessagingPreprocessor) SharedSubscriptionsMqttMessagingSkeleton(io.joynr.messaging.mqtt.SharedSubscriptionsMqttMessagingSkeleton) HashSet(java.util.HashSet)

Aggregations

NoOpRawMessagingPreprocessor (io.joynr.messaging.NoOpRawMessagingPreprocessor)3 JoynrMessageProcessor (io.joynr.messaging.JoynrMessageProcessor)2 DefaultJoynrRuntimeFactory (io.joynr.jeeintegration.DefaultJoynrRuntimeFactory)1 RawMessagingPreprocessor (io.joynr.messaging.RawMessagingPreprocessor)1 MqttClientIdProvider (io.joynr.messaging.mqtt.MqttClientIdProvider)1 SharedSubscriptionsMqttMessagingSkeleton (io.joynr.messaging.mqtt.SharedSubscriptionsMqttMessagingSkeleton)1 Field (java.lang.reflect.Field)1 HashSet (java.util.HashSet)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 ImmutableMessage (joynr.ImmutableMessage)1 Test (org.junit.Test)1