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()));
}
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));
}
}
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));
}
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));
}
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));
}
Aggregations