Search in sources :

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

Example 72 with Version

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

the class FrozenNodeTest method testFrozenNodeType.

/**
     * @throws RepositoryException
     */
public void testFrozenNodeType() throws RepositoryException {
    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    Version v = versionManager.checkin(path);
    Node n = v.getFrozenNode();
    String fuuid = n.getProperty("jcr:frozenPrimaryType").getValue().getString();
    String ruuid = versionableNode.getPrimaryNodeType().getName();
    assertEquals("jcr:frozenPrimaryType needs to be equal to the getPrimaryNodeType() return value.", ruuid, fuuid);
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 73 with Version

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

the class RestoreTest method testRestoreChild1Jcr2_2.

public void testRestoreChild1Jcr2_2() throws RepositoryException {
    versionableNode.addNode("child1");
    versionableNode.getSession().save();
    Version v1 = versionManager.checkin(versionableNode.getPath());
    versionManager.checkout(versionableNode.getPath());
    Version v2 = versionManager.checkin(versionableNode.getPath());
    versionManager.restore(v1, true);
    assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
    versionManager.restore(version, true);
    assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
    try {
        versionManager.restore(v2, true);
    } catch (RepositoryException e) {
        fail("Node.restore('1.3') must fail.");
    }
}
Also used : Version(javax.jcr.version.Version) RepositoryException(javax.jcr.RepositoryException)

Example 74 with Version

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

the class RestoreTest method testRestoreChild1Jcr2_3.

public void testRestoreChild1Jcr2_3() throws RepositoryException {
    versionableNode.addNode("child1");
    versionableNode.getSession().save();
    Version v1 = versionManager.checkin(versionableNode.getPath());
    versionManager.checkout(versionableNode.getPath());
    Version v2 = versionManager.checkin(versionableNode.getPath());
    versionManager.restore(versionableNode.getPath(), v1.getName(), true);
    assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
    versionManager.restore(versionableNode.getPath(), version.getName(), true);
    assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
    try {
        versionManager.restore(versionableNode.getPath(), v2.getName(), true);
    } catch (RepositoryException e) {
        fail("Node.restore('1.3') must fail.");
    }
}
Also used : Version(javax.jcr.version.Version) RepositoryException(javax.jcr.RepositoryException)

Example 75 with Version

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

the class RestoreTest method testRestoreWithInvalidVersion.

/**
     * Test if restoring a node with an invalid Version throws a VersionException
     *
     * @throws RepositoryException
     */
@SuppressWarnings("deprecation")
public void testRestoreWithInvalidVersion() throws RepositoryException {
    Version invalidVersion = versionableNode2.checkin();
    try {
        versionableNode.restore(invalidVersion, true);
        fail("Node.restore(Version, boolean): A VersionException must be thrown if the specified version does not exists in this node's version history.");
    } catch (VersionException e) {
    // success
    }
}
Also used : Version(javax.jcr.version.Version) VersionException(javax.jcr.version.VersionException)

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