@Test
    public void ensureCapacityTest() {
        ByteBuffer byteBuffer = ByteBuffer.allocate(10);
        ByteBuffer newByteBuffer = Utils.ensureCapacity(byteBuffer, 5);
        assertEquals(10, newByteBuffer.capacity());

        ByteBuffer byteBuffer2 = ByteBuffer.allocate(10);
        ByteBuffer newByteBuffer2 = Utils.ensureCapacity(byteBuffer2, 15);
        assertEquals(15, newByteBuffer2.capacity());

        ByteBuffer byteBuffer3 = ByteBuffer.allocate(10);
        for (int i = 1; i <= 10; i++) {
            byteBuffer3.put((byte) i);
        }
        ByteBuffer newByteBuffer3 = Utils.ensureCapacity(byteBuffer3, 15);
        newByteBuffer3.flip();
        assertEquals(15, newByteBuffer3.capacity());
        assertEquals(1, newByteBuffer3.get());
        assertEquals(2, newByteBuffer3.get());
        assertEquals(3, newByteBuffer3.get());
    }
Test to read content of named pipe as string. As reading/writing to a pipe can block,
timeout test after a minute (test finishes within 100 ms normally).
clients/src/test/java/org/apache/kafka/common/utils/UtilsTest.java