jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r792142 [24/35] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrab...
Date Wed, 08 Jul 2009 13:57:46 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/HoldTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/HoldTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/HoldTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/HoldTest.java Wed Jul  8 13:57:13 2009
@@ -230,7 +230,7 @@
     }
 
     public void testReadOnlySession() throws NotExecutableException, RepositoryException {
-        javax.jcr.Session s = helper.getReadOnlySession();
+        javax.jcr.Session s = getHelper().getReadOnlySession();
         try {
             RetentionManager rmgr = getRetentionManager(s);
             try {
@@ -256,7 +256,7 @@
         List holdsBefore = Arrays.asList(retentionMgr.getHolds(child.getPath()));
 
         // get another session.
-        javax.jcr.Session otherS = helper.getSuperuserSession();
+        javax.jcr.Session otherS = getHelper().getSuperuserSession();
         try {
             RetentionManager rmgr = getRetentionManager(otherS);            
             rmgr.addHold(child.getPath(), getHoldName(), false);
@@ -284,7 +284,7 @@
         Hold h = retentionMgr.addHold(child.getPath(), getHoldName(), false);
         testRootNode.save();
 
-        javax.jcr.Session otherS = helper.getSuperuserSession();
+        javax.jcr.Session otherS = getHelper().getSuperuserSession();
         try {
             RetentionManager rmgr = getRetentionManager(otherS);
             Hold[] holds = rmgr.getHolds(child.getPath());
@@ -312,13 +312,7 @@
     private Node getLockedChildNode() throws NotExecutableException, RepositoryException {
         checkSupportedOption(Repository.OPTION_LOCKING_SUPPORTED);
         Node child = testRootNode.addNode(nodeName2, testNodeType);
-        if (!child.isNodeType(mixLockable)) {
-            if (child.canAddMixin(mixLockable)) {
-                child.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException();
-            }
-        }
+        ensureMixinType(child, mixLockable);
         testRootNode.save();
         child.lock(false, true); // session-scoped lock clean upon superuser-logout.
         return child;
@@ -330,7 +324,7 @@
         child.checkin();
 
         // get another session.
-        javax.jcr.Session otherS = helper.getSuperuserSession();
+        javax.jcr.Session otherS = getHelper().getSuperuserSession();
         try {
             RetentionManager rmgr = getRetentionManager(otherS);
             rmgr.addHold(child.getPath(), getHoldName(), false);
@@ -362,7 +356,7 @@
         // checkin on the parent node make the hold-containing node checked-in.
         vn.checkin();
 
-        javax.jcr.Session otherS = helper.getSuperuserSession();
+        javax.jcr.Session otherS = getHelper().getSuperuserSession();
         try {
             RetentionManager rmgr = getRetentionManager(otherS);
             Hold[] holds = rmgr.getHolds(n.getPath());
@@ -391,13 +385,7 @@
     private Node getVersionableChildNode() throws NotExecutableException, RepositoryException {
         checkSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
         Node child = testRootNode.addNode(nodeName2, testNodeType);
-        if (!child.isNodeType(mixVersionable)) {
-            if (child.canAddMixin(mixVersionable)) {
-                child.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException();
-            }
-        }
+        ensureMixinType(child, mixVersionable);
         testRootNode.save();
         return child;
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyEffectTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyEffectTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyEffectTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyEffectTest.java Wed Jul  8 13:57:13 2009
@@ -43,7 +43,7 @@
         childP = testRootNode.setProperty(propertyName1, v);
         superuser.save();
 
-        otherS = helper.getSuperuserSession();
+        otherS = getHelper().getSuperuserSession();
     }
 
     protected void tearDown() throws Exception {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyTest.java Wed Jul  8 13:57:13 2009
@@ -234,7 +234,7 @@
     }
 
     public void testReadOnlySession() throws NotExecutableException, RepositoryException {
-        Session s = helper.getReadOnlySession();
+        Session s = getHelper().getReadOnlySession();
         try {
             RetentionManager rmgr = getRetentionManager(s);
             try {
@@ -258,7 +258,7 @@
         String childPath = getLockedChildNode().getPath();
 
         // get another session.
-        Session otherS = helper.getSuperuserSession();
+        Session otherS = getHelper().getSuperuserSession();
         try {
             RetentionManager rmgr = getRetentionManager(otherS);
             rmgr.setRetentionPolicy(childPath, getApplicableRetentionPolicy());
@@ -282,7 +282,7 @@
         retentionMgr.setRetentionPolicy(childPath, getApplicableRetentionPolicy());
         testRootNode.save();
 
-        Session otherS = helper.getSuperuserSession();
+        Session otherS = getHelper().getSuperuserSession();
         try {
             RetentionManager rmgr = getRetentionManager(otherS);
             rmgr.removeRetentionPolicy(childPath);
@@ -305,13 +305,7 @@
     private Node getLockedChildNode() throws NotExecutableException, RepositoryException {
         checkSupportedOption(Repository.OPTION_LOCKING_SUPPORTED);
         Node child = testRootNode.addNode(nodeName2, testNodeType);
-        if (!child.isNodeType(mixLockable)) {
-            if (child.canAddMixin(mixLockable)) {
-                child.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException();
-            }
-        }
+        ensureMixinType(child, mixLockable);
         testRootNode.save();
         child.lock(false, true); // session-scoped lock clean upon superuser-logout.
         return child;
@@ -324,7 +318,7 @@
         String childPath = child.getPath();
 
         // get another session.
-        Session otherS = helper.getSuperuserSession();
+        Session otherS = getHelper().getSuperuserSession();
         try {
             RetentionManager rmgr = getRetentionManager(otherS);
             rmgr.setRetentionPolicy(childPath, getApplicableRetentionPolicy());
@@ -353,7 +347,7 @@
         superuser.save();
         child.checkin();
 
-        Session otherS = helper.getSuperuserSession();
+        Session otherS = getHelper().getSuperuserSession();
         try {
             RetentionManager rmgr = getRetentionManager(otherS);
             rmgr.removeRetentionPolicy(child.getPath());
@@ -378,13 +372,7 @@
     private Node getVersionableChildNode() throws NotExecutableException, RepositoryException {
         checkSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
         Node child = testRootNode.addNode(nodeName2, testNodeType);
-        if (!child.isNodeType(mixVersionable)) {
-            if (child.canAddMixin(mixVersionable)) {
-                child.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException();
-            }
-        }
+        ensureMixinType(child, mixVersionable);
         testRootNode.save();
         return child;
     }
@@ -414,7 +402,7 @@
         Node childN = testRootNode.addNode(nodeName2);
         superuser.save();
 
-        Session otherS = helper.getSuperuserSession();
+        Session otherS = getHelper().getSuperuserSession();
         try {
             retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
             superuser.save();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java Wed Jul  8 13:57:13 2009
@@ -70,7 +70,7 @@
                 throw new NotExecutableException("No supported privileges at absPath " + path);
             }
 
-            testPrincipal = helper.getKnownPrincipal(superuser);
+            testPrincipal = getHelper().getKnownPrincipal(superuser);
             
             // remember existing entries for test-principal -> later restore.
             privilegesToRestore = currentPrivileges(getList(acMgr, path), testPrincipal);
@@ -146,10 +146,6 @@
             assertTrue("An ACE must contain at least a single privilege", privs != null && privs.length > 0);
         }
     }
-    
-    public void testFoo() {
-        throw new RuntimeException("LALALA");
-    }
 
     public void testAddAccessControlEntry() throws NotExecutableException, RepositoryException {
         checkCanModifyAc(path);
@@ -317,7 +313,7 @@
     public void testAddAccessControlEntryInvalidPrincipal() throws NotExecutableException, RepositoryException {
         checkCanModifyAc(path);
         try {
-            Principal invalidPrincipal = helper.getUnknownPrincipal(superuser);
+            Principal invalidPrincipal = getHelper().getUnknownPrincipal(superuser);
             AccessControlList acl = getList(acMgr, path);
             acl.addAccessControlEntry(invalidPrincipal, privs);
             fail("Adding an entry with an unknown principal must throw AccessControlException.");

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java Wed Jul  8 13:57:13 2009
@@ -273,7 +273,7 @@
 
         Session s2 = null;
         try {
-            s2 = helper.getSuperuserSession();
+            s2 = getHelper().getSuperuserSession();
             List plcs = Arrays.asList(getAccessControlManager(s2).getPolicies(path));
             // TODO: check again if policies can be compared with equals!
             assertTrue("Policy must be visible to another superuser session.", plcs.contains(policy));

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java Wed Jul  8 13:57:13 2009
@@ -40,7 +40,7 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        readOnlySession = helper.getReadOnlySession();
+        readOnlySession = getHelper().getReadOnlySession();
         testAcMgr = getAccessControlManager(readOnlySession);
         testPath = testRootNode.getPath();
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlPolicyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlPolicyTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlPolicyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlPolicyTest.java Wed Jul  8 13:57:13 2009
@@ -45,7 +45,7 @@
         superuser.save();
         path = n.getPath();
 
-        readOnlySession = helper.getReadOnlySession();
+        readOnlySession = getHelper().getReadOnlySession();
         testAcMgr = getAccessControlManager(readOnlySession);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlTest.java Wed Jul  8 13:57:13 2009
@@ -46,7 +46,7 @@
         testPropertyPath = p.getPath();
         testRootNode.save();
 
-        readOnlySession = helper.getReadOnlySession();
+        readOnlySession = getHelper().getReadOnlySession();
     }
 
     protected void tearDown() throws Exception {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractMergeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractMergeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractMergeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractMergeTest.java Wed Jul  8 13:57:13 2009
@@ -96,7 +96,7 @@
         }
 
         // initialise a new session on second workspace as superuser
-        superuserW2 = helper.getSuperuserSession(workspaceName);
+        superuserW2 = getHelper().getSuperuserSession(workspaceName);
 
         workspace = superuser.getWorkspace();
         workspaceW2 = superuserW2.getWorkspace();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java Wed Jul  8 13:57:13 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.test.api.version;
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
 
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -132,11 +133,10 @@
      * @return versionable node.
      * @throws RepositoryException
      */
-    protected Node createVersionableNode(Node parent, String name, NodeType nodetype) throws RepositoryException {
+    protected Node createVersionableNode(Node parent, String name, NodeType nodetype)
+            throws RepositoryException, NotExecutableException {
         Node versionableNode = parent.addNode(name, nodetype.getName());
-        if (!nodetype.isNodeType(mixVersionable)) {
-            versionableNode.addMixin(mixVersionable);
-        }
+        ensureMixinType(versionableNode, mixVersionable);
         parent.save();
 
         return versionableNode;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/FrozenNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/FrozenNodeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/FrozenNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/FrozenNodeTest.java Wed Jul  8 13:57:13 2009
@@ -21,6 +21,8 @@
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionManager;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>CheckinTest</code> covers tests related to {@link javax.jcr.Node#checkin()}.
  *
@@ -70,9 +72,10 @@
     /**
      * @throws RepositoryException
      */
-    public void testFrozenUUUID() throws RepositoryException {
+    public void testFrozenUUUID() throws RepositoryException,
+            NotExecutableException {
         // make versionable node referenceable
-        versionableNode.addMixin(mixReferenceable);
+        ensureMixinType(versionableNode, mixReferenceable);
         versionableNode.getSession().save();
         VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
         String path = versionableNode.getPath();
@@ -86,9 +89,10 @@
     /**
      * @throws RepositoryException
      */
-    public void testFrozenChildUUUID() throws RepositoryException {
+    public void testFrozenChildUUUID() throws RepositoryException,
+            NotExecutableException {
         Node n1 = versionableNode.addNode("child");
-        n1.addMixin(mixReferenceable);
+        ensureMixinType(n1, mixReferenceable);
         versionableNode.getSession().save();
         VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
         String path = versionableNode.getPath();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetReferencesNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetReferencesNodeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetReferencesNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetReferencesNodeTest.java Wed Jul  8 13:57:13 2009
@@ -99,12 +99,11 @@
         assertFalse(nodeToBeReferencedIsReference);
     }
 
-    private void initTestNodes() throws RepositoryException {
+    private void initTestNodes() throws RepositoryException,
+            NotExecutableException {
         // create a versionable node with reference property
         testNode = testRootNode.addNode(nodeName1, versionableNodeType);
-        if (needsMixin(testNode, mixVersionable)) {
-          testNode.addMixin(mixVersionable);
-        }
+        ensureMixinType(testNode, mixVersionable);
 
         // node to be referenced, does not have to be versionable
         nodeToBeReferenced = testRootNode.addNode(nodeName2, versionableNodeType);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeCancelMergeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeCancelMergeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeCancelMergeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeCancelMergeTest.java Wed Jul  8 13:57:13 2009
@@ -21,6 +21,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.version.Version;
+import javax.jcr.version.VersionManager;
 
 /**
  * <code>MergeCancelMergeTest</code> contains tests dealing with nodes on which
@@ -43,7 +44,8 @@
 
         nodeToMerge = testRootNodeW2.getNode(nodeName1);
         // node has to be checked out while merging
-        nodeToMerge.checkout();
+        VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        versionManager.checkout(nodeToMerge.getPath());
     }
 
     protected void tearDown() throws Exception {
@@ -99,15 +101,19 @@
      * initialize a versionable node on default and second workspace
      */
     protected void initNodes() throws RepositoryException {
+
+        VersionManager versionManager = testRootNode.getSession().getWorkspace().getVersionManager();
+
         // create a versionable node
         // nodeName1
         Node topVNode = testRootNode.addNode(nodeName1, versionableNodeType);
         topVNode.setProperty(propertyName1, topVNode.getName());
+        String path = topVNode.getPath();
 
         // save default workspace
-        testRootNode.save();
-        topVNode.checkin();
-        topVNode.checkout();
+        testRootNode.getSession().save();
+        versionManager.checkin(path);
+        versionManager.checkout(path);
 
         log.println("test nodes created successfully on " + workspace.getName());
 
@@ -117,4 +123,52 @@
 
         testRootNodeW2 = (Node) superuserW2.getItem(testRoot);
     }
+
+    /**
+     * Merge.cancelMerge(V): has the effect of removing the reference to V' from
+     * the jcr:mergeFailed property of N. <br> without adding it to
+     * jcr:predecessors.<br> Branches will not be joined.<br>
+     */
+    public void testMergeNodeCancelMergeJcr2() throws RepositoryException {
+        // create 2 independent versions for a node and its corresponding node
+        // so merge fails for this node
+    
+        // default workspace
+        Node originalNode = testRootNode.getNode(nodeName1);
+        VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
+        String originalPath = originalNode.getPath();
+        vmWsp1.checkout(originalPath);
+        vmWsp1.checkin(originalPath);
+    
+        // second workspace
+        VersionManager vmWsp2 = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        String path = nodeToMerge.getPath();
+        vmWsp2.checkin(path);
+    
+        // "merge" the clonedNode with the newNode from the default workspace
+        vmWsp2.checkout(path);
+        vmWsp2.merge(path, workspace.getName(), true);
+    
+        // get predecessors
+        Version[] predecessors = vmWsp2.getBaseVersion(path).getPredecessors();
+        // get mergeFailed property
+        Property mergeFailedProperty = nodeToMerge.getProperty(jcrMergeFailed);
+        Value[] mergeFailedReferences = mergeFailedProperty.getValues();
+    
+        for (int i = 0; i < mergeFailedReferences.length; i++) {
+            String id = mergeFailedReferences[i].getString();
+            vmWsp2.cancelMerge(path, (Version) superuser.getNodeByIdentifier(id));
+        }
+    
+        // check predecessors - unchanged
+        Version[] predecessorsAfterCancel = vmWsp2.getBaseVersion(path).getPredecessors();
+        assertTrue(predecessors.length == predecessorsAfterCancel.length);
+    
+        // check mergeFailed property - reference removed
+        if (nodeToMerge.hasProperty(jcrMergeFailed)) {
+            Property mergeFailedPropertyAfterCancelMerge = nodeToMerge.getProperty(jcrMergeFailed);
+            Value[] mergeFailedReferencesAfterCancelMerge = mergeFailedPropertyAfterCancelMerge.getValues();
+            assertTrue(mergeFailedReferences.length > mergeFailedReferencesAfterCancelMerge.length);
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeCheckedoutSubNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeCheckedoutSubNodeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeCheckedoutSubNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeCheckedoutSubNodeTest.java Wed Jul  8 13:57:13 2009
@@ -19,6 +19,7 @@
 import javax.jcr.MergeException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.version.VersionManager;
 
 /**
  * <code>MergeCheckedoutSubNodeTest</code> contains tests dealing with
@@ -41,7 +42,8 @@
 
         nodeToMerge = testRootNodeW2.getNode(nodeName1);
         // node has to be checked out while merging
-        nodeToMerge.checkout();
+        VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        versionManager.checkout(nodeToMerge.getPath());
     }
 
     protected void tearDown() throws Exception {
@@ -74,6 +76,31 @@
     }
 
     /**
+     * VersionManager.merge(): If V' of a versionable subnode N' in the source workspace
+     * is a successor of V (the base version of a subnode N in this workspace),
+     * calling merge must fail.
+     */
+    public void testFailIfCorrespondingNodeIsSuccessorJcr2() throws RepositoryException {
+        // make V' of a subnode N' in source workspace be a successor version of
+        // the base version of the corresponding subnode.
+        Node n = testRootNode.getNode(nodeName1 + "/" + nodeName2);
+        VersionManager versionManager = n.getSession().getWorkspace().getVersionManager();
+        String path = n.getPath();
+        versionManager.checkout(path);
+        versionManager.checkin(path);
+        versionManager.checkout(path);
+
+        try {
+            // merge, besteffort set to false to stop at the first failure
+            nodeToMerge.getSession().getWorkspace().getVersionManager().merge(nodeToMerge.getPath(), workspace.getName(), false);
+            fail("Merging a checkedout node if the version V' of the corresponding node is a successor of this node's base version must fail.");
+
+        } catch (MergeException e) {
+            // success
+        }
+    }
+
+    /**
      * Node.merge(): If V' of a versionable subnode N' in the source workspace
      * is a predeccessor of V or V' identical to V (the base version of a
      * subnode N in this workspace), calling merge must be leave.
@@ -97,6 +124,30 @@
     }
 
     /**
+     * VersionManager.merge(): If V' of a versionable subnode N' in the source workspace
+     * is a predeccessor of V or V' identical to V (the base version of a
+     * subnode N in this workspace), calling merge must be leave.
+     */
+    public void testLeaveIfCorrespondingNodeIsPredeccessorJcr2() throws RepositoryException {
+        // make V' of a subnode N' in source workspace be a predeccessor version of
+        // the base version of the corresponding subnode.
+        Node n = testRootNodeW2.getNode(nodeName1 + "/" + nodeName2);
+        VersionManager versionManager = n.getSession().getWorkspace().getVersionManager();
+        String path = n.getPath();
+        versionManager.checkout(path);
+        n.setProperty(propertyName1, CHANGED_STRING);
+        testRootNodeW2.getSession().save();
+        versionManager.checkin(path);
+        versionManager.checkout(path);
+
+        // merge, besteffort set to false to stop at the first failure
+        nodeToMerge.getSession().getWorkspace().getVersionManager().merge(nodeToMerge.getPath(), workspace.getName(), false);
+
+        // check if subnode has status "leave"
+        assertTrue(n.getProperty(propertyName1).getString().equals(CHANGED_STRING));
+    }
+
+    /**
      * initialize a two-step-hierarchy on default and second workspace
      */
     protected void initNodes() throws RepositoryException {
@@ -111,7 +162,7 @@
         subNvNode.setProperty(propertyName1, subNvNode.getName());
 
         // save default workspace
-        testRootNode.save();
+        testRootNode.getSession().save();
 
         log.println("test nodes created successfully on " + workspace.getName());
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeDoneMergeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeDoneMergeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeDoneMergeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeDoneMergeTest.java Wed Jul  8 13:57:13 2009
@@ -21,6 +21,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.version.Version;
+import javax.jcr.version.VersionManager;
 
 /**
  * <code>MergeDoneMergeTest</code> contains test dealing with nodes on which
@@ -42,7 +43,8 @@
 
         nodeToMerge = testRootNodeW2.getNode(nodeName1);
         // node has to be checked out while merging
-        nodeToMerge.checkout();
+        VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        versionManager.checkout(nodeToMerge.getPath());
 
     }
 
@@ -92,18 +94,66 @@
     }
 
     /**
+     * VersionManager.doneMerge(V) throws VersionException if V is not among the Vs in the
+     * jcr:mergeFailed prop. <br> with adding it to jcr:predecessors.<br>
+     * Branches will be joined.<br>
+     */
+    public void testMergeNodeDoneMergeJcr2() throws RepositoryException {
+        // create 2 independent versions for a node and its corresponding node
+        // so merge fails for this node
+
+        // default workspace
+        Node originalNode = testRootNode.getNode(nodeName1);
+        VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
+        String originalPath = originalNode.getPath();
+        vmWsp1.checkout(originalPath);
+        vmWsp1.checkin(originalPath);
+
+        // second workspace
+        VersionManager vmWsp2 = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        String path = nodeToMerge.getPath();
+        vmWsp2.checkin(path);
+
+        // "merge" the clonedNode with the newNode from the default workspace
+        vmWsp2.checkout(path);
+        vmWsp2.merge(path, workspace.getName(), true);
+
+        // get predecessors
+        Version[] predecessors = nodeToMerge.getBaseVersion().getPredecessors();
+        // get mergeFailed property
+        Property mergeFailedProperty = nodeToMerge.getProperty(jcrMergeFailed);
+        Value[] mergeFailedReferences = mergeFailedProperty.getValues();
+
+        for (int i = 0; i < mergeFailedReferences.length; i++) {
+            String id = mergeFailedReferences[i].getString();
+            vmWsp2.doneMerge(path, (Version) superuser.getNodeByIdentifier(id));
+        }
+
+        // check mergeFailed property - reference moved to predecessor
+        if (nodeToMerge.hasProperty(jcrMergeFailed)) {
+            Property mergeFailedPropertyAfterCancelMerge = nodeToMerge.getProperty(jcrMergeFailed);
+            Value[] mergeFailedReferencesAfterCancelMerge = mergeFailedPropertyAfterCancelMerge.getValues();
+            assertTrue(mergeFailedReferences.length > mergeFailedReferencesAfterCancelMerge.length);
+        }
+    }
+
+    /**
      * initialize a versionable node on default and second workspace
      */
     protected void initNodes() throws RepositoryException {
+
+        VersionManager versionManager = testRootNode.getSession().getWorkspace().getVersionManager();
+
         // create a versionable node
         // nodeName1
         Node topVNode = testRootNode.addNode(nodeName1, versionableNodeType);
         topVNode.setProperty(propertyName1, topVNode.getName());
+        String path = topVNode.getPath();
 
         // save default workspace
-        testRootNode.save();
-        topVNode.checkin();
-        topVNode.checkout();
+        testRootNode.getSession().save();
+        versionManager.checkin(path);
+        versionManager.checkout(path);
 
         log.println("test nodes created successfully on " + workspace.getName());
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeIteratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeIteratorTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeIteratorTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeIteratorTest.java Wed Jul  8 13:57:13 2009
@@ -18,6 +18,7 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Node;
+import javax.jcr.version.VersionManager;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -86,12 +87,56 @@
     }
 
     /**
+     * Tests if VersionManager.merge() when bestEffort is true returns a NodeIterator
+     * containing all nodes that received a fail.
+     */
+    public void testNodeIteratorJcr2() throws RepositoryException {
+
+        Node nodeToMerge = testRootNodeW2.getNode(nodeName1);
+
+        Iterator failedNodes = nodeToMerge.getSession().getWorkspace().getVersionManager().merge(
+                nodeToMerge.getPath(), workspace.getName(), true);
+
+        List nodeList = new ArrayList();
+        while (failedNodes.hasNext()) {
+            nodeList.add(failedNodes.next());
+        }
+
+        assertEquals("Node.merge() does not return a NodeIterator with " +
+                "expected number of elements.",
+                expectedFailedNodes.length,
+                nodeList.size());
+
+        // re-aquire iterator, has been consumed to get size
+        failedNodes = nodeList.iterator();
+        compareReturnedWithExpected:
+        while (failedNodes.hasNext()) {
+            String path = ((Node) failedNodes.next()).getPath();
+            for (int i = 0; i < expectedFailedNodes.length; i++) {
+                if (expectedFailedNodes[i] != null) {
+                    String expectedPath = expectedFailedNodes[i].getPath();
+                    if (path.equals(expectedPath)) {
+                        // to assure every failed node appears only once in the
+                        // NodeIterator, set each found expected node to null
+                        expectedFailedNodes[i] = null;
+                        continue compareReturnedWithExpected;
+                    }
+                }
+            }
+            fail("Node.merge() must return a NodeIterator over all " +
+                    "nodes that did receive a result of fail.");
+        }
+    }
+
+    /**
      * initialize some versionable nodes on default and second workspace
      */
     protected void initNodes() throws RepositoryException {
 
         // create some versionable node in default workspace (WS1)
 
+        VersionManager versionManager = testRootNode.getSession().getWorkspace().getVersionManager();
+
         Node mergeRootNode = testRootNode.addNode(nodeName1, versionableNodeType);
 
         Node nodeWS1_1 = mergeRootNode.addNode(nodeName1, versionableNodeType);
@@ -100,23 +145,22 @@
         Node nodeWS1_2Sub1 = nodeWS1_2.addNode(nodeName1, versionableNodeType);
         Node nodeWS1_3 = mergeRootNode.addNode(nodeName3, versionableNodeType);
 
-        testRootNode.save();
-
-        nodeWS1_1.checkin(); // create version 1.0
-        nodeWS1_1.checkout();
+        testRootNode.getSession().save();
 
-        nodeWS1_1Sub1.checkin(); // create version 1.0
-        nodeWS1_1Sub1.checkout();
+        versionManager.checkin(nodeWS1_1.getPath()); // create version 1.0
+        versionManager.checkout(nodeWS1_1.getPath());
 
-        nodeWS1_2.checkin(); // create version 1.0
-        nodeWS1_2.checkout();
+        versionManager.checkin(nodeWS1_1Sub1.getPath()); // create version 1.0
+        versionManager.checkout(nodeWS1_1Sub1.getPath());
 
-        nodeWS1_2Sub1.checkin(); // create version 1.0
-        nodeWS1_2Sub1.checkout();
+        versionManager.checkin(nodeWS1_2.getPath()); // create version 1.0
+        versionManager.checkout(nodeWS1_2.getPath());
 
-        nodeWS1_3.checkin(); // create version 1.0
-        nodeWS1_3.checkout();
+        versionManager.checkin(nodeWS1_2Sub1.getPath()); // create version 1.0
+        versionManager.checkout(nodeWS1_2Sub1.getPath());
 
+        versionManager.checkin(nodeWS1_3.getPath()); // create version 1.0
+        versionManager.checkout(nodeWS1_3.getPath());
 
         workspaceW2.clone(workspace.getName(), mergeRootNode.getPath(), mergeRootNode.getPath(), true);
 
@@ -127,14 +171,14 @@
 
         // create version branches for some of the nodes
 
-        nodeWS2_1.checkin(); // create version 1.1
-        nodeWS1_1.checkin(); // create version 1.0.1
+        versionManager.checkin(nodeWS2_1.getPath()); // create version 1.1
+        versionManager.checkin(nodeWS1_1.getPath()); // create version 1.0.1
 
-        nodeWS2_2.checkin(); // create version 1.1
-        nodeWS1_2.checkin(); // create version 1.0.1
+        versionManager.checkin(nodeWS2_2.getPath()); // create version 1.1
+        versionManager.checkin(nodeWS1_2.getPath()); // create version 1.0.1
 
-        nodeWS2_2Sub1.checkin(); // create version 1.1
-        nodeWS1_2Sub1.checkin(); // create version 1.0.1
+        versionManager.checkin(nodeWS2_2Sub1.getPath()); // create version 1.1
+        versionManager.checkin(nodeWS1_2Sub1.getPath()); // create version 1.0.1
 
         // set the nodes with version branches in expectedFailedNodes
         expectedFailedNodes[0] = nodeWS1_1;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeTest.java Wed Jul  8 13:57:13 2009
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.test.NotExecutableException;
 
 import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionManager;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.InvalidItemStateException;
@@ -52,7 +53,8 @@
 
         nodeToMerge = testRootNodeW2.getNode(nodeName1);
         // node has to be checked out while merging
-        nodeToMerge.checkout();
+        VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        versionManager.checkout(nodeToMerge.getPath());
 
     }
 
@@ -77,6 +79,22 @@
     }
 
     /**
+     * VersionManager.merge(): InvalidItemStateException if unsaved changes within the
+     * current Session<br>
+     */
+    public void testMergeNodeWithUnsavedStatesJcr2() throws RepositoryException {
+        // set a property and do not save workspace
+        nodeToMerge.setProperty(propertyName1, CHANGED_STRING);
+        try {
+            nodeToMerge.getSession().getWorkspace().getVersionManager().merge(
+                    nodeToMerge.getPath(), workspace.getName(), false);
+            fail("InvalidItemStateException if unsaved changes within the current Session was expected.");
+        } catch (InvalidItemStateException e) {
+            // success
+        }
+    }
+
+    /**
      * Perform a merge on a node with a unkwnown workspacename
      */
     public void testMergeUnknownWorkspaceName() throws RepositoryException {
@@ -88,6 +106,18 @@
     }
 
     /**
+     * Perform a merge on a node with a unkwnown workspacename
+     */
+    public void testMergeUnknownWorkspaceNameJcr2() throws RepositoryException {
+        try {
+            nodeToMerge.getSession().getWorkspace().getVersionManager().merge(
+                    nodeToMerge.getPath(), getNonExistingWorkspaceName(superuser), false);
+        } catch (NoSuchWorkspaceException e) {
+            // success expected exception
+        }
+    }
+
+    /**
      * Node.merge(): If this node does not have a corresponding node in the
      * indicated workspace <br> then the merge method returns quietly and no
      * changes are made.<br>
@@ -104,6 +134,24 @@
     }
 
     /**
+     * VersionManager.merge(): If this node does not have a corresponding node in the
+     * indicated workspace <br> then the merge method returns quietly and no
+     * changes are made.<br>
+     */
+    public void testMergeNodeNonCorrespondingNodeJcr2() throws RepositoryException {
+        // create new node - this node has no corresponding node in default workspace
+        Node subNode = nodeToMerge.addNode(nodeName3, versionableNodeType);
+        subNode.setProperty(propertyName1, CHANGED_STRING);
+        superuserW2.save();
+        VersionManager versionManager = subNode.getSession().getWorkspace().getVersionManager();
+        String path = subNode.getPath();
+        versionManager.checkin(path);
+
+        versionManager.merge(path, workspace.getName(), true);
+        assertTrue(subNode.getProperty(propertyName1).getString().equals(CHANGED_STRING));
+    }
+
+    /**
      * Node.merge(): versionable subNode N checked-in: If V is neither a
      * successor of, predecessor of, nor identical with V', then the merge
      * result for N is failed<br>
@@ -132,6 +180,38 @@
     }
 
     /**
+     * VersionManager.merge(): versionable subNode N checked-in: If V is neither a
+     * successor of, predecessor of, nor identical with V', then the merge
+     * result for N is failed<br>
+     */
+    public void testMergeNodeVersionAmbiguousJcr2() throws RepositoryException {
+        // create 2 independent versions for a node and its corresponding node
+        // so merge fails for this node
+
+        // default workspace
+        Node originalNode = testRootNode.getNode(nodeName1);
+        VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
+        String originalPath = originalNode.getPath();
+        vmWsp1.checkout(originalPath);
+        vmWsp1.checkin(originalPath);
+
+        // second workspace
+        VersionManager vmWsp2 = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        String path = nodeToMerge.getPath();
+        vmWsp2.checkin(path);
+
+        // "merge" the clonedNode with the newNode from the default workspace
+        // besteffort set to false to stop at the first failure
+        try {
+            vmWsp2.checkout(path);
+            vmWsp2.merge(path, workspace.getName(), false);
+            fail("Node has ambigous versions. Merge must throw a MergeException");
+        } catch (MergeException e) {
+            // success if the merge exception thrown
+        }
+    }
+
+    /**
      * Node.merge(): bestEffort is true > any merge-failure (represented by the
      * version in the workspace) is reported in the jcrMergeFailed property<br>
      */
@@ -172,6 +252,50 @@
     }
 
     /**
+     * VersionManager.merge(): bestEffort is true > any merge-failure (represented by the
+     * version in the workspace) is reported in the jcrMergeFailed property<br>
+     */
+    public void testMergeNodeBestEffortTrueCheckMergeFailedPropertyJcr2() throws RepositoryException {
+        // create 2 independent versions for a node and its corresponding node
+        // so merge fails for this node
+
+        // default workspace
+        Node originalNode = testRootNode.getNode(nodeName1);
+        VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
+        String originalPath = originalNode.getPath();
+        vmWsp1.checkout(originalPath);
+        vmWsp1.checkin(originalPath);
+
+        // second workspace
+        VersionManager vmWsp2 = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        String path = nodeToMerge.getPath();
+        vmWsp2.checkin(path);
+
+        // "merge" the clonedNode with the newNode from the default workspace
+        // besteffort set to true to report all failures
+        vmWsp2.checkout(path);
+        vmWsp2.merge(path, workspace.getName(), true);
+
+        // success merge exception was raised as expected
+        // jcrMergeFailed should contains reference to the V' as it is a different branche
+        String expectedReferenceUUID = originalNode.getBaseVersion().getUUID();
+        Property mergeFailedProperty = nodeToMerge.getProperty(jcrMergeFailed);
+        Value[] references = mergeFailedProperty.getValues();
+        boolean referenceFound = false;
+        if (references != null) {
+            for (int i = 0; i < references.length; i++) {
+                String referenceUUID = references[i].getString();
+                if (referenceUUID.equals(expectedReferenceUUID)) {
+                    referenceFound = true;
+                    break; // it's not necessary to loop thru all the references
+                }
+            }
+
+            assertTrue("reference to expected version that give the failure wasnt found in the mergeFailed", referenceFound);
+        }
+    }
+
+    /**
      * if mergeFailedProperty is present > VersionException<br>
      */
     public void disable_testMergeNodeForceFailure() throws RepositoryException {
@@ -200,6 +324,38 @@
     }
 
     /**
+     * if mergeFailedProperty is present > VersionException<br>
+     */
+    public void disable_testMergeNodeForceFailureJcr2() throws RepositoryException {
+        // create 2 independent versions for a node and its corresponding node
+        // so merge fails for this node
+
+        // default workspace
+        Node originalNode = testRootNode.getNode(nodeName1);
+        VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
+        String originalPath = originalNode.getPath();
+        vmWsp1.checkout(originalPath);
+        vmWsp1.checkin(originalPath);
+
+        // second workspace
+        VersionManager vmWsp2 = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        String path = nodeToMerge.getPath();
+        vmWsp2.checkin(path);
+
+        // "merge" the clonedNode with the newNode from the default workspace
+        // besteffort set to true to report all failures
+        vmWsp2.checkout(path);
+        vmWsp2.merge(path, workspace.getName(), true);
+
+        try {
+            vmWsp2.merge(path, workspace.getName(), true);
+            fail("Merge failed for node in earlier merge operations. Because the mergeFailedProperty is present, merge must throw a VersionException");
+        } catch (VersionException e) {
+            // success version exception expected
+        }
+    }
+
+    /**
      * Node.merge(): bestEffort is false and any merge fails a MergeException is
      * thrown.<br>
      */
@@ -223,6 +379,32 @@
     }
 
     /**
+     * VersionManager.merge(): bestEffort is false and any merge fails a MergeException is
+     * thrown.<br>
+     */
+    public void testMergeNodeBestEffortFalseJcr2() throws RepositoryException {
+        /// create successor versions for a node
+        // so merge fails for this node
+
+        // default workspace
+        Node originalNode = testRootNode.getNode(nodeName1);
+        VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
+        String originalPath = originalNode.getPath();
+        vmWsp1.checkout(originalPath);
+        vmWsp1.checkin(originalPath);
+
+        // "merge" the clonedNode with the newNode from the default workspace
+        // merge, besteffort set to false
+        try {
+            nodeToMerge.getSession().getWorkspace().getVersionManager().merge(
+                    nodeToMerge.getPath(), workspace.getName(), false);
+            fail("bestEffort is false and any merge should throw a MergeException.");
+        } catch (MergeException e) {
+            // successful
+        }
+    }
+
+    /**
      * A MergeVersionException is thrown if bestEffort is false and a
      * versionable node is encountered whose corresponding node's base version
      * is on a divergent branch from this node's base version.
@@ -252,6 +434,39 @@
     }
 
     /**
+     * A MergeVersionException is thrown if bestEffort is false and a
+     * versionable node is encountered whose corresponding node's base version
+     * is on a divergent branch from this node's base version.
+     */
+    public void testMergeNodeBestEffortFalseAmbiguousVersionsJcr2() throws RepositoryException {
+        /// create 2 independent base versions for a node and its corresponding node
+        // so merge fails for this node
+
+        // default workspace
+        Node originalNode = testRootNode.getNode(nodeName1);
+        VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
+        String originalPath = originalNode.getPath();
+        vmWsp1.checkout(originalPath);
+        vmWsp1.checkin(originalPath);
+
+        // second workspace
+        VersionManager vmWsp2 = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        String path = nodeToMerge.getPath();
+        vmWsp2.checkin(path);
+
+        // "merge" the clonedNode with the newNode from the default workspace
+        vmWsp2.checkout(path);
+
+        // merge, besteffort set to false
+        try {
+            vmWsp2.merge(path, workspace.getName(), false);
+            fail("BestEffort is false and corresponding node's version is ambiguous. Merge should throw a MergeException.");
+        } catch (MergeException e) {
+            // successful
+        }
+    }
+
+    /**
      * Tests if a {@link LockException} is thrown when merge is called on a
      * locked node.
      * @throws NotExecutableException if repository does not support locking.
@@ -259,28 +474,19 @@
     public void disable_testMergeLocked()
             throws NotExecutableException, RepositoryException {
 
-        Session session = testRootNode.getSession();
-
         if (!isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
             throw new NotExecutableException("Locking is not supported.");
         }
 
         // try to make nodeToMerge lockable if it is not
-        if (!nodeToMerge.isNodeType(mixLockable)) {
-            if (nodeToMerge.canAddMixin(mixLockable)) {
-                nodeToMerge.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException("Node " + nodeToMerge.getName() + " is not lockable and " +
-                        "does not allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(nodeToMerge, mixLockable);
         nodeToMerge.getParent().save();
 
         // lock the node
         // remove first slash of path to get rel path to root
         String pathRelToRoot = nodeToMerge.getPath().substring(1);
         // access node through another session to lock it
-        Session session2 = helper.getSuperuserSession();
+        Session session2 = getHelper().getSuperuserSession();
         try {
             Node node2 = session2.getRootNode().getNode(pathRelToRoot);
             node2.lock(false, false);
@@ -300,18 +506,62 @@
     }
 
     /**
+     * Tests if a {@link LockException} is thrown when merge is called on a
+     * locked node.
+     * @throws NotExecutableException if repository does not support locking.
+     */
+    public void disable_testMergeLockedJcr2()
+            throws NotExecutableException, RepositoryException {
+
+        if (!isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
+            throw new NotExecutableException("Locking is not supported.");
+        }
+
+        // try to make nodeToMerge lockable if it is not
+        ensureMixinType(nodeToMerge, mixLockable);
+        nodeToMerge.getParent().getSession().save();
+
+        // lock the node
+        // remove first slash of path to get rel path to root
+        String pathRelToRoot = nodeToMerge.getPath().substring(1);
+        // access node through another session to lock it
+        Session session2 = getHelper().getSuperuserSession();
+        try {
+            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
+            node2.getSession().getWorkspace().getLockManager().lock(node2.getPath(), false, false, 60, "");
+
+            try {
+                nodeToMerge.getSession().getWorkspace().getVersionManager().merge(
+                        nodeToMerge.getPath(), workspace.getName(), false);
+                fail("merge must throw a LockException if applied on a " +
+                        "locked node");
+            } catch (LockException e) {
+                // success
+            }
+
+            node2.getSession().getWorkspace().getLockManager().unlock(node2.getPath());
+        } finally {
+            session2.logout();
+        }
+    }
+
+    /**
      * initialize a versionable node on default and second workspace
      */
     protected void initNodes() throws RepositoryException {
+
+        VersionManager versionManager = testRootNode.getSession().getWorkspace().getVersionManager();
+
         // create a versionable node
         // nodeName1
         Node topVNode = testRootNode.addNode(nodeName1, versionableNodeType);
         topVNode.setProperty(propertyName1, topVNode.getName());
+        String path = topVNode.getPath();
 
         // save default workspace
-        testRootNode.save();
-        topVNode.checkin();
-        topVNode.checkout();
+        testRootNode.getSession().save();
+        versionManager.checkin(path);
+        versionManager.checkout(path);
 
         log.println("test nodes created successfully on " + workspace.getName());
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNonVersionableSubNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNonVersionableSubNodeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNonVersionableSubNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNonVersionableSubNodeTest.java Wed Jul  8 13:57:13 2009
@@ -58,6 +58,30 @@
     }
 
     /**
+     * VersionManager.merge(): nonversionable subNode N: if it has no versionable
+     * ancestor, then it is updated to reflect the state of its corresponding
+     * node.<br>
+     */
+    public void testMergeNodeNonVersionableSubNodeNonVersionableAncestorJcr2() throws RepositoryException {
+        String nodeToMergePath = nodeName1 + "/" + nodeName2 + "/" + nodeName3;
+
+        // node to merge in second workspace
+        Node nodeToMerge = testRootNodeW2.getNode(nodeToMergePath);
+        // corresponding node to nodeToMerge in default workspace
+        Node correspondingNode = testRootNode.getNode(nodeToMergePath);
+
+        // modify value for non'v node in workspace2 so we can check if node in workspace2 after merge is updated
+        // to reflect the state of its corresponding node in default workspace....
+        nodeToMerge.setProperty(propertyName1, CHANGED_STRING);
+        nodeToMerge.getSession().save();
+        nodeToMerge.getSession().getWorkspace().getVersionManager().merge(
+                nodeToMerge.getPath(), workspace.getName(), true);
+
+        // test if modification on non-v node is done according to corresponding node.
+        assertTrue(nodeToMerge.getProperty(propertyName1).getString().equals(correspondingNode.getName()));
+    }
+
+    /**
      * Node.merge(): nonversionable subNode N: if the merge result of its
      * nearest versionable ancestor is update,<br> then it is updated to reflect
      * the state of its corresponding node.<br>
@@ -91,6 +115,39 @@
     }
 
     /**
+     * VersionManager.merge(): nonversionable subNode N: if the merge result of its
+     * nearest versionable ancestor is update,<br> then it is updated to reflect
+     * the state of its corresponding node.<br>
+     */
+    public void testMergeNodeNonVersionableSubNodeUpdateJcr2() throws RepositoryException {
+        // modify non versionable subnode so we can check if it's updated after merge
+        String changedString = CHANGED_STRING + System.currentTimeMillis();
+        String nvSubNodePath = nodeName2 + "/" + nodeName3;
+
+        // versionable ancestor to merge in first workspace (N)
+        Node n = testRootNodeW2.getNode(nodeName1);
+
+        // versionable ancestor to merge in second workspace (N')
+        Node np = testRootNodeW2.getNode(nodeName1);
+
+        // checkout N and make change
+        n.getSession().getWorkspace().getVersionManager().checkout(n.getPath());
+        Node nvSubNode = n.getNode(nvSubNodePath);
+        nvSubNode.setProperty(propertyName1, changedString);
+        n.getSession().save();
+        n.getSession().getWorkspace().getVersionManager().checkin(n.getPath());
+
+        // merge change into N'
+        np.getSession().getWorkspace().getVersionManager().merge(np.getPath(), workspaceW2.getName(), true);
+
+        // corresponding node to nvSubNode in 2nd workspace
+        Node nvSubNodeP = np.getNode(nvSubNodePath);
+
+        // test if modification on N was merged into N' subnode
+        assertTrue(nvSubNodeP.getProperty(propertyName1).getString().equals(changedString));
+    }
+
+    /**
      * Node.merge(): nonversionable subNode N: is left unchanged if the nearest
      * versionable ancestor has state leave.<br>
      */
@@ -123,6 +180,38 @@
     }
 
     /**
+     * VersionManager.merge(): nonversionable subNode N: is left unchanged if the nearest
+     * versionable ancestor has state leave.<br>
+     */
+    public void testMergeNodeNonVersionableSubNodeLeaveJcr2() throws RepositoryException {
+        // modify non versionable subnode so we can check if it's updated after merge
+        String changedString = CHANGED_STRING + System.currentTimeMillis();
+        String nvSubNodePath = nodeName2 + "/" + nodeName3;
+
+        // versionable ancestor to merge in first workspace (N)
+        Node n = testRootNodeW2.getNode(nodeName1);
+
+        // versionable ancestor to merge in second workspace (N')
+        Node np = testRootNodeW2.getNode(nodeName1);
+
+        // checkout N' and make change
+        np.getSession().getWorkspace().getVersionManager().checkout(np.getPath());
+        Node nvSubNodeP = np.getNode(nvSubNodePath);
+        nvSubNodeP.setProperty(propertyName1, changedString);
+        np.getSession().save();
+        np.getSession().getWorkspace().getVersionManager().checkin(np.getPath());
+
+        // merge into N'
+        np.getSession().getWorkspace().getVersionManager().merge(np.getPath(), workspaceW2.getName(), true);
+
+        // corresponding node to nvSubNode in 2nd workspace
+        Node nvSubNode = np.getNode(nvSubNodePath);
+
+        // test if modification on N' was not modified
+        assertTrue(nvSubNode.getProperty(propertyName1).getString().equals(changedString));
+    }
+
+    /**
      * initialize a three-step-hierarchy on default and second workspace
      */
     protected void initNodes() throws RepositoryException {
@@ -142,7 +231,7 @@
         subSubNvNode.setProperty(propertyName1, subSubNvNode.getName());
 
         // save default workspace
-        testRootNode.save();
+        testRootNode.getSession().save();
 
         log.println("test nodes created successfully on " + workspace.getName());
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeSubNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeSubNodeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeSubNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeSubNodeTest.java Wed Jul  8 13:57:13 2009
@@ -19,6 +19,7 @@
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
+import javax.jcr.version.VersionManager;
 
 /**
  * <code>MergeSubNodeTest</code> contains tests dealing with sub nodes in the
@@ -42,7 +43,8 @@
 
         nodeToMerge = testRootNodeW2.getNode(nodeName1);
         // node has to be checked out while merging
-        nodeToMerge.checkout();
+        VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        versionManager.checkout(nodeToMerge.getPath());
 
     }
 
@@ -82,6 +84,40 @@
     }
 
     /**
+     * VersionManager.merge(): versionable subNode N: If N has status leave but parent is
+     * update, then the subnode N is removed<br> retrieve the initialised node
+     * to perform operations we need before for this test<br>
+     */
+    public void disable_testRemoveNodeFromSourceWorkspaceAndMergeWithUpdateJcr2() throws RepositoryException {
+        // status 'update' for parent
+        VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        String path = nodeToMerge.getPath();
+        versionManager.checkin(path);
+        versionManager.checkout(path);
+
+        // status 'leave' for subnode
+        Node originalNode = testRootNode.getNode(nodeName1);
+        Node originalSubNode = originalNode.getNode(nodeName2);
+        VersionManager originalVersionManager = originalSubNode.getSession().getWorkspace().getVersionManager();
+        String originalSubPath = originalSubNode.getPath();
+        originalVersionManager.checkout(originalSubPath);
+        originalVersionManager.checkin(originalSubPath);
+
+        // "merge" the nodeToMerge with the newNode from the default workspace
+        // besteffort set to false to stop at the first failure
+        versionManager.merge(path, workspace.getName(), false);
+
+        // if merge passed newSubNode1 should be also removed from workspace2
+        assertFalse("subNode1 not removed from " + workspaceW2.getName() + " as expected", nodeToMerge.hasNode(nodeName2));
+
+        // return version info about the clonedNode as it must also be updated
+        final String originalBaseVersionId = originalVersionManager.getBaseVersion(originalNode.getPath()).getIdentifier();
+        final String clonedBaseVersionId = versionManager.getBaseVersion(path).getIdentifier();
+
+        assertTrue("clonedNode has different version UUID than expected, it should be updated with the newNode version UUID", originalBaseVersionId.equals(clonedBaseVersionId));
+    }
+
+    /**
      * Node.merge(): versionable subNode N checked-in: If V' is a successor (to
      * any degree) of V, then the merge result for N is update<br> modify a node
      * on the workspace1 and then merge the one in workspace2 with the one in
@@ -104,7 +140,35 @@
         final String clonedBaseVersionUUID = nodeToMerge.getBaseVersion().getUUID();
 
         assertTrue("clonedNode has different version UUID than expected, it should be updated with the newNode version UUID", originalBaseVersionUUID.equals(clonedBaseVersionUUID));
+    }
+
+    /**
+     * VersionManager.merge(): versionable subNode N checked-in: If V' is a successor (to
+     * any degree) of V, then the merge result for N is update<br> modify a node
+     * on the workspace1 and then merge the one in workspace2 with the one in
+     * workspace1 precondition is that the node in workspace2 is checked in
+     */
+    public void disable_testMergeNodeFromUpdatedSourceWorkspaceJcr2() throws RepositoryException {
+        Node originalNode = testRootNode.getNode(nodeName1);
+        VersionManager originalVersionManager = originalNode.getSession().getWorkspace().getVersionManager();
+        String originalPath = originalNode.getPath();
+
+        // update nodeName1 on workspace1
+        originalVersionManager.checkout(originalPath);
+        originalVersionManager.checkin(originalPath);
+
+        testRootNode.getSession().save();
+
+        // "merge" the clonedNode with the newNode from the default workspace
+        // besteffort set to false to stop at the first failure
+        VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        String path = nodeToMerge.getPath();
+        versionManager.merge(path, workspace.getName(), false);
+
+        final String originalBaseVersionId = originalVersionManager.getBaseVersion(originalPath).getIdentifier();
+        final String clonedBaseVersionId = versionManager.getBaseVersion(path).getIdentifier();
 
+        assertTrue("clonedNode has different version UUID than expected, it should be updated with the newNode version UUID", originalBaseVersionId.equals(clonedBaseVersionId));
     }
 
     /**
@@ -130,6 +194,32 @@
     }
 
     /**
+     * VersionManager.merge(): versionable subNode N checked-in: If V' is a predecessor
+     * (to any degree) of V or if V and V' are identical (i.e., are actually the
+     * same version), then the merge result for N is leave<br> modify a node on
+     * the workspace2 and then merge the one in workspace2 with the one in
+     * workspace1<br> the node in workspace2 should be updated<br> precondition
+     * is that the node in workspace2 is checked in
+     */
+    public void testMergeNodeFromOlderSourceWorkspaceJcr2() throws RepositoryException {
+
+        VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        String path = nodeToMerge.getPath();
+
+        // touch the version on workspace2
+        versionManager.checkin(path);
+        versionManager.checkout(path);
+
+        String baseVersionIdbeforeMerge = versionManager.getBaseVersion(path).getIdentifier();
+
+        // "merge" the clonedNode with the newNode from the default workspace
+        // besteffort set to false to stop at the first failure
+        versionManager.merge(path, workspace.getName(), false);
+
+        assertTrue("clonedNode has different UUID than expected, it should be left unchanged", baseVersionIdbeforeMerge .equals(versionManager.getBaseVersion(path).getIdentifier()));
+    }
+
+    /**
      * Node.merge(): bestEffort is true > (sub)node which could not be merged
      * are not affected.<br>
      */
@@ -167,6 +257,46 @@
     }
 
     /**
+     * VersionManager.merge(): bestEffort is true > (sub)node which could not be merged
+     * are not affected.<br>
+     */
+    public void disable_testMergeNodeBestEffortTrueJcr2() throws RepositoryException {
+        // create 2 new nodes with two independent versions
+        // so merge fails for this node
+        Node originalNode = testRootNode.getNode(nodeName1);
+        VersionManager originalVersionManager = originalNode.getSession().getWorkspace().getVersionManager();
+        String originalPath = originalNode.getPath();
+        originalVersionManager.checkout(originalPath);
+        Node subNode = originalNode.getNode(nodeName2);
+        // will be unchanged after merge
+        originalVersionManager.checkout(subNode.getPath());
+        subNode.setProperty(propertyName1, CHANGED_STRING);
+        // will be updated
+        originalNode.setProperty(propertyName1, CHANGED_STRING);
+        superuser.save();
+        originalVersionManager.checkin(subNode.getPath());
+        originalVersionManager.checkin(originalPath);
+
+        VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        Node subNodeW2 = nodeToMerge.getNode(nodeName2);
+        versionManager.checkout(subNodeW2.getPath());
+        subNodeW2.setProperty(propertyName1, CHANGED_STRING);
+        superuserW2.save();
+        versionManager.checkin(subNodeW2.getPath());
+
+        versionManager.checkout(nodeToMerge.getPath());
+
+        // merge, besteffort set to true
+        versionManager.merge(nodeToMerge.getPath(), workspace.getName(), true);
+
+        // sub node should not be touched because merging failed
+        assertTrue(subNodeW2.getProperty(propertyName1).getString().equals(""));
+
+        // test root node should be touched because update
+        assertFalse(nodeToMerge.getProperty(propertyName1).getString().equals(nodeToMerge.getName()));
+    }
+
+    /**
      * Node.merge(): For each versionable node N in the subtree rooted at this
      * node,<br> a merge test is performed comparing N with its corresponding
      * node in workspace, N'.<br>
@@ -187,6 +317,28 @@
     }
 
     /**
+     * VersionManager.merge(): For each versionable node N in the subtree rooted at this
+     * node,<br> a merge test is performed comparing N with its corresponding
+     * node in workspace, N'.<br>
+     */
+    public void disable_testMergeNodeSubNodesMergeTestJcr2() throws RepositoryException {
+        //setCheckProperty(nodeToMerge);
+        VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
+        String path = nodeToMerge.getPath();
+        versionManager.checkout(path);
+
+        versionManager.merge(path, workspace.getName(), true);
+
+        // check subnodes if they were touched
+        for (NodeIterator ni = nodeToMerge.getNodes(); ni.hasNext();) {
+            Node n = ni.nextNode();
+            if (versionManager.getBaseVersion(n.getPath()) != null) {
+                assertTrue(n.getProperty(propertyName1).getString().equals(CHANGED_STRING));
+            }
+        }
+    }
+
+    /**
      * initialize a two-step-hierarchy on default and second workspace
      */
     protected void initNodes() throws RepositoryException {
@@ -201,7 +353,7 @@
         subNvNode.setProperty(propertyName1, subNvNode.getName());
 
         // save default workspace
-        testRootNode.save();
+        testRootNode.getSession().save();
 
         log.println("test nodes created successfully on " + workspace.getName());
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionAbortTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionAbortTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionAbortTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionAbortTest.java Wed Jul  8 13:57:13 2009
@@ -21,6 +21,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.version.OnParentVersionAction;
 import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionManager;
 
 /**
  * <code>OnParentVersionAbortTest</code> tests the OnParentVersion {@link OnParentVersionAction#ABORT ABORT}
@@ -54,6 +55,23 @@
     }
 
     /**
+     * Test the restore of a OnParentVersion-ABORT property
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestorePropJcr2() throws RepositoryException {
+        try {
+            VersionManager versionManager = p.getSession().getWorkspace().getVersionManager();
+            String path = p.getParent().getPath();
+            versionManager.checkout(path);
+            versionManager.checkin(path);
+            fail("On checkin of N which has a property with OnParentVersion ABORT defined, an UnsupportedRepositoryOperationException must be thrown.");
+        } catch (VersionException e) {
+            // success
+        }
+    }
+
+    /**
      * Test the restore of a OnParentVersion-ABORT node
      *
      * @throws RepositoryException
@@ -70,4 +88,22 @@
             // success
         }
     }
+
+    /**
+     * Test the restore of a OnParentVersion-ABORT node
+     *
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
+    public void testRestoreNodeJcr2() throws RepositoryException, NotExecutableException {
+        // create child node with OPV-ABORT behaviour
+        addChildNode(OPVAction);
+        testRootNode.getSession().save();
+        try {
+            versionableNode.getSession().getWorkspace().getVersionManager().checkin(versionableNode.getPath());
+            fail("On checkin of N which has a child node with OnParentVersion ABORT defined, an UnsupportedRepositoryOperationException must be thrown.");
+        } catch (VersionException e) {
+            // success
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionComputeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionComputeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionComputeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionComputeTest.java Wed Jul  8 13:57:13 2009
@@ -20,6 +20,7 @@
 import javax.jcr.Node;
 import javax.jcr.version.OnParentVersionAction;
 import javax.jcr.version.Version;
+import javax.jcr.version.VersionManager;
 
 /**
  * <code>OnParentVersionComputeTest</code> tests the OnParentVersion {@link OnParentVersionAction#COMPUTE COMPUTE}
@@ -56,4 +57,26 @@
 
         assertEquals("On restore of a OnParentVersion-COMPUTE property P, the current P in the workspace will be left unchanged.", p.getString(), newPropValue);
     }
+
+    /**
+     * Test the restore of a OnParentVersion-COMPUTE property
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestorePropJcr2() throws RepositoryException {
+
+        Node propParent = p.getParent();
+        VersionManager versionManager = propParent.getSession().getWorkspace().getVersionManager();
+        String path = propParent.getPath();
+        versionManager.checkout(path);
+        Version v = versionManager.checkin(path);
+        versionManager.checkout(path);
+
+        p.setValue(newPropValue);
+        p.getSession().save();
+
+        versionManager.restore(v, false);
+
+        assertEquals("On restore of a OnParentVersion-COMPUTE property P, the current P in the workspace will be left unchanged.", p.getString(), newPropValue);
+    }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionCopyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionCopyTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionCopyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionCopyTest.java Wed Jul  8 13:57:13 2009
@@ -20,6 +20,7 @@
 import javax.jcr.Node;
 import javax.jcr.version.OnParentVersionAction;
 import javax.jcr.version.Version;
+import javax.jcr.version.VersionManager;
 
 /**
  * <code>OnParentVersionCopyTest</code> tests the OnParentVersion {@link OnParentVersionAction#COPY COPY}
@@ -76,4 +77,35 @@
         // todo: add proper comparison of restored node. equals does not work
         // assertEquals("On restore of a OnParentVersion-COPY child node, the node needs to be restored, replacing the current node in the workspace.", childNode, superuser.getItem(initialNodePath));
     }
+
+    /**
+     * Test the restore of a OnParentVersion-COPY node
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestoreNodeJcr2() throws RepositoryException {
+        // prepare for node test
+        Node childNode = addChildNode(OPVAction);
+        Node nodeParent = childNode.getParent();
+        // todo: added next line. correct? -> angela
+        nodeParent.getSession().save();
+
+        VersionManager versionManager = nodeParent.getSession().getWorkspace().getVersionManager();
+        String path = nodeParent.getPath();
+        versionManager.checkout(path);
+        Version v = versionManager.checkin(path);
+
+        initialNodePath = childNode.getPath();
+        versionManager.checkout(path);
+        childNode.remove();
+        nodeParent.getSession().save();
+
+        versionManager.restore(v, false);
+
+        if (!superuser.itemExists(initialNodePath)) {
+            fail("On restore of a OnParentVersion-COPY child node, the node needs to be restored, replacing the current node in the workspace.");
+        }
+        // todo: add proper comparison of restored node. equals does not work
+        // assertEquals("On restore of a OnParentVersion-COPY child node, the node needs to be restored, replacing the current node in the workspace.", childNode, superuser.getItem(initialNodePath));
+    }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionIgnoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionIgnoreTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionIgnoreTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionIgnoreTest.java Wed Jul  8 13:57:13 2009
@@ -20,6 +20,7 @@
 import javax.jcr.Node;
 import javax.jcr.version.OnParentVersionAction;
 import javax.jcr.version.Version;
+import javax.jcr.version.VersionManager;
 
 /**
  * <code>OnParentVersionIgnoreTest</code> tests the OnParentVersion {@link OnParentVersionAction#IGNORE IGNORE}
@@ -58,6 +59,28 @@
     }
 
     /**
+     * Test the restore of a OnParentVersion-IGNORE property
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestorePropJcr2() throws RepositoryException {
+
+        Node propParent = p.getParent();
+        VersionManager versionManager = propParent.getSession().getWorkspace().getVersionManager();
+        String path = propParent.getPath();
+        versionManager.checkout(path);
+        Version v = versionManager.checkin(path);
+        versionManager.checkout(path);
+
+        p.setValue(newPropValue);
+        p.getSession().save();
+
+        versionManager.restore(v, false);
+
+        assertEquals("On restore of a OnParentVersion-IGNORE property P, the current value of P must be left unchanged.", p.getString(), newPropValue);
+    }
+
+    /**
      * Test the restore of a OnParentVersion-Ignore node
      *
      * @throws javax.jcr.RepositoryException
@@ -79,4 +102,27 @@
         }
     }
 
+    /**
+     * Test the restore of a OnParentVersion-Ignore node
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestoreNodeJcr2() throws RepositoryException {
+
+        VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
+        String path = versionableNode.getPath();
+        versionManager.checkout(path);
+        Version v = versionManager.checkin(path);
+        versionManager.checkout(path);
+
+        // add 'ignore' child
+        String childName = addChildNode(OPVAction).getName();
+        versionableNode.getSession().save();
+
+        versionManager.restore(v, false);
+
+        if (!versionableNode.hasNode(childName)) {
+            fail("On restore of a OnParentVersion-Ignore child node, the node needs to be untouched.");
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionInitializeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionInitializeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionInitializeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/OnParentVersionInitializeTest.java Wed Jul  8 13:57:13 2009
@@ -20,6 +20,7 @@
 import javax.jcr.Node;
 import javax.jcr.version.OnParentVersionAction;
 import javax.jcr.version.Version;
+import javax.jcr.version.VersionManager;
 
 /**
  * <code>OnParentVersionInitializeTest</code> tests the {@link OnParentVersionAction#INITIALIZE INITIALIZE}
@@ -56,4 +57,26 @@
 
         assertEquals("On restore of a OnParentVersion-INITIALIZE property P, the current value of P must be left unchanged.", p.getString(), newPropValue);
     }
+
+    /**
+     * Test the restore of a OnParentVersion-INITIALIZE property
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestorePropJcr2() throws RepositoryException {
+
+        Node propParent = p.getParent();
+        VersionManager versionManager = propParent.getSession().getWorkspace().getVersionManager();
+        String path = propParent.getPath();
+        versionManager.checkout(path);
+        Version v = versionManager.checkin(path);
+        versionManager.checkout(path);
+
+        p.setValue(newPropValue);
+        p.getSession().save();
+
+        versionManager.restore(v, false);
+
+        assertEquals("On restore of a OnParentVersion-INITIALIZE property P, the current value of P must be left unchanged.", p.getString(), newPropValue);
+    }
 }
\ No newline at end of file



Mime
View raw message