use of com.sun.jersey.api.client.ClientResponse in project hadoop by apache.
the class TestNMWebServices method testNode.
@Test
public void testNode() 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.ClientResponse in project hadoop by apache.
the class TestNMWebServices method testInvalidUri2.
@Test
public void testInvalidUri2() throws JSONException, Exception {
WebResource r = resource();
String responseStr = "";
try {
responseStr = r.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);
}
}
use of com.sun.jersey.api.client.ClientResponse in project hadoop by apache.
the class TestRMWebServiceAppsNodelabel method testAppsRunning.
@Test
public void testAppsRunning() throws JSONException, Exception {
rm.start();
MockNM nm1 = rm.registerNode("h1:1234", 2048);
MockNM nm2 = rm.registerNode("h2:1235", 2048);
nodeLabelManager.addLabelsToNode(ImmutableMap.of(NodeId.newInstance("h2", 1235), toSet("X")));
RMApp app1 = rm.submitApp(AM_CONTAINER_MB, "app", "user", null, "default");
MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
nm1.nodeHeartbeat(true);
// AM request for resource in partition X
am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "X");
nm2.nodeHeartbeat(true);
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster").path("apps").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
JSONObject json = response.getEntity(JSONObject.class);
// Verify apps resource
JSONObject apps = json.getJSONObject("apps");
assertEquals("incorrect number of elements", 1, apps.length());
JSONObject jsonObject = apps.getJSONArray("app").getJSONObject(0).getJSONObject("resourceInfo");
JSONArray jsonArray = jsonObject.getJSONArray("resourceUsagesByPartition");
assertEquals("Partition expected is 2", 2, jsonArray.length());
// Default partition resource
JSONObject defaultPartition = jsonArray.getJSONObject(0);
verifyResource(defaultPartition, "", getResource(1024, 1), getResource(1024, 1), getResource(0, 0));
// verify resource used for parition x
JSONObject paritionX = jsonArray.getJSONObject(1);
verifyResource(paritionX, "X", getResource(0, 0), getResource(1024, 1), getResource(0, 0));
rm.stop();
}
use of com.sun.jersey.api.client.ClientResponse in project hadoop by apache.
the class TestRMWebServices method testClusterSlash.
@Test
public void testClusterSlash() throws JSONException, Exception {
WebResource r = resource();
// test with trailing "/" to make sure acts same as without slash
ClientResponse response = r.path("ws").path("v1").path("cluster/").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
verifyClusterInfo(json);
}
use of com.sun.jersey.api.client.ClientResponse in project hadoop by apache.
the class TestRMWebServices method testInfoXML.
@Test
public void testInfoXML() throws JSONException, Exception {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster").path("info").accept("application/xml").get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8, response.getType().toString());
String xml = response.getEntity(String.class);
verifyClusterInfoXML(xml);
}
Aggregations