Search in sources :

Example 86 with Item

use of javax.jcr.Item in project jackrabbit by apache.

the class GetPropertyTest method testGetExternallyChangedProperty.

public void testGetExternallyChangedProperty() throws RepositoryException {
    // Access node1 through session 1
    Node node1 = (Node) readOnly.getItem(node1Path);
    // Add node and property through session 2
    Node n2 = testRootNode.getNode(nodeName1).addNode(nodeName2);
    Property p3 = n2.setProperty(propertyName1, "test");
    p3.setValue("v3");
    testRootNode.save();
    // Assert added nodes are visible in session 1 after refresh
    node1.refresh(false);
    assertTrue(readOnly.itemExists(n2.getPath()));
    assertTrue(readOnly.itemExists(p3.getPath()));
    Item q3 = readOnly.getItem(p3.getPath());
    assertFalse(q3.isNode());
    assertTrue("v3".equals(((Property) q3).getString()));
    // Change property value through session 2
    p3.setValue("v3_modified");
    testRootNode.save();
    // Assert modification is visible through session 1
    node1.refresh(false);
    assertTrue("v3_modified".equals(((Property) q3).getString()));
}
Also used : Item(javax.jcr.Item) Node(javax.jcr.Node) Property(javax.jcr.Property)

Example 87 with Item

use of javax.jcr.Item in project jackrabbit by apache.

the class MoveNewTreeTest method testRefreshMovedTree.

public void testRefreshMovedTree() throws RepositoryException {
    testRootNode.refresh(true);
    String msg = "Refresh must not revert a moved tree.";
    assertFalse(msg, superuser.itemExists(srcPath + "/" + nodeName2 + "/" + nodeName3));
    int degree = destParentNode.getDepth();
    List<Item> l = new ArrayList<Item>();
    l.add(childNode);
    l.add(childProperty);
    l.add(grandChildNode);
    for (Iterator<Item> it = l.iterator(); it.hasNext(); ) {
        Item item = it.next();
        assertTrue(msg, item.isNew());
        assertTrue(msg, childNode.getAncestor(degree).isSame(destParentNode));
    }
}
Also used : Item(javax.jcr.Item) ArrayList(java.util.ArrayList)

Example 88 with Item

use of javax.jcr.Item in project jackrabbit by apache.

the class MoveNewTreeTest method testTreeEntries.

public void testTreeEntries() throws RepositoryException {
    Item item = superuser.getItem(destinationPath + "/" + nodeName2);
    assertTrue("Moving a node must move all child items as well.", childNode.isSame(item));
    item = superuser.getItem(destinationPath + "/" + propertyName2);
    assertTrue("Moving a node must move all child items as well.", childProperty.isSame(item));
    item = superuser.getItem(destinationPath + "/" + nodeName2 + "/" + nodeName3);
    assertTrue("Moving a node must move all child items as well.", grandChildNode.isSame(item));
}
Also used : Item(javax.jcr.Item)

Example 89 with Item

use of javax.jcr.Item in project jackrabbit by apache.

the class MoveTreeTest method testTreeAncestors.

public void testTreeAncestors() throws RepositoryException {
    int degree = destParentNode.getDepth();
    Item ancestor = childNode.getAncestor(degree);
    assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
    ancestor = childProperty.getAncestor(degree);
    assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
    ancestor = grandChildNode.getAncestor(degree);
    assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
}
Also used : Item(javax.jcr.Item)

Example 90 with Item

use of javax.jcr.Item in project jackrabbit by apache.

the class MoveTreeTest method testAncestorAfterRevert.

public void testAncestorAfterRevert() throws RepositoryException {
    superuser.refresh(false);
    Item ancestor = grandChildNode.getAncestor(srcParentNode.getDepth());
    assertTrue("Reverting a move-operation must move the tree back.", ancestor.isSame(srcParentNode));
}
Also used : Item(javax.jcr.Item)

Aggregations

Item (javax.jcr.Item)117 Node (javax.jcr.Node)48 RepositoryException (javax.jcr.RepositoryException)28 Property (javax.jcr.Property)19 Session (javax.jcr.Session)15 PathNotFoundException (javax.jcr.PathNotFoundException)11 ArrayList (java.util.ArrayList)7 ItemNotFoundException (javax.jcr.ItemNotFoundException)6 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)6 IOException (java.io.IOException)5 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)5 HashSet (java.util.HashSet)4 NodeIterator (javax.jcr.NodeIterator)4 Principal (java.security.Principal)3 NoSuchElementException (java.util.NoSuchElementException)3 AccessDeniedException (javax.jcr.AccessDeniedException)3 PropertyIterator (javax.jcr.PropertyIterator)3 Version (javax.jcr.version.Version)3 ResourceNotFoundException (org.apache.sling.api.resource.ResourceNotFoundException)3 OutputStreamWriter (java.io.OutputStreamWriter)2