Search in sources :

Example 66 with Application

use of com.netflix.discovery.shared.Application 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());
}
Also used : Applications(com.netflix.discovery.shared.Applications) Application(com.netflix.discovery.shared.Application) Test(org.junit.Test)

Example 67 with Application

use of com.netflix.discovery.shared.Application in project eureka by Netflix.

the class EurekaCodecCompatibilityTest method testApplicationEncodeDecode.

@Test
public void testApplicationEncodeDecode() throws Exception {
    final Application application = new Application("testApp");
    application.addInstance(infoIterator.next());
    application.addInstance(infoIterator.next());
    Action2 codingAction = new Action2() {

        @Override
        public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
            String encodedString = encodingCodec.encode(application);
            Application decodedValue = decodingCodec.decode(encodedString, Application.class);
            assertThat(EurekaEntityComparators.equal(application, decodedValue), is(true));
        }
    };
    verifyAllPairs(codingAction, Application.class, availableJsonWrappers);
    verifyAllPairs(codingAction, Application.class, availableXmlWrappers);
}
Also used : DecoderWrapper(com.netflix.discovery.converters.wrappers.DecoderWrapper) Application(com.netflix.discovery.shared.Application) EncoderWrapper(com.netflix.discovery.converters.wrappers.EncoderWrapper) Test(org.junit.Test)

Example 68 with Application

use of com.netflix.discovery.shared.Application in project eureka by Netflix.

the class EurekaJacksonCodecTest method testApplicationJacksonEncodeXStreamDecode.

@Test
public void testApplicationJacksonEncodeXStreamDecode() throws Exception {
    // Encode
    ByteArrayOutputStream captureStream = new ByteArrayOutputStream();
    codec.writeTo(APPLICATION_1, captureStream);
    byte[] encoded = captureStream.toByteArray();
    // Decode
    InputStream source = new ByteArrayInputStream(encoded);
    Application decoded = (Application) new EntityBodyConverter().read(source, Application.class, MediaType.APPLICATION_JSON_TYPE);
    assertTrue(EurekaEntityComparators.equal(decoded, APPLICATION_1));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Application(com.netflix.discovery.shared.Application) Test(org.junit.Test)

Example 69 with Application

use of com.netflix.discovery.shared.Application in project eureka by Netflix.

the class EurekaJsonAndXmlJacksonCodecTest method doApplicationEncodeDecode.

private void doApplicationEncodeDecode(AbstractEurekaJacksonCodec codec) throws Exception {
    Application application = new Application("testApp");
    application.addInstance(infoIterator.next());
    application.addInstance(infoIterator.next());
    String encodedString = codec.getObjectMapper(Application.class).writeValueAsString(application);
    Application decodedValue = codec.getObjectMapper(Application.class).readValue(encodedString, Application.class);
    assertThat(EurekaEntityComparators.equal(application, decodedValue), is(true));
}
Also used : Application(com.netflix.discovery.shared.Application)

Example 70 with Application

use of com.netflix.discovery.shared.Application in project eureka by Netflix.

the class EurekaJacksonCodecTest method testApplicationXStreamEncodeJacksonDecode.

@Test
public void testApplicationXStreamEncodeJacksonDecode() throws Exception {
    Application original = APPLICATION_1;
    // Encode
    ByteArrayOutputStream captureStream = new ByteArrayOutputStream();
    new EntityBodyConverter().write(original, captureStream, MediaType.APPLICATION_JSON_TYPE);
    byte[] encoded = captureStream.toByteArray();
    // Decode
    InputStream source = new ByteArrayInputStream(encoded);
    Application decoded = codec.readValue(Application.class, source);
    assertTrue(EurekaEntityComparators.equal(decoded, original));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Application(com.netflix.discovery.shared.Application) Test(org.junit.Test)

Aggregations

Application (com.netflix.discovery.shared.Application)104 InstanceInfo (com.netflix.appinfo.InstanceInfo)51 Test (org.junit.Test)43 Applications (com.netflix.discovery.shared.Applications)41 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)14 DecoderWrapper (com.netflix.discovery.converters.wrappers.DecoderWrapper)7 Response (javax.ws.rs.core.Response)7 CodecWrappers (com.netflix.discovery.converters.wrappers.CodecWrappers)6 Map (java.util.Map)6 DiscoveryNode (com.hazelcast.spi.discovery.DiscoveryNode)4 Lease (com.netflix.eureka.lease.Lease)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InputStream (java.io.InputStream)3 AmazonInfo (com.netflix.appinfo.AmazonInfo)2 InstanceStatus (com.netflix.appinfo.InstanceInfo.InstanceStatus)2 Pair (com.netflix.discovery.shared.Pair)2