use of org.apache.jackrabbit.api.JackrabbitNode in project jackrabbit-oak by apache.
the class SameNameSiblingTest method renameSiblings.
@Test
public void renameSiblings() throws RepositoryException {
for (String name : SIBLINGS) {
JackrabbitNode sib = (JackrabbitNode) sns.getNode(name);
sib.rename(rename(name));
}
session.save();
for (String name : SIBLINGS) {
assertFalse(sns.hasNode(name));
assertTrue(sns.hasNode(rename(name)));
}
}
use of org.apache.jackrabbit.api.JackrabbitNode in project jackrabbit-oak by apache.
the class ObservationTest method testRename.
@Test
public void testRename() throws RepositoryException, ExecutionException, InterruptedException {
Node testNode = getNode(TEST_PATH);
Session session = testNode.getSession();
Node nodeA = testNode.addNode("a");
String parentPath = testNode.getPath();
session.save();
assumeTrue(nodeA instanceof JackrabbitNode);
ExpectationListener listener = new ExpectationListener();
observationManager.addEventListener(listener, NODE_MOVED, "/", true, null, null, false);
((JackrabbitNode) nodeA).rename("b");
listener.expectMove(parentPath + "/a", parentPath + "/b");
session.save();
List<Expectation> missing = listener.getMissing(TIME_OUT, TimeUnit.SECONDS);
assertTrue("Missing events: " + missing, missing.isEmpty());
List<Event> unexpected = listener.getUnexpected();
assertTrue("Unexpected events: " + unexpected, unexpected.isEmpty());
}
use of org.apache.jackrabbit.api.JackrabbitNode in project jackrabbit-oak by apache.
the class RenameTest method testRename2.
@Test
public void testRename2() throws Exception {
// give 'add_child_nodes' and 'nt-management' privilege
// -> not sufficient privileges for a renaming of the child
allow(path, privilegesFromNames(new String[] { Privilege.JCR_ADD_CHILD_NODES, Privilege.JCR_NODE_TYPE_MANAGEMENT }));
Node child = testSession.getNode(childNPath);
try {
((JackrabbitNode) child).rename("rename");
testSession.save();
fail("test session must not be allowed to rename nodes.");
} catch (AccessDeniedException e) {
// success.
}
}
use of org.apache.jackrabbit.api.JackrabbitNode in project jackrabbit-oak by apache.
the class RenameTest method testRename.
@Test
public void testRename() throws Exception {
Node child = testSession.getNode(childNPath);
try {
((JackrabbitNode) child).rename("rename");
testSession.save();
fail("test session must not be allowed to rename nodes.");
} catch (AccessDeniedException e) {
// success.
}
}
use of org.apache.jackrabbit.api.JackrabbitNode in project jackrabbit-oak by apache.
the class RenameTest method testRename3.
/**
* @since OAK 1.0 : Renaming a node requires the same permission as moving it
* around. This behavior differs from Jackrabbit 2.x where renaming just
* required the ability to change the child collection of the parent.
*/
@Test
public void testRename3() throws Exception {
// grant 'add_child_nodes', 'nt-management' and remove_child_nodes' at 'path
// -> rename of child must now succeed
allow(path, privilegesFromNames(new String[] { Privilege.JCR_ADD_CHILD_NODES, Privilege.JCR_NODE_TYPE_MANAGEMENT, Privilege.JCR_REMOVE_CHILD_NODES, Privilege.JCR_REMOVE_NODE }));
Node child = testSession.getNode(childNPath);
((JackrabbitNode) child).rename("rename");
testSession.save();
}
Aggregations