Search in sources :

Example 11 with JoynrPropertiesModule

use of io.joynr.common.JoynrPropertiesModule in project joynr by bmwcarit.

the class UrlResolverTest method setUp.

@Before
public void setUp() throws Exception {
    Properties properties = new Properties();
    properties.put(MessagingPropertyKeys.CHANNELID, channelId);
    Injector injector = Guice.createInjector(new JoynrPropertiesModule(properties), new MessagingTestModule(), new AtmosphereMessagingModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(RequestConfig.class).toProvider(HttpDefaultRequestConfigProvider.class).in(Singleton.class);
            bind(MessageRouter.class).toInstance(mockMessageRouter);
            Multibinder.newSetBinder(binder(), new TypeLiteral<JoynrMessageProcessor>() {
            });
        }
    });
    urlResolver = injector.getInstance(UrlResolver.class);
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) TypeLiteral(com.google.inject.TypeLiteral) Injector(com.google.inject.Injector) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) Singleton(com.google.inject.Singleton) Properties(java.util.Properties) MessagingTestModule(io.joynr.messaging.MessagingTestModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

Example 12 with JoynrPropertiesModule

use of io.joynr.common.JoynrPropertiesModule in project joynr by bmwcarit.

the class HttpCommunicationManagerTest method setUp.

@Before
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "correct use of RestAssured API")
public void setUp() throws Exception {
    RestAssured.port = port;
    String basePath = "/bounceproxy/";
    RestAssured.basePath = basePath;
    bounceProxyUrlString = "http://localhost:" + port + basePath;
    Properties properties = new Properties();
    properties.put(MessagingPropertyKeys.CHANNELID, testChannelId);
    properties.put(MessagingPropertyKeys.BOUNCE_PROXY_URL, bounceProxyUrlString);
    Injector injector = Guice.createInjector(new JoynrPropertiesModule(properties), new MessagingTestModule(), new AtmosphereMessagingModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(RequestConfig.class).toProvider(HttpDefaultRequestConfigProvider.class).in(Singleton.class);
            bind(MessageRouter.class).toInstance(mockMessageRouter);
            Multibinder.newSetBinder(binder(), new TypeLiteral<JoynrMessageProcessor>() {
            });
        }
    });
    longpollingMessageReceiver = injector.getInstance(LongPollingMessageReceiver.class);
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) TypeLiteral(com.google.inject.TypeLiteral) Injector(com.google.inject.Injector) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) Singleton(com.google.inject.Singleton) Matchers.containsString(org.hamcrest.Matchers.containsString) Properties(java.util.Properties) MessagingTestModule(io.joynr.messaging.MessagingTestModule) AtmosphereMessagingModule(io.joynr.messaging.AtmosphereMessagingModule) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

Example 13 with JoynrPropertiesModule

use of io.joynr.common.JoynrPropertiesModule in project joynr by bmwcarit.

the class LongPollingChannelLifecycleTest method setUp.

@Before
public void setUp() throws Exception {
    server = new LocalTestServer(null, null);
    server.register(CHANNELPATH, new HttpRequestHandler() {

        @Override
        public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
            response.setStatusCode(createChannelResponseCode);
            response.setHeader("Location", bounceProxyUrl + "channels/" + channelId);
        }
    });
    server.start();
    serviceAddress = "http://" + server.getServiceAddress().getHostName() + ":" + server.getServiceAddress().getPort();
    bounceProxyUrl = serviceAddress + BOUNCEPROXYPATH;
    Properties properties = new Properties();
    properties.put(MessagingPropertyKeys.CHANNELID, channelId);
    properties.put(MessagingPropertyKeys.BOUNCE_PROXY_URL, bounceProxyUrl);
    Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        public void configure() {
            bind(HttpRequestFactory.class).to(ApacheHttpRequestFactory.class);
            bind(CloseableHttpClient.class).toProvider(HttpClientProvider.class).in(Singleton.class);
            bind(RequestConfig.class).toProvider(HttpDefaultRequestConfigProvider.class).in(Singleton.class);
            bind(MessagingSettings.class).to(ConfigurableMessagingSettings.class);
        }
    }, new JoynrPropertiesModule(properties), new JsonMessageSerializerModule(), new DummyDiscoveryModule());
    longpollingChannelLifecycle = injector.getInstance(LongPollingChannelLifecycle.class);
}
Also used : HttpRequest(org.apache.http.HttpRequest) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) RequestConfig(org.apache.http.client.config.RequestConfig) ConfigurableMessagingSettings(io.joynr.messaging.ConfigurableMessagingSettings) HttpRequestHandler(org.apache.http.protocol.HttpRequestHandler) JsonMessageSerializerModule(io.joynr.messaging.JsonMessageSerializerModule) HttpContext(org.apache.http.protocol.HttpContext) HttpResponse(org.apache.http.HttpResponse) IOException(java.io.IOException) Properties(java.util.Properties) DummyDiscoveryModule(io.joynr.capabilities.DummyDiscoveryModule) AbstractModule(com.google.inject.AbstractModule) Injector(com.google.inject.Injector) Singleton(com.google.inject.Singleton) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) HttpException(org.apache.http.HttpException) LocalTestServer(org.apache.http.localserver.LocalTestServer) Before(org.junit.Before)

Aggregations

AbstractModule (com.google.inject.AbstractModule)13 JoynrPropertiesModule (io.joynr.common.JoynrPropertiesModule)13 Injector (com.google.inject.Injector)10 Properties (java.util.Properties)10 Before (org.junit.Before)10 JoynrMessageProcessor (io.joynr.messaging.JoynrMessageProcessor)6 TypeLiteral (com.google.inject.TypeLiteral)5 JsonMessageSerializerModule (io.joynr.messaging.JsonMessageSerializerModule)4 NoOpRawMessagingPreprocessor (io.joynr.messaging.NoOpRawMessagingPreprocessor)4 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)4 Module (com.google.inject.Module)3 Singleton (com.google.inject.Singleton)3 MessagingQos (io.joynr.messaging.MessagingQos)3 Request (joynr.Request)3 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)3 RequestConfig (org.apache.http.client.config.RequestConfig)3 Multibinder (com.google.inject.multibindings.Multibinder)2 AtmosphereMessagingModule (io.joynr.messaging.AtmosphereMessagingModule)2 MessagingTestModule (io.joynr.messaging.MessagingTestModule)2 RawMessagingPreprocessor (io.joynr.messaging.RawMessagingPreprocessor)2