@Test
public void writesThroughToBuffer() throws IOException {

    final int expectedCount = 11;
    final ByteBuffer buffer = ByteBuffer.allocate(expectedCount);
    final ByteBufferOutputStream outputStream = new ByteBufferOutputStream(buffer);
    for (int i = 0; i < 5; i++) {
        outputStream.write(i);
    }
    outputStream.write(new byte[]{7,8,9});
    outputStream.write(new byte[]{10,11,12,13,14}, 1, 3);
    Assertions.assertThat(buffer.position()).isEqualTo(expectedCount);
}