Search in sources :

Example 81 with VersionManager

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

the class CheckinTest method testMultipleCheckinHasNoEffectJcr2.

/**
     * Test if VersionManager.checkin(P) has no effect if the path P resolves
     * to a checked-in node.
     *
     * @throws RepositoryException
     */
public void testMultipleCheckinHasNoEffectJcr2() throws RepositoryException {
    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    Version v = versionManager.checkin(path);
    try {
        Version v2 = versionManager.checkin(path);
        assertTrue("Calling VersionManager.checkin(P) must not have an if the path P resolves to a node that is already checked-in.", v.isSame(v2));
    } catch (RepositoryException e) {
        fail("Calling VersionManager.checkin(P) must not throw an exception if the path P resolves to a node that is already checked-in.");
    }
}
Also used : Version(javax.jcr.version.Version) RepositoryException(javax.jcr.RepositoryException) VersionManager(javax.jcr.version.VersionManager)

Example 82 with VersionManager

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

the class CheckinTest method testIsNotCheckedOutJcr2.

/**
     * Test if VersionManager.isCheckedOut(P) returns false after calling VersionManager.checkin(P).
     *
     * @throws RepositoryException
     */
public void testIsNotCheckedOutJcr2() throws RepositoryException {
    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    versionManager.checkin(path);
    boolean isCheckedOut = versionManager.isCheckedOut(path);
    assertFalse("VersionManager.isCheckedOut(P) must return false after VersionManager.checkin(P).", isCheckedOut);
}
Also used : VersionManager(javax.jcr.version.VersionManager)

Example 83 with VersionManager

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

the class CheckinTest method testBaseVersionAfterCheckinJcr2.

/**
     * Test if versionable node N's jcr:baseVersion property is set to refer to
     * the new version after checkin.
     *
     * @throws RepositoryException
     */
public void testBaseVersionAfterCheckinJcr2() throws RepositoryException {
    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    Version v = versionManager.checkin(path);
    Value baseVersionRef = versionableNode.getProperty(jcrBaseVersion).getValue();
    assertEquals("Checked-in node's jcr:baseVersion property is set to refer to the version created on checkin.", superuser.getValueFactory().createValue(v), baseVersionRef);
}
Also used : Version(javax.jcr.version.Version) Value(javax.jcr.Value) VersionManager(javax.jcr.version.VersionManager)

Example 84 with VersionManager

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

the class CheckoutTest method testCheckoutTwiceDoesNotThrowJcr2.

/**
     * Test if VersionManager.checkout(P) doesn't throw any exception if P
     * denotes the absolute path of a versionable node that has been checked
     * out before.
     */
public void testCheckoutTwiceDoesNotThrowJcr2() throws RepositoryException {
    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    versionManager.checkout(path);
    versionManager.checkout(path);
}
Also used : VersionManager(javax.jcr.version.VersionManager)

Example 85 with VersionManager

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

the class CheckoutTest method testCheckoutCopiesBaseValueToPredecessorPropertyJcr2.

/**
     * Test if VersionManager.checkout(P), with P denoting the absolute path
     * of a versionable node, copies the node's jcr:baseVersion to the node's
     * jcr:predecessors property (no save required).
     */
public void testCheckoutCopiesBaseValueToPredecessorPropertyJcr2() throws RepositoryException {
    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    Value baseVersionValue = versionableNode.getProperty(jcrBaseVersion).getValue();
    versionManager.checkout(path);
    Value[] predecessorsValues = versionableNode.getProperty(jcrPredecessors).getValues();
    // loop over all values of jcr:predecessors property as it's not sure
    // on which position jcr:baseVersion is copied.
    boolean foundBaseVersionProp = false;
    int i = 0;
    while (i < predecessorsValues.length && !foundBaseVersionProp) {
        if (predecessorsValues[i].equals(baseVersionValue)) {
            foundBaseVersionProp = true;
        }
        i++;
    }
    if (!foundBaseVersionProp) {
        fail("After calling Node.checkout() the current value of node's jcr:baseVersion must be copied to node's jcr:predecessors property");
    }
}
Also used : Value(javax.jcr.Value) VersionManager(javax.jcr.version.VersionManager)

Aggregations

VersionManager (javax.jcr.version.VersionManager)154 Node (javax.jcr.Node)97 Version (javax.jcr.version.Version)65 VersionHistory (javax.jcr.version.VersionHistory)17 RepositoryException (javax.jcr.RepositoryException)11 Value (javax.jcr.Value)10 Test (org.junit.Test)9 Property (javax.jcr.Property)8 Session (javax.jcr.Session)8 NodeIterator (javax.jcr.NodeIterator)7 VersionException (javax.jcr.version.VersionException)5 ItemNotFoundException (javax.jcr.ItemNotFoundException)4 MergeException (javax.jcr.MergeException)4 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)4 VersionIterator (javax.jcr.version.VersionIterator)4 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 NodeDefinitionTemplate (javax.jcr.nodetype.NodeDefinitionTemplate)3 InvalidItemStateException (javax.jcr.InvalidItemStateException)2