Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixLockable);
testRootNode.save();
// lock node and get lock token
Lock lock = n.lock(false, true);
// assert: session must get a non-null lock token
assertNotNull("session must get a non-null lock token",
lock.getLockToken());
// assert: session must hold lock token
assertTrue("session must hold lock token",
containsLockToken(superuser, lock.getLockToken()));
// remove lock token
String lockToken = lock.getLockToken();
superuser.removeLockToken(lockToken);
// assert: session must get a null lock token
assertNull("session must get a null lock token",
lock.getLockToken());
// assert: session must still hold lock token
assertFalse("session must not hold lock token",
containsLockToken(superuser, lockToken));
// assert: session unable to modify node
try {
n.addNode(nodeName2, testNodeType);
fail("session unable to modify node");
} catch (LockException e) {
// expected
}
// add lock token
superuser.addLockToken(lockToken);
// assert: session must get a non-null lock token
assertNotNull("session must get a non-null lock token",
lock.getLockToken());
// assert: session must hold lock token
assertTrue("session must hold lock token",
containsLockToken(superuser, lock.getLockToken()));
// assert: session able to modify node
n.addNode(nodeName2, testNodeType);
}