use of javax.jcr.lock.Lock in project jackrabbit by apache.
the class LockManagerTest method testGetLockTokens.
public void testGetLockTokens() throws RepositoryException, NotExecutableException {
assertLockable(testNode);
boolean sessionScoped = false;
Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
String ltoken = l.getLockToken();
assertTrue("Creating open scoped lock must add token to the lock manager.", containsLockToken(lockMgr, ltoken));
assertTrue("Creating open scoped lock must add token to the lock manager.", containsLockToken(superuser.getLockTokens(), ltoken));
}
use of javax.jcr.lock.Lock in project jackrabbit by apache.
the class LockManagerTest method testGetLockTokensAfterUnlock.
public void testGetLockTokensAfterUnlock() throws RepositoryException, NotExecutableException {
assertLockable(testNode);
boolean sessionScoped = false;
Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
String ltoken = l.getLockToken();
lockMgr.unlock(testPath);
assertFalse("Removing an open scoped lock must remove the token from the lock manager.", containsLockToken(lockMgr, ltoken));
assertFalse("Removing an open scoped lock must remove the token from the lock manager.", containsLockToken(superuser.getLockTokens(), ltoken));
}
use of javax.jcr.lock.Lock in project jackrabbit by apache.
the class LockManagerTest method testGetLockTokensSessionScoped.
public void testGetLockTokensSessionScoped() throws RepositoryException, NotExecutableException {
assertLockable(testNode);
List<String> tokensBefore = Arrays.asList(lockMgr.getLockTokens());
boolean sessionScoped = true;
Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
assertEquals("Creating a session scoped lock must not change the lock tokens.", tokensBefore, Arrays.asList(lockMgr.getLockTokens()));
assertEquals("Creating a session scoped lock must not change the lock tokens.", tokensBefore, Arrays.asList(superuser.getLockTokens()));
}
use of javax.jcr.lock.Lock in project jackrabbit by apache.
the class LockManagerTest method testRemoveLockToken3.
public void testRemoveLockToken3() throws Exception {
assertLockable(testNode);
boolean sessionScoped = false;
Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
String ltoken = l.getLockToken();
try {
lockMgr.removeLockToken(ltoken);
// the locked node.
try {
testNode.addNode(nodeName2, testNodeType);
fail("Session must not be allowed to modify node");
} catch (LockException e) {
// expected
}
} finally {
// make sure lock token is added even if test fail
lockMgr.addLockToken(ltoken);
}
}
use of javax.jcr.lock.Lock in project jackrabbit by apache.
the class LockTest method testOpenScopedLocks.
/**
* Test open-scoped locks
*/
public void testOpenScopedLocks() throws Exception {
// add node
Node n1 = testRootNode.addNode(nodeName1, testNodeType);
ensureMixinType(n1, mixLockable);
testRootNode.getSession().save();
// create new session
Session otherSuperuser = getHelper().getSuperuserSession();
try {
// get node created above
Node n2 = (Node) otherSuperuser.getItem(n1.getPath());
// lock node
Lock lock = n2.lock(false, false);
// transfer to standard session
String lockToken = lock.getLockToken();
otherSuperuser.removeLockToken(lockToken);
superuser.addLockToken(lockToken);
} finally {
// log out
otherSuperuser.logout();
}
// assert: node still locked
assertTrue(n1.isLocked());
}
Aggregations