jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r927858 - /jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/RepositoryStubImpl.java
Date Fri, 26 Mar 2010 14:09:52 GMT
Author: jukka
Date: Fri Mar 26 14:09:52 2010
New Revision: 927858

URL: http://svn.apache.org/viewvc?rev=927858&view=rev
Log:
JCRRMI-27: JSR-283: Support AccessControlManager

Some streamlining of the test setup

Modified:
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/RepositoryStubImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/RepositoryStubImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/RepositoryStubImpl.java?rev=927858&r1=927857&r2=927858&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/RepositoryStubImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/RepositoryStubImpl.java
Fri Mar 26 14:09:52 2010
@@ -60,20 +60,10 @@ public class RepositoryStubImpl extends 
         if (repository == null) {
             try {
                 Repository repo = super.getRepository();
-                SessionImpl session = (SessionImpl) repo.login(
-                        new SimpleCredentials("admin", "admin".toCharArray()));
-                try {
-                    for (Principal p : session.getSubject().getPrincipals()) {
-                        if (!(p instanceof Group)) {
-                            principal = p;
-                        }
-                    }
-                } finally {
-                    session.logout();
-                }
+                principal = findKnownPrincipal(repo);
 
                 RemoteAdapterFactory raf = new ServerAdapterFactory();
-                remote = raf.getRemoteRepository(super.getRepository());
+                remote = raf.getRemoteRepository(repo);
 
                 // Make sure that the remote reference survives serialization
                 ByteArrayOutputStream buffer = new ByteArrayOutputStream();
@@ -93,14 +83,26 @@ public class RepositoryStubImpl extends 
         return repository;
     }
 
+    private static Principal findKnownPrincipal(Repository repo)
+            throws RepositoryException {
+        SessionImpl session = (SessionImpl) repo.login(
+                new SimpleCredentials("admin", "admin".toCharArray()));
+        try {
+            for (Principal principal : session.getSubject().getPrincipals()) {
+                if (!(principal instanceof Group)) {
+                    return principal;
+                }
+            }
+            throw new RepositoryException("Known principal not found");
+        } finally {
+            session.logout();
+        }
+    }
+
     @Override
     public Principal getKnownPrincipal(Session ignored)
             throws RepositoryException {
-        if (principal != null) {
-            return principal;
-        } else {
-            throw new RepositoryException("no applicable principal found");
-        }
+        return principal;
     }
 
 }



Mime
View raw message