use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class RemoveMixinTest method testRemoveMixinTakingAffectUponSave.
/**
* Implementation specific test for 'removeMixin' only taking effect upon
* save.
*
* @throws NotExecutableException
* @throws RepositoryException
*/
public void testRemoveMixinTakingAffectUponSave() throws NotExecutableException, RepositoryException {
Node node;
try {
node = testRootNode.addNode(nodeName1, testNodeType);
node.addMixin(mixReferenceable);
testRootNode.save();
} catch (RepositoryException e) {
throw new NotExecutableException();
}
node.removeMixin(mixReferenceable);
assertTrue("Removing Mixin must not take effect but after Node has been saved.", node.isNodeType(mixReferenceable));
List<NodeType> mixins = Arrays.asList(node.getMixinNodeTypes());
assertTrue("Removing Mixin must not take effect but after Node has been saved.", mixins.contains(ntMgr.getNodeType(mixReferenceable)));
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class MandatoryItemTest method testCreation.
public void testCreation() throws NotExecutableException, RepositoryException {
Node n;
try {
n = testRootNode.addNode(nodeName1, testNodeType);
} catch (RepositoryException e) {
throw new NotExecutableException();
}
try {
testRootNode.save();
fail("Saving without having added the mandatory child items must fail.");
} catch (ConstraintViolationException e) {
// success
}
if (childNodeDef != null) {
n.addNode(childNodeDef.getName(), childNodeDef.getDefaultPrimaryType().getName());
}
if (childPropDef != null) {
// TODO: check if definition defines default values
n.setProperty(childPropDef.getName(), "any value");
}
// now save must succeed.
testRootNode.save();
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class MandatoryItemTest method testRemoval.
public void testRemoval() throws NotExecutableException, RepositoryException {
Node n;
Node childN = null;
Property childP = null;
try {
n = testRootNode.addNode(nodeName1, testNodeType);
if (childNodeDef != null) {
childN = n.addNode(childNodeDef.getName(), childNodeDef.getDefaultPrimaryType().getName());
}
if (childPropDef != null) {
// TODO: check if definition defines default values
childP = n.setProperty(childPropDef.getName(), "any value");
}
testRootNode.save();
} catch (RepositoryException e) {
throw new NotExecutableException();
}
// remove the mandatory items ((must succeed))
if (childN != null) {
childN.remove();
}
if (childP != null) {
childP.remove();
}
// ... however, saving must not be allowed.
try {
testRootNode.save();
fail("removing mandatory child items without re-adding them must fail.");
} catch (ConstraintViolationException e) {
// success.
}
// re-add the mandatory items
if (childNodeDef != null) {
childN = n.addNode(childNodeDef.getName(), childNodeDef.getDefaultPrimaryType().getName());
}
if (childPropDef != null) {
// TODO: check if definition defines default values
childP = n.setProperty(childPropDef.getName(), "any value");
}
// save must succeed now.
testRootNode.save();
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class DeepLockTest method testDeepLockAboveLockedChild.
public void testDeepLockAboveLockedChild() throws RepositoryException, NotExecutableException {
try {
Node parent = lockedNode.getParent();
if (!parent.isNodeType(mixLockable)) {
try {
parent.addMixin(mixLockable);
parent.save();
} catch (RepositoryException e) {
throw new NotExecutableException();
}
}
parent.lock(true, isSessionScoped);
fail("Creating a deep lock on a parent of a locked node must fail.");
} catch (LockException e) {
// expected
}
}
use of javax.jcr.RepositoryException in project jackrabbit-oak by apache.
the class RemoveMembersTest method runTest.
@Override
public void runTest() throws Exception {
Session s = null;
try {
// use system session login to avoid measuring the login-performance here
s = systemLogin();
UserManager userManager = ((JackrabbitSession) s).getUserManager();
String groupPath = groupPaths.get(random.nextInt(GROUP_CNT));
Group g = (Group) userManager.getAuthorizableByPath(groupPath);
removeMembers(userManager, g, s);
} catch (RepositoryException e) {
if (s.hasPendingChanges()) {
s.refresh(false);
}
} finally {
if (s != null) {
s.logout();
}
}
}
Aggregations