use of javax.jcr.ValueFormatException in project jackrabbit-oak by apache.
the class PropertyTest method testMixTitleOnUnstructured.
public void testMixTitleOnUnstructured() throws Exception {
Node n = testRootNode.addNode("unstructured", JcrConstants.NT_UNSTRUCTURED);
n.addMixin("mix:title");
superuser.save();
// create jcr:title property with type LONG => declaring NT is nt:unstructured
Property title = n.setProperty("jcr:title", 12345);
assertEquals(PropertyType.LONG, title.getType());
PropertyDefinition def = title.getDefinition();
assertEquals(JcrConstants.NT_UNSTRUCTURED, def.getDeclaringNodeType().getName());
assertEquals(PropertyType.UNDEFINED, def.getRequiredType());
// changing value to STRING => ValueFormatException expected
try {
title.setValue("str");
fail();
} catch (ValueFormatException e) {
// success
}
// re-setting property to STRING -> change definition => declaring NT is mix:title
n.setProperty("jcr:title", "str");
assertEquals(PropertyType.STRING, title.getType());
assertEquals(PropertyType.STRING, title.getValue().getType());
def = title.getDefinition();
assertEquals("mix:title", def.getDeclaringNodeType().getName());
assertEquals(PropertyType.STRING, def.getRequiredType());
}
use of javax.jcr.ValueFormatException in project jackrabbit-oak by apache.
the class PropertyTest method testRequiredTypeLongChangeBoolean.
public void testRequiredTypeLongChangeBoolean() throws Exception {
Property p = node.setProperty(LONG_PROP_NAME, 12345);
assertEquals(PropertyType.LONG, p.getType());
assertEquals(PropertyType.LONG, p.getValue().getType());
PropertyDefinition def = p.getDefinition();
assertEquals(PropertyType.LONG, def.getRequiredType());
assertEquals(NT_NAME, def.getDeclaringNodeType().getName());
superuser.save();
try {
p.setValue(true);
fail("Conversion from BOOLEAN to LONG must throw ValueFormatException");
} catch (ValueFormatException e) {
// success
}
try {
node.setProperty(LONG_PROP_NAME, true);
fail("Conversion from BOOLEAN to LONG must throw ValueFormatException");
} catch (ValueFormatException e) {
// success
}
}
use of javax.jcr.ValueFormatException in project jackrabbit-oak by apache.
the class PropertyTest method testPathRequiredTypeLong.
public void testPathRequiredTypeLong() throws Exception {
Value pathValue = superuser.getValueFactory().createValue("/path", PropertyType.PATH);
try {
Property p = node.setProperty(LONG_PROP_NAME, pathValue);
fail("Conversion from PATH to LONG must throw ValueFormatException");
} catch (ValueFormatException e) {
// success
}
}
use of javax.jcr.ValueFormatException in project jackrabbit-oak by apache.
the class PropertyTest method testPathRequiredTypeBoolean.
public void testPathRequiredTypeBoolean() throws Exception {
Value pathValue = superuser.getValueFactory().createValue("/path", PropertyType.PATH);
try {
Property p = node.setProperty(BOOLEAN_PROP_NAME, pathValue);
fail("Conversion from PATH to BOOLEAN must throw ValueFormatException");
} catch (ValueFormatException e) {
// success
}
}
use of javax.jcr.ValueFormatException in project jackrabbit-oak by apache.
the class ACLTest method testMvRestrictions.
@Test
public void testMvRestrictions() throws Exception {
ValueFactory vf = getValueFactory();
Value[] vs = new Value[] { vf.createValue(JcrConstants.NT_FILE, PropertyType.NAME), vf.createValue(JcrConstants.NT_FOLDER, PropertyType.NAME) };
Map<String, Value[]> mvRestrictions = Collections.singletonMap(REP_NT_NAMES, vs);
Map<String, Value> restrictions = Collections.singletonMap(REP_GLOB, vf.createValue("/.*"));
assertTrue(acl.addEntry(testPrincipal, testPrivileges, false, restrictions, mvRestrictions));
assertFalse(acl.addEntry(testPrincipal, testPrivileges, false, restrictions, mvRestrictions));
assertEquals(1, acl.getAccessControlEntries().length);
JackrabbitAccessControlEntry ace = (JackrabbitAccessControlEntry) acl.getAccessControlEntries()[0];
try {
ace.getRestriction(REP_NT_NAMES);
fail();
} catch (ValueFormatException e) {
// success
}
Value[] vvs = ace.getRestrictions(REP_NT_NAMES);
assertArrayEquals(vs, vvs);
}
Aggregations