Search in sources :

Example 11 with Property

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

Example 12 with Property

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

Example 13 with Property

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]);
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Value(javax.jcr.Value) Property(javax.jcr.Property)

Example 14 with Property

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

Example 15 with Property

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

Aggregations

Property (javax.jcr.Property)445 Node (javax.jcr.Node)252 Value (javax.jcr.Value)99 Test (org.junit.Test)87 Session (javax.jcr.Session)78 PropertyIterator (javax.jcr.PropertyIterator)68 RepositoryException (javax.jcr.RepositoryException)64 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)47 JackrabbitNode (org.apache.jackrabbit.api.JackrabbitNode)37 ValueFormatException (javax.jcr.ValueFormatException)34 QValue (org.apache.jackrabbit.spi.QValue)29 ArrayList (java.util.ArrayList)24 NodeIterator (javax.jcr.NodeIterator)24 QValueValue (org.apache.jackrabbit.spi.commons.value.QValueValue)23 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)20 Item (javax.jcr.Item)19 PathNotFoundException (javax.jcr.PathNotFoundException)17 InvalidItemStateException (javax.jcr.InvalidItemStateException)16 Version (javax.jcr.version.Version)16 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)15