@Test
  public void testCachingSameKeyTwice() {
    mCache =
        createDummyAdaptiveCountingMemoryCache(
            mParamsSupplier,
            mCacheTrimStrategy,
            mValueDescriptor,
            100,
            1,
            2,
            initialLFUCacheFractionPromil);
    CloseableReference<Integer> originalRef1 = newReference(110);
    CloseableReference<Integer> cachedRef1 = mCache.cache(KEY, originalRef1);
    CloseableReference<Integer> cachedRef2a = mCache.get(KEY);
    CloseableReference<Integer> cachedRef2b = cachedRef2a.clone();
    CloseableReference<Integer> cachedRef3 = mCache.get(KEY);
    AbstractAdaptiveCountingMemoryCache.Entry<String, Integer> entry1 =
        mCache.mCachedEntries.get(KEY);

    CloseableReference<Integer> cachedRef2 = mCache.cache(KEY, newReference(120));
    AbstractAdaptiveCountingMemoryCache.Entry<String, Integer> entry2 =
        mCache.mCachedEntries.get(KEY);
    assertNotSame(entry1, entry2);
    assertOrphanWithCount(entry1, 3);
    assertSharedWithCount(KEY, 120, 1);

    // release the orphaned reference only when all clients are gone
    originalRef1.close();
    cachedRef2b.close();
    assertOrphanWithCount(entry1, 3);
    cachedRef2a.close();
    assertOrphanWithCount(entry1, 2);
    cachedRef1.close();
    assertOrphanWithCount(entry1, 1);
    verify(mReleaser, never()).release(anyInt());
    cachedRef3.close();
    assertOrphanWithCount(entry1, 0);
    verify(mReleaser).release(110);
  }
test: pass illegal adaptive rate and illegal initial LFU cache fraction. expected result: fall
back and use the default adaptive rate and initial LFU fraction values.
imagepipeline-base/src/test/java/com/facebook/imagepipeline/cache/AbstractAdaptiveCountingMemoryCacheTest.java