Search in sources :

Example 6 with ThreeWayConflictHandler

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

the class ThreeWayConflictHandlerTest method deleteDeletedProperty.

@Test
public void deleteDeletedProperty() throws Exception {
    AtomicBoolean called = new AtomicBoolean(false);
    ThreeWayConflictHandler handler = new ErrorThreeWayConflictHandler() {

        @Override
        public Resolution deleteDeletedProperty(NodeBuilder parent, PropertyState base) {
            called.set(true);
            assertEquals("base", base.getValue(STRING));
            return Resolution.IGNORED;
        }
    };
    ContentRepository repo = newRepo(handler);
    Root root = login(repo);
    setup(root);
    Root ourRoot = login(repo);
    Root theirRoot = login(repo);
    theirRoot.getTree("/c").removeProperty("p");
    ourRoot.getTree("/c").removeProperty("p");
    theirRoot.commit();
    ourRoot.commit();
    assertTrue(called.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ThreeWayConflictHandler(org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler) Root(org.apache.jackrabbit.oak.api.Root) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 7 with ThreeWayConflictHandler

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

the class ThreeWayConflictHandlerTest method addExistingProperty.

@Test
public void addExistingProperty() throws Exception {
    AtomicBoolean called = new AtomicBoolean(false);
    ThreeWayConflictHandler handler = new ErrorThreeWayConflictHandler() {

        @Override
        public Resolution addExistingProperty(NodeBuilder parent, PropertyState ours, PropertyState theirs) {
            called.set(true);
            assertEquals("ours", ours.getValue(STRING));
            assertEquals("theirs", theirs.getValue(STRING));
            return Resolution.IGNORED;
        }
    };
    ContentRepository repo = newRepo(handler);
    Root root = login(repo);
    setup(root);
    Root ourRoot = login(repo);
    Root theirRoot = login(repo);
    theirRoot.getTree("/c").setProperty("p0", "theirs");
    ourRoot.getTree("/c").setProperty("p0", "ours");
    theirRoot.commit();
    ourRoot.commit();
    assertTrue(called.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ThreeWayConflictHandler(org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler) Root(org.apache.jackrabbit.oak.api.Root) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 8 with ThreeWayConflictHandler

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

the class ThreeWayConflictHandlerTest method deleteChangedProperty.

@Test
public void deleteChangedProperty() throws Exception {
    AtomicBoolean called = new AtomicBoolean(false);
    ThreeWayConflictHandler handler = new ErrorThreeWayConflictHandler() {

        @Override
        public Resolution deleteChangedProperty(NodeBuilder parent, PropertyState theirs, PropertyState base) {
            called.set(true);
            assertEquals("theirs", theirs.getValue(STRING));
            assertEquals("base", base.getValue(STRING));
            return Resolution.IGNORED;
        }
    };
    ContentRepository repo = newRepo(handler);
    Root root = login(repo);
    setup(root);
    Root ourRoot = login(repo);
    Root theirRoot = login(repo);
    theirRoot.getTree("/c").setProperty("p", "theirs");
    ourRoot.getTree("/c").removeProperty("p");
    theirRoot.commit();
    ourRoot.commit();
    assertTrue(called.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ThreeWayConflictHandler(org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler) Root(org.apache.jackrabbit.oak.api.Root) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Aggregations

AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)8 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)8 Root (org.apache.jackrabbit.oak.api.Root)8 ThreeWayConflictHandler (org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler)8 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)8 Test (org.junit.Test)8 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)5 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)3 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)3