use of org.apache.jackrabbit.api.observation.JackrabbitEventFilter in project jackrabbit-oak by apache.
the class ObservationTest method testAggregate4.
@Test
public void testAggregate4() throws Exception {
assumeTrue(observationManager instanceof ObservationManagerImpl);
ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager;
ExpectationListener listener = new ExpectationListener();
JackrabbitEventFilter filter = new JackrabbitEventFilter();
filter.setEventTypes(ALL_EVENTS);
filter = FilterFactory.wrap(filter).withNodeTypeAggregate(new String[] { "oak:Unstructured" }, new String[] { "**/foo/**" }).withIncludeGlobPaths("/parent/**/bar/**");
oManager.addEventListener(listener, filter);
ChangeProcessor cp = oManager.getChangeProcessor(listener);
assertNotNull(cp);
FilterProvider filterProvider = cp.getFilterProvider();
assertNotNull(filterProvider);
assertMatches(filterProvider.getSubTrees(), "/parent");
Node parent = getAdminSession().getRootNode().addNode("parent", "nt:unstructured");
Node a = parent.addNode("a", "nt:unstructured");
Node b = a.addNode("b", "nt:unstructured");
Node bar = b.addNode("bar", "oak:Unstructured");
// OAK-5096: in OR mode the following event also gets sent:
listener.expect(bar.getPath() + "/jcr:primaryType", PROPERTY_ADDED);
Node c = bar.addNode("c", "nt:unstructured");
// OAK-5096: in OR mode the following event also gets sent:
listener.expectAdd(c);
Node foo = c.addNode("foo", "nt:unstructured");
// OAK-5096: in OR mode the following event also gets sent:
listener.expectAdd(foo);
Node jcrContent = foo.addNode("jcr:content", "nt:unstructured");
listener.expectAdd(jcrContent);
parent.getSession().save();
Thread.sleep(1000);
List<Expectation> missing = listener.getMissing(TIME_OUT, TimeUnit.SECONDS);
List<Event> unexpected = listener.getUnexpected();
assertTrue("Unexpected events: " + unexpected, unexpected.isEmpty());
assertTrue("Missing events: " + missing, missing.isEmpty());
}
use of org.apache.jackrabbit.api.observation.JackrabbitEventFilter in project jackrabbit-oak by apache.
the class ObservationTest method testAggregate3.
@Test
public void testAggregate3() throws Exception {
assumeTrue(observationManager instanceof ObservationManagerImpl);
ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager;
ExpectationListener listener = new ExpectationListener();
JackrabbitEventFilter filter = new JackrabbitEventFilter();
filter.setAbsPath("/parent");
filter.setIsDeep(true);
filter.setEventTypes(ALL_EVENTS);
filter = FilterFactory.wrap(filter).withNodeTypeAggregate(new String[] { "oak:Unstructured" }, new String[] { "**" });
oManager.addEventListener(listener, filter);
Node parent = getAdminSession().getRootNode().addNode("parent", "nt:unstructured");
// OAK-5096: in OR mode the following event also gets sent:
listener.expect(parent.getPath() + "/jcr:primaryType", PROPERTY_ADDED);
Node child = parent.addNode("child", "nt:unstructured");
// OAK-5096: in OR mode the following event also gets sent:
listener.expectAdd(child);
Node file = child.addNode("file", "oak:Unstructured");
listener.expect(file.getPath(), "/parent/child/file", NODE_ADDED);
listener.expect(file.getPath() + "/jcr:primaryType", "/parent/child/file", PROPERTY_ADDED);
Node jcrContent = file.addNode("jcr:content", "nt:unstructured");
listener.expect(jcrContent.getPath(), "/parent/child/file", NODE_ADDED);
listener.expect(jcrContent.getPath() + "/jcr:primaryType", "/parent/child/file", PROPERTY_ADDED);
Property jcrDataProperty = jcrContent.setProperty("jcr:data", "foo");
listener.expect(jcrDataProperty.getPath(), "/parent/child/file", PROPERTY_ADDED);
parent.getSession().save();
Thread.sleep(1000);
List<Expectation> missing = listener.getMissing(TIME_OUT, TimeUnit.SECONDS);
List<Event> unexpected = listener.getUnexpected();
assertTrue("Unexpected events: " + unexpected, unexpected.isEmpty());
assertTrue("Missing events: " + missing, missing.isEmpty());
}
use of org.apache.jackrabbit.api.observation.JackrabbitEventFilter in project jackrabbit-oak by apache.
the class ObservationTest method disjunctPaths.
@Test
public void disjunctPaths() throws ExecutionException, InterruptedException, RepositoryException {
assumeTrue(observationManager instanceof JackrabbitObservationManager);
JackrabbitObservationManager oManager = (JackrabbitObservationManager) observationManager;
ExpectationListener listener = new ExpectationListener();
JackrabbitEventFilter filter = new JackrabbitEventFilter().setAdditionalPaths(TEST_PATH + "/a", TEST_PATH + "/x").setEventTypes(NODE_ADDED);
oManager.addEventListener(listener, filter);
Node testNode = getNode(TEST_PATH);
Node b = testNode.addNode("a").addNode("b");
b.addNode("c");
Node y = testNode.addNode("x").addNode("y");
y.addNode("z");
listener.expect(b.getPath(), NODE_ADDED);
listener.expect(y.getPath(), NODE_ADDED);
testNode.getSession().save();
List<Expectation> missing = listener.getMissing(TIME_OUT, TimeUnit.SECONDS);
assertTrue("Missing events: " + missing, missing.isEmpty());
List<Event> unexpected = listener.getUnexpected();
assertTrue("Unexpected events: " + unexpected, unexpected.isEmpty());
}
use of org.apache.jackrabbit.api.observation.JackrabbitEventFilter in project jackrabbit-oak by apache.
the class ObservationTest method includeAncestorsRemove_WithGlobs.
@Test
public void includeAncestorsRemove_WithGlobs() throws Exception {
OakEventFilter oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths(TEST_PATH + "/a/b/c/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths(TEST_PATH + "/a/b/*/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths(TEST_PATH + "/a/*/*/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths(TEST_PATH + "/*/b/*/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths(TEST_PATH + "/*/b/c/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths(TEST_PATH + "/*/*/c/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths(TEST_PATH + "/*/*/*/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths(TEST_PATH + "/a/**/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths(TEST_PATH + "/**/c/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths("/**/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
oef = FilterFactory.wrap(new JackrabbitEventFilter());
oef.setEventTypes(ALL_EVENTS);
oef.withIncludeGlobPaths(TEST_PATH + "/**/d.jsp");
oef.setIsDeep(true);
oef.withIncludeAncestorsRemove();
doIncludeAncestorsRemove_WithGlobs(oef);
}
use of org.apache.jackrabbit.api.observation.JackrabbitEventFilter in project jackrabbit-oak by apache.
the class ObservationTest method includeRemovedSubtree.
@Test
public void includeRemovedSubtree() throws RepositoryException, ExecutionException, InterruptedException {
assumeTrue(observationManager instanceof ObservationManagerImpl);
Node testNode = getNode(TEST_PATH);
testNode.addNode("a").addNode("c");
testNode.getSession().save();
ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager;
ExpectationListener listener = new ExpectationListener();
JackrabbitEventFilter filter = new JackrabbitEventFilter();
filter.setEventTypes(ALL_EVENTS);
filter.setAbsPath("/");
filter.setIsDeep(true);
filter = FilterFactory.wrap(filter).withIncludeSubtreeOnRemove();
oManager.addEventListener(listener, filter);
listener.expectRemove(testNode.getNode("a").getNode("c"));
listener.expectRemove(testNode.getNode("a")).remove();
testNode.getSession().save();
List<Expectation> missing = listener.getMissing(TIME_OUT, TimeUnit.SECONDS);
assertTrue("Missing events: " + missing, missing.isEmpty());
List<Event> unexpected = listener.getUnexpected();
assertTrue("Unexpected events: " + unexpected, unexpected.isEmpty());
}
Aggregations