use of javax.jcr.Property in project jackrabbit by apache.
the class SetValueValueFormatExceptionTest method testString.
/**
* Tests if setValue(String) throws a ValueFormatException immediately (not
* on save) if a conversion fails.
*/
public void testString() throws NotExecutableException, RepositoryException {
Property dateProperty = createProperty(PropertyType.DATE, false);
try {
dateProperty.setValue("abc");
fail("Property.setValue(String) must throw a ValueFormatException " + "immediately if a conversion fails.");
} catch (ValueFormatException e) {
// success
}
}
use of javax.jcr.Property in project jackrabbit by apache.
the class RSessionAccessControlTest method setUp.
protected void setUp() throws Exception {
super.setUp();
Node n = testRootNode.addNode(nodeName1, testNodeType);
testNodePath = n.getPath();
Value v = getJcrValue(superuser, RepositoryStub.PROP_PROP_VALUE1, RepositoryStub.PROP_PROP_TYPE1, "test");
Property p = n.setProperty(propertyName1, v);
testPropertyPath = p.getPath();
testRootNode.getSession().save();
readOnlySession = getHelper().getReadOnlySession();
}
use of javax.jcr.Property in project jackrabbit by apache.
the class RetentionPolicyEffectTest method assertEffect.
private void assertEffect(Node targetNode, String childName, String propName, String childName2, String propName2) throws RepositoryException {
Session s = targetNode.getSession();
try {
Node child = targetNode.getNode(childName);
child.remove();
s.save();
fail("Retention policy present must prevent a child node from being removed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
Property p = targetNode.getProperty(propName);
p.remove();
s.save();
fail("Retention policy present must prevent a child property from being removed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
Property p = targetNode.getProperty(propName);
p.setValue("test2");
s.save();
fail("Retention policy present must prevent the child property from being modified.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
targetNode.addNode(childName2);
s.save();
fail("Retention policy present must prevent the target node from having new nodes added.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
Value v = getJcrValue(s, RepositoryStub.PROP_PROP_VALUE2, RepositoryStub.PROP_PROP_TYPE2, "test");
targetNode.setProperty(propName2, v);
s.save();
fail("Retention policy present must prevent the target node from having new properties set.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
targetNode.remove();
s.save();
fail("Hold present must prevent the target node from being removed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
}
use of javax.jcr.Property in project jackrabbit by apache.
the class ExternalModificationTest method testExternalRemoval2.
public void testExternalRemoval2() 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 remove the property -> test effect of external removal.
p2.remove();
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.STALE_DESTROYED);
assertItemStatus(p2, Status.REMOVED);
}
use of javax.jcr.Property in project jackrabbit by apache.
the class GetPropertyTest method testGetPropertyOfRemovedAncestor.
public void testGetPropertyOfRemovedAncestor() throws RepositoryException {
Session rw = getHelper().getReadWriteSession();
try {
// add modification to a property.
Property p = (Property) rw.getItem(prop1Path);
p.setValue("changedValue");
// transiently remove the test root node
rw.getItem(testRootNode.getPath()).remove();
try {
p.getValue();
fail("modified property must be marked removed upon parent removal");
} catch (InvalidItemStateException e) {
// success
}
try {
rw.getItem(prop1Path);
fail("modified property must be marked removed upon parent removal");
} catch (PathNotFoundException e) {
// success
}
try {
Property p2 = (Property) rw.getItem(prop2Path);
fail("existing property must be marked removed upon parent removal");
} catch (PathNotFoundException e) {
// success
}
// revert all transient modifications
rw.refresh(false);
Property pAgain = (Property) rw.getItem(prop1Path);
// TODO: for generic jsr 170 test: change assert to p.isSame(pAgain)
assertTrue(p.isSame(pAgain));
assertEquals("string1", p.getString());
} finally {
rw.logout();
}
}
Aggregations