use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class NamePropertyTest method testGetNode.
/**
* Since JCR 2.0 a path property can be dereferenced if it points to a
* Node.
* TODO: create several tests out of this one
*/
public void testGetNode() throws RepositoryException {
if (!multiple) {
String path = prop.getString();
if (prop.getParent().hasNode(path)) {
Node n = prop.getNode();
assertEquals("The name of the dereferenced property must be equal to the value", path, n.getName());
} else {
try {
prop.getNode();
fail("Calling Property.getNode() for a NAME value that doesn't have a corresponding Node, ItemNotFoundException is expected");
} catch (ItemNotFoundException e) {
// success.
}
}
} else {
try {
prop.getNode();
fail("Property.getNode() called on a multivalue property " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class BinaryPropertyTest method testGetDouble.
/**
* Tests conversion from Binary type to Double type. This is done via String
* conversion.
*/
public void testGetDouble() throws RepositoryException {
Value val = PropertyUtil.getValue(prop);
String str = val.getString();
// double
try {
Double.parseDouble(str);
double d = val.getDouble();
assertEquals("Wrong conversion from Binary to Double", new Double(d), Double.valueOf(str));
} catch (NumberFormatException nfe) {
try {
val.getDouble();
fail("Conversion from malformed Binary to Double " + "should throw ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class DatePropertyTest method testValue.
/**
* Tests that Property.getDate() delivers the same as Value.getDate() and
* that in case of a multivalue property a ValueFormatException is thrown.
*/
public void testValue() throws RepositoryException {
if (multiple) {
try {
prop.getDate();
fail("Property.getDate() called on a multivalue property " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
} else {
Calendar calendar = prop.getValue().getDate();
Calendar calendar2 = prop.getDate();
assertEquals("Value.getDate() and Property.getDate() return different values.", calendar, calendar2);
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class StringPropertyTest method testGetDouble.
/**
* Tests conversion from String type to Double type.
*/
public void testGetDouble() throws RepositoryException {
Value val = PropertyUtil.getValue(prop);
String str = val.getString();
// double
try {
Double.parseDouble(str);
double d = val.getDouble();
assertEquals("Wrong conversion from String to Double.", new Double(d), Double.valueOf(str));
} catch (NumberFormatException nfe) {
try {
val.getDouble();
fail("Conversion from malformed String to Double should throw ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class StringPropertyTest method testGetDate.
/**
* Tests conversion from String type to Date type.
*/
public void testGetDate() throws RepositoryException {
Value val = PropertyUtil.getValue(prop);
if (PropertyUtil.isDateFormat(val.getString())) {
val.getDate();
} else {
try {
val.getDate();
fail("Conversion from a malformed String to a Date " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
}
Aggregations