Search in sources :

Example 96 with Version

use of javax.jcr.version.Version in project jackrabbit by apache.

the class MergeDoneMergeTest method testMergeNodeDoneMergeJcr2.

/**
     * VersionManager.doneMerge(V) throws VersionException if V is not among the Vs in the
     * jcr:mergeFailed prop. <br> with adding it to jcr:predecessors.<br>
     * Branches will be joined.<br>
     */
public void testMergeNodeDoneMergeJcr2() 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);
    // "merge" the clonedNode with the newNode from the default workspace
    vmWsp2.checkout(path);
    vmWsp2.merge(path, workspace.getName(), true);
    // get predecessors
    Version[] predecessors = nodeToMerge.getBaseVersion().getPredecessors();
    // get mergeFailed property
    Property mergeFailedProperty = nodeToMerge.getProperty(jcrMergeFailed);
    Value[] mergeFailedReferences = mergeFailedProperty.getValues();
    for (int i = 0; i < mergeFailedReferences.length; i++) {
        String id = mergeFailedReferences[i].getString();
        vmWsp2.doneMerge(path, (Version) superuser.getNodeByIdentifier(id));
    }
    // check mergeFailed property - reference moved to predecessor
    if (nodeToMerge.hasProperty(jcrMergeFailed)) {
        Property mergeFailedPropertyAfterCancelMerge = nodeToMerge.getProperty(jcrMergeFailed);
        Value[] mergeFailedReferencesAfterCancelMerge = mergeFailedPropertyAfterCancelMerge.getValues();
        assertTrue(mergeFailedReferences.length > mergeFailedReferencesAfterCancelMerge.length);
    }
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) Value(javax.jcr.Value) VersionManager(javax.jcr.version.VersionManager) Property(javax.jcr.Property)

Example 97 with Version

use of javax.jcr.version.Version in project jackrabbit by apache.

the class GetContainingHistoryTest method testGetContainingHistory.

/**
     * Tests if {@link javax.jcr.version.Version#getContainingHistory()} returns
     * the correct VersionHistory instance.
     */
public void testGetContainingHistory() throws RepositoryException {
    // create version
    versionableNode.checkout();
    Version version = versionableNode.checkin();
    assertTrue("Method getContainingHistory() must return the same VersionHistory " + "as getVersionHistory() of the corresponding Node.", versionableNode.getVersionHistory().isSame(version.getContainingHistory()));
}
Also used : Version(javax.jcr.version.Version)

Example 98 with Version

use of javax.jcr.version.Version in project jackrabbit by apache.

the class FrozenNodeTest method testFrozenChildNodeUUUID.

/**
     * @throws RepositoryException
     */
public void testFrozenChildNodeUUUID() throws RepositoryException {
    versionableNode.addNode("child");
    versionableNode.getSession().save();
    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    Version v = versionManager.checkin(path);
    Node n = v.getFrozenNode().getNode("child");
    String puuid = n.getProperty(jcrUUID).getValue().getString();
    String nuuid = n.getIdentifier();
    assertEquals("jcr:uuid needs to be equal to the getIdentifier() return value.", nuuid, puuid);
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 99 with Version

use of javax.jcr.version.Version in project jackrabbit by apache.

the class GetCreatedTest method testGetCreatedCheckAgainstProperty.

/**
     * Returns the date this version was created. This corresponds to the value
     * of the jcr:created property in the nt:version node that represents this
     * version.
     */
public void testGetCreatedCheckAgainstProperty() throws RepositoryException {
    // create version
    versionableNode.checkout();
    Version version = versionableNode.checkin();
    Calendar calGetCreated = version.getCreated();
    Calendar calCreatedProp = version.getProperty(jcrCreated).getValue().getDate();
    assertEquals("Method getCreated() should return value of the jcr:created property.", calGetCreated, calCreatedProp);
}
Also used : Version(javax.jcr.version.Version) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar)

Example 100 with Version

use of javax.jcr.version.Version in project jackrabbit by apache.

the class FrozenNodeTest method testFrozenUUUID.

/**
     * @throws RepositoryException
     */
public void testFrozenUUUID() throws RepositoryException, NotExecutableException {
    // make versionable node referenceable
    ensureMixinType(versionableNode, mixReferenceable);
    versionableNode.getSession().save();
    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    Version v = versionManager.checkin(path);
    Node n = v.getFrozenNode();
    String fuuid = n.getProperty(jcrFrozenUuid).getValue().getString();
    String ruuid = versionableNode.getIdentifier();
    assertEquals("jcr:frozenUuid needs to be equal to the getIdentifier() return value.", ruuid, fuuid);
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Aggregations

Version (javax.jcr.version.Version)265 Node (javax.jcr.Node)155 VersionManager (javax.jcr.version.VersionManager)65 RepositoryException (javax.jcr.RepositoryException)45 VersionHistory (javax.jcr.version.VersionHistory)29 VersionException (javax.jcr.version.VersionException)25 NodeIterator (javax.jcr.NodeIterator)23 Session (javax.jcr.Session)19 Test (org.junit.Test)19 Property (javax.jcr.Property)16 VersionIterator (javax.jcr.version.VersionIterator)16 Value (javax.jcr.Value)14 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)14 ItemExistsException (javax.jcr.ItemExistsException)13 HashSet (java.util.HashSet)12 NodeDefinition (javax.jcr.nodetype.NodeDefinition)12 ArrayList (java.util.ArrayList)11 Set (java.util.Set)7 DavException (org.apache.jackrabbit.webdav.DavException)7 UserTransaction (javax.transaction.UserTransaction)6