WrappedOutputStream extends ServletOutputStream { public long getContentLength() { return contentLength; } WrappedOutputStream(OutputStream out); long getContentLength(); @Override void write(int b); @Override void write(byte[] b); @Override void write(byte[] b, int off, int len); @Override void close(); @Override void flush();  }
@Test public void emptyStreamReportsMinusOneBytes() throws Exception { assertThat(wrapper.getContentLength(), is(-1L)); }
@Test public void printingAsciiStringAddsLengthToByteCount() throws Exception { wrapper.print("Testing"); assertThat(wrapper.getContentLength(), is(7L)); }