You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2013/03/07 15:39:29 UTC

svn commit: r1453897 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/test/java/org/apache/jackrabbit/oak/core/ oak-jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/test/java/org/apach...

Author: mduerig
Date: Thu Mar  7 14:39:29 2013
New Revision: 1453897

URL: http://svn.apache.org/r1453897
Log:
OAK-101: implement identifier handling (byUUID, byIdentifier, etc)
OAK-664: Track Tree instance across moves

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1453897&r1=1453896&r2=1453897&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java Thu Mar  7 14:39:29 2013
@@ -87,6 +87,9 @@ public class RootImpl implements Root {
      */
     private NodeStoreBranch branch;
 
+    /** Sentinel for the next move operation to take place on the this root */
+    private Move lastMove;
+
     /**
      * Current root {@code Tree}
      */
@@ -192,6 +195,8 @@ public class RootImpl implements Root {
             getTree(getParentPath(sourcePath)).updateChildOrder();
             getTree(getParentPath(destPath)).updateChildOrder();
         }
+
+        lastMove = lastMove.setMove(sourcePath, destParent, destName);
         return success;
     }
 
@@ -226,7 +231,8 @@ public class RootImpl implements Root {
         if (!store.getRoot().equals(rootTree.getBaseState())) {
             purgePendingChanges();
             branch.rebase();
-            rootTree = new TreeImpl(this);
+            lastMove = new Move();
+            rootTree = new TreeImpl(this, lastMove);
             permissionProvider = null;
         }
     }
@@ -235,7 +241,8 @@ public class RootImpl implements Root {
     public final void refresh() {
         checkLive();
         branch = store.branch();
-        rootTree = new TreeImpl(this);
+        lastMove = new Move();
+        rootTree = new TreeImpl(this, lastMove);
         modCount = 0;
         if (permissionProvider != null) {
             permissionProvider.refresh();
@@ -420,4 +427,57 @@ public class RootImpl implements Root {
     private PermissionProvider createPermissionProvider() {
         return  securityProvider.getAccessControlConfiguration().getPermissionProvider(this, subject.getPrincipals());
     }
+
+    //------------------------------------------------------------< MoveRecord >---
+
+    /**
+     * Instances of this class record move operations which took place on this root.
+     * They form a singly linked list where each move instance points to the next one.
+     * The last entry in the list is always an empty slot to be filled in by calling
+     * {@code setMove()}. This fills the slot with the source and destination of the move
+     * and links this move to the next one which will be the new empty slot.
+     *
+     * Moves can be applied to {@code TreeImpl} instances by calling {@code apply()},
+     * which will execute all moves in the list on the passed tree instance
+     */
+    class Move {
+
+        /** source path */
+        private String source;
+
+        /** Parent tree of the destination */
+        private TreeImpl destParent;
+
+        /** Name at the destination */
+        private String destName;
+
+        /** Pointer to the next move. {@code null} if this is the last, empty slot */
+        private Move next;
+
+        /**
+         * Set this move to the given source and destination. Creates a new empty slot,
+         * sets this as the next move and returns it.
+         */
+        Move setMove(String source, TreeImpl destParent, String destName) {
+            this.source = source;
+            this.destParent = destParent;
+            this.destName = destName;
+            return next = new Move();
+        }
+
+        /**
+         * Apply this and all subsequent moves to the passed tree instance.
+         */
+        Move apply(TreeImpl tree) {
+            Move move = this;
+            while (move.next != null) {
+                if (move.source.equals(tree.getPathInternal())) {
+                    tree.moveTo(move.destParent, move.destName);
+                }
+                move = move.next;
+            }
+            return move;
+        }
+
+    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1453897&r1=1453896&r2=1453897&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java Thu Mar  7 14:39:29 2013
@@ -36,6 +36,7 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.core.RootImpl.Move;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.plugins.memory.MultiStringPropertyState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -61,14 +62,14 @@ public class TreeImpl implements Tree {
     private final RootImpl root;
 
     /**
-     * The {@code NodeBuilder} for the underlying node state
+     * The node state this tree is based on. {@code null} if this is a newly added tree.
      */
-    private final NodeBuilder nodeBuilder;
+    private final NodeState baseState;
 
     /**
-     * The node state this tree is based on. {@code null} if this is a newly added tree.
+     * The {@code NodeBuilder} for the underlying node state
      */
-    private final NodeState baseState;
+    private NodeBuilder nodeBuilder;
 
     /**
      * Parent of this tree. Null for the root.
@@ -80,18 +81,23 @@ public class TreeImpl implements Tree {
      */
     private String name;
 
-    TreeImpl(RootImpl root) {
+    /** Pointer into the list of pending moves */
+    private Move pendingMoves;
+
+    TreeImpl(RootImpl root, Move pendingMoves) {
         this.root = checkNotNull(root);
         this.name = "";
         this.nodeBuilder = root.createRootBuilder();
         this.baseState = root.getBaseState();
+        this.pendingMoves = checkNotNull(pendingMoves);
     }
 
-    private TreeImpl(RootImpl root, TreeImpl parent, String name) {
+    private TreeImpl(RootImpl root, TreeImpl parent, String name, Move pendingMoves) {
         this.root = checkNotNull(root);
         this.parent = checkNotNull(parent);
         this.name = checkNotNull(name);
         this.nodeBuilder = parent.getNodeBuilder().child(name);
+        this.pendingMoves = checkNotNull(pendingMoves);
 
         if (parent.baseState == null) {
             this.baseState = null;
@@ -102,32 +108,25 @@ public class TreeImpl implements Tree {
 
     @Override
     public String getName() {
-        root.checkLive();
+        enter();
         return name;
     }
 
     @Override
     public boolean isRoot() {
-        root.checkLive();
+        enter();
         return parent == null;
     }
 
     @Override
     public String getPath() {
-        root.checkLive();
-        if (isRoot()) {
-            // shortcut
-            return "/";
-        }
-
-        StringBuilder sb = new StringBuilder();
-        buildPath(sb);
-        return sb.toString();
+        enter();
+        return getPathInternal();
     }
 
     @Override
     public Tree getParent() {
-        root.checkLive();
+        enter();
         if (parent != null && canRead(parent)) {
             return parent;
         } else {
@@ -137,7 +136,7 @@ public class TreeImpl implements Tree {
 
     @Override
     public PropertyState getProperty(String name) {
-        root.checkLive();
+        enter();
         PropertyState property = internalGetProperty(name);
         if (canRead(property)) {
             return property;
@@ -149,7 +148,7 @@ public class TreeImpl implements Tree {
     @Override
     public Status getPropertyStatus(String name) {
         // TODO: see OAK-212
-        root.checkLive();
+        enter();
         Status nodeStatus = getStatus();
         if (nodeStatus == Status.NEW) {
             return (hasProperty(name)) ? Status.NEW : null;
@@ -180,19 +179,19 @@ public class TreeImpl implements Tree {
 
     @Override
     public boolean hasProperty(String name) {
-        root.checkLive();
+        enter();
         return getProperty(name) != null;
     }
 
     @Override
     public long getPropertyCount() {
-        root.checkLive();
+        enter();
         return Iterables.size(getProperties());
     }
 
     @Override
     public Iterable<? extends PropertyState> getProperties() {
-        root.checkLive();
+        enter();
         return Iterables.filter(nodeBuilder.getProperties(),
                 new Predicate<PropertyState>() {
                     @Override
@@ -205,7 +204,7 @@ public class TreeImpl implements Tree {
     @Override
     public TreeImpl getChild(@Nonnull String name) {
         checkNotNull(name);
-        root.checkLive();
+        enter();
         TreeImpl child = internalGetChild(name);
         if (child != null && canRead(child)) {
             return child;
@@ -229,7 +228,7 @@ public class TreeImpl implements Tree {
 
     @Override
     public Status getStatus() {
-        root.checkLive();
+        enter();
 
         if (isDisconnected()) {
             return Status.DISCONNECTED;
@@ -252,13 +251,13 @@ public class TreeImpl implements Tree {
     @Override
     public long getChildrenCount() {
         // TODO: make sure cnt respects access control
-        root.checkLive();
+        enter();
         return nodeBuilder.getChildNodeCount();
     }
 
     @Override
     public Iterable<Tree> getChildren() {
-        root.checkLive();
+        enter();
         Iterable<String> childNames;
         if (hasOrderableChildren()) {
             childNames = getOrderedChildNames();
@@ -270,7 +269,7 @@ public class TreeImpl implements Tree {
                 new Function<String, Tree>() {
                     @Override
                     public Tree apply(String input) {
-                        return new TreeImpl(root, TreeImpl.this, input);
+                        return new TreeImpl(root, TreeImpl.this, input, pendingMoves);
                     }
                 }),
                 new Predicate<Tree>() {
@@ -283,7 +282,7 @@ public class TreeImpl implements Tree {
 
     @Override
     public Tree addChild(String name) {
-        root.checkLive();
+        enter();
         if (!hasChild(name)) {
             nodeBuilder.child(name);
             if (hasOrderableChildren()) {
@@ -295,7 +294,7 @@ public class TreeImpl implements Tree {
             root.updated();
         }
 
-        TreeImpl child = new TreeImpl(root, this, name);
+        TreeImpl child = new TreeImpl(root, this, name, pendingMoves);
 
         // Make sure to allocate the node builder for new nodes in order to correctly
         // track removes and moves. See OAK-621
@@ -304,7 +303,7 @@ public class TreeImpl implements Tree {
 
     @Override
     public void setOrderableChildren(boolean enable) {
-        root.checkLive();
+        enter();
         if (enable) {
             ensureChildOrderProperty();
         } else {
@@ -314,7 +313,7 @@ public class TreeImpl implements Tree {
 
     @Override
     public boolean remove() {
-        root.checkLive();
+        enter();
         if (isDisconnected()) {
             throw new IllegalStateException("Cannot remove a disconnected tree");
         }
@@ -338,7 +337,7 @@ public class TreeImpl implements Tree {
 
     @Override
     public boolean orderBefore(final String name) {
-        root.checkLive();
+        enter();
         if (isRoot()) {
             // root does not have siblings
             return false;
@@ -383,35 +382,35 @@ public class TreeImpl implements Tree {
 
     @Override
     public void setProperty(PropertyState property) {
-        root.checkLive();
+        enter();
         nodeBuilder.setProperty(property);
         root.updated();
     }
 
     @Override
     public <T> void setProperty(String name, T value) {
-        root.checkLive();
+        enter();
         nodeBuilder.setProperty(name, value);
         root.updated();
     }
 
     @Override
     public <T> void setProperty(String name, T value, Type<T> type) {
-        root.checkLive();
+        enter();
         nodeBuilder.setProperty(name, value, type);
         root.updated();
     }
 
     @Override
     public void removeProperty(String name) {
-        root.checkLive();
+        enter();
         nodeBuilder.removeProperty(name);
         root.updated();
     }
 
     @Override
     public TreeLocation getLocation() {
-        root.checkLive();
+        enter();
         return new NodeLocation(this);
     }
 
@@ -440,12 +439,15 @@ public class TreeImpl implements Tree {
      * @param destName   new name for this tree
      */
     void moveTo(TreeImpl destParent, String destName) {
-        if (isDisconnected()) {
-            throw new IllegalStateException("Cannot move a disconnected tree");
-        }
-
         name = destName;
         parent = destParent;
+        if (parent.nodeBuilder.hasChildNode(name)) {
+            nodeBuilder = parent.nodeBuilder.child(name);
+        } else {
+            // make this builder disconnected from its new parent
+            nodeBuilder = parent.nodeBuilder.child(name);
+            parent.nodeBuilder.removeNode(name);
+        }
     }
 
     /**
@@ -504,12 +506,35 @@ public class TreeImpl implements Tree {
         }
     }
 
+    String getPathInternal() {
+        if (parent == null) {
+            return "/";
+        }
+
+        StringBuilder sb = new StringBuilder();
+        buildPath(sb);
+        return sb.toString();
+    }
+
     //------------------------------------------------------------< private >---
 
+    private void enter() {
+        root.checkLive();
+        applyPendingMoves();
+    }
+
+    private void applyPendingMoves() {
+        if (parent != null) {
+            parent.applyPendingMoves();
+        }
+
+        pendingMoves = pendingMoves.apply(this);
+    }
+
     private TreeImpl internalGetChild(String childName) {
         return nodeBuilder.hasChildNode(childName)
-                ? new TreeImpl(root, this, childName)
-                : null;
+            ? new TreeImpl(root, this, childName, pendingMoves)
+            : null;
     }
 
     private PropertyState internalGetProperty(String propertyName) {
@@ -517,7 +542,7 @@ public class TreeImpl implements Tree {
     }
 
     private void buildPath(StringBuilder sb) {
-        if (!isRoot()) {
+        if (parent != null) {
             parent.buildPath(sb);
             sb.append('/').append(name);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java?rev=1453897&r1=1453896&r2=1453897&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java Thu Mar  7 14:39:29 2013
@@ -28,6 +28,7 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Tree.Status;
+import org.apache.jackrabbit.oak.api.Type;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -99,12 +100,14 @@ public class RootImplTest {
         Tree tree = root.getTree("/");
 
         Tree y = tree.getChild("y");
+        Tree x = tree.getChild("x");
+        assertNotNull(x);
 
-        assertTrue(tree.hasChild("x"));
         root.move("/x", "/y/xx");
         assertFalse(tree.hasChild("x"));
         assertTrue(y.hasChild("xx"));
-        
+        assertEquals("/y/xx", x.getPath());
+
         root.commit();
         tree = root.getTree("/");
 
@@ -114,6 +117,28 @@ public class RootImplTest {
     }
 
     @Test
+    public void moveRemoveAdd() {
+        Root root = session.getLatestRoot();
+
+        Tree x = root.getTree("/x");
+        Tree z = root.getTree("/z");
+        z.setProperty("p", "1");
+
+        root.move("/z", "/x/z");
+        root.getTree("/x/z").remove();
+
+        assertEquals(Status.DISCONNECTED, z.getStatus());
+
+        x.addChild("z");
+        assertEquals(Status.EXISTING, z.getStatus());
+
+        x.getChild("z").setProperty("p", "2");
+        PropertyState p = z.getProperty("p");
+        assertNotNull(p);
+        assertEquals("2", p.getValue(Type.STRING));
+    }
+
+    @Test
     public void moveNew() throws CommitFailedException {
         Root root = session.getLatestRoot();
         Tree tree = root.getTree("/");
@@ -121,7 +146,7 @@ public class RootImplTest {
         Tree t = tree.addChild("new");
 
         root.move("/new", "/y/new");
-        assertEquals(Status.DISCONNECTED, t.getStatus());
+        assertEquals("/y/new", t.getPath());
 
         assertNull(tree.getChild("new"));
     }
@@ -153,11 +178,13 @@ public class RootImplTest {
     public void rename() throws CommitFailedException {
         Root root = session.getLatestRoot();
         Tree tree = root.getTree("/");
+        Tree x = tree.getChild("x");
+        assertNotNull(x);
 
-        assertTrue(tree.hasChild("x"));
         root.move("/x", "/xx");
         assertFalse(tree.hasChild("x"));
         assertTrue(tree.hasChild("xx"));
+        assertEquals("/xx", x.getPath());
         
         root.commit();
         tree = root.getTree("/");
@@ -172,6 +199,8 @@ public class RootImplTest {
         Tree tree = root.getTree("/");
 
         Tree y = tree.getChild("y");
+        Tree x = tree.getChild("x");
+        assertNotNull(x);
 
         assertTrue(tree.hasChild("x"));
         root.copy("/x", "/y/xx");

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1453897&r1=1453896&r2=1453897&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Thu Mar  7 14:39:29 2013
@@ -223,7 +223,6 @@
       org.apache.jackrabbit.oak.jcr.version.VersionHistoryTest#testGetVersionHistoryFromNode             <!-- OAK-601 -->
       org.apache.jackrabbit.oak.jcr.version.VersionHistoryTest#testGetVersionHistory                     <!-- OAK-602 -->
       org.apache.jackrabbit.oak.jcr.version.VersionHistoryTest#testGetVersionHistoryAfterMove            <!-- OAK-602 -->
-      org.apache.jackrabbit.oak.jcr.MoveTest                                                             <!-- OAK-606, OAK-607 -->
     </known.issues>
   </properties>
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java?rev=1453897&r1=1453896&r2=1453897&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java Thu Mar  7 14:39:29 2013
@@ -83,7 +83,7 @@ public abstract class ItemDelegate {
      * @return  {@code true} iff stale
      */
     public boolean isStale() {
-        return !getLocationInternal().exists();
+        return !loadLocation().exists();
     }
 
     /**
@@ -115,7 +115,7 @@ public abstract class ItemDelegate {
      */
     @Nonnull
     public TreeLocation getLocation() throws InvalidItemStateException {
-        TreeLocation location = getLocationInternal();
+        TreeLocation location = loadLocation();
         if (!location.exists()) {
             throw new InvalidItemStateException("Item is stale");
         }
@@ -132,12 +132,12 @@ public abstract class ItemDelegate {
 
     /**
      * The underlying {@link org.apache.jackrabbit.oak.api.TreeLocation} of this item.
-     * The location is only re-resolved when the revision of this item does not match
+     * The location is only loaded when the revision of this item does not match
      * the revision of the session or when the location does not exist (anymore).
-     * @return  tree location of the underlying item.
+     * @return tree location of the underlying item.
      */
     @Nonnull
-    private synchronized TreeLocation getLocationInternal() {
+    private synchronized TreeLocation loadLocation() {
         if (sessionDelegate.getRevision() != revision || !location.exists()) {
             location = sessionDelegate.getLocation(location.getPath());
             revision = sessionDelegate.getRevision();

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=1453897&r1=1453896&r2=1453897&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 Mar  7 14:39:29 2013
@@ -22,16 +22,8 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.nodetype.ConstraintViolationException;
 
-import org.apache.jackrabbit.oak.Oak;
-import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.api.ContentSession;
-import org.apache.jackrabbit.oak.api.Root;
-import org.apache.jackrabbit.oak.api.Tree;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 /**
@@ -123,26 +115,6 @@ public class CompatibilityIssuesTest ext
         }
     }
 
-    @Test
-    public void move2() throws CommitFailedException {
-        ContentSession session = new Oak().createContentSession();
-        Root root = session.getLatestRoot();
-        root.getTree("/").addChild("x");
-        root.getTree("/").addChild("y");
-        root.commit();
-
-        Tree r = root.getTree("/");
-        Tree x = r.getChild("x");
-        Tree y = r.getChild("y");
-
-        assertFalse(y.hasChild("x"));
-        assertEquals("", x.getParent().getName());
-        root.move("/x", "/y/x");
-        assertTrue(y.hasChild("x"));
-        // assertEquals("y", x.getParent().getName());  // passed on JR2, fails on Oak
-        assertEquals("", x.getParent().getName());      // fails on JR2, passes on Oak
-    }
-
     /**
      * Type checks are deferred to the Session#save call instead of the
      * Node#addNode method like in Jackrabbit2.

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java?rev=1453897&r1=1453896&r2=1453897&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java Thu Mar  7 14:39:29 2013
@@ -159,13 +159,7 @@ public class MoveRemoveTest extends Abst
         Node n = session.getNode("/new");
         session.move("/new", "/moved");
 
-        try {
-            n.getPath();
-            fail();
-        } catch (InvalidItemStateException e) {}
-
-        session.getRootNode().addNode("new");
-        assertEquals("/new", n.getPath());
+        assertEquals("/moved", n.getPath());
     }
 
     @Test
@@ -176,13 +170,7 @@ public class MoveRemoveTest extends Abst
         Node n = session.getNode("/new");
         session.move("/new", "/moved");
 
-        try {
-            n.getPath();
-            fail();
-        } catch (InvalidItemStateException e) {}
-
-        session.getRootNode().addNode("new");
-        assertEquals("/new", n.getPath());
+        assertEquals("/moved", n.getPath());
     }
 
     @Test
@@ -228,13 +216,7 @@ public class MoveRemoveTest extends Abst
         Node n = session.getNode("/parent/new");
         session.move("/parent", "/moved");
 
-        try {
-            n.getPath();
-            fail();
-        } catch (InvalidItemStateException e) {}
-
-        session.getRootNode().addNode("parent").addNode("new");
-        assertEquals("/parent/new", n.getPath());
+        assertEquals("/moved/new", n.getPath());
     }
 
     @Test
@@ -245,13 +227,7 @@ public class MoveRemoveTest extends Abst
         Node n = session.getNode("/parent/new");
         session.move("/parent", "/moved");
 
-        try {
-            n.getPath();
-            fail();
-        } catch (InvalidItemStateException e) {}
-
-        session.getRootNode().addNode("parent").addNode("new");
-        assertEquals("/parent/new", n.getPath());
+        assertEquals("/moved/new", n.getPath());
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java?rev=1453897&r1=1453896&r2=1453897&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java Thu Mar  7 14:39:29 2013
@@ -16,12 +16,10 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import javax.jcr.InvalidItemStateException;
 import javax.jcr.Node;
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -41,33 +39,20 @@ public class MoveTest extends AbstractJC
         Node node1 = testRootNode.addNode(nodeName1);
         superuser.save();
 
-        String sourcePath = node1.getPath();
-        move(sourcePath, testRoot + '/' + nodeName2, true);
-
-        try {
-            node1.getPath();
-            fail();
-        } catch (InvalidItemStateException expected) {}
+        String destPath = testRoot + '/' + nodeName2;
+        move(node1.getPath(), destPath, true);
 
-        testRootNode.addNode(nodeName1);
-        assertEquals(sourcePath, node1.getPath());
+        assertEquals(destPath, node1.getPath());
     }
 
     @Test
     public void testRenameNewNode() throws Exception {
         Node node1 = testRootNode.addNode(nodeName1);
 
-        String sourcePath = node1.getPath();
-        move(sourcePath, testRoot + '/' + nodeName2, false);
-
-        try {
-            node1.getPath();
-            fail();
-        } catch (InvalidItemStateException expected) {}
+        String destPath = testRoot + '/' + nodeName2;
+        move(node1.getPath(), destPath, false);
 
-        testRootNode.addNode(nodeName1);
-        superuser.save();
-        assertEquals(sourcePath, node1.getPath());
+        assertEquals(destPath, node1.getPath());
     }
 
     @Test
@@ -76,19 +61,12 @@ public class MoveTest extends AbstractJC
         Node node2 = testRootNode.addNode(nodeName2);
         superuser.save();
 
-        String sourcePath = node1.getPath();
-        move(sourcePath, node2.getPath() + '/' + nodeName1, true);
-
-        try {
-            node1.getPath();
-            fail();
-        } catch (InvalidItemStateException expected) {}
+        String destPath = node2.getPath() + '/' + nodeName1;
+        move(node1.getPath(), destPath, true);
 
-        testRootNode.addNode(nodeName1);
-        assertEquals(sourcePath, node1.getPath());
+        assertEquals(destPath, node1.getPath());
     }
 
-    @Ignore("OAK-606")
     @Test
     public void testMoveReferenceable() throws Exception {
         Node node1 = testRootNode.addNode(nodeName1);
@@ -107,20 +85,12 @@ public class MoveTest extends AbstractJC
         Node node1 = testRootNode.addNode(nodeName1);
         Node node2 = testRootNode.addNode(nodeName2);
 
-        String sourcePath = node1.getPath();
-        move(sourcePath, node2.getPath() + '/' + nodeName1, false);
-
-        try {
-            node1.getPath();
-            fail();
-        } catch (InvalidItemStateException expected) {}
+        String destPath = node2.getPath() + '/' + nodeName1;
+        move(node1.getPath(), destPath, false);
 
-        testRootNode.addNode(nodeName1);
-        superuser.save();
-        assertEquals(sourcePath, node1.getPath());
+        assertEquals(destPath, node1.getPath());
     }
 
-    @Ignore("OAK-607")
     @Test
     public void testMoveNewReferenceable() throws Exception {
         Node node1 = testRootNode.addNode(nodeName1);