ExternalWriterHttpServletResponse extends
        HttpServletResponseWrapper { @Override public PrintWriter getWriter() { return writer; } ExternalWriterHttpServletResponse(HttpServletResponse response, PrintWriter writer); @Override PrintWriter getWriter();  }
@Test public void testGetWriter() { HttpServletResponse wrappedResponse = createMock(HttpServletResponse.class); Writer writer = new StringWriter(); PrintWriter printWriter = new PrintWriter(writer); replay(wrappedResponse); ExternalWriterHttpServletResponse response = new ExternalWriterHttpServletResponse( wrappedResponse, printWriter); assertEquals(printWriter, response.getWriter()); verify(wrappedResponse); }