use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method doTestPropertyOverflown.
private void doTestPropertyOverflown(int overflowCnt) throws CommitFailedException, PrivilegedActionException {
setup();
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
Tree child1 = rootTree.getChild("child1");
Set<String> expectedPropertyNames = Sets.newHashSet();
for (int i = 0; i < collectorProvider.getMaxItems() + overflowCnt; i++) {
child1.setProperty("aProperty" + i, "foo");
expectedPropertyNames.add("aProperty" + i);
}
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), "/test/child1");
assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "child1");
assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:childType");
assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType", "test:childType");
assertEquals("propertyNames", null, changeSet.getPropertyNames());
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testAddNonEmptyGrandChild.
@Test
public void testAddNonEmptyGrandChild() throws CommitFailedException {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
Tree child = rootTree.addChild("child");
child.setProperty("childProperty", 1);
Tree grandChild = child.addChild("grandChild");
grandChild.setProperty("grandChildProperty", 2);
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), "/test", "/test/child", "/test/child/grandChild");
assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "test", "child", "grandChild");
assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:parentType");
assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType");
assertMatches("propertyNames", changeSet.getPropertyNames(), "childProperty", "grandChildProperty");
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testAddNodeWithProperties.
@Test
public void testAddNodeWithProperties() throws Exception {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
Tree aChild = rootTree.addChild("newchild");
aChild.setProperty("aProp", "aValue", Type.NAME);
aChild.setProperty(JcrConstants.JCR_PRIMARYTYPE, "aPrimaryType", Type.NAME);
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), "/test", "/test/newchild");
assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "test", "newchild");
assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:parentType", "aPrimaryType");
assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType", "aPrimaryType");
assertMatches("propertyNames", changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE, "aProp");
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testAddEmptyChild.
@Test
public void testAddEmptyChild() throws CommitFailedException {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
rootTree.addChild("child");
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), "/test");
assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "test");
assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:parentType");
assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType");
assertMatches("propertyNames", changeSet.getPropertyNames());
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method doChangeMaxPathDepth.
private void doChangeMaxPathDepth(int changeAt, 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();
recorder.changes.clear();
// now do the change
root = session.getLatestRoot();
rootTree = root.getTree("/test");
next = rootTree;
List<String> expectedParentPaths = new LinkedList<String>();
List<String> expectedParentNodeNames = new LinkedList<String>();
Set<String> expectedAllNodeTypes = new HashSet<String>();
List<String> expectedParentNodeTypes = new LinkedList<String>();
List<String> expectedPropertyNames = new LinkedList<String>();
expectedPropertyNames.add(JcrConstants.JCR_PRIMARYTYPE);
String parent = "/";
if (maxPathDepth > 0) {
parent = "/test";
}
expectedAllNodeTypes.add("test:parentType");
for (int i = 0; i <= changeAt; i++) {
String childName = "n" + i;
next = next.getChild(childName);
if (i < maxPathDepth - 1) {
parent = concat(parent, childName);
}
final String originalNodeTypeName = i % 2 == 0 ? "test:even" : "test:odd";
if (i % 3 != 0) {
if (i == changeAt) {
expectedParentNodeTypes.add(originalNodeTypeName);
}
expectedAllNodeTypes.add(originalNodeTypeName);
}
if (i == changeAt) {
expectedParentNodeNames.add(next.getName());
String propertyName = "nextProp" + i;
next.setProperty(propertyName, i + 1);
expectedPropertyNames.add(propertyName);
final String changedNodeTypeName = i % 2 == 0 ? "test:evenChanged" : "test:oddChanged";
expectedParentNodeTypes.add(changedNodeTypeName);
expectedAllNodeTypes.add(changedNodeTypeName);
next.setProperty(JcrConstants.JCR_PRIMARYTYPE, changedNodeTypeName, Type.NAME);
}
}
expectedParentPaths.add(parent);
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths-" + changeAt + "-" + maxPathDepth, changeSet.getParentPaths(), expectedParentPaths.toArray(new String[0]));
assertMatches("parentNodeNames-" + changeAt + "-" + maxPathDepth, changeSet.getParentNodeNames(), expectedParentNodeNames.toArray(new String[0]));
assertMatches("parentNodeTypes-" + changeAt + "-" + maxPathDepth, changeSet.getParentNodeTypes(), expectedParentNodeTypes.toArray(new String[0]));
assertMatches("allNodeTypes-" + changeAt + "-" + maxPathDepth, changeSet.getAllNodeTypes(), expectedAllNodeTypes.toArray(new String[0]));
assertMatches("propertyNames-" + changeAt + "-" + maxPathDepth, changeSet.getPropertyNames(), expectedPropertyNames.toArray(new String[0]));
}
Aggregations