public void testRootNodePersistence() throws CacheLoaderException { cache.put(ROOT, "key", "value"); assert "value".equals(cache.get(ROOT, "key")); assert store.containsKey(new NodeKey(ROOT, DATA)); assert "value".equals(nodeContentsInCacheStore(store, ROOT).get("key")); assert store.containsKey(new NodeKey(ROOT, STRUCTURE)); cache.stop(); cache.start(); assert "value".equals(cache.get(ROOT, "key")); assert store.containsKey(new NodeKey(ROOT, DATA)); assert "value".equals(nodeContentsInCacheStore(store, ROOT).get("key")); assert store.containsKey(new NodeKey(ROOT, STRUCTURE)); }
public void testPersistence() throws CacheLoaderException { cache.put("/a/b/c", "key", "value"); assert "value".equals(cache.get("/a/b/c", "key")); assert store.containsKey(new NodeKey(Fqn.fromString("/a/b/c"), DATA)); assert "value".equals(nodeContentsInCacheStore(store, Fqn.fromString("/a/b/c")).get("key")); assert store.containsKey(new NodeKey(Fqn.fromString("/a/b/c"), STRUCTURE)); cache.stop(); cache.start(); assert "value".equals(cache.get("/a/b/c", "key")); assert store.containsKey(new NodeKey(Fqn.fromString("/a/b/c"), DATA)); assert "value".equals(nodeContentsInCacheStore(store, Fqn.fromString("/a/b/c")).get("key")); assert store.containsKey(new NodeKey(Fqn.fromString("/a/b/c"), STRUCTURE)); }
private void assertInCacheAndNotInStore(Cache cache, CacheStore store, Object... keys) throws CacheLoaderException { for (Object key : keys) { assert cache.getAdvancedCache().getDataContainer().containsKey(key, null) : "Cache should not contain key " + key; assert !store.containsKey(key) : "Store should contain key " + key; } }