Search in sources :

Example 11 with DefaultNodeStateDiff

use of org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff in project jackrabbit-oak by apache.

the class DocumentNodeStoreTest method dispatch.

// OAK-2695
@Test
public void dispatch() throws Exception {
    DocumentNodeStore ns = builderProvider.newBuilder().getNodeStore();
    RevisionVector from = ns.getHeadRevision();
    NodeBuilder builder = ns.getRoot().builder();
    builder.child("test");
    merge(ns, builder);
    RevisionVector to = ns.getHeadRevision();
    DiffCache.Entry entry = ns.getDiffCache().newEntry(from, to, true);
    entry.append("/", "-\"foo\"");
    entry.done();
    ns.compare(ns.getRoot(), ns.getRoot(from), new DefaultNodeStateDiff() {

        @Override
        public boolean childNodeDeleted(String name, NodeState before) {
            assertNotNull(before);
            return true;
        }
    });
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) DefaultNodeStateDiff(org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 12 with DefaultNodeStateDiff

use of org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff in project jackrabbit-oak by apache.

the class LastRevRecoveryRandomizedIT method compareAndTraverse.

private void compareAndTraverse(NodeState state, final String path, Map<String, NodeState> states) {
    NodeState expected = states.remove(path);
    if (expected == null) {
        fail("unexpected node at " + path + " (seed=" + SEED + ")");
        return;
    }
    comparePropertiesAgainstBaseState(state, expected, new DefaultNodeStateDiff() {

        @Override
        public boolean propertyAdded(PropertyState after) {
            fail("unexpected property: " + path + "/" + after + " (seed=" + SEED + ")");
            return super.propertyAdded(after);
        }

        @Override
        public boolean propertyChanged(PropertyState before, PropertyState after) {
            assertEquals("property mismatch on node " + path + " (seed=" + SEED + ")", before, after);
            return super.propertyChanged(before, after);
        }

        @Override
        public boolean propertyDeleted(PropertyState before) {
            fail("missing property: " + path + "/" + before + " (seed=" + SEED + ")");
            return super.propertyDeleted(before);
        }
    });
    for (ChildNodeEntry entry : state.getChildNodeEntries()) {
        String p = PathUtils.concat(path, entry.getName());
        compareAndTraverse(entry.getNodeState(), p, states);
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) DefaultNodeStateDiff(org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Aggregations

DefaultNodeStateDiff (org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff)12 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)12 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)10 Test (org.junit.Test)10 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)5 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)3 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)3 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3 Clock (org.apache.jackrabbit.oak.stats.Clock)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 CONSTRAINT (org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT)2 TRANSIENT (org.apache.jackrabbit.oak.plugins.document.DocumentStoreException.Type.TRANSIENT)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 DocumentNodeState (org.apache.jackrabbit.oak.plugins.document.DocumentNodeState)1 MapEntry.newMapEntry (org.apache.jackrabbit.oak.segment.MapEntry.newMapEntry)1 Mounts (org.apache.jackrabbit.oak.spi.mount.Mounts)1 AbstractNodeState (org.apache.jackrabbit.oak.spi.state.AbstractNodeState)1 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)1