Search in sources :

Example 61 with ValueFormatException

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

the class SimpleValueFactoryTest method testString.

public void testString() throws RepositoryException {
    String a = "test";
    Value value = factory.createValue(a);
    assertEquals(PropertyType.STRING, value.getType());
    assertEquals(value, factory.createValue(a));
    assertFalse(value.getBoolean());
    try {
        value.getDate();
        fail();
    } catch (ValueFormatException e) {
    }
    try {
        value.getDecimal();
        fail();
    } catch (ValueFormatException e) {
    }
    try {
        value.getDouble();
        fail();
    } catch (ValueFormatException e) {
    }
    try {
        value.getLong();
        fail();
    } catch (ValueFormatException e) {
    }
    assertEquals(a, value.getString());
// TODO: binary representation
}
Also used : Value(javax.jcr.Value) ValueFormatException(javax.jcr.ValueFormatException)

Example 62 with ValueFormatException

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

the class BooleanPropertyTest method testGetLong.

/**
 * Tests failure of conversion from Boolean type to Long type.
 */
public void testGetLong() throws RepositoryException {
    try {
        Value val = PropertyUtil.getValue(prop);
        val.getLong();
        fail("Conversion from a Boolean value to a Long value " + "should throw a ValueFormatException");
    } catch (ValueFormatException vfe) {
    // ok
    }
}
Also used : Value(javax.jcr.Value) ValueFormatException(javax.jcr.ValueFormatException)

Example 63 with ValueFormatException

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

the class BooleanPropertyTest method testGetDouble.

/**
 * Tests failure from Boolean type to Double type.
 */
public void testGetDouble() throws RepositoryException {
    try {
        Value val = PropertyUtil.getValue(prop);
        val.getDouble();
        fail("Conversion from a Boolean value to a Double value " + "should throw a ValueFormatException");
    } catch (ValueFormatException vfe) {
    // ok
    }
}
Also used : Value(javax.jcr.Value) ValueFormatException(javax.jcr.ValueFormatException)

Example 64 with ValueFormatException

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

the class BooleanPropertyTest method testGetDate.

/**
 * Tests failure of conversion from Boolean type to Date type.
 */
public void testGetDate() throws RepositoryException {
    try {
        Value val = PropertyUtil.getValue(prop);
        val.getDate();
        fail("Conversion from a Boolean value to a Date value " + "should throw a ValueFormatException");
    } catch (ValueFormatException vfe) {
    // ok
    }
}
Also used : Value(javax.jcr.Value) ValueFormatException(javax.jcr.ValueFormatException)

Example 65 with ValueFormatException

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

the class BinaryPropertyTest method testMultiValue.

/**
 * Tests the failure of calling Property.getStream() on a multivalue
 * property.
 */
public void testMultiValue() throws RepositoryException, IOException {
    if (multiple) {
        InputStream in = null;
        try {
            in = prop.getStream();
            fail("Calling getStream() on a multivalue property " + "should throw a ValueFormatException.");
        } catch (ValueFormatException vfe) {
        // ok
        } finally {
            if (in != null) {
                in.close();
            }
        }
    }
}
Also used : InputStream(java.io.InputStream) ValueFormatException(javax.jcr.ValueFormatException)

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