jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r758649 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlListTest.java
Date Thu, 26 Mar 2009 14:03:32 GMT
Author: angela
Date: Thu Mar 26 14:03:23 2009
New Revision: 758649

URL: http://svn.apache.org/viewvc?rev=758649&view=rev
Log:
JCR-1588: Access Control

tests: missing session.logout in case of failing setup

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlListTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlListTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlListTest.java?rev=758649&r1=758648&r2=758649&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlListTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlListTest.java
Thu Mar 26 14:03:23 2009
@@ -25,7 +25,6 @@
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import java.security.Principal;
 import java.security.acl.Group;
 import java.util.ArrayList;
@@ -53,36 +52,41 @@
         //checkSupportedOption(Repository.OPTION_ACCESS_CONTROL_SUPPORTED);
         super.setUp();
 
-        // TODO: retrieve targetPath from configuration
-        Node n = testRootNode.addNode(nodeName1, testNodeType);
-        superuser.save();
-        path = n.getPath();
-
-        privs = acMgr.getSupportedPrivileges(path);
-        if (privs.length == 0) {
-            throw new NotExecutableException("No supported privileges at absPath " + path);
-        }
-
         // TODO: make sure, entries to ADD are not present yet.
         // TODO: retrieve principal name from tck-Configuration
         // TODO: get rid of SessionImpl dependency
-        Session s = superuser;
-        if (s instanceof SessionImpl) {
-            for (Iterator it = ((SessionImpl) s).getSubject().getPrincipals().iterator();
it.hasNext();) {
-                Principal p = (Principal) it.next();
-                if (!(p instanceof Group)) {
-                    testPrincipal = p;
-                }
+        try {
+            // TODO: retrieve targetPath from configuration
+            Node n = testRootNode.addNode(nodeName1, testNodeType);
+            superuser.save();
+            path = n.getPath();
+
+            privs = acMgr.getSupportedPrivileges(path);
+
+            if (privs.length == 0) {
+                throw new NotExecutableException("No supported privileges at absPath " +
path);
             }
-            if (testPrincipal == null) {
-                throw new NotExecutableException("Test principal missing.");
+
+            if (superuser instanceof SessionImpl) {
+                for (Iterator it = ((SessionImpl) superuser).getSubject().getPrincipals().iterator();
it.hasNext();) {
+                    Principal p = (Principal) it.next();
+                    if (!(p instanceof Group)) {
+                        testPrincipal = p;
+                    }
+                }
+                if (testPrincipal == null) {
+                    throw new NotExecutableException("Test principal missing.");
+                }
+            } else {
+                throw new NotExecutableException("SessionImpl expected");
             }
-        } else {
-            throw new NotExecutableException("SessionImpl expected");
-        }
 
-        // remember existing entries for test-principal -> later restore.
-        privilegesToRestore = currentPrivileges(getList(acMgr, path), testPrincipal);
+            // remember existing entries for test-principal -> later restore.
+            privilegesToRestore = currentPrivileges(getList(acMgr, path), testPrincipal);
+        } catch (Exception e) {
+            superuser.logout();
+            throw e;
+        }
     }
 
     protected void tearDown() throws Exception {



Mime
View raw message