Node a1 = testRootNode.addNode("a1");
Node a2 = testRootNode.addNode("a2");
Node b1 = a1.addNode("b1");
testRootNode.save();
Workspace workspace = b1.getSession().getWorkspace();
try {
// clone (1st attempt, without mix:shareable, should fail)
workspace.clone(workspace.getName(), b1.getPath(),
a2.getPath() + "/b2", false);
fail("Cloning a node into the same workspace should fail.");
} catch (RepositoryException e) {
// expected
}
// add mixin
ensureMixinType(b1, mixShareable);
b1.save();
// clone (2nd attempt, with mix:shareable)
workspace.clone(workspace.getName(), b1.getPath(),
a2.getPath() + "/b2", false);
}