@Test
  public void testReaderBlockAllocationWithLRUCache() throws IOException {
    // false because caching is fully enabled
    testReaderBlockAllocationWithLRUCache(true, true, null, false);
    // false because we only look at cache config when expectedBlockType is non-null
    testReaderBlockAllocationWithLRUCache(false, true, null, false);
    // false because cacheBlock is true and even with cache config is disabled, we still cache
    // important blocks like indexes
    testReaderBlockAllocationWithLRUCache(false, true, BlockType.INTERMEDIATE_INDEX, false);
    // true because since it's a DATA block, we honor the cache config
    testReaderBlockAllocationWithLRUCache(false, true, BlockType.DATA, true);
    // true for the following 2 because cacheBlock takes precedence over cache config
    testReaderBlockAllocationWithLRUCache(true, false, null, true);
    testReaderBlockAllocationWithLRUCache(true, false, BlockType.INTERMEDIATE_INDEX, false);
    // false for the following 3 because both cache config and cacheBlock are false.
    // per above, INDEX would supersede cache config, but not cacheBlock
    testReaderBlockAllocationWithLRUCache(false, false, null, true);
    testReaderBlockAllocationWithLRUCache(false, false, BlockType.INTERMEDIATE_INDEX, true);
    testReaderBlockAllocationWithLRUCache(false, false, BlockType.DATA, true);
  }
Tests that we properly allocate from the off-heap or on-heap when LRUCache is configured. In
this case, the determining factor is whether we end up caching the block or not. So the below
test cases try different permutations of enabling/disabling via CacheConfig and via user
request (cacheblocks), along with different expected block types.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java