Search in sources :

Example 96 with ValueFormatException

use of javax.jcr.ValueFormatException in project jackrabbit by apache.

the class SetValueValueFormatExceptionTest method testNodeNotReferenceable.

/**
 * Tests if setValue(Node) throws a ValueFormatException immediately (not
 * on save) if the specified node is not referencable.
 */
public void testNodeNotReferenceable() throws NotExecutableException, RepositoryException {
    if (testRootNode.isNodeType(mixReferenceable)) {
        throw new NotExecutableException("test requires testRootNode to be non-referenceable");
    }
    Property referenceProperty = createProperty(PropertyType.REFERENCE, false);
    try {
        referenceProperty.setValue(testRootNode);
        fail("Property.setValue(Node) must throw a ValueFormatException " + "immediately if the specified node is not referenceable.");
    } catch (ValueFormatException e) {
    // success
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 97 with ValueFormatException

use of javax.jcr.ValueFormatException in project jackrabbit by apache.

the class SetValueValueFormatExceptionTest method testValueArray.

/**
 * Tests if setValue(Value[]) throws a ValueFormatException immediately (not
 * on save) if a conversion fails.
 */
public void testValueArray() throws NotExecutableException, RepositoryException {
    Property booleanProperty = createProperty(PropertyType.BOOLEAN, true);
    try {
        Value[] dateValues = new Value[] { NodeTypeUtil.getValueOfType(superuser, PropertyType.DOUBLE) };
        booleanProperty.setValue(dateValues);
        fail("Property.setValue(Value[]) must throw a ValueFormatException " + "immediately if a conversion fails.");
    } catch (ValueFormatException e) {
    // success
    }
}
Also used : Value(javax.jcr.Value) ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 98 with ValueFormatException

use of javax.jcr.ValueFormatException in project jackrabbit by apache.

the class SetValueValueFormatExceptionTest method testBoolean.

/**
 * Tests if setValue(boolean) throws a ValueFormatException immediately (not
 * on save) if a conversion fails.
 */
public void testBoolean() throws NotExecutableException, RepositoryException {
    Property dateProperty = createProperty(PropertyType.DATE, false);
    try {
        dateProperty.setValue(true);
        fail("Property.setValue(boolean) must throw a ValueFormatException " + "immediately if a conversion fails.");
    } catch (ValueFormatException e) {
    // success
    }
}
Also used : ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 99 with ValueFormatException

use of javax.jcr.ValueFormatException in project jackrabbit by apache.

the class SetValueValueFormatExceptionTest method testInputStream.

/**
 * Tests if setValue(InputStream) throws a ValueFormatException immediately (not
 * on save) if a conversion fails.
 */
public void testInputStream() throws NotExecutableException, RepositoryException {
    Property dateProperty = createProperty(PropertyType.DATE, false);
    try {
        byte[] bytes = { 123 };
        InputStream value = new ByteArrayInputStream(bytes);
        dateProperty.setValue(value);
        fail("Property.setValue(InputStream) must throw a ValueFormatException " + "immediately if a conversion fails.");
    } catch (ValueFormatException e) {
    // success
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 100 with ValueFormatException

use of javax.jcr.ValueFormatException in project jackrabbit by apache.

the class SetValueValueFormatExceptionTest method testValue.

/**
 * Tests if setValue(Value) throws a ValueFormatException immediately (not
 * on save) if a conversion fails.
 */
public void testValue() throws NotExecutableException, RepositoryException {
    Property booleanProperty = createProperty(PropertyType.BOOLEAN, false);
    try {
        Value dateValue = NodeTypeUtil.getValueOfType(superuser, PropertyType.DATE);
        booleanProperty.setValue(dateValue);
        fail("Property.setValue(Value) must throw a ValueFormatException " + "immediately if a conversion fails.");
    } catch (ValueFormatException e) {
    // success
    }
}
Also used : Value(javax.jcr.Value) ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Aggregations

ValueFormatException (javax.jcr.ValueFormatException)106 Value (javax.jcr.Value)53 Property (javax.jcr.Property)34 RepositoryException (javax.jcr.RepositoryException)16 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)12 Calendar (java.util.Calendar)10 ItemNotFoundException (javax.jcr.ItemNotFoundException)10 Node (javax.jcr.Node)10 QValue (org.apache.jackrabbit.spi.QValue)10 PathNotFoundException (javax.jcr.PathNotFoundException)6 Name (org.apache.jackrabbit.spi.Name)6 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)5 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)5 InternalValue (org.apache.jackrabbit.core.value.InternalValue)5 InputStream (java.io.InputStream)4 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 Path (org.apache.jackrabbit.spi.Path)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3