Search in sources :

Example 1 with RawMessagingPreprocessor

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());
}
Also used : ImmutableMessage(joynr.ImmutableMessage) NoOpRawMessagingPreprocessor(io.joynr.messaging.NoOpRawMessagingPreprocessor) RawMessagingPreprocessor(io.joynr.messaging.RawMessagingPreprocessor) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with RawMessagingPreprocessor

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();
}
Also used : DummyJoynrApplication(io.joynr.integration.util.DummyJoynrApplication) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) Properties(java.util.Properties) Module(com.google.inject.Module) MqttModule(io.joynr.messaging.mqtt.MqttModule) MqttPahoModule(io.joynr.messaging.mqtt.paho.client.MqttPahoModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) AbstractModule(com.google.inject.AbstractModule) RawMessagingPreprocessor(io.joynr.messaging.RawMessagingPreprocessor) Map(java.util.Map) AbstractModule(com.google.inject.AbstractModule) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory)

Example 3 with RawMessagingPreprocessor

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);
}
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)

Aggregations

RawMessagingPreprocessor (io.joynr.messaging.RawMessagingPreprocessor)3 NoOpRawMessagingPreprocessor (io.joynr.messaging.NoOpRawMessagingPreprocessor)2 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 DummyJoynrApplication (io.joynr.integration.util.DummyJoynrApplication)1 DefaultJoynrRuntimeFactory (io.joynr.jeeintegration.DefaultJoynrRuntimeFactory)1 JoynrMessageProcessor (io.joynr.messaging.JoynrMessageProcessor)1 MqttClientIdProvider (io.joynr.messaging.mqtt.MqttClientIdProvider)1 MqttModule (io.joynr.messaging.mqtt.MqttModule)1 MqttPahoModule (io.joynr.messaging.mqtt.paho.client.MqttPahoModule)1 CCInProcessRuntimeModule (io.joynr.runtime.CCInProcessRuntimeModule)1 JoynrInjectorFactory (io.joynr.runtime.JoynrInjectorFactory)1 Field (java.lang.reflect.Field)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Properties (java.util.Properties)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 ImmutableMessage (joynr.ImmutableMessage)1 Test (org.junit.Test)1