use of javax.jcr.Value in project jackrabbit by apache.
the class ReferencePropertyTest method testGetString.
/**
* Tests conversion from Reference type to String type.
*/
public void testGetString() throws RepositoryException {
Value val = PropertyUtil.getValue(prop);
// format of reference value is implementation specifc. but at least
// must not throw
val.getString();
}
use of javax.jcr.Value in project jackrabbit by apache.
the class RepositoryDescriptorTest method testGetDescriptorValues.
/**
* Tests whether {@link Repository#getDescriptorValues(String)} returns an
* Value[] of size 1 for single valued descriptors.
*/
public void testGetDescriptorValues() {
Repository rep = session.getRepository();
// "option.node.type.management.supported" denotes a single-valued BOOLEAN descriptor
String descName = Repository.OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED;
assertTrue(rep.isSingleValueDescriptor(descName));
Value[] vals = rep.getDescriptorValues(descName);
assertNotNull("Required descriptor is missing: " + descName, vals);
assertEquals(1, vals.length);
assertEquals(PropertyType.BOOLEAN, vals[0].getType());
try {
// getDescriptorValue(key).getString() is equivalent to getDescriptor(key)
assertEquals(vals[0].getString(), rep.getDescriptor(descName));
} catch (RepositoryException e) {
fail(e.getMessage());
}
// "option.node.type.management.supported" denotes a single-valued BOOLEAN descriptor
descName = Repository.QUERY_LANGUAGES;
assertFalse(rep.isSingleValueDescriptor(descName));
Value val = rep.getDescriptorValue(descName);
assertNull(descName + " is a multi-value descriptor, getDescriptorValue() should return null", val);
}
use of javax.jcr.Value 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.Value 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());
}
use of javax.jcr.Value in project jackrabbit by apache.
the class ReferencePropertyTest method testGetDate.
/**
* Tests failure of conversion from Reference type to Date type.
*/
public void testGetDate() throws RepositoryException {
try {
Value val = PropertyUtil.getValue(prop);
val.getDate();
fail("Conversion from a Reference value to a Date value " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
//ok
}
}
Aggregations