Search in sources :

Example 1 with MovieService

use of com.netflix.ribbon.examples.rx.proxy.MovieService in project ribbon by Netflix.

the class RxMovieProxyExampleTest method shouldBindCustomClientConfigFactory.

@Test
public void shouldBindCustomClientConfigFactory() {
    ConfigurationManager.getConfigInstance().setProperty(MovieService.class.getSimpleName() + ".MyConfig.listOfServers", "localhost:" + port);
    Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(RibbonResourceFactory.class).to(DefaultResourceFactory.class).in(Scopes.SINGLETON);
            bind(RibbonTransportFactory.class).to(DefaultRibbonTransportFactory.class).in(Scopes.SINGLETON);
            bind(AnnotationProcessorsProvider.class).to(DefaultAnnotationProcessorsProvider.class).in(Scopes.SINGLETON);
            bind(ClientConfigFactory.class).to(MyClientConfigFactory.class).in(Scopes.SINGLETON);
        }
    }, new AbstractModule() {

        @Override
        protected void configure() {
            bind(MovieService.class).toProvider(new RibbonResourceProvider<MovieService>(MovieService.class)).asEagerSingleton();
        }
    });
    RxMovieProxyExample example = injector.getInstance(RxMovieProxyExample.class);
    assertTrue(example.runExample());
}
Also used : MovieService(com.netflix.ribbon.examples.rx.proxy.MovieService) 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) RibbonResourceFactory(com.netflix.ribbon.RibbonResourceFactory) DefaultAnnotationProcessorsProvider(com.netflix.ribbon.proxy.processor.AnnotationProcessorsProvider.DefaultAnnotationProcessorsProvider) AnnotationProcessorsProvider(com.netflix.ribbon.proxy.processor.AnnotationProcessorsProvider) RxMovieProxyExample(com.netflix.ribbon.examples.rx.proxy.RxMovieProxyExample) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test)

Example 2 with MovieService

use of com.netflix.ribbon.examples.rx.proxy.MovieService in project ribbon by Netflix.

the class RxMovieProxyExampleTest method shouldBind.

@Test
public void shouldBind() {
    ConfigurationManager.getConfigInstance().setProperty(MovieService.class.getSimpleName() + ".ribbon.listOfServers", "localhost:" + port);
    Injector injector = Guice.createInjector(new RibbonModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MovieService.class).toProvider(new RibbonResourceProvider<MovieService>(MovieService.class)).asEagerSingleton();
        }
    });
    RxMovieProxyExample example = injector.getInstance(RxMovieProxyExample.class);
    assertTrue(example.runExample());
}
Also used : MovieService(com.netflix.ribbon.examples.rx.proxy.MovieService) Injector(com.google.inject.Injector) RibbonModule(com.netflix.ribbon.guice.RibbonModule) RxMovieProxyExample(com.netflix.ribbon.examples.rx.proxy.RxMovieProxyExample) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test)

Aggregations

AbstractModule (com.google.inject.AbstractModule)2 Injector (com.google.inject.Injector)2 MovieService (com.netflix.ribbon.examples.rx.proxy.MovieService)2 RxMovieProxyExample (com.netflix.ribbon.examples.rx.proxy.RxMovieProxyExample)2 Test (org.junit.Test)2 ClientConfigFactory (com.netflix.client.config.ClientConfigFactory)1 DefaultClientConfigFactory (com.netflix.client.config.ClientConfigFactory.DefaultClientConfigFactory)1 RibbonResourceFactory (com.netflix.ribbon.RibbonResourceFactory)1 RibbonTransportFactory (com.netflix.ribbon.RibbonTransportFactory)1 DefaultRibbonTransportFactory (com.netflix.ribbon.RibbonTransportFactory.DefaultRibbonTransportFactory)1 RibbonModule (com.netflix.ribbon.guice.RibbonModule)1 AnnotationProcessorsProvider (com.netflix.ribbon.proxy.processor.AnnotationProcessorsProvider)1 DefaultAnnotationProcessorsProvider (com.netflix.ribbon.proxy.processor.AnnotationProcessorsProvider.DefaultAnnotationProcessorsProvider)1