### Question:
LRUCache extends LinkedHashMap<K, V> { protected void onCacheEviction(Map.Entry<K,V> eldest) { } LRUCache();  LRUCache(int maximumCacheSize);  LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder); int getMaxCacheSize(); void setMaxCacheSize(int maxCacheSize);  }### Answer:
@SuppressWarnings("serial") @Test public void testOnCacheEviction() { final int ENTRY_COUNT = 20; List<CacheEntry> entries = new ArrayList<CacheEntry>(); LRUCache<String, CacheEntry> cache = new LRUCache<String, CacheEntry>(ENTRY_COUNT / 2) { @Override protected void onCacheEviction(java.util.Map.Entry<String,CacheEntry> eldest) { eldest.getValue().close(); }; }; for (int i = 0; i < ENTRY_COUNT; ++i) { CacheEntry entry = new CacheEntry(); entries.add(entry); cache.put("Entry:" + i, entry); } for (int i = 0; i < ENTRY_COUNT; ++i) { if (i < ENTRY_COUNT / 2) { assertFalse(entries.get(i).isOpen()); } else { assertTrue(entries.get(i).isOpen()); } } }