@Test public void testWriterEncoding() throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); DummyResponse dummyResponse = new DummyResponse(); dummyResponse.setCharacterEncoding(characterEncoding); dummyResponse.setOutputStream(new DummyServletOutputStream(byteArrayOutputStream)); TeeHttpServletResponse teeServletResponse = new TeeHttpServletResponse(dummyResponse); PrintWriter writer = teeServletResponse.getWriter(); writer.write(testString); writer.flush(); assertArrayEquals(expectedBytes, byteArrayOutputStream.toByteArray()); }
@Override public PrintWriter getWriter() throws IOException { if (this.teeWriter == null) { this.teeWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), this.getResponse().getCharacterEncoding()), true); } return this.teeWriter; }
TeeHttpServletResponse extends HttpServletResponseWrapper { @Override public PrintWriter getWriter() throws IOException { if (this.teeWriter == null) { this.teeWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), this.getResponse().getCharacterEncoding()), true); } return this.teeWriter; } }
TeeHttpServletResponse extends HttpServletResponseWrapper { @Override public PrintWriter getWriter() throws IOException { if (this.teeWriter == null) { this.teeWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), this.getResponse().getCharacterEncoding()), true); } return this.teeWriter; } TeeHttpServletResponse(HttpServletResponse httpServletResponse); }
TeeHttpServletResponse extends HttpServletResponseWrapper { @Override public PrintWriter getWriter() throws IOException { if (this.teeWriter == null) { this.teeWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), this.getResponse().getCharacterEncoding()), true); } return this.teeWriter; } TeeHttpServletResponse(HttpServletResponse httpServletResponse); @Override ServletOutputStream getOutputStream(); @Override PrintWriter getWriter(); @Override void flushBuffer(); }
TeeHttpServletResponse extends HttpServletResponseWrapper { @Override public PrintWriter getWriter() throws IOException { if (this.teeWriter == null) { this.teeWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), this.getResponse().getCharacterEncoding()), true); } return this.teeWriter; } TeeHttpServletResponse(HttpServletResponse httpServletResponse); @Override ServletOutputStream getOutputStream(); @Override PrintWriter getWriter(); @Override void flushBuffer();  }