use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CugValidatorTest method testMissingMixin.
@Test
public void testMissingMixin() throws Exception {
NodeUtil cug = node.addChild(REP_CUG_POLICY, NT_REP_CUG_POLICY);
cug.setStrings(REP_PRINCIPAL_NAMES, EveryonePrincipal.NAME);
try {
root.commit();
fail();
} catch (CommitFailedException e) {
assertTrue(e.isAccessControlViolation());
assertEquals(22, e.getCode());
} finally {
root.refresh();
}
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CugUtilTest method testHasCugNodeState.
@Test
public void testHasCugNodeState() throws Exception {
assertTrue(CugUtil.hasCug(getNodeState(root.getTree(SUPPORTED_PATH))));
assertFalse(CugUtil.hasCug((NodeState) null));
for (String path : new String[] { PathUtils.ROOT_PATH, INVALID_PATH, UNSUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH2, SUPPORTED_PATH3 }) {
assertFalse(CugUtil.hasCug(getNodeState(root.getTree(path))));
}
new NodeUtil(root.getTree(SUPPORTED_PATH2)).addChild(REP_CUG_POLICY, NodeTypeConstants.NT_OAK_UNSTRUCTURED);
assertTrue(CugUtil.hasCug(getNodeState(root.getTree(SUPPORTED_PATH2))));
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class NestedCugHookTest method testMoveToSupportedPath.
@Test
public void testMoveToSupportedPath() throws Exception {
createCug(root, SUPPORTED_PATH3, EveryonePrincipal.NAME);
Tree newTree = new NodeUtil(root.getTree(SUPPORTED_PATH3)).addChild("child", NT_OAK_UNSTRUCTURED).getTree();
String path = newTree.getPath();
createCug(path, getTestGroupPrincipal());
root.commit();
String destPath = PathUtils.concat(SUPPORTED_PATH, "moved");
root.move(path, destPath);
root.commit();
assertNestedCugs(root, SUPPORTED_PATH3, true);
assertNestedCugs(root, ROOT_PATH, false, SUPPORTED_PATH3, destPath);
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class NestedCugHookTest method testMoveToUnsupportedPath.
@Test
public void testMoveToUnsupportedPath() throws Exception {
createCug(root, SUPPORTED_PATH3, EveryonePrincipal.NAME);
Tree newTree = new NodeUtil(root.getTree(SUPPORTED_PATH3)).addChild("child", NT_OAK_UNSTRUCTURED).getTree();
String path = newTree.getPath();
createCug(path, getTestGroupPrincipal());
root.commit();
String destPath = PathUtils.concat(UNSUPPORTED_PATH, "moved");
root.move(path, destPath);
root.commit();
assertNestedCugs(root, SUPPORTED_PATH3, true);
assertNestedCugs(root, ROOT_PATH, false, SUPPORTED_PATH3, destPath);
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class NestedCugHookTest method testMoveToNested.
@Test
public void testMoveToNested() throws Exception {
createCug(root, SUPPORTED_PATH2, EveryonePrincipal.NAME);
createCug(root, SUPPORTED_PATH3, EveryonePrincipal.NAME);
Tree newTree = new NodeUtil(root.getTree(SUPPORTED_PATH3)).addChild("child", NT_OAK_UNSTRUCTURED).getTree();
String path = newTree.getPath();
createCug(path, getTestGroupPrincipal());
root.commit();
String destPath = PathUtils.concat(SUPPORTED_PATH2, "moved");
root.move(path, destPath);
root.commit();
assertNestedCugs(root, ROOT_PATH, false, SUPPORTED_PATH3, SUPPORTED_PATH2);
assertNestedCugs(root, SUPPORTED_PATH3, true);
assertNestedCugs(root, SUPPORTED_PATH2, true, destPath);
}
Aggregations