// Load initial data in cache store
int numEntries = loadInitialData(cm);
DummyInMemoryStore dummyStore = TestingUtil.getFirstWriter(cm.getCache("dummyStore"));
// Load all from cache store
CompletionListenerFuture future = new CompletionListenerFuture();
Set<Integer> keys = Collections.singleton(1);
cache.loadAll(keys, false, future);
futureGet(future); // wait for key to be loaded
assertTrue(future.isDone());
assertEquals(numEntries, dummyStore.stats().get("load").intValue());
// Load from memory
assertEquals("v1", cache.get(1));
// Load again from cache store, overriding in-memory contents
future = new CompletionListenerFuture();
cache.loadAll(keys, true, future);
futureGet(future); // wait for key to be loaded
assertTrue(future.isDone());
assertEquals(numEntries * 2, dummyStore.stats().get("load").intValue());
}
});
}