use of org.apache.jackrabbit.api.JackrabbitNode in project jackrabbit-oak by apache.
the class JackrabbitNodeTest method _testRename.
//Ignore("OAK-3658")
public void _testRename() throws RepositoryException {
Node renamedNode = null;
NodeIterator it = testRootNode.getNodes();
int pos = 0;
while (it.hasNext()) {
Node n = it.nextNode();
String name = n.getName();
assertEquals(new String(new char[] { SEQ_BEFORE.charAt(pos) }), name);
if (pos == RELPOS) {
JackrabbitNode node = (JackrabbitNode) n;
node.rename(name.toUpperCase());
renamedNode = n;
}
pos++;
}
it = testRootNode.getNodes();
pos = 0;
while (it.hasNext()) {
Node n = it.nextNode();
String name = n.getName();
assertEquals(new String(new char[] { SEQ_AFTER.charAt(pos) }), name);
if (pos == RELPOS) {
assertTrue(n.isSame(renamedNode));
}
pos++;
}
}
use of org.apache.jackrabbit.api.JackrabbitNode in project jackrabbit-oak by apache.
the class RepositoryTest method renameNonOrderable.
@Test
public void renameNonOrderable() throws RepositoryException {
Session session = getAdminSession();
Node root = session.getRootNode();
Node parent = root.addNode("parent", NodeTypeConstants.NT_OAK_UNSTRUCTURED);
parent.addNode("fo");
Node foo = parent.addNode("foo");
session.save();
((JackrabbitNode) foo).rename("renamed");
assertEquals("renamed", foo.getName());
assertFalse(session.nodeExists("/parent/foo"));
assertTrue(session.nodeExists("/parent/renamed"));
}
use of org.apache.jackrabbit.api.JackrabbitNode in project jackrabbit by apache.
the class AbstractWriteTest method testRename.
public void testRename() throws RepositoryException, NotExecutableException {
Session testSession = getTestSession();
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.
}
// give 'add_child_nodes' and 'nt-management' privilege
// -> not sufficient privileges for a renaming of the child
givePrivileges(path, privilegesFromNames(new String[] { Privilege.JCR_ADD_CHILD_NODES, Privilege.JCR_NODE_TYPE_MANAGEMENT }), getRestrictions(superuser, path));
try {
((JackrabbitNode) child).rename("rename");
testSession.save();
fail("test session must not be allowed to rename nodes.");
} catch (AccessDeniedException e) {
// success.
}
// add 'remove_child_nodes' at 'path
// -> rename of child must now succeed
givePrivileges(path, privilegesFromName(Privilege.JCR_REMOVE_CHILD_NODES), getRestrictions(superuser, path));
((JackrabbitNode) child).rename("rename");
testSession.save();
}
use of org.apache.jackrabbit.api.JackrabbitNode in project jackrabbit-oak by apache.
the class JackrabbitNodeTest method testSetNewMixins.
/**
* @since oak 1.0
*/
public void testSetNewMixins() throws RepositoryException {
// create node with mixin test:AA
Node n = testRootNode.addNode("foo", "nt:folder");
((JackrabbitNode) n).setMixins(new String[] { "test:AA", "test:A" });
superuser.save();
assertTrue(n.isNodeType("test:AA"));
assertTrue(n.isNodeType("test:A"));
assertTrue(n.hasProperty(JcrConstants.JCR_MIXINTYPES));
}
use of org.apache.jackrabbit.api.JackrabbitNode in project jackrabbit-oak by apache.
the class JackrabbitNodeTest method testUpdateMixins.
/**
* @since oak 1.0
*/
public void testUpdateMixins() throws RepositoryException {
// create node with mixin test:AA
Node n = testRootNode.addNode("foo", "nt:folder");
((JackrabbitNode) n).setMixins(new String[] { "test:A", "test:AA" });
superuser.save();
assertTrue(n.isNodeType("test:AA"));
assertTrue(n.isNodeType("test:A"));
((JackrabbitNode) n).setMixins(new String[] { "test:A", "test:AA", JcrConstants.MIX_REFERENCEABLE });
superuser.save();
assertTrue(n.isNodeType("test:AA"));
assertTrue(n.isNodeType("test:A"));
assertTrue(n.isNodeType(JcrConstants.MIX_REFERENCEABLE));
assertTrue(n.hasProperty(JcrConstants.JCR_UUID));
((JackrabbitNode) n).setMixins(new String[] { JcrConstants.MIX_REFERENCEABLE });
superuser.save();
assertFalse(n.isNodeType("test:AA"));
assertFalse(n.isNodeType("test:A"));
assertTrue(n.isNodeType(JcrConstants.MIX_REFERENCEABLE));
assertTrue(n.hasProperty(JcrConstants.JCR_UUID));
}
Aggregations