Search in sources :

Example 16 with AbstractDocumentNodeState

use of org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState in project jackrabbit-oak by apache.

the class DelegatingDocumentNodeStateTest method metaPropertiesFilteredOut.

@Test
public void metaPropertiesFilteredOut() throws Exception {
    setMetaProps(builder);
    builder.setProperty("foo", "bar");
    AbstractDocumentNodeState state = DelegatingDocumentNodeState.wrap(builder.getNodeState(), NodeStateDiffer.DEFAULT_DIFFER);
    assertEquals(1, Iterables.size(state.getProperties()));
    assertEquals(1, state.getPropertyCount());
}
Also used : AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) Test(org.junit.Test)

Example 17 with AbstractDocumentNodeState

use of org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState in project jackrabbit-oak by apache.

the class DelegatingDocumentNodeStateTest method childNodeDecorated.

@Test
public void childNodeDecorated() throws Exception {
    setMetaProps(builder);
    setMetaProps(builder.child("a"));
    setMetaProps(builder.child("b"));
    AbstractDocumentNodeState state = DelegatingDocumentNodeState.wrap(builder.getNodeState(), NodeStateDiffer.DEFAULT_DIFFER);
    assertTrue(state.getChildNode("a") instanceof AbstractDocumentNodeState);
    assertTrue(state.getChildNode("b") instanceof AbstractDocumentNodeState);
    assertFalse(state.hasChildNode("c"));
    assertFalse(state.getChildNode("c").exists());
    assertFalse(state.hasNoChildren());
    for (ChildNodeEntry cne : state.getChildNodeEntries()) {
        assertTrue(cne.getNodeState() instanceof AbstractDocumentNodeState);
    }
    assertEquals(2, state.getChildNodeCount(100));
}
Also used : ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) Test(org.junit.Test)

Example 18 with AbstractDocumentNodeState

use of org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState in project jackrabbit-oak by apache.

the class SecondaryStoreCacheTest method readWithSecondaryLagging.

@Test
public void readWithSecondaryLagging() throws Exception {
    PathFilter pathFilter = new PathFilter(of("/a"), empty);
    SecondaryStoreCache cache = createBuilder(pathFilter).buildCache();
    SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(cache);
    NodeBuilder nb = primary.getRoot().builder();
    create(nb, "/a/b", "/a/c");
    AbstractDocumentNodeState r0 = merge(nb);
    AbstractDocumentNodeState a_c_0 = documentState(primary.getRoot(), "/a/c");
    observer.contentChanged(r0, CommitInfo.EMPTY);
    AbstractDocumentNodeState result = cache.getDocumentNodeState("/a/c", r0.getRootRevision(), a_c_0.getLastRevision());
    assertTrue(EqualsDiff.equals(a_c_0, result));
    //Make change in some other part of tree i.e. /a/c is unmodified
    nb = primary.getRoot().builder();
    create(nb, "/a/e");
    AbstractDocumentNodeState r1 = merge(nb);
    //Change is yet not pushed to secondary i.e. observer not invoked
    //but lookup with latest root should still work fine if lastRev matches
    result = cache.getDocumentNodeState("/a/c", r1.getRootRevision(), a_c_0.getLastRevision());
    assertTrue(EqualsDiff.equals(a_c_0, result));
    //Change which is not pushed would though not be visible
    AbstractDocumentNodeState a_e_1 = documentState(primary.getRoot(), "/a/e");
    result = cache.getDocumentNodeState("/a/e", r1.getRootRevision(), a_e_1.getLastRevision());
    assertNull(result);
}
Also used : PathFilter(org.apache.jackrabbit.oak.plugins.index.PathFilter) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Aggregations

AbstractDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState)18 Test (org.junit.Test)9 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)8 PathFilter (org.apache.jackrabbit.oak.plugins.index.PathFilter)6 CheckForNull (javax.annotation.CheckForNull)3 RevisionVector (org.apache.jackrabbit.oak.plugins.document.RevisionVector)3 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)3 DocumentNodeState (org.apache.jackrabbit.oak.plugins.document.DocumentNodeState)2 Revision (org.apache.jackrabbit.oak.plugins.document.Revision)2 Stopwatch (com.google.common.base.Stopwatch)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 PathRev (org.apache.jackrabbit.oak.plugins.document.PathRev)1 ApplyDiff (org.apache.jackrabbit.oak.spi.state.ApplyDiff)1 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)1 Counting (org.apache.jackrabbit.oak.stats.Counting)1 TimerStats (org.apache.jackrabbit.oak.stats.TimerStats)1