use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyItemIsNewTest method testPersistentPropertyItemIsNew.
/**
* Test if Item.isNew() returns false after a new PropertyItem is set and
* the node is saved (persistent).
* This is equivalent to the test if Item.isNew() returns false for an
* already exixting and not modified PropertyItem.
*
* @see javax.jcr.Item#isNew()
*/
public void testPersistentPropertyItemIsNew() throws RepositoryException {
Property testProperty = testNode.setProperty(propertyName1, "test");
testNode.save();
Item testPropertyItem = superuser.getItem(testProperty.getPath());
// check testPropertyItem.isNew() after save
assertFalse("Item.isNew() must return false after a new PropertyItem is set and the current Node is saved", testPropertyItem.isNew());
}
use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyItemIsNewTest method testTransientPropertyItemIsNew.
/**
* Test if Item.isNew() returns true direct after a new PropertyItem is set
* (before node is saved (transient)).
*
* @see javax.jcr.Item#isNew()
*/
public void testTransientPropertyItemIsNew() throws RepositoryException {
Property testProperty = testNode.setProperty(propertyName1, "test");
Item testPropertyItem = superuser.getItem(testProperty.getPath());
// check testPropertyItem.isNew() before save
assertTrue("Item.isNew() must return true directly after a new Property is set (before current node is saved)", testPropertyItem.isNew());
}
use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyReadMethodsTest method testGetValueCopyStoredValues.
/**
* Tests if <code>Property.getValues()</code> returns an array that is a copy
* of the stored values, so changes to it are not reflected in internal storage.
*/
public void testGetValueCopyStoredValues() throws NotExecutableException, RepositoryException {
Property prop = PropertyUtil.searchMultivalProp(testRootNode);
if (prop == null) {
throw new NotExecutableException("No multivalued property found.");
}
// acquire the values of the property and change the zeroth value
Value[] values = prop.getValues();
if (values.length == 0) {
throw new NotExecutableException("No testable property found.");
}
values[0] = null;
// re-acquire the values and check if nulled value still exists
Value[] values2 = prop.getValues();
assertNotNull("Changes on the array returned by Property.getValues() must " + "not be reflected in the internal storage.", values2[0]);
}
use of javax.jcr.Property in project jackrabbit by apache.
the class PathTest method testResolvedIdentifierBasedPropertyValue.
public void testResolvedIdentifierBasedPropertyValue() throws RepositoryException {
ValueFactory vf = superuser.getValueFactory();
Value pathValue = vf.createValue("[" + identifier + "]", PropertyType.PATH);
Property p = testRootNode.setProperty(propertyName1, pathValue);
assertTrue("Identifier-based PATH value must resolve to the Node the identifier has been obtained from.", testRootNode.isSame(p.getNode()));
}
use of javax.jcr.Property in project jackrabbit by apache.
the class PathTest method testNotNormalizedPathValue.
public void testNotNormalizedPathValue() throws RepositoryException {
ValueFactory vf = superuser.getValueFactory();
Value pathValue = vf.createValue("/a/../b/./c/dd/..", PropertyType.PATH);
Property p = testRootNode.setProperty(propertyName1, pathValue);
assertEquals(PropertyType.PATH, p.getType());
assertEquals(pathValue.getString(), p.getValue().getString());
assertEquals(pathValue, p.getValue());
}
Aggregations