jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1187345 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java
Date Fri, 21 Oct 2011 13:50:46 GMT
Author: reschke
Date: Fri Oct 21 13:50:46 2011
New Revision: 1187345

URL: http://svn.apache.org/viewvc?rev=1187345&view=rev
Log:
JCR-3115: Versioning fixup leaves persistence in a state where the node can't be made versionable
again

Modify checker to also inspect "candidate" version histories (additional test case)

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=1187345&r1=1187344&r2=1187345&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
Fri Oct 21 13:50:46 2011
@@ -101,7 +101,6 @@ public class AutoFixCorruptNode extends 
         try {
             Node root = s.getRootNode();
 
-            // add nodes /test and /test/missing
             Node test = root.addNode("test");
             test.addMixin("mix:versionable");
 
@@ -114,7 +113,6 @@ public class AutoFixCorruptNode extends 
 
             Node brokenNode = vhr;
             String vhrRootVersionId = vhr.getNode("jcr:rootVersion").getIdentifier();
-            
             UUID destroy = UUID.fromString(brokenNode.getIdentifier());
             s.logout();
             
@@ -168,6 +166,10 @@ public class AutoFixCorruptNode extends 
             report = TestHelper.checkVersionStoreConsistency(s, false);
             assertTrue("Some problems should have been fixed but are not: " + report, report.getItems().size()
< reportitems);
             
+            // get a fresh session
+            s.logout();
+            s = openSession(rep, false);
+
             test = s.getRootNode().getNode("test");
             // versioning should be disabled now
             assertFalse(test.isNodeType("mix:versionable"));
@@ -309,6 +311,87 @@ public class AutoFixCorruptNode extends 
         }
     }
 
+    // similar to above, but disconnects version history before damaging the repository
+    public void testMissingRootVersion2() throws Exception {
+
+        // new repository
+        TransientRepository rep = new TransientRepository(new File(TEST_DIR));
+        Session s = openSession(rep, false);
+
+        String oldVersionRecoveryProp = System
+                .getProperty("org.apache.jackrabbit.version.recovery");
+
+        try {
+            Node root = s.getRootNode();
+
+            // add nodes /test and /test/missing
+            Node test = root.addNode("test");
+            test.addMixin("mix:versionable");
+
+            s.save();
+
+            Node vhr = s.getWorkspace().getVersionManager()
+                    .getVersionHistory(test.getPath());
+
+            assertNotNull(vhr);
+
+            Node brokenNode = vhr.getNode("jcr:rootVersion");
+            String vhrId = vhr.getIdentifier();
+            
+            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, false);
+            assertTrue("Report should have reported broken nodes", !report.getItems().isEmpty());
+            
+            s.logout();
+
+            System.setProperty("org.apache.jackrabbit.version.recovery", "true");
+
+            s = openSession(rep, false);
+            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();
+
+            Node oldVHR = s.getNodeByIdentifier(vhrId);
+            Node newVHR = s.getWorkspace().getVersionManager().getVersionHistory(test.getPath());
+
+            assertTrue("old and new version history path should be different: "
+                    + oldVHR.getPath() + " vs " + newVHR.getPath(), !oldVHR
+                    .getPath().equals(newVHR.getPath()));
+
+            // name should be same plus suffix
+            assertTrue(oldVHR.getName().startsWith(newVHR.getName()));
+            
+            // try a checkout / checkin
+            s.getWorkspace().getVersionManager().checkout(test.getPath());
+            s.getWorkspace().getVersionManager().checkin(test.getPath());
+        } finally {
+            s.logout();
+            System.setProperty("org.apache.jackrabbit.version.recovery",
+                    oldVersionRecoveryProp == null ? ""
+                            : oldVersionRecoveryProp);
+        }
+    }
+
     public void testAutoFix() throws Exception {
 
         // new repository



Mime
View raw message