use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeSetFilterImplTest method manyIncludePaths.
@Test
public void manyIncludePaths() throws Exception {
int numPaths = 50;
ChangeSetBuilder builder = newBuilder(50, 9);
for (int i = 0; i < numPaths; i++) {
builder.addParentPath("/a/b/c/d/e/n" + i);
}
ChangeSet cs = builder.build();
Set<String> includes = Sets.newHashSet();
for (int i = 0; i < 100; i++) {
includes.add("/foo/bar/n-" + i + "/*.jsp");
}
ChangeSetFilter filter = new ChangeSetFilterImpl(s(), true, includes, s(), s(), s(), s());
// warm up
doManyIncludePaths(filter, cs);
// and measure
Stopwatch sw = Stopwatch.createStarted();
doManyIncludePaths(filter, cs);
LOG.info("manyIncludePaths() took {}", sw.stop());
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testPropertyNotOverflown.
@Test
public void testPropertyNotOverflown() throws Exception {
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(); 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");
assertMatches("propertyNames", changeSet.getPropertyNames(), expectedPropertyNames.toArray(new String[0]));
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method setup.
@Before
public void setup() throws PrivilegedActionException, CommitFailedException {
collectorProvider = new ChangeCollectorProvider();
recorder = new Recorder();
Oak oak = new Oak().with(new InitialContent()).with(collectorProvider).with(recorder).with(getSecurityProvider());
contentRepository = oak.createContentRepository();
session = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {
@Override
public ContentSession run() throws LoginException, NoSuchWorkspaceException {
return contentRepository.login(null, null);
}
});
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/").addChild("test");
rootTree.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:parentType", Type.NAME);
Tree child1 = rootTree.addChild("child1");
child1.setProperty("child1Prop", 1);
child1.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:childType", Type.NAME);
Tree grandChild1 = child1.addChild("grandChild1");
grandChild1.setProperty("grandChild1Prop", 1);
grandChild1.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:grandChildType", Type.NAME);
Tree greatGrandChild1 = grandChild1.addChild("greatGrandChild1");
greatGrandChild1.setProperty("greatGrandChild1Prop", 1);
greatGrandChild1.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:greatGrandChildType", Type.NAME);
Tree child2 = rootTree.addChild("child2");
child2.setProperty("child2Prop", 1);
child2.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:childType", Type.NAME);
Tree grandChild2 = child2.addChild("grandChild2");
grandChild2.setProperty("grandChild2Prop", 1);
grandChild2.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:grandChildType", Type.NAME);
recorder.changes.clear();
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), "/test/child2", "/test/child1", "/test/child1/grandChild1/greatGrandChild1", "/", "/test", "/test/child1/grandChild1", "/test/child2/grandChild2");
assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "child2", "child1", "greatGrandChild1", "test", "grandChild1", "grandChild2");
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", "child2Prop", "grandChild1Prop", "grandChild2Prop", "greatGrandChild1Prop");
// clear the recorder so that we start off empty
recorder.changes.clear();
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method doTestPathOverflown.
private void doTestPathOverflown(int overflowCnt) throws CommitFailedException, PrivilegedActionException {
setup();
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
for (int i = 0; i < collectorProvider.getMaxItems() + overflowCnt; i++) {
rootTree.addChild("manychildren" + i).setProperty("aProperty", "foo");
;
}
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertEquals("parentPaths", null, changeSet.getParentPaths());
assertEquals("parentNodeNames", null, changeSet.getParentNodeNames());
assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:parentType");
assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType");
assertMatches("propertyNames", changeSet.getPropertyNames(), "aProperty");
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method getSingleChangeSet.
/**
* Assumes that the recorder got 1 call, and extracts the ChangeSet from
* that call
*/
private ChangeSet getSingleChangeSet() {
assertEquals(recorder.changes.size(), 1);
CommitContext commitContext = (CommitContext) recorder.changes.get(0).info.getInfo().get(CommitContext.NAME);
assertNotNull(commitContext);
ChangeSet changeSet = (ChangeSet) commitContext.get(ChangeSet.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
assertNotNull(changeSet);
return changeSet;
}
Aggregations