jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1183334 - in /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core: ConsistencyCheck.java TestHelper.java
Date Fri, 14 Oct 2011 12:39:21 GMT
Author: reschke
Date: Fri Oct 14 12:39:21 2011
New Revision: 1183334

URL: http://svn.apache.org/viewvc?rev=1183334&view=rev
Log:
JCR-3114: add versioning PM consistency check to TestHelper and ConsistencyCheck

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConsistencyCheck.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestHelper.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConsistencyCheck.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConsistencyCheck.java?rev=1183334&r1=1183333&r2=1183334&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConsistencyCheck.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConsistencyCheck.java
Fri Oct 14 12:39:21 2011
@@ -36,9 +36,17 @@ public class ConsistencyCheck extends Ab
     }
 
     private void runCheck() throws Exception {
-        log.print("running consistency check on repository " + getHelper().getRepository());
+        log.print("running consistency check on repository "
+                + getHelper().getRepository());
 
-        ConsistencyReport rep = TestHelper.checkConsistency(testRootNode.getSession());
-        assertEquals("Found broken nodes in repository: " + rep, 0, rep.getItems().size());
+        ConsistencyReport rep = TestHelper.checkConsistency(testRootNode
+                .getSession());
+        assertEquals("Found broken nodes in repository: " + rep, 0, rep
+                .getItems().size());
+
+        rep = TestHelper
+                .checkVersionStoreConsistency(testRootNode.getSession());
+        assertEquals("Found broken nodes in version storage: " + rep, 0, rep
+                .getItems().size());
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestHelper.java?rev=1183334&r1=1183333&r2=1183334&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestHelper.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestHelper.java
Fri Oct 14 12:39:21 2011
@@ -69,4 +69,30 @@ public class TestHelper {
             }
         }
     }
+
+    /**
+     * Runs a consistency check on the versioning store used by the specified session.
+     *
+     * @param session the Session accessing the workspace to be checked
+     * @throws RepositoryException
+     * @throws NotExecutableException if the {@link PersistenceManager} does
+     * not implement {@link ConsistencyChecker}, or if the associated
+     * {@link Repository} is not a {@link RepositoryImpl}.
+     */
+    public static ConsistencyReport checkVersionStoreConsistency(Session session)
+            throws NotExecutableException, RepositoryException {
+        Repository r = session.getRepository();
+        if (!(r instanceof RepositoryImpl)) {
+            throw new NotExecutableException();
+        } else {
+            RepositoryImpl ri = (RepositoryImpl) r;
+            PersistenceManager pm = ri.getRepositoryContext()
+                    .getInternalVersionManager().getPersistenceManager();
+            if (!(pm instanceof ConsistencyChecker)) {
+                throw new NotExecutableException();
+            } else {
+                return ((ConsistencyChecker) pm).check(null, true, false);
+            }
+        }
+    }
 }



Mime
View raw message