You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2014/01/23 22:19:55 UTC

svn commit: r1560809 - /myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletRequest.java

Author: lu4242
Date: Thu Jan 23 21:19:55 2014
New Revision: 1560809

URL: http://svn.apache.org/r1560809
Log:
MYFACESTEST-65 Implement HttpServletRequest.isUserInRole(String)

Modified:
    myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletRequest.java

Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletRequest.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletRequest.java?rev=1560809&r1=1560808&r2=1560809&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletRequest.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletRequest.java Thu Jan 23 21:19:55 2014
@@ -294,6 +294,24 @@ public class MockHttpServletRequest impl
     {
         this.servletPath = servletPath;
     }
+    
+    public void addUserRole(String role)
+    {
+        if (this.roles == null)
+        {
+            this.roles = new ArrayList<String>();
+        }
+        this.roles.add(role);
+    }
+        
+    public void clearUserRoles()
+    {
+        if (this.roles == null)
+        {
+            return;
+        }
+        this.roles.clear();
+    }
 
     // ------------------------------------------------------ Instance Variables
 
@@ -314,6 +332,7 @@ public class MockHttpServletRequest impl
     private List cookies = new ArrayList();
     private Vector locales = null;
     private String method = null;
+    private List<String> roles = null;
 
     // ---------------------------------------------- HttpServletRequest Methods
 
@@ -607,9 +626,7 @@ public class MockHttpServletRequest impl
     /** {@inheritDoc} */
     public boolean isUserInRole(String role)
     {
-
-        throw new UnsupportedOperationException();
-
+        return (this.roles != null) ? this.roles.contains(role) : false;
     }
 
     // ------------------------------------------------- ServletRequest Methods