Search in sources :

Example 1 with AuthorizationException

use of org.nhindirect.common.rest.exceptions.AuthorizationException in project nhin-d by DirectProject.

the class UnsecuredServiceRequestBase_handleUnauthorizedTest method testHandleUnauthorized_noHeaders_assertAuthorizationException.

@Test
public void testHandleUnauthorized_noHeaders_assertAuthorizationException() throws Exception {
    MockServiceRequest req = new MockServiceRequest(null, "http://service/svc", "Test");
    HttpResponse resp = mock(HttpResponse.class);
    AuthorizationException ex = req.handleUnauthorized(resp);
    assertEquals("Action not authorized", ex.getMessage());
}
Also used : AuthorizationException(org.nhindirect.common.rest.exceptions.AuthorizationException) HttpResponse(org.apache.http.HttpResponse) Test(org.junit.Test)

Example 2 with AuthorizationException

use of org.nhindirect.common.rest.exceptions.AuthorizationException in project nhin-d by DirectProject.

the class UnsecuredServiceRequestBase_interpretResponseTest method testInterpretResponseTest_401Status_assertAuthorizationException.

@Test
public void testInterpretResponseTest_401Status_assertAuthorizationException() throws Exception {
    MockServiceRequest req = new MockServiceRequest(null, "http://service/svc", "Test");
    HttpResponse resp = mock(HttpResponse.class);
    boolean exceptionOccured = false;
    try {
        req.interpretResponse(401, resp);
    } catch (AuthorizationException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : AuthorizationException(org.nhindirect.common.rest.exceptions.AuthorizationException) HttpResponse(org.apache.http.HttpResponse) Test(org.junit.Test)

Aggregations

HttpResponse (org.apache.http.HttpResponse)2 Test (org.junit.Test)2 AuthorizationException (org.nhindirect.common.rest.exceptions.AuthorizationException)2