Search in sources :

Example 1 with ChangeSet

use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.

the class ChangeCollectorProviderTest method testAddMixin.

@Test
public void testAddMixin() throws Exception {
    Root root = session.getLatestRoot();
    Tree rootTree = root.getTree("/test");
    rootTree.addChild("child").setProperty(JcrConstants.JCR_MIXINTYPES, Arrays.asList("aMixin1", "aMixin2"), Type.NAMES);
    root.commit();
    ChangeSet changeSet = getSingleChangeSet();
    assertMatches("parentPaths", changeSet.getParentPaths(), "/test", "/test/child");
    assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "test", "child");
    assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:parentType", "aMixin1", "aMixin2");
    assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType", "aMixin1", "aMixin2");
    assertMatches("propertyNames", changeSet.getPropertyNames(), JcrConstants.JCR_MIXINTYPES);
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) Tree(org.apache.jackrabbit.oak.api.Tree) ChangeSet(org.apache.jackrabbit.oak.spi.observation.ChangeSet) Test(org.junit.Test)

Example 2 with ChangeSet

use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.

the class ChangeCollectorProviderTest method testChangeGreatGrandChild.

@Test
public void testChangeGreatGrandChild() throws CommitFailedException {
    Root root = session.getLatestRoot();
    Tree rootTree = root.getTree("/test");
    rootTree.getChild("child1").getChild("grandChild1").getChild("greatGrandChild1").setProperty("greatGrandChild1Prop", 2);
    root.commit();
    ChangeSet changeSet = getSingleChangeSet();
    assertMatches("parentPaths", changeSet.getParentPaths(), "/test/child1/grandChild1/greatGrandChild1");
    assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "greatGrandChild1");
    assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:greatGrandChildType");
    assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType", "test:childType", "test:grandChildType", "test:greatGrandChildType");
    assertMatches("propertyNames", changeSet.getPropertyNames(), "greatGrandChild1Prop");
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) Tree(org.apache.jackrabbit.oak.api.Tree) ChangeSet(org.apache.jackrabbit.oak.spi.observation.ChangeSet) Test(org.junit.Test)

Example 3 with ChangeSet

use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.

the class ChangeCollectorProviderTest method testAddEmptyRemoveChildren.

@Test
public void testAddEmptyRemoveChildren() throws CommitFailedException {
    Root root = session.getLatestRoot();
    Tree rootTree = root.getTree("/test");
    Tree child = rootTree.addChild("child");
    child.addChild("grandChild");
    assertTrue(rootTree.getChild("child2").remove());
    root.commit();
    ChangeSet changeSet = getSingleChangeSet();
    assertMatches("parentPaths", changeSet.getParentPaths(), "/test", "/test/child", "/test/child2", "/test/child2/grandChild2");
    assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "test", "child", "child2", "grandChild2");
    assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:parentType", "test:childType", "test:grandChildType");
    assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType", "test:childType", "test:grandChildType");
    assertMatches("propertyNames", changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE, "child2Prop", "grandChild2Prop");
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) Tree(org.apache.jackrabbit.oak.api.Tree) ChangeSet(org.apache.jackrabbit.oak.spi.observation.ChangeSet) Test(org.junit.Test)

Example 4 with ChangeSet

use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.

the class ChangeCollectorProviderTest method testAddEmptyGrandChild.

@Test
public void testAddEmptyGrandChild() throws CommitFailedException {
    Root root = session.getLatestRoot();
    Tree rootTree = root.getTree("/test");
    Tree child = rootTree.addChild("child");
    child.addChild("grandChild");
    root.commit();
    ChangeSet changeSet = getSingleChangeSet();
    assertMatches("parentPaths", changeSet.getParentPaths(), "/test", "/test/child");
    assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "test", "child");
    assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:parentType");
    assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType");
    assertMatches("propertyNames", changeSet.getPropertyNames());
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) Tree(org.apache.jackrabbit.oak.api.Tree) ChangeSet(org.apache.jackrabbit.oak.spi.observation.ChangeSet) Test(org.junit.Test)

Example 5 with ChangeSet

use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.

the class ChangeCollectorProviderTest method doAddMaxPathDepth.

private void doAddMaxPathDepth(int maxPathDepth) throws CommitFailedException {
    collectorProvider.setMaxPathDepth(maxPathDepth);
    Root root = session.getLatestRoot();
    Tree rootTree = root.getTree("/test");
    Tree next = rootTree;
    for (int i = 0; i < 16; i++) {
        next = next.addChild("n" + i);
        if (i % 3 != 0) {
            next.setProperty("nextProp" + i, i);
            next.setProperty(JcrConstants.JCR_PRIMARYTYPE, i % 2 == 0 ? "test:even" : "test:odd", Type.NAME);
        }
    }
    root.commit();
    ChangeSet changeSet = getSingleChangeSet();
    List<String> expectedParentPaths = new LinkedList<String>();
    if (maxPathDepth == 0) {
        expectedParentPaths.add("/");
    } else {
        expectedParentPaths.add("/test");
    }
    for (int i = 0; i < maxPathDepth - 1; i++) {
        StringBuffer path = new StringBuffer("/test");
        for (int j = 0; j < i; j++) {
            path.append("/n" + j);
        }
        expectedParentPaths.add(path.toString());
    }
    assertMatches("parentPaths-" + maxPathDepth, changeSet.getParentPaths(), expectedParentPaths.toArray(new String[0]));
    assertMatches("parentNodeNames-" + maxPathDepth, changeSet.getParentNodeNames(), "test", "n0", "n1", "n2", "n3", "n4", "n5", "n6", "n7", "n8", "n9", "n10", "n11", "n12", "n13", "n14");
    assertMatches("parentNodeTypes-" + maxPathDepth, changeSet.getParentNodeTypes(), "test:parentType", "test:even", "test:odd");
    assertMatches("allNodeTypes-" + maxPathDepth, changeSet.getAllNodeTypes(), "test:parentType", "test:even", "test:odd");
    assertMatches("propertyNames-" + maxPathDepth, changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE, /* "nextProp0", */
    "nextProp1", "nextProp2", /* "nextProp3", */
    "nextProp4", "nextProp5", /* , "nextProp6" */
    "nextProp7", "nextProp8", /* "nextProp9", */
    "nextProp10", "nextProp11", /* "nextProp12", */
    "nextProp13", "nextProp14");
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) Tree(org.apache.jackrabbit.oak.api.Tree) ChangeSet(org.apache.jackrabbit.oak.spi.observation.ChangeSet) LinkedList(java.util.LinkedList)

Aggregations

ChangeSet (org.apache.jackrabbit.oak.spi.observation.ChangeSet)26 Root (org.apache.jackrabbit.oak.api.Root)19 Tree (org.apache.jackrabbit.oak.api.Tree)19 Test (org.junit.Test)18 CommitContext (org.apache.jackrabbit.oak.spi.commit.CommitContext)5 SimpleCommitContext (org.apache.jackrabbit.oak.spi.commit.SimpleCommitContext)4 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Stopwatch (com.google.common.base.Stopwatch)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 InitialContent (org.apache.jackrabbit.oak.InitialContent)1 Oak (org.apache.jackrabbit.oak.Oak)1 CommitInfoCollector (org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdateTest.CommitInfoCollector)1 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)1 ChangeSetBuilder (org.apache.jackrabbit.oak.spi.observation.ChangeSetBuilder)1 Before (org.junit.Before)1