Code example for PrintWriter

Methods: write

0
  private HttpServletResponse createHttpResponse(String header1, String header2,
      String contentType, String response, int httpStatusCode) throws IOException {
    HttpServletResponse result = createMock(HttpServletResponse.class);
    PrintWriter writer = createMock(PrintWriter.class);
    if (response != null) {
      expect(result.getWriter()).andReturn(writer);
      writer.write(response);
    } 
    if (header1 != null && header2 != null) {
      result.setHeader(header1, header2);
    } 
    if (contentType != null) {
      result.setContentType(contentType);
    } 
    result.setStatus(httpStatusCode);
    replay(result, writer);
    return result;
  } 
}