### Question:
HeapBuffer extends ByteBufferBuffer { public static HeapBuffer allocate() { return allocate(DEFAULT_INITIAL_CAPACITY, MAX_SIZE); } protected  HeapBuffer(HeapBytes bytes, int offset, int initialCapacity, int maxCapacity); static HeapBuffer allocate(); static HeapBuffer allocate(int initialCapacity); static HeapBuffer allocate(int initialCapacity, int maxCapacity); static HeapBuffer wrap(byte[] bytes); @Override boolean hasArray(); @Override HeapBuffer duplicate();  }### Answer:
@Test public void testHeapToDirectBuffer() { HeapBuffer heapBuffer = HeapBuffer.allocate(8); heapBuffer.writeLong(10); heapBuffer.flip(); DirectBuffer directBuffer = DirectBuffer.allocate(8); directBuffer.write(heapBuffer.array()); directBuffer.flip(); assertEquals(directBuffer.readLong(), heapBuffer.readLong()); directBuffer.release(); }