use of org.apache.jackrabbit.oak.spi.commit.CommitContext in project jackrabbit-oak by apache.
the class ExternalChangesTest method changeSetForExternalChanges.
@Test
public void changeSetForExternalChanges() throws Exception {
NodeBuilder b1 = ns1.getRoot().builder();
b1.child("a");
b1.setProperty("foo1", "bar");
ns1.merge(b1, newCollectingHook(), newCommitInfo());
NodeBuilder b2 = ns1.getRoot().builder();
b2.child("b");
b2.setProperty("foo2", "bar");
ns1.merge(b2, newCollectingHook(), newCommitInfo());
ns1.runBackgroundUpdateOperations();
c2.reset();
ns2.runBackgroundReadOperations();
CommitInfo ci = c2.getExternalChange();
CommitContext cc = (CommitContext) ci.getInfo().get(CommitContext.NAME);
assertNotNull(cc);
ChangeSet cs = (ChangeSet) cc.get(ChangeCollectorProvider.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
assertNotNull(cs);
assertFalse(cs.anyOverflow());
assertThat(cs.getPropertyNames(), containsInAnyOrder("foo1", "foo2"));
}
use of org.apache.jackrabbit.oak.spi.commit.CommitContext in project jackrabbit-oak by apache.
the class AsyncIndexerServiceTest method changeCollectionEnabled.
@Test
public void changeCollectionEnabled() throws Exception {
injectDefaultServices();
Map<String, Object> config = ImmutableMap.<String, Object>of("asyncConfigs", new String[] { "async:5" });
context.registerService(IndexEditorProvider.class, new PropertyIndexEditorProvider());
MockOsgi.activate(service, context.bundleContext(), config);
NodeBuilder builder = nodeStore.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
builder.child("testRoot").setProperty("foo", "abc");
// merge it back in
nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
CommitInfoCollector infoCollector = new CommitInfoCollector();
nodeStore.addObserver(infoCollector);
AsyncIndexUpdate indexUpdate = getIndexUpdate("async");
indexUpdate.run();
CommitContext commitContext = (CommitContext) infoCollector.infos.get(0).getInfo().get(CommitContext.NAME);
assertNotNull(commitContext);
ChangeSet changeSet = (ChangeSet) commitContext.get(ChangeCollectorProvider.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
assertNotNull(changeSet);
}
use of org.apache.jackrabbit.oak.spi.commit.CommitContext in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method getSingleChangeSet.
/**
* Assumes that the recorder got 1 call, and extracts the ChangeSet from
* that call
*/
private ChangeSet getSingleChangeSet() {
assertEquals(recorder.changes.size(), 1);
CommitContext commitContext = (CommitContext) recorder.changes.get(0).info.getInfo().get(CommitContext.NAME);
assertNotNull(commitContext);
ChangeSet changeSet = (ChangeSet) commitContext.get(ChangeCollectorProvider.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
assertNotNull(changeSet);
return changeSet;
}
Aggregations