use of com.sun.jersey.api.client.UniformInterfaceException in project hadoop by apache.
the class TestAHSWebServices method testInvalidAccept.
@Test
public void testInvalidAccept() throws JSONException, Exception {
WebResource r = resource();
String responseStr = "";
try {
responseStr = r.path("ws").path("v1").path("applicationhistory").queryParam("user.name", USERS[round]).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.UniformInterfaceException in project hadoop by apache.
the class TestAHSWebServices method testInvalidUri.
@Test
public void testInvalidUri() throws JSONException, Exception {
WebResource r = resource();
String responseStr = "";
try {
responseStr = r.path("ws").path("v1").path("applicationhistory").path("bogus").queryParam("user.name", USERS[round]).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.UniformInterfaceException in project hadoop by apache.
the class TestHsWebServices method testInvalidUri2.
@Test
public void testInvalidUri2() throws JSONException, Exception {
WebResource r = resource();
String responseStr = "";
try {
responseStr = r.path("ws").path("v1").path("invalid").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.UniformInterfaceException in project OpenAM by OpenRock.
the class RestTest method missingResourcesTest.
@Test
public void missingResourcesTest() throws Exception {
Form params = new Form();
params.add("subject", hashedUserTokenId);
params.add("action", "GET");
params.add("env", ATTR_NAME + "=" + ATTR_VAL);
params.add("realm", REALM);
try {
decisionsClient.queryParams(params).header(RestServiceManager.SUBJECT_HEADER_NAME, userTokenIdHeader).cookie(cookie).accept("application/json").get(String.class);
throw new Exception("RESTTest.missingResourceTest: no exception thrown.");
} catch (UniformInterfaceException e) {
int errorCode = e.getResponse().getStatus();
if (errorCode != 400) {
throw new Exception("RESTTest.missingResourceTest: incorrect error code");
}
String json = e.getResponse().getEntity(String.class);
JSONObject jo = new JSONObject(json);
if (jo.optInt("statusCode") != 424) {
throw new Exception("RESTTest.missingResourcesTest() failed, status code not 424");
}
if (jo.optJSONObject("body") != null) {
throw new Exception("RESTTest.missingResourcesTest() failed, body not empty");
}
}
}
use of com.sun.jersey.api.client.UniformInterfaceException in project OpenAM by OpenRock.
the class PrivilegeRestTest method noJSONStringInPut.
private void noJSONStringInPut() throws Exception {
try {
Form form = new Form();
webClient.path(PRIVILEGE_NAME).queryParam("subject", hashedTokenId).header(RestServiceManager.SUBJECT_HEADER_NAME, tokenIdHeader).cookie(cookie).put(String.class, form);
} catch (UniformInterfaceException e) {
validateUniformInterfaceException(e, 9, "noJSONStringInPut");
}
}
Aggregations