Search in sources :

Example 76 with Applications

use of com.netflix.discovery.shared.Applications 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)

Example 77 with Applications

use of com.netflix.discovery.shared.Applications 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 78 with Applications

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

the class InstanceRegistryTest method testGetAppsFromAllRemoteRegions.

@Test
public void testGetAppsFromAllRemoteRegions() throws Exception {
    Applications apps = registry.getApplicationsFromAllRemoteRegions();
    List<Application> registeredApplications = apps.getRegisteredApplications();
    Assert.assertEquals("Apps size from remote regions do not match", 1, registeredApplications.size());
    Application app = registeredApplications.iterator().next();
    Assert.assertEquals("Added app did not return from remote registry", REMOTE_REGION_APP_NAME, app.getName());
    Assert.assertEquals("Returned app did not have the instance", 1, app.getInstances().size());
}
Also used : Applications(com.netflix.discovery.shared.Applications) Application(com.netflix.discovery.shared.Application) Test(org.junit.Test)

Example 79 with Applications

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

the class AbstractVIPResourceTest method testFullVipGet.

@Test
public void testFullVipGet() throws Exception {
    Response response = resource.getVipResponse(Version.V2.name(), vipName, MediaType.APPLICATION_JSON, EurekaAccept.full, Key.EntityType.VIP);
    String json = String.valueOf(response.getEntity());
    DecoderWrapper decoder = CodecWrappers.getDecoder(CodecWrappers.LegacyJacksonJson.class);
    Applications decodedApps = decoder.decode(json, Applications.class);
    Application decodedApp = decodedApps.getRegisteredApplications(testApplication.getName());
    assertThat(EurekaEntityComparators.equal(testApplication, 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)

Example 80 with Applications

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

Aggregations

Applications (com.netflix.discovery.shared.Applications)85 Test (org.junit.Test)43 Application (com.netflix.discovery.shared.Application)25 InstanceInfo (com.netflix.appinfo.InstanceInfo)22 EurekaEntityFunctions.toApplications (com.netflix.discovery.util.EurekaEntityFunctions.toApplications)11 EurekaEntityFunctions.mergeApplications (com.netflix.discovery.util.EurekaEntityFunctions.mergeApplications)10 EurekaEntityFunctions.copyApplications (com.netflix.discovery.util.EurekaEntityFunctions.copyApplications)8 DecoderWrapper (com.netflix.discovery.converters.wrappers.DecoderWrapper)6 List (java.util.List)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 CodecWrappers (com.netflix.discovery.converters.wrappers.CodecWrappers)5 InstanceInfoGenerator (com.netflix.discovery.util.InstanceInfoGenerator)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Response (javax.ws.rs.core.Response)4 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Map (java.util.Map)3