Search in sources :

Example 51 with QPropertyDefinition

use of org.apache.jackrabbit.spi.QPropertyDefinition in project jackrabbit by apache.

the class TestAll method testPathProperty.

/** Test for the <code>path</code> property definition type. */
public void testPathProperty() {
    QPropertyDefinition def = getPropDef("propertyNodeType", "pathProperty");
    assertEquals("pathProperty requiredType", PropertyType.PATH, def.getRequiredType());
    assertEquals("pathProperty valueConstraints", 1, def.getValueConstraints().length);
    assertEquals("pathProperty valueConstraints[0]", "{}\t{http://www.apache.org/jackrabbit/test}testPath", (def.getValueConstraints())[0].getString());
    assertNull("pathProperty defaultValues", def.getDefaultValues());
}
Also used : QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition)

Example 52 with QPropertyDefinition

use of org.apache.jackrabbit.spi.QPropertyDefinition in project jackrabbit by apache.

the class TestAll method getPropDef.

/**
     * Returns the named property definition from the named node type
     * definition. If either of the definitions do not exist, an assertion
     * failure is generated.
     * <p>
     * If the given property name is <code>null</code>, then the residual
     * property definition (if one exists) is returned.
     *
     * @param typeName node type name
     * @param propertyName property name, or <code>null</code>
     * @return property definition
     */
private QPropertyDefinition getPropDef(String typeName, String propertyName) {
    Name name;
    if (propertyName != null) {
        name = FACTORY.create(TEST_NAMESPACE, propertyName);
    } else {
        name = NameConstants.ANY_NAME;
    }
    QNodeTypeDefinition def = getNodeType(typeName);
    QPropertyDefinition[] defs = def.getPropertyDefs();
    for (int i = 0; i < defs.length; i++) {
        if (name.equals(defs[i].getName())) {
            return defs[i];
        }
    }
    throw new AssertionFailedError("Property " + propertyName + " does not exist");
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition) AssertionFailedError(junit.framework.AssertionFailedError) Name(org.apache.jackrabbit.spi.Name)

Example 53 with QPropertyDefinition

use of org.apache.jackrabbit.spi.QPropertyDefinition in project jackrabbit by apache.

the class TestAll method testLongProperty.

/** Test for the <code>long</code> property definition type. */
public void testLongProperty() {
    QPropertyDefinition def = getPropDef("propertyNodeType", "longProperty");
    assertEquals("longProperty requiredType", PropertyType.LONG, def.getRequiredType());
    assertEquals("longProperty valueConstraints", 3, def.getValueConstraints().length);
    assertEquals("longProperty valueConstraints[0]", "(-10,0]", (def.getValueConstraints())[0].getString());
    assertEquals("longProperty valueConstraints[1]", "[1,2]", (def.getValueConstraints())[1].getString());
    assertEquals("longProperty valueConstraints[2]", "[10,100)", (def.getValueConstraints())[2].getString());
    assertEquals("longProperty defaultValues", 1, def.getDefaultValues().length);
    assertEquals("longProperty defaultValues[0]", "25", getDefaultValue(def, 0));
}
Also used : QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition)

Example 54 with QPropertyDefinition

use of org.apache.jackrabbit.spi.QPropertyDefinition in project jackrabbit by apache.

the class TestAll method testReferenceProperty.

/** Test for the <code>reference</code> property definition type. */
public void testReferenceProperty() {
    QPropertyDefinition def = getPropDef("propertyNodeType", "referenceProperty");
    assertEquals("referenceProperty requiredType", PropertyType.REFERENCE, def.getRequiredType());
    assertEquals("referenceProperty valueConstraints", 1, def.getValueConstraints().length);
    assertEquals("referenceProperty valueConstraints[0]", "{http://www.jcp.org/jcr/nt/1.0}base", (def.getValueConstraints())[0].getString());
    assertNull("referenceProperty defaultValues", def.getDefaultValues());
}
Also used : QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition)

Example 55 with QPropertyDefinition

use of org.apache.jackrabbit.spi.QPropertyDefinition in project jackrabbit by apache.

the class TestAll method testAbortItem.

/** Test for the <code>abort</code> parent version action. */
public void testAbortItem() {
    QPropertyDefinition def = getPropDef("itemNodeType", "abortItem");
    assertEquals("abortItem onParentVersion", OnParentVersionAction.ABORT, def.getOnParentVersion());
}
Also used : QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition)

Aggregations

QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)81 Name (org.apache.jackrabbit.spi.Name)32 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)22 QNodeDefinition (org.apache.jackrabbit.spi.QNodeDefinition)19 RepositoryException (javax.jcr.RepositoryException)14 QValue (org.apache.jackrabbit.spi.QValue)12 QItemDefinition (org.apache.jackrabbit.spi.QItemDefinition)9 QValueConstraint (org.apache.jackrabbit.spi.QValueConstraint)9 ArrayList (java.util.ArrayList)8 Value (javax.jcr.Value)7 InternalValue (org.apache.jackrabbit.core.value.InternalValue)7 ItemExistsException (javax.jcr.ItemExistsException)6 NodeId (org.apache.jackrabbit.core.id.NodeId)6 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)5 EffectiveNodeType (org.apache.jackrabbit.core.nodetype.EffectiveNodeType)5 PropertyState (org.apache.jackrabbit.core.state.PropertyState)5 QNodeTypeDefinition (org.apache.jackrabbit.spi.QNodeTypeDefinition)5 ValueConstraint (org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint)5 NodeState (org.apache.jackrabbit.core.state.NodeState)4 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)4