use of javax.jcr.Session in project jackrabbit by apache.
the class SessionScopedLockTest method testImplicitUnlock.
/**
* Test locks are released when session logs out
*/
public void testImplicitUnlock() 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);
Lock lock = getLockManager(other).lock(lockedNode.getPath(), isDeep(), isSessionScoped(), getTimeoutHint(), getLockOwner());
other.logout();
assertFalse(lock.isLive());
} finally {
if (other.isLive()) {
other.logout();
}
}
}
use of javax.jcr.Session in project jackrabbit by apache.
the class SessionScopedLockTest method testImplicitUnlock2.
/**
* 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();
}
}
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class AbstractTest method tearDown.
/**
* Cleans up after this performance benchmark.
*
* @throws Exception if the benchmark can not be cleaned up
*/
public void tearDown() throws Exception {
issueHaltChildThreads();
this.running = false;
for (Thread thread : threads) {
thread.join();
}
if (profiler != null) {
System.out.println(profiler.stopCollecting().getTop(5));
profiler = null;
}
afterSuite();
for (Session session : sessions) {
if (session.isLive()) {
session.logout();
}
}
this.threads = null;
this.sessions = null;
this.credentials = null;
this.repository = null;
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class AddMembersTest method afterSuite.
@Override
public void afterSuite() throws Exception {
Session s = loginAdministrative();
try {
Authorizable authorizable = ((JackrabbitSession) s).getUserManager().getAuthorizable(GROUP + "0");
if (authorizable != null) {
Node n = s.getNode(Text.getRelativeParent(authorizable.getPath(), 1));
n.remove();
}
if (!ImportBehavior.NAME_BESTEFFORT.equals(importBehavior)) {
authorizable = ((JackrabbitSession) s).getUserManager().getAuthorizable(USER + "0");
if (authorizable != null) {
Node n = s.getNode(Text.getRelativeParent(authorizable.getPath(), 1));
n.remove();
}
}
s.save();
} finally {
s.logout();
}
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class BundlingNodeTest method registerAssetNodeType.
private void registerAssetNodeType() throws ParseException, RepositoryException, IOException {
Session session = loginWriter();
CndImporter.registerNodeTypes(new StringReader(ASSET_NODE_TYPE_DEFN), session);
session.logout();
}
Aggregations