jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r778720 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveOrphanVersionHistoryTest.java
Date Tue, 26 May 2009 14:36:38 GMT
Author: jukka
Date: Tue May 26 14:36:38 2009
New Revision: 778720

URL: http://svn.apache.org/viewvc?rev=778720&view=rev
Log:
JCR-134: Unreferenced VersionHistory should be deleted automatically

Added a test case that makes sure that a version history that is still being referenced from
another workspace won't get lost when the last version is removed.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveOrphanVersionHistoryTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveOrphanVersionHistoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveOrphanVersionHistoryTest.java?rev=778720&r1=778719&r2=778720&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveOrphanVersionHistoryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveOrphanVersionHistoryTest.java
Tue May 26 14:36:38 2009
@@ -18,6 +18,8 @@
 
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
@@ -138,6 +140,57 @@
     }
 
     /**
+     * Test that an emptied version history that is still being referenced
+     * from another workspace does not get removed.
+     *
+     * @throws RepositoryException if an error occurs.
+     */
+    public void testEmptyNonOrphanVersionHistory() throws RepositoryException {
+        Session session = testRootNode.getSession();
+
+        // Create versionable test node
+        Node node = testRootNode.addNode(nodeName1);
+        node.addMixin(mixVersionable);
+        session.save();
+
+        VersionHistory history = node.getVersionHistory();
+        String uuid = history.getUUID();
+
+        // Create version 1.0
+        Version v10 = node.checkin();
+
+        // Remove the test node
+        node.checkout();
+        node.remove();
+        session.save();
+
+        Session otherSession = helper.getReadWriteSession(workspaceName);
+        try {
+            // create a reference to the version history in another workspace
+            Node otherRoot = otherSession.getRootNode();
+            Property reference = otherRoot.setProperty(
+                    "RemoveOrphanVersionTest", uuid, PropertyType.REFERENCE);
+            otherSession.save();
+
+            // Now remove the contents of the version history
+            history.removeVersion(v10.getName());
+
+            // Check that the version history still exists!
+            try {
+                session.getNodeByUUID(uuid);
+            } catch (ItemNotFoundException e) {
+                fail("Referenced empty version history must note be removed");
+            }
+
+            // Cleanup
+            reference.remove();
+            otherSession.save();
+        } finally {
+            otherSession.logout();
+        }
+    }
+
+    /**
      * Assert that a node exists in a session.
      * @param session the session.
      * @param uuid the node's UUID.



Mime
View raw message