{
cache.destroy();
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig(pasv, "", DummyInMemoryCacheLoader.class.getName(), null, 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"));
}
nodeA = rootNode.addChild(A);
nodeA.put(k, vA);
nodeB = rootNode.addChild(B);
nodeB.put(k, vB);
nodeC = nodeA.addChild(C);
nodeC.put(k, vC);
nodeD = nodeC.addChild(D);
nodeD.put(k, vD);
nodeE = nodeD.addChild(E);
nodeE.put(k, vE);
/*
Node nodeF = nodeE.addChild(Fqn.fromString("F"));
nodeF.put(k, vE);
Node nodeG = nodeF.addChild(Fqn.fromString("G"));
nodeG.put(k, vE);
*/
assertNotNull(cache.peek(A, false));
assertNotNull(cache.peek(B, false));
assertNull(cache.peek(C, false));
assertNotNull(cache.peek(new Fqn<String>(A, C), false));
assertNotNull(cache.peek(new Fqn<String>(new Fqn<String>(A, C), D), false));
assertNotNull(cache.peek(new Fqn<String>(new Fqn<String>(new Fqn<String>(A, C), D), E), false));
// 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(nodeA, nodeC.getParent());
assertEquals(nodeC, nodeD.getParent());
assertEquals(nodeD, nodeE.getParent());
System.out.println("Loader" + loader);
cache.evict(Fqn.ROOT, true);
// move
if (useTx) tm.begin();
cache.move(nodeC.getFqn(), nodeB.getFqn());
// Fqn[] fqns = {A, B, new Fqn(B, C), new Fqn(new Fqn(B, C), D), new Fqn(new Fqn(new Fqn(B, C), D), E)};
// System.out.println("*** LOADER BEFORE COMMIT ");
// for (Fqn f: fqns)
// {
// System.out.println(" Fqn: " + f);
// System.out.println(" Contents in loader: " + loader.get(f));
// }
if (useTx) tm.commit();
// System.out.println("*** LOADER AFTER COMMIT ");
// for (Fqn f: fqns)
// {
// System.out.println(" Fqn: " + f);
// System.out.println(" Contents in loader: " + loader.get(f));
// }
// 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<String> old_C = new Fqn<String>(C);
Fqn<String> old_D = new Fqn<String>(old_C, D);
Fqn<String> old_E = new Fqn<String>(old_D, E);
assertNotNull(cache.peek(A, false));
assertNotNull(cache.peek(B, false));
assertNull(cache.peek(C, false));
assertNull(cache.peek(new Fqn<String>(A, C), false));
assertNotNull(cache.peek(new Fqn<String>(B, C), false));
assertNotNull(cache.peek(new Fqn<String>(new Fqn<String>(B, C), D), false));
assertNotNull(cache.peek(new Fqn<String>(new Fqn<String>(new Fqn<String>(B, C), D), E), false));
// 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));
}