@Test public void shouldThrowResultExceptionIfAnIOExceptionWhenSendErrorWithMessage() throws Exception { doThrow(new IOException()).when(response).sendError(anyInt(), anyString()); try { httpResult.sendError(SC_INTERNAL_SERVER_ERROR, "A simple message"); fail("should throw ResultException"); } catch (ResultException e) { verify(response, only()).sendError(anyInt(), anyString()); } }
public void sendError(int statusCode) { try { response.sendError(statusCode); } catch (IOException e) { throw new ResultException("Error while setting status code", e); } }
DefaultHttpResult implements HttpResult { public void sendError(int statusCode) { try { response.sendError(statusCode); } catch (IOException e) { throw new ResultException("Error while setting status code", e); } } }
DefaultHttpResult implements HttpResult { public void sendError(int statusCode) { try { response.sendError(statusCode); } catch (IOException e) { throw new ResultException("Error while setting status code", e); } } DefaultHttpResult(HttpServletResponse response, Status status); }
DefaultHttpResult implements HttpResult { public void sendError(int statusCode) { try { response.sendError(statusCode); } catch (IOException e) { throw new ResultException("Error while setting status code", e); } } DefaultHttpResult(HttpServletResponse response, Status status); HttpResult addDateHeader(String name, long date); HttpResult addHeader(String name, String value); HttpResult addIntHeader(String name, int value); void sendError(int statusCode); void sendError(int statusCode, String message); void setStatusCode(int statusCode); void movedPermanentlyTo(String uri); T movedPermanentlyTo(final Class<T> controller); HttpResult body(String body); HttpResult body(InputStream body); HttpResult body(Reader body); }
DefaultHttpResult implements HttpResult { public void sendError(int statusCode) { try { response.sendError(statusCode); } catch (IOException e) { throw new ResultException("Error while setting status code", e); } } DefaultHttpResult(HttpServletResponse response, Status status); HttpResult addDateHeader(String name, long date); HttpResult addHeader(String name, String value); HttpResult addIntHeader(String name, int value); void sendError(int statusCode); void sendError(int statusCode, String message); void setStatusCode(int statusCode); void movedPermanentlyTo(String uri); T movedPermanentlyTo(final Class<T> controller); HttpResult body(String body); HttpResult body(InputStream body); HttpResult body(Reader body);  }