jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1510440 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
Date Mon, 05 Aug 2013 12:06:37 GMT
Author: chetanm
Date: Mon Aug  5 12:06:36 2013
New Revision: 1510440

URL: http://svn.apache.org/r1510440
Log:
OAK-939 - Removing modified node in different session leads to conflict

Adding testcase for the issue

Modified:
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1510440&r1=1510439&r2=1510440&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Mon Aug  5 12:06:36 2013
@@ -310,6 +310,8 @@
       org.apache.jackrabbit.core.observation.ShareableNodesTest#testAddShare            
            <!-- OAK-118 workspace support needed -->
       org.apache.jackrabbit.core.observation.ShareableNodesTest#testRemoveShare         
            <!-- OAK-118 workspace support needed -->
       org.apache.jackrabbit.oak.jcr.nodetype.NodeDefinitionTest#testRootType            
            <!-- OAK-901 -->
+
+      org.apache.jackrabbit.oak.jcr.CompatibilityIssuesTest.removeNodeInDifferentSession
          <!-- OAK-939 -->
     </known.issues>
   </properties>
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java?rev=1510440&r1=1510439&r2=1510440&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
Mon Aug  5 12:06:36 2013
@@ -18,14 +18,20 @@ package org.apache.jackrabbit.oak.jcr;
 
 import static org.junit.Assert.fail;
 
+import javax.jcr.Credentials;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
 import javax.jcr.nodetype.ConstraintViolationException;
 
+import org.apache.jackrabbit.api.JackrabbitRepository;
 import org.junit.Test;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * This class contains test cases which demonstrate changes in behaviour wrt. to Jackrabbit
2.
  * 
@@ -115,4 +121,43 @@ public class CompatibilityIssuesTest ext
         session.save(); // // this is where OAK throws ConstraintViolationException
     }
 
+
+    /**
+     * OAK-939 - Change in behaviour from JR2. Following testcase leads to
+     * CommitFailedException but it passes in JR2
+     */
+    @Test
+    public void removeNodeInDifferentSession() throws RepositoryException {
+
+        final String testNode = "test_node";
+        final String testNodePath = "/" + testNode;
+
+        //Create the test node
+        Session session = getAdminSession();
+        session.getRootNode().addNode(testNode);
+        session.save();
+
+        //TestCase would pass if the sessionRefreshInterval is set to zero
+        boolean refreshIntervalZero = false;
+        Session s3 = createSessionWithRefreshInterval(refreshIntervalZero);
+        Session s2 = createSessionWithRefreshInterval(refreshIntervalZero);
+
+        s2.getNode(testNodePath).setProperty("foo","bar");
+        s2.save();
+
+        s3.getNode(testNodePath).remove();
+        s3.save();
+    }
+
+    private Session createSessionWithRefreshInterval(boolean refreshIntervalZero) throws
RepositoryException {
+        Credentials creds = new SimpleCredentials("admin", "admin".toCharArray());
+        if(refreshIntervalZero){
+            Map<String,Object> attrs = new HashMap<String, Object>();
+            attrs.put(RepositoryImpl.REFRESH_INTERVAL,0);
+            return ((JackrabbitRepository)getRepository()).login(creds,null,attrs);
+        }else{
+            return getRepository().login(creds);
+        }
+    }
+
 }



Mime
View raw message