use of javax.jcr.nodetype.NodeDefinition in project jackrabbit-oak by apache.
the class CopyNodeTypesUpgradeTest method customNodeTypesAreRegistered.
@Test
public void customNodeTypesAreRegistered() throws RepositoryException {
final JackrabbitSession adminSession = createAdminSession();
final NodeTypeManager nodeTypeManager = adminSession.getWorkspace().getNodeTypeManager();
final NodeType testFolderNodeType = nodeTypeManager.getNodeType("test:Folder");
final NodeDefinition[] cnd = testFolderNodeType.getChildNodeDefinitions();
final PropertyDefinition[] pd = testFolderNodeType.getPropertyDefinitions();
assertEquals("More than one child node definition", 1, cnd.length);
assertEquals("Incorrect default primary type", "test:Folder", cnd[0].getDefaultPrimaryTypeName());
assertEquals("More than two property definitions", 4, pd.length);
adminSession.logout();
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit-oak by apache.
the class NodeTypeDefDiff method collectChildNodeDefs.
private Map<NodeDefinitionId, List<NodeDefinition>> collectChildNodeDefs(final NodeDefinition[] cnda1) {
Map<NodeDefinitionId, List<NodeDefinition>> defs1 = new HashMap<NodeDefinitionId, List<NodeDefinition>>();
for (NodeDefinition def1 : cnda1) {
final NodeDefinitionId def1Id = new NodeDefinitionId(def1);
List<NodeDefinition> list = defs1.get(def1Id);
if (list == null) {
list = new ArrayList<NodeDefinition>();
defs1.put(def1Id, list);
}
list.add(def1);
}
return defs1;
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit by apache.
the class RestoreTest method testRestoreWithUUIDConflictJcr2_4.
/**
* Tests if restoring the <code>Version</code> of an existing node throws an
* <code>ItemExistsException</code> if removeExisting is set to FALSE.
*/
public void testRestoreWithUUIDConflictJcr2_4() throws RepositoryException, NotExecutableException {
try {
Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
// Verify that nodes used for the test have proper opv behaviour
NodeDefinition nd = naa.getDefinition();
if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
}
Version v = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
superuser.save();
versionManager.restore(new Version[] { v }, false);
fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
} catch (ItemExistsException e) {
// success
}
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit by apache.
the class RestoreTest method testRestoreWithUUIDConflictJcr2_3.
/**
* Tests if restoring the <code>Version</code> of an existing node throws an
* <code>ItemExistsException</code> if removeExisting is set to FALSE.
*/
public void testRestoreWithUUIDConflictJcr2_3() throws RepositoryException, NotExecutableException {
try {
Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
// Verify that nodes used for the test have proper opv behaviour
NodeDefinition nd = naa.getDefinition();
if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
}
Version v = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
superuser.save();
versionManager.restore(versionableNode.getPath(), v.getName(), false);
fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
} catch (ItemExistsException e) {
// success
}
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit by apache.
the class RestoreTest method testRestoreWithUUIDConflictJcr2_2.
/**
* Tests if restoring the <code>Version</code> of an existing node throws an
* <code>ItemExistsException</code> if removeExisting is set to FALSE.
*/
public void testRestoreWithUUIDConflictJcr2_2() throws RepositoryException, NotExecutableException {
try {
Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
// Verify that nodes used for the test have proper opv behaviour
NodeDefinition nd = naa.getDefinition();
if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
}
Version v = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
superuser.save();
versionManager.restore(v, false);
fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
} catch (ItemExistsException e) {
// success
}
}
Aggregations