jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1495435 - /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java
Date Fri, 21 Jun 2013 13:42:51 GMT
Author: mduerig
Date: Fri Jun 21 13:42:50 2013
New Revision: 1495435

URL: http://svn.apache.org/r1495435
Log:
OAK-144 Implement Observation
Test for filtering observation events on path

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java?rev=1495435&r1=1495434&r2=1495435&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java
Fri Jun 21 13:42:50 2013
@@ -54,6 +54,7 @@ import com.google.common.util.concurrent
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
+import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest;
 import org.junit.After;
 import org.junit.Before;
@@ -170,6 +171,33 @@ public class ObservationTest extends Abs
     }
 
     @Test
+    public void pathFilter() throws Exception {
+        final String path = "/events/only/here";
+        ExpectationListener listener = new ExpectationListener();
+        listener.expect(new Expectation(path){
+            @Override
+            public boolean onEvent(Event event) throws Exception {
+                return PathUtils.isAncestor(path, event.getPath());
+            }
+        });
+
+        observationManager.addEventListener(listener, NODE_ADDED, path, true, null, null,
false);
+        try {
+            Node root = getNode("/");
+            root.addNode("events").addNode("only").addNode("here").addNode("at");
+            root.getSession().save();
+
+            List<Expectation> missing = listener.getMissing(2, TimeUnit.SECONDS);
+            assertTrue("Missing events: " + missing, missing.isEmpty());
+            List<Event> unexpected = listener.getUnexpected();
+            assertTrue("Unexpected events: " + unexpected, unexpected.isEmpty());
+        }
+        finally {
+            observationManager.removeEventListener(listener);
+        }
+    }
+
+    @Test
     public void observationDispose()
             throws RepositoryException, InterruptedException, ExecutionException, TimeoutException
{
 
@@ -189,9 +217,9 @@ public class ObservationTest extends Abs
             public void run() {
                 try {
                     getNode(TEST_PATH)
-                        .addNode("c" + c++)
-                        .getSession()
-                        .save();
+                            .addNode("c" + c++)
+                            .getSession()
+                            .save();
                 }
                 catch (RepositoryException e) {
                     throw new RuntimeException(e);



Mime
View raw message