use of io.joynr.messaging.RawMessagingPreprocessor in project joynr by bmwcarit.
the class MqttMessagingSkeletonTest method testMessageRouterIsCalled.
@SuppressWarnings("unchecked")
@Test
public void testMessageRouterIsCalled() throws Exception {
RawMessagingPreprocessor preprocessor = mock(RawMessagingPreprocessor.class);
when(preprocessor.process(any(byte[].class), anyMap())).then(returnsFirstArg());
subject = new MqttMessagingSkeleton(ownAddress, maxIncomingMqttRequests, messageRouter, mqttClientFactory, mqttTopicPrefixProvider, preprocessor, new HashSet<JoynrMessageProcessor>(), mqttStatusReceiver);
ImmutableMessage rqMessage = createTestRequestMessage();
subject.transmit(rqMessage.getSerializedMessage(), failIfCalledAction);
ArgumentCaptor<ImmutableMessage> captor = ArgumentCaptor.forClass(ImmutableMessage.class);
verify(messageRouter).route(captor.capture());
assertArrayEquals(rqMessage.getSerializedMessage(), captor.getValue().getSerializedMessage());
}
use of io.joynr.messaging.RawMessagingPreprocessor in project joynr by bmwcarit.
the class MqttProviderProxyEnd2EndTest method getRuntime.
@Override
protected JoynrRuntime getRuntime(Properties joynrConfig, Module... modules) {
mqttConfig = new Properties();
mqttConfig.put(MqttModule.PROPERTY_KEY_MQTT_BROKER_URI, "tcp://localhost:" + mqttBrokerPort);
// test is using 2 global address typs, so need to set one of them as primary
mqttConfig.put(MessagingPropertyKeys.PROPERTY_MESSAGING_PRIMARYGLOBALTRANSPORT, "mqtt");
mqttConfig.put(MessagingPropertyKeys.DISCOVERYDIRECTORYURL, "tcp://localhost:" + mqttBrokerPort);
mqttConfig.put(MessagingPropertyKeys.DOMAINACCESSCONTROLLERURL, "tcp://localhost:" + mqttBrokerPort);
mqttConfig.put(MessagingPropertyKeys.MQTT_TOPIC_PREFIX_MULTICAST, "");
mqttConfig.put(MessagingPropertyKeys.MQTT_TOPIC_PREFIX_REPLYTO, "replyto/");
mqttConfig.put(MessagingPropertyKeys.MQTT_TOPIC_PREFIX_UNICAST, "");
joynrConfig.putAll(mqttConfig);
joynrConfig.putAll(baseTestConfig);
Module runtimeModule = Modules.override(new CCInProcessRuntimeModule()).with(modules);
Module modulesWithRuntime = Modules.override(runtimeModule).with(new MqttPahoModule(), new AbstractModule() {
@Override
protected void configure() {
bind(RawMessagingPreprocessor.class).toInstance(new RawMessagingPreprocessor() {
@Override
public byte[] process(byte[] rawMessage, Map<String, Serializable> context) {
return rawMessage;
}
});
}
});
DummyJoynrApplication application = (DummyJoynrApplication) new JoynrInjectorFactory(joynrConfig, modulesWithRuntime).createApplication(DummyJoynrApplication.class);
return application.getRuntime();
}
use of io.joynr.messaging.RawMessagingPreprocessor 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);
}
Aggregations