@Test public void testWriteToOutputStream() throws Exception{ ServletOutputStream sos = response.getOutputStream(); sos.write(TEST_STRING.getBytes()); sos.close(); streamBytes.flip(); Assert.assertEquals("Expected output in GZIP.", TEST_STRING_IN_GZIP, streamBytes); }
@Override public ServletOutputStream getOutputStream() throws IOException{ if(returnedWriter != null){ throw new IllegalStateException("Method getWriter() has already been called."); } if(returnedStream == null){ returnedStream = new GzipServletOutputStream(super.getOutputStream()); } return returnedStream; }
GzipMessageResponse extends HttpServletResponseWrapper { @Override public ServletOutputStream getOutputStream() throws IOException{ if(returnedWriter != null){ throw new IllegalStateException("Method getWriter() has already been called."); } if(returnedStream == null){ returnedStream = new GzipServletOutputStream(super.getOutputStream()); } return returnedStream; } }
GzipMessageResponse extends HttpServletResponseWrapper { @Override public ServletOutputStream getOutputStream() throws IOException{ if(returnedWriter != null){ throw new IllegalStateException("Method getWriter() has already been called."); } if(returnedStream == null){ returnedStream = new GzipServletOutputStream(super.getOutputStream()); } return returnedStream; } GzipMessageResponse(HttpServletResponse response); }
GzipMessageResponse extends HttpServletResponseWrapper { @Override public ServletOutputStream getOutputStream() throws IOException{ if(returnedWriter != null){ throw new IllegalStateException("Method getWriter() has already been called."); } if(returnedStream == null){ returnedStream = new GzipServletOutputStream(super.getOutputStream()); } return returnedStream; } GzipMessageResponse(HttpServletResponse response); @Override ServletOutputStream getOutputStream(); @Override PrintWriter getWriter(); }
GzipMessageResponse extends HttpServletResponseWrapper { @Override public ServletOutputStream getOutputStream() throws IOException{ if(returnedWriter != null){ throw new IllegalStateException("Method getWriter() has already been called."); } if(returnedStream == null){ returnedStream = new GzipServletOutputStream(super.getOutputStream()); } return returnedStream; } GzipMessageResponse(HttpServletResponse response); @Override ServletOutputStream getOutputStream(); @Override PrintWriter getWriter();  }