Search in sources :

Example 31 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 32 with VersionManager

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

the class CheckinTest method testCheckinWithPendingChangesJcr2.

/**
     * Test if VersionManager.checkin(P) throws InvalidItemStateException if
     * the path P resolves to a node that has unsaved changes pending.
     *
     * @throws RepositoryException
     */
public void testCheckinWithPendingChangesJcr2() throws RepositoryException {
    try {
        // modify node without calling save()
        versionableNode.setProperty(propertyName1, propertyValue);
        VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
        String path = versionableNode.getPath();
        versionManager.checkin(path);
        fail("InvalidItemStateException must be thrown on attempt to checkin a node having any unsaved changes pending.");
    } catch (InvalidItemStateException e) {
    // ok
    }
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) VersionManager(javax.jcr.version.VersionManager)

Example 33 with VersionManager

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

the class CheckinTest method testCheckinCreatesNewVersionJcr2.

/**
     * Test if VersionManager.checkin(String) adds another version to the VersionHistory
     *
     * @throws RepositoryException
     */
public void testCheckinCreatesNewVersionJcr2() throws RepositoryException {
    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    long initialNumberOfVersions = getNumberOfVersions(versionManager.getVersionHistory(path));
    versionManager.checkin(path);
    long numberOfVersions = getNumberOfVersions(versionManager.getVersionHistory(path));
    assertTrue("Checkin must create a new Version in the VersionHistory.", numberOfVersions == initialNumberOfVersions + 1);
}
Also used : VersionManager(javax.jcr.version.VersionManager)

Example 34 with VersionManager

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

the class CheckoutTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    if (!versionManager.isCheckedOut(path)) {
        fail("A versionable node must be checked-out after persistent creation.");
    }
    if (!versionableNode.isCheckedOut()) {
        fail("A versionable node must be checked-out after persistent creation.");
    }
    try {
        versionManager.checkin(path);
    } catch (RepositoryException e) {
        cleanUp();
        throw e;
    }
}
Also used : RepositoryException(javax.jcr.RepositoryException) VersionManager(javax.jcr.version.VersionManager)

Example 35 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)

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