use of io.joynr.messaging.mqtt.MqttClientFactory in project joynr by bmwcarit.
the class MqttPahoClientTest method createMqttClientInternal.
private JoynrMqttClient createMqttClientInternal(final MqttStatusReceiver mqttStatusReceiver) {
injector = Guice.createInjector(override(new MqttPahoModule()).with(new AbstractModule() {
@Override
protected void configure() {
if (mqttStatusReceiver != null) {
bind(MqttStatusReceiver.class).toInstance(mqttStatusReceiver);
}
}
}), new JoynrPropertiesModule(properties), new AbstractModule() {
@Override
protected void configure() {
bind(MessageRouter.class).toInstance(mockMessageRouter);
bind(ScheduledExecutorService.class).annotatedWith(Names.named(MessageRouter.SCHEDULEDTHREADPOOL)).toInstance(Executors.newScheduledThreadPool(10));
bind(RawMessagingPreprocessor.class).to(NoOpRawMessagingPreprocessor.class);
Multibinder.newSetBinder(binder(), new TypeLiteral<JoynrMessageProcessor>() {
});
}
});
// create a new Factory because the factory caches its client.
mqttClientFactory = injector.getInstance(MqttClientFactory.class);
JoynrMqttClient client = mqttClientFactory.create();
client.setMessageListener(mockReceiver);
return client;
}
Aggregations