public void testCacheStoring() throws Exception
{
Transaction tx;
CacheSPI<Object, Object> cache = createCacheWithLoader();
CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
// test the cache ...
TransactionManager mgr = cache.getTransactionManager();
assertNull(mgr.getTransaction());
mgr.begin();
cache.put(fqn, key, value);
mgr.commit();
assertEquals(value, cache.get(fqn, key));
//now lets see if the state has been persisted in the cache loader
assertEquals(value, loader.get(fqn).get(key));
mgr.begin();
cache.removeNode(fqn);
mgr.commit();
assertNull(cache.get(fqn, key));
//now lets see if the state has been persisted in the cache loader
assertNull(loader.get(fqn));
mgr.begin();
cache.put(fqn, key, value);
tx = mgr.getTransaction();
mgr.suspend();
// lets see what we've got halfway within a tx
assertNull(cache.get(fqn, key));
assertNull(loader.get(fqn));
mgr.resume(tx);
mgr.commit();
// and after committing...
assertEquals(value, cache.get(fqn, key));
assertEquals(value, loader.get(fqn).get(key));
// clean up loader
loader.remove(fqn);
}