Search in sources :

Example 1 with MergeException

use of javax.jcr.MergeException in project jackrabbit by apache.

the class MergeCheckedoutSubNodeTest method testFailIfCorrespondingNodeIsSuccessor.

/**
     * Node.merge(): If V' of a versionable subnode N' in the source workspace
     * is a successor of V (the base version of a subnode N in this workspace),
     * calling merge must fail.
     */
public void testFailIfCorrespondingNodeIsSuccessor() throws RepositoryException {
    // make V' of a subnode N' in source workspace be a successor version of
    // the base version of the corresponding subnode.
    Node n = testRootNode.getNode(nodeName1 + "/" + nodeName2);
    n.checkout();
    n.checkin();
    n.checkout();
    try {
        // merge, besteffort set to false to stop at the first failure
        nodeToMerge.merge(workspace.getName(), false);
        fail("Merging a checkedout node if the version V' of the corresponding node is a successor of this node's base version must fail.");
    } catch (MergeException e) {
    // success
    }
}
Also used : MergeException(javax.jcr.MergeException) Node(javax.jcr.Node)

Example 2 with MergeException

use of javax.jcr.MergeException in project jackrabbit by apache.

the class MergeNodeTest method testMergeNodeVersionAmbiguousJcr2.

/**
     * VersionManager.merge(): versionable subNode N checked-in: If V is neither a
     * successor of, predecessor of, nor identical with V', then the merge
     * result for N is failed<br>
     */
public void testMergeNodeVersionAmbiguousJcr2() throws RepositoryException {
    // create 2 independent versions for a node and its corresponding node
    // so merge fails for this node
    // default workspace
    Node originalNode = testRootNode.getNode(nodeName1);
    VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
    String originalPath = originalNode.getPath();
    vmWsp1.checkout(originalPath);
    vmWsp1.checkin(originalPath);
    // second workspace
    VersionManager vmWsp2 = nodeToMerge.getSession().getWorkspace().getVersionManager();
    String path = nodeToMerge.getPath();
    vmWsp2.checkin(path);
    // besteffort set to false to stop at the first failure
    try {
        vmWsp2.checkout(path);
        vmWsp2.merge(path, workspace.getName(), false);
        fail("Node has ambigous versions. Merge must throw a MergeException");
    } catch (MergeException e) {
    // success if the merge exception thrown
    }
}
Also used : MergeException(javax.jcr.MergeException) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 3 with MergeException

use of javax.jcr.MergeException in project jackrabbit by apache.

the class MergeNodeTest method testMergeNodeVersionAmbiguous.

/**
     * Node.merge(): versionable subNode N checked-in: If V is neither a
     * successor of, predecessor of, nor identical with V', then the merge
     * result for N is failed<br>
     */
@SuppressWarnings("deprecation")
public void testMergeNodeVersionAmbiguous() throws RepositoryException {
    // create 2 independent versions for a node and its corresponding node
    // so merge fails for this node
    // default workspace
    Node originalNode = testRootNode.getNode(nodeName1);
    originalNode.checkout();
    originalNode.checkin();
    // second workspace
    nodeToMerge.checkin();
    // besteffort set to false to stop at the first failure
    try {
        nodeToMerge.checkout();
        nodeToMerge.merge(workspace.getName(), false);
        fail("Node has ambigous versions. Merge must throw a MergeException");
    } catch (MergeException e) {
    // success if the merge exception thrown
    }
}
Also used : MergeException(javax.jcr.MergeException) Node(javax.jcr.Node)

Example 4 with MergeException

use of javax.jcr.MergeException in project jackrabbit by apache.

the class MergeNodeTest method testMergeNodeBestEffortFalseJcr2.

/**
     * VersionManager.merge(): bestEffort is false and any merge fails a MergeException is
     * thrown.<br>
     */
public void testMergeNodeBestEffortFalseJcr2() throws RepositoryException {
    /// create successor versions for a node
    // so merge fails for this node
    // default workspace
    Node originalNode = testRootNode.getNode(nodeName1);
    VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
    String originalPath = originalNode.getPath();
    vmWsp1.checkout(originalPath);
    vmWsp1.checkin(originalPath);
    // merge, besteffort set to false
    try {
        nodeToMerge.getSession().getWorkspace().getVersionManager().merge(nodeToMerge.getPath(), workspace.getName(), false);
        fail("bestEffort is false and any merge should throw a MergeException.");
    } catch (MergeException e) {
    // successful
    }
}
Also used : MergeException(javax.jcr.MergeException) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 5 with MergeException

use of javax.jcr.MergeException in project jackrabbit by apache.

the class MergeNodeTest method testMergeNodeBestEffortFalseAmbiguousVersionsJcr2.

/**
     * A MergeVersionException is thrown if bestEffort is false and a
     * versionable node is encountered whose corresponding node's base version
     * is on a divergent branch from this node's base version.
     */
public void testMergeNodeBestEffortFalseAmbiguousVersionsJcr2() throws RepositoryException {
    /// create 2 independent base versions for a node and its corresponding node
    // so merge fails for this node
    // default workspace
    Node originalNode = testRootNode.getNode(nodeName1);
    VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
    String originalPath = originalNode.getPath();
    vmWsp1.checkout(originalPath);
    vmWsp1.checkin(originalPath);
    // second workspace
    VersionManager vmWsp2 = nodeToMerge.getSession().getWorkspace().getVersionManager();
    String path = nodeToMerge.getPath();
    vmWsp2.checkin(path);
    // "merge" the clonedNode with the newNode from the default workspace
    vmWsp2.checkout(path);
    // merge, besteffort set to false
    try {
        vmWsp2.merge(path, workspace.getName(), false);
        fail("BestEffort is false and corresponding node's version is ambiguous. Merge should throw a MergeException.");
    } catch (MergeException e) {
    // successful
    }
}
Also used : MergeException(javax.jcr.MergeException) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Aggregations

MergeException (javax.jcr.MergeException)9 Node (javax.jcr.Node)8 VersionManager (javax.jcr.version.VersionManager)4 HashSet (java.util.HashSet)1 Set (java.util.Set)1