### Question:
BufferedOutputStreamSliceOutput extends SliceOutput { @Override public void writeBytes(Slice source) { writeBytes(source, 0, source.length()); } BufferedOutputStreamSliceOutput(OutputStream outputStream); @Override void flush(); @Override void close(); @Override void reset(); @Override void reset(int position); @Override int size(); @Override long getRetainedSize(); @Override int writableBytes(); @Override boolean isWritable(); @Override void writeByte(int value); @Override void writeShort(int value); @Override void writeInt(int value); @Override void writeLong(long value); @Override void writeFloat(float value); @Override void writeDouble(double value); @Override void writeBytes(Slice source); @Override void writeBytes(Slice source, int sourceIndex, int length); @Override void writeBytes(byte[] source); @Override void writeBytes(byte[] source, int sourceIndex, int length); @Override void writeBytes(InputStream in, int length); @Override void writeZero(int length); @Override SliceOutput appendLong(long value); @Override SliceOutput appendDouble(double value); @Override SliceOutput appendInt(int value); @Override SliceOutput appendShort(int value); @Override SliceOutput appendByte(int value); @Override SliceOutput appendBytes(byte[] source, int sourceIndex, int length); @Override SliceOutput appendBytes(byte[] source); @Override SliceOutput appendBytes(Slice slice); @Override Slice slice(); @Override Slice getUnderlyingSlice(); @Override String toString(Charset charset); @Override String toString();  }### Answer:
@Test public void testWriteBytes() throws Exception { int length = 65536; byte[] inputArray = new byte[length]; for (int i = 0; i < length; i++) { inputArray[i] = (byte) (i % 128); } int[] offsets = {0, 100, 545, 1024, 2049, 2050, 2051, 2151, 10480, 20042, 20100, 40001, 65536}; MockOutputStream byteOutputStream = new MockOutputStream(length); BufferedOutputStreamSliceOutput output = new BufferedOutputStreamSliceOutput(byteOutputStream); for (int i = 0; i < offsets.length - 1; i++) { output.writeBytes(inputArray, offsets[i], offsets[i + 1] - offsets[i]); } output.flush(); assertEquals(byteOutputStream.toByteArray(), inputArray); byteOutputStream.close(); byteOutputStream = new MockOutputStream(length); Slice inputSlice = Slices.wrappedBuffer(inputArray); output = new BufferedOutputStreamSliceOutput(byteOutputStream); for (int i = 0; i < offsets.length - 1; i++) { output.writeBytes(inputSlice, offsets[i], offsets[i + 1] - offsets[i]); } output.flush(); assertEquals(byteOutputStream.toByteArray(), inputArray); byteOutputStream.close(); }