Search in sources :

Example 1 with LoadBalancingHttpClient

use of com.netflix.ribbon.transport.netty.http.LoadBalancingHttpClient in project ribbon by Netflix.

the class RxMovieProxyExampleTest method testTransportFactoryWithInjection.

@Test
public void testTransportFactoryWithInjection() {
    Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(ClientConfigFactory.class).to(MyClientConfigFactory.class).in(Scopes.SINGLETON);
            bind(RibbonTransportFactory.class).to(DefaultRibbonTransportFactory.class).in(Scopes.SINGLETON);
        }
    });
    RibbonTransportFactory transportFactory = injector.getInstance(RibbonTransportFactory.class);
    HttpClient<ByteBuf, ByteBuf> client = transportFactory.newHttpClient("myClient");
    IClientConfig config = ((LoadBalancingHttpClient) client).getClientConfig();
    assertEquals("MyConfig", config.getNameSpace());
}
Also used : Injector(com.google.inject.Injector) DefaultClientConfigFactory(com.netflix.client.config.ClientConfigFactory.DefaultClientConfigFactory) ClientConfigFactory(com.netflix.client.config.ClientConfigFactory) RibbonTransportFactory(com.netflix.ribbon.RibbonTransportFactory) DefaultRibbonTransportFactory(com.netflix.ribbon.RibbonTransportFactory.DefaultRibbonTransportFactory) IClientConfig(com.netflix.client.config.IClientConfig) LoadBalancingHttpClient(com.netflix.ribbon.transport.netty.http.LoadBalancingHttpClient) ByteBuf(io.netty.buffer.ByteBuf) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 ClientConfigFactory (com.netflix.client.config.ClientConfigFactory)1 DefaultClientConfigFactory (com.netflix.client.config.ClientConfigFactory.DefaultClientConfigFactory)1 IClientConfig (com.netflix.client.config.IClientConfig)1 RibbonTransportFactory (com.netflix.ribbon.RibbonTransportFactory)1 DefaultRibbonTransportFactory (com.netflix.ribbon.RibbonTransportFactory.DefaultRibbonTransportFactory)1 LoadBalancingHttpClient (com.netflix.ribbon.transport.netty.http.LoadBalancingHttpClient)1 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1