jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r164811 - in /incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api: ./ lock/ query/ version/
Date Tue, 26 Apr 2005 16:40:07 GMT
Author: mreutegg
Date: Tue Apr 26 09:40:05 2005
New Revision: 164811

URL: http://svn.apache.org/viewcvs?rev=164811&view=rev
Log:
Fix missing calls to Session.logout() in various test cases.

Modified:
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NamespaceRegistryReadMethodsTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeCanAddMixinTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeUUIDTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionUUIDTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceReadMethodsTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/lock/LockTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/SaveTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/MergeNodeTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java Tue Apr 26 09:40:05 2005
@@ -92,6 +92,9 @@
                 superuserW2.logout();
             }
         }
+        if (rwSessionW2 != null) {
+            rwSessionW2.logout();
+        }
         super.tearDown();
     }
 

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NamespaceRegistryReadMethodsTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NamespaceRegistryReadMethodsTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NamespaceRegistryReadMethodsTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NamespaceRegistryReadMethodsTest.java Tue Apr 26 09:40:05 2005
@@ -49,12 +49,25 @@
     /** The NamespaceRegistry of the repository */
     private NamespaceRegistry nsr;
 
+    /** A read-only session */
+    private Session session;
+
     public void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        Session session = helper.getReadOnlySession();
+        session = helper.getReadOnlySession();
         Workspace ws = session.getWorkspace();
         nsr = ws.getNamespaceRegistry();
+    }
+
+    /**
+     * Releases the session aquired in {@link #setUp()}.
+     */
+    protected void tearDown() throws Exception {
+        if (session != null) {
+            session.logout();
+        }
+        super.tearDown();
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeAddMixinTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeAddMixinTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeAddMixinTest.java Tue Apr 26 09:40:05 2005
@@ -146,19 +146,23 @@
 
         // access node through another session to lock it
         Session session2 = helper.getSuperuserSession();
-        Node node2 = session2.getRootNode().getNode(pathRelToRoot);
-        node2.lock(true, true);
-
         try {
-            node.addMixin(mixinName);
-            fail("Node.addMixin(String mixinName) must throw a LockException " +
-                    "if the node is locked.");
-        } catch (LockException e) {
-            // success
-        }
+            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
+            node2.lock(true, true);
 
-        // unlock to remove node at tearDown()
-        node2.unlock();
+            try {
+                node.addMixin(mixinName);
+                fail("Node.addMixin(String mixinName) must throw a LockException " +
+                        "if the node is locked.");
+            } catch (LockException e) {
+                // success
+            }
+
+            // unlock to remove node at tearDown()
+            node2.unlock();
+        } finally {
+            session2.logout();
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeCanAddMixinTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeCanAddMixinTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeCanAddMixinTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeCanAddMixinTest.java Tue Apr 26 09:40:05 2005
@@ -73,15 +73,18 @@
 
         // access node through another session to lock it
         Session session2 = helper.getSuperuserSession();
-        Node node2 = session2.getRootNode().getNode(pathRelToRoot);
-        node2.lock(true, true);
+        try {
+            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
+            node2.lock(true, true);
 
-        assertFalse("Node.canAddMixin(String mixinName) must return false " +
-                "if the node is locked.",
-                node.canAddMixin(mixinName));
+            assertFalse("Node.canAddMixin(String mixinName) must return false " +
+                    "if the node is locked.",
+                    node.canAddMixin(mixinName));
 
-        node2.unlock();
-        session2.logout();
+            node2.unlock();
+        } finally {
+            session2.logout();
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java Tue Apr 26 09:40:05 2005
@@ -227,10 +227,15 @@
      */
     public void testIsSame() throws RepositoryException {
         // access same node through different session
-        Item otherTestNode = helper.getReadOnlySession().getRootNode().getNode(testPath);
-        assertTrue("isSame(Item item) must return true for the same " +
-                "item retrieved through different sessions.",
-                testRootNode.isSame(otherTestNode));
+        Session s = helper.getReadOnlySession();
+        try {
+            Item otherTestNode = s.getRootNode().getNode(testPath);
+            assertTrue("isSame(Item item) must return true for the same " +
+                    "item retrieved through different sessions.",
+                    testRootNode.isSame(otherTestNode));
+        } finally {
+            s.logout();
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java Tue Apr 26 09:40:05 2005
@@ -171,20 +171,23 @@
 
         // access node through another session to lock it
         Session session2 = helper.getSuperuserSession();
-        Node node2 = session2.getRootNode().getNode(pathRelToRoot);
-        node2.lock(true, true);
-
         try {
-            node.removeMixin(mixinName);
-            fail("Node.removeMixin(String mixinName) must throw a " +
-                    "LockException if the node is locked.");
-        } catch (LockException e) {
-            // success
-        }
+            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
+            node2.lock(true, true);
 
-        // unlock to remove node at tearDown()
-        node2.unlock();
-        session2.logout();
+            try {
+                node.removeMixin(mixinName);
+                fail("Node.removeMixin(String mixinName) must throw a " +
+                        "LockException if the node is locked.");
+            } catch (LockException e) {
+                // success
+            }
+
+            // unlock to remove node at tearDown()
+            node2.unlock();
+        } finally {
+            session2.logout();
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeTest.java Tue Apr 26 09:40:05 2005
@@ -545,20 +545,23 @@
 
         // get the node with session 2
         Session testSession = helper.getReadWriteSession();
-        Node defaultTestNodeSession2 = (Node) testSession.getItem(defaultTestNode.getPath());
+        try {
+            Node defaultTestNodeSession2 = (Node) testSession.getItem(defaultTestNode.getPath());
 
-        // remove node with session 1
-        defaultTestNode.remove();
-        superuser.save();
+            // remove node with session 1
+            defaultTestNode.remove();
+            superuser.save();
 
-        // try to remove already deleted node with session 2
-        try {
-            defaultTestNodeSession2.remove();
-            fail("Removing a node already deleted by other session should throw an InvalidItemStateException!");
-        } catch (InvalidItemStateException e) {
-            //ok, works as expected
+            // try to remove already deleted node with session 2
+            try {
+                defaultTestNodeSession2.remove();
+                fail("Removing a node already deleted by other session should throw an InvalidItemStateException!");
+            } catch (InvalidItemStateException e) {
+                //ok, works as expected
+            }
+        } finally {
+            testSession.logout();
         }
-        testSession.logout();
     }
 
     /**
@@ -654,13 +657,16 @@
 
         // access node through another session to lock it
         Session session2 = helper.getSuperuserSession();
-        Node node2 = session2.getRootNode().getNode(pathRelToRoot);
-        node2.lock(true, true);
+        try {
+            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
+            node2.lock(true, true);
 
-        // test fails if a LockException is thrown when removing the node
-        // (remove must be possible since the parent is not locked)
-        node.remove();
-        session2.logout();
+            // test fails if a LockException is thrown when removing the node
+            // (remove must be possible since the parent is not locked)
+            node.remove();
+        } finally {
+            session2.logout();
+        }
     }
 
     /**
@@ -701,20 +707,23 @@
         String pathRelToRoot = node.getPath().substring(1);
         // access node through another session to lock it
         Session session2 = helper.getSuperuserSession();
-        Node node2 = session2.getRootNode().getNode(pathRelToRoot);
-        node2.lock(true, true);
-
         try {
-            subNode.remove();
-            fail("Node.remove() must throw a LockException if the parent " +
-                    "of the node is locked");
-        } catch (LockException e) {
-            // success
-        }
+            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
+            node2.lock(true, true);
+
+            try {
+                subNode.remove();
+                fail("Node.remove() must throw a LockException if the parent " +
+                        "of the node is locked");
+            } catch (LockException e) {
+                // success
+            }
 
-        // unlock to remove node at tearDown()
-        node2.unlock();
-        session2.logout();
+            // unlock to remove node at tearDown()
+            node2.unlock();
+        } finally {
+            session2.logout();
+        }
     }
 
     /**
@@ -889,26 +898,30 @@
         // get session 2
         Session session2 = helper.getReadWriteSession();
 
-        // get the second node
-        Node testNode2Session2 = (Node) session2.getItem(testNode2Session1.getPath());
+        try {
+            // get the second node
+            Node testNode2Session2 = (Node) session2.getItem(testNode2Session1.getPath());
 
-        // adds a child node
-        testNode2Session2.addNode(nodeName3, testNodeType);
+            // adds a child node
+            testNode2Session2.addNode(nodeName3, testNodeType);
 
-        // save the changes
-        session2.save();
+            // save the changes
+            session2.save();
 
-        // call refresh on session 1
-        defaultRootNode.refresh(false);
+            // call refresh on session 1
+            defaultRootNode.refresh(false);
 
-        // check if session 1 flag has been cleared
-        assertFalse("Session should have no pending changes recorded after Node.refresh(false)!", superuser.hasPendingChanges());
+            // check if session 1 flag has been cleared
+            assertFalse("Session should have no pending changes recorded after Node.refresh(false)!", superuser.hasPendingChanges());
 
-        // check if added child node for node 1 by session 1 has been removed
-        assertFalse("Node Modifications have not been flushed after Node.refresh(false)", testNode1Session1.hasNodes());
+            // check if added child node for node 1 by session 1 has been removed
+            assertFalse("Node Modifications have not been flushed after Node.refresh(false)", testNode1Session1.hasNodes());
 
-        // check if added child node for node 2 by session 2 has become visible in session 1
-        assertTrue("Node modified by a different session has not been updated after Node.refresh(false)", testNode2Session1.hasNodes());
+            // check if added child node for node 2 by session 2 has become visible in session 1
+            assertTrue("Node modified by a different session has not been updated after Node.refresh(false)", testNode2Session1.hasNodes());
+        } finally {
+            session2.logout();
+        }
     }
 
     /**
@@ -942,26 +955,30 @@
         // get session 2
         Session session2 = helper.getReadWriteSession();
 
-        // get the second node
-        Node testNode2Session2 = (Node) session2.getItem(testNode2Session1.getPath());
+        try {
+            // get the second node
+            Node testNode2Session2 = (Node) session2.getItem(testNode2Session1.getPath());
 
-        // adds a child node
-        testNode2Session2.addNode(nodeName3, testNodeType);
+            // adds a child node
+            testNode2Session2.addNode(nodeName3, testNodeType);
 
-        // save the changes
-        session2.save();
+            // save the changes
+            session2.save();
 
-        // call refresh on session 1
-        defaultRootNode.refresh(true);
+            // call refresh on session 1
+            defaultRootNode.refresh(true);
 
-        // check if session 1 flag has been cleared
-        assertTrue("Session should still have pending changes recorded after Node.refresh(true)!", superuser.hasPendingChanges());
+            // check if session 1 flag has been cleared
+            assertTrue("Session should still have pending changes recorded after Node.refresh(true)!", superuser.hasPendingChanges());
 
-        // check if added child node for node 1 by session 1 is still there
-        assertTrue("Node Modifications are lost after Node.refresh(true)", testNode1Session1.hasNodes());
+            // check if added child node for node 1 by session 1 is still there
+            assertTrue("Node Modifications are lost after Node.refresh(true)", testNode1Session1.hasNodes());
 
-        // check if added child node for node 2 by session 2 has become visible in session 1
-        assertTrue("Node modified by a different session has not been updated after Node.refresh(true)", testNode2Session1.hasNodes());
+            // check if added child node for node 2 by session 2 has become visible in session 1
+            assertTrue("Node modified by a different session has not been updated after Node.refresh(true)", testNode2Session1.hasNodes());
+        } finally {
+            session2.logout();
+        }
     }
 
     /**
@@ -989,20 +1006,24 @@
 
         // get the new node with a different session
         Session testSession = helper.getReadWriteSession();
-        Node nodeSession2 = (Node) testSession.getItem(nodeSession1.getPath());
+        try {
+            Node nodeSession2 = (Node) testSession.getItem(nodeSession1.getPath());
 
-        // delete the node with the new session
-        nodeSession2.remove();
+            // delete the node with the new session
+            nodeSession2.remove();
 
-        // make node removal persistent
-        testSession.save();
+            // make node removal persistent
+            testSession.save();
 
-        // save changes made wit superuser session
-        try {
-            defaultRootNode.save();
-            fail("Saving a modified Node using Node.save() already deleted by an other session should throw InvalidItemStateException");
-        } catch (InvalidItemStateException e) {
-            // ok, works as expected
+            // save changes made wit superuser session
+            try {
+                defaultRootNode.save();
+                fail("Saving a modified Node using Node.save() already deleted by an other session should throw InvalidItemStateException");
+            } catch (InvalidItemStateException e) {
+                // ok, works as expected
+            }
+        } finally {
+            testSession.logout();
         }
     }
 
@@ -1046,8 +1067,11 @@
 
         // get the new node with a different session
         Session testSession = helper.getReadOnlySession();
-        testSession.getItem(testNode.getPath());
-        testSession.logout();
+        try {
+            testSession.getItem(testNode.getPath());
+        } finally {
+            testSession.logout();
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeUUIDTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeUUIDTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeUUIDTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeUUIDTest.java Tue Apr 26 09:40:05 2005
@@ -113,21 +113,24 @@
 
         // get the moving node with session 2
         Session testSession = helper.getReadWriteSession();
-        Node refTargetNodeSession2 = (Node) testSession.getItem(refTargetNode.getPath());
+        try {
+            Node refTargetNodeSession2 = (Node) testSession.getItem(refTargetNode.getPath());
 
-        //move the node with session 1
-        superuser.move(refTargetNode.getPath(), newParentNode.getPath() + "/" + nodeName3);
+            //move the node with session 1
+            superuser.move(refTargetNode.getPath(), newParentNode.getPath() + "/" + nodeName3);
 
-        // make the move persistent with session 1
-        superuser.save();
+            // make the move persistent with session 1
+            superuser.save();
 
-        // modify some prop of the moved node with session 2
-        refTargetNodeSession2.setProperty(propertyName1, "test");
+            // modify some prop of the moved node with session 2
+            refTargetNodeSession2.setProperty(propertyName1, "test");
 
-        // save it
-        refTargetNodeSession2.save();
-        // ok, works as expected
-        testSession.logout();
+            // save it
+            refTargetNodeSession2.save();
+            // ok, works as expected
+        } finally {
+            testSession.logout();
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionTest.java Tue Apr 26 09:40:05 2005
@@ -255,9 +255,12 @@
 
         // get moved tree root node with session 2
         Session testSession = helper.getReadWriteSession();
-        testSession.getItem(destParentNode.getPath() + "/" + nodeName2);
-        // node found
-        testSession.logout();
+        try {
+            testSession.getItem(destParentNode.getPath() + "/" + nodeName2);
+            // node found
+        } finally {
+            testSession.logout();
+        }
     }
 
     /**
@@ -277,9 +280,13 @@
         superuser.save();
 
         // use a different session to verify if the node is there
-        helper.getReadOnlySession().getItem(newNode.getPath());
-
-        // throws PathNotFoundException if item was not saved
+        Session s = helper.getReadOnlySession();
+        try {
+            s.getItem(newNode.getPath());
+            // throws PathNotFoundException if item was not saved
+        } finally {
+            s.logout();
+        }
     }
 
     /**
@@ -310,9 +317,14 @@
         // check if the child node was created properly
 
         // get a reference with a second session to the modified node
-        Node newNodeSession2 = (Node) helper.getReadOnlySession().getItem(newNode.getPath());
-        // check if child is there
-        assertTrue("Modifications on  a node are not save after Session.save()", newNodeSession2.hasNode(nodeName2));
+        Session s = helper.getReadOnlySession();
+        try {
+            Node newNodeSession2 = (Node) s.getItem(newNode.getPath());
+            // check if child is there
+            assertTrue("Modifications on  a node are not save after Session.save()", newNodeSession2.hasNode(nodeName2));
+        } finally {
+            s.logout();
+        }
     }
 
     /**
@@ -363,20 +375,24 @@
 
         // get the new node with a different session
         Session testSession = helper.getReadWriteSession();
-        Node nodeSession2 = (Node) testSession.getItem(nodeSession1.getPath());
+        try {
+            Node nodeSession2 = (Node) testSession.getItem(nodeSession1.getPath());
 
-        // delete the node with the new session
-        nodeSession2.remove();
+            // delete the node with the new session
+            nodeSession2.remove();
 
-        // make node removal persistent
-        testSession.save();
+            // make node removal persistent
+            testSession.save();
 
-        // save changes made wit superuser session
-        try {
-            superuser.save();
-            fail("Saving a modified Node using Session.save() already deleted by an other session should throw InvalidItemStateException");
-        } catch (InvalidItemStateException e) {
-            // ok, works as expected
+            // save changes made wit superuser session
+            try {
+                superuser.save();
+                fail("Saving a modified Node using Session.save() already deleted by an other session should throw InvalidItemStateException");
+            } catch (InvalidItemStateException e) {
+                // ok, works as expected
+            }
+        } finally {
+            testSession.logout();
         }
     }
 
@@ -411,26 +427,30 @@
         // get session 2
         Session session2 = helper.getReadWriteSession();
 
-        // get the second node
-        Node testNode2Session2 = (Node) session2.getItem(testNode2Session1.getPath());
+        try {
+            // get the second node
+            Node testNode2Session2 = (Node) session2.getItem(testNode2Session1.getPath());
 
-        // adds a child node
-        testNode2Session2.addNode(nodeName3, testNodeType);
+            // adds a child node
+            testNode2Session2.addNode(nodeName3, testNodeType);
 
-        // save the changes
-        session2.save();
+            // save the changes
+            session2.save();
 
-        // call refresh on session 1
-        superuser.refresh(false);
+            // call refresh on session 1
+            superuser.refresh(false);
 
-        // check if session 1 flag has been cleared
-        assertFalse("Session should have no pending changes recorded after Session.refresh(false)!", superuser.hasPendingChanges());
+            // check if session 1 flag has been cleared
+            assertFalse("Session should have no pending changes recorded after Session.refresh(false)!", superuser.hasPendingChanges());
 
-        // check if added child node for node 1 by session 1 has been removed
-        assertFalse("Node Modifications have not been flushed after session.refresh(false)", testNode1Session1.hasNodes());
+            // check if added child node for node 1 by session 1 has been removed
+            assertFalse("Node Modifications have not been flushed after session.refresh(false)", testNode1Session1.hasNodes());
 
-        // check if added child node for node 2 by session 2 has become visible in session 1
-        assertTrue("Node modified by a different session has not been updated after Session.refresh(false)", testNode2Session1.hasNodes());
+            // check if added child node for node 2 by session 2 has become visible in session 1
+            assertTrue("Node modified by a different session has not been updated after Session.refresh(false)", testNode2Session1.hasNodes());
+        } finally {
+            session2.logout();
+        }
     }
 
     /**
@@ -464,26 +484,30 @@
         // get session 2
         Session session2 = helper.getReadWriteSession();
 
-        // get the second node
-        Node testNode2Session2 = (Node) session2.getItem(testNode2Session1.getPath());
+        try {
+            // get the second node
+            Node testNode2Session2 = (Node) session2.getItem(testNode2Session1.getPath());
 
-        // adds a child node
-        testNode2Session2.addNode(nodeName3, testNodeType);
+            // adds a child node
+            testNode2Session2.addNode(nodeName3, testNodeType);
 
-        // save the changes
-        session2.save();
+            // save the changes
+            session2.save();
 
-        // call refresh on session 1
-        superuser.refresh(true);
+            // call refresh on session 1
+            superuser.refresh(true);
 
-        // check if session 1 flag has been cleared
-        assertTrue("Session should still have pending changes recorded after Session.refresh(true)!", superuser.hasPendingChanges());
+            // check if session 1 flag has been cleared
+            assertTrue("Session should still have pending changes recorded after Session.refresh(true)!", superuser.hasPendingChanges());
 
-        // check if added child node for node 1 by session 1 is still there
-        assertTrue("Node Modifications are lost after session.refresh(true)", testNode1Session1.hasNodes());
+            // check if added child node for node 1 by session 1 is still there
+            assertTrue("Node Modifications are lost after session.refresh(true)", testNode1Session1.hasNodes());
 
-        // check if added child node for node 2 by session 2 has become visible in session 1
-        assertTrue("Node modified by a different session has not been updated after Session.refresh(true)", testNode2Session1.hasNodes());
+            // check if added child node for node 2 by session 2 has become visible in session 1
+            assertTrue("Node modified by a different session has not been updated after Session.refresh(true)", testNode2Session1.hasNodes());
+        } finally {
+            session2.logout();
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionUUIDTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionUUIDTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionUUIDTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionUUIDTest.java Tue Apr 26 09:40:05 2005
@@ -22,7 +22,6 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.Session;
-import javax.jcr.InvalidItemStateException;
 
 /**
  * <code>SessionUUIDTest</code> contains all tests for the {@link javax.jcr.Session}
@@ -114,20 +113,24 @@
         // get the moving node with session 2
         Session testSession = helper.getReadWriteSession();
 
-        Node refTargetNodeSession2 = (Node) testSession.getItem(refTargetNode.getPath());
+        try {
+            Node refTargetNodeSession2 = (Node) testSession.getItem(refTargetNode.getPath());
 
-        // move the node with session 1
-        superuser.move(refTargetNode.getPath(), newParentNode.getPath() + "/" + nodeName2);
+            // move the node with session 1
+            superuser.move(refTargetNode.getPath(), newParentNode.getPath() + "/" + nodeName2);
 
-        // make the move persistent with session 1
-        superuser.save();
+            // make the move persistent with session 1
+            superuser.save();
 
-        // modify some prop of the moved node with session 2
-        refTargetNodeSession2.setProperty(propertyName1, "test");
+            // modify some prop of the moved node with session 2
+            refTargetNodeSession2.setProperty(propertyName1, "test");
 
-        // save it
-        testSession.save();
+            // save it
+            testSession.save();
 
-        // ok, works as expected
+            // ok, works as expected
+        } finally {
+            testSession.logout();
+        }
     }
 }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java Tue Apr 26 09:40:05 2005
@@ -21,7 +21,6 @@
 import org.apache.jackrabbit.test.api.nodetype.NodeTypeUtil;
 
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import javax.jcr.PropertyType;
 import javax.jcr.Value;
 import javax.jcr.Node;
@@ -54,9 +53,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.BOOLEAN, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No boolean property def with " +
@@ -114,9 +112,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.DATE, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.DATE, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No date property def with " +
@@ -174,9 +171,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.DOUBLE, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.DOUBLE, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No double property def with " +
@@ -234,9 +230,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.BINARY, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No binary property def with " +
@@ -295,9 +290,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.LONG, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.LONG, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No long property def with " +
@@ -355,9 +349,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.REFERENCE, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.REFERENCE, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No reference property def with " +
@@ -367,7 +360,7 @@
         String constraints[] = propDef.getValueConstraints();
         String nodeTypeNotSatisfied = null;
 
-        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
+        NodeTypeManager manager = superuser.getWorkspace().getNodeTypeManager();
         NodeTypeIterator types = manager.getAllNodeTypes();
 
         // find a NodeType which is not satisfying the constraints

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java Tue Apr 26 09:40:05 2005
@@ -21,7 +21,6 @@
 import org.apache.jackrabbit.test.api.nodetype.NodeTypeUtil;
 
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import javax.jcr.PropertyType;
 import javax.jcr.Value;
 import javax.jcr.Node;
@@ -54,9 +53,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.BINARY, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No binary property def with " +
@@ -123,9 +121,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.BOOLEAN, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No boolean property def with " +
@@ -191,9 +188,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.DATE, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.DATE, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No date property def with " +
@@ -259,9 +255,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.DOUBLE, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.DOUBLE, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No double property def with " +
@@ -327,9 +322,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.LONG, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.LONG, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No long property def with " +
@@ -396,9 +390,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.REFERENCE, false, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.REFERENCE, false, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No reference property def with " +
@@ -409,7 +402,7 @@
         String nodeTypeSatisfied = constraints[0];
         String nodeTypeNotSatisfied = null;
 
-        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
+        NodeTypeManager manager = superuser.getWorkspace().getNodeTypeManager();
         NodeTypeIterator types = manager.getAllNodeTypes();
 
         // find a NodeType which is not satisfying the constraints
@@ -488,9 +481,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, true, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.BINARY, true, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No multiple binary property def with " +
@@ -544,9 +536,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, true, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.BOOLEAN, true, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No multiple boolean property def with " +
@@ -601,9 +592,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.DATE, true, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.DATE, true, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No multiple date property def with " +
@@ -657,9 +647,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.DOUBLE, true, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.DOUBLE, true, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No multiple double property def with " +
@@ -714,9 +703,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.LONG, true, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.LONG, true, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No multiple long property def with " +
@@ -771,9 +759,8 @@
             throws NotExecutableException, RepositoryException {
 
         // locate a PropertyDefinition with ValueConstraints
-        Session session = helper.getReadWriteSession();
         PropertyDefinition propDef =
-                NodeTypeUtil.locatePropertyDef(session, PropertyType.REFERENCE, true, false, true, false);
+                NodeTypeUtil.locatePropertyDef(superuser, PropertyType.REFERENCE, true, false, true, false);
 
         if (propDef == null) {
             throw new NotExecutableException("No multiple reference property def with " +
@@ -784,7 +771,7 @@
         String nodeTypeSatisfied = constraints[0];
         String nodeTypeNotSatisfied = null;
 
-        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
+        NodeTypeManager manager = superuser.getWorkspace().getNodeTypeManager();
         NodeTypeIterator types = manager.getAllNodeTypes();
 
         // find a NodeType which is not satisfying the constraints

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java Tue Apr 26 09:40:05 2005
@@ -105,16 +105,18 @@
      * sufficient access permissions to complete the operation.
      */
     public void testCloneNodesAccessDenied() throws RepositoryException {
-        // logout and get read only session
-        //superuser.logout();
+        // get read only session
         Session readOnlySuperuser = helper.getReadOnlySession();
-
-        String dstAbsPath = node2.getPath() + "/" + node1.getName();
         try {
-            readOnlySuperuser.getWorkspace().clone(workspaceW2.getName(), node1.getPath(), dstAbsPath, true);
-            fail("Cloning in a read-only session should throw an AccessDeniedException.");
-        } catch (AccessDeniedException e) {
-            // successful
+            String dstAbsPath = node2.getPath() + "/" + node1.getName();
+            try {
+                readOnlySuperuser.getWorkspace().clone(workspaceW2.getName(), node1.getPath(), dstAbsPath, true);
+                fail("Cloning in a read-only session should throw an AccessDeniedException.");
+            } catch (AccessDeniedException e) {
+                // successful
+            }
+        } finally {
+            readOnlySuperuser.logout();
         }
     }
 

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java Tue Apr 26 09:40:05 2005
@@ -110,13 +110,16 @@
      */
     public void testCopyNodesAccessDenied() throws RepositoryException {
         Session readOnlySuperuser = helper.getReadOnlySession();
-
-        String dstAbsPath = node2.getPath() + "/" + node1.getName();
         try {
-            readOnlySuperuser.getWorkspace().copy(workspaceW2.getName(), node1W2.getPath(), dstAbsPath);
-            fail("Copy in a read-only session should throw an AccessDeniedException.");
-        } catch (AccessDeniedException e) {
-            // successful
+            String dstAbsPath = node2.getPath() + "/" + node1.getName();
+            try {
+                readOnlySuperuser.getWorkspace().copy(workspaceW2.getName(), node1W2.getPath(), dstAbsPath);
+                fail("Copy in a read-only session should throw an AccessDeniedException.");
+            } catch (AccessDeniedException e) {
+                // successful
+            }
+        } finally {
+            readOnlySuperuser.logout();
         }
     }
 

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java Tue Apr 26 09:40:05 2005
@@ -91,13 +91,16 @@
      */
     public void testCopyNodesAccessDenied() throws RepositoryException {
         Session readOnlySuperuser = helper.getReadOnlySession();
-
-        String dstAbsPath = node2.getPath() + "/" + node1.getName();
         try {
-            readOnlySuperuser.getWorkspace().copy(node1.getPath(), dstAbsPath);
-            fail("Copy in a read-only session should throw an AccessDeniedException.");
-        } catch (AccessDeniedException e) {
-            // successful
+            String dstAbsPath = node2.getPath() + "/" + node1.getName();
+            try {
+                readOnlySuperuser.getWorkspace().copy(node1.getPath(), dstAbsPath);
+                fail("Copy in a read-only session should throw an AccessDeniedException.");
+            } catch (AccessDeniedException e) {
+                // successful
+            }
+        } finally {
+            readOnlySuperuser.logout();
         }
     }
 
@@ -139,25 +142,29 @@
         // get other session
         Session otherSession = helper.getReadWriteSession();
 
-        // get lock target node in destination wsp through other session
-        Node lockTarget = (Node) otherSession.getItem(node2.getPath());
-
-        // add mixin "lockable" to be able to lock the node
-        if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
-            lockTarget.addMixin(mixLockable);
-            lockTarget.getParent().save();
-        }
-
-        // lock dst parent node using other session
-        lockTarget.lock(true, true);
-
         try {
-            workspace.copy(node1.getPath(), dstAbsPath);
-            fail("LockException was expected.");
-        } catch (LockException e) {
-            // successful
+            // get lock target node in destination wsp through other session
+            Node lockTarget = (Node) otherSession.getItem(node2.getPath());
+
+            // add mixin "lockable" to be able to lock the node
+            if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
+                lockTarget.addMixin(mixLockable);
+                lockTarget.getParent().save();
+            }
+
+            // lock dst parent node using other session
+            lockTarget.lock(true, true);
+
+            try {
+                workspace.copy(node1.getPath(), dstAbsPath);
+                fail("LockException was expected.");
+            } catch (LockException e) {
+                // successful
+            } finally {
+                lockTarget.unlock();
+            }
         } finally {
-            lockTarget.unlock();
+            otherSession.logout();
         }
     }
 }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java Tue Apr 26 09:40:05 2005
@@ -91,13 +91,16 @@
      */
     public void testMoveNodesAccessDenied() throws RepositoryException {
         Session readOnlySuperuser = helper.getReadOnlySession();
-
-        String dstAbsPath = node2.getPath() + "/" + node1.getName();
         try {
-            readOnlySuperuser.getWorkspace().move(node1.getPath(), dstAbsPath);
-            fail("Copy in a read-only session should throw an AccessDeniedException.");
-        } catch (AccessDeniedException e) {
-            // successful
+            String dstAbsPath = node2.getPath() + "/" + node1.getName();
+            try {
+                readOnlySuperuser.getWorkspace().move(node1.getPath(), dstAbsPath);
+                fail("Copy in a read-only session should throw an AccessDeniedException.");
+            } catch (AccessDeniedException e) {
+                // successful
+            }
+        } finally {
+            readOnlySuperuser.logout();
         }
     }
 
@@ -140,25 +143,29 @@
         // get other session
         Session otherSession = helper.getReadWriteSession();
 
-        // get lock target node in destination wsp through other session
-        Node lockTarget = (Node) otherSession.getItem(node2.getPath());
-
-        // add mixin "lockable" to be able to lock the node
-        if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
-            lockTarget.addMixin(mixLockable);
-            lockTarget.getParent().save();
-        }
-
-        // lock dst parent node using other session
-        lockTarget.lock(true, true);
-
         try {
-            workspace.move(node1.getPath(), dstAbsPath);
-            fail("LockException was expected.");
-        } catch (LockException e) {
-            // successful
+            // get lock target node in destination wsp through other session
+            Node lockTarget = (Node) otherSession.getItem(node2.getPath());
+
+            // add mixin "lockable" to be able to lock the node
+            if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
+                lockTarget.addMixin(mixLockable);
+                lockTarget.getParent().save();
+            }
+
+            // lock dst parent node using other session
+            lockTarget.lock(true, true);
+
+            try {
+                workspace.move(node1.getPath(), dstAbsPath);
+                fail("LockException was expected.");
+            } catch (LockException e) {
+                // successful
+            } finally {
+                lockTarget.unlock();
+            }
         } finally {
-            lockTarget.unlock();
+            otherSession.logout();
         }
     }
 }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceReadMethodsTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceReadMethodsTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceReadMethodsTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceReadMethodsTest.java Tue Apr 26 09:40:05 2005
@@ -46,10 +46,13 @@
      */
     public void testGetSession() throws RepositoryException {
         Session session = helper.getReadOnlySession();
-        Session otherSession = session.getWorkspace().getSession();
-        assertSame("Workspace.getSession() returns not the same session object.",
-                session, otherSession);
-        session.logout();
+        try {
+            Session otherSession = session.getWorkspace().getSession();
+            assertSame("Workspace.getSession() returns not the same session object.",
+                    session, otherSession);
+        } finally {
+            session.logout();
+        }
     }
 
     /**
@@ -58,12 +61,15 @@
      */
     public void testGetName() throws RepositoryException {
         Session session = helper.getReadOnlySession(workspaceName);
-        String name = session.getWorkspace().getName();
-        if (workspaceName != null) {
-            assertEquals("Workspace.getName() returns wrong name.",
-                    workspaceName, name);
+        try {
+            String name = session.getWorkspace().getName();
+            if (workspaceName != null) {
+                assertEquals("Workspace.getName() returns wrong name.",
+                        workspaceName, name);
+            }
+        } finally {
+            session.logout();
         }
-        session.logout();
     }
 
     /**
@@ -72,8 +78,11 @@
      */
     public void testGetQueryManager() throws RepositoryException {
         Workspace ws = helper.getReadOnlySession().getWorkspace();
-        assertNotNull("Workspace does not return a QueryManager object.", ws.getQueryManager());
-        ws.getSession().logout();
+        try {
+            assertNotNull("Workspace does not return a QueryManager object.", ws.getQueryManager());
+        } finally {
+            ws.getSession().logout();
+        }
     }
 
     /**
@@ -83,12 +92,15 @@
      */
     public void testGetAccessibleWorkspaceNames() throws RepositoryException {
         Session session = helper.getReadOnlySession();
-        String[] wsNames = session.getWorkspace().getAccessibleWorkspaceNames();
-        for (int i = 0; i < wsNames.length; i++) {
-            // login
-            Session s = helper.getReadOnlySession(wsNames[i]);
-            s.logout();
+        try {
+            String[] wsNames = session.getWorkspace().getAccessibleWorkspaceNames();
+            for (int i = 0; i < wsNames.length; i++) {
+                // login
+                Session s = helper.getReadOnlySession(wsNames[i]);
+                s.logout();
+            }
+        } finally {
+            session.logout();
         }
-        session.logout();
     }
 }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/lock/LockTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/lock/LockTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/lock/LockTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/lock/LockTest.java Tue Apr 26 09:40:05 2005
@@ -116,23 +116,24 @@
         // create new session
         Session otherSuperuser = helper.getSuperuserSession();
 
-        // get same node
-        Node n2 = (Node) otherSuperuser.getItem(n1.getPath());
-
-        // assert: lock token must be null for other session
-        assertNull("Lock token must be null for other session",
-                n2.getLock().getLockToken());
-
-        // assert: modifying same node in other session must fail
         try {
-            n2.addNode(nodeName2, testNodeType);
-            fail("modifying same node in other session must fail");
-        } catch (LockException e) {
-            // expected
-        }
+            // get same node
+            Node n2 = (Node) otherSuperuser.getItem(n1.getPath());
 
-        // logout
-        otherSuperuser.logout();
+            // assert: lock token must be null for other session
+            assertNull("Lock token must be null for other session",
+                    n2.getLock().getLockToken());
+
+            // assert: modifying same node in other session must fail
+            try {
+                n2.addNode(nodeName2, testNodeType);
+                fail("modifying same node in other session must fail");
+            } catch (LockException e) {
+                // expected
+            }
+        } finally {
+            otherSuperuser.logout();
+        }
     }
 
     /**
@@ -371,20 +372,24 @@
         // create new session
         Session otherSuperuser = helper.getSuperuserSession();
 
-        // get node created above
-        Node n2 = (Node) otherSuperuser.getItem(n1.getPath());
+        Lock lock;
+        try {
+            // get node created above
+            Node n2 = (Node) otherSuperuser.getItem(n1.getPath());
 
-        // lock node
-        Lock lock = n2.lock(false, true);
+            // lock node
+            lock = n2.lock(false, true);
 
-        // assert: lock must be alive
-        assertTrue("lock must be alive", lock.isLive());
+            // assert: lock must be alive
+            assertTrue("lock must be alive", lock.isLive());
 
-        // assert: node must be locked
-        assertTrue("node must be locked", n1.isLocked());
+            // assert: node must be locked
+            assertTrue("node must be locked", n1.isLocked());
+        } finally {
+            // log out
+            otherSuperuser.logout();
+        }
 
-        // log out
-        otherSuperuser.logout();
 
         // assert: lock must not be alive
         assertFalse("lock must not be alive", lock.isLive());
@@ -405,29 +410,31 @@
         // create new session
         Session otherSuperuser = helper.getSuperuserSession();
 
-        // get node created above
-        Node n2 = (Node) otherSuperuser.getItem(n1.getPath());
-
-        // lock node
-        Lock lock = n2.lock(false, true);
-
-        // assert: user must get non-null token
-        assertNotNull("user must get non-null token", lock.getLockToken());
-
-        // transfer to standard session
-        String lockToken = lock.getLockToken();
-        otherSuperuser.removeLockToken(lockToken);
-        superuser.addLockToken(lockToken);
+        try {
+            // get node created above
+            Node n2 = (Node) otherSuperuser.getItem(n1.getPath());
 
-        // assert: user must get null token
-        assertNull("user must get null token", lock.getLockToken());
+            // lock node
+            Lock lock = n2.lock(false, true);
 
-        // assert: user must get non-null token
-        assertNotNull("user must get non-null token",
-                n1.getLock().getLockToken());
+            // assert: user must get non-null token
+            assertNotNull("user must get non-null token", lock.getLockToken());
 
-        // log out
-        otherSuperuser.logout();
+            // transfer to standard session
+            String lockToken = lock.getLockToken();
+            otherSuperuser.removeLockToken(lockToken);
+            superuser.addLockToken(lockToken);
+
+            // assert: user must get null token
+            assertNull("user must get null token", lock.getLockToken());
+
+            // assert: user must get non-null token
+            assertNotNull("user must get non-null token",
+                    n1.getLock().getLockToken());
+        } finally {
+            // log out
+            otherSuperuser.logout();
+        }
     }
 
     /**
@@ -442,19 +449,21 @@
         // create new session
         Session otherSuperuser = helper.getSuperuserSession();
 
-        // get node created above
-        Node n2 = (Node) otherSuperuser.getItem(n1.getPath());
-
-        // lock node
-        Lock lock = n2.lock(false, false);
+        try {
+            // get node created above
+            Node n2 = (Node) otherSuperuser.getItem(n1.getPath());
 
-        // transfer to standard session
-        String lockToken = lock.getLockToken();
-        otherSuperuser.removeLockToken(lockToken);
-        superuser.addLockToken(lockToken);
+            // lock node
+            Lock lock = n2.lock(false, false);
 
-        // log out
-        otherSuperuser.logout();
+            // transfer to standard session
+            String lockToken = lock.getLockToken();
+            otherSuperuser.removeLockToken(lockToken);
+            superuser.addLockToken(lockToken);
+        } finally {
+            // log out
+            otherSuperuser.logout();
+        }
 
         // assert: node still locked
         assertTrue(n1.isLocked());

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/SaveTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/SaveTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/SaveTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/SaveTest.java Tue Apr 26 09:40:05 2005
@@ -182,8 +182,8 @@
         lockable.lock(false, true);
 
         Session readWrite = helper.getReadWriteSession();
-        Query query = readWrite.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
         try {
+            Query query = readWrite.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
             query.storeAsNode(testRoot + "/" + nodeName1 + "/" + nodeName2);
             fail("Query.storeAsNode() must throw LockException, parent node is locked.");
         } catch (LockException e) {

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/MergeNodeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/MergeNodeTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/MergeNodeTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/MergeNodeTest.java Tue Apr 26 09:40:05 2005
@@ -276,19 +276,22 @@
         String pathRelToRoot = nodeToMerge.getPath().substring(1);
         // access node through another session to lock it
         Session session2 = helper.getSuperuserSession();
-        Node node2 = session2.getRootNode().getNode(pathRelToRoot);
-        node2.lock(false, false);
-
         try {
-            nodeToMerge.merge(workspace.getName(), false);
-            fail("merge must throw a LockException if applied on a " +
-                    "locked node");
-        } catch (LockException e) {
-            // success
-        }
+            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
+            node2.lock(false, false);
 
-        node2.unlock();
-        session2.logout();
+            try {
+                nodeToMerge.merge(workspace.getName(), false);
+                fail("merge must throw a LockException if applied on a " +
+                        "locked node");
+            } catch (LockException e) {
+                // success
+            }
+
+            node2.unlock();
+        } finally {
+            session2.logout();
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java Tue Apr 26 09:40:05 2005
@@ -65,17 +65,21 @@
         // The superuser session for the second workspace
         Session superuserW2 = helper.getSuperuserSession(workspaceName);
 
-        // check path to version storage
-        assertTrue("Version strorage must be reflected as a subtree below the node '" + versionStoragePath + "'", superuserW2.getRootNode().hasNode(versionStoragePath));
-
-        // check if subnodes in versionStorage are protected
         try {
-            // try to create a version node
-            Node versionStorageNodeW2 = superuserW2.getRootNode().getNode(versionStoragePath);
-            versionStorageNodeW2.addNode(nodeName1, ntVersion);
-            fail("It should not be possible to add a subnode/version in version storage.");
-        } catch (ConstraintViolationException e) {
-            // success
+            // check path to version storage
+            assertTrue("Version strorage must be reflected as a subtree below the node '" + versionStoragePath + "'", superuserW2.getRootNode().hasNode(versionStoragePath));
+
+            // check if subnodes in versionStorage are protected
+            try {
+                // try to create a version node
+                Node versionStorageNodeW2 = superuserW2.getRootNode().getNode(versionStoragePath);
+                versionStorageNodeW2.addNode(nodeName1, ntVersion);
+                fail("It should not be possible to add a subnode/version in version storage.");
+            } catch (ConstraintViolationException e) {
+                // success
+            }
+        } finally {
+            superuserW2.logout();
         }
     }
 

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java?rev=164811&r1=164810&r2=164811&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java Tue Apr 26 09:40:05 2005
@@ -115,6 +115,9 @@
             wVersionableNode.remove();
             wVersionableNode2.remove();
             wTestRoot.save();
+            if (wSuperuser != null) {
+                wSuperuser.logout();
+            }
         } finally {
             super.tearDown();
         }



Mime
View raw message