use of org.apache.jackrabbit.oak.commons.sort.StringSort in project jackrabbit-oak by apache.
the class JournalEntryTest method applyTo.
@Test
public void applyTo() throws Exception {
DiffCache cache = new MemoryDiffCache(new DocumentMK.Builder());
List<String> paths = Lists.newArrayList();
addRandomPaths(paths);
StringSort sort = JournalEntry.newSorter();
add(sort, paths);
RevisionVector from = new RevisionVector(new Revision(1, 0, 1));
RevisionVector to = new RevisionVector(new Revision(2, 0, 1));
sort.sort();
JournalEntry.applyTo(sort, cache, "/", from, to);
for (String p : paths) {
String changes = cache.getChanges(from, to, p, null);
assertNotNull("missing changes for " + p, changes);
for (String c : getChildren(changes)) {
assertTrue(paths.contains(PathUtils.concat(p, c)));
}
}
sort.close();
}
use of org.apache.jackrabbit.oak.commons.sort.StringSort in project jackrabbit-oak by apache.
the class JournalEntryTest method fillExternalChangesWithPath.
@Test
public void fillExternalChangesWithPath() throws Exception {
Revision r1 = new Revision(1, 0, 1);
Revision r2 = new Revision(2, 0, 1);
DocumentStore store = new MemoryDocumentStore();
JournalEntry entry = JOURNAL.newDocument(store);
entry.modified("/");
entry.modified("/foo");
entry.modified("/foo/a");
entry.modified("/foo/b");
entry.modified("/foo/c");
entry.modified("/bar");
entry.modified("/bar/a");
entry.modified("/bar/b");
entry.modified("/bar/c");
UpdateOp op = entry.asUpdateOp(r2);
assertTrue(store.create(JOURNAL, Collections.singletonList(op)));
StringSort sort = JournalEntry.newSorter();
StringSort inv = JournalEntry.newSorter();
JournalEntry.fillExternalChanges(sort, inv, "/foo", r1, r2, store, null, null);
assertEquals(4, sort.getSize());
assertEquals(0, inv.getSize());
sort.close();
inv.close();
}
use of org.apache.jackrabbit.oak.commons.sort.StringSort in project jackrabbit-oak by apache.
the class JournalEntryTest method fillExternalChanges2.
@Test
public void fillExternalChanges2() throws Exception {
Revision r1 = new Revision(1, 0, 1);
Revision r2 = new Revision(2, 0, 1);
Revision r3 = new Revision(3, 0, 1);
Revision r4 = new Revision(4, 0, 1);
DocumentStore store = new MemoryDocumentStore();
JournalEntry entry = JOURNAL.newDocument(store);
entry.modified("/");
entry.modified("/foo");
UpdateOp op = entry.asUpdateOp(r2);
assertTrue(store.create(JOURNAL, Collections.singletonList(op)));
entry = JOURNAL.newDocument(store);
entry.modified("/");
entry.modified("/bar");
op = entry.asUpdateOp(r4);
assertTrue(store.create(JOURNAL, Collections.singletonList(op)));
StringSort sort = externalChanges(r1, r1, store);
assertEquals(0, sort.getSize());
sort.close();
sort = externalChanges(r1, r2, store);
assertEquals(Sets.newHashSet("/", "/foo"), Sets.newHashSet(sort));
sort.close();
sort = externalChanges(r1, r3, store);
assertEquals(Sets.newHashSet("/", "/foo", "/bar"), Sets.newHashSet(sort));
sort.close();
sort = externalChanges(r1, r4, store);
assertEquals(Sets.newHashSet("/", "/foo", "/bar"), Sets.newHashSet(sort));
sort.close();
sort = externalChanges(r2, r2, store);
assertEquals(0, sort.getSize());
sort.close();
sort = externalChanges(r2, r3, store);
assertEquals(Sets.newHashSet("/", "/bar"), Sets.newHashSet(sort));
sort.close();
sort = externalChanges(r2, r4, store);
assertEquals(Sets.newHashSet("/", "/bar"), Sets.newHashSet(sort));
sort.close();
sort = externalChanges(r3, r3, store);
assertEquals(0, sort.getSize());
sort.close();
sort = externalChanges(r3, r4, store);
assertEquals(Sets.newHashSet("/", "/bar"), Sets.newHashSet(sort));
sort.close();
sort = externalChanges(r4, r4, store);
assertEquals(0, sort.getSize());
sort.close();
}
Aggregations