public void testLoading() throws PersistenceException {
assertNotInCacheAndStore("k1", "k2", "k3", "k4");
for (int i = 1; i < 5; i++) writer.write(new MarshalledEntryImpl("k" + i, "v" + i, null, sm));
for (int i = 1; i < 5; i++) assertEquals("v" + i, cache.get("k" + i));
assertNoLocks(cache);
for (int i = 1; i < 5; i++) cache.evict("k" + i);
assertNoLocks(cache);
assertEquals("v1", cache.putIfAbsent("k1", "v1-SHOULD-NOT-STORE"));
assertEquals("v2", cache.remove("k2"));
assertEquals("v3", cache.replace("k3", "v3-REPLACED"));
assertTrue(cache.replace("k4", "v4", "v4-REPLACED"));
assertNoLocks(cache);
int size = cache.size();
assertEquals("Expected the cache to contain 3 elements but contained " + cache.entrySet(), 3, size);
for (int i = 1; i < 5; i++) cache.evict("k" + i);
assertNoLocks(cache);
assertEquals(0, cache.getAdvancedCache().getDataContainer().size());
cache.clear();
assertNotInCacheAndStore("k1", "k2", "k3", "k4");
assertNoLocks(cache);
}