public void testPassivateAndUpdate(Method m) throws Exception { String key = "k-" + m.getName(); TransactionManager tm = TestingUtil.getTransactionManager(cache); tm.begin(); AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(cache, key); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); tm.commit(); assertInCacheNotInStore(key); log.trace("About to evict..."); cache.evict(key); assertInStoreNotInCache(key); tm.begin(); map = AtomicMapLookup.getAtomicMap(cache, key); map.put("a", "c"); map.put("d", "e"); tm.commit(); }
private void assertInStoreNotInCache(Object key) throws PersistenceException { MarshalledEntry se = loader.load(key); testStoredEntry(se, key, "Store"); assert !cache.getAdvancedCache().getDataContainer().containsKey(key) : "Key " + key + " should not be in cache!"; }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder c = getDefaultStandaloneCacheConfig(true); c .invocationBatching().enable() .persistence() .passivation(true) .addStore(DummyInMemoryStoreConfigurationBuilder.class); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(c); cache = cm.getCache(); loader = TestingUtil.getFirstLoader(cache); return cm; }
private void assertInCacheNotInStore(Object key) throws PersistenceException { InternalCacheValue ice = cache.getAdvancedCache().getDataContainer().get(key).toInternalCacheValue(); testStoredEntry(ice, key, "Cache"); assert !loader.contains(key) : "Key " + key + " should not be in store!"; }