use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class SimpleValueFactoryTest method testDecimal.
public void testDecimal() throws RepositoryException {
BigDecimal a = new BigDecimal(1234567890);
Value value = factory.createValue(a);
assertEquals(PropertyType.DECIMAL, value.getType());
assertEquals(value, factory.createValue(a));
try {
value.getBoolean();
fail();
} catch (ValueFormatException e) {
}
assertEquals(a.longValue(), value.getDate().getTimeInMillis());
assertEquals(a, value.getDecimal());
assertEquals(a.doubleValue(), value.getDouble());
assertEquals(a.longValue(), value.getLong());
assertEquals(a.toString(), value.getString());
// TODO: binary representation
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class SimpleValueFactoryTest method testLong.
public void testLong() throws RepositoryException {
long a = 1234567890;
Value value = factory.createValue(a);
assertEquals(PropertyType.LONG, value.getType());
assertEquals(value, factory.createValue(a));
try {
value.getBoolean();
fail();
} catch (ValueFormatException e) {
}
assertEquals(a, value.getDate().getTimeInMillis());
assertEquals(new BigDecimal(a), value.getDecimal());
assertEquals((double) a, value.getDouble());
assertEquals(a, value.getLong());
assertEquals(Long.toString(a), value.getString());
// TODO: binary representation
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class SimpleValueFactoryTest method testBoolean.
public void testBoolean() throws RepositoryException {
Value value = factory.createValue(true);
assertEquals(PropertyType.BOOLEAN, value.getType());
assertEquals(value, factory.createValue(true));
assertTrue(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(Boolean.TRUE.toString(), value.getString());
// TODO: binary representation
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class DoublePropertyTest method testGetBoolean.
/**
* tests failure of conversion from Double type to Boolean type
*/
public void testGetBoolean() throws RepositoryException {
try {
Value val = PropertyUtil.getValue(prop);
val.getBoolean();
fail("Conversion from a Double value to a Boolean value " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class NamePropertyTest method testGetLong.
/**
* Tests failure of conversion from Name type to Long type.
*
* @throws RepositoryException
*/
public void testGetLong() throws RepositoryException {
try {
Value val = PropertyUtil.getValue(prop);
val.getLong();
fail("Conversion from a Name value to a Long value " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
Aggregations