Search in sources :

Example 1 with SimpleCommitContext

use of org.apache.jackrabbit.oak.spi.commit.SimpleCommitContext in project jackrabbit-oak by apache.

the class ExternalChangesTest method journalService.

@Test
public void journalService() throws Exception {
    wb.register(JournalPropertyService.class, new TestJournalService(), null);
    // Do a dummy write so that journal property handler gets refreshed
    // and picks our newly registered service
    NodeBuilder b0 = ns1.getRoot().builder();
    b0.child("0");
    ns1.merge(b0, newCollectingHook(), newCommitInfo());
    ns1.runBackgroundUpdateOperations();
    NodeBuilder b1 = ns1.getRoot().builder();
    b1.child("a");
    CommitContext cc = new SimpleCommitContext();
    cc.set(TestProperty.NAME, new TestProperty("foo"));
    ns1.merge(b1, newCollectingHook(), newCommitInfo(cc));
    NodeBuilder b2 = ns1.getRoot().builder();
    b2.child("b");
    cc = new SimpleCommitContext();
    cc.set(TestProperty.NAME, new TestProperty("bar"));
    ns1.merge(b2, newCollectingHook(), newCommitInfo(cc));
    // null entry
    NodeBuilder b3 = ns1.getRoot().builder();
    b3.child("c");
    ns1.merge(b3, newCollectingHook(), newCommitInfo());
    ns1.runBackgroundUpdateOperations();
    c2.reset();
    ns2.runBackgroundReadOperations();
    CommitInfo ci = c2.getExternalChange();
    cc = (CommitContext) ci.getInfo().get(CommitContext.NAME);
    CumulativeTestProperty ct = (CumulativeTestProperty) cc.get(TestProperty.NAME);
    assertNotNull(ct);
    assertThat(ct.values, containsInAnyOrder("foo", "bar", "NULL"));
}
Also used : CommitContext(org.apache.jackrabbit.oak.spi.commit.CommitContext) SimpleCommitContext(org.apache.jackrabbit.oak.spi.commit.SimpleCommitContext) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) SimpleCommitContext(org.apache.jackrabbit.oak.spi.commit.SimpleCommitContext) Test(org.junit.Test)

Example 2 with SimpleCommitContext

use of org.apache.jackrabbit.oak.spi.commit.SimpleCommitContext in project jackrabbit-oak by apache.

the class DocumentNodeStore method newCommitInfo.

private static CommitInfo newCommitInfo(@Nonnull ChangeSet changeSet, JournalPropertyHandler journalPropertyHandler) {
    CommitContext commitContext = new SimpleCommitContext();
    commitContext.set(COMMIT_CONTEXT_OBSERVATION_CHANGESET, changeSet);
    journalPropertyHandler.addTo(commitContext);
    Map<String, Object> info = ImmutableMap.<String, Object>of(CommitContext.NAME, commitContext);
    return new CommitInfo(CommitInfo.OAK_UNKNOWN, CommitInfo.OAK_UNKNOWN, info, true);
}
Also used : CommitContext(org.apache.jackrabbit.oak.spi.commit.CommitContext) SimpleCommitContext(org.apache.jackrabbit.oak.spi.commit.SimpleCommitContext) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) SimpleCommitContext(org.apache.jackrabbit.oak.spi.commit.SimpleCommitContext)

Aggregations

CommitContext (org.apache.jackrabbit.oak.spi.commit.CommitContext)2 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)2 SimpleCommitContext (org.apache.jackrabbit.oak.spi.commit.SimpleCommitContext)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 Test (org.junit.Test)1