portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security TestUserManager.java
Date Wed, 15 Sep 2004 22:40:05 GMT
taylor      2004/09/15 15:40:05

  Modified:    components/security/src/test/org/apache/jetspeed/security
                        TestUserManager.java
  Log:
  added test for getUsers
  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.8       +42 -0     jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestUserManager.java
  
  Index: TestUserManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestUserManager.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestUserManager.java	27 May 2004 19:45:32 -0000	1.7
  +++ TestUserManager.java	15 Sep 2004 22:40:05 -0000	1.8
  @@ -15,6 +15,8 @@
   package org.apache.jetspeed.security;
   
   import java.security.Principal;
  +import java.util.Iterator;
  +import java.util.Set;
   import java.util.prefs.Preferences;
   
   import javax.security.auth.Subject;
  @@ -24,7 +26,12 @@
   import junit.framework.Test;
   import junit.framework.TestSuite;
   
  +import org.apache.jetspeed.components.persistence.store.Filter;
  +import org.apache.jetspeed.components.persistence.store.PersistenceStore;
  +import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
   import org.apache.jetspeed.security.impl.PassiveCallbackHandler;
  +import org.apache.jetspeed.security.om.JetspeedGroupPrincipal;
  +import org.apache.jetspeed.security.om.impl.JetspeedGroupPrincipalImpl;
   
   /**
    * <p>Unit testing for {@link UserManager}.</p>
  @@ -170,6 +177,41 @@
           }
       }
   
  +    public void testGetUsers()
  +    throws Exception
  +    {
  +        ums.addUser("one", "one-pw");
  +        ums.addUser("two", "two-pw");
  +        ums.addUser("three", "three-pw");
  +        int count = 0;
  +        Iterator it = ums.getUsers("");
  +        while (it.hasNext())
  +        {            
  +            User user = (User)it.next();
  +            Iterator principals = user.getSubject().getPrincipals().iterator();
  +            while (principals.hasNext())
  +            {
  +                Principal principal = (Principal)principals.next();
  +                System.out.println("principal = " + principal.getName());
  +                if (principal.getName().equals("one"))
  +                {
  +                    count++;
  +                }
  +                else if (principal.getName().equals("two"))
  +                {
  +                    count++;
  +                }
  +                else if (principal.getName().equals("three"))
  +                {
  +                    count++;
  +                }                                
  +            }
  +        }
  +        assertTrue("user count should be 3", count == 3);
  +        ums.removeUser("one");
  +        ums.removeUser("two");
  +        ums.removeUser("three");
  +    }
       /**
        * <p>Destroy user test object.</p>
        */
  
  
  

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


Mime
View raw message