jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r519001 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api: ./ lock/ version/
Date Fri, 16 Mar 2007 15:12:21 GMT
Author: mreutegg
Date: Fri Mar 16 08:12:19 2007
New Revision: 519001

URL: http://svn.apache.org/viewvc?view=rev&rev=519001
Log:
JCR-795: Sessions are not logged out in case of exceptions

Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ImpersonateTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/RepositoryLoginTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ValueFactoryTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ImpersonateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ImpersonateTest.java?view=diff&rev=519001&r1=519000&r2=519001
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ImpersonateTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ImpersonateTest.java
Fri Mar 16 08:12:19 2007
@@ -50,41 +50,44 @@
             throw new NotExecutableException("impersonate threw LoginException");
         }
 
-        // get a path to test the permissions on
-        String thePath = "";
-        NodeIterator ni = session.getRootNode().getNodes();
-        while (ni.hasNext()) {
-            Node n = ni.nextNode();
-            if (!n.getPath().equals("/" + jcrSystem)) {
-                thePath = n.getPath();
-                break;
+        try {
+            // get a path to test the permissions on
+            String thePath = "";
+            NodeIterator ni = session.getRootNode().getNodes();
+            while (ni.hasNext()) {
+                Node n = ni.nextNode();
+                if (!n.getPath().equals("/" + jcrSystem)) {
+                    thePath = n.getPath();
+                    break;
+                }
             }
-        }
 
-        // check that all 4 permissions are granted/denied correctly
-        session.checkPermission(thePath, "read");
+            // check that all 4 permissions are granted/denied correctly
+            session.checkPermission(thePath, "read");
 
-        try {
-            session.checkPermission(thePath + "/" + nodeName1, "add_node");
-            fail("add_node permission on \"" + thePath + "/" + nodeName1 + "\" granted to
read-only Session");
-        } catch (AccessControlException success) {
-            // ok
-        }
+            try {
+                session.checkPermission(thePath + "/" + nodeName1, "add_node");
+                fail("add_node permission on \"" + thePath + "/" + nodeName1 + "\" granted
to read-only Session");
+            } catch (AccessControlException success) {
+                // ok
+            }
 
-        try {
-            session.checkPermission(thePath + "/" + propertyName1, "set_property");
-            fail("set_property permission on \"" + thePath + "/" + propertyName1 + "\" granted
to read-only Session");
-        } catch (AccessControlException success) {
-            // ok
-        }
+            try {
+                session.checkPermission(thePath + "/" + propertyName1, "set_property");
+                fail("set_property permission on \"" + thePath + "/" + propertyName1 + "\"
granted to read-only Session");
+            } catch (AccessControlException success) {
+                // ok
+            }
 
-        try {
-            session.checkPermission(thePath, "remove");
-            fail("remove permission on \"" + thePath + "\" granted to read-only Session");
-        } catch (AccessControlException success) {
-            // ok
-        }
+            try {
+                session.checkPermission(thePath, "remove");
+                fail("remove permission on \"" + thePath + "\" granted to read-only Session");
+            } catch (AccessControlException success) {
+                // ok
+            }
 
-        session.logout();
+        } finally {
+            session.logout();
+        }
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java?view=diff&rev=519001&r1=519000&r2=519001
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java
Fri Mar 16 08:12:19 2007
@@ -64,10 +64,11 @@
     public void tearDown() throws Exception {
         try {
             cleanUpTestRoot(superuserW2);
-            // log out
-            superuserW2.logout();
         } catch (RepositoryException e) {
             log.println("Exception in tearDown: " + e.toString());
+        } finally {
+            // log out
+            superuserW2.logout();
         }
 
         super.tearDown();

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/RepositoryLoginTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/RepositoryLoginTest.java?view=diff&rev=519001&r1=519000&r2=519001
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/RepositoryLoginTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/RepositoryLoginTest.java
Fri Mar 16 08:12:19 2007
@@ -64,14 +64,19 @@
             name = getNonExistingWorkspaceName(session);
         } finally {
             session.logout();
+            session = null;
         }
 
         try {
-            helper.getRepository().login(credentials, name);
+            session = helper.getRepository().login(credentials, name);
             fail("login with a not available workspace name must throw a " +
                     "NoSuchWorkspaceException");
         } catch (NoSuchWorkspaceException e) {
             // success
+        } finally {
+            if (session != null) {
+                session.logout();
+            }
         }
     }
 
@@ -108,4 +113,4 @@
             s.logout();
         }
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java?view=diff&rev=519001&r1=519000&r2=519001
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java
Fri Mar 16 08:12:19 2007
@@ -86,6 +86,9 @@
 
     public void tearDown() throws Exception {
         file.delete();
+        if (session != null && session.isLive()) {
+            session.logout();
+        }
         super.tearDown();
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java?view=diff&rev=519001&r1=519000&r2=519001
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java
Fri Mar 16 08:12:19 2007
@@ -265,20 +265,22 @@
 
         // access node through another session to lock it
         Session session2 = helper.getSuperuserSession();
-        Node node2 = session2.getRootNode().getNode(pathRelToRoot);
-        node2.lock(true, true);
-
         try {
-            String destPath = testRoot + "/" + nodeName2;
-            session.move(srcNode.getPath(), destPath);
-            testRootNode.save();
-            fail("A LockException is thrown either immediately or on save  if a lock prevents
the move.");
-        }
-        catch (LockException e){
-            // success
-        }
+            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
+            node2.lock(true, true);
 
-        session2.logout();
+            try {
+                String destPath = testRoot + "/" + nodeName2;
+                session.move(srcNode.getPath(), destPath);
+                testRootNode.save();
+                fail("A LockException is thrown either immediately or on save  if a lock
prevents the move.");
+            } catch (LockException e){
+                // success
+            }
+
+        } finally {
+            session2.logout();
+        }
     }
 
     /**
@@ -638,4 +640,4 @@
         assertFalse("Session should have no pending changes recorded after property has been
removed and saved!", superuser.hasPendingChanges());
 
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java?view=diff&rev=519001&r1=519000&r2=519001
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java
Fri Mar 16 08:12:19 2007
@@ -90,12 +90,14 @@
      * Releases the session aquired in {@link #setUp()}.
      */
     protected void tearDown() throws Exception {
-        node.checkout();
-
-        if (session != null) {
-            session.logout();
+        try {
+            node.checkout();
+        } finally {
+            if (session != null) {
+                session.logout();
+            }
+            super.tearDown();
         }
-        super.tearDown();
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ValueFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ValueFactoryTest.java?view=diff&rev=519001&r1=519000&r2=519001
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ValueFactoryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ValueFactoryTest.java
Fri Mar 16 08:12:19 2007
@@ -87,6 +87,14 @@
         referenceNode = createReferenceableNode(nodeName1);
     }
 
+
+    protected void tearDown() throws Exception {
+        if (session != null) {
+            session.logout();
+        }
+        super.tearDown();
+    }
+
     /**
      * Create a referenceable node under the testRootNode
      * or null if it is not possible to create one.
@@ -308,4 +316,4 @@
         }
 
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java?view=diff&rev=519001&r1=519000&r2=519001
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java
Fri Mar 16 08:12:19 2007
@@ -43,9 +43,6 @@
  */
 public class SetValueLockExceptionTest extends AbstractJCRTest {
 
-    private Session lockingSession;
-    private Session session;
-
     private Node testNode;
 
     private static final String binaryProp = "binaryProp";
@@ -84,14 +81,11 @@
      */
     public void setUp() throws Exception {
         super.setUp();
-        Repository repo = helper.getRepository();
         if (!isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
             throw new NotExecutableException("SetValueLockExceptionTest "
                     + "not executable: Locking not supported");
         }
         else {
-            lockingSession = superuser;
-
             // add a lockable node
             testNode = testRootNode.addNode(nodeName1, testNodeType);
             testNode.addMixin(mixLockable);
@@ -120,7 +114,7 @@
         if (testNode.holdsLock()) {
             testNode.unlock();
         }
-        lockingSession.save();
+        superuser.save();
         super.tearDown();
     }
 
@@ -136,12 +130,11 @@
         // lock if not yet locked
         if (!testNode.holdsLock()) {
             testNode.lock(false, false);
-            lockingSession.save();
+            superuser.save();
         }
 
         // another session
-        session = helper.getReadWriteSession();
-
+        Session session = helper.getReadWriteSession();
         try {
             Node node = (Node) session.getItem(testNode.getPath());
             Property prop = null;
@@ -209,6 +202,8 @@
                     + "if the parent node holds a Lock.");
         } catch (LockException le) {
             // ok
+        } finally {
+            session.logout();
         }
     }
 
@@ -234,7 +229,7 @@
         try {
             Node node = testRootNode.getNode(name);
             node.remove();
-            lockingSession.save();
+            superuser.save();
         } catch (PathNotFoundException pnfe) {
             // ok
         }
@@ -243,7 +238,7 @@
         if (n1.canAddMixin(mixReferenceable)) {
             n1.addMixin(mixReferenceable);
             // make sure jcr:uuid is available
-            lockingSession.save();
+            superuser.save();
             return n1;
         }
         else {

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java?view=diff&rev=519001&r1=519000&r2=519001
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java
Fri Mar 16 08:12:19 2007
@@ -115,10 +115,10 @@
             wVersionableNode.remove();
             wVersionableNode2.remove();
             wTestRoot.save();
+        } finally {
             if (wSuperuser != null) {
                 wSuperuser.logout();
             }
-        } finally {
             super.tearDown();
         }
     }
@@ -242,4 +242,4 @@
         superuser.getWorkspace().restore(new Version[]{version}, true);
     }
 
-}
\ No newline at end of file
+}



Mime
View raw message