@Override
    public void copyTo(byte[] dest, int destPos) {
        if (totalSize() > 0) {
            System.arraycopy(payload, 0, dest, destPos, payload.length);
        }
    }
@Test
    public void copyTo() {
        byte[] inputBytes = "12345678890".getBytes();
        HeapData heap = new HeapData(inputBytes);
        byte[] bytes = new byte[inputBytes.length];
        heap.copyTo(bytes, 0);

        assertEquals(new String(inputBytes), new String(bytes));
    }