jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1214757 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java
Date Thu, 15 Dec 2011 13:49:23 GMT
Author: reschke
Date: Thu Dec 15 13:49:23 2011
New Revision: 1214757

URL: http://svn.apache.org/viewvc?rev=1214757&view=rev
Log:
JCR-3181: add test case for recovering from broken version history hierarchy

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java?rev=1214757&r1=1214756&r2=1214757&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java
Thu Dec 15 13:49:23 2011
@@ -392,6 +392,63 @@ public class AutoFixCorruptNode extends 
         }
     }
 
+    // tests recovery from a broken hierarchy in the version store
+    public void testBrokenVhrParent() throws Exception {
+
+        // new repository
+        TransientRepository rep = new TransientRepository(new File(TEST_DIR));
+        Session s = openSession(rep, false);
+
+        try {
+            Node root = s.getRootNode();
+
+            // add node /test
+            Node test = root.addNode("test");
+            test.addMixin("mix:versionable");
+
+            s.save();
+
+            Node vhr = s.getWorkspace().getVersionManager().getVersionHistory(test.getPath());
+
+            assertNotNull(vhr);
+
+            Node brokenNode = vhr.getParent().getParent();
+
+            UUID destroy = UUID.fromString(brokenNode.getIdentifier());
+
+            // disable versioning
+            test.removeMixin("mix:versionable");
+            s.save();
+
+            s.logout();
+
+            destroyBundle(destroy, "version");
+
+            s = openSession(rep, false);
+
+            ConsistencyReport report = TestHelper.checkVersionStoreConsistency(s, true);
+            assertTrue("Report should have reported broken nodes", !report.getItems().isEmpty());
+
+            s.logout();
+
+            s = openSession(rep, false);
+
+            test = s.getRootNode().getNode("test");
+            // versioning should still be disabled
+            assertFalse(test.isNodeType("mix:versionable"));
+
+            // try to enable versioning again
+            test.addMixin("mix:versionable");
+            s.save();
+
+            // try a checkout / checkin
+            s.getWorkspace().getVersionManager().checkout(test.getPath());
+            s.getWorkspace().getVersionManager().checkin(test.getPath());
+        } finally {
+            s.logout();
+        }
+    }
+
     public void testAutoFix() throws Exception {
 
         // new repository



Mime
View raw message