ChangeSetFilterImpl implements ChangeSetFilter { @Override public boolean excludes(ChangeSet changeSet) { try{ return doExcludes(changeSet); } catch(Exception e) { LOG.warn("excludes: got an Exception while evaluating excludes: " + e.getMessage() + ", changeSet=" + changeSet, e); return false; } } ChangeSetFilterImpl(@NotNull Set<String> includedParentPaths, boolean isDeep,
            @Nullable Set<String> additionalIncludedParentPaths, Set<String> excludedParentPaths,
            Set<String> parentNodeNames, Set<String> parentNodeTypes, Set<String> propertyNames);  ChangeSetFilterImpl(@NotNull Set<String> includedParentPaths, boolean isDeep,
            @Nullable Set<String> additionalIncludedParentPaths, Set<String> excludedParentPaths,
            Set<String> parentNodeNames, Set<String> parentNodeTypes, Set<String> propertyNames,
            int maxExcludedPaths); @Override String toString(); Set<String> getRootIncludePaths(); @Override boolean excludes(ChangeSet changeSet);  }
@Test public void testIsDeepFalse() throws Exception { ChangeSetFilterImpl prefilter = new ChangeSetFilterImpl(s("/"), false, null, s("/excluded"), s(), s(), s()); assertTrue(prefilter.excludes(newChangeSet(5, s("/child1", "/child2"), s("child1", "child2"), s(), s()))); assertFalse(prefilter.excludes(newChangeSet(5, s("/", "/child2"), s("child2"), s(), s()))); }
@Test public void testParentPathsIncludeExclude() throws Exception { ChangeSetFilterImpl prefilter = new ChangeSetFilterImpl(s("/"), true, null, s("/excluded"), s(), s(), s()); assertFalse(prefilter.excludes(newChangeSet(5, s("/a", "/b"), s("a", "b"), s(), s()))); assertTrue(prefilter.excludes(newChangeSet(5, s("/excluded/foo", "/excluded/bar"), s("foo", "bar"), s(), s()))); prefilter = new ChangeSetFilterImpl(s("/included"), true, null, s("/excluded"), s(), s(), s()); assertTrue(prefilter.excludes(newChangeSet(5, s("/a", "/b"), s(), s(), s()))); assertFalse(prefilter.excludes(newChangeSet(5, s("/included/a", "/included/b"), s(), s(), s()))); assertTrue(prefilter.excludes(newChangeSet(5, s("/excluded/foo", "/excluded/bar"), s(), s(), s()))); prefilter = new ChangeSetFilterImpl(s("/fooincluded, null, s("/excluded"), s(), s(), s()); assertTrue(prefilter.excludes(newChangeSet(5, s("/a", "/b"), s(), s(), s()))); assertTrue(prefilter.excludes(newChangeSet(5, s("/included/a", "/included/b"), s(), s(), s()))); assertFalse(prefilter.excludes(newChangeSet(5, s("/foo/included/a"), s(), s(), s()))); assertTrue(prefilter.excludes(newChangeSet(5, s("/included/b"), s(), s(), s()))); assertFalse(prefilter.excludes(newChangeSet(5, s("/foo/bar/included/a", "/included/b"), s(), s(), s()))); assertTrue(prefilter.excludes(newChangeSet(5, s("/excluded/foo", "/excluded/bar"), s(), s(), s()))); prefilter = new ChangeSetFilterImpl(s("/mainincluded"), true, null, s("/main/excluded"), s(), s(), s()); assertTrue(prefilter.excludes(newChangeSet(5, s("/main", "/main/foo"), s(), s(), s()))); assertFalse(prefilter.excludes(newChangeSet(5, s("/main/included", "/main/excluded"), s(), s(), s()))); assertTrue(prefilter.excludes(newChangeSet(5, s("/main/excluded/included", "/main/excluded"), s(), s(), s()))); prefilter = new ChangeSetFilterImpl(s("/main/included**"), true, null, s("/main/excluded"), s(), s(), s()); assertTrue(prefilter.excludes(newChangeSet(5, s("/main", "/main/foo"), s(), s(), s()))); assertTrue(prefilter.excludes(newChangeSet(5, s("/main/excluded"), s(), s(), s()))); assertFalse(prefilter.excludes(newChangeSet(5, s("/main/inc-luded"), s(), s(), s()))); assertTrue(prefilter.excludes(newChangeSet(5, s("/main/excluded/included", "/main/excluded"), s(), s(), s()))); }
@Test public void testParentNodeNames() throws Exception { ChangeSetFilterImpl prefilter = new ChangeSetFilterImpl(s("/"), true, null, s(), s("foo", "bar"), s(), s()); assertFalse(prefilter.excludes(newChangeSet(5, s("/a/foo", "/b"), s("foo", "b"), s(), s()))); assertTrue(prefilter.excludes(newChangeSet(5, s("/a/zoo", "/b"), s("zoo", "b"), s(), s()))); assertFalse(prefilter.excludes(newChangeSet(5, s("/a/zoo", "/bar"), s("zoo", "bar"), s(), s()))); }
@Test public void testParentNodeTypes() throws Exception { ChangeSetFilterImpl prefilter = new ChangeSetFilterImpl(s("/"), true, null, s(), s(), s("nt:folder"), s()); assertTrue(prefilter.excludes(newChangeSet(5, s("/a"), s("a"), s("nt:unstructured"), s()))); assertFalse(prefilter.excludes(newChangeSet(5, s("/a"), s("a"), s("nt:folder"), s()))); }
@Test public void testPropertyNames() throws Exception { ChangeSetFilterImpl prefilter = new ChangeSetFilterImpl(s("/"), true, null, s(), s(), s(), s("jcr:data")); assertTrue(prefilter.excludes(newChangeSet(5, s("/a"), s("a"), s(), s("myProperty")))); assertFalse(prefilter.excludes(newChangeSet(5, s("/a"), s("a"), s(), s("jcr:data")))); }
@Test public void testIncludeOnAllNodeTypeOverflow() 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())); overflowAllNodeTypes(builder); assertFalse(prefilter.excludes(builder.build())); }
@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())); }
@Test public void testIncludeOnPropertyNamesOverflow() 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())); overflowPropertyNames(builder); assertFalse(prefilter.excludes(builder.build())); }
@Test public void testIncludeOnParentNodeTypeOverflow() 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())); overflowParentNodeTypes(builder); assertFalse(prefilter.excludes(builder.build())); }
@Test public void testIncludeOnParentPathsOverflow() 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())); overflowParentPaths(builder); assertFalse(prefilter.excludes(builder.build())); }
@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())); }