CounterServletResponseWrapper extends FilterServletResponseWrapper { public CounterServletResponseWrapper(HttpServletResponse response) { super(response); assert response != null; } CounterServletResponseWrapper(HttpServletResponse response); long getDataLength(); @Override void reset(); @Override void resetBuffer(); @Override ServletOutputStream createOutputStream();  }
@Test public void testCounterServletResponseWrapper() throws IOException { final CounterServletResponseWrapper wrapper = new CounterServletResponseWrapper( new HttpResponse()); wrapper.reset(); wrapper.resetBuffer(); wrapper.createOutputStream(); wrapper.getOutputStream().write(new byte[8]); assertEquals("dataLength", 8, wrapper.getDataLength()); wrapper.reset(); assertEquals("dataLength with reset", 0, wrapper.getDataLength()); wrapper.getOutputStream().write(new byte[8]); wrapper.resetBuffer(); assertEquals("dataLength with resetBuffer", 0, wrapper.getDataLength()); }