### Question:
ClientOutputStream extends OutputStream { @Override public void write(int b) throws IOException { remote.write(b); } ClientOutputStream(RemoteOutputStream out); @Override void close(); @Override void flush(); @Override void write(int b); @Override void write(byte[] buf); @Override void write(byte[] buf, int off, int len);  }### Answer:
@Test public void testWriteInt() throws IOException { bo.reset(); co.write('a'); byte[] b = bo.toByteArray(); assertNotNull(b); assertEquals(1, b.length); assertEquals('a', b[0]); }
@Test public void testWriteByteArray() throws IOException { bo.reset(); byte[] in = "Hello World".getBytes(); co.write(in); byte[] b = bo.toByteArray(); assertNotNull(b); assertEquals(in, b); bo.reset(); in = new byte[0]; co.write(in); b = bo.toByteArray(); assertNotNull(b); assertEquals(in, b); }
@Test public void testWriteByteArrayIntInt() throws IOException { bo.reset(); byte[] in = "Hello World".getBytes(); byte[] pb = new byte[in.length * 3]; System.arraycopy(in, 0, pb, in.length, in.length); co.write(pb, in.length, in.length); byte[] b = bo.toByteArray(); assertNotNull(b); assertEquals(in, b); byte[] r = new byte[100]; bogusIndex(r, -1, 10); bogusIndex(r, 10, -1); bogusIndex(r, -1, -1); bogusIndex(r, 50, 51); bogusIndex(r, 101, 1); bogusIndex(r, 0, 101); co.write(pb, in.length, 0); b = bo.toByteArray(); assertNotNull(b); assertEquals(in, b); }