FilePersistenceClassNotFoundException,
FilePersistenceDataCorruptedException,
FilePersistenceTooBigForSerializationException, RBTException {
filePersistence = (FilePersistence) createFilePersistence();
// filePersistence.setAutoSaveEventListener(this);
final IExclusiveDataAccessSession session = filePersistence
.createExclusiveDataAccessSession();
final IInstanceFactory instanceFactory = session.getInstanceFactory();
session.open();
int count = 0;
try {
final SimpleTreeOp<String> tree = SimpleTreeOp
.newInstance(instanceFactory);
session.setObject("tree", tree);
RBTNode<String> nodeQ = RBTNode.newInstance(instanceFactory, "Q");
RBTNode<String> nodeP = RBTNode.newInstance(instanceFactory, "P");
RBTNode<String> nodeC = RBTNode.newInstance(instanceFactory, "C");
RBTSentinel<String> nodeCLeft = RBTSentinel
.newInstance(instanceFactory);
nodeC.setLeft(nodeCLeft);
nodeCLeft.setParent(nodeC);
nodeCLeft = null;// NOPMD
RBTSentinel<String> nodeCRight = RBTSentinel
.newInstance(instanceFactory);
nodeC.setRight(nodeCRight);
nodeCRight.setParent(nodeC);
nodeCRight = null;// NOPMD
RBTNode<String> nodeA = RBTNode.newInstance(instanceFactory, "A");
RBTSentinel<String> nodeALeft = RBTSentinel
.newInstance(instanceFactory);
nodeA.setLeft(nodeALeft);
nodeALeft.setParent(nodeA);
nodeALeft = null;// NOPMD
RBTSentinel<String> nodeARight = RBTSentinel
.newInstance(instanceFactory);
nodeA.setRight(nodeARight);
nodeARight.setParent(nodeA);
nodeARight = null;// NOPMD
RBTNode<String> nodeB = RBTNode.newInstance(instanceFactory, "B");
RBTSentinel<String> nodeBLeft = RBTSentinel
.newInstance(instanceFactory);
nodeB.setLeft(nodeBLeft);
nodeBLeft.setParent(nodeB);
nodeBLeft = null;// NOPMD
RBTSentinel<String> nodeBRight = RBTSentinel
.newInstance(instanceFactory);
nodeB.setRight(nodeBRight);
nodeBRight.setParent(nodeB);
nodeBRight = null;// NOPMD
nodeQ.setRight(nodeC);
nodeC.setParent(nodeQ);
nodeQ.setLeft(nodeP);
nodeP.setParent(nodeQ);
nodeP.setRight(nodeB);
nodeB.setParent(nodeP);
nodeP.setLeft(nodeA);
nodeA.setParent(nodeP);
tree.setRootNode(nodeQ);
nodeQ = nodeP = nodeA = nodeB = nodeC = null;// NOPMD
for (count = 0; count < 1000; count++) {
check1(tree);
tree.rotateRight();
check2(tree);
tree.rotateLeft();
}
} catch (Exception e) {
System.err.println("count=" + count);// NOPMD
e.printStackTrace();// NOPMD
} finally {
session.close();
}
filePersistence.xmlExport("runtime", "runtime/temp", false);
filePersistence.close();
}