jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1478052 - in /jackrabbit/oak/trunk/oak-jcr/src: main/java/org/apache/jackrabbit/oak/jcr/ test/java/org/apache/jackrabbit/oak/jcr/
Date Wed, 01 May 2013 15:34:34 GMT
Author: mduerig
Date: Wed May  1 15:34:34 2013
New Revision: 1478052

URL: http://svn.apache.org/r1478052
Log:
OAK-803: Backwards compatibility of long-lived sessions
- make session auto refreshing the default
- update test expectations

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java?rev=1478052&r1=1478051&r2=1478052&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
Wed May  1 15:34:34 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.util.concurrent.ScheduledExecutorService;
 
 import javax.annotation.Nonnull;
@@ -35,8 +37,6 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 /**
  * TODO document
  */
@@ -122,7 +122,7 @@ public class RepositoryImpl implements R
      */
     @Override
     public Session login(@Nullable Credentials credentials, @Nullable String workspaceName)
throws RepositoryException {
-        final boolean autoRefresh = false; // TODO implement auto refresh configuration
+        final boolean autoRefresh = true; // TODO implement auto refresh configuration
         try {
             ContentSession contentSession = contentRepository.login(credentials, workspaceName);
 

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=1478052&r1=1478051&r2=1478052&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
Wed May  1 15:34:34 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import static org.junit.Assert.fail;
+
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -24,8 +26,6 @@ import javax.jcr.nodetype.ConstraintViol
 
 import org.junit.Test;
 
-import static org.junit.Assert.fail;
-
 /**
  * This class contains test cases which demonstrate changes in behaviour wrt. to Jackrabbit
2.
  * 
@@ -33,60 +33,6 @@ import static org.junit.Assert.fail;
  */
 public class CompatibilityIssuesTest extends AbstractRepositoryTest {
 
-    /**
-     * Trans-session isolation differs from Jackrabbit 2. Snapshot isolation can
-     * result in write skew as this test demonstrates: the check method enforces
-     * an application logic constraint which says that the sum of the properties
-     * p1 and p2 must not be negative. While session1 and session2 each enforce
-     * this constraint before saving, the constraint might not hold globally as
-     * can be seen in session3.
-     *
-     * @see <a href="http://wiki.apache.org/jackrabbit/Transactional%20model%20of%20the%20Microkernel%20based%20Jackrabbit%20prototype">
-     *     Transactional model of the Microkernel based Jackrabbit prototype</a>
-     */
-    @Test
-    public void sessionIsolation() throws RepositoryException {
-        Session session0 = createAdminSession();
-        Session session1 = null;
-        Session session2 = null;
-        try {
-            Node testNode = session0.getNode("/").addNode("testNode");
-            testNode.setProperty("p1", 1);
-            testNode.setProperty("p2", 1);
-            session0.save();
-            check(getAdminSession());
-
-            session1 = createAdminSession();
-            session2 = createAdminSession();
-            session1.getNode("/testNode").setProperty("p1", -1);
-            check(session1);
-            session1.save();
-
-            session2.getNode("/testNode").setProperty("p2", -1);
-            check(session2);      // Throws on JR2, not on Oak
-            session2.save();
-
-            Session session3 = createAnonymousSession();
-            try {
-                check(session3);  // Throws on Oak
-                fail();
-            } catch (AssertionError e) {
-                // expected
-            } finally {
-                session3.logout();
-            }
-
-        } finally {
-            session0.logout();
-            if (session1 != null) {
-                session1.logout();
-            }
-            if (session2 != null) {
-                session2.logout();
-            }
-        }
-    }
-
     private static void check(Session session) throws RepositoryException {
         if (session.getNode("/testNode").getProperty("p1").getLong() +
                 session.getNode("/testNode").getProperty("p2").getLong() < 0) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java?rev=1478052&r1=1478051&r2=1478052&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java
Wed May  1 15:34:34 2013
@@ -76,9 +76,6 @@ public class MoveRemoveTest extends Abst
         n.remove();
         session.save();
 
-        assertEquals("/new", n2.getPath());
-
-        session2.refresh(true);
         try {
             n2.getPath();
             fail();
@@ -86,12 +83,6 @@ public class MoveRemoveTest extends Abst
 
         session.getRootNode().addNode("new");
         session.save();
-        try {
-            n2.getPath();
-            fail();
-        } catch (InvalidItemStateException e) {}
-
-        session2.refresh(true);
         assertEquals("/new", n2.getPath());
 
         session2.logout();
@@ -145,9 +136,6 @@ public class MoveRemoveTest extends Abst
         n.getParent().remove();
         session.save();
 
-        assertEquals("/parent/new", n2.getPath());
-
-        session2.refresh(true);
         try {
             n2.getPath();
             fail();
@@ -155,12 +143,6 @@ public class MoveRemoveTest extends Abst
 
         session.getRootNode().addNode("parent").addNode("new");
         session.save();
-        try {
-            n2.getPath();
-            fail();
-        } catch (InvalidItemStateException e) {}
-
-        session2.refresh(true);
         assertEquals("/parent/new", n2.getPath());
 
         session2.logout();
@@ -202,9 +184,6 @@ public class MoveRemoveTest extends Abst
         session.move("/new", "/moved");
         session.save();
 
-        assertEquals("/new", n2.getPath());
-
-        session2.refresh(true);
         try {
             n2.getPath();
             fail();
@@ -212,12 +191,6 @@ public class MoveRemoveTest extends Abst
 
         session.getRootNode().addNode("new");
         session.save();
-        try {
-            n2.getPath();
-            fail();
-        } catch (InvalidItemStateException e) {}
-
-        session2.refresh(true);
         assertEquals("/new", n2.getPath());
 
         session2.logout();
@@ -261,9 +234,6 @@ public class MoveRemoveTest extends Abst
         session.move("/parent", "/moved");
         session.save();
 
-        assertEquals("/parent/new", n2.getPath());
-
-        session2.refresh(true);
         try {
             n2.getPath();
             fail();
@@ -271,12 +241,6 @@ public class MoveRemoveTest extends Abst
 
         session.getRootNode().addNode("parent").addNode("new");
         session.save();
-        try {
-            n2.getPath();
-            fail();
-        } catch (InvalidItemStateException e) {}
-
-        session2.refresh(true);
         assertEquals("/parent/new", n2.getPath());
 
         session2.logout();

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1478052&r1=1478051&r2=1478052&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Wed May  1 15:34:34 2013
@@ -1352,13 +1352,7 @@ public class RepositoryTest extends Abst
 
             session1.save();
 
-            // Make sure these items are still not accessible through another session until
refresh
-            assertFalse(session2.itemExists("/node1"));
-            assertFalse(session2.itemExists("/node1/node2"));
-            assertFalse(session2.itemExists("/node1/node3"));
-            assertFalse(session2.itemExists("/node1/node3/property1"));
-
-            session2.refresh(false);
+            // Make sure these items are still accessible through another session
             assertTrue(session2.itemExists("/node1"));
             assertTrue(session2.itemExists("/node1/node2"));
             assertTrue(session2.itemExists("/node1/node3"));
@@ -1461,7 +1455,7 @@ public class RepositoryTest extends Abst
             session1.save();
             session2.save();
             assertTrue(session1.getRootNode().hasNode("node1"));
-            assertFalse(session1.getRootNode().hasNode("node2"));
+            assertTrue(session1.getRootNode().hasNode("node2"));
             assertTrue(session2.getRootNode().hasNode("node1"));
             assertTrue(session2.getRootNode().hasNode("node2"));
         } finally {
@@ -1515,8 +1509,7 @@ public class RepositoryTest extends Abst
 
             session1.save();
             assertFalse(session1.getRootNode().hasNode("node"));
-            assertTrue(session2.getRootNode().hasNode("node"));
-            assertTrue(session2.getRootNode().getNode("node").hasNode("2"));
+            assertFalse(session2.getRootNode().hasNode("node"));
 
             try {
                 session2.save();
@@ -1613,13 +1606,6 @@ public class RepositoryTest extends Abst
 
         session.getWorkspace().move(TEST_PATH + "/source/node", TEST_PATH + "/target/moved");
 
-        // Move must not be visible in session
-        assertTrue(node.hasNode("source/node"));
-        assertFalse(node.hasNode("target/moved"));
-
-        session.refresh(false);
-
-        // Move must be visible in session after refresh
         assertFalse(node.hasNode("source/node"));
         assertTrue(node.hasNode("source"));
         assertTrue(node.hasNode("target/moved"));
@@ -1636,13 +1622,6 @@ public class RepositoryTest extends Abst
 
         session.getWorkspace().copy(TEST_PATH + "/source/node", TEST_PATH + "/target/copied");
 
-        // Copy must not be visible in session
-        assertTrue(node.hasNode("source/node"));
-        assertFalse(node.hasNode("target/copied"));
-
-        session.refresh(false);
-
-        // Copy must be visible in session after refresh
         assertTrue(node.hasNode("source/node"));
         assertTrue(node.hasNode("target/copied"));
     }



Mime
View raw message