}
@Test
public void testFilesCacheSize() {
final int MAX_CAPACITY = 16;
FilesCache cache = new FilesCache(MAX_CAPACITY);
for (int index = 0; index < 2 * MAX_CAPACITY; index++) {
CacheKey key = CacheKey.getFileKey(Mockito.mock(Closeable.class));
assertNull("Multiple mappings for " + key, cache.put(key, String.valueOf(index)));
if (index < MAX_CAPACITY) {
assertEquals("Mismatched pre-populated cache size", index + 1, cache.size());
} else {
assertEquals("Mismatched post-populated cache size", MAX_CAPACITY, cache.size());
assertTrue("Last value was bumped unpexpectedly", cache.containsKey(key));
}
}
}