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());
}
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());
}
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))));
}
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"));
}
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);
}
}
Aggregations