Search in sources :

Example 96 with Application

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

the class AbstractTester method createRemoteApps.

private static Application createRemoteApps() {
    Application myapp = new Application(REMOTE_REGION_APP_NAME);
    InstanceInfo instanceInfo = createRemoteInstance(REMOTE_REGION_INSTANCE_1_HOSTNAME);
    // instanceInfo.setActionType(InstanceInfo.ActionType.MODIFIED);
    myapp.addInstance(instanceInfo);
    return myapp;
}
Also used : Application(com.netflix.discovery.shared.Application) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 97 with Application

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

the class AbstractTester method populateRemoteRegistryAtStartup.

private void populateRemoteRegistryAtStartup() {
    Application myapp = createRemoteApps();
    Application myappDelta = createRemoteAppsDelta();
    remoteRegionApps.put(REMOTE_REGION_APP_NAME, myapp);
    remoteRegionAppsDelta.put(REMOTE_REGION_APP_NAME, myappDelta);
}
Also used : Application(com.netflix.discovery.shared.Application)

Example 98 with Application

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

the class AbstractTester method createRemoteAppsDelta.

private static Application createRemoteAppsDelta() {
    Application myapp = new Application(REMOTE_REGION_APP_NAME);
    InstanceInfo instanceInfo = createRemoteInstance(REMOTE_REGION_INSTANCE_1_HOSTNAME);
    myapp.addInstance(instanceInfo);
    return myapp;
}
Also used : Application(com.netflix.discovery.shared.Application) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 99 with Application

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

the class ApplicationsResourceTest method testMiniAppsGet.

@Test
public void testMiniAppsGet() throws Exception {
    Response response = applicationsResource.getContainers(Version.V2.name(), MediaType.APPLICATION_JSON, // encoding
    null, EurekaAccept.compact.name(), // uriInfo
    null, // remote regions
    null);
    String json = String.valueOf(response.getEntity());
    DecoderWrapper decoder = CodecWrappers.getDecoder(CodecWrappers.LegacyJacksonJson.class);
    Applications decoded = decoder.decode(json, Applications.class);
    // test per app as the full apps list include the mock server that is not part of the test apps
    for (Application application : testApplications.getRegisteredApplications()) {
        Application decodedApp = decoded.getRegisteredApplications(application.getName());
        // assert false as one is mini, so should NOT equal
        assertThat(EurekaEntityComparators.equal(application, decodedApp), is(false));
    }
    for (Application application : testApplications.getRegisteredApplications()) {
        Application decodedApp = decoded.getRegisteredApplications(application.getName());
        assertThat(application.getName(), is(decodedApp.getName()));
        // now do mini equals
        for (InstanceInfo instanceInfo : application.getInstances()) {
            InstanceInfo decodedInfo = decodedApp.getByInstanceId(instanceInfo.getId());
            assertThat(EurekaEntityComparators.equalMini(instanceInfo, decodedInfo), is(true));
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) DecoderWrapper(com.netflix.discovery.converters.wrappers.DecoderWrapper) Applications(com.netflix.discovery.shared.Applications) Application(com.netflix.discovery.shared.Application) InstanceInfo(com.netflix.appinfo.InstanceInfo) CodecWrappers(com.netflix.discovery.converters.wrappers.CodecWrappers) Test(org.junit.Test)

Example 100 with Application

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

the class ApplicationsResourceTest method testFullAppsGetJson.

@Test
public void testFullAppsGetJson() throws Exception {
    Response response = applicationsResource.getContainers(Version.V2.name(), MediaType.APPLICATION_JSON, // encoding
    null, EurekaAccept.full.name(), // uriInfo
    null, // remote regions
    null);
    String json = String.valueOf(response.getEntity());
    DecoderWrapper decoder = CodecWrappers.getDecoder(CodecWrappers.LegacyJacksonJson.class);
    Applications decoded = decoder.decode(json, Applications.class);
    // test per app as the full apps list include the mock server that is not part of the test apps
    for (Application application : testApplications.getRegisteredApplications()) {
        Application decodedApp = decoded.getRegisteredApplications(application.getName());
        assertThat(EurekaEntityComparators.equal(application, decodedApp), is(true));
    }
}
Also used : Response(javax.ws.rs.core.Response) DecoderWrapper(com.netflix.discovery.converters.wrappers.DecoderWrapper) Applications(com.netflix.discovery.shared.Applications) Application(com.netflix.discovery.shared.Application) CodecWrappers(com.netflix.discovery.converters.wrappers.CodecWrappers) 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