use of com.sun.jersey.api.client.Client in project hadoop by apache.
the class TestTimelineReaderWebServices method testGetEntityCustomFields.
@Test
public void testGetEntityCustomFields() throws Exception {
Client client = createClient();
try {
// Fields are case insensitive.
URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/entities/app/id_1?" + "fields=CONFIGS,Metrics,info");
ClientResponse resp = getResponse(client, uri);
TimelineEntity entity = resp.getEntity(TimelineEntity.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
assertNotNull(entity);
assertEquals("id_1", entity.getId());
assertEquals("app", entity.getType());
assertEquals(3, entity.getConfigs().size());
assertEquals(3, entity.getMetrics().size());
assertTrue("UID should be present", entity.getInfo().containsKey(TimelineReaderManager.UID_KEY));
// Includes UID.
assertEquals(3, entity.getInfo().size());
// No events will be returned as events are not part of fields.
assertEquals(0, entity.getEvents().size());
} finally {
client.destroy();
}
}
use of com.sun.jersey.api.client.Client in project hadoop by apache.
the class TestRMHA method checkActiveRMWebServices.
// Do some sanity testing of the web-services after fail-over.
private void checkActiveRMWebServices() throws JSONException {
// Validate web-service
Client webServiceClient = Client.create(new DefaultClientConfig());
InetSocketAddress rmWebappAddr = NetUtils.getConnectAddress(rm.getWebapp().getListenerAddress());
String webappURL = "http://" + rmWebappAddr.getHostName() + ":" + rmWebappAddr.getPort();
WebResource webResource = webServiceClient.resource(webappURL);
String path = app.getApplicationId().toString();
ClientResponse response = webResource.path("ws").path("v1").path("cluster").path("apps").path(path).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject appJson = json.getJSONObject("app");
assertEquals("ACCEPTED", appJson.getString("state"));
// Other stuff is verified in the regular web-services related tests
}
use of com.sun.jersey.api.client.Client in project neo4j by neo4j.
the class EnterpriseServerIT method shouldBeAbleToStartInHAMode.
@Test
public void shouldBeAbleToStartInHAMode() throws Throwable {
// Given
NeoServer server = EnterpriseServerBuilder.server().usingDataDir(folder.getRoot().getAbsolutePath()).withProperty(mode.name(), "HA").withProperty(server_id.name(), "1").withProperty(initial_hosts.name(), ":5001").persistent().build();
try {
server.start();
server.getDatabase();
assertThat(server.getDatabase().getGraph(), is(instanceOf(HighlyAvailableGraphDatabase.class)));
Client client = Client.create();
ClientResponse r = client.resource("http://localhost:7474/db/manage/server/ha").accept(APPLICATION_JSON).get(ClientResponse.class);
assertEquals(200, r.getStatus());
assertThat(r.getEntity(String.class), containsString("master"));
} finally {
server.stop();
}
}
use of com.sun.jersey.api.client.Client in project neo4j by neo4j.
the class NeoServerStartupLoggingIT method shouldLogStartup.
@Test
public void shouldLogStartup() throws Exception {
// Check the logs
assertThat(out.toString().length(), is(greaterThan(0)));
// Check the server is alive
Client nonRedirectingClient = Client.create();
nonRedirectingClient.setFollowRedirects(false);
final JaxRsResponse response = new RestRequest(server.baseUri(), nonRedirectingClient).get();
assertThat(response.getStatus(), is(greaterThan(199)));
}
use of com.sun.jersey.api.client.Client in project neo4j by neo4j.
the class RedirectToBrowserTest method shouldRedirectToBrowserUsingXForwardedHeaders.
@Test
public void shouldRedirectToBrowserUsingXForwardedHeaders() throws Exception {
Client nonRedirectingClient = Client.create();
nonRedirectingClient.setFollowRedirects(false);
final JaxRsResponse response = new RestRequest(server.baseUri(), nonRedirectingClient).accept(MediaType.TEXT_HTML_TYPE).header("X-Forwarded-Host", "foo.bar:8734").header("X-Forwarded-Proto", "https").get(server.baseUri().toString());
assertEquals(303, response.getStatus());
assertEquals(new URI("https://foo.bar:8734/browser/"), response.getLocation());
response.close();
}
Aggregations