Search in sources :

Example 1 with DummyDiscoveryModule

use of io.joynr.capabilities.DummyDiscoveryModule 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)1 Injector (com.google.inject.Injector)1 Singleton (com.google.inject.Singleton)1 DummyDiscoveryModule (io.joynr.capabilities.DummyDiscoveryModule)1 JoynrPropertiesModule (io.joynr.common.JoynrPropertiesModule)1 ConfigurableMessagingSettings (io.joynr.messaging.ConfigurableMessagingSettings)1 JsonMessageSerializerModule (io.joynr.messaging.JsonMessageSerializerModule)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 HttpException (org.apache.http.HttpException)1 HttpRequest (org.apache.http.HttpRequest)1 HttpResponse (org.apache.http.HttpResponse)1 RequestConfig (org.apache.http.client.config.RequestConfig)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 LocalTestServer (org.apache.http.localserver.LocalTestServer)1 HttpContext (org.apache.http.protocol.HttpContext)1 HttpRequestHandler (org.apache.http.protocol.HttpRequestHandler)1 Before (org.junit.Before)1