use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class IndexSelectionTest method uuidIndexNotNullQuery.
@Test
public void uuidIndexNotNullQuery() throws Exception {
NodeUtil node = new NodeUtil(root.getTree("/"));
String uuid = UUID.randomUUID().toString();
node.setString(JcrConstants.JCR_UUID, uuid);
root.commit();
assertQuery("SELECT * FROM [nt:base] WHERE [jcr:uuid] is not null", ImmutableList.of("/"));
assertEquals("Test index plan should be invoked", 1, testIndexProvider.index.invocationCount);
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CompositeRestrictionProviderTest method testWriteRestrictions.
@Test
public void testWriteRestrictions() throws Exception {
NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
Set<Restriction> restrictions = ImmutableSet.of(provider.createRestriction("/test", "boolean", vf.createValue(true)), provider.createRestriction("/test", "longs"), provider.createRestriction("/test", REP_GLOB, vf.createValue("*")), provider.createRestriction("/test", REP_NT_NAMES, vf.createValue("nt:base", PropertyType.NAME), vf.createValue("nt:version", PropertyType.NAME)));
provider.writeRestrictions("/test", aceNode.getTree(), restrictions);
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CustomRestrictionProviderTest method before.
@Before
@Override
public void before() throws Exception {
super.before();
NodeUtil rootNode = new NodeUtil(root.getTree("/"));
NodeUtil testRootNode = rootNode.addChild("testRoot", NT_UNSTRUCTURED);
NodeUtil a = testRootNode.addChild("a", NT_UNSTRUCTURED);
NodeUtil b = a.addChild("b", NT_UNSTRUCTURED);
NodeUtil c = b.addChild("c", NT_UNSTRUCTURED);
c.setBoolean(PROP_NAME_PROTECT_ME, true);
NodeUtil d = c.addChild("d", NT_UNSTRUCTURED);
d.addChild("e", NT_UNSTRUCTURED);
root.commit();
testPrincipal = getTestUser().getPrincipal();
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class ItemNamePatternTest method testMatchesItem.
@Test
public void testMatchesItem() throws Exception {
NodeUtil rootTree = new NodeUtil(root.getTree("/"));
List<String> matching = ImmutableList.of("a", "b", "c", "d/e/a", "a/b/c/d/b", "test/c");
for (String relPath : matching) {
Tree testTree = rootTree.getOrAddTree(relPath, NodeTypeConstants.NT_OAK_UNSTRUCTURED).getTree();
assertTrue(pattern.matches(testTree, null));
assertTrue(pattern.matches(testTree, PropertyStates.createProperty("a", Boolean.FALSE)));
assertFalse(pattern.matches(testTree, PropertyStates.createProperty("f", "anyval")));
testTree.remove();
}
List<String> notMatching = ImmutableList.of("d", "b/d", "d/e/f", "c/b/abc");
for (String relPath : notMatching) {
Tree testTree = rootTree.getOrAddTree(relPath, NodeTypeConstants.NT_OAK_UNSTRUCTURED).getTree();
assertFalse(pattern.matches(testTree, null));
assertTrue(pattern.matches(testTree, PropertyStates.createProperty("a", Boolean.FALSE)));
assertFalse(pattern.matches(testTree, PropertyStates.createProperty("f", "anyval")));
testTree.remove();
}
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class PrefixPatternTest method testMatchesItem.
@Test
public void testMatchesItem() throws Exception {
NodeUtil rootTree = new NodeUtil(root.getTree("/"));
for (String prefix : prefixes) {
Tree testTree = rootTree.addChild(prefix + ":name", NodeTypeConstants.NT_OAK_UNSTRUCTURED).getTree();
assertTrue(pattern.matches(testTree, null));
assertTrue(pattern.matches(testTree, PropertyStates.createProperty(prefix + ":f", "anyval")));
assertFalse(pattern.matches(testTree, PropertyStates.createProperty("a", Boolean.FALSE)));
testTree.remove();
}
List<String> notMatching = ImmutableList.of(NamespaceRegistry.PREFIX_EMPTY, NamespaceRegistry.PREFIX_MIX, "any");
for (String prefix : notMatching) {
String name = (prefix.isEmpty()) ? "name" : prefix + ":name";
Tree testTree = rootTree.addChild(name, NodeTypeConstants.NT_OAK_UNSTRUCTURED).getTree();
assertFalse(pattern.matches(testTree, null));
assertFalse(pattern.matches(testTree, PropertyStates.createProperty("f", "anyval")));
assertTrue(pattern.matches(testTree, PropertyStates.createProperty("jcr:a", Boolean.FALSE)));
testTree.remove();
}
}
Aggregations