portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r418603 - /portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/TestPermissionManager.java
Date Sun, 02 Jul 2006 15:06:39 GMT
Author: ate
Date: Sun Jul  2 08:06:38 2006
New Revision: 418603

URL: http://svn.apache.org/viewvc?rev=418603&view=rev
Log:
Cannot reliably test unordered lists values using index based comparisions. Added sorting
to make sure it works allways.

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

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?rev=418603&r1=418602&r2=418603&view=diff
==============================================================================
--- 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
Sun Jul  2 08:06:38 2006
@@ -19,8 +19,10 @@
 import java.security.Permissions;
 import java.security.Principal;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Set;
@@ -44,6 +46,14 @@
  */
 public class TestPermissionManager extends AbstractSecurityTestcase
 {
+    private static final Comparator principalComparator = new Comparator()
+    {
+
+        public int compare(Object arg0, Object arg1)
+        {
+            return ((Principal)arg0).getName().compareTo(((Principal)arg1).getName());
+        }
+    };
 
     /**
      * @see junit.framework.TestCase#setUp()
@@ -778,6 +788,7 @@
         Collection principals = pms.getPrincipals(perm1);        
         assertTrue("principal count should be 2 ", principals.size() == 2);        
         Object [] array = (Object[])principals.toArray();
+        Arrays.sort(array, principalComparator);
         assertTrue("element is Principal ", array[0] instanceof Principal);
         assertTrue("first element not found ", ((Principal)array[0]).getName().equals("role1"));
         assertTrue("second element not found ", ((Principal)array[1]).getName().equals("role2"));
@@ -799,7 +810,8 @@
         principals = pms.getPrincipals(perm1);
         assertTrue("principal count should be 3 ", principals.size() == 3);
         array = (Object[])principals.toArray();
-        assertTrue("first element not found ", ((Principal)array[0]).getName().equals("role1"));
+        Arrays.sort(array, principalComparator);
+        assertTrue("first element should be [role1] but found ["+((Principal)array[0]).getName()+"]",
((Principal)array[0]).getName().equals("role1"));
         assertTrue("second element not found ", ((Principal)array[1]).getName().equals("role3"));
         assertTrue("third element not found ", ((Principal)array[2]).getName().equals("role4"));
         



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