use of com.sun.jersey.api.client.UniformInterfaceException in project OpenAM by OpenRock.
the class PrivilegeRestTest method noJSONStringInPost.
private void noJSONStringInPost() throws Exception {
Form form = new Form();
form.add("subject", hashedTokenId);
try {
webClient.header(RestServiceManager.SUBJECT_HEADER_NAME, tokenIdHeader).cookie(cookie).post(String.class, form);
} catch (UniformInterfaceException e) {
validateUniformInterfaceException(e, 9, "noJSONStringInPost");
}
}
use of com.sun.jersey.api.client.UniformInterfaceException in project OpenAM by OpenRock.
the class OAuthServiceUtils method getUUIDByTokenId.
public static String getUUIDByTokenId(String tokenId) throws OAuthServiceException {
String uuid;
MultivaluedMapImpl params = new MultivaluedMapImpl();
params.add(SUBJECT_ID, tokenId);
params.add("attributenames", UUID_SESSION_PROPERTY_NAME);
String response;
try {
response = attributesResource.queryParams(params).get(String.class);
} catch (UniformInterfaceException uie) {
throw new OAuthServiceException("Get uuid failed", uie);
}
if (response == null) {
return null;
}
int index = response.indexOf(USERDETAILS_NAME_KEY + "=" + UUID_SESSION_PROPERTY_NAME);
index = response.indexOf(USERDETAILS_VALUE_KEY + "=", index);
int startIdx = index + USERDETAILS_VALUE_KEY.length() + 1;
int idx = response.indexOf(USERDETAILS_NAME_KEY + "=", startIdx);
int endIdx;
if (idx > 0) {
endIdx = idx;
} else {
endIdx = response.length() - 1;
}
uuid = response.substring(startIdx, endIdx).trim();
return uuid;
}
use of com.sun.jersey.api.client.UniformInterfaceException in project apex-core by apache.
the class StramWebServicesTest method testInvalidUri.
@Test
@SuppressWarnings("UnusedAssignment")
public void testInvalidUri() throws JSONException, Exception {
WebResource r = resource();
String responseStr = "";
try {
responseStr = r.path(StramWebServices.PATH).path("bogus").accept(MediaType.APPLICATION_JSON).get(String.class);
fail("should have thrown exception on invalid uri");
} catch (UniformInterfaceException ue) {
ClientResponse response = ue.getResponse();
assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
StramTestSupport.checkStringMatch("error string exists and shouldn't", "", responseStr);
}
}
use of com.sun.jersey.api.client.UniformInterfaceException in project apex-core by apache.
the class StramWebServicesTest method testInvalidUri2.
@Test
@SuppressWarnings("UnusedAssignment")
public void testInvalidUri2() throws JSONException, Exception {
WebResource r = resource();
String responseStr = "";
try {
responseStr = r.path("ws").path("v2").path("invalid").accept(MediaType.APPLICATION_JSON).get(String.class);
fail("should have thrown exception on invalid uri");
} catch (UniformInterfaceException ue) {
ClientResponse response = ue.getResponse();
assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
StramTestSupport.checkStringMatch("error string exists and shouldn't", "", responseStr);
}
}
Aggregations