ProxyOutputStream extends OutputStream { public void write( final int b ) throws IOException { if ( parent != null ) { parent.write( b ); } } 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 testWrite() throws Exception { OutputStream outputStream = mock( OutputStream.class ); stream.setParent( outputStream ); stream.write( 1 ); stream.write( new byte[] { 1 } ); stream.write( new byte[] { 1 }, 0, 3 ); verify( outputStream, times( 1 ) ).write( anyInt() ); verify( outputStream, times( 1 ) ).write( any( byte[].class ) ); verify( outputStream, times( 1 ) ).write( any( byte[].class ), anyInt(), anyInt() ); }