use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CacheValidatorProviderTest method testCreateCacheBelowProfile.
@Test
public void testCreateCacheBelowProfile() throws Exception {
try {
NodeUtil node = new NodeUtil(getAuthorizableTree(getTestUser()));
NodeUtil child = node.addChild("profile", NodeTypeConstants.NT_OAK_UNSTRUCTURED);
child.addChild(CacheConstants.REP_CACHE, CacheConstants.NT_REP_CACHE).setLong(CacheConstants.REP_EXPIRATION, 23);
root.commit(CacheValidatorProvider.asCommitAttributes());
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();
}
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CacheValidatorProviderTest method testCreateCacheByNodeType.
@Test
public void testCreateCacheByNodeType() throws RepositoryException {
for (Authorizable a : authorizables) {
try {
NodeUtil node = new NodeUtil(getAuthorizableTree(a));
NodeUtil cache = node.addChild("childNode", CacheConstants.NT_REP_CACHE);
cache.setLong(CacheConstants.REP_EXPIRATION, 1);
root.commit();
fail("Creating node with nt rep:Cache below a user or group 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 MembershipProviderTest method testNotIsDeclaredMemberMissingMembersProperty.
@Test
public void testNotIsDeclaredMemberMissingMembersProperty() throws Exception {
Tree grTree = getTree(createGroup());
Tree memberTree = getTree(createUser());
NodeUtil memberList = new NodeUtil(grTree).addChild(REP_MEMBERS_LIST, NT_REP_MEMBER_REFERENCES_LIST);
memberList.addChild("member1", NT_REP_MEMBER_REFERENCES).setStrings(REP_MEMBERS, getContentID("another"));
assertFalse(mp.isDeclaredMember(grTree, memberTree));
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class MembershipProviderTest method testIsDeclaredMemberMissingMembersProperty.
@Test
public void testIsDeclaredMemberMissingMembersProperty() throws Exception {
Tree grTree = getTree(createGroup());
Tree memberTree = getTree(createUser());
NodeUtil memberList = new NodeUtil(grTree).addChild(REP_MEMBERS_LIST, NT_REP_MEMBER_REFERENCES_LIST);
memberList.addChild("member1", NT_REP_MEMBER_REFERENCES).setStrings(REP_MEMBERS, getContentID(memberTree));
assertTrue(mp.isDeclaredMember(grTree, memberTree));
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class SystemUserImplTest method testCreateSystemUserWithOtherPath.
@Test
public void testCreateSystemUserWithOtherPath() throws Exception {
String path = null;
try {
Tree t = root.getTree(UserConstants.DEFAULT_USER_PATH);
NodeUtil systemUserTree = new NodeUtil(t).addChild("systemUser", UserConstants.NT_REP_SYSTEM_USER);
systemUserTree.setString(UserConstants.REP_PRINCIPAL_NAME, "systemUser");
systemUserTree.setString(UserConstants.REP_AUTHORIZABLE_ID, "systemUser");
path = systemUserTree.getTree().getPath();
root.commit();
fail();
} catch (CommitFailedException e) {
// success
assertTrue(e.isConstraintViolation());
} finally {
root.refresh();
if (path != null) {
Tree t = root.getTree(path);
if (t.exists()) {
t.remove();
root.commit();
}
}
}
}
Aggregations