cache0.putAll(originalValues);
PersistenceManager persistenceManager = TestingUtil.extractComponent(cache0, PersistenceManager.class);
DummyInMemoryStore store = persistenceManager.getStores(DummyInMemoryStore.class).iterator().next();
TestObjectStreamMarshaller sm = new TestObjectStreamMarshaller();
PersistenceManager pm = null;
try {
store.write(new MarshalledEntryImpl(loaderKey, loaderValue, null, sm));
final CheckPoint checkPoint = new CheckPoint();
pm = waitUntilAboutToProcessStoreTask(cache0, checkPoint);
Future<Void> future = fork(new Callable<Void>() {
@Override
public Void call() throws Exception {
// Wait until loader is invoked
checkPoint.awaitStrict("pre_process_on_all_stores_invoked", 1000, TimeUnit.SECONDS);
// Now force the entry to be moved to loader
TestingUtil.extractComponent(cache0, PassivationManager.class).passivate(new ImmortalCacheEntry(loaderKey, loaderValue));
checkPoint.triggerForever("pre_process_on_all_stores_released");
return null;
}
});
EntryRetriever<MagicKey, String> retriever = cache1.getAdvancedCache().getComponentRegistry().getComponent(
EntryRetriever.class);
Iterator<Map.Entry<MagicKey, String>> iterator = retriever.retrieveEntries(null, null, null);
// we need this count since the map will replace same key'd value
int count = 0;
Map<MagicKey, String> results = new HashMap<MagicKey, String>();
while (iterator.hasNext()) {
Map.Entry<MagicKey, String> entry = iterator.next();
results.put(entry.getKey(), entry.getValue());
count++;
}
assertEquals(4, count);
assertEquals(originalValues, results);
future.get(10, TimeUnit.SECONDS);
} finally {
if (pm != null) {
TestingUtil.replaceComponent(cache0, PersistenceManager.class, pm, true);
}
sm.stop();
}
}