/** * Add the mix:shareable mixin to a node (6.13.2). */ public void testAddMixin() throws Exception { // setup parent node and first child Node a = testRootNode.addNode("a"); Node b = a.addNode("b"); testRootNode.getSession().save(); ensureMixinType(b, mixShareable); b.save(); }
public Node createRoleBasedFolderNode( final Session session, final PentahoJcrConstants pentahoJcrConstants, final ITenant tenant ) throws RepositoryException { Node authzFolderNode = createAuthzFolderNode( session, pentahoJcrConstants, tenant ); Node node = authzFolderNode.addNode( FOLDER_NAME_ROLEBASED, pentahoJcrConstants.getPHO_NT_INTERNALFOLDER() ); authzFolderNode.save(); session.save(); return node; }
/** * Test if Item.isModified() returns false for an already exixting and modified * NodeItem after the node is saved (persistent). * Modified means that a property is added with a string value. * * @see javax.jcr.Item#isModified() */ public void testPersistentNodeItemIsModified () throws RepositoryException { Node testNode = testRootNode.addNode(nodeName1, testNodeType); testRootNode.getSession().save(); // modify the persistent testNode testNode.setProperty(propertyName1, "test"); testNode.save(); Item testNodeItem = superuser.getItem(testNode.getPath()); // check testNodeItem.isModified() after save assertFalse("Item.isModified() must return false after an existing Property is modified and the current Node is saved", testNodeItem.isModified()); }
/** * Tests if a {@link javax.jcr.RepositoryException} is thrown when calling * <code>Node.save()</code> on a newly added node */ public void testSaveOnNewNodeRepositoryException() throws Exception { // get default workspace test root node using superuser session Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath()); // create a node Node newNode = defaultRootNode.addNode(nodeName1, testNodeType); try { newNode.save(); fail("Calling Node.save() on a newly added node should throw a RepositoryException"); } catch (RepositoryException success) { // ok } }
@Override protected void setUp() throws Exception { super.setUp(); testNode = testRootNode.addNode(nodeName1); testNode.setProperty(propertyName1, "existingProp"); testRootNode.save(); }
/** * Move a orderable child node and reorder the remaining nodes. */ public void testMoveAndReorder() throws RepositoryException { Node[] children = createOrderableChildren(false); String oldName = children[2].getName(); // move testRootNode.getSession().move(children[2].getPath(), destPath); // reorder srcParent.orderBefore(getRelPath(children[1]), null); testOrder(srcParent, new Node[] {children[0], children[3], children[1]}); testRootNode.save(); testOrder(srcParent, new Node[] {children[0], children[3], children[1]}); assertFalse(srcParent.hasNode(oldName)); }
public void testRemoveMixin() throws RepositoryException, NotExecutableException { ((Node) superuser.getItem(childNode.getPath())).addMixin(mixinName); superuser.save(); checkReadOnly(childNode.getPath()); try { childNode.removeMixin(mixinName); childNode.save(); fail("TestSession does not have sufficient privileges to remove a mixin type."); } catch (AccessDeniedException e) { // success } modifyPrivileges(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, true); childNode.removeMixin(mixinName); childNode.save(); }
/** * Creates the named test node. The node is created within a transaction * to avoid mixing transactional and non-transactional writes within a * concurrent test run. */ private static synchronized Node createParentNode(Node test, String name) throws RepositoryException { try { UserTransaction utx = new UserTransactionImpl(test.getSession()); utx.begin(); Node parent = test.addNode(name); test.save(); utx.commit(); return parent; } catch (RepositoryException e) { throw e; } catch (Exception e) { throw new RepositoryException("Failed to add node: " + name, e); } }
public void testRemovedProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException { Property p = testRootNode.setProperty(propertyName1, testValue); testRootNode.save(); p.remove(); testRootNode.refresh(false); // Property p must be reverted to 'existing' -> getString must succeed. p.getString(); // similarly accessing the property again must succeed. testRootNode.getProperty(propertyName1); }
@Override protected void setUp() throws Exception { super.setUp(); if (testRootNode.hasProperty(propertyName1)) { testRootNode.getProperty(propertyName1).remove(); testRootNode.save(); } testValue = testRootNode.getSession().getValueFactory().createValue("anyString"); if (!testRootNode.getPrimaryNodeType().canSetProperty(propertyName1, testValue)) { throw new NotExecutableException(""); } }
/** * 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()); }
@Override protected void setUp() throws Exception { super.setUp(); // create parent node srcParentNode = testRootNode.addNode(nodeName1, testNodeType); // create node to be moved moveNode = srcParentNode.addNode(nodeName2, testNodeType); // create a node that will serve as new parent destParentNode = testRootNode.addNode(nodeName3, testNodeType); // save the new nodes testRootNode.save(); destinationPath = destParentNode.getPath() + "/" + nodeName2; }
public void testWrongCaseNeverMatches() throws RepositoryException { Node n = testRootNode.addNode("node"); n.setProperty("foo", "Bar"); testRootNode.save(); executeXPathQuery(testPath + "/*[jcr:like(fn:lower-case(@foo), 'BA%')]", new Node[]{}); }
public void testReorder3() throws RepositoryException { String pathBefore = child3.getPath(); testRootNode.orderBefore(getRelPath(child3), getRelPath(child1)); testRootNode.save(); Item itemIndex3 = testRootNode.getSession().getItem(pathBefore); assertTrue(itemIndex3.isSame(child2)); Item item3 = testRootNode.getSession().getItem(child3.getPath()); assertTrue(item3.isSame(child3)); } }
public Node createRuntimeRolesFolderNode( final Session session, final PentahoJcrConstants pentahoJcrConstants, final ITenant tenant ) throws RepositoryException { Node roleBasedFolderNode = createRoleBasedFolderNode( session, pentahoJcrConstants, tenant ); Node node = roleBasedFolderNode.addNode( FOLDER_NAME_RUNTIMEROLES, pentahoJcrConstants.getPHO_NT_INTERNALFOLDER() ); roleBasedFolderNode.save(); session.save(); return node; }
public void testAddMixin() throws RepositoryException, NotExecutableException { checkReadOnly(childNode.getPath()); try { childNode.addMixin(mixinName); childNode.save(); fail("TestSession does not have sufficient privileges to add a mixin type."); } catch (AccessDeniedException e) { // success } modifyPrivileges(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, true); childNode.addMixin(mixinName); childNode.save(); }
protected void initNodesW2() throws RepositoryException { // testroot if (superuserW2.getRootNode().hasNode(testPath)) { testRootNodeW2 = superuserW2.getRootNode().getNode(testPath); // clean test root for (NodeIterator it = testRootNodeW2.getNodes(); it.hasNext(); ) { it.nextNode().remove(); } testRootNodeW2.save(); } else { testRootNodeW2 = superuserW2.getRootNode().addNode(testPath, testNodeType); superuserW2.save(); } // some test nodes superuserW2.getWorkspace().copy(workspace.getName(), node1.getPath(), node1.getPath()); node1W2 = testRootNodeW2.getNode(node1.getName()); superuserW2.getWorkspace().copy(workspace.getName(), node2.getPath(), node2.getPath()); node2W2 = testRootNodeW2.getNode(node2.getName()); } }
/** * Checks if {@link Node#isNew()} works correctly for new and existing, * unmodified nodes. */ public void testIsNew() throws RepositoryException { // get default workspace test root node using superuser session Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath()); // create a node Node testNode = defaultRootNode.addNode(nodeName1, testNodeType); assertTrue("Newly created node should return true on newNode.isNew()", testNode.isNew()); defaultRootNode.save(); assertFalse("Unmodified, exisiting node should return false on newNode.isNew()", testNode.isNew()); }
protected void setUp() throws Exception { super.setUp(); for (int i = 0; i < INITIAL_NODE_NUM; i++) { testRootNode.addNode("node" + i).setProperty(propertyName1, i); } testRootNode.save(); }