use of com.netflix.discovery.EurekaClient in project ribbon by Netflix.
the class EurekaDynamicServerListLoadBalancerTest method setUpEurekaClientMock.
private EurekaClient setUpEurekaClientMock(List<InstanceInfo> servers) {
final EurekaClient eurekaClientMock = PowerMock.createMock(EurekaClient.class);
EasyMock.expect(eurekaClientMock.getInstancesByVipAddress(EasyMock.anyString(), EasyMock.anyBoolean(), EasyMock.anyString())).andReturn(servers.subList(0, initialServerListSize)).times(1).andReturn(servers.subList(initialServerListSize, servers.size())).anyTimes();
EasyMock.expectLastCall();
EasyMock.expect(eurekaClientMock.unregisterEventListener(EasyMock.isA(EurekaEventListener.class))).andReturn(true).anyTimes();
return eurekaClientMock;
}
use of com.netflix.discovery.EurekaClient in project iep by Netflix.
the class EurekaModuleTest method getEurekaClient.
@Test
public void getEurekaClient() throws Exception {
Injector injector = Guice.createInjector(new EurekaModule());
EurekaClient client = injector.getInstance(EurekaClient.class);
Assert.assertNotNull(client);
}
use of com.netflix.discovery.EurekaClient in project hazelcast-eureka by hazelcast.
the class HazelcastClientTestCase method testInstanceRegistrationUsingProvidedEurekaClient.
@Test
public void testInstanceRegistrationUsingProvidedEurekaClient() {
EurekaClient eurekaClient = mock(EurekaClient.class);
ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class);
EurekaInstanceConfig eurekaInstanceConfig = mock(EurekaInstanceConfig.class);
when(eurekaClient.getApplicationInfoManager()).thenReturn(applicationInfoManager);
when(eurekaClient.getApplication(anyString())).thenReturn(new Application(APP_NAME));
when(applicationInfoManager.getEurekaInstanceConfig()).thenReturn(eurekaInstanceConfig);
when(eurekaInstanceConfig.getAppname()).thenReturn(APP_NAME);
// use provided EurekaClient
EurekaOneDiscoveryStrategyFactory.setEurekaClient(eurekaClient);
HazelcastInstance hz1 = factory.newHazelcastInstance();
HazelcastInstance hz2 = factory.newHazelcastInstance();
verify(eurekaClient, times(2)).getApplicationInfoManager();
verify(eurekaClient, times(2)).getApplication(APP_NAME);
verify(applicationInfoManager, never()).setInstanceStatus(InstanceStatus.UP);
verify(applicationInfoManager, never()).setInstanceStatus(any(InstanceStatus.class));
assertClusterSizeEventually(2, hz1);
assertClusterSizeEventually(2, hz2);
}
use of com.netflix.discovery.EurekaClient in project eureka by Netflix.
the class Ec2EurekaClientModuleTest method testDI.
@SuppressWarnings("deprecation")
@Test
public void testDI() {
InstanceInfo instanceInfo = injector.getInstance(InstanceInfo.class);
Assert.assertEquals(ApplicationInfoManager.getInstance().getInfo(), instanceInfo);
VipAddressResolver vipAddressResolver = injector.getInstance(VipAddressResolver.class);
Assert.assertTrue(vipAddressResolver instanceof Archaius2VipAddressResolver);
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);
Assert.assertTrue(eurekaInstanceConfig instanceof Ec2EurekaArchaius2InstanceConfig);
ApplicationInfoManager applicationInfoManager = injector.getInstance(ApplicationInfoManager.class);
InstanceInfo myInfo = applicationInfoManager.getInfo();
Assert.assertTrue(myInfo.getDataCenterInfo() instanceof AmazonInfo);
Assert.assertEquals(DataCenterInfo.Name.Amazon, myInfo.getDataCenterInfo().getName());
}
use of com.netflix.discovery.EurekaClient in project eureka by Netflix.
the class NonEc2EurekaClientModuleTest method testDI.
@SuppressWarnings("deprecation")
@Test
public void testDI() {
InstanceInfo instanceInfo = injector.getInstance(InstanceInfo.class);
Assert.assertEquals(ApplicationInfoManager.getInstance().getInfo(), instanceInfo);
VipAddressResolver vipAddressResolver = injector.getInstance(VipAddressResolver.class);
Assert.assertTrue(vipAddressResolver instanceof Archaius2VipAddressResolver);
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);
Assert.assertTrue(eurekaInstanceConfig instanceof EurekaArchaius2InstanceConfig);
ApplicationInfoManager applicationInfoManager = injector.getInstance(ApplicationInfoManager.class);
InstanceInfo myInfo = applicationInfoManager.getInfo();
Assert.assertEquals(DataCenterInfo.Name.MyOwn, myInfo.getDataCenterInfo().getName());
}
Aggregations