use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class XmlXStreamTest method testEncodingDecodingWithMetaData.
@Test
public void testEncodingDecodingWithMetaData() throws Exception {
Applications applications = InstanceInfoGenerator.newBuilder(10, 2).withMetaData(true).build().toApplications();
XStream xstream = XmlXStream.getInstance();
String xmlDocument = xstream.toXML(applications);
Applications decodedApplications = (Applications) xstream.fromXML(xmlDocument);
assertThat(EurekaEntityComparators.equal(decodedApplications, applications), is(true));
}
use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class XmlXStreamTest method testEncodingDecodingWithoutMetaData.
@Test
public void testEncodingDecodingWithoutMetaData() throws Exception {
Applications applications = InstanceInfoGenerator.newBuilder(10, 2).withMetaData(false).build().toApplications();
XStream xstream = XmlXStream.getInstance();
String xmlDocument = xstream.toXML(applications);
Applications decodedApplications = (Applications) xstream.fromXML(xmlDocument);
assertThat(EurekaEntityComparators.equal(decodedApplications, applications), is(true));
}
use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class EurekaJacksonCodecIntegrationTest method testDecodeTimeout.
/**
* parse discovery response with an unreasonable timeout, so that the
* parsing job is cancelled
*
* @throws Exception
*/
@Test
public void testDecodeTimeout() throws Exception {
ExecutorService executor = Executors.newFixedThreadPool(5);
File localDiscovery = downloadRegistration(System.getProperty("discovery.url"));
Callable<Applications> task = () -> {
try (InputStream is = new FileInputStream(localDiscovery)) {
return codec.readValue(Applications.class, is);
}
};
final int cancelAllButNthTask = 3;
for (int i = 0; i < 30; i++) {
Future<Applications> appsFuture = executor.submit(task);
if (i % cancelAllButNthTask < cancelAllButNthTask - 1) {
Thread.sleep(UNREASONABLE_TIMEOUT_MS);
System.out.println("cancelling..." + " i: " + i + " - " + (i % 3));
appsFuture.cancel(true);
}
try {
Applications apps = appsFuture.get();
System.out.println("found some applications: " + apps.toString() + ":" + apps.getRegisteredApplications().size() + " i: " + i + " - " + (i % 3));
} catch (Exception e) {
System.out.println(e + " cause: " + " i: " + i + " - " + (i % 3));
}
}
}
use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class EurekaJacksonCodecIntegrationTest method testRealDecode.
/**
* parse discovery response in a long-running loop with a delay
*
* @throws Exception
*/
@Test
public void testRealDecode() throws Exception {
Applications applications;
// downloadRegistration(System.getProperty("discovery.url"));
File localDiscovery = new File("/var/folders/6j/qy6n1npj11x5j2j_9ng2wzmw0000gp/T/discovery-data-6054758555577530004.json");
long testStart = System.currentTimeMillis();
for (int i = 0; i < 60; i++) {
try (InputStream is = new FileInputStream(localDiscovery)) {
long start = System.currentTimeMillis();
applications = codec.readValue(Applications.class, is);
System.out.println("found some applications: " + applications.getRegisteredApplications().size() + " et: " + (System.currentTimeMillis() - start));
}
}
System.out.println("test time: " + " et: " + (System.currentTimeMillis() - testStart));
}
use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class EurekaHttpClientCompatibilityTestSuite method testGetVipRequest.
@Test
public void testGetVipRequest() throws Exception {
Applications vipApps = InstanceInfoGenerator.newBuilder(1, 2).build().toApplications();
String vipAddress = vipApps.getRegisteredApplications().get(0).getInstances().get(0).getVIPAddress();
when(requestHandler.getVip(vipAddress)).thenReturn(createResponse(vipApps));
EurekaHttpResponse<Applications> httpResponse = getEurekaHttpClient().getVip(vipAddress);
verifyResponseOkWithEntity(vipApps, httpResponse);
}
Aggregations