public void testShrinkCache() { if (isRemoveSupported() == false || isAddSupported() == false) return; resetEmpty(); NodeCachingLinkedList list = (NodeCachingLinkedList) collection; list.addAll( Arrays.asList( new String[]{"1", "2", "3", "4"})); list.removeAllNodes(); // Will dump all 4 elements into cache ((NodeCachingLinkedList) list).setMaximumCacheSize(2); // shrink cache list.addAll( Arrays.asList( new String[]{"1", "2", "3", "4"})); checkNodes(); list.removeNode(list.getNode(0, false)); // no room in cache list.removeNode(list.getNode(0, false)); list.removeNode(list.getNode(0, false)); checkNodes(); list.addAll( Arrays.asList( new String[]{"1", "2", "3", "4"})); checkNodes(); }