public void write(final int b)
    {
        if (position == length)
        {
            throw new IllegalStateException("position has reached the end of underlying buffer");
        }

        buffer.putByte(offset + position, (byte)b);
        ++position;
    }
@Test
    void shouldWriteByteArray()
    {
        final byte[] data = new byte[2];
        final DirectBufferOutputStream outputStream = new DirectBufferOutputStream(new UnsafeBuffer(data));

        final byte[] source = { 1, 2 };
        outputStream.write(source);

        assertArrayEquals(source, data);
    }