Search in sources :

Example 1 with CommitInfoCollector

use of org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdateTest.CommitInfoCollector 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(ChangeSet.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
    assertNotNull(changeSet);
}
Also used : CommitContext(org.apache.jackrabbit.oak.spi.commit.CommitContext) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitInfoCollector(org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdateTest.CommitInfoCollector) ChangeSet(org.apache.jackrabbit.oak.spi.observation.ChangeSet) Test(org.junit.Test)

Aggregations

CommitInfoCollector (org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdateTest.CommitInfoCollector)1 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)1 CommitContext (org.apache.jackrabbit.oak.spi.commit.CommitContext)1 ChangeSet (org.apache.jackrabbit.oak.spi.observation.ChangeSet)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 Test (org.junit.Test)1