use of com.sun.jersey.api.client.WebResource in project hadoop by apache.
the class TestNMWebServices method testNodeInfo.
@Test
public void testNodeInfo() throws JSONException, Exception {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("node").path("info").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
verifyNodeInfo(json);
}
use of com.sun.jersey.api.client.WebResource in project hadoop by apache.
the class TestNMWebServices method testNodeSlash.
@Test
public void testNodeSlash() throws JSONException, Exception {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("node/").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
verifyNodeInfo(json);
}
use of com.sun.jersey.api.client.WebResource in project hadoop by apache.
the class TestNMWebServices method testInvalidAccept.
@Test
public void testInvalidAccept() throws JSONException, Exception {
WebResource r = resource();
String responseStr = "";
try {
responseStr = r.path("ws").path("v1").path("node").accept(MediaType.TEXT_PLAIN).get(String.class);
fail("should have thrown exception on invalid uri");
} catch (UniformInterfaceException ue) {
ClientResponse response = ue.getResponse();
assertResponseStatusCode(Status.INTERNAL_SERVER_ERROR, response.getStatusInfo());
WebServicesTestUtils.checkStringMatch("error string exists and shouldn't", "", responseStr);
}
}
use of com.sun.jersey.api.client.WebResource in project hadoop by apache.
the class TestNMWebServices method testNodeInfoSlash.
@Test
public void testNodeInfoSlash() throws JSONException, Exception {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("node").path("info/").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
verifyNodeInfo(json);
}
use of com.sun.jersey.api.client.WebResource in project hadoop by apache.
the class TestNMWebServices method testInvalidUri.
@Test
public void testInvalidUri() throws JSONException, Exception {
WebResource r = resource();
String responseStr = "";
try {
responseStr = r.path("ws").path("v1").path("node").path("bogus").accept(MediaType.APPLICATION_JSON).get(String.class);
fail("should have thrown exception on invalid uri");
} catch (UniformInterfaceException ue) {
ClientResponse response = ue.getResponse();
assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
WebServicesTestUtils.checkStringMatch("error string exists and shouldn't", "", responseStr);
}
}
Aggregations