Search in sources :

Example 11 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class DelegatingDocumentNodeStateTest method basicWorking.

@Test
public void basicWorking() throws Exception {
    RevisionVector rv1 = new RevisionVector(new Revision(1, 0, 1));
    RevisionVector rv2 = new RevisionVector(new Revision(1, 0, 3));
    builder.setProperty(asPropertyState(PROP_REVISION, rv1));
    builder.setProperty(asPropertyState(PROP_LAST_REV, rv2));
    AbstractDocumentNodeState state = DelegatingDocumentNodeState.wrap(builder.getNodeState(), NodeStateDiffer.DEFAULT_DIFFER);
    assertEquals(rv1, state.getRootRevision());
    assertEquals(rv2, state.getLastRevision());
    assertTrue(state.hasNoChildren());
    assertTrue(state.exists());
    assertFalse(state.isFromExternalChange());
}
Also used : Revision(org.apache.jackrabbit.oak.plugins.document.Revision) RevisionVector(org.apache.jackrabbit.oak.plugins.document.RevisionVector) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) Test(org.junit.Test)

Example 12 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class DelegatingDocumentNodeStateTest method withRootRevision.

@Test
public void withRootRevision() throws Exception {
    RevisionVector rv1 = new RevisionVector(new Revision(1, 0, 1));
    RevisionVector rv2 = new RevisionVector(new Revision(1, 0, 3));
    builder.setProperty(asPropertyState(PROP_REVISION, rv1));
    builder.setProperty(asPropertyState(PROP_LAST_REV, rv2));
    AbstractDocumentNodeState state = DelegatingDocumentNodeState.wrap(builder.getNodeState(), NodeStateDiffer.DEFAULT_DIFFER);
    AbstractDocumentNodeState state2 = state.withRootRevision(rv1, false);
    assertSame(state, state2);
    RevisionVector rv4 = new RevisionVector(new Revision(1, 0, 4));
    AbstractDocumentNodeState state3 = state.withRootRevision(rv4, true);
    assertEquals(rv4, state3.getRootRevision());
    assertTrue(state3.isFromExternalChange());
}
Also used : Revision(org.apache.jackrabbit.oak.plugins.document.Revision) RevisionVector(org.apache.jackrabbit.oak.plugins.document.RevisionVector) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) Test(org.junit.Test)

Example 13 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class DelegatingDocumentNodeStateTest method setMetaProps.

private static void setMetaProps(NodeBuilder nb) {
    nb.setProperty(asPropertyState(PROP_REVISION, new RevisionVector(new Revision(1, 0, 1))));
    nb.setProperty(asPropertyState(PROP_LAST_REV, new RevisionVector(new Revision(1, 0, 1))));
}
Also used : Revision(org.apache.jackrabbit.oak.plugins.document.Revision) RevisionVector(org.apache.jackrabbit.oak.plugins.document.RevisionVector)

Example 14 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class RevisionsCommandTest method sweep.

@Test
public void sweep() throws Exception {
    int clusterId = ns.getClusterId();
    String output = captureSystemErr(new Sweep(clusterId));
    assertThat(output, containsString("cannot sweep revisions for active clusterId"));
    output = captureSystemErr(new Sweep(0));
    assertThat(output, containsString("clusterId option is required"));
    output = captureSystemErr(new Sweep(99));
    assertThat(output, containsString("store does not have changes with clusterId"));
    ns.dispose();
    output = captureSystemOut(new Sweep(clusterId));
    assertThat(output, containsString("Revision sweep not needed for clusterId"));
    // remove the sweep revision to force a sweep run
    MongoConnection c = connectionFactory.getConnection();
    DocumentMK.Builder builder = builderProvider.newBuilder().setMongoDB(c.getDB());
    DocumentStore store = builder.getDocumentStore();
    UpdateOp op = new UpdateOp(getIdFromPath("/"), false);
    op.removeMapEntry("_sweepRev", new Revision(0, 0, clusterId));
    assertNotNull(store.findAndUpdate(Collection.NODES, op));
    output = captureSystemOut(new Sweep(clusterId));
    assertThat(output, containsString("Updated sweep revision to"));
}
Also used : DocumentStore(org.apache.jackrabbit.oak.plugins.document.DocumentStore) Revision(org.apache.jackrabbit.oak.plugins.document.Revision) UpdateOp(org.apache.jackrabbit.oak.plugins.document.UpdateOp) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) MongoConnection(org.apache.jackrabbit.oak.plugins.document.util.MongoConnection) Test(org.junit.Test)

Example 15 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class PersistentCacheTest method runTest.

@Override
protected void runTest() throws Exception {
    for (int i = 0; i < ITEMS_TO_ADD; i++) {
        PathRev key = PathRev.fromString("/" + timestamp.getAndIncrement() + "@" + new Revision(timestamp.getAndIncrement(), 0, 0));
        nodesCache.put(key, dns.getRoot());
        // read, so the entry is marked as used
        nodesCache.getIfPresent(key);
    }
}
Also used : Revision(org.apache.jackrabbit.oak.plugins.document.Revision) PathRev(org.apache.jackrabbit.oak.plugins.document.PathRev)

Aggregations

Revision (org.apache.jackrabbit.oak.plugins.document.Revision)32 Test (org.junit.Test)17 RevisionVector (org.apache.jackrabbit.oak.plugins.document.RevisionVector)13 BasicDBObject (com.mongodb.BasicDBObject)4 DBObject (com.mongodb.DBObject)4 NodeDocument (org.apache.jackrabbit.oak.plugins.document.NodeDocument)4 PathRev (org.apache.jackrabbit.oak.plugins.document.PathRev)4 UpdateOp (org.apache.jackrabbit.oak.plugins.document.UpdateOp)4 DBCollection (com.mongodb.DBCollection)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 StringValue (org.apache.jackrabbit.oak.plugins.document.util.StringValue)3 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)3 TreeMap (java.util.TreeMap)2 AbstractDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState)2 AbstractMongoConnectionTest (org.apache.jackrabbit.oak.plugins.document.AbstractMongoConnectionTest)2 DocumentStoreException (org.apache.jackrabbit.oak.plugins.document.DocumentStoreException)2 Key (org.apache.jackrabbit.oak.plugins.document.UpdateOp.Key)2 Operation (org.apache.jackrabbit.oak.plugins.document.UpdateOp.Operation)2