MemoryPoolAssigner { public MemoryChunk allocateChunk() throws MemoryAllocationException { return memoryPool.requestChunkFromPool(); } @Inject  MemoryPoolAssigner(@Parameter(JobConf.ExecutorMemoryMb.class) final int memory,
                            @Parameter(JobConf.MaxOffheapRatio.class) final double maxOffheapRatio,
                            @Parameter(JobConf.ChunkSizeKb.class) final int chunkSizeKb); MemoryChunk allocateChunk(); void returnChunksToPool(final Iterable<MemoryChunk> target); int getChunkSize();  }
@Test(expected = MemoryAllocationException.class) public void testTooMuchRequest() throws MemoryAllocationException { List<MemoryChunk> chunkList = new LinkedList<>(); for (int i = 0; i < MAX_NUM_CHUNKS; i++) { chunkList.add(memoryPoolAssigner.allocateChunk()); } memoryPoolAssigner.allocateChunk(); }