TrackingOutputStream extends OutputStream { public void close() throws IOException { wrappedStream.close(); } TrackingOutputStream( final OutputStream wrapped ); void write( final int b ); void write( final byte[] b ); void write( final byte[] b, final int off, final int len ); void flush(); void close(); OutputStream getWrappedStream(); int getTrackingSize();  }
@Test public void testClose() throws Exception { streamSpy.close(); verify( streamSpy, times( 1 ) ).close(); }