Search in sources :

Example 11 with Value

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();
}
Also used : Value(javax.jcr.Value)

Example 12 with Value

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);
}
Also used : Repository(javax.jcr.Repository) Value(javax.jcr.Value) RepositoryException(javax.jcr.RepositoryException)

Example 13 with Value

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()));
}
Also used : Value(javax.jcr.Value) ValueFactory(javax.jcr.ValueFactory) Property(javax.jcr.Property)

Example 14 with Value

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());
}
Also used : Value(javax.jcr.Value) ValueFactory(javax.jcr.ValueFactory) Property(javax.jcr.Property)

Example 15 with Value

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
    }
}
Also used : Value(javax.jcr.Value) ValueFormatException(javax.jcr.ValueFormatException)

Aggregations

Value (javax.jcr.Value)600 Node (javax.jcr.Node)158 Test (org.junit.Test)118 Property (javax.jcr.Property)99 RepositoryException (javax.jcr.RepositoryException)82 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)82 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)70 Session (javax.jcr.Session)63 NodeType (javax.jcr.nodetype.NodeType)57 ValueFormatException (javax.jcr.ValueFormatException)53 ValueFactory (javax.jcr.ValueFactory)51 QValue (org.apache.jackrabbit.spi.QValue)51 HashMap (java.util.HashMap)46 ArrayList (java.util.ArrayList)31 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)30 Privilege (javax.jcr.security.Privilege)30 InputStream (java.io.InputStream)29 JackrabbitNode (org.apache.jackrabbit.api.JackrabbitNode)29 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)29 QValueValue (org.apache.jackrabbit.spi.commons.value.QValueValue)27