You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2009/03/26 14:32:46 UTC

svn commit: r758629 - in /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core: NodeImplTest.java XATest.java

Author: angela
Date: Thu Mar 26 13:32:40 2009
New Revision: 758629

URL: http://svn.apache.org/viewvc?rev=758629&view=rev
Log:
tests: missing session.logout

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java?rev=758629&r1=758628&r2=758629&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java Thu Mar 26 13:32:40 2009
@@ -79,13 +79,16 @@
 
     private static Principal getReadOnlyPrincipal() throws RepositoryException, NotExecutableException {
         SessionImpl s = (SessionImpl) helper.getReadOnlySession();
-        for (Iterator it = s.getSubject().getPrincipals().iterator(); it.hasNext();) {
-            Principal p = (Principal) it.next();
-            if (!(p instanceof Group)) {
-                return p;
+        try {
+            for (Iterator it = s.getSubject().getPrincipals().iterator(); it.hasNext();) {
+                Principal p = (Principal) it.next();
+                if (!(p instanceof Group)) {
+                    return p;
+                }
             }
+        } finally {
+            s.logout();
         }
-        s.logout();
         throw new NotExecutableException();
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java?rev=758629&r1=758628&r2=758629&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java Thu Mar 26 13:32:40 2009
@@ -54,28 +54,31 @@
 
         // clean testroot on second workspace
         Session s2 = helper.getSuperuserSession(workspaceName);
-        Node root = s2.getRootNode();
-        if (root.hasNode(testPath)) {
-            // clean test root
-            Node testRootNode = root.getNode(testPath);
-            for (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
-                children.nextNode().remove();
-            }
-        } else {
-            // create nodes to testPath
-            StringTokenizer names = new StringTokenizer(testPath, "/");
-            Node currentNode = root;
-            while (names.hasMoreTokens()) {
-                String name = names.nextToken();
-                if (currentNode.hasNode(name)) {
-                    currentNode = currentNode.getNode(name);
-                } else {
-                    currentNode = currentNode.addNode(name, testNodeType);
+        try {
+            Node root = s2.getRootNode();
+            if (root.hasNode(testPath)) {
+                // clean test root
+                Node testRootNode = root.getNode(testPath);
+                for (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
+                    children.nextNode().remove();
+                }
+            } else {
+                // create nodes to testPath
+                StringTokenizer names = new StringTokenizer(testPath, "/");
+                Node currentNode = root;
+                while (names.hasMoreTokens()) {
+                    String name = names.nextToken();
+                    if (currentNode.hasNode(name)) {
+                        currentNode = currentNode.getNode(name);
+                    } else {
+                        currentNode = currentNode.addNode(name, testNodeType);
+                    }
                 }
             }
+            root.save();
+        } finally {
+            s2.logout();
         }
-        root.save();
-
     }
 
     /**
@@ -1513,24 +1516,27 @@
         final String testNodePath = testPath + "/" + Math.random();
 
         Session session = helper.getSuperuserSession();
-
-        // Add node
-        doTransactional(new Operation() {
-            public void invoke(Session session) throws Exception {
-                session.getRootNode().addNode(testNodePath);
-                session.save();
-            }
-        }, session);
-
-        for (int i = 1; i <= 3; i++) {
-            // Set property "name" to value "value"
+        try {
+            // Add node
             doTransactional(new Operation() {
                 public void invoke(Session session) throws Exception {
-                    Node n = (Node) session.getItem("/" + testNodePath);
-                    n.setProperty("name", "value");
+                    session.getRootNode().addNode(testNodePath);
                     session.save();
                 }
             }, session);
+
+            for (int i = 1; i <= 3; i++) {
+                // Set property "name" to value "value"
+                doTransactional(new Operation() {
+                    public void invoke(Session session) throws Exception {
+                        Node n = (Node) session.getItem("/" + testNodePath);
+                        n.setProperty("name", "value");
+                        session.save();
+                    }
+                }, session);
+            }
+        } finally {
+            session.logout();
         }
     }
 
@@ -1545,31 +1551,34 @@
         final String testNodePath = testPath + "/" + Math.random();
 
         Session session = helper.getSuperuserSession();
-
-        for (int i = 1; i <= 3; i++) {
-            // Add parent node
-            doTransactional(new Operation() {
-                public void invoke(Session session) throws Exception {
-                    session.getRootNode().addNode(testNodePath);
-                    session.save();
-                }
-            }, session);
-
-            // Add child node
-            doTransactional(new Operation() {
-                public void invoke(Session session) throws Exception {
-                    session.getRootNode().addNode(testNodePath + "/subnode");
-                    session.save();
-                }
-            }, session);
-
-            // Remove parent node
-            doTransactional(new Operation() {
-                public void invoke(Session session) throws Exception {
-                    session.getRootNode().getNode(testNodePath).remove();
-                    session.save();
-                }
-            }, session);
+        try {
+            for (int i = 1; i <= 3; i++) {
+                // Add parent node
+                doTransactional(new Operation() {
+                    public void invoke(Session session) throws Exception {
+                        session.getRootNode().addNode(testNodePath);
+                        session.save();
+                    }
+                }, session);
+
+                // Add child node
+                doTransactional(new Operation() {
+                    public void invoke(Session session) throws Exception {
+                        session.getRootNode().addNode(testNodePath + "/subnode");
+                        session.save();
+                    }
+                }, session);
+
+                // Remove parent node
+                doTransactional(new Operation() {
+                    public void invoke(Session session) throws Exception {
+                        session.getRootNode().getNode(testNodePath).remove();
+                        session.save();
+                    }
+                }, session);
+            }
+        } finally {
+            session.logout();
         }
     }