jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1233069 - in /jackrabbit/trunk: jackrabbit-core/pom.xml jackrabbit-jcr-rmi/pom.xml jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeReorderTest.java jackrabbit-jcr2dav/pom.xml jackrabbit-spi2jcr/pom.xml
Date Wed, 18 Jan 2012 21:04:19 GMT
Author: reschke
Date: Wed Jan 18 21:04:19 2012
New Revision: 1233069

URL: http://svn.apache.org/viewvc?rev=1233069&view=rev
Log:
JCR-3207: add TCK test for Info map of NODE_MOVED event on node reordering

Modified:
    jackrabbit/trunk/jackrabbit-core/pom.xml
    jackrabbit/trunk/jackrabbit-jcr-rmi/pom.xml
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeReorderTest.java
    jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml
    jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml

Modified: jackrabbit/trunk/jackrabbit-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/pom.xml?rev=1233069&r1=1233068&r2=1233069&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-core/pom.xml Wed Jan 18 21:04:19 2012
@@ -108,6 +108,7 @@ org.apache.jackrabbit.test.api.Shareable
 org.apache.jackrabbit.test.api.ShareableNodeTest#testGetNodesByPattern
 org.apache.jackrabbit.test.api.lock.OpenScopedLockTest#testLockExpiration
 org.apache.jackrabbit.test.api.lock.SessionScopedLockTest#testLockExpiration
+org.apache.jackrabbit.test.api.observation.NodeReorderTest#testNodeReorderMove
 org.apache.jackrabbit.core.data.ConcurrentGcTest#testDatabases
 org.apache.jackrabbit.core.data.GarbageCollectorTest#testCloseSessionWhileRunningGc
               </value>

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/pom.xml?rev=1233069&r1=1233068&r2=1233069&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/pom.xml Wed Jan 18 21:04:19 2012
@@ -238,6 +238,7 @@ org.apache.jackrabbit.test.api.observati
 org.apache.jackrabbit.test.api.observation.NodeMovedTest#testMoveTree
 org.apache.jackrabbit.test.api.observation.NodeMovedTest#testMoveWithRemove
 org.apache.jackrabbit.test.api.observation.NodeReorderTest#testNodeReorder
+org.apache.jackrabbit.test.api.observation.NodeReorderTest#testNodeReorderMove
 org.apache.jackrabbit.test.api.observation.NodeReorderTest#testNodeReorderSameName
 org.apache.jackrabbit.test.api.observation.NodeReorderTest#testNodeReorderSameNameWithRemove
 org.apache.jackrabbit.test.api.PathTest#testResolvedIdentifierBasedPropertyValue

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeReorderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeReorderTest.java?rev=1233069&r1=1233068&r2=1233069&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeReorderTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeReorderTest.java
Wed Jan 18 21:04:19 2012
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.test.api.observation;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.jackrabbit.test.NotExecutableException;
@@ -54,11 +57,7 @@ public class NodeReorderTest extends Abs
      */
     private static final String DEST_CHILD_REL_PATH = "destChildRelPath";
 
-    /**
-     * Tests if reordering a child node triggers a {@link Event#NODE_REMOVED}
-     * and a {@link Event#NODE_ADDED} event.
-     */
-    public void testNodeReorder()
+    private void doTestNodeReorder(List<Event> added, List<Event> removed, List<Event>
moved)
             throws RepositoryException, NotExecutableException {
         if (!testRootNode.getDefinition().getDeclaringNodeType().hasOrderableChildNodes())
{
             throw new NotExecutableException("Node at '" + testRoot + "' does not support
orderable child nodes.");
@@ -89,12 +88,26 @@ public class NodeReorderTest extends Abs
         addEventListener(moveNodeListener, Event.NODE_MOVED);
         testRootNode.orderBefore(nodeName3, nodeName2);
         testRootNode.getSession().save();
-        Event[] added = addNodeListener.getEvents(DEFAULT_WAIT_TIMEOUT);
-        Event[] removed = removeNodeListener.getEvents(DEFAULT_WAIT_TIMEOUT);
-        Event[] moved = moveNodeListener.getEvents(DEFAULT_WAIT_TIMEOUT);
+        added.addAll(Arrays.asList(addNodeListener.getEvents(DEFAULT_WAIT_TIMEOUT)));
+        removed.addAll(Arrays.asList(removeNodeListener.getEvents(DEFAULT_WAIT_TIMEOUT)));
+        moved.addAll(Arrays.asList(moveNodeListener.getEvents(DEFAULT_WAIT_TIMEOUT)));
         removeEventListener(addNodeListener);
         removeEventListener(removeNodeListener);
         removeEventListener(moveNodeListener);
+    }
+
+    /**
+     * Tests if reordering a child node triggers a {@link Event#NODE_REMOVED}
+     * and a {@link Event#NODE_ADDED} event.
+     */
+    public void testNodeReorderAddRemove() throws RepositoryException, NotExecutableException
{
+
+        List<Event> added = new ArrayList<Event>();
+        List<Event> removed = new ArrayList<Event>();
+        List<Event> moved = new ArrayList<Event>();
+
+        doTestNodeReorder(added, removed, moved);
+
         // either
         // 1) nodename2 has been reordered to the end
         // or:
@@ -106,24 +119,38 @@ public class NodeReorderTest extends Abs
 
         // if true, check for option 1)
         boolean reorderEnd = false;
-        for (int i = 0; i < added.length; i++) {
-            if (added[i].getPath().endsWith(nodeName2)) {
+        for (Event e : added) {
+            if (e.getPath().endsWith(nodeName2)) {
                 reorderEnd = true;
                 break;
             }
         }
+
         if (reorderEnd) {
-            checkNodeAdded(added, new String[]{nodeName2}, null);
-            checkNodeRemoved(removed, new String[]{nodeName2}, null);
-            checkNodeReordered(moved, nodeName2, nodeName2, null);
+            checkNodeAdded(added, new String[] { nodeName2 }, null);
+            checkNodeRemoved(removed, new String[] { nodeName2 }, null);
         } else {
-            checkNodeAdded(added, new String[]{nodeName3}, null);
-            checkNodeRemoved(removed, new String[]{nodeName3}, null);
-            checkNodeReordered(moved, nodeName3, nodeName3, nodeName2);
+            checkNodeAdded(added, new String[] { nodeName3 }, null);
+            checkNodeRemoved(removed, new String[] { nodeName3 }, null);
         }
     }
 
     /**
+     * Tests if reordering a child node triggers a {@link Event#NODE_MOVED}
+     * event.
+     */
+    public void testNodeReorderMove() throws RepositoryException, NotExecutableException
{
+
+        List<Event> added = new ArrayList<Event>();
+        List<Event> removed = new ArrayList<Event>();
+        List<Event> moved = new ArrayList<Event>();
+
+        doTestNodeReorder(added, removed, moved);
+
+        checkNodeReordered(moved, nodeName3, nodeName3, nodeName2);
+    }
+
+    /**
      * Tests if reordering a child node triggers a {@link Event#NODE_REMOVED}
      * and a {@link Event#NODE_ADDED} event with same name siblings.
      */
@@ -297,6 +324,15 @@ public class NodeReorderTest extends Abs
         checkInfoEntry(info, DEST_CHILD_REL_PATH, before);
     }
 
+    protected void checkNodeReordered(List<Event> events, String src, String dest,
String before)
+            throws RepositoryException {
+        checkNodes(events.toArray(new Event[0]), new String[] { dest }, null, Event.NODE_MOVED);
+        assertEquals("Wrong number of events", 1, events.size());
+        Map<?, ?> info = events.get(0).getInfo();
+        checkInfoEntry(info, SRC_CHILD_REL_PATH, src);
+        checkInfoEntry(info, DEST_CHILD_REL_PATH, before);
+    }
+
     /**
      * Checks if the info map contains the given <code>key</code> with the
      * <code>expected</code> value.
@@ -310,4 +346,15 @@ public class NodeReorderTest extends Abs
         assertEquals("Wrong event info value for: " + key,
                 expected, (String) info.get(key));
     }
+
+    protected void checkNodeAdded(List<Event> events, String[] requiredRelPaths, String[]
optionalRelPaths)
+            throws RepositoryException {
+        checkNodes(events.toArray(new Event[0]), requiredRelPaths, optionalRelPaths, Event.NODE_ADDED);
+    }
+
+    protected void checkNodeRemoved(List<Event> events, String[] requiredRelPaths,
String[] optionalRelPaths)
+            throws RepositoryException {
+        checkNodes(events.toArray(new Event[0]), requiredRelPaths, optionalRelPaths, Event.NODE_REMOVED);
+    }
+
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml?rev=1233069&r1=1233068&r2=1233069&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml Wed Jan 18 21:04:19 2012
@@ -75,7 +75,9 @@
                       org.apache.jackrabbit.test.api.lock.LockManagerTest#testAddInvalidLockToken
                       org.apache.jackrabbit.test.api.lock.LockManagerTest#testAddLockTokenToAnotherSession
                       org.apache.jackrabbit.test.api.lock.LockManagerTest#testLockTransfer2
-                      org.apache.jackrabbit.jcr2spi.lock.OpenScopedLockTest#testLogoutHasNoEffect

+                      org.apache.jackrabbit.jcr2spi.lock.OpenScopedLockTest#testLogoutHasNoEffect
+                      <!-- JCR-3207 -->
+                      org.apache.jackrabbit.test.api.observation.NodeReorderTest#testNodeReorderMove
                       <!-- JCR-2533 : missing impl of checkQueryStatement -->     
                
                       org.apache.jackrabbit.test.api.query.CreateQueryTest#testUnknownQueryLanguage
                       <!-- JCR-2533 : missing impl of checkQueryStatement -->

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml?rev=1233069&r1=1233068&r2=1233069&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml Wed Jan 18 21:04:19 2012
@@ -57,6 +57,7 @@
                 org.apache.jackrabbit.jcr2spi.name.NamespaceRegistryTest#testReRegisteredNamespaceVisibility
                 org.apache.jackrabbit.jcr2spi.name.NamespaceRegistryTest#testRegisteredNamespaceVisibility
                 org.apache.jackrabbit.test.api.ShareableNodeTest
+                org.apache.jackrabbit.test.api.observation.NodeReorderTest#testNodeReorderMove
                 org.apache.jackrabbit.test.api.version.simple
                 org.apache.jackrabbit.test.api.LifecycleTest
               </value>



Mime
View raw message