// Verify correctly calculated cache heap size
assertEquals(expectedCacheSize, cache.heapSize());
// Check if all blocks are properly cached and retrieved
for (CachedItem block : blocks) {
HeapSize buf = cache.getBlock(block.cacheKey, true, false);
assertTrue(buf != null);
assertEquals(buf.heapSize(), block.heapSize());
}
// Re-add same blocks and ensure nothing has changed
for (CachedItem block : blocks) {
try {
cache.cacheBlock(block.cacheKey, block);
assertTrue("Cache should not allow re-caching a block", false);
} catch(RuntimeException re) {
// expected
}
}
// Verify correctly calculated cache heap size
assertEquals(expectedCacheSize, cache.heapSize());
// Check if all blocks are properly cached and retrieved
for (CachedItem block : blocks) {
HeapSize buf = cache.getBlock(block.cacheKey, true, false);
assertTrue(buf != null);
assertEquals(buf.heapSize(), block.heapSize());
}
// Expect no evictions
assertEquals(0, cache.getEvictionCount());
Thread t = new LruBlockCache.StatisticsThread(cache);