portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r888711 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src: main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java
Date Wed, 09 Dec 2009 06:33:07 GMT
Author: ate
Date: Wed Dec  9 06:33:06 2009
New Revision: 888711

URL: http://svn.apache.org/viewvc?rev=888711&view=rev
Log:
JS2-1088: fixing TestUserInfoManager testcase
As the UserInfoManager no longer retrieves user attributes from the UserManager but takes
them directly from the Subject UserPrincipal, the testcase needed to be adjusted to use a
properly setup UserPrincipal to test against as well.
Also, I've fixed a small glitch I introduced with my previous changes to never return null
for an authenticated User (by the way untested by the testcase)

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java?rev=888711&r1=888710&r2=888711&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java
Wed Dec  9 06:33:06 2009
@@ -104,11 +104,16 @@
             log.debug("Getting user info for portlet application: " + appName);
         
         Map<String, String> userInfo = getUserInformation(context);
-        if (null == userInfo || userInfo.isEmpty())
+        if (null == userInfo)
         {
-            log.debug(PortletRequest.USER_INFO + " is null or empty");
+            log.debug(PortletRequest.USER_INFO + " is null");
             return null;
         }
+        else if (userInfo.isEmpty())
+        {
+            log.debug(PortletRequest.USER_INFO + " is empty");
+            return Collections.emptyMap();
+        }
         
         return mapUserInfo(userInfo, getLinkedUserAttr(appName));
     }
@@ -149,17 +154,20 @@
     protected Map<String, String> mapUserInfo(Map<String, String> userInfo, List<UserAttributeRef>
linkedUserAttributes)
     {
         Map<String, String>userInfoMap = new HashMap<String, String>();
-        for (UserAttributeRef currentAttributeRef : linkedUserAttributes)
+        if (linkedUserAttributes != null)
         {
-            String key = currentAttributeRef.getNameLink();
-            String name = currentAttributeRef.getName();
-            if (key == null)
-            {                
-                key = name;
-            }
-            if (userInfo.containsKey(key))
+            for (UserAttributeRef currentAttributeRef : linkedUserAttributes)
             {
-                userInfoMap.put(name, userInfo.get(key));
+                String key = currentAttributeRef.getNameLink();
+                String name = currentAttributeRef.getName();
+                if (key == null)
+                {                
+                    key = name;
+                }
+                if (userInfo.containsKey(key))
+                {
+                    userInfoMap.put(name, userInfo.get(key));
+                }
             }
         }
         return userInfoMap;
@@ -194,4 +202,4 @@
         }
         return userInfo;
     }
-}
\ No newline at end of file
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java?rev=888711&r1=888710&r2=888711&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java
Wed Dec  9 06:33:06 2009
@@ -169,9 +169,20 @@
      * @return The request context.
      */
     private RequestContext initRequestContext(String username)
-    {
+    {        
         RequestContext request = new MockRequestContext("default-other");
-        request.setSubject(JetspeedSubjectFactory.createSubject(new UserImpl(username), null,
null, null));
+        User user = null;
+        // need to retrieve user from usermanager to retrieve previously configured user
attributes
+        // if user doesn't exist (e.g. anon user), a transient UserImpl will be used instead
+        try
+        {
+            user = ums.getUser(username);
+        }
+        catch (SecurityException e)
+        {
+            user = new UserImpl(username);
+        }
+        request.setSubject(JetspeedSubjectFactory.createSubject(user, null, null, null));
         return request;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message