*
* @throws Exception
*/
public void testReregisterAddNewProperty() throws Exception
{
NodeTypeValue testNTValue = new NodeTypeValue();
List<String> superType = new ArrayList<String>();
superType.add("nt:base");
testNTValue.setName("exo:testReregisterAddNewProperty");
testNTValue.setPrimaryItemName("");
testNTValue.setDeclaredSupertypeNames(superType);
nodeTypeManager.registerNodeType(testNTValue, ExtendedNodeTypeManager.FAIL_IF_EXISTS);
Node testNode = root.addNode("testNode", testNTValue.getName());
session.save();
testNTValue = nodeTypeManager.getNodeTypeValue(testNTValue.getName());
List<PropertyDefinitionValue> props = new ArrayList<PropertyDefinitionValue>();
props.add(new PropertyDefinitionValue("tt", true, true, 1, false, new ArrayList<String>(), false,
PropertyType.STRING, new ArrayList<String>()));
testNTValue.setDeclaredPropertyDefinitionValues(props);
try
{
nodeTypeManager.registerNodeType(testNTValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);
fail();
}
catch (ConstraintViolationException e)
{
// ok
}
testNTValue = nodeTypeManager.getNodeTypeValue(testNTValue.getName());
List<String> def = new ArrayList<String>();
def.add("tt");
props = new ArrayList<PropertyDefinitionValue>();
props.add(new PropertyDefinitionValue("tt", true, true, 1, false, def, false, PropertyType.STRING,
new ArrayList<String>()));
testNTValue.setDeclaredPropertyDefinitionValues(props);
nodeTypeManager.registerNodeType(testNTValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);
assertEquals("tt", testNode.getProperty("tt").getString());
Node test2 = root.addNode("test2", testNTValue.getName());
assertEquals("tt", test2.getProperty("tt").getString());
}