use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method doRemoveMaxPathDepth.
private void doRemoveMaxPathDepth(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();
// now do the delete
recorder.changes.clear();
root = session.getLatestRoot();
rootTree = root.getTree("/test");
next = rootTree;
for (int i = 0; i < 15; i++) {
next = next.getChild("n" + i);
if (i == 14) {
next.remove();
}
}
root.commit();
ChangeSet changeSet = getSingleChangeSet();
Set<String> expectedParentPaths = new HashSet<String>();
String path = "/";
if (maxPathDepth == 1) {
path = "/test";
} else if (maxPathDepth > 1) {
path = "/test";
for (int i = 0; i < maxPathDepth - 1; i++) {
path = concat(path, "n" + i);
}
}
expectedParentPaths.add(path);
assertMatches("parentPaths-" + maxPathDepth, changeSet.getParentPaths(), expectedParentPaths.toArray(new String[0]));
assertMatches("parentNodeNames-" + maxPathDepth, changeSet.getParentNodeNames(), "n13", "n14");
assertMatches("parentNodeTypes-" + maxPathDepth, changeSet.getParentNodeTypes(), "test:even", "test:odd");
assertMatches("allNodeTypes-" + maxPathDepth, changeSet.getAllNodeTypes(), "test:parentType", "test:even", "test:odd");
assertMatches("propertyNames-" + maxPathDepth, changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE, "nextProp14");
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testPathNotOverflown.
@Test
public void testPathNotOverflown() throws Exception {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
Set<String> expectedParentPaths = Sets.newHashSet();
expectedParentPaths.add("/test");
Set<String> expectedParentNodeNames = Sets.newHashSet();
expectedParentNodeNames.add("test");
Set<String> expectedParentNodeTypes = Sets.newHashSet();
expectedParentNodeTypes.add("test:parentType");
// avoid overflowing
for (int i = 0; i < collectorProvider.getMaxItems() - 1; i++) {
Tree aChild = rootTree.addChild("manychildren" + i);
aChild.setProperty("aProperty", "foo");
aChild.setProperty(JcrConstants.JCR_PRIMARYTYPE, "aChildPrimaryType" + i, Type.NAME);
expectedParentPaths.add("/test/manychildren" + i);
expectedParentNodeNames.add("manychildren" + i);
expectedParentNodeTypes.add("aChildPrimaryType" + i);
}
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), expectedParentPaths.toArray(new String[0]));
assertMatches("parentNodeNames", changeSet.getParentNodeNames(), expectedParentNodeNames.toArray(new String[0]));
assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), expectedParentNodeTypes.toArray(new String[0]));
assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), expectedParentNodeTypes.toArray(new String[0]));
assertMatches("propertyNames", changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE, "aProperty");
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testRemoveGreatGrandChild.
@Test
public void testRemoveGreatGrandChild() throws CommitFailedException {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
assertTrue(rootTree.getChild("child1").getChild("grandChild1").getChild("greatGrandChild1").remove());
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), "/test/child1/grandChild1/greatGrandChild1", "/test/child1/grandChild1");
assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "grandChild1", "greatGrandChild1");
assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:greatGrandChildType", "test:grandChildType");
assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType", "test:childType", "test:grandChildType", "test:greatGrandChildType");
assertMatches("propertyNames", changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE, "greatGrandChild1Prop");
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testChangeGreatAndGrandChild.
@Test
public void testChangeGreatAndGrandChild() throws CommitFailedException {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
rootTree.getChild("child1").getChild("grandChild1").setProperty("grandChild1Prop", 2);
rootTree.getChild("child1").getChild("grandChild1").getChild("greatGrandChild1").setProperty("greatGrandChild1Prop", 2);
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), "/test/child1/grandChild1", "/test/child1/grandChild1/greatGrandChild1");
assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "grandChild1", "greatGrandChild1");
assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:grandChildType", "test:greatGrandChildType");
assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType", "test:childType", "test:grandChildType", "test:greatGrandChildType");
assertMatches("propertyNames", changeSet.getPropertyNames(), "grandChild1Prop", "greatGrandChild1Prop");
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testRemoveChild.
@Test
public void testRemoveChild() throws CommitFailedException {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
assertTrue(rootTree.getChild("child1").remove());
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), "/test", "/test/child1", "/test/child1/grandChild1", "/test/child1/grandChild1/greatGrandChild1");
assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "test", "child1", "grandChild1", "greatGrandChild1");
assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:parentType", "test:childType", "test:grandChildType", "test:greatGrandChildType");
assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType", "test:childType", "test:grandChildType", "test:greatGrandChildType");
assertMatches("propertyNames", changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE, "child1Prop", "grandChild1Prop", "greatGrandChild1Prop");
}
Aggregations