jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1510873 - /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
Date Tue, 06 Aug 2013 07:32:00 GMT
Author: mduerig
Date: Tue Aug  6 07:32:00 2013
New Revision: 1510873

URL: http://svn.apache.org/r1510873
Log:
OAK-939 - Removing modified node in different session leads to conflict
Make test case pass for Oak (and fail for JR2)

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

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=1510873&r1=1510872&r2=1510873&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
Tue Aug  6 07:32:00 2013
@@ -16,8 +16,12 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import static org.apache.jackrabbit.oak.jcr.RepositoryImpl.REFRESH_INTERVAL;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.util.Collections;
+
 import javax.jcr.Credentials;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.Node;
@@ -27,12 +31,9 @@ import javax.jcr.SimpleCredentials;
 import javax.jcr.nodetype.ConstraintViolationException;
 
 import org.apache.jackrabbit.api.JackrabbitRepository;
-import org.junit.Ignore;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
 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.
  * 
@@ -124,40 +125,41 @@ public class CompatibilityIssuesTest ext
 
 
     /**
-     * OAK-939 - Change in behaviour from JR2. Following testcase leads to
+     * OAK-939 - Change in behaviour from JR2. Following test case leads to
      * CommitFailedException but it passes in JR2
      */
     @Test
-    @Ignore("OAK-939") // FIXME
-    public void removeNodeInDifferentSession() throws RepositoryException {
-
+    public void removeNodeInDifferentSession() throws Throwable {
         final String testNode = "test_node";
-        final String testNodePath = "/" + testNode;
+        final String testNodePath = '/' + testNode;
 
-        //Create the test node
+        // Create the test node
         Session session = getAdminSession();
         session.getRootNode().addNode(testNode);
         session.save();
 
-        //TestCase would pass if the sessionRefreshInterval is set to zero
+        // Test case would pass if the sessionRefreshInterval is set to zero
         boolean refreshIntervalZero = false;
-        Session s3 = createSessionWithRefreshInterval(refreshIntervalZero);
-        Session s2 = createSessionWithRefreshInterval(refreshIntervalZero);
+        Session s3 = newSession(refreshIntervalZero);
+        Session s2 = newSession(refreshIntervalZero);
 
-        s2.getNode(testNodePath).setProperty("foo","bar");
+        s2.getNode(testNodePath).setProperty("foo", "bar");
         s2.save();
 
         s3.getNode(testNodePath).remove();
-        s3.save();
+        try {
+            s3.save();
+        } catch (InvalidItemStateException e) {
+            assertTrue(e.getCause() instanceof CommitFailedException);
+        }
     }
 
-    private Session createSessionWithRefreshInterval(boolean refreshIntervalZero) throws
RepositoryException {
+    private Session newSession(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{
+        if (refreshIntervalZero){
+            return ((JackrabbitRepository) getRepository())
+                    .login(creds, null, Collections.<String, Object>singletonMap(REFRESH_INTERVAL,
0));
+        } else{
             return getRepository().login(creds);
         }
     }



Mime
View raw message