use of org.apache.jackrabbit.core.UserTransactionImpl in project jackrabbit by apache.
the class RemoveVersionTest method testRemoveVersionAndCheckinXA_JCR2.
/**
* Removes a version in 1 transaction and tries to commit afterwards the
* versionable node using a 2nd transaction. Uses the JCR2.0 API.
*
* Tests error reported in JCR-2613
*
* @throws Exception if an error occurs
*/
public void testRemoveVersionAndCheckinXA_JCR2() throws Exception {
UserTransaction tx = new UserTransactionImpl(superuser);
tx.begin();
Node n = testRootNode.addNode(nodeName1);
n.addMixin(mixVersionable);
superuser.save();
// create two versions
String path = n.getPath();
String v1 = superuser.getWorkspace().getVersionManager().checkpoint(path).getName();
String v2 = superuser.getWorkspace().getVersionManager().checkpoint(path).getName();
tx.commit();
tx = new UserTransactionImpl(superuser);
tx.begin();
// remove one version
superuser.getWorkspace().getVersionManager().getVersionHistory(path).removeVersion(v1);
tx.commit();
// new session
Session session = getHelper().getSuperuserSession();
tx = new UserTransactionImpl(session);
tx.begin();
session.getWorkspace().getVersionManager().checkin(path);
tx.commit();
}
use of org.apache.jackrabbit.core.UserTransactionImpl in project jackrabbit by apache.
the class ConcurrentLockingWithTransactionsTest method testConcurrentRefreshInTransaction.
public void testConcurrentRefreshInTransaction() throws RepositoryException {
runTask(new Task() {
public void execute(Session session, Node test) throws RepositoryException {
int i = 0;
try {
Node n = test.addNode("test");
n.addMixin(mixLockable);
session.save();
for (i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
Lock lock = n.lock(false, true);
final UserTransaction utx = new UserTransactionImpl(test.getSession());
utx.begin();
lock.refresh();
utx.commit();
n.unlock();
}
} catch (Exception e) {
final String threadName = Thread.currentThread().getName();
final Throwable deepCause = getLevel2Cause(e);
if (deepCause != null && deepCause instanceof StaleItemStateException) {
// ignore
} else {
throw new RepositoryException(threadName + ", i=" + i + ":" + e.getClass().getName(), e);
}
}
}
}, CONCURRENCY);
}
Aggregations