use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodeTest method testCloneToSameParent.
//--------------------------------------------------------- limitation tests
/**
* Clone a mix:shareable node to the same workspace, with the same
* parent. This is unsupported in Jackrabbit.
*/
public void testCloneToSameParent() throws Exception {
// setup parent nodes and first child
Node a = testRootNode.addNode("a");
Node b1 = a.addNode("b1");
testRootNode.getSession().save();
// add mixin
ensureMixinType(b1, mixShareable);
b1.save();
Workspace workspace = b1.getSession().getWorkspace();
try {
// clone to same parent
workspace.clone(workspace.getName(), b1.getPath(), a.getPath() + "/b2", false);
fail("Cloning inside same parent should fail.");
} catch (UnsupportedRepositoryOperationException e) {
// expected
}
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodeTest method testModifyDescendantAndSave.
/**
* Verify that invoking save() on a share-ancestor will save changes in
* all share-descendants.
*/
public void testModifyDescendantAndSave() throws Exception {
// setup parent nodes and first child
Node a1 = testRootNode.addNode("a1");
Node a2 = testRootNode.addNode("a2");
Node b1 = a1.addNode("b1");
testRootNode.getSession().save();
// add mixin
ensureMixinType(b1, mixShareable);
b1.save();
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(), a2.getPath() + "/b2", false);
// add child node c to b1
Node c = b1.addNode("c");
b1.save();
// add child d to c, this modifies c
c.addNode("d");
// save a2 (having path /testroot/a2): this should save c as well
// since one of the paths to c is /testroot/a2/b2/c
a2.save();
assertFalse("Saving share-ancestor should save share-descendants", c.isModified());
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodeTest method testSharedNodePath.
/**
* Verify that shared nodes return correct paths.
*/
public void testSharedNodePath() throws Exception {
Node a1 = testRootNode.addNode("a1");
Node a2 = a1.addNode("a2");
Node b1 = a1.addNode("b1");
ensureMixinType(b1, mixShareable);
testRootNode.getSession().save();
//now we have a shareable node N with path a1/b1
Session session = testRootNode.getSession();
Workspace workspace = session.getWorkspace();
String path = a2.getPath() + "/b2";
workspace.clone(workspace.getName(), b1.getPath(), path, false);
//now we have another shareable node N' in the same shared set as N with path a1/a2/b2
//using the path a1/a2/b2, we should get the node N' here
Item item = session.getItem(path);
assertEquals("unexpectedly got the path from another node from the same shared set", path, item.getPath());
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodeTest method testRemoveDescendantAndSave.
//----------------------------------------------------- implementation tests
/**
* Verify that invoking save() on a share-ancestor will save changes in
* all share-descendants.
*/
public void testRemoveDescendantAndSave() throws Exception {
// setup parent nodes and first child
Node a1 = testRootNode.addNode("a1");
Node a2 = testRootNode.addNode("a2");
Node b1 = a1.addNode("b1");
testRootNode.getSession().save();
// add mixin
ensureMixinType(b1, mixShareable);
b1.save();
// clone
Session session = b1.getSession();
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(), a2.getPath() + "/b2", false);
// add child node c to b1
Node c = b1.addNode("c");
b1.save();
// remove child node c
c.remove();
// save a2 (having path /testroot/a2): this should save c as well
// since one of the paths to c is /testroot/a2/b2/c
a2.save();
assertFalse("Saving share-ancestor should save share-descendants", session.hasPendingChanges());
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodeTest method testGetIndex.
//------------------------------------------------------ specification tests
/**
* Verify that Node.getIndex returns the correct index in a shareable
* node (6.13).
*/
public void testGetIndex() throws Exception {
// setup parent nodes and first child
Node a1 = testRootNode.addNode("a1");
Node a2 = testRootNode.addNode("a2");
Node b1 = a1.addNode("b1");
a2.addNode("b");
testRootNode.getSession().save();
// add mixin
ensureMixinType(b1, mixShareable);
b1.save();
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(), a2.getPath() + "/b", false);
Node[] shared = getSharedSet(b1);
assertEquals(2, shared.length);
b1 = shared[0];
Node b2 = shared[1];
// verify indices of nodes b1/b2 in shared set
assertEquals(1, b1.getIndex());
assertEquals(2, b2.getIndex());
}
Aggregations