public void testChangesOnAtomicMap() { AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(cache, "key"); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getAtomicMap(cache, "key").get("a").equals("b"); }
public void testChangesOnAtomicMapNoLocks() { AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(cache, "key"); assert map.isEmpty(); // InvocationContextContainer icc = TestingUtil.extractComponent(cache, InvocationContextContainer.class); // InvocationContext ic = icc.createInvocationContext(false, -1); // ic.setFlags(SKIP_LOCKING); log.debug("Doing a put"); // assert icc.getInvocationContext(true).hasFlag(SKIP_LOCKING); map.put("a", "b"); log.debug("Put complete"); assert map.get("a").equals("b"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getAtomicMap(cache, "key").get("a").equals("b"); }
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(); }
public void testChangesOnAtomicMapNoLocksExistingData() { AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(cache, "key"); assert map.isEmpty(); map.put("x", "y"); assert map.get("x").equals("y"); // TestingUtil.extractComponent(cache, InvocationContextContainer.class).createInvocationContext(false, -1).setFlags(SKIP_LOCKING); log.debug("Doing a put"); map.put("a", "b"); log.debug("Put complete"); assert map.get("a").equals("b"); assert map.get("x").equals("y"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getAtomicMap(cache, "key").get("x").equals("y"); assert AtomicMapLookup.getAtomicMap(cache, "key").get("a").equals("b"); }
public void testTxChangesOnAtomicMap() throws Exception { AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(cache, "key"); tm().begin(); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); Transaction t = tm().suspend(); assert AtomicMapLookup.getAtomicMap(cache, "key").get("a") == null; tm().resume(t); tm().commit(); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getAtomicMap(cache, "key").get("a").equals("b"); }
public void testTxChangesOnAtomicMapNoLocks() throws Exception { AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(cache, "key"); tm().begin(); assert map.isEmpty(); // TestingUtil.extractComponent(cache, InvocationContextContainer.class).createInvocationContext(true, -1).setFlags(SKIP_LOCKING); map.put("a", "b"); assert map.get("a").equals("b"); Transaction t = tm().suspend(); assert AtomicMapLookup.getAtomicMap(cache, "key").get("a") == null; tm().resume(t); tm().commit(); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getAtomicMap(cache, "key").get("a").equals("b"); }
public void testAtomicMapWithoutBatchSet() { ConfigurationBuilder builder = buildConfiguration(); builder.invocationBatching().disable(); cacheManager.defineConfiguration("ahm_without_batch", builder.build()); Cache<String, String> ahmCache = cacheManager.getCache("ahm_without_batch"); AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(ahmCache, "key"); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getAtomicMap(ahmCache, "key").get("a").equals("b"); }
public void testReadSafetyNotEmptyCache() throws Exception { AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(cache, "map"); tm.begin(); map.put("blah", "blah"); assert map.get("blah").equals("blah"); Transaction t = tm.suspend(); assert map.isEmpty(); assertIsEmpty(map); assertIsEmptyMap(cache, "map"); tm.resume(t); tm.commit(); assert map.size() == 1; assert map.get("blah").equals("blah"); assert map.containsKey("blah"); map.clear(); assertIsEmpty(map); assertIsEmptyMap(cache, "map"); }
public void testAtomicMapWithoutTransactionManagerLookupSet() { ConfigurationBuilder builder = buildConfiguration(); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).transactionManagerLookup(null); cacheManager.defineConfiguration("ahm_without_tmlookup", builder.build()); Cache<String, String> ahmCache = cacheManager.getCache("ahm_without_tmlookup"); AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(ahmCache, "key"); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getAtomicMap(ahmCache, "key").get("a").equals("b"); }
public void testAtomicMapNonTransactionWithoutBatchSet() { ConfigurationBuilder builder = buildConfiguration(); builder.invocationBatching().disable(); builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL); cacheManager.defineConfiguration("ahm_no_tx_without_batch", builder.build()); Cache<String, String> ahmCache = cacheManager.getCache("ahm_no_tx_without_batch"); AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(ahmCache, "key"); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getAtomicMap(ahmCache, "key").get("a").equals("b"); }
public void testAtomicMapBackup() { AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(cache("LON", 0), "amKey"); assert map.isEmpty(); log.trace("Update is here"); map.put("a", "fancyValue"); assertEquals("fancyValue", map.get("a")); assertEquals("fancyValue", AtomicMapLookup.getAtomicMap(backup("LON"), "amKey").get("a")); }