Package org.apache.jackrabbit.oak.spi.state

Examples of org.apache.jackrabbit.oak.spi.state.NodeStateBuilder


    @Test
    public void branch() throws CommitFailedException {
        NodeStoreBranch branch = store.branch();

        NodeStateBuilder rootBuilder = store.getBuilder(branch.getRoot());
        NodeStateBuilder testBuilder = store.getBuilder(root.getChildNode("test"));

        testBuilder.setNode("newNode", MemoryNodeState.EMPTY_NODE);
        testBuilder.removeNode("x");

        NodeStateBuilder newNodeBuilder = store.getBuilder(
                testBuilder.getNodeState().getChildNode("newNode"));

        CoreValue fortyTwo = store.getValueFactory().createValue(42);
        newNodeBuilder.setProperty("n", fortyTwo);

        testBuilder.setNode("newNode", newNodeBuilder.getNodeState());
        rootBuilder.setNode("test", testBuilder.getNodeState());

        // Assert changes are present in the builder
        NodeState testState = rootBuilder.getNodeState().getChildNode("test");
        assertNotNull(testState.getChildNode("newNode"));
View Full Code Here


    }

    @Test
    public void afterCommitHook() throws CommitFailedException {
        NodeState root = store.getRoot();
        NodeStateBuilder rootBuilder= store.getBuilder(root);

        NodeState test = root.getChildNode("test");
        NodeStateBuilder testBuilder = store.getBuilder(test);

        NodeStateBuilder newNodeBuilder = store.getBuilder(MemoryNodeState.EMPTY_NODE);
        final CoreValue fortyTwo = store.getValueFactory().createValue(42);
        newNodeBuilder.setProperty("n", fortyTwo);

        testBuilder.setNode("newNode", newNodeBuilder.getNodeState());
        testBuilder.removeNode("a");

        rootBuilder.setNode("test", testBuilder.getNodeState());
        final NodeState newRoot = rootBuilder.getNodeState();
View Full Code Here

    }

    @Test
    public void beforeCommitHook() throws CommitFailedException {
        NodeState root = store.getRoot();
        NodeStateBuilder rootBuilder = store.getBuilder(root);

        NodeState test = root.getChildNode("test");
        NodeStateBuilder testBuilder = store.getBuilder(test);

        NodeStateBuilder newNodeBuilder = store.getBuilder(MemoryNodeState.EMPTY_NODE);
        final CoreValue fortyTwo = store.getValueFactory().createValue(42);
        newNodeBuilder.setProperty("n", fortyTwo);

        testBuilder.setNode("newNode", newNodeBuilder.getNodeState());
        testBuilder.removeNode("a");

        rootBuilder.setNode("test", testBuilder.getNodeState());
        final NodeState newRoot = rootBuilder.getNodeState();

        commitWithEditor(newRoot, new EmptyEditor() {
            @Override
            public NodeState editCommit(NodeStore store, NodeState before, NodeState after) {
                NodeStateBuilder rootBuilder = store.getBuilder(after);
                NodeStateBuilder testBuilder = store.getBuilder(after.getChildNode("test"));
                testBuilder.setNode("fromHook", MemoryNodeState.EMPTY_NODE);
                rootBuilder.setNode("test", testBuilder.getNodeState());
                return rootBuilder.getNodeState();
            }
        });

        test = store.getRoot().getChildNode("test");
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.spi.state.NodeStateBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.