jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1212842 - in /jackrabbit/sandbox/jackrabbit-microkernel/src: main/java/org/apache/jackrabbit/state/TransientSpace.java test/java/org/apache/jackrabbit/RepositoryTest.java
Date Sat, 10 Dec 2011 18:50:59 GMT
Author: mduerig
Date: Sat Dec 10 18:50:59 2011
New Revision: 1212842

URL: http://svn.apache.org/viewvc?rev=1212842&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
correct session refresh behaviour, add test case

Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java?rev=1212842&r1=1212841&r2=1212842&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
Sat Dec 10 18:50:59 2011
@@ -188,8 +188,10 @@ public class TransientSpace {
 
     public String refresh(boolean keepChanges) throws RepositoryException {
         NodeDelta oldRoot = root;
+        String oldRevision = revision;
         try {
             root = new NodeDelta(rootPath, rootPath);
+            revision = microKernel.getHeadRevision();
 
             if (keepChanges) {
                 apply(changeLog);
@@ -198,10 +200,11 @@ public class TransientSpace {
                 changeLog.clear();
             }
 
-            return revision = microKernel.getHeadRevision();
+            return revision;
         }
         catch (RepositoryException e) {
             root = oldRoot;
+            revision = oldRevision;
             throw e;
         }
     }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java?rev=1212842&r1=1212841&r2=1212842&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
Sat Dec 10 18:50:59 2011
@@ -1003,7 +1003,7 @@ public class RepositoryTest {
     }
     
     @Test
-    public void testSessionSave() throws RepositoryException {
+    public void sessionSave() throws RepositoryException {
         Session session1 = getRepository().login();
         Session session2 = getRepository().login();
         try {
@@ -1053,7 +1053,7 @@ public class RepositoryTest {
     }
 
     @Test
-    public void testSessionRefresh() throws RepositoryException {
+    public void sessionRefresh() throws RepositoryException {
         Session session = getRepository().login();
         try {
             // Add some items and ensure they are accessible through this session
@@ -1095,7 +1095,7 @@ public class RepositoryTest {
     }
 
     @Test
-    public void testRefreshConflict() throws RepositoryException {
+    public void refreshConflict() throws RepositoryException {
         Session session1 = getRepository().login();
         Session session2 = getRepository().login();
         try {
@@ -1119,6 +1119,32 @@ public class RepositoryTest {
     }
 
     @Test
+    public void refreshConflict2() throws RepositoryException {
+        getSession().getRootNode().addNode("node");
+        getSession().save();
+
+        Session session1 = getRepository().login();
+        Session session2 = getRepository().login();
+        try {
+            session1.getNode("/node").remove();
+            session2.getNode("/node").addNode("2");
+
+            session1.save();
+            try {
+                session2.refresh(true);
+                fail();
+            }
+            catch (RepositoryException e) {
+                // expected
+            }
+        }
+        finally {
+            session1.logout();
+            session2.logout();
+        }
+    }
+
+    @Test
     @Ignore // todo implement node type support
     public void setPrimaryType() throws RepositoryException {
         Node testNode = getNode(TEST_PATH);
@@ -1265,6 +1291,7 @@ public class RepositoryTest {
         ObservationManager obsMgr = getSession().getWorkspace().getObservationManager();
         obsMgr.setUserData("my user data");
         obsMgr.addEventListener(new EventListener() {
+                @Override
                 public void onEvent(EventIterator events) {
                     while (events.hasNext()) {
                         Event event = events.nextEvent();
@@ -1353,6 +1380,7 @@ public class RepositoryTest {
         ObservationManager obsMgr = getSession().getWorkspace().getObservationManager();
         obsMgr.setUserData("my user data");
         obsMgr.addEventListener(new EventListener() {
+                @Override
                 public void onEvent(EventIterator events) {
                     while (events.hasNext()) {
                         Event event = events.nextEvent();
@@ -1410,6 +1438,7 @@ public class RepositoryTest {
         ObservationManager obsMgr = getSession().getWorkspace().getObservationManager();
         obsMgr.setUserData("my user data");
         obsMgr.addEventListener(new EventListener() {
+                @Override
                 public void onEvent(EventIterator events) {
                     while (events.hasNext()) {
                         failedEvents.add(events.nextEvent());
@@ -1433,6 +1462,7 @@ public class RepositoryTest {
         final ObservationManager obsMgr = getSession().getWorkspace().getObservationManager();
         obsMgr.setUserData("my user data");
         final EventListener listener = new EventListener() {
+            @Override
             public void onEvent(EventIterator events) {
                 while (events.hasNext()) {
                     failedEvents.add(events.nextEvent());
@@ -1444,6 +1474,7 @@ public class RepositoryTest {
             "/", true, null, null, false);
 
         FutureTask<Object> disposer = new FutureTask<Object>(new Callable<Object>()
{
+            @Override
             public Object call() throws Exception {
                 obsMgr.removeEventListener(listener);
                 return null;
@@ -1468,7 +1499,7 @@ public class RepositoryTest {
      *     Transactional model of the Microkernel based Jackrabbit prototype</a>
      */
     @Test
-    public void testSessionIsolation() throws RepositoryException {
+    public void sessionIsolation() throws RepositoryException {
         Repository repository = getRepository();
 
         Session session0 = repository.login();



Mime
View raw message