use of org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler in project jackrabbit-oak by apache.
the class ThreeWayConflictHandlerTest method changeChangedProperty.
@Test
public void changeChangedProperty() throws Exception {
AtomicBoolean called = new AtomicBoolean(false);
ThreeWayConflictHandler handler = new ErrorThreeWayConflictHandler() {
@Override
public Resolution changeChangedProperty(NodeBuilder parent, PropertyState ours, PropertyState theirs, PropertyState base) {
called.set(true);
assertEquals("ours", ours.getValue(STRING));
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").setProperty("p", "ours");
theirRoot.commit();
ourRoot.commit();
assertTrue(called.get());
}
use of org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler in project jackrabbit-oak by apache.
the class ThreeWayConflictHandlerTest method deleteDeletedNode.
@Test
public void deleteDeletedNode() throws Exception {
AtomicBoolean called = new AtomicBoolean(false);
ThreeWayConflictHandler handler = new ErrorThreeWayConflictHandler() {
@Override
public Resolution deleteDeletedNode(NodeBuilder parent, String name, NodeState base) {
called.set(true);
assertTrue(base.hasProperty("p"));
assertEquals("base", base.getProperty("p").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").remove();
ourRoot.getTree("/c").remove();
theirRoot.commit();
ourRoot.commit();
assertTrue(called.get());
}
use of org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler in project jackrabbit-oak by apache.
the class ThreeWayConflictHandlerTest method deleteChangedNode.
@Test
public void deleteChangedNode() throws Exception {
AtomicBoolean called = new AtomicBoolean(false);
ThreeWayConflictHandler handler = new ErrorThreeWayConflictHandler() {
@Override
public Resolution deleteChangedNode(NodeBuilder parent, String name, NodeState theirs, NodeState base) {
called.set(true);
assertTrue(theirs.hasProperty("p"));
assertTrue(base.hasProperty("p"));
assertEquals("theirs", theirs.getProperty("p").getValue(STRING));
assertEquals("base", base.getProperty("p").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").remove();
theirRoot.commit();
ourRoot.commit();
assertTrue(called.get());
}
use of org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler in project jackrabbit-oak by apache.
the class ThreeWayConflictHandlerTest method changeDeletedProperty.
@Test
public void changeDeletedProperty() throws Exception {
AtomicBoolean called = new AtomicBoolean(false);
ThreeWayConflictHandler handler = new ErrorThreeWayConflictHandler() {
@Override
public Resolution changeDeletedProperty(NodeBuilder parent, PropertyState ours, PropertyState base) {
called.set(true);
assertEquals("ours", ours.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").removeProperty("p");
ourRoot.getTree("/c").setProperty("p", "ours");
theirRoot.commit();
ourRoot.commit();
assertTrue(called.get());
}
use of org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler in project jackrabbit-oak by apache.
the class ThreeWayConflictHandlerTest method changeDeletedNode.
@Test
public void changeDeletedNode() throws Exception {
AtomicBoolean called = new AtomicBoolean(false);
ThreeWayConflictHandler handler = new ErrorThreeWayConflictHandler() {
@Override
public Resolution changeDeletedNode(NodeBuilder parent, String name, NodeState ours, NodeState base) {
called.set(true);
assertTrue(ours.hasProperty("p"));
assertTrue(base.hasProperty("p"));
assertEquals("ours", ours.getProperty("p").getValue(STRING));
assertEquals("base", base.getProperty("p").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").remove();
ourRoot.getTree("/c").setProperty("p", "ours");
theirRoot.commit();
ourRoot.commit();
assertTrue(called.get());
}
Aggregations