You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2009/05/15 18:15:03 UTC
svn commit: r775213 [2/2] - in
/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version:
./ simple/
Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckinTest.java?rev=775213&r1=775212&r2=775213&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckinTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckinTest.java Fri May 15 16:15:02 2009
@@ -20,6 +20,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.version.Version;
+import javax.jcr.version.VersionManager;
/**
* <code>CheckinTest</code> covers tests related to {@link javax.jcr.Node#checkin()}
@@ -35,7 +36,32 @@
protected void setUp() throws Exception {
super.setUp();
- versionableNode.checkout();
+ VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+ String path = versionableNode.getPath();
+ versionManager.checkout(path);
+ }
+
+ /**
+ * Test if Node.isCheckedOut() return false after calling Node.checkin()
+ *
+ * @throws javax.jcr.RepositoryException
+ */
+ public void testIsCheckedOut() throws RepositoryException {
+ versionableNode.checkin();
+ assertTrue("After calling Node.checkin() on a versionable node N, N.isCheckedOut() must return false", versionableNode.isCheckedOut() == false);
+ }
+
+ /**
+ * Test if VersionManager.isCheckedOut(P) returns false if P is the
+ * absolute path of a checked-in versionable node.
+ *
+ * @throws javax.jcr.RepositoryException
+ */
+ public void testIsCheckedOutJcr2() throws RepositoryException {
+ VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+ String path = versionableNode.getPath();
+ versionManager.checkin(path);
+ assertTrue("VersionManager.isCheckedOut(P) must return false if the path P resolves to a checked-in node.", versionManager.isCheckedOut(path) == false);
}
/**
@@ -56,6 +82,26 @@
}
/**
+ * 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.");
+ }
+ }
+
+ /**
* Test if Node.checkin() throws InvalidItemStateException if the node
* has unsaved changes pending.
*
@@ -74,6 +120,26 @@
}
/**
+ * 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
+ }
+ }
+
+ /**
* Test if Node.isCheckedOut() returns false after Node.checkin().
*
* @throws RepositoryException
@@ -86,6 +152,20 @@
}
/**
+ * 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);
+ }
+
+ /**
* Test if Node.checkin() adds another version to the VersionHistory
*
* @throws RepositoryException
@@ -100,6 +180,22 @@
}
/**
+ * 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);
+ }
+
+ /**
* Test calling Node.checkin() on a non-versionable node.
*
* @throws RepositoryException
@@ -107,7 +203,24 @@
public void testCheckinNonVersionableNode() throws RepositoryException {
try {
nonVersionableNode.checkin();
- fail("Node.checkin() on a non versionable node must throw UnsupportedRepositoryOperationException");
+ fail("Node.checkin() on a non-versionable node must throw UnsupportedRepositoryOperationException");
+ } catch (UnsupportedRepositoryOperationException e) {
+ //success
+ }
+ }
+
+ /**
+ * Test calling VersionManager.checkin(P) with the path P resolving to
+ * a non-versionable node.
+ *
+ * @throws RepositoryException
+ */
+ public void testCheckinNonVersionableNodeJcr2() throws RepositoryException {
+ try {
+ VersionManager versionManager = nonVersionableNode.getSession().getWorkspace().getVersionManager();
+ String path = nonVersionableNode.getPath();
+ versionManager.checkin(path);
+ fail("VersionManager.checkin(P) must throw UnsupportedRepositoryOperationException if the path P resolves to a non-versionable node.");
} catch (UnsupportedRepositoryOperationException e) {
//success
}
Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckoutTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckoutTest.java?rev=775213&r1=775212&r2=775213&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckoutTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CheckoutTest.java Fri May 15 16:15:02 2009
@@ -20,6 +20,7 @@
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.version.VersionManager;
/**
* <code>SVCheckoutTest</code> covers tests related to {@link
@@ -34,68 +35,140 @@
public class CheckoutTest extends AbstractVersionTest {
protected void setUp() throws Exception {
- super.setUp();
-
- if (!versionableNode.isCheckedOut()) {
- fail("A versionable node must be checked-out after persistent creation.");
- }
- versionableNode.checkin();
- }
-
- /**
- * Test if Node.isCheckedOut() returns true, if the versionable node has
- * been checked out before.
- */
- public void testIsCheckedOut() throws RepositoryException {
- versionableNode.checkout();
- assertTrue("After calling Node.checkout() a versionable node N, N.isCheckedOut() must return true.", versionableNode.isCheckedOut());
- }
-
- /**
- * Test calling Node.isCheckedOut() on a non-versionable.
- */
- public void testIsCheckedOutNonVersionableNode() throws RepositoryException {
- boolean isCheckedOut = nonVersionableNode.isCheckedOut();
- Node vParent = null;
- try {
- vParent = nonVersionableNode.getParent();
- while (!vParent.isNodeType(mixVersionable)) {
- vParent = vParent.getParent();
- }
- } catch (ItemNotFoundException e) {
- // root reached.
- }
-
- if (vParent != null && vParent.isNodeType(mixVersionable)) {
- if (vParent.isCheckedOut()) {
- assertTrue("Node.isCheckedOut() must return true if the node is non-versionable and its nearest versionable ancestor is checked-out.", isCheckedOut);
- } else {
- assertFalse("Node.isCheckedOut() must return false if the node is non-versionable and its nearest versionable ancestor is checked-in.", isCheckedOut);
- }
- } else {
- assertTrue("Node.isCheckedOut() must return true if the node is non-versionable and has no versionable ancestor", isCheckedOut);
- }
- }
-
- /**
- * Test calling Node.checkout() on a non-versionable node.
- */
- public void testCheckoutNonVersionableNode() throws RepositoryException {
- try {
- nonVersionableNode.checkout();
- fail("Node.checkout() on a non versionable node must throw UnsupportedRepositoryOperationException");
- } catch (UnsupportedRepositoryOperationException e) {
- //success
- }
- }
-
- /**
- * Test if Node.checkout() doesn't throw any exception if the versionable
- * node has been checked out before.
- */
- public void testCheckoutTwiceDoesNotThrow() throws RepositoryException {
- versionableNode.checkout();
- versionableNode.checkout();
- }
+ 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.");
+ }
+ versionManager.checkin(path);
+ }
+
+ /**
+ * Test if Node.isCheckedOut() returns true, if the versionable node has
+ * been checked out before.
+ */
+ public void testIsCheckedOut() throws RepositoryException {
+ versionableNode.checkout();
+ assertTrue("After calling Node.checkout() a versionable node N, N.isCheckedOut() must return true.", versionableNode.isCheckedOut());
+ }
+
+ /**
+ * Test if VersionManager.isCheckedOut(P) returns true if P is the
+ * absolute path of a versionable node that has been checked out before.
+ */
+ public void testIsCheckedOutJcr2() throws RepositoryException {
+ VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+ String path = versionableNode.getPath();
+ versionManager.checkout(path);
+ assertTrue("After successfully calling VersionManager.checkout(P) with P denoting the absolute path of a versionable node, VersionManager.isCheckedOut(P) must return true.", versionManager.isCheckedOut(path));
+ }
+
+ /**
+ * Test calling Node.isCheckedOut() on a non-versionable.
+ */
+ public void testIsCheckedOutNonVersionableNode() throws RepositoryException {
+ boolean isCheckedOut = nonVersionableNode.isCheckedOut();
+ Node vParent = null;
+ try {
+ vParent = nonVersionableNode.getParent();
+ while (!vParent.isNodeType(mixVersionable)) {
+ vParent = vParent.getParent();
+ }
+ } catch (ItemNotFoundException e) {
+ // root reached.
+ }
+
+ if (vParent != null && vParent.isNodeType(mixVersionable)) {
+ if (vParent.isCheckedOut()) {
+ assertTrue("Node.isCheckedOut() must return true if the node is non-versionable and its nearest versionable ancestor is checked-out.", isCheckedOut);
+ } else {
+ assertFalse("Node.isCheckedOut() must return false if the node is non-versionable and its nearest versionable ancestor is checked-in.", isCheckedOut);
+ }
+ } else {
+ assertTrue("Node.isCheckedOut() must return true if the node is non-versionable and has no versionable ancestor", isCheckedOut);
+ }
+ }
+
+ /**
+ * Test calling VersionManager.isCheckedOut(P) with P denoting the
+ * absolute path of a non-versionable node.
+ */
+ public void testIsCheckedOutNonVersionableNodeJcr2() throws RepositoryException {
+ VersionManager versionManager = nonVersionableNode.getSession().getWorkspace().getVersionManager();
+ String path = nonVersionableNode.getPath();
+ boolean isCheckedOut = versionManager.isCheckedOut(path);
+ Node vParent = null;
+ try {
+ vParent = nonVersionableNode.getParent();
+ while (!vParent.isNodeType(mixVersionable)) {
+ vParent = vParent.getParent();
+ }
+ } catch (ItemNotFoundException e) {
+ // root reached.
+ }
+
+ if (vParent != null && vParent.isNodeType(mixVersionable)) {
+ String parentPath = vParent.getPath();
+ if (versionManager.isCheckedOut(parentPath)) {
+ assertTrue("VersionManager.isCheckedOut(P) must return true if P denotes the absolute path of a non-versionable node whose nearest versionable ancestor is checked-out.", isCheckedOut);
+ } else {
+ assertFalse("VersionManager.isCheckedOut(P) must return false if P denotes the absolute path of a non-versionable node whose nearest versionable ancestor is checked-in.", isCheckedOut);
+ }
+ } else {
+ assertTrue("VersionManager.isCheckedOut(P) must return true if P denotes the absolute path of a non-versionable node that has no versionable ancestor", isCheckedOut);
+ }
+ }
+
+ /**
+ * Test calling Node.checkout() on a non-versionable node.
+ */
+ public void testCheckoutNonVersionableNode() throws RepositoryException {
+ try {
+ nonVersionableNode.checkout();
+ fail("Node.checkout() on a non-versionable node must throw UnsupportedRepositoryOperationException");
+ } catch (UnsupportedRepositoryOperationException e) {
+ //success
+ }
+ }
+
+ /**
+ * Test calling VersionManager.checkout(P) with P denoting the absolute
+ * path of a non-versionable node.
+ */
+ public void testCheckoutNonVersionableNodeJcr2() throws RepositoryException {
+ VersionManager versionManager = nonVersionableNode.getSession().getWorkspace().getVersionManager();
+ String path = nonVersionableNode.getPath();
+ try {
+ versionManager.checkout(path);
+ fail("VersionManager.checkout(P) with P denoting the absolute path of a non-versionable node must throw UnsupportedRepositoryOperationException");
+ } catch (UnsupportedRepositoryOperationException e) {
+ //success
+ }
+ }
+
+ /**
+ * Test if Node.checkout() doesn't throw any exception if the versionable
+ * node has been checked out before.
+ */
+ public void testCheckoutTwiceDoesNotThrow() throws RepositoryException {
+ versionableNode.checkout();
+ versionableNode.checkout();
+ }
+
+ /**
+ * 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);
+ }
}
\ No newline at end of file
Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CopyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CopyTest.java?rev=775213&r1=775212&r2=775213&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CopyTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/CopyTest.java Fri May 15 16:15:02 2009
@@ -49,7 +49,7 @@
try {
String dstPath = getProperty("destination");
superuser.getNode(dstPath).remove();
- testRootNode.save();
+ testRootNode.getSession().save();
} catch (Exception e) {
log.println("Exception in tearDown: " + e.toString());
} finally {
Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java?rev=775213&r1=775212&r2=775213&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java Fri May 15 16:15:02 2009
@@ -19,6 +19,7 @@
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.version.Version;
+import javax.jcr.version.VersionManager;
/**
* <code>SVFrozenNodeTest</code> covers tests related to frozen nodes in
@@ -34,18 +35,22 @@
protected void setUp() throws Exception {
super.setUp();
- versionableNode.checkout();
+ VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+ String path = versionableNode.getPath();
+ versionManager.checkout(path);
}
/**
* @throws RepositoryException
*/
public void testFrozenNodeUUUID() throws RepositoryException {
- Version v = versionableNode.checkin();
+ VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+ String path = versionableNode.getPath();
+ Version v = versionManager.checkin(path);
Node n = v.getFrozenNode();
String puuid = n.getProperty(jcrUUID).getValue().getString();
- String nuuid = n.getUUID();
- assertEquals("jcr:uuid needs to be equal to the getUUID() return value.", nuuid, puuid);
+ String nuuid = n.getIdentifier();
+ assertEquals("jcr:uuid needs to be equal to the getIdentifier() return value.", nuuid, puuid);
}
/**
@@ -53,12 +58,14 @@
*/
public void testFrozenChildNodeUUUID() throws RepositoryException {
versionableNode.addNode("child");
- versionableNode.save();
- Version v = versionableNode.checkin();
+ 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.getUUID();
- assertEquals("jcr:uuid needs to be equal to the getUUID() return value.", nuuid, puuid);
+ String nuuid = n.getIdentifier();
+ assertEquals("jcr:uuid needs to be equal to the getIdentifier() return value.", nuuid, puuid);
}
/**
@@ -67,12 +74,14 @@
public void testFrozenUUUID() throws RepositoryException {
// make versionable node referenceable
versionableNode.addMixin(mixReferenceable);
- versionableNode.save();
- Version v = versionableNode.checkin();
+ 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.getUUID();
- assertEquals("jcr:frozenUuid needs to be equal to the getUUID() return value.", ruuid, fuuid);
+ String ruuid = versionableNode.getIdentifier();
+ assertEquals("jcr:frozenUuid needs to be equal to the getIdentifier() return value.", ruuid, fuuid);
}
/**
@@ -81,12 +90,14 @@
public void testFrozenChildUUUID() throws RepositoryException {
Node n1 = versionableNode.addNode("child");
n1.addMixin(mixReferenceable);
- versionableNode.save();
- Version v = versionableNode.checkin();
+ 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 fuuid = n.getProperty(jcrFrozenUuid).getValue().getString();
- String ruuid = n1.getUUID();
- assertEquals("jcr:frozenUuid needs to be equal to the getUUID() return value.", ruuid, fuuid);
+ String ruuid = n1.getIdentifier();
+ assertEquals("jcr:frozenUuid needs to be equal to the getIdentifier() return value.", ruuid, fuuid);
}
@@ -94,7 +105,9 @@
* @throws RepositoryException
*/
public void testFrozenNodeNodeType() throws RepositoryException {
- Version v = versionableNode.checkin();
+ VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+ String path = versionableNode.getPath();
+ Version v = versionManager.checkin(path);
Node n = v.getFrozenNode();
String puuid = n.getProperty(jcrPrimaryType).getValue().getString();
String nuuid = n.getPrimaryNodeType().getName();
@@ -106,8 +119,10 @@
*/
public void testFrozenChildNodeNodeType() throws RepositoryException {
versionableNode.addNode("child");
- versionableNode.save();
- Version v = versionableNode.checkin();
+ 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(jcrPrimaryType).getValue().getString();
String nuuid = n.getPrimaryNodeType().getName();
@@ -118,7 +133,9 @@
* @throws RepositoryException
*/
public void testFrozenNodeType() throws RepositoryException {
- Version v = versionableNode.checkin();
+ 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();
@@ -130,8 +147,10 @@
*/
public void testFrozenChildNodeType() throws RepositoryException {
Node n1 = versionableNode.addNode("child");
- versionableNode.save();
- Version v = versionableNode.checkin();
+ 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 fuuid = n.getProperty("jcr:frozenPrimaryType").getValue().getString();
String ruuid = n1.getPrimaryNodeType().getName();
Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java?rev=775213&r1=775212&r2=775213&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java Fri May 15 16:15:02 2009
@@ -23,10 +23,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.nodetype.NodeDefinition;
-import javax.jcr.version.OnParentVersionAction;
-import javax.jcr.version.Version;
-import javax.jcr.version.VersionException;
-import javax.jcr.version.VersionIterator;
+import javax.jcr.version.*;
import org.apache.jackrabbit.test.NotExecutableException;
@@ -46,6 +43,8 @@
*/
public class RestoreTest extends AbstractVersionTest {
+ VersionManager versionManager;
+
Version version;
Version version2;
Version rootVersion;
@@ -57,17 +56,19 @@
protected void setUp() throws Exception {
super.setUp();
+ versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+ String path = versionableNode.getPath();
propertyValue1 = getProperty("propertyValue1");
- propertyValue2 = getProperty("propertyValue1");
+ propertyValue2 = getProperty("propertyValue2");
versionableNode.setProperty(propertyName1, propertyValue1);
- versionableNode.save();
- version = versionableNode.checkin();
- versionableNode.checkout();
+ versionableNode.getSession().save();
+ version = versionManager.checkin(path);
+ versionManager.checkout(path);
versionableNode.setProperty(propertyName1, propertyValue2);
- versionableNode.save();
- version2 = versionableNode.checkin();
- versionableNode.checkout();
- rootVersion = versionableNode.getVersionHistory().getRootVersion();
+ versionableNode.getSession().save();
+ version2 = versionManager.checkin(path);
+ versionManager.checkout(path);
+ rootVersion = versionManager.getVersionHistory(path).getRootVersion();
// build a second versionable node below the testroot
try {
@@ -80,7 +81,7 @@
protected void tearDown() throws Exception {
try {
versionableNode2.remove();
- testRootNode.save();
+ testRootNode.getSession().save();
} finally {
version = null;
version2 = null;
@@ -105,6 +106,20 @@
}
/**
+ * Test if restoring the root version fails.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreRootVersionFailJcr2() throws RepositoryException {
+ try {
+ versionManager.restore(rootVersion, true);
+ fail("Restore of jcr:rootVersion must throw VersionException.");
+ } catch (VersionException e) {
+ // success
+ }
+ }
+
+ /**
* Test if restoring a node works on checked-in node.
*
* @throws RepositoryException
@@ -115,6 +130,46 @@
}
/**
+ * Test if restoring a node works on checked-in node.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreOnCheckedInNodeJcr2_1() throws RepositoryException {
+ versionManager.checkin(versionableNode.getPath());
+ versionManager.restore(version, true);
+ }
+
+ /**
+ * Test if restoring a node works on checked-in node.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreOnCheckedInNodeJcr2_2() throws RepositoryException {
+ versionManager.checkin(versionableNode.getPath());
+ versionManager.restore(versionableNode.getPath(), version, true);
+ }
+
+ /**
+ * Test if restoring a node works on checked-in node.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreOnCheckedInNodeJcr2_3() throws RepositoryException {
+ versionManager.checkin(versionableNode.getPath());
+ versionManager.restore(versionableNode.getPath(), version.getName(), true);
+ }
+
+ /**
+ * Test if restoring a node works on checked-in node.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreOnCheckedInNodeJcr2_4() throws RepositoryException {
+ versionManager.checkin(versionableNode.getPath());
+ versionManager.restore(new Version[] {version}, true);
+ }
+
+ /**
* Test if restoring a node works on checked-out node.
*
* @throws RepositoryException
@@ -124,28 +179,147 @@
}
/**
+ * Test if restoring a node works on checked-out node.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreOnCheckedOutNodeJcr2() throws RepositoryException {
+ versionManager.restore(version, true);
+ }
+
+ /**
+ * Test if restoring a node works on checked-out node.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreOnCheckedOutNodeJcr2_2() throws RepositoryException {
+ versionManager.restore(versionableNode.getPath(), version, true);
+ }
+
+ /**
+ * Test if restoring a node works on checked-out node.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreOnCheckedOutNodeJcr2_3() throws RepositoryException {
+ versionManager.restore(versionableNode.getPath(), version.getName(), true);
+ }
+
+ /**
+ * Test if restoring a node works on checked-out node.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreOnCheckedOutNodeJcr2_4() throws RepositoryException {
+ versionManager.restore(new Version[] {version}, true);
+ }
+
+ /**
* Restoring a node set the jcr:isCheckedOut property to false.
*
* @throws RepositoryException
*/
public void testRestoreSetsIsCheckedOutToFalse() throws RepositoryException {
versionableNode.restore(version, true);
-
assertFalse("Restoring a node sets the jcr:isCheckedOut property to false", versionableNode.isCheckedOut());
}
/**
+ * Restoring a node set the jcr:isCheckedOut property to false.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreSetsIsCheckedOutToFalseJcr2() throws RepositoryException {
+ versionManager.restore(version, true);
+ assertFalse("Restoring a node sets the jcr:isCheckedOut property to false", versionManager.isCheckedOut(versionableNode.getPath()));
+ }
+
+ /**
+ * Restoring a node set the jcr:isCheckedOut property to false.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreSetsIsCheckedOutToFalseJcr2_2() throws RepositoryException {
+ versionManager.restore(versionableNode.getPath(), version, true);
+ assertFalse("Restoring a node sets the jcr:isCheckedOut property to false", versionManager.isCheckedOut(versionableNode.getPath()));
+ }
+
+ /**
+ * Restoring a node set the jcr:isCheckedOut property to false.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreSetsIsCheckedOutToFalseJcr3() throws RepositoryException {
+ versionManager.restore(versionableNode.getPath(), version.getName(), true);
+ assertFalse("Restoring a node sets the jcr:isCheckedOut property to false", versionManager.isCheckedOut(versionableNode.getPath()));
+ }
+
+ /**
+ * Restoring a node set the jcr:isCheckedOut property to false.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreSetsIsCheckedOutToFalseJcr2_4() throws RepositoryException {
+ versionManager.restore(new Version[] {version}, true);
+ assertFalse("Restoring a node sets the jcr:isCheckedOut property to false", versionManager.isCheckedOut(versionableNode.getPath()));
+ }
+
+ /**
* Test if restoring a node restores the correct property
*
* @throws RepositoryException
*/
- public void testRestoreCorrectVersion() throws RepositoryException {
+ public void testRestoreCorrectProperty() throws RepositoryException {
versionableNode.restore(version, true);
String value = versionableNode.getProperty(propertyName1).getString();
assertEquals("Restoring a node must set the correct property.", propertyValue1, value);
}
/**
+ * Test if restoring a node restores the correct property
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreCorrectPropertyJcr2() throws RepositoryException {
+ versionManager.restore(version, true);
+ String value = versionableNode.getProperty(propertyName1).getString();
+ assertEquals("Restoring a node must set the correct property.", propertyValue1, value);
+ }
+
+ /**
+ * Test if restoring a node restores the correct property
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreCorrectPropertyJcr2_2() throws RepositoryException {
+ versionManager.restore(versionableNode.getPath(), version, true);
+ String value = versionableNode.getProperty(propertyName1).getString();
+ assertEquals("Restoring a node must set the correct property.", propertyValue1, value);
+ }
+
+ /**
+ * Test if restoring a node restores the correct property
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreCorrectPropertyJcr2_3() throws RepositoryException {
+ versionManager.restore(versionableNode.getPath(), version.getName(), true);
+ String value = versionableNode.getProperty(propertyName1).getString();
+ assertEquals("Restoring a node must set the correct property.", propertyValue1, value);
+ }
+
+ /**
+ * Test if restoring a node restores the correct property
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreCorrectPropertyJcr2_4() throws RepositoryException {
+ versionManager.restore(new Version[] {version}, true);
+ String value = versionableNode.getProperty(propertyName1).getString();
+ assertEquals("Restoring a node must set the correct property.", propertyValue1, value);
+ }
+
+ /**
* Test if InvalidItemStateException is thrown if the node has pending changes.
*
* @throws RepositoryException
@@ -163,6 +337,74 @@
}
/**
+ * Test if InvalidItemStateException is thrown if the node has pending changes.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreWithPendingChangesJcr2() throws RepositoryException {
+ // modify node without calling save()
+ try {
+ versionableNode.setProperty(propertyName1, propertyValue);
+ versionManager.restore(version, true);
+
+ fail("InvalidItemStateException must be thrown on attempt to restore a node having any unsaved changes pending.");
+ } catch (InvalidItemStateException e) {
+ // ok
+ }
+ }
+
+ /**
+ * Test if InvalidItemStateException is thrown if the node has pending changes.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreWithPendingChangesJcr2_2() throws RepositoryException {
+ // modify node without calling save()
+ try {
+ versionableNode.setProperty(propertyName1, propertyValue);
+ versionManager.restore(versionableNode.getPath(), version, true);
+
+ fail("InvalidItemStateException must be thrown on attempt to restore a node having any unsaved changes pending.");
+ } catch (InvalidItemStateException e) {
+ // ok
+ }
+ }
+
+ /**
+ * Test if InvalidItemStateException is thrown if the node has pending changes.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreWithPendingChangesJcr2_3() throws RepositoryException {
+ // modify node without calling save()
+ try {
+ versionableNode.setProperty(propertyName1, propertyValue);
+ versionManager.restore(versionableNode.getPath(), version.getName(), true);
+
+ fail("InvalidItemStateException must be thrown on attempt to restore a node having any unsaved changes pending.");
+ } catch (InvalidItemStateException e) {
+ // ok
+ }
+ }
+
+ /**
+ * Test if InvalidItemStateException is thrown if the node has pending changes.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreWithPendingChangesJcr2_4() throws RepositoryException {
+ // modify node without calling save()
+ try {
+ versionableNode.setProperty(propertyName1, propertyValue);
+ versionManager.restore(new Version[] {version}, true);
+
+ fail("InvalidItemStateException must be thrown on attempt to restore a node having any unsaved changes pending.");
+ } catch (InvalidItemStateException e) {
+ // ok
+ }
+ }
+
+ /**
* VersionException expected on Node.restore(Version, boolean) if the
* specified version is not part of this node's version history.
*
@@ -180,6 +422,23 @@
}
/**
+ * VersionException expected on restore if the
+ * specified version is not part of this node's version history.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreInvalidVersionJcr2() throws RepositoryException {
+ Version vNode2 = versionManager.checkin(versionableNode2.getPath());
+ try {
+ versionManager.restore(versionableNode.getPath(), vNode2, true);
+
+ fail("VersionException expected on Node.restore(Version, boolean) if the specified version is not part of this node's version history.");
+ } catch (VersionException e) {
+ // ok
+ }
+ }
+
+ /**
* VersionException expected on Node.restore(String, boolean) if the specified version is not part of this node's version history.
*
* @throws RepositoryException
@@ -206,6 +465,32 @@
}
/**
+ * VersionException expected on Node.restore(String, boolean) if the specified version is not part of this node's version history.
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreInvalidVersion2Jcr2() throws RepositoryException {
+ String invalidName;
+ do {
+ invalidName = createRandomString(3);
+ for (VersionIterator it = versionManager.getVersionHistory(versionableNode.getPath()).getAllVersions(); it.hasNext();) {
+ Version v = it.nextVersion();
+ if (invalidName.equals(v.getName())) {
+ invalidName = null;
+ break;
+ }
+ }
+ } while (invalidName == null);
+
+ try {
+ versionManager.restore(versionableNode.getPath(), invalidName, true);
+ fail("VersionException expected on Node.restore(String, boolean) if the specified version is not part of this node's version history.");
+ } catch (VersionException e) {
+ // ok
+ }
+ }
+
+ /**
* Test calling Node.restore(String, boolean) on a non-versionable node.
*
* @throws RepositoryException
@@ -221,6 +506,36 @@
}
/**
+ * Test restoring on a non-versionable node.
+ *
+ * @throws RepositoryException
+ * @see Node#restore(String, boolean)
+ */
+ public void testRestoreNonVersionableNodeJcr2() throws RepositoryException {
+ try {
+ versionManager.restore(nonVersionableNode.getPath(), version, true);
+ fail("trying to restore on a non versionable node must throw UnsupportedRepositoryOperationException");
+ } catch (UnsupportedRepositoryOperationException e) {
+ //success
+ }
+ }
+
+ /**
+ * Test restoring on a non-versionable node.
+ *
+ * @throws RepositoryException
+ * @see Node#restore(String, boolean)
+ */
+ public void testRestoreNonVersionableNodeJcr2_2() throws RepositoryException {
+ try {
+ versionManager.restore(nonVersionableNode.getPath(), "foo", true);
+ fail("trying to restore on a non versionable node must throw UnsupportedRepositoryOperationException");
+ } catch (UnsupportedRepositoryOperationException e) {
+ //success
+ }
+ }
+
+ /**
* Test calling Node.restore(Version, String, boolean) on a non-versionable node.
*
* @throws RepositoryException
@@ -253,7 +568,37 @@
}
/**
- * Test if restoring a node with an invalid Version throws a VersionException
+ * Test restoring on a non-versionable node.
+ *
+ * @throws RepositoryException
+ * @see Node#restore(Version, boolean)
+ */
+ public void testRestoreNonVersionableNode3Jcr2() throws RepositoryException {
+ try {
+ versionManager.restore(nonVersionableNode.getPath(), version, true);
+ fail("Node.restore(Version, boolean) on a non versionable node must throw UnsupportedRepositoryOperationException");
+ } catch (UnsupportedRepositoryOperationException e) {
+ //success
+ }
+ }
+
+ /**
+ * Test restoring on a non-versionable node.
+ *
+ * @throws RepositoryException
+ * @see Node#restore(Version, boolean)
+ */
+ public void testRestoreNonVersionableNode3Jcr2_2() throws RepositoryException {
+ try {
+ versionManager.restore(nonVersionableNode.getPath(), version.getName(), true);
+ fail("Node.restore(Version, boolean) on a non versionable node must throw UnsupportedRepositoryOperationException");
+ } catch (UnsupportedRepositoryOperationException e) {
+ //success
+ }
+ }
+
+ /**
+ * Test if restoring a node with an invalid Version throws a VersionException
*
* @throws RepositoryException
*/
@@ -268,6 +613,21 @@
}
/**
+ * Test if restoring a node with an invalid Version throws a VersionException
+ *
+ * @throws RepositoryException
+ */
+ public void testRestoreWithInvalidVersionJcr2() throws RepositoryException {
+ Version invalidVersion = versionManager.checkin(versionableNode2.getPath());
+ try {
+ versionManager.restore(versionableNode.getPath(), 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
+ }
+ }
+
+ /**
* Tests if restoring the <code>Version</code> of an existing node throws an
* <code>ItemExistsException</code> if removeExisting is set to FALSE.
*/
@@ -292,9 +652,109 @@
}
}
+ /**
+ * Tests if restoring the <code>Version</code> of an existing node throws an
+ * <code>ItemExistsException</code> if removeExisting is set to FALSE.
+ */
+ public void testRestoreWithUUIDConflictJcr2() throws RepositoryException, NotExecutableException {
+ try {
+ Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
+ // Verify that nodes used for the test have proper opv behaviour
+ NodeDefinition nd = naa.getDefinition();
+ if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
+ throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
+ }
+
+ Version v = versionManager.checkin(versionableNode.getPath());
+ versionManager.checkout(versionableNode.getPath());
+ superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
+ superuser.save();
+ versionManager.restore(v, false);
+
+ fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
+ } catch (ItemExistsException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if restoring the <code>Version</code> of an existing node throws an
+ * <code>ItemExistsException</code> if removeExisting is set to FALSE.
+ */
+ public void testRestoreWithUUIDConflictJcr2_2() throws RepositoryException, NotExecutableException {
+ try {
+ Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
+ // Verify that nodes used for the test have proper opv behaviour
+ NodeDefinition nd = naa.getDefinition();
+ if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
+ throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
+ }
+
+ Version v = versionManager.checkin(versionableNode.getPath());
+ versionManager.checkout(versionableNode.getPath());
+ superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
+ superuser.save();
+ versionManager.restore(versionableNode.getPath(), v, false);
+
+ fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
+ } catch (ItemExistsException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if restoring the <code>Version</code> of an existing node throws an
+ * <code>ItemExistsException</code> if removeExisting is set to FALSE.
+ */
+ public void testRestoreWithUUIDConflictJcr2_3() throws RepositoryException, NotExecutableException {
+ try {
+ Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
+ // Verify that nodes used for the test have proper opv behaviour
+ NodeDefinition nd = naa.getDefinition();
+ if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
+ throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
+ }
+
+ Version v = versionManager.checkin(versionableNode.getPath());
+ versionManager.checkout(versionableNode.getPath());
+ superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
+ superuser.save();
+ versionManager.restore(versionableNode.getPath(), v.getName(), false);
+
+ fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
+ } catch (ItemExistsException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if restoring the <code>Version</code> of an existing node throws an
+ * <code>ItemExistsException</code> if removeExisting is set to FALSE.
+ */
+ public void testRestoreWithUUIDConflictJcr2_4() throws RepositoryException, NotExecutableException {
+ try {
+ Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
+ // Verify that nodes used for the test have proper opv behaviour
+ NodeDefinition nd = naa.getDefinition();
+ if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
+ throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
+ }
+
+ Version v = versionManager.checkin(versionableNode.getPath());
+ versionManager.checkout(versionableNode.getPath());
+ superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
+ superuser.save();
+ versionManager.restore(new Version[] {v}, false);
+
+ fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
+ } catch (ItemExistsException e) {
+ // success
+ }
+ }
+
public void testRestoreChild1() throws RepositoryException {
versionableNode.addNode("child1");
- versionableNode.save();
+ versionableNode.getSession().save();
Version v1 = versionableNode.checkin();
versionableNode.checkout();
Version v2 = versionableNode.checkin();
@@ -312,6 +772,86 @@
}
}
+ public void testRestoreChild1Jcr2() 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.");
+ }
+ }
+
+ 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(versionableNode.getPath(), v1, true);
+ assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
+
+ versionManager.restore(versionableNode.getPath(), version, true);
+ assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
+
+ try {
+ versionManager.restore(versionableNode.getPath(), v2, true);
+ } catch (RepositoryException e) {
+ fail("Node.restore('1.3') must fail.");
+ }
+ }
+
+ 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.");
+ }
+ }
+
+ public void testRestoreChild1Jcr2_4() 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(new Version[] {v1}, true);
+ assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
+
+ versionManager.restore(new Version[] {version}, true);
+ assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
+
+ try {
+ versionManager.restore(new Version[] {v2}, true);
+ } catch (RepositoryException e) {
+ fail("Node.restore('1.3') must fail.");
+ }
+ }
+
/**
* Test the restore of a versionable node using a label.
* @throws RepositoryException
@@ -327,6 +867,20 @@
}
/**
+ * Test the restore of a versionable node using a label.
+ * @throws RepositoryException
+ */
+ public void testRestoreLabelJcr2() throws RepositoryException {
+ // mark V1 with label test1
+ versionManager.getVersionHistory(versionableNode.getPath()).addVersionLabel(version.getName(), "test", true);
+
+ // restore V1 via label.
+ versionManager.restoreByLabel(versionableNode.getPath(), "test", true);
+ String value = versionableNode.getProperty(propertyName1).getString();
+ assertEquals("Node.restore('test') not correctly restored", propertyValue1, value);
+ }
+
+ /**
* Test the restore of the OPV=Version child nodes.
* @throws RepositoryException
*/
@@ -336,7 +890,7 @@
if (!child1.isNodeType(mixVersionable)) {
child1.addMixin(mixVersionable);
}
- versionableNode.save();
+ versionableNode.getSession().save();
// create v1.0 of child
Version v1Child = child1.checkin();
@@ -368,6 +922,47 @@
}
/**
+ * Test the restore of the OPV=Version child nodes.
+ * @throws RepositoryException
+ */
+ public void testRestoreNameJcr2() throws RepositoryException {
+ // V1.0 of versionableNode has no child
+ Node child1 = versionableNode.addNode(nodeName4);
+ if (!child1.isNodeType(mixVersionable)) {
+ child1.addMixin(mixVersionable);
+ }
+ versionableNode.getSession().save();
+ // create v1.0 of child
+ Version v1Child = child1.checkin();
+
+ // V1 of versionable node has child1
+ String v1 = versionManager.checkin(versionableNode.getPath()).getName();
+
+ // create V1.1 of child
+ versionManager.checkout(child1.getPath());
+ Version v11Child = versionManager.checkin(child1.getPath());
+
+ // V2 of versionable node has child1
+ versionManager.checkout(versionableNode.getPath());
+ String v2 = versionManager.checkin(versionableNode.getPath()).getName();
+
+ // restore 1.0 of versionable node --> no child
+ versionManager.restore(version, true);
+ assertFalse("restore must remove child node.", versionableNode.hasNode(nodeName4));
+
+ // restore V1 via name. since child was checkin first, 1.0 should be restored
+ versionManager.restore(versionableNode.getPath(), v1, true);
+ assertTrue("restore must restore child node.", versionableNode.hasNode(nodeName4));
+ child1 = versionableNode.getNode(nodeName4);
+ assertEquals("restore must restore child node version 1.0.", v1Child.getName(), versionManager.getBaseVersion(child1.getPath()).getName());
+
+ // restore V2 via name. child should be 1.1
+ versionManager.restore(versionableNode.getPath(), v2, true);
+ child1 = versionableNode.getNode(nodeName4);
+ assertEquals("Node.restore('foo') must restore child node version 1.1.", v11Child.getName(), versionManager.getBaseVersion(child1.getPath()).getName());
+ }
+
+ /**
* Test the child ordering of restored nodes.
* @throws RepositoryException
*/
@@ -375,7 +970,7 @@
// create a test-root that has orderable child nodes
Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
testRoot.addMixin(mixVersionable);
- versionableNode.save();
+ versionableNode.getSession().save();
// create children of vNode and checkin
Node child1 = testRoot.addNode(nodeName1);
@@ -386,7 +981,7 @@
if (!child2.isNodeType(mixVersionable)) {
child2.addMixin(mixVersionable);
}
- testRoot.save();
+ testRoot.getSession().save();
child1.checkin();
child2.checkin();
Version v1 = testRoot.checkin();
@@ -394,7 +989,7 @@
// remove node 1
testRoot.checkout();
child1.remove();
- testRoot.save();
+ testRoot.getSession().save();
testRoot.checkin();
// restore version 1.0
@@ -415,11 +1010,11 @@
* Test the child ordering of restored nodes.
* @throws RepositoryException
*/
- public void testRestoreOrder2() throws RepositoryException {
+ public void testRestoreOrderJcr2() throws RepositoryException {
// create a test-root that has orderable child nodes
Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
testRoot.addMixin(mixVersionable);
- versionableNode.save();
+ versionableNode.getSession().save();
// create children of vNode and checkin
Node child1 = testRoot.addNode(nodeName1);
@@ -430,19 +1025,19 @@
if (!child2.isNodeType(mixVersionable)) {
child2.addMixin(mixVersionable);
}
- testRoot.save();
- child1.checkin();
- child2.checkin();
- Version v1 = testRoot.checkin();
+ testRoot.getSession().save();
+ versionManager.checkin(child1.getPath());
+ versionManager.checkin(child2.getPath());
+ Version v1 = versionManager.checkin(testRoot.getPath());
- // reoder nodes
- testRoot.checkout();
- testRoot.orderBefore(nodeName2, nodeName1);
- testRoot.save();
- testRoot.checkin();
+ // remove node 1
+ versionManager.checkout(testRoot.getPath());
+ child1.remove();
+ testRoot.getSession().save();
+ versionManager.checkout(testRoot.getPath());
// restore version 1.0
- testRoot.restore(v1, true);
+ versionManager.restore(v1, true);
// check order
NodeIterator iter = testRoot.getNodes();
@@ -456,23 +1051,479 @@
}
/**
- * Tests if restore on simple versioning creates a new version that is
- * in the correct linear order.
+ * Test the child ordering of restored nodes.
+ * @throws RepositoryException
*/
- public void testLinearVersions() throws Exception {
- // first get all linear versions
- VersionIterator iter = versionableNode.getVersionHistory().getAllLinearVersions();
- StringBuffer expected = new StringBuffer();
- while (iter.hasNext()) {
- expected.append(iter.nextVersion().getName()).append(",");
+ public void testRestoreOrderJcr2_2() throws RepositoryException {
+ // create a test-root that has orderable child nodes
+ Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
+ testRoot.addMixin(mixVersionable);
+ versionableNode.getSession().save();
+
+ // create children of vNode and checkin
+ Node child1 = testRoot.addNode(nodeName1);
+ if (!child1.isNodeType(mixVersionable)) {
+ child1.addMixin(mixVersionable);
}
- // restore version
- versionableNode.restore(version, true);
- // append new base version
- expected.append(versionableNode.getBaseVersion().getName()).append(",");
+ Node child2 = testRoot.addNode(nodeName2);
+ if (!child2.isNodeType(mixVersionable)) {
+ child2.addMixin(mixVersionable);
+ }
+ testRoot.getSession().save();
+ versionManager.checkin(child1.getPath());
+ versionManager.checkin(child2.getPath());
+ Version v1 = versionManager.checkin(testRoot.getPath());
- // get the version names again
- iter = versionableNode.getVersionHistory().getAllLinearVersions();
+ // remove node 1
+ versionManager.checkout(testRoot.getPath());
+ child1.remove();
+ testRoot.getSession().save();
+ versionManager.checkout(testRoot.getPath());
+
+ // restore version 1.0
+ versionManager.restore(testRoot.getPath(), 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);
+ }
+
+ /**
+ * Test the child ordering of restored nodes.
+ * @throws RepositoryException
+ */
+ public void testRestoreOrderJcr2_3() throws RepositoryException {
+ // create a test-root that has orderable child nodes
+ Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
+ testRoot.addMixin(mixVersionable);
+ versionableNode.getSession().save();
+
+ // create children of vNode and checkin
+ Node child1 = testRoot.addNode(nodeName1);
+ if (!child1.isNodeType(mixVersionable)) {
+ child1.addMixin(mixVersionable);
+ }
+ Node child2 = testRoot.addNode(nodeName2);
+ if (!child2.isNodeType(mixVersionable)) {
+ child2.addMixin(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(testRoot.getPath(), v1.getName(), 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);
+ }
+
+ /**
+ * Test the child ordering of restored nodes.
+ * @throws RepositoryException
+ */
+ public void testRestoreOrderJcr2_4() throws RepositoryException {
+ // create a test-root that has orderable child nodes
+ Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
+ testRoot.addMixin(mixVersionable);
+ versionableNode.getSession().save();
+
+ // create children of vNode and checkin
+ Node child1 = testRoot.addNode(nodeName1);
+ if (!child1.isNodeType(mixVersionable)) {
+ child1.addMixin(mixVersionable);
+ }
+ Node child2 = testRoot.addNode(nodeName2);
+ if (!child2.isNodeType(mixVersionable)) {
+ child2.addMixin(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(new Version[] {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);
+ }
+
+ /**
+ * Test the child ordering of restored nodes.
+ * @throws RepositoryException
+ */
+ public void testRestoreOrder2() throws RepositoryException {
+ // create a test-root that has orderable child nodes
+ Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
+ testRoot.addMixin(mixVersionable);
+ versionableNode.getSession().save();
+
+ // create children of vNode and checkin
+ Node child1 = testRoot.addNode(nodeName1);
+ if (!child1.isNodeType(mixVersionable)) {
+ child1.addMixin(mixVersionable);
+ }
+ Node child2 = testRoot.addNode(nodeName2);
+ if (!child2.isNodeType(mixVersionable)) {
+ child2.addMixin(mixVersionable);
+ }
+ testRoot.getSession().save();
+ child1.checkin();
+ child2.checkin();
+ Version v1 = testRoot.checkin();
+
+ // reoder nodes
+ testRoot.checkout();
+ testRoot.orderBefore(nodeName2, nodeName1);
+ testRoot.getSession().save();
+ testRoot.checkin();
+
+ // restore version 1.0
+ testRoot.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);
+ }
+
+ /**
+ * Test the child ordering of restored nodes.
+ * @throws RepositoryException
+ */
+ public void testRestoreOrder2Jcr2() throws RepositoryException {
+ // create a test-root that has orderable child nodes
+ Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
+ testRoot.addMixin(mixVersionable);
+ versionableNode.getSession().save();
+
+ // create children of vNode and checkin
+ Node child1 = testRoot.addNode(nodeName1);
+ if (!child1.isNodeType(mixVersionable)) {
+ child1.addMixin(mixVersionable);
+ }
+ Node child2 = testRoot.addNode(nodeName2);
+ if (!child2.isNodeType(mixVersionable)) {
+ child2.addMixin(mixVersionable);
+ }
+ testRoot.getSession().save();
+ versionManager.checkin(child1.getPath());
+ versionManager.checkin(child2.getPath());
+ Version v1 = versionManager.checkin(testRoot.getPath());
+
+ // reoder nodes
+ versionManager.checkout(testRoot.getPath());
+ testRoot.orderBefore(nodeName2, nodeName1);
+ testRoot.getSession().save();
+ versionManager.checkin(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);
+ }
+
+ /**
+ * Test the child ordering of restored nodes.
+ * @throws RepositoryException
+ */
+ public void testRestoreOrder2Jcr2_2() throws RepositoryException {
+ // create a test-root that has orderable child nodes
+ Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
+ testRoot.addMixin(mixVersionable);
+ versionableNode.getSession().save();
+
+ // create children of vNode and checkin
+ Node child1 = testRoot.addNode(nodeName1);
+ if (!child1.isNodeType(mixVersionable)) {
+ child1.addMixin(mixVersionable);
+ }
+ Node child2 = testRoot.addNode(nodeName2);
+ if (!child2.isNodeType(mixVersionable)) {
+ child2.addMixin(mixVersionable);
+ }
+ testRoot.getSession().save();
+ versionManager.checkin(child1.getPath());
+ versionManager.checkin(child2.getPath());
+ Version v1 = versionManager.checkin(testRoot.getPath());
+
+ // reoder nodes
+ versionManager.checkout(testRoot.getPath());
+ testRoot.orderBefore(nodeName2, nodeName1);
+ testRoot.getSession().save();
+ versionManager.checkin(testRoot.getPath());
+
+ // restore version 1.0
+ versionManager.restore(testRoot.getPath(), 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);
+ }
+
+ /**
+ * Test the child ordering of restored nodes.
+ * @throws RepositoryException
+ */
+ public void testRestoreOrder2Jcr2_3() throws RepositoryException {
+ // create a test-root that has orderable child nodes
+ Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
+ testRoot.addMixin(mixVersionable);
+ versionableNode.getSession().save();
+
+ // create children of vNode and checkin
+ Node child1 = testRoot.addNode(nodeName1);
+ if (!child1.isNodeType(mixVersionable)) {
+ child1.addMixin(mixVersionable);
+ }
+ Node child2 = testRoot.addNode(nodeName2);
+ if (!child2.isNodeType(mixVersionable)) {
+ child2.addMixin(mixVersionable);
+ }
+ testRoot.getSession().save();
+ versionManager.checkin(child1.getPath());
+ versionManager.checkin(child2.getPath());
+ Version v1 = versionManager.checkin(testRoot.getPath());
+
+ // reoder nodes
+ versionManager.checkout(testRoot.getPath());
+ testRoot.orderBefore(nodeName2, nodeName1);
+ testRoot.getSession().save();
+ versionManager.checkin(testRoot.getPath());
+
+ // restore version 1.0
+ versionManager.restore(testRoot.getPath(), 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);
+ }
+
+ /**
+ * Test the child ordering of restored nodes.
+ * @throws RepositoryException
+ */
+ public void testRestoreOrder2Jcr2_4() throws RepositoryException {
+ // create a test-root that has orderable child nodes
+ Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
+ testRoot.addMixin(mixVersionable);
+ versionableNode.getSession().save();
+
+ // create children of vNode and checkin
+ Node child1 = testRoot.addNode(nodeName1);
+ if (!child1.isNodeType(mixVersionable)) {
+ child1.addMixin(mixVersionable);
+ }
+ Node child2 = testRoot.addNode(nodeName2);
+ if (!child2.isNodeType(mixVersionable)) {
+ child2.addMixin(mixVersionable);
+ }
+ testRoot.getSession().save();
+ versionManager.checkin(child1.getPath());
+ versionManager.checkin(child2.getPath());
+ Version v1 = versionManager.checkin(testRoot.getPath());
+
+ // reoder nodes
+ versionManager.checkout(testRoot.getPath());
+ testRoot.orderBefore(nodeName2, nodeName1);
+ testRoot.getSession().save();
+ versionManager.checkin(testRoot.getPath());
+
+ // restore version 1.0
+ versionManager.restore(new Version[] {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);
+ }
+
+ /**
+ * Tests if restore on simple versioning creates a new version that is
+ * in the correct linear order.
+ */
+ public void testLinearVersions() throws Exception {
+ // first get all linear versions
+ VersionIterator iter = versionableNode.getVersionHistory().getAllLinearVersions();
+ StringBuffer expected = new StringBuffer();
+ while (iter.hasNext()) {
+ expected.append(iter.nextVersion().getName()).append(",");
+ }
+ // restore version
+ versionableNode.restore(version, true);
+ // append new base version
+ expected.append(versionableNode.getBaseVersion().getName()).append(",");
+
+ // get the version names again
+ iter = versionableNode.getVersionHistory().getAllLinearVersions();
+ StringBuffer actual = new StringBuffer();
+ while (iter.hasNext()) {
+ actual.append(iter.nextVersion().getName()).append(",");
+ }
+ assertEquals("Node.restore() on simple versioning must create a new version.",
+ expected.toString(), actual.toString());
+ }
+
+ /**
+ * Tests if restore on simple versioning creates a new version that is
+ * in the correct linear order.
+ */
+ public void testLinearVersionsJcr2() throws Exception {
+ // first get all linear versions
+ VersionIterator iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
+ StringBuffer expected = new StringBuffer();
+ while (iter.hasNext()) {
+ expected.append(iter.nextVersion().getName()).append(",");
+ }
+ // restore version
+ versionManager.restore(version, true);
+ // append new base version
+ expected.append(versionManager.getBaseVersion(versionableNode.getPath()).getName()).append(",");
+
+ // get the version names again
+ iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
+ StringBuffer actual = new StringBuffer();
+ while (iter.hasNext()) {
+ actual.append(iter.nextVersion().getName()).append(",");
+ }
+ assertEquals("Node.restore() on simple versioning must create a new version.",
+ expected.toString(), actual.toString());
+ }
+
+ /**
+ * Tests if restore on simple versioning creates a new version that is
+ * in the correct linear order.
+ */
+ public void testLinearVersionsJcr2_2() throws Exception {
+ // first get all linear versions
+ VersionIterator iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
+ StringBuffer expected = new StringBuffer();
+ while (iter.hasNext()) {
+ expected.append(iter.nextVersion().getName()).append(",");
+ }
+ // restore version
+ versionManager.restore(versionableNode.getPath(), version, true);
+ // append new base version
+ expected.append(versionManager.getBaseVersion(versionableNode.getPath()).getName()).append(",");
+
+ // get the version names again
+ iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
+ StringBuffer actual = new StringBuffer();
+ while (iter.hasNext()) {
+ actual.append(iter.nextVersion().getName()).append(",");
+ }
+ assertEquals("Node.restore() on simple versioning must create a new version.",
+ expected.toString(), actual.toString());
+ }
+
+ /**
+ * Tests if restore on simple versioning creates a new version that is
+ * in the correct linear order.
+ */
+ public void testLinearVersionsJcr2_3() throws Exception {
+ // first get all linear versions
+ VersionIterator iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
+ StringBuffer expected = new StringBuffer();
+ while (iter.hasNext()) {
+ expected.append(iter.nextVersion().getName()).append(",");
+ }
+ // restore version
+ versionManager.restore(versionableNode.getPath(), version.getName(), true);
+ // append new base version
+ expected.append(versionManager.getBaseVersion(versionableNode.getPath()).getName()).append(",");
+
+ // get the version names again
+ iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
+ StringBuffer actual = new StringBuffer();
+ while (iter.hasNext()) {
+ actual.append(iter.nextVersion().getName()).append(",");
+ }
+ assertEquals("Node.restore() on simple versioning must create a new version.",
+ expected.toString(), actual.toString());
+ }
+
+ /**
+ * Tests if restore on simple versioning creates a new version that is
+ * in the correct linear order.
+ */
+ public void testLinearVersionsJcr2_4() throws Exception {
+ // first get all linear versions
+ VersionIterator iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
+ StringBuffer expected = new StringBuffer();
+ while (iter.hasNext()) {
+ expected.append(iter.nextVersion().getName()).append(",");
+ }
+ // restore version
+ versionManager.restore(new Version[] {version}, true);
+ // append new base version
+ expected.append(versionManager.getBaseVersion(versionableNode.getPath()).getName()).append(",");
+
+ // get the version names again
+ iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
StringBuffer actual = new StringBuffer();
while (iter.hasNext()) {
actual.append(iter.nextVersion().getName()).append(",");