Search in sources :

Example 1 with ConsistencyReport

use of org.apache.jackrabbit.core.persistence.check.ConsistencyReport in project jackrabbit by apache.

the class ConsistencyCheck method runCheck.

private void runCheck() throws Exception {
    log.print("running consistency check on repository " + getHelper().getRepository());
    ConsistencyReport rep = TestHelper.checkConsistency(testRootNode.getSession(), false, null);
    assertEquals("Found broken nodes in repository: " + rep, 0, rep.getItems().size());
    rep = TestHelper.checkVersionStoreConsistency(testRootNode.getSession(), false, null);
    assertEquals("Found broken nodes in version storage: " + rep, 0, rep.getItems().size());
}
Also used : ConsistencyReport(org.apache.jackrabbit.core.persistence.check.ConsistencyReport)

Example 2 with ConsistencyReport

use of org.apache.jackrabbit.core.persistence.check.ConsistencyReport in project jackrabbit by apache.

the class ConcurrentAddMoveRemoveTest method tearDown.

@Override
public void tearDown() throws Exception {
    ConsistencyReport consistencyReport = TestHelper.checkConsistency(testRootNode.getSession(), false, null);
    //for (ReportItem item : consistencyReport.getItems()) {
    //    System.out.println(item.getMessage());
    //}
    assertTrue(consistencyReport.getItems().size() == 0);
    super.tearDown();
}
Also used : ConsistencyReport(org.apache.jackrabbit.core.persistence.check.ConsistencyReport)

Example 3 with ConsistencyReport

use of org.apache.jackrabbit.core.persistence.check.ConsistencyReport in project jackrabbit by apache.

the class MoveRemoveTest method testMoveRemove.

public void testMoveRemove() throws RepositoryException, NotExecutableException {
    Session session1 = getHelper().getSuperuserSession();
    Session session2 = getHelper().getSuperuserSession();
    session1.move(folder1Path + "/node", folder2Path + "/node");
    session2.getNode(folder1Path + "/node").remove();
    session1.save();
    try {
        session2.save();
    } catch (InvalidItemStateException e) {
        if (e.getCause() == null || e.getCause().getClass() != StaleItemStateException.class) {
            throw e;
        }
    }
    ConsistencyReport consistencyReport = TestHelper.checkConsistency(testRootNode.getSession(), false, null);
    //for (ReportItem item : consistencyReport.getItems()) {
    //    System.out.println(item.getMessage());
    //}
    assertTrue(consistencyReport.getItems().size() == 0);
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) ConsistencyReport(org.apache.jackrabbit.core.persistence.check.ConsistencyReport) Session(javax.jcr.Session)

Example 4 with ConsistencyReport

use of org.apache.jackrabbit.core.persistence.check.ConsistencyReport in project jackrabbit by apache.

the class ConcurrentImportTest method checkConsistency.

private void checkConsistency() throws RepositoryException {
    try {
        ConsistencyReport rep = TestHelper.checkConsistency(testRootNode.getSession(), false, null);
        assertEquals("Found broken nodes in repository: " + rep, 0, rep.getItems().size());
    } catch (NotExecutableException ex) {
    // ignore
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ConsistencyReport(org.apache.jackrabbit.core.persistence.check.ConsistencyReport)

Example 5 with ConsistencyReport

use of org.apache.jackrabbit.core.persistence.check.ConsistencyReport in project jackrabbit by apache.

the class AutoFixCorruptNode method testMissingRootVersion2.

// 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, null);
        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());
        validateDisconnectedVHR(oldVHR);
    } finally {
        s.logout();
        System.setProperty("org.apache.jackrabbit.version.recovery", oldVersionRecoveryProp == null ? "" : oldVersionRecoveryProp);
    }
}
Also used : TransientRepository(org.apache.jackrabbit.core.TransientRepository) Node(javax.jcr.Node) UUID(java.util.UUID) File(java.io.File) ConsistencyReport(org.apache.jackrabbit.core.persistence.check.ConsistencyReport) Session(javax.jcr.Session)

Aggregations

ConsistencyReport (org.apache.jackrabbit.core.persistence.check.ConsistencyReport)11 Session (javax.jcr.Session)8 Node (javax.jcr.Node)7 File (java.io.File)6 UUID (java.util.UUID)6 TransientRepository (org.apache.jackrabbit.core.TransientRepository)6 SQLException (java.sql.SQLException)2 ItemNotFoundException (javax.jcr.ItemNotFoundException)2 RepositoryException (javax.jcr.RepositoryException)2 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)2 InvalidItemStateException (javax.jcr.InvalidItemStateException)1 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)1