Search in sources :

Example 1 with BootstrapModule

use of com.netflix.governator.guice.BootstrapModule in project eureka by Netflix.

the class DefaultEurekaClientConfigProviderTest method testNameSpaceInjection.

@Test
public void testNameSpaceInjection() throws Exception {
    ConfigurationManager.getConfigInstance().setProperty("testnamespace.serviceUrl.default", SERVICE_URI);
    Injector injector = LifecycleInjector.builder().withBootstrapModule(new BootstrapModule() {

        @Override
        public void configure(BootstrapBinder binder) {
            binder.bind(String.class).annotatedWith(EurekaNamespace.class).toInstance("testnamespace.");
        }
    }).build().createInjector();
    DefaultEurekaClientConfig clientConfig = injector.getInstance(DefaultEurekaClientConfig.class);
    List<String> serviceUrls = clientConfig.getEurekaServerServiceUrls("default");
    assertThat(serviceUrls.get(0), is(equalTo(SERVICE_URI)));
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) Injector(com.google.inject.Injector) LifecycleInjector(com.netflix.governator.guice.LifecycleInjector) BootstrapBinder(com.netflix.governator.guice.BootstrapBinder) BootstrapModule(com.netflix.governator.guice.BootstrapModule) Test(org.junit.Test)

Aggregations

Injector (com.google.inject.Injector)1 DefaultEurekaClientConfig (com.netflix.discovery.DefaultEurekaClientConfig)1 BootstrapBinder (com.netflix.governator.guice.BootstrapBinder)1 BootstrapModule (com.netflix.governator.guice.BootstrapModule)1 LifecycleInjector (com.netflix.governator.guice.LifecycleInjector)1 Test (org.junit.Test)1