harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r414066 - /incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SerializationTest.java
Date Wed, 14 Jun 2006 04:29:54 GMT
Author: smishura
Date: Tue Jun 13 21:29:53 2006
New Revision: 414066

URL: http://svn.apache.org/viewvc?rev=414066&view=rev
Log:
Adding comparator for PermissionCollection objects

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SerializationTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SerializationTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SerializationTest.java?rev=414066&r1=414065&r2=414066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SerializationTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/SerializationTest.java
Tue Jun 13 21:29:53 2006
@@ -33,6 +33,13 @@
 import java.io.OutputStream;
 import java.io.Serializable;
 import java.lang.reflect.Method;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
 
 import junit.framework.TestCase;
 
@@ -268,6 +275,29 @@
         }
     };
 
+    // for comparing java.security.PermissionCollection objects
+    private final static SerializableAssert PERMISSION_COLLECTION_COMPARATOR = new SerializableAssert()
{
+        public void assertDeserialized(Serializable reference, Serializable test) {
+
+            PermissionCollection refPC = (PermissionCollection) reference;
+            PermissionCollection tstPC = (PermissionCollection) test;
+
+            // verify class
+            TestCase.assertEquals(refPC.getClass(), tstPC.getClass());
+
+            // verify 'readOnly' field
+            TestCase.assertEquals(refPC.isReadOnly(), tstPC.isReadOnly());
+
+            // verify collection of permissions
+            Collection<Permission> refCollection = new HashSet<Permission>(
+                    Collections.list(refPC.elements()));
+            Collection<Permission> tstCollection = new HashSet<Permission>(
+                    Collections.list(tstPC.elements()));
+
+            TestCase.assertEquals(refCollection, tstCollection);
+        }
+    };
+
     private SerializableAssert defineComparator() throws Exception {
 
         if (this instanceof SerializableAssert) {
@@ -293,6 +323,8 @@
         // instead of 'instanceof' for the first element
         if(s[0] instanceof java.lang.Throwable){
             return THROWABLE_COMPARATOR;
+        } else if (s[0] instanceof java.security.PermissionCollection){
+            return PERMISSION_COLLECTION_COMPARATOR;
         }
 
         // TODO - throw new RuntimeException() if failed to detect comparator



Mime
View raw message