jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1511584 - /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
Date Thu, 08 Aug 2013 04:58:01 GMT
Author: chetanm
Date: Thu Aug  8 04:58:00 2013
New Revision: 1511584

URL: http://svn.apache.org/r1511584
Log:
 OAK-948 - Compatibility - Oak not generates property change event for touched properties

 Adding testcase

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

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java?rev=1511584&r1=1511583&r2=1511584&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
Thu Aug  8 04:58:00 2013
@@ -16,11 +16,17 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import static javax.jcr.observation.Event.PROPERTY_CHANGED;
 import static org.apache.jackrabbit.oak.jcr.RepositoryImpl.REFRESH_INTERVAL;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 import javax.jcr.Credentials;
 import javax.jcr.InvalidItemStateException;
@@ -29,6 +35,10 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventIterator;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.ObservationManager;
 
 import org.apache.jackrabbit.api.JackrabbitRepository;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
@@ -164,4 +174,53 @@ public class CompatibilityIssuesTest ext
         }
     }
 
+    /**
+     * OAK-948 - JR2 generates propertyChange event for touched properties while Oak does
not
+     */
+    @Test
+    public void noEventsForTouchedProperties() throws RepositoryException, InterruptedException
{
+        final String testNodeName = "test_touched_node";
+        final String testNodePath = '/' + testNodeName;
+
+        // Create the test node
+        Session session = getAdminSession();
+        Node testNode = session.getRootNode().addNode(testNodeName);
+        testNode.setProperty("foo", "bar");
+        testNode.setProperty("foo2", "bar0");
+        session.save();
+
+        Session observingSession = createAdminSession();
+        ObservationManager observationManager = observingSession.getWorkspace().getObservationManager();
+
+        try{
+            final List<Event> events = new ArrayList<Event>();
+            final CountDownLatch latch = new CountDownLatch(1);
+            EventListener listener = new EventListener() {
+                @Override
+                public void onEvent(EventIterator eventIt) {
+                    while(eventIt.hasNext()){
+                        events.add(eventIt.nextEvent());
+                    }
+                    if(!events.isEmpty()){
+                        latch.countDown();
+                    }
+                }
+            };
+
+            observationManager.addEventListener(listener, PROPERTY_CHANGED, testNodePath,
true, null, null, false);
+
+            //Now touch foo and modify foo2
+            session.getNode(testNodePath).setProperty("foo","bar");
+            session.getNode(testNodePath).setProperty("foo2","bar2");
+            session.save();
+
+            latch.await(10,TimeUnit.SECONDS);
+
+            //Only one event is recorded for foo2 modification
+            assertEquals(1,events.size());
+        }finally{
+            observingSession.logout();
+        }
+    }
+
 }



Mime
View raw message