@Test public void testBucketAllocator() throws BucketAllocatorException { BucketAllocator mAllocator = cache.getAllocator(); /* * Test the allocator first */ int[] blockSizes = new int[2]; blockSizes[0] = 4 * 1024; blockSizes[1] = 8 * 1024; boolean full = false; int i = 0; ArrayList<Long> allocations = new ArrayList<Long>(); // Fill the allocated extents while (!full) { try { allocations.add(new Long(mAllocator.allocateBlock(blockSizes[i % blockSizes.length]))); ++i; } catch (CacheFullException cfe) { full = true; } } for (i = 0; i < blockSizes.length; i++) { BucketSizeInfo bucketSizeInfo = mAllocator .roundUpToBucketSizeInfo(blockSizes[0]); IndexStatistics indexStatistics = bucketSizeInfo.statistics(); assertTrue(indexStatistics.freeCount() == 0); } for (long offset : allocations) { assertTrue(mAllocator.sizeOfAllocation(offset) == mAllocator .freeBlock(offset)); } assertTrue(mAllocator.getUsedSize() == 0); }