// aka Region.
Fqn fqn = Fqn.fromString(fqn4);
Object key = "key";
MethodCall mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, new Object[]{fqn, key, Boolean.FALSE});
interceptor.invoke(mc);
Region region = regionManager.getRegion(fqn.toString());
assertNull(region.takeLastEventNode());
// add the node but try to get on a null element should result in no cache events being added to Region.
cache.put(fqn, "wrongkey", "");
mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, new Object[]{fqn, key, Boolean.FALSE});
interceptor.invoke(mc);
assertNull(region.takeLastEventNode());
// now make sure if we try to get on the node/key we just created in cache, that this DOES add a EvictedEventNode to
// the Region.
mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, new Object[]{fqn, "wrongkey", Boolean.FALSE});
interceptor.invoke(mc);
EvictedEventNode event = region.takeLastEventNode();
assertEquals(fqn, event.getFqn());
assertEquals(EvictedEventNode.VISIT_NODE_EVENT, event.getEvent());
assertNull(region.takeLastEventNode());
cache.put(fqn4, key, "value");
// test on element granularity configured node.
fqn = Fqn.fromString(fqn4);
mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, new Object[]{fqn, key, Boolean.FALSE});
interceptor.invoke(mc);
region = regionManager.getRegion(fqn.toString());
event = region.takeLastEventNode();
assertEquals(EvictedEventNode.VISIT_NODE_EVENT, event.getEvent());
assertEquals(fqn, event.getFqn());
assertNull(region.takeLastEventNode());
fqn = Fqn.fromString("/d/e/g");
for (int i = 0; i < 1000; i++)
{
key = new Integer(i);
cache.put("/d/e/g", key, "");
mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, new Object[]{fqn, key, Boolean.TRUE});
interceptor.invoke(mc);
}
region = regionManager.getRegion(fqn.toString());
for (int i = 0; i < 1000; i++)
{
event = region.takeLastEventNode();
assertEquals(fqn, event.getFqn());
assertEquals(EvictedEventNode.VISIT_NODE_EVENT, event.getEvent());
}
cache.put("/a/b/c", key, "");
fqn = Fqn.fromString("/a/b/c");
mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, new Object[]{fqn, key, Boolean.FALSE});
interceptor.invoke(mc);
region = regionManager.getRegion(fqn.toString());
event = region.takeLastEventNode();
assertNull(region.takeLastEventNode());
assertEquals(EvictedEventNode.VISIT_NODE_EVENT, event.getEvent());
assertEquals(fqn, event.getFqn());
for (int i = 0; i < 1000; i++)
{
key = new Integer(i);
cache.put(fqn.toString(), key, "");
mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, new Object[]{fqn, key, Boolean.TRUE});
interceptor.invoke(mc);
}
for (int i = 0; i < 1000; i++)
{
event = region.takeLastEventNode();
assertEquals(EvictedEventNode.VISIT_NODE_EVENT, event.getEvent());
assertEquals(fqn, event.getFqn());
}
assertNull(region.takeLastEventNode());
// check null handling
mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, new Object[]{null, key, Boolean.TRUE});
interceptor.invoke(mc);
assertNull(region.takeLastEventNode());
mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, new Object[]{null, null, Boolean.TRUE});
interceptor.invoke(mc);
assertNull(region.takeLastEventNode());
mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, new Object[]{fqn, null, Boolean.TRUE});
interceptor.invoke(mc);
assertNull(region.takeLastEventNode());
}