public void testDuplicatePersistence() throws CacheLoaderException {
   cache.put(Fqn.fromElements("a", "b"), "k", "v");
   assert "v".equals(cache.get(Fqn.fromElements("a", "b"), "k"));
   cache.stop();
   cache.start();
   cache.put(Fqn.fromElements("a", "b"), "k", "v");
   assert "v".equals(cache.get(Fqn.fromElements("a", "b"), "k"));
 }
예제 #2
0
  public void testOverwritingDataTx() throws Exception {
    Node<Object, Object> rootNode = cache.getRoot();

    Node<Object, Object> nodeA = rootNode.addChild(A);
    nodeA.put("key", "value");
    assertEquals("value", nodeA.get("key"));
    tm.begin();
    rootNode.removeChild(A);
    cache.put(A, "k2", "v2");
    tm.commit();
    assertNull(nodeA.get("key"));
    assertEquals("v2", nodeA.get("k2"));
  }
예제 #3
0
 public void testDoubleRemovalOfData2() throws Exception {
   cache.put("/foo/1/2", "item", 1);
   tm.begin();
   assertEquals(cache.get("/foo/1", "item"), null);
   cache.removeNode("/foo/1");
   assertNull(cache.get("/foo/1", "item"));
   cache.removeNode("/foo/1/2");
   assertNull(cache.get("/foo/1", "item"));
   tm.commit();
   assertFalse(cache.exists("/foo/1"));
   assertNull(cache.get("/foo/1/2", "item"));
   assertNull(cache.get("/foo/1", "item"));
 }
  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));
  }
예제 #6
0
 public void testDoubleRemovalOfData() throws Exception {
   assert tm.getTransaction() == null;
   cache.put("/foo/1/2/3", "item", 1);
   assert tm.getTransaction() == null;
   assert 1 == (Integer) cache.get("/foo/1/2/3", "item");
   tm.begin();
   assert 1 == (Integer) cache.get("/foo/1/2/3", "item");
   cache.removeNode("/foo/1");
   assertNull(cache.getNode("/foo/1"));
   assertNull(cache.get("/foo/1", "item"));
   cache.removeNode("/foo/1/2/3");
   System.out.println("Cache: " + cache);
   assertNull(cache.get("/foo/1/2/3", "item"));
   assertNull(cache.get("/foo/1", "item"));
   tm.commit();
   assertFalse(cache.exists("/foo/1"));
   assertNull(cache.get("/foo/1/2/3", "item"));
   assertNull(cache.get("/foo/1", "item"));
 }
예제 #7
0
 public void testAddingDataPutKey() {
   cache.put(A_B, "key", "value");
   assertEquals("value", cache.get(A_B, "key"));
 }
예제 #8
0
 public void testAddingDataPutMap() {
   cache.put(A_B, Collections.singletonMap("key", "value"));
   assertEquals("value", cache.get(A_B, "key"));
 }