use of org.apache.jackrabbit.oak.plugins.observation.ChangeSetBuilder in project jackrabbit-oak by apache.
the class ChangeSetFilterImplTest method testUnpreciseInclude.
@Test
public void testUnpreciseInclude() throws Exception {
ChangeSetBuilder builder = newBuilder(5, 5);
builder.addNodeType("nt:file");
builder.addParentNodeType("nt:file");
builder.addParentPath("/a/b/c/e");
builder.addParentNodeName("d");
builder.addPropertyName("e");
builder.addPropertyName("f");
Set<String> largeExcludeSet = new HashSet<String>();
for (int a = 0; a < 3; a++) {
for (int b = 0; b < 3; b++) {
for (int c = 0; c < 10; c++) {
String s = "/a";
if (a > 0) {
s += a;
}
s += "/b";
if (b > 0) {
s += b;
}
s += "/c";
if (c > 0) {
s += c;
}
s += "/d";
largeExcludeSet.add(s);
}
}
}
ChangeSetFilterImpl prefilter = new ChangeSetFilterImpl(s("/"), true, null, largeExcludeSet, s("foo", "bars"), s("nt:file"), s(), 999);
assertTrue(prefilter.excludes(builder.build()));
prefilter = new ChangeSetFilterImpl(s("/"), true, null, largeExcludeSet, s("foo", "bars"), s("nt:file"), s(), 15);
assertFalse(prefilter.excludes(builder.build()));
prefilter = new ChangeSetFilterImpl(s("/"), true, null, largeExcludeSet, s("foo", "bars"), s("nt:file"), s(), 1);
assertFalse(prefilter.excludes(builder.build()));
}
use of org.apache.jackrabbit.oak.plugins.observation.ChangeSetBuilder in project jackrabbit-oak by apache.
the class ChangeSetFilterImplTest method sampleBuilder.
private ChangeSetBuilder sampleBuilder() {
ChangeSetBuilder builder = newBuilder(5, 5);
builder.addNodeType("nt:file");
builder.addParentNodeType("nt:file");
builder.addParentPath("/bar");
builder.addParentNodeName("bar");
builder.addPropertyName("a");
builder.addPropertyName("b");
return builder;
}
use of org.apache.jackrabbit.oak.plugins.observation.ChangeSetBuilder in project jackrabbit-oak by apache.
the class ChangeSetFilterImplTest method testIncludeOnParentNodeNameOverflow.
@Test
public void testIncludeOnParentNodeNameOverflow() throws Exception {
ChangeSetBuilder builder = sampleBuilder();
ChangeSetFilterImpl prefilter = new ChangeSetFilterImpl(s("/"), true, null, s("/excluded"), s("foo", "bars"), s("nt:file"), s());
assertTrue(prefilter.excludes(builder.build()));
overflowParentNodeNames(builder);
assertFalse(prefilter.excludes(builder.build()));
}
use of org.apache.jackrabbit.oak.plugins.observation.ChangeSetBuilder 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.plugins.observation.ChangeSetBuilder in project jackrabbit-oak by apache.
the class ChangeSetFilterImplTest method doTestDeepPath.
private void doTestDeepPath(String changeSetPath, String includePath, int maxPathDepth, boolean expectExclude) {
ChangeSetBuilder builder = newBuilder(5, maxPathDepth);
builder.addNodeType("nt:file");
builder.addParentNodeType("nt:file");
builder.addParentPath("/bar");
builder.addParentNodeName("bar");
builder.addPropertyName("a");
builder.addPropertyName("b");
builder.addParentPath(changeSetPath);
builder.addParentNodeName(PathUtils.getName(changeSetPath));
ChangeSetFilterImpl prefilter = new ChangeSetFilterImpl(s(includePath), true, null, s("/excluded"), s("foo", "bars", "l"), s("nt:file"), s());
if (expectExclude) {
assertTrue(prefilter.excludes(builder.build()));
} else {
assertFalse(prefilter.excludes(builder.build()));
}
}
Aggregations