public void testHoldsLockNewChild() throws RepositoryException { Node newChild = lockedNode.addNode(nodeName3, testNodeType); assertFalse("Child node below a locked node must never be lock holder", newChild.holdsLock()); assertFalse( "Child node below a locked node must never be lock holder", lockMgr.holdsLock(newChild.getPath())); }
/** A locked node must also be locked if accessed by some other session. */ public void testLockVisibility() throws RepositoryException { Session otherSession = getHelper().getReadWriteSession(); try { Node ln = (Node) otherSession.getItem(lockedNode.getPath()); assertTrue("Locked node must also be locked for another session", ln.isLocked()); assertTrue("Locked node must also be locked for another session", ln.holdsLock()); assertTrue( "Locked node must also be locked for another session", getLockManager(otherSession).holdsLock(ln.getPath())); } finally { otherSession.logout(); } }
/** Test locks are released when session logs out */ public void testImplicitUnlock2() throws RepositoryException, NotExecutableException { Session other = getHelper().getReadWriteSession(); try { Node testNode = (Node) other.getItem(testRootNode.getPath()); Node lockedNode = testNode.addNode(nodeName1, testNodeType); other.save(); assertLockable(lockedNode); LockManager lMgr = getLockManager(other); Lock lock = lMgr.lock( lockedNode.getPath(), isDeep(), isSessionScoped(), getTimeoutHint(), getLockOwner()); // access the locked noded added by another session testRootNode.refresh(false); Node n = (Node) superuser.getItem(lockedNode.getPath()); // remove lock implicit by logout lock-holding session other.logout(); // check if superuser session is properly informed about the unlock assertFalse(n.isLocked()); assertFalse(n.holdsLock()); try { n.getLock(); fail("Upon logout of the session a session-scoped lock must be gone."); } catch (LockException e) { // ok } } finally { if (other.isLive()) { other.logout(); } } }
public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return currentNode.holdsLock(); }
public void testHoldsLockChild() throws RepositoryException { assertFalse("Child node below a locked node must never be lock holder", childNode.holdsLock()); assertFalse( "Child node below a locked node must never be lock holder", lockMgr.holdsLock(childNode.getPath())); }
/** * Test {@link LockManager#holdsLock(String)} and {@link javax.jcr.Node#holdsLock()}. * * @throws RepositoryException If an execption occurs. */ public void testNodeHoldsLocked() throws RepositoryException { assertTrue("Node must hold lock after lock creation.", lockedNode.holdsLock()); assertTrue("Node must hold lock after lock creation.", lockMgr.holdsLock(lockedNode.getPath())); }