Search in sources :

Example 61 with NodeState

use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.

the class NodeTypePredicateTest method singleNodeTypeMatch.

@Test
public void singleNodeTypeMatch() {
    NodeState node = createNodeOfType(NT_BASE);
    TypePredicate p = new TypePredicate(node, new String[] { NT_BASE });
    assertTrue(p.apply(node));
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) TypePredicate(org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate) Test(org.junit.Test)

Example 62 with NodeState

use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.

the class GlobbingPathFilterTest method matchAtStart.

/**
     * **&#47a/b/c should match a/b/c
     */
@Test
public void matchAtStart() {
    EventFilter rootFilter = new GlobbingPathFilter("**/a/b/c");
    NodeState a = tree.getChild("a").getNodeState();
    assertFalse(rootFilter.includeAdd("a", a));
    EventFilter aFilter = rootFilter.create("a", a, a);
    assertNotNull(aFilter);
    NodeState b = a.getChildNode("b");
    assertFalse(aFilter.includeAdd("b", b));
    EventFilter bFilter = aFilter.create("b", b, b);
    assertNotNull(bFilter);
    NodeState c = b.getChildNode("c");
    assertTrue(bFilter.includeAdd("c", b));
    assertFalse(bFilter.includeAdd("x", b));
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Test(org.junit.Test)

Example 63 with NodeState

use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.

the class GlobbingPathFilterTest method emptyMatchesNothing.

/**
     * An empty path pattern should match no path
     */
@Test
public void emptyMatchesNothing() {
    EventFilter rootFilter = new GlobbingPathFilter("");
    NodeState a = tree.getChild("a").getNodeState();
    assertFalse(rootFilter.includeAdd("a", a));
    assertNull(rootFilter.create("a", a, a));
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Test(org.junit.Test)

Example 64 with NodeState

use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.

the class CompositeTreePermissionTest method testMultipleToSingle.

@Test
public void testMultipleToSingle() {
    TreePermission rootTp = createRootTreePermission(fullScopeProvider, new NoScopeProvider(root), new NoScopeProvider(root));
    assertCompositeTreePermission(true, rootTp);
    NodeState childState = rootTree.getChild("test").getNodeState();
    TreePermission testTp = rootTp.getChildPermission("test", childState);
    TreePermission expected = fullScopeProvider.getTreePermission(rootTree, TreePermission.EMPTY).getChildPermission("test", childState);
    assertEquals(expected.getClass(), testTp.getClass());
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 65 with NodeState

use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.

the class CompositeProviderNoScopeTest method testTreePermissionGetChild.

@Override
@Test
public void testTreePermissionGetChild() throws Exception {
    List<String> childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting");
    Tree rootTree = readOnlyRoot.getTree(ROOT_PATH);
    NodeState ns = ((ImmutableTree) rootTree).getNodeState();
    TreePermission tp = createPermissionProvider().getTreePermission(rootTree, TreePermission.EMPTY);
    assertCompositeTreePermission(tp);
    for (String cName : childNames) {
        ns = ns.getChildNode(cName);
        tp = tp.getChildPermission(cName, ns);
        assertCompositeTreePermission(false, tp);
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Tree(org.apache.jackrabbit.oak.api.Tree) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) Test(org.junit.Test)

Aggregations

NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)580 Test (org.junit.Test)375 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)254 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)69 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)46 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)45 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)43 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)39 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)36 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)33 AbstractNodeState (org.apache.jackrabbit.oak.spi.state.AbstractNodeState)32 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)29 Nonnull (javax.annotation.Nonnull)28 Tree (org.apache.jackrabbit.oak.api.Tree)23 NodeStateTestUtils.getNodeState (org.apache.jackrabbit.oak.upgrade.util.NodeStateTestUtils.getNodeState)23 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)19 DocumentNodeState (org.apache.jackrabbit.oak.plugins.document.DocumentNodeState)18 ArrayList (java.util.ArrayList)17 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)16 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)15