use of org.apache.jackrabbit.oak.plugins.document.RevisionVector in project jackrabbit-oak by apache.
the class SecondaryStoreCacheTest method binarySearch.
@Test
public void binarySearch() throws Exception {
SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty));
List<AbstractDocumentNodeState> roots = Lists.newArrayList();
List<RevisionVector> revs = Lists.newArrayList();
for (int i = 0; i < 50; i++) {
NodeBuilder nb = primary.getRoot().builder();
create(nb, "/a/b" + i);
AbstractDocumentNodeState r = merge(nb);
roots.add(r);
revs.add(r.getRootRevision());
}
AbstractDocumentNodeState[] rootsArr = Iterables.toArray(roots, AbstractDocumentNodeState.class);
Collections.shuffle(revs);
for (RevisionVector rev : revs) {
AbstractDocumentNodeState result = SecondaryStoreCache.findMatchingRoot(rootsArr, rev);
assertNotNull(result);
assertEquals(rev, result.getRootRevision());
}
NodeBuilder nb = primary.getRoot().builder();
create(nb, "/a/m");
AbstractDocumentNodeState r = merge(nb);
AbstractDocumentNodeState result = SecondaryStoreCache.findMatchingRoot(rootsArr, r.getRootRevision());
assertNull(result);
}
use of org.apache.jackrabbit.oak.plugins.document.RevisionVector in project jackrabbit-oak by apache.
the class SecondaryStoreCacheTest method basicTest.
@Test
public void basicTest() throws Exception {
SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty));
NodeBuilder nb = primary.getRoot().builder();
create(nb, "/a/b", "/a/c", "/x/y/z");
merge(nb);
RevisionVector rv1 = new RevisionVector(new Revision(1, 0, 1));
RevisionVector rv2 = new RevisionVector(new Revision(1, 0, 3));
assertNull(cache.getDocumentNodeState("/a/b", rv1, rv2));
assertNull(cache.getDocumentNodeState("/x", rv1, rv2));
}
use of org.apache.jackrabbit.oak.plugins.document.RevisionVector 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.RevisionVector 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.RevisionVector 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))));
}
Aggregations