@Test
public void toArrayWithExtraCapacity() throws BufferException {

    ByteBuffer buffer = new ByteBuffer(TEST_BYTES1, TEST_BYTES1.length+20);
    byte[] copyArray = buffer.toArray();
    Assert.assertArrayEquals(TEST_BYTES1, copyArray);
    // validate our returned buffer isn't larger capacity
    Assert.assertEquals(TEST_BYTES1.length, copyArray.length);
}