testRootNode.addNode(nodeName2, testNodeType);
testRootNode.addNode(nodeName1, testNodeType);
testRootNode.addNode(nodeName1, testNodeType);
testRootNode.addNode(nodeName3, testNodeType);
testRootNode.save();
EventResult addNodeListener = new EventResult(log);
EventResult removeNodeListener = new EventResult(log);
addEventListener(addNodeListener, Event.NODE_ADDED);
addEventListener(removeNodeListener, Event.NODE_REMOVED);
testRootNode.orderBefore(nodeName1 + "[2]", null);
testRootNode.getNode(nodeName3).remove();
testRootNode.save();
removeEventListener(addNodeListener);
removeEventListener(removeNodeListener);
Event[] added = addNodeListener.getEvents(DEFAULT_WAIT_TIMEOUT);
Event[] removed = removeNodeListener.getEvents(DEFAULT_WAIT_TIMEOUT);
// not deterministic, there exist various re-order seqences. the minimal
// is:
// nodename1[2] has been reordered to the end + nodeName3 has been removed
checkNodeAdded(added, new String[]{nodeName1 + "[4]"}, null);
checkNodeRemoved(removed, new String[]{nodeName1 + "[2]", nodeName3}, null);