CounterServletResponseWrapper extends FilterServletResponseWrapper { public long getDataLength() { return getCounterResponseStream() == null ? 0 : getCounterResponseStream().getDataLength(); } CounterServletResponseWrapper(HttpServletResponse response); long getDataLength(); @Override void reset(); @Override void resetBuffer(); @Override ServletOutputStream createOutputStream();  }
@Test public void testCounterResponseStream() throws IOException { final CounterResponseStream wrapper = new CounterResponseStream(new HttpResponse()); wrapper.write(1); wrapper.write(new byte[8]); wrapper.write(new byte[8], 1, 7); assertEquals("dataLength", 16, wrapper.getDataLength()); wrapper.isReady(); wrapper.setWriteListener(null); wrapper.flush(); wrapper.close(); }