Search in sources :

Example 21 with EurekaClient

use of com.netflix.discovery.EurekaClient in project eureka by Netflix.

the class Jersey2EurekaModuleTest method testDI.

@SuppressWarnings("deprecation")
@Test
public void testDI() {
    InstanceInfo instanceInfo = injector.getInstance(InstanceInfo.class);
    Assert.assertEquals(ApplicationInfoManager.getInstance().getInfo(), instanceInfo);
    EurekaClient eurekaClient = injector.getInstance(EurekaClient.class);
    DiscoveryClient discoveryClient = injector.getInstance(DiscoveryClient.class);
    Assert.assertEquals(DiscoveryManager.getInstance().getEurekaClient(), eurekaClient);
    Assert.assertEquals(DiscoveryManager.getInstance().getDiscoveryClient(), discoveryClient);
    Assert.assertEquals(eurekaClient, discoveryClient);
    EurekaClientConfig eurekaClientConfig = injector.getInstance(EurekaClientConfig.class);
    Assert.assertEquals(DiscoveryManager.getInstance().getEurekaClientConfig(), eurekaClientConfig);
    EurekaInstanceConfig eurekaInstanceConfig = injector.getInstance(EurekaInstanceConfig.class);
    Assert.assertEquals(DiscoveryManager.getInstance().getEurekaInstanceConfig(), eurekaInstanceConfig);
    Binding<TransportClientFactories> binding = injector.getExistingBinding(Key.get(TransportClientFactories.class));
    // has a binding for jersey2
    Assert.assertNotNull(binding);
    TransportClientFactories transportClientFactories = injector.getInstance(TransportClientFactories.class);
    Assert.assertTrue(transportClientFactories instanceof Jersey2TransportClientFactories);
}
Also used : EurekaClientConfig(com.netflix.discovery.EurekaClientConfig) Jersey2TransportClientFactories(com.netflix.discovery.shared.transport.jersey2.Jersey2TransportClientFactories) EurekaInstanceConfig(com.netflix.appinfo.EurekaInstanceConfig) EurekaClient(com.netflix.discovery.EurekaClient) DiscoveryClient(com.netflix.discovery.DiscoveryClient) Jersey2TransportClientFactories(com.netflix.discovery.shared.transport.jersey2.Jersey2TransportClientFactories) TransportClientFactories(com.netflix.discovery.shared.transport.jersey.TransportClientFactories) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Aggregations

EurekaClient (com.netflix.discovery.EurekaClient)21 Test (org.junit.Test)13 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)7 DiscoveryClient (com.netflix.discovery.DiscoveryClient)6 ServerListUpdater (com.netflix.loadbalancer.ServerListUpdater)6 EurekaInstanceConfig (com.netflix.appinfo.EurekaInstanceConfig)5 InstanceInfo (com.netflix.appinfo.InstanceInfo)5 CacheRefreshedEvent (com.netflix.discovery.CacheRefreshedEvent)5 EurekaEventListener (com.netflix.discovery.EurekaEventListener)5 Capture (org.easymock.Capture)5 MyDataCenterInstanceConfig (com.netflix.appinfo.MyDataCenterInstanceConfig)4 DefaultEurekaClientConfig (com.netflix.discovery.DefaultEurekaClientConfig)4 EurekaClientConfig (com.netflix.discovery.EurekaClientConfig)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 Archaius2VipAddressResolver (com.netflix.appinfo.providers.Archaius2VipAddressResolver)2 VipAddressResolver (com.netflix.appinfo.providers.VipAddressResolver)2 TransportClientFactories (com.netflix.discovery.shared.transport.jersey.TransportClientFactories)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 Injector (com.google.inject.Injector)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1