portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r484887 - in /portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security: TestAuthenticationProviderProxy.java TestGroupManager.java TestPermissionManager.java TestRoleManager.java
Date Sat, 09 Dec 2006 01:39:55 GMT
Author: taylor
Date: Fri Dec  8 17:39:53 2006
New Revision: 484887

URL: http://svn.apache.org/viewvc?view=rev&rev=484887
Log:
patch from Hajo Birthelmer cleaning up security tests so that they run even if db isn't cleaned

Modified:
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestAuthenticationProviderProxy.java
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestGroupManager.java
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestPermissionManager.java
    portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestRoleManager.java

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestAuthenticationProviderProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestAuthenticationProviderProxy.java?view=diff&rev=484887&r1=484886&r2=484887
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestAuthenticationProviderProxy.java
(original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestAuthenticationProviderProxy.java
Fri Dec  8 17:39:53 2006
@@ -42,7 +42,9 @@
  */
 public class TestAuthenticationProviderProxy extends AbstractSecurityTestcase
 {
-
+	int userCount = 0;
+	int usersAdded = 0;
+	
     /**
      * @see junit.framework.TestCase#setUp()
      */
@@ -136,9 +138,10 @@
                 users.next();
                 count++;
             }
+            
             // assertEquals(8, count);
-
-            assertEquals(5, count);
+           
+            assertEquals(userCount + usersAdded, count);
         }
         catch (SecurityException sex)
         {
@@ -257,11 +260,30 @@
         final String[] groups = new String[] { "testgroup1", "testgroup1.subgroup1", "testgroup1.subgroup1.subgroup2",
                 "testgroup2", "testgroup2.subgroup1" };
 
+        
+        //before we adding users make sure we know how mnay we have
+        try
+        {
+	        Iterator it = ums.getUsers("");
+	        userCount = 0;
+	        while (it.hasNext())
+	        {
+	        	it.next();
+	        	userCount++;
+	        }
+        }
+        catch (Exception e)
+        {
+        	
+        }
+    
+        usersAdded = 0;
         for (int i = 0; i < users.length; i++)
         {
             try
             {
                 ums.addUser(users[i], "password");
+                usersAdded++;
             }
             catch (SecurityException e)
             {

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestGroupManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestGroupManager.java?view=diff&rev=484887&r1=484886&r2=484887
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestGroupManager.java
(original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestGroupManager.java
Fri Dec  8 17:39:53 2006
@@ -471,12 +471,23 @@
      */
     public void testGetGroups() throws Exception
     {
-        ums.addUser("notme", "one-pw");
+    	int groupCount = 0;
+    	int groupAdded = 0;
+        Iterator it = gms.getGroups("");
+        while (it.hasNext())
+        {
+            Group group = (Group) it.next();
+            System.out.println("Group is " + group);
+            groupCount++;
+        }
+
+    	ums.addUser("notme", "one-pw");
         gms.addGroup("g1");
         gms.addGroup("g2");
         gms.addGroup("g3");
+        groupAdded = 3;
         int count = 0;
-        Iterator it = gms.getGroups("");
+        it = gms.getGroups("");
         while (it.hasNext())
         {
             Group group = (Group) it.next();
@@ -487,7 +498,7 @@
         gms.removeGroup("g1");
         gms.removeGroup("g2");
         gms.removeGroup("g3");
-        //assertTrue("group count should be 3", count == 3);
+        assertTrue("group count should be " + (groupAdded + groupCount), count == (groupAdded
+ groupCount));
                
     }
     

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestPermissionManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestPermissionManager.java?view=diff&rev=484887&r1=484886&r2=484887
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestPermissionManager.java
(original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestPermissionManager.java
Fri Dec  8 17:39:53 2006
@@ -84,12 +84,12 @@
         //////////////////////////////////////////////////////////////////////////
         // setup
         ////////////
-        UserPrincipal adminUser = new UserPrincipalImpl("admin");
-        UserPrincipal userUser = new UserPrincipalImpl("user");
-        PortletPermission adminPerm = new PortletPermission("admin::*", "view, edit");
-        PortletPermission userPerm = new PortletPermission("demo::*", "view, edit");
-        RolePrincipal adminRole = new RolePrincipalImpl("admin");
-        RolePrincipal userRole = new RolePrincipalImpl("user");
+        UserPrincipal adminUser = new UserPrincipalImpl("adminTEST");
+        UserPrincipal userUser = new UserPrincipalImpl("userTEST");
+        PortletPermission adminPerm = new PortletPermission("adminTEST::*", "view, edit");
+        PortletPermission userPerm = new PortletPermission("demoTEST::*", "view, edit");
+        RolePrincipal adminRole = new RolePrincipalImpl("adminTEST");
+        RolePrincipal userRole = new RolePrincipalImpl("userTEST");
         
         try
         {

Modified: portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestRoleManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestRoleManager.java?view=diff&rev=484887&r1=484886&r2=484887
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestRoleManager.java
(original)
+++ portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestRoleManager.java
Fri Dec  8 17:39:53 2006
@@ -35,7 +35,6 @@
  */
 public class TestRoleManager extends AbstractSecurityTestcase
 {
-
     /**
      * @see junit.framework.TestCase#setUp()
      */
@@ -604,13 +603,24 @@
      */
     public void testGetRoles() throws Exception
     {
+    	int roleCount = 0;
+    	int rolesAdded = 0;
+        Iterator it = rms.getRoles("");
+        while (it.hasNext())
+        {
+            Role role = (Role) it.next();
+            roleCount++;
+        }
         ums.addUser("notme", "one-pw");
         gms.addGroup("g1");
         rms.addRole("r1");
         rms.addRole("r2");
         rms.addRole("r3");
+        rolesAdded = 3;
+
         int count = 0;
-        Iterator it = rms.getRoles("");
+        
+        it = rms.getRoles("");
         while (it.hasNext())
         {
             Role role = (Role) it.next();
@@ -621,7 +631,7 @@
         rms.removeRole("r1");
         rms.removeRole("r2");
         rms.removeRole("r3");
-        assertTrue("role count should be 3", count == 3);
+        assertTrue("role count should be " + (rolesAdded + roleCount), count == (rolesAdded
+ roleCount));
                
     }
    



---------------------------------------------------------------------
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