Search in sources :

Example 51 with ValueFormatException

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

the class MultiValuedPropertyTest method testGetStreamFromMultivalued.

/**
 * Tests if Property.getStream() fails with ValueFormatException for
 * multivalued properties.
 *
 * @throws RepositoryException
 * @throws NotExecutableException
 */
public void testGetStreamFromMultivalued() throws RepositoryException, NotExecutableException {
    Property prop = PropertyUtil.searchMultivalProp(testRootNode);
    if (prop == null) {
        throw new NotExecutableException("No multivalued property found.");
    } else {
        try {
            prop.getStream();
            fail("Property.getStream() must fail with ValueFormatException for any multivalued property.");
        } catch (ValueFormatException vfe) {
        // ok
        }
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 52 with ValueFormatException

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

the class MultiValuedPropertyTest method testGetDateFromMultivalued.

/**
 * Tests if Property.getDate() fails multivalued properties.
 *
 * @throws RepositoryException
 * @throws NotExecutableException
 */
public void testGetDateFromMultivalued() throws RepositoryException, NotExecutableException {
    Property prop = PropertyUtil.searchMultivalProp(testRootNode);
    if (prop == null) {
        throw new NotExecutableException("No multivalued property found.");
    } else {
        try {
            prop.getDate();
            fail("Property.getDate() must fail with ValueFormatException for any multivalued property.");
        } catch (ValueFormatException vfe) {
        // ok
        }
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 53 with ValueFormatException

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

the class MultiValuedPropertyTest method testGetLongFromMultivalued.

/**
 * Tests if Property.getLong() fails for multivalued properties.
 *
 * @throws RepositoryException
 * @throws NotExecutableException
 */
public void testGetLongFromMultivalued() throws RepositoryException, NotExecutableException {
    Property prop = PropertyUtil.searchMultivalProp(testRootNode);
    if (prop == null) {
        throw new NotExecutableException("No multivalued property found.");
    } else {
        try {
            prop.getLong();
            fail("Property.getLong() must fail with ValueFormatException for any multivalued property.");
        } catch (ValueFormatException vfe) {
        // ok
        }
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 54 with ValueFormatException

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

the class PropertyTest method testLongRequiredTypeBoolean.

public void testLongRequiredTypeBoolean() throws Exception {
    try {
        Property p = node.setProperty(BOOLEAN_PROP_NAME, 12345);
        fail("Conversion from LONG to BOOLEAN must throw ValueFormatException");
    } catch (ValueFormatException e) {
    // success
    }
}
Also used : ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 55 with ValueFormatException

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

the class PropertyTest method testRequiredTypeBooleanChangeDouble.

public void testRequiredTypeBooleanChangeDouble() throws Exception {
    Property p = node.setProperty(BOOLEAN_PROP_NAME, true);
    assertEquals(PropertyType.BOOLEAN, p.getType());
    assertEquals(PropertyType.BOOLEAN, p.getValue().getType());
    assertTrue(p.getBoolean());
    PropertyDefinition def = p.getDefinition();
    assertEquals(PropertyType.BOOLEAN, def.getRequiredType());
    assertEquals(NT_NAME, def.getDeclaringNodeType().getName());
    superuser.save();
    try {
        p.setValue(24.4);
        fail("Conversion from DOUBLE to BOOLEAN must throw ValueFormatException");
    } catch (ValueFormatException e) {
    // success
    }
    try {
        node.setProperty(BOOLEAN_PROP_NAME, 24.4);
        fail("Conversion from DOUBLE to BOOLEAN must throw ValueFormatException");
    } catch (ValueFormatException e) {
    // success
    }
}
Also used : ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition)

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