@Test
    public void testCantAllocateMoreMemoryThanWeHave() throws Exception {
        BufferPool pool = new BufferPool(1024, 512, metrics, time, metricGroup);
        ByteBuffer buffer = pool.allocate(1024, maxBlockTimeMs);
        assertEquals(1024, buffer.limit());
        pool.deallocate(buffer);
        assertThrows(IllegalArgumentException.class, () -> pool.allocate(1025, maxBlockTimeMs));
    }
Test that we cannot try to allocate more memory than we have in the whole pool
clients/src/test/java/org/apache/kafka/clients/producer/internals/BufferPoolTest.java