@Test
public void testAuthorizeFailure() {

    HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
    HttpServletResponse httpServletResponse = Mockito.mock(HttpServletResponse.class);
    Authorizer authorizer = Mockito.mock(Authorizer.class);
    Http.AuthorityList authorities = new Http.AuthorityList();
    ResourceContext context = new ResourceContext(httpServletRequest, httpServletResponse,
            authorities, authorizer);
    try {
        context.authorize("action", "resource", "domain");
    } catch (ResourceException expected) {
        assertEquals(expected.getCode(), 401);
    }
}