protected static void assertMapEntries( Map<Object, Object> expected, InMemoryBasedCacheSupport<Object, Object> cache) { assertEquals("Length not currect", expected.size(), cache.getEntries().size()); for (final Object key : expected.keySet()) { final CacheEntry<?, ?> entry = cache.getEntries().get(key); assertNotNull("Entry for key '" + key + "' is null!", entry); assertEquals("key '" + key + "'", expected.get(key), entry.getValue().getValue()); } }
/** Assert the correct order of the linked list contained in each AbstractCache. */ protected static void assertLinkedList(InMemoryBasedCacheSupport<?, ?> c) throws Exception { if (c.getFirst() == null || c.getLast() == null) { assertNull(c.getLast()); assertNull(c.getFirst()); } else { assertNull(c.getFirst().getPrevious()); assertNull(c.getLast().getNext()); CacheEntry<?, ?> ce = c.getFirst(); while (ce != null) { if (!ce.equals(c.getLast())) { assertNotNull(ce.getNext()); assertEquals(ce.getNext().getPrevious(), ce); } if (!ce.equals(c.getFirst())) { assertEquals(ce.getPrevious().getNext(), ce); } ce = ce.getNext(); } } }