@Test public void shouldThrowResultExceptionIfAnIOExceptionWhenWriteInputStreamBody() throws Exception { doThrow(new IOException()).when(response).getOutputStream(); InputStream in = new ByteArrayInputStream("the text".getBytes()); try { httpResult.body(in); fail("should throw ResultException"); } catch (ResultException e) { } }
public HttpResult body(String body) { try { response.getWriter().print(body); } catch (IOException e) { throw new ResultException(COULD_NOT_WRITE_TO_RESPONSE_BODY, e); } return this; }
DefaultHttpResult implements HttpResult { public HttpResult body(String body) { try { response.getWriter().print(body); } catch (IOException e) { throw new ResultException(COULD_NOT_WRITE_TO_RESPONSE_BODY, e); } return this; } }
DefaultHttpResult implements HttpResult { public HttpResult body(String body) { try { response.getWriter().print(body); } catch (IOException e) { throw new ResultException(COULD_NOT_WRITE_TO_RESPONSE_BODY, e); } return this; } DefaultHttpResult(HttpServletResponse response, Status status); }
DefaultHttpResult implements HttpResult { public HttpResult body(String body) { try { response.getWriter().print(body); } catch (IOException e) { throw new ResultException(COULD_NOT_WRITE_TO_RESPONSE_BODY, e); } return this; } 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 HttpResult body(String body) { try { response.getWriter().print(body); } catch (IOException e) { throw new ResultException(COULD_NOT_WRITE_TO_RESPONSE_BODY, e); } return this; } 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);  }