use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class EurekaEventListenerTest method testCacheRefreshEvent.
@Test
public void testCacheRefreshEvent() throws Exception {
CapturingEurekaEventListener listener = new CapturingEurekaEventListener();
Applications initialApps = toApplications(discoveryClientResource.getMyInstanceInfo());
when(requestHandler.getApplications()).thenReturn(anEurekaHttpResponse(200, initialApps).type(MediaType.APPLICATION_JSON_TYPE).build());
DiscoveryClient client = (DiscoveryClient) discoveryClientResource.getClient();
client.registerEventListener(listener);
client.refreshRegistry();
assertNotNull(listener.event);
assertThat(listener.event, is(instanceOf(CacheRefreshedEvent.class)));
}
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));
}
use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class EurekaJacksonCodecTest method testApplicationsJacksonEncodeDecode.
@Test
public void testApplicationsJacksonEncodeDecode() throws Exception {
// Encode
ByteArrayOutputStream captureStream = new ByteArrayOutputStream();
codec.writeTo(APPLICATIONS, captureStream);
byte[] encoded = captureStream.toByteArray();
// Decode
InputStream source = new ByteArrayInputStream(encoded);
Applications decoded = codec.readValue(Applications.class, source);
assertTrue(EurekaEntityComparators.equal(decoded, APPLICATIONS));
}
use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class EurekaJacksonCodecTest method testApplicationsXStreamEncodeJacksonDecode.
@Test
public void testApplicationsXStreamEncodeJacksonDecode() throws Exception {
Applications original = APPLICATIONS;
// Encode
ByteArrayOutputStream captureStream = new ByteArrayOutputStream();
new EntityBodyConverter().write(original, captureStream, MediaType.APPLICATION_JSON_TYPE);
byte[] encoded = captureStream.toByteArray();
String encodedString = new String(encoded);
// Decode
InputStream source = new ByteArrayInputStream(encoded);
Applications decoded = codec.readValue(Applications.class, source);
assertTrue(EurekaEntityComparators.equal(decoded, original));
}
use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class JsonXStreamTest method testEncodingDecodingWithoutMetaData.
@Test
public void testEncodingDecodingWithoutMetaData() throws Exception {
Applications applications = InstanceInfoGenerator.newBuilder(10, 2).withMetaData(false).build().toApplications();
XStream xstream = JsonXStream.getInstance();
String jsonDocument = xstream.toXML(applications);
Applications decodedApplications = (Applications) xstream.fromXML(jsonDocument);
assertThat(EurekaEntityComparators.equal(decodedApplications, applications), is(true));
}
Aggregations