Search in sources :

Example 26 with Version

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

the class RestoreTest method testRestoreRemovedJcr2.

public void testRestoreRemovedJcr2() throws RepositoryException {
    String path = versionableNode.getPath();
    Version v1 = versionManager.checkin(path);
    versionableNode.remove();
    versionableNode = null;
    superuser.save();
    versionManager.restore(path, v1, true);
    versionableNode = superuser.getNode(path);
    String value = versionableNode.getProperty(propertyName1).getString();
    assertEquals("Restoring a node must set the correct property.", propertyValue2, value);
}
Also used : Version(javax.jcr.version.Version)

Example 27 with Version

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

the class RestoreTest method testRestoreSetsBaseVersionJcr2_2.

/**
     * Test if restoring a node sets the jcr:baseVersion property correctly.
     *
     * @throws javax.jcr.RepositoryException
     */
public void testRestoreSetsBaseVersionJcr2_2() throws RepositoryException {
    versionManager.restore(version, true);
    Version baseV = versionManager.getBaseVersion(versionableNode.getPath());
    assertTrue("Restoring a node must set node's base version in order to point to the restored version.", version.isSame(baseV));
}
Also used : Version(javax.jcr.version.Version)

Example 28 with Version

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

the class RestoreTest method testRestoreOrderJcr2.

/**
     * Test the child ordering of restored nodes.
     * @throws RepositoryException
     */
public void testRestoreOrderJcr2() throws RepositoryException, NotExecutableException {
    // create a test-root that has orderable child nodes
    Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
    ensureMixinType(testRoot, mixVersionable);
    versionableNode.getSession().save();
    // create children of vNode and checkin
    Node child1 = testRoot.addNode(nodeName1);
    ensureMixinType(child1, mixVersionable);
    Node child2 = testRoot.addNode(nodeName2);
    ensureMixinType(child2, mixVersionable);
    testRoot.getSession().save();
    versionManager.checkin(child1.getPath());
    versionManager.checkin(child2.getPath());
    Version v1 = versionManager.checkin(testRoot.getPath());
    // remove node 1
    versionManager.checkout(testRoot.getPath());
    child1.remove();
    testRoot.getSession().save();
    versionManager.checkout(testRoot.getPath());
    // restore version 1.0
    versionManager.restore(v1, true);
    // check order
    NodeIterator iter = testRoot.getNodes();
    assertTrue(testRoot.getName() + " should have 2 child nodes.", iter.hasNext());
    Node n1 = iter.nextNode();
    assertTrue(testRoot.getName() + " should have 2 child nodes.", iter.hasNext());
    Node n2 = iter.nextNode();
    String orderOk = nodeName1 + ", " + nodeName2;
    String order = n1.getName() + ", " + n2.getName();
    assertEquals("Invalid child node ordering", orderOk, order);
}
Also used : NodeIterator(javax.jcr.NodeIterator) Version(javax.jcr.version.Version) Node(javax.jcr.Node)

Example 29 with Version

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

the class OnParentVersionInitializeTest method testRestoreProp.

/**
     * Test the restore of a OnParentVersion-INITIALIZE property
     *
     * @throws javax.jcr.RepositoryException
     */
public void testRestoreProp() throws RepositoryException {
    Node propParent = p.getParent();
    propParent.checkout();
    Version v = propParent.checkin();
    propParent.checkout();
    p.setValue(newPropValue);
    p.save();
    propParent.restore(v, false);
    assertEquals("On restore of a OnParentVersion-INITIALIZE property P, the current value of P must be left unchanged.", p.getString(), newPropValue);
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node)

Example 30 with Version

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

the class VersionLabelTest method testGetVersionLabelsForInvalidVersion.

/**
     * Test if versionHistory.getVersionLabels(Version) throws a VersionException if the
     * specified version is not in this version history.
     */
public void testGetVersionLabelsForInvalidVersion() throws Exception {
    // build a second versionable node below the testroot to get it's version.
    Node versionableNode2 = createVersionableNode(testRootNode, nodeName2, versionableNodeType);
    Version invalidV = versionableNode2.checkin();
    try {
        vHistory.getVersionLabels(invalidV);
        fail("VersionHistory.getVersionLabels(Version) must throw a VersionException if the specified version is not in this version history");
    } catch (VersionException ve) {
    // success
    }
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) 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