cache.destroy();
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig(pasv, "/", DummyInMemoryCacheLoader.class.getName(), "debug=true", false, false, false, false));
cache.start();
DummyInMemoryCacheLoader loader = (DummyInMemoryCacheLoader) cache.getCacheLoaderManager().getCacheLoader();
rootNode.put("key", "value");
if (!pasv)
{
Map m = loader.get(Fqn.ROOT);
assertNotNull("Should not be null", m);
assertEquals("value", m.get("key"));
}
Node<Object, Object> nodeA = rootNode.addChild(A);
nodeA.put(k, vA);
Node<Object, Object> nodeB = rootNode.addChild(B);
nodeB.put(k, vB);
Node<Object, Object> nodeC = nodeA.addChild(C);
nodeC.put(k, vC);
Node<Object, Object> nodeD = nodeC.addChild(D);
nodeD.put(k, vD);
Node<Object, Object> nodeE = nodeD.addChild(E);
nodeE.put(k, vE);
cache.evict(Fqn.ROOT, true);
// move
if (useTx) tm.begin();
cache.move(nodeC.getFqn(), nodeB.getFqn());
if (useTx) tm.commit();
// after eviction, the node objects we hold are probably stale.
nodeA = rootNode.getChild(A);
nodeB = rootNode.getChild(B);
nodeC = nodeB.getChild(C);
log.info("nodeC get child B ");
nodeD = nodeC.getChild(D);
log.info("nodeD get child E ");
nodeE = nodeD.getChild(E);
Fqn old_C = C;
Fqn old_D = Fqn.fromRelativeFqn(old_C, D);
Fqn old_E = Fqn.fromRelativeFqn(old_D, E);
// test data
assertEquals(vA, nodeA.get(k));
assertEquals(vB, nodeB.get(k));
assertEquals(vC, nodeC.get(k));
assertEquals(vD, nodeD.get(k));
assertEquals(vE, nodeE.get(k));
// parentage
assertEquals(rootNode, nodeA.getParent());
assertEquals(rootNode, nodeB.getParent());
assertEquals(nodeB, nodeC.getParent());
assertEquals(nodeC, nodeD.getParent());
assertEquals(nodeD, nodeE.getParent());
if (pasv) cache.evict(Fqn.ROOT, true);
//now inspect the loader.
assertEquals(vA, loader.get(nodeA.getFqn()).get(k));
assertEquals(vB, loader.get(nodeB.getFqn()).get(k));
assertEquals(vC, loader.get(nodeC.getFqn()).get(k));
assertEquals(vD, loader.get(nodeD.getFqn()).get(k));
assertEquals(vE, loader.get(nodeE.getFqn()).get(k));
assertNull(loader.get(old_C));
assertNull(loader.get(old_D));
assertNull(loader.get(old_E));
}