use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class DiscoveryClientRegistryTest method testAllAppsForRegions.
@Test
public void testAllAppsForRegions() throws Exception {
prepareRemoteRegionRegistry();
EurekaClient client = discoveryClientResource.getClient();
Applications appsForRemoteRegion = client.getApplicationsForARegion(TEST_REMOTE_REGION);
assertThat(countInstances(appsForRemoteRegion), is(equalTo(4)));
Applications appsForLocalRegion = client.getApplicationsForARegion(TEST_LOCAL_REGION);
assertThat(countInstances(appsForLocalRegion), is(equalTo(4)));
}
use of com.netflix.discovery.shared.Applications 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.shared.Applications in project eureka by Netflix.
the class BackUpRegistryTest method setupBackupMock.
private void setupBackupMock() {
Application localApp = createLocalApps();
Applications localApps = new Applications();
localApps.addApplication(localApp);
backupRegistry.setLocalRegionApps(localApps);
Application remoteApp = createRemoteApps();
Applications remoteApps = new Applications();
remoteApps.addApplication(remoteApp);
backupRegistry.getRemoteRegionVsApps().put(REMOTE_REGION, remoteApps);
}
use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class BackUpRegistryTest method testRemoteEnabledAndQueried.
@Test
public void testRemoteEnabledAndQueried() throws Exception {
setUp(true);
Applications applications = client.getApplicationsForARegion(REMOTE_REGION);
List<Application> registeredApplications = applications.getRegisteredApplications();
Assert.assertNotNull("Remote region apps not found.", registeredApplications);
Assert.assertEquals("Remote apps size not as expected.", 1, registeredApplications.size());
Assert.assertEquals("Remote region apps not present.", REMOTE_REGION_APP_NAME, registeredApplications.get(0).getName());
}
use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class EurekaJacksonCodecTest method testApplicationsJacksonEncodeXStreamDecode.
@Test
public void testApplicationsJacksonEncodeXStreamDecode() throws Exception {
// Encode
ByteArrayOutputStream captureStream = new ByteArrayOutputStream();
codec.writeTo(APPLICATIONS, captureStream);
byte[] encoded = captureStream.toByteArray();
// Decode
InputStream source = new ByteArrayInputStream(encoded);
Applications decoded = (Applications) new EntityBodyConverter().read(source, Applications.class, MediaType.APPLICATION_JSON_TYPE);
assertTrue(EurekaEntityComparators.equal(decoded, APPLICATIONS));
}
Aggregations