use of javax.jcr.Property in project jackrabbit by apache.
the class ExternalModificationTest method testExternalRemoval3.
public void testExternalRemoval3() throws RepositoryException, NotExecutableException {
Node childN = refNode.addNode(nodeName3);
Property p = childN.setProperty(propertyName1, "anyvalue");
refNode.save();
String uuid = refNode.getUUID();
Node refNode2 = testSession.getNodeByUUID(uuid);
Node c2 = (Node) testSession.getItem(childN.getPath());
Property p2 = (Property) testSession.getItem(p.getPath());
// transiently modify -> test effect of external removal.
p2.setValue("changedValue");
String srcPath = refNode.getPath();
String destPath = destParentNode.getPath() + "/" + nodeName2;
superuser.move(srcPath, destPath);
superuser.save();
try {
refNode2.refresh(true);
Node parent = refNode2.getParent();
} catch (InvalidItemStateException e) {
}
assertItemStatus(refNode2, Status.REMOVED);
assertItemStatus(c2, Status.REMOVED);
assertItemStatus(p2, Status.STALE_DESTROYED);
assertEquals("changedValue", p2.getString());
}
use of javax.jcr.Property in project jackrabbit by apache.
the class ExternalModificationTest method testNewItemsUponStaleDestroyed.
public void testNewItemsUponStaleDestroyed() throws RepositoryException, NotExecutableException {
String uuid = refNode.getUUID();
Node refNode2 = (Node) testSession.getItem(refNode.getPath());
refNode2.addMixin(mixLockable);
Node childN = refNode2.addNode(nodeName3);
String childNPath = childN.getPath();
Property childP = refNode2.setProperty(propertyName2, "someValue");
String childPPath = childP.getPath();
String destPath = destParentNode.getPath() + "/" + nodeName2;
superuser.move(refNode.getPath(), destPath);
superuser.save();
testSession.refresh(true);
testSession.getItem(destPath);
assertItemStatus(refNode2, Status.STALE_DESTROYED);
assertItemStatus(refNode2.getProperty(jcrMixinTypes), Status.STALE_DESTROYED);
assertItemStatus(childN, Status.NEW);
assertItemStatus(childP, Status.NEW);
assertItemStatus(childN.getProperty(jcrPrimaryType), Status.NEW);
assertTrue(testSession.itemExists(childNPath));
assertTrue(childN.isSame(testSession.getItem(childNPath)));
assertTrue(testSession.itemExists(childPPath));
assertTrue(childP.isSame(testSession.getItem(childPPath)));
testSession.refresh(false);
assertItemStatus(childN, Status.REMOVED);
assertItemStatus(childP, Status.REMOVED);
assertFalse(testSession.itemExists(childNPath));
assertFalse(testSession.itemExists(childPPath));
}
use of javax.jcr.Property in project jackrabbit by apache.
the class GetPropertyTest method testGetDeepRefNodeProperties.
public void testGetDeepRefNodeProperties() throws RepositoryException, NotExecutableException {
Node n = testRootNode.getNode(nodeName1);
n.addMixin(mixReferenceable);
Node n2 = n.addNode(nodeName2);
Property p3 = n2.setProperty(propertyName1, "test");
testRootNode.save();
// other session directly accesses p3.
// consequently n1 is not yet resolved
Property prop3 = (Property) readOnly.getItem(p3.getPath());
// now try to access properties below n1 -> should be existing although
// n1 has not yet been resolved.
assertTrue(readOnly.itemExists(prop2Path));
Property p1 = (Property) readOnly.getItem(prop2Path);
Node node1 = readOnly.getNodeByUUID(n.getUUID());
assertTrue(p1.isSame(node1.getProperty(Text.getName(prop2Path))));
}
use of javax.jcr.Property in project jackrabbit by apache.
the class IsSameTest method testIsSameProperty2.
public void testIsSameProperty2() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
Property p = n.setProperty(propertyName1, "anyvalue");
testRootNode.save();
// add transient modification to the property:
p.setValue("someOtherValue");
// access same property through different session
Session otherSession = getHelper().getReadOnlySession();
try {
Property otherProperty = (Property) otherSession.getItem(p.getPath());
assertTrue(p.isSame(otherProperty));
} finally {
otherSession.logout();
}
}
use of javax.jcr.Property in project jackrabbit by apache.
the class AddPropertyTest method testAddingProperty.
public void testAddingProperty() throws RepositoryException, NotExecutableException {
Property p1 = testNode.setProperty(propertyName2, "value1");
p1.remove();
Property p2 = testNode.setProperty(propertyName2, "value2");
p2.remove();
Property p3 = testNode.setProperty(propertyName2, "value3");
testNode.save();
assertTrue(testNode.hasProperty(propertyName2));
assertItemStatus(p1, Status.REMOVED);
assertItemStatus(p2, Status.REMOVED);
assertItemStatus(p3, Status.EXISTING);
}
Aggregations