### Question:
WriterOutputStream extends OutputStream { @Override public void write( int b ) throws IOException { write( new byte[] { (byte) b, } ); } WriterOutputStream( Writer writer );  WriterOutputStream( Writer writer, String encoding ); @Override void write( int b ); @Override void write( byte[] b, int off, int len ); @Override void write( byte[] b ); @Override void close(); @Override void flush(); Writer getWriter(); String getEncoding();  }### Answer:
@Test public void testWrite() throws IOException { WriterOutputStream stream = new WriterOutputStream( writer ); stream.write( 68 ); stream.write( "value".getBytes(), 1, 3 ); stream.write( "value".getBytes() ); stream.flush(); stream.close(); verify( writer ).append( new String( new byte[] { (byte) 68 } ) ); verify( writer ).append( "alu" ); verify( writer ).append( "value" ); verify( writer ).flush(); verify( writer ).close(); assertNull( stream.getWriter() ); writer = mock( Writer.class ); WriterOutputStream streamWithEncoding = new WriterOutputStream( writer, encoding ); streamWithEncoding.write( "value".getBytes( encoding ) ); verify( writer ).append( "value" ); }