jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1331005 - /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Date Thu, 26 Apr 2012 18:13:38 GMT
Author: mduerig
Date: Thu Apr 26 18:13:38 2012
New Revision: 1331005

URL: http://svn.apache.org/viewvc?rev=1331005&view=rev
Log:
Session.save and Session.refresh test cases

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

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=1331005&r1=1331004&r2=1331005&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
Thu Apr 26 18:13:38 2012
@@ -1143,18 +1143,52 @@ public class RepositoryTest extends Abst
         }
     }
 
-    @Test(expected = RepositoryException.class)
-    @Ignore("WIP")  // TODO clarify
+    @Test
+    public void sessionIsolation() throws RepositoryException {
+        Session session1 = getRepository().login();
+        Session session2 = getRepository().login();
+        try {
+            session1.getRootNode().addNode("node1");
+            session2.getRootNode().addNode("node2");
+            assertTrue(session1.getRootNode().hasNode("node1"));
+            assertTrue(session2.getRootNode().hasNode("node2"));
+            assertFalse(session1.getRootNode().hasNode("node2"));
+            assertFalse(session2.getRootNode().hasNode("node1"));
+
+            session1.save();
+            session2.save();
+            assertTrue(session1.getRootNode().hasNode("node1"));
+            assertFalse(session1.getRootNode().hasNode("node2"));
+            assertTrue(session2.getRootNode().hasNode("node1"));
+            assertTrue(session2.getRootNode().hasNode("node2"));
+        }
+        finally {
+            session1.logout();
+            session2.logout();
+        }
+    }
+
+    @Test
     public void saveRefreshConflict() throws RepositoryException {
         Session session1 = getRepository().login();
         Session session2 = getRepository().login();
         try {
             session1.getRootNode().addNode("node");
             session2.getRootNode().addNode("node");
+            assertTrue(session1.getRootNode().hasNode("node"));
+            assertTrue(session2.getRootNode().hasNode("node"));
 
             session1.save();
+            assertTrue(session1.getRootNode().hasNode("node"));
+            assertTrue(session2.getRootNode().hasNode("node"));
+
             session2.refresh(true);
+            assertTrue(session1.getRootNode().hasNode("node"));
+            assertTrue(session2.getRootNode().hasNode("node"));
+
             session2.save();
+            assertTrue(session1.getRootNode().hasNode("node"));
+            assertTrue(session2.getRootNode().hasNode("node"));
         }
         finally {
             session1.logout();
@@ -1162,9 +1196,8 @@ public class RepositoryTest extends Abst
         }
     }
 
-    @Test(expected = RepositoryException.class)
-    @Ignore("WIP")  // TODO clarify
-    public void refreshConflict2() throws RepositoryException {
+    @Test
+    public void saveConflict() throws RepositoryException {
         getSession().getRootNode().addNode("node");
         getSession().save();
 
@@ -1173,9 +1206,18 @@ public class RepositoryTest extends Abst
         try {
             session1.getNode("/node").remove();
             session2.getNode("/node").addNode("2");
+            assertFalse(session1.getRootNode().hasNode("node"));
+            assertTrue(session2.getRootNode().hasNode("node"));
+            assertTrue(session2.getRootNode().getNode("node").hasNode("2"));
 
             session1.save();
+            assertFalse(session1.getRootNode().hasNode("node"));
+            assertTrue(session2.getRootNode().hasNode("node"));
+            assertTrue(session2.getRootNode().getNode("node").hasNode("2"));
+
             session2.save();
+            assertFalse(session1.getRootNode().hasNode("node"));
+            assertFalse(session2.getRootNode().hasNode("node"));  // TODO: is this correct?
         }
         finally {
             session1.logout();



Mime
View raw message