ProxyOutputStream extends OutputStream { public void flush() throws IOException { if ( parent != null ) { parent.flush(); } } ProxyOutputStream(); OutputStream getParent(); void setParent( final OutputStream parent ); 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();  }
@Test public void testFlush() throws Exception { OutputStream outputStream = mock( OutputStream.class ); stream.setParent( outputStream ); stream.flush(); verify( outputStream, times( 1 ) ).flush(); }