assertNull(ndt.getDefaultPrimaryTypeName());
assertFalse(ndt.allowsSameNameSiblings());
}
public void testNodeDefinitionTemplate() throws Exception {
NodeDefinitionTemplate ndt = ntm.createNodeDefinitionTemplate();
try {
ndt.setName(null);
fail("null isn't a valid JCR name");
} catch (ConstraintViolationException e) {
// success
}
String expandedName = "{" + NS_JCR_URI + "}" + "content";
String jcrName = superuser.getNamespacePrefix(NS_JCR_URI) + ":content";
ndt.setName(expandedName);
assertEquals(jcrName, ndt.getName());
ndt.setName(jcrName);
assertEquals(jcrName, ndt.getName());
ndt.setSameNameSiblings(true);
assertTrue(ndt.allowsSameNameSiblings());
ndt.setAutoCreated(true);
assertTrue(ndt.isAutoCreated());
ndt.setMandatory(true);
assertTrue(ndt.isMandatory());
ndt.setProtected(true);
assertTrue(ndt.isProtected());
ndt.setOnParentVersion(OnParentVersionAction.VERSION);
assertEquals(OnParentVersionAction.VERSION, ndt.getOnParentVersion());
expandedName = "{" + NS_NT_URI + "}" + "folder";
jcrName = superuser.getNamespacePrefix(NS_NT_URI) + ":folder";
ndt.setDefaultPrimaryTypeName(expandedName);
assertEquals(jcrName, ndt.getDefaultPrimaryTypeName());
ndt.setDefaultPrimaryTypeName(null);
assertEquals("setting null must clear the name.", null, ndt.getDefaultPrimaryTypeName());
ndt.setRequiredPrimaryTypeNames(new String[] {expandedName});
assertNotNull(ndt.getRequiredPrimaryTypeNames());
assertEquals(1, ndt.getRequiredPrimaryTypeNames().length);
assertEquals(jcrName, ndt.getRequiredPrimaryTypeNames()[0]);
try {
ndt.setRequiredPrimaryTypeNames(null);
fail("null isn't a valid array of jcr name");
} catch (ConstraintViolationException e) {
// success
}
}