use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class BinaryPropertyTest method testGetDate.
/**
* Tests conversion from Binary type to Date type. This is done via String
* conversion.
*/
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
}
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class BinaryPropertyTest method testGetLong.
/**
* Tests conversion from Binary type to Long type. This is done via String
* conversion.
*/
public void testGetLong() throws RepositoryException {
Value val = PropertyUtil.getValue(prop);
String str = val.getString();
try {
Long.parseLong(str);
long l = val.getLong();
assertEquals("Wrong conversion from Binary to Long", new Long(l), Long.valueOf(str));
} catch (NumberFormatException nfe) {
try {
val.getLong();
fail("Conversion from malformed Binary to Long " + "should throw ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class NodeAddMixinTest method testAddMixinReferencable.
/**
* Tests if adding mix:referenceable automatically populates the jcr:uuid
* value.
*/
public void testAddMixinReferencable() throws NotExecutableException, RepositoryException {
// check if repository supports references
checkMixReferenceable();
// get session an create default node
Node node = testRootNode.addNode(nodeName1, testNodeType);
ensureMixinType(node, mixReferenceable);
// implementation specific: mixin may take effect only upon save
testRootNode.getSession().save();
// check that it did
assertTrue(node.isNodeType(mixReferenceable));
// (format of value is not defined so we can only test if not empty)
try {
String uuid = node.getProperty(jcrUUID).getValue().getString();
// default value is null so check for null
assertNotNull("Acessing jcr:uuid after assginment of mix:referencable returned null", uuid);
// check if it was not set to an empty string
assertTrue("Acessing jcr:uuid after assginment of mix:referencable returned an empty String!", uuid.length() > 0);
} catch (ValueFormatException e) {
// trying to access the uuid caused an exception
fail("Acessing jcr:uuid after assginment of mix:referencable caused an ValueFormatException!");
}
}
use of javax.jcr.ValueFormatException in project jackrabbit by apache.
the class NamePropertyTest method testGetBoolean.
/**
* Tests failure of conversion from Name type to Boolean type.
*
* @throws RepositoryException
*/
public void testGetBoolean() throws RepositoryException {
try {
Value val = PropertyUtil.getValue(prop);
val.getBoolean();
fail("Conversion from a Name 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 testGetDate.
/**
* Tests failure of conversion from Name type to Date type.
*
* @throws RepositoryException
*/
public void testGetDate() throws RepositoryException {
try {
Value val = PropertyUtil.getValue(prop);
val.getDate();
fail("Conversion from a Name value to a Date value " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
Aggregations