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"));
 }
Exemplo n.º 2
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));
  }
Exemplo n.º 5
0
  public void testBasicOperation()
      throws SystemException, NotSupportedException, HeuristicMixedException,
          HeuristicRollbackException, RollbackException {
    assertClusterSize("Should only be 2  caches in the cluster!!!", 2);

    Fqn f = Fqn.fromString("/test/data");
    String k = "key", v = "value";

    assertNull("Should be null", cache1.getRoot().getChild(f));
    assertNull("Should be null", cache2.getRoot().getChild(f));

    Node<Object, Object> node = cache1.getRoot().addChild(f);

    assertNotNull("Should not be null", node);

    TransactionManager tm = beginTransaction(cache1.getCache());
    node.put(k, v);
    tm.commit();

    assertEquals(v, node.get(k));
    assertEquals(v, cache1.get(f, k));
    assertEquals("Should have replicated", v, cache2.get(f, k));
  }
Exemplo n.º 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"));
 }
Exemplo n.º 7
0
 public void testAddingDataPutKey() {
   cache.put(A_B, "key", "value");
   assertEquals("value", cache.get(A_B, "key"));
 }
Exemplo n.º 8
0
 public void testAddingDataPutMap() {
   cache.put(A_B, Collections.singletonMap("key", "value"));
   assertEquals("value", cache.get(A_B, "key"));
 }