Search in sources :

Example 6 with ChangeSetBuilder

use of org.apache.jackrabbit.oak.spi.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()));
    }
}
Also used : ChangeSetBuilder(org.apache.jackrabbit.oak.spi.observation.ChangeSetBuilder)

Example 7 with ChangeSetBuilder

use of org.apache.jackrabbit.oak.spi.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()));
}
Also used : ChangeSetBuilder(org.apache.jackrabbit.oak.spi.observation.ChangeSetBuilder) Test(org.junit.Test)

Example 8 with ChangeSetBuilder

use of org.apache.jackrabbit.oak.spi.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());
}
Also used : ChangeSetBuilder(org.apache.jackrabbit.oak.spi.observation.ChangeSetBuilder) Stopwatch(com.google.common.base.Stopwatch) ChangeSet(org.apache.jackrabbit.oak.spi.observation.ChangeSet) Test(org.junit.Test)

Example 9 with ChangeSetBuilder

use of org.apache.jackrabbit.oak.spi.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()));
}
Also used : ChangeSetBuilder(org.apache.jackrabbit.oak.spi.observation.ChangeSetBuilder) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with ChangeSetBuilder

use of org.apache.jackrabbit.oak.spi.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;
}
Also used : ChangeSetBuilder(org.apache.jackrabbit.oak.spi.observation.ChangeSetBuilder)

Aggregations

ChangeSetBuilder (org.apache.jackrabbit.oak.spi.observation.ChangeSetBuilder)11 Test (org.junit.Test)8 Stopwatch (com.google.common.base.Stopwatch)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 StringSort (org.apache.jackrabbit.oak.commons.sort.StringSort)1 ChangeSet (org.apache.jackrabbit.oak.spi.observation.ChangeSet)1 Clock (org.apache.jackrabbit.oak.stats.Clock)1