use of com.netflix.discovery.util.InstanceInfoGenerator in project eureka by Netflix.
the class DiscoveryClientRegistryTest method testCacheRefreshSingleAppForLocalRegion.
@Test
public void testCacheRefreshSingleAppForLocalRegion() throws Exception {
InstanceInfoGenerator instanceGen = InstanceInfoGenerator.newBuilder(2, "testApp").build();
Applications initialApps = instanceGen.takeDelta(1);
String vipAddress = initialApps.getRegisteredApplications().get(0).getInstances().get(0).getVIPAddress();
DiscoveryClientResource vipClientResource = discoveryClientResource.fork().withVipFetch(vipAddress).build();
// Take first portion
when(requestHandler.getVip(vipAddress, TEST_REMOTE_REGION)).thenReturn(anEurekaHttpResponse(200, initialApps).type(MediaType.APPLICATION_JSON_TYPE).build());
EurekaClient vipClient = vipClientResource.getClient();
assertThat(countInstances(vipClient.getApplications()), is(equalTo(1)));
// Now second one
when(requestHandler.getVip(vipAddress, TEST_REMOTE_REGION)).thenReturn(anEurekaHttpResponse(200, instanceGen.toApplications()).type(MediaType.APPLICATION_JSON_TYPE).build());
assertThat(vipClientResource.awaitCacheUpdate(5, TimeUnit.SECONDS), is(true));
assertThat(countInstances(vipClient.getApplications()), is(equalTo(2)));
}
use of com.netflix.discovery.util.InstanceInfoGenerator in project eureka by Netflix.
the class ApplicationResourceTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
InstanceInfoGenerator instanceInfos = InstanceInfoGenerator.newBuilder(6, 1).build();
testApplication = instanceInfos.toApplications().getRegisteredApplications().get(0);
applicationResource = new ApplicationResource(testApplication.getName(), serverContext.getServerConfig(), serverContext.getRegistry());
for (InstanceInfo instanceInfo : testApplication.getInstances()) {
registry.register(instanceInfo, false);
}
}
use of com.netflix.discovery.util.InstanceInfoGenerator in project eureka by Netflix.
the class ApplicationsResourceTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
InstanceInfoGenerator instanceInfos = InstanceInfoGenerator.newBuilder(20, 6).build();
testApplications = instanceInfos.toApplications();
applicationsResource = new ApplicationsResource(serverContext);
for (Application application : testApplications.getRegisteredApplications()) {
for (InstanceInfo instanceInfo : application.getInstances()) {
registry.register(instanceInfo, false);
}
}
}
Aggregations