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);
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CacheValidatorProviderTest method testChangePrimaryType.
@Test
public void testChangePrimaryType() throws RepositoryException {
for (Authorizable a : authorizables) {
try {
NodeUtil node = new NodeUtil(getAuthorizableTree(a));
NodeUtil cache = node.addChild("childNode", JcrConstants.NT_UNSTRUCTURED);
root.commit();
cache.setName(JcrConstants.JCR_PRIMARYTYPE, CacheConstants.NT_REP_CACHE);
cache.setLong(CacheConstants.REP_EXPIRATION, 1);
root.commit();
fail("Changing primary type of residual node below an user/group to rep:Cache must fail.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(34, e.getCode());
} finally {
root.refresh();
}
}
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CacheValidatorProviderTest method testNestedCache.
@Test
public void testNestedCache() throws Exception {
NodeUtil cache = new NodeUtil(getCache(getTestUser()));
try {
NodeUtil c = cache.getOrAddChild(CacheConstants.REP_CACHE, CacheConstants.NT_REP_CACHE);
c.setLong(CacheConstants.REP_EXPIRATION, 223);
root.commit(CacheValidatorProvider.asCommitAttributes());
fail("Creating nested cache must fail.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(34, e.getCode());
} finally {
root.refresh();
}
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CacheValidatorProviderTest method testCreateCacheByName.
@Test
public void testCreateCacheByName() throws RepositoryException {
for (Authorizable a : authorizables) {
try {
NodeUtil node = new NodeUtil(getAuthorizableTree(a));
node.addChild(CacheConstants.REP_CACHE, JcrConstants.NT_UNSTRUCTURED);
root.commit();
fail("Creating rep:cache node below a user or group must fail.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(34, e.getCode());
} finally {
root.refresh();
}
}
}
Aggregations