{
Fqn fqn1 = Fqn.fromString("/a/b/c");
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
Fqn fqn4 = Fqn.fromString("/a/b/f");
RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
// Should have a maximum of 2 nodes.
config.setMaxNodes(2);
config.setTimeToLive(1000);
config.setMaxAge(3000);
region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
region.registerEvictionEvent(fqn4, EvictionEvent.Type.ADD_NODE_EVENT);
algorithm.process(region.getEvictionEventQueue());
EvictionQueue eq = algorithm.getEvictionQueue();
int numNodesInQueue = eq.getNumberOfNodes();
assert 2 == numNodesInQueue : "Queue size #1: expected 2 but was " + numNodesInQueue;
// make sure all nodes now expire
TestingUtil.sleepThread(1100);
region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);
algorithm.process(region.getEvictionEventQueue());
numNodesInQueue = eq.getNumberOfNodes();
assert 1 == numNodesInQueue : "Queue size #2: expected 1 but was " + numNodesInQueue;
TestingUtil.sleepThread(3100);
// visit the node now to prevent the idle time from doing the pruning - node still gets pruned but by
// max age.
region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVENT);
algorithm.process(region.getEvictionEventQueue());
numNodesInQueue = eq.getNumberOfNodes();
assert 0 == numNodesInQueue : "Queue size #3: expected 0 but was " + numNodesInQueue;
}