You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2008/08/28 13:56:32 UTC
svn commit: r689792 -
/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
Author: tellison
Date: Thu Aug 28 04:56:31 2008
New Revision: 689792
URL: http://svn.apache.org/viewvc?rev=689792&view=rev
Log:
Apply patch for HARMONY-5962 ([classlib][support] Fail on UnresolvedPermissionTest and UnresolvedPermissionCollectionTest with Sun JDK)
Modified:
harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
Modified: harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java?rev=689792&r1=689791&r2=689792&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java (original)
+++ harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java Thu Aug 28 04:56:31 2008
@@ -35,9 +35,9 @@
import java.lang.reflect.Method;
import java.security.Permission;
import java.security.PermissionCollection;
-import java.util.Collection;
+import java.security.UnresolvedPermission;
+import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import junit.framework.Assert;
import junit.framework.TestCase;
@@ -292,13 +292,86 @@
Assert.assertEquals(initPC.isReadOnly(), dserPC.isReadOnly());
// verify collection of permissions
- Collection<Permission> refCollection = new HashSet<Permission>(
- Collections.list(initPC.elements()));
- Collection<Permission> tstCollection = new HashSet<Permission>(
- Collections.list(dserPC.elements()));
+ ArrayList<Permission> refList = Collections.list(initPC.elements());
+ ArrayList<Permission> tstList = Collections.list(dserPC.elements());
+ Assert.assertEquals(refList.size(), refList.size());
+
+ int size = refList.size();
+ if (size > 0) {
+ if (refList.get(0) instanceof UnresolvedPermission) {
+ boolean found;
+ UnresolvedPermission refPerm, tstPerm;
+ for (int i = 0; i < size; i++) {
+ found = false;
+ refPerm = (UnresolvedPermission)refList.get(i);
+ for(int j = 0; j < size; j++){
+ tstPerm = (UnresolvedPermission)tstList.get(i);
+ if(equalsUnresolvedPermission(refPerm, tstPerm)){
+ found = true;
+ break;
+ }
+ }
+
+ Assert.assertTrue(found);
+ }
+ } else {
+ Assert.assertEquals(refList, tstList);
+ }
+ }
+ }
+
+ /*
+ * check whether the given two UnresolvedPermission objects equal to each other
+ */
+ private boolean equalsUnresolvedPermission(UnresolvedPermission up1,
+ UnresolvedPermission up2) {
+
+ java.security.cert.Certificate[] certs = up1.getUnresolvedCerts();
+ if (certs != null && certs.length == 0) {
+ if(null == up2.getUnresolvedCerts()){
+ if (up1.getName().equals(up2.getName())){
+ String up1Name = up1.getUnresolvedName();
+ String up2Name = up2.getUnresolvedName();
+ if(up1Name == null ? up2Name == null : up1Name.equals(up2Name)){
+ String up1Actions = up1.getUnresolvedActions();
+ String up2Actions = up2.getUnresolvedActions();
+ return up1Actions == null ? up2Actions == null : up1Actions.equals(up2Actions);
+ }
+ }
+ }
+
+ return false;
+ }
+
+ return up1.equals(up2);
+
+ }
+ };
+
+ /**
+ * Comparator for java.security.UnresolvedPermission objects
+ */
+ public final static SerializableAssert UNRESOLVED_PERMISSION_COMPARATOR = new SerializableAssert() {
- Assert.assertEquals(refCollection, tstCollection);
+ public void assertDeserialized(Serializable initial,
+ Serializable deserialized) {
+ UnresolvedPermission initPerm = (UnresolvedPermission) initial;
+ UnresolvedPermission dserPerm = (UnresolvedPermission) deserialized;
+
+ java.security.cert.Certificate[] certs = initPerm.getUnresolvedCerts();
+ if (certs != null && certs.length == 0) {
+ Assert.assertEquals(initPerm.getUnresolvedType(), dserPerm
+ .getUnresolvedType());
+ Assert.assertEquals(initPerm.getUnresolvedName(), dserPerm
+ .getUnresolvedName());
+ Assert.assertEquals(initPerm.getUnresolvedActions(), dserPerm
+ .getUnresolvedActions());
+ Assert.assertNull(dserPerm.getUnresolvedCerts());
+ } else {
+ Assert.assertEquals(initPerm, dserPerm);
+ }
}
+
};
/**
@@ -334,6 +407,9 @@
if (m.getDeclaringClass() != Object.class) {
// one of classes overrides Object.equals(Object) method
// use default comparator
+ if (object instanceof UnresolvedPermission) {
+ return UNRESOLVED_PERMISSION_COMPARATOR;
+ }
return DEFAULT_COMPARATOR;
}
Re: svn commit: r689792 - /harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
Posted by Tim Ellison <t....@gmail.com>.
Fixed at r691250
Regards,
Tim
Kevin Zhou wrote:
> I'm sorry! I modified this source code to support UnresolvedPermissionTest.
> But I didn't run the above
> KrbServicePermissionCollectionTest/KrbDelegationPermissionCollectionTest
> tests.
>
> I have attached a new patch "HARMONY-5962v2.diff" to the issue [1] to solve
> this integrity failures.
> Would you please help me to review this patch and publish it?
>
> [1] https://issues.apache.org/jira/browse/HARMONY-5962
>
>
> On Mon, Sep 1, 2008 at 12:32 AM, chunrong lai <ch...@gmail.com> wrote:
>
>> I see the commit only modifies some tests. But it breaks the test cases
>>
>> org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.KrbServicePermissionCollectionTest
>> and
>>
>> org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.KrbDelegationPermissionCollectionTest
>> of classlib test suites, in our integrity testing platforms.
>>
>> Should we have a check?
>> Thanks.
>>
>>
>> http://people.apache.org/~chunrong/harmony-integrity/windows_x86/classlib-test/<http://people.apache.org/%7Echunrong/harmony-integrity/windows_x86/classlib-test/>
>> junit.framework.AssertionFailedError:
>> expected:<[(javax.security.auth.kerberos.DelegationPermission "AAA" "BBB"),
>> (javax.security.auth.kerberos.DelegationPermission "AAA" "CCC"),
>> (javax.security.auth.kerberos.DelegationPermission "BBB" "CCC")]> but
>> was:<[(javax.security.auth.kerberos.DelegationPermission "BBB" "CCC"),
>> (javax.security.auth.kerberos.DelegationPermission "AAA" "CCC"),
>> (javax.security.auth.kerberos.DelegationPermission "AAA" "BBB")]>
>>
>>
>> On 8/28/08, tellison@apache.org <te...@apache.org> wrote:
>>> Author: tellison
>>> Date: Thu Aug 28 04:56:31 2008
>>> New Revision: 689792
>>>
>>> URL: http://svn.apache.org/viewvc?rev=689792&view=rev
>>> Log:
>>> Apply patch for HARMONY-5962 ([classlib][support] Fail on
>>> UnresolvedPermissionTest and UnresolvedPermissionCollectionTest with Sun
>>> JDK)
>>>
>>> Modified:
>>>
>>>
>> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
>>> Modified:
>>>
>> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
>>> URL:
>>>
>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java?rev=689792&r1=689791&r2=689792&view=diff
>>>
>> ==============================================================================
>>> ---
>>>
>> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
>>> (original)
>>> +++
>>>
>> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
>>> Thu Aug 28 04:56:31 2008
>>> @@ -35,9 +35,9 @@
>>> import java.lang.reflect.Method;
>>> import java.security.Permission;
>>> import java.security.PermissionCollection;
>>> -import java.util.Collection;
>>> +import java.security.UnresolvedPermission;
>>> +import java.util.ArrayList;
>>> import java.util.Collections;
>>> -import java.util.HashSet;
>>>
>>> import junit.framework.Assert;
>>> import junit.framework.TestCase;
>>> @@ -292,13 +292,86 @@
>>> Assert.assertEquals(initPC.isReadOnly(),
>> dserPC.isReadOnly());
>>> // verify collection of permissions
>>> - Collection<Permission> refCollection = new
>>> HashSet<Permission>(
>>> - Collections.list(initPC.elements()));
>>> - Collection<Permission> tstCollection = new
>>> HashSet<Permission>(
>>> - Collections.list(dserPC.elements()));
>>> + ArrayList<Permission> refList =
>>> Collections.list(initPC.elements());
>>> + ArrayList<Permission> tstList =
>>> Collections.list(dserPC.elements());
>>> + Assert.assertEquals(refList.size(), refList.size());
>>> +
>>> + int size = refList.size();
>>> + if (size > 0) {
>>> + if (refList.get(0) instanceof UnresolvedPermission) {
>>> + boolean found;
>>> + UnresolvedPermission refPerm, tstPerm;
>>> + for (int i = 0; i < size; i++) {
>>> + found = false;
>>> + refPerm = (UnresolvedPermission)refList.get(i);
>>> + for(int j = 0; j < size; j++){
>>> + tstPerm =
>>> (UnresolvedPermission)tstList.get(i);
>>> + if(equalsUnresolvedPermission(refPerm,
>>> tstPerm)){
>>> + found = true;
>>> + break;
>>> + }
>>> + }
>>> +
>>> + Assert.assertTrue(found);
>>> + }
>>> + } else {
>>> + Assert.assertEquals(refList, tstList);
>>> + }
>>> + }
>>> + }
>>> +
>>> + /*
>>> + * check whether the given two UnresolvedPermission objects
>> equal
>>> to each other
>>> + */
>>> + private boolean equalsUnresolvedPermission(UnresolvedPermission
>>> up1,
>>> + UnresolvedPermission up2) {
>>> +
>>> + java.security.cert.Certificate[] certs =
>>> up1.getUnresolvedCerts();
>>> + if (certs != null && certs.length == 0) {
>>> + if(null == up2.getUnresolvedCerts()){
>>> + if (up1.getName().equals(up2.getName())){
>>> + String up1Name = up1.getUnresolvedName();
>>> + String up2Name = up2.getUnresolvedName();
>>> + if(up1Name == null ? up2Name == null :
>>> up1Name.equals(up2Name)){
>>> + String up1Actions =
>>> up1.getUnresolvedActions();
>>> + String up2Actions =
>>> up2.getUnresolvedActions();
>>> + return up1Actions == null ? up2Actions ==
>> null
>>> : up1Actions.equals(up2Actions);
>>> + }
>>> + }
>>> + }
>>> +
>>> + return false;
>>> + }
>>> +
>>> + return up1.equals(up2);
>>> +
>>> + }
>>> + };
>>> +
>>> + /**
>>> + * Comparator for java.security.UnresolvedPermission objects
>>> + */
>>> + public final static SerializableAssert
>>> UNRESOLVED_PERMISSION_COMPARATOR = new SerializableAssert() {
>>>
>>> - Assert.assertEquals(refCollection, tstCollection);
>>> + public void assertDeserialized(Serializable initial,
>>> + Serializable deserialized) {
>>> + UnresolvedPermission initPerm = (UnresolvedPermission)
>>> initial;
>>> + UnresolvedPermission dserPerm = (UnresolvedPermission)
>>> deserialized;
>>> +
>>> + java.security.cert.Certificate[] certs =
>>> initPerm.getUnresolvedCerts();
>>> + if (certs != null && certs.length == 0) {
>>> + Assert.assertEquals(initPerm.getUnresolvedType(),
>> dserPerm
>>> + .getUnresolvedType());
>>> + Assert.assertEquals(initPerm.getUnresolvedName(),
>> dserPerm
>>> + .getUnresolvedName());
>>> + Assert.assertEquals(initPerm.getUnresolvedActions(),
>>> dserPerm
>>> + .getUnresolvedActions());
>>> + Assert.assertNull(dserPerm.getUnresolvedCerts());
>>> + } else {
>>> + Assert.assertEquals(initPerm, dserPerm);
>>> + }
>>> }
>>> +
>>> };
>>>
>>> /**
>>> @@ -334,6 +407,9 @@
>>> if (m.getDeclaringClass() != Object.class) {
>>> // one of classes overrides Object.equals(Object) method
>>> // use default comparator
>>> + if (object instanceof UnresolvedPermission) {
>>> + return UNRESOLVED_PERMISSION_COMPARATOR;
>>> + }
>>> return DEFAULT_COMPARATOR;
>>> }
>>>
>>>
>>>
>>>
>
Re: svn commit: r689792 - /harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
Posted by Kevin Zhou <zh...@gmail.com>.
I'm sorry! I modified this source code to support UnresolvedPermissionTest.
But I didn't run the above
KrbServicePermissionCollectionTest/KrbDelegationPermissionCollectionTest
tests.
I have attached a new patch "HARMONY-5962v2.diff" to the issue [1] to solve
this integrity failures.
Would you please help me to review this patch and publish it?
[1] https://issues.apache.org/jira/browse/HARMONY-5962
On Mon, Sep 1, 2008 at 12:32 AM, chunrong lai <ch...@gmail.com> wrote:
> I see the commit only modifies some tests. But it breaks the test cases
>
> org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.KrbServicePermissionCollectionTest
> and
>
> org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.KrbDelegationPermissionCollectionTest
> of classlib test suites, in our integrity testing platforms.
>
> Should we have a check?
> Thanks.
>
>
> http://people.apache.org/~chunrong/harmony-integrity/windows_x86/classlib-test/<http://people.apache.org/%7Echunrong/harmony-integrity/windows_x86/classlib-test/>
> junit.framework.AssertionFailedError:
> expected:<[(javax.security.auth.kerberos.DelegationPermission "AAA" "BBB"),
> (javax.security.auth.kerberos.DelegationPermission "AAA" "CCC"),
> (javax.security.auth.kerberos.DelegationPermission "BBB" "CCC")]> but
> was:<[(javax.security.auth.kerberos.DelegationPermission "BBB" "CCC"),
> (javax.security.auth.kerberos.DelegationPermission "AAA" "CCC"),
> (javax.security.auth.kerberos.DelegationPermission "AAA" "BBB")]>
>
>
> On 8/28/08, tellison@apache.org <te...@apache.org> wrote:
> >
> > Author: tellison
> > Date: Thu Aug 28 04:56:31 2008
> > New Revision: 689792
> >
> > URL: http://svn.apache.org/viewvc?rev=689792&view=rev
> > Log:
> > Apply patch for HARMONY-5962 ([classlib][support] Fail on
> > UnresolvedPermissionTest and UnresolvedPermissionCollectionTest with Sun
> > JDK)
> >
> > Modified:
> >
> >
> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
> >
> > Modified:
> >
> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
> > URL:
> >
> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java?rev=689792&r1=689791&r2=689792&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
> > (original)
> > +++
> >
> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
> > Thu Aug 28 04:56:31 2008
> > @@ -35,9 +35,9 @@
> > import java.lang.reflect.Method;
> > import java.security.Permission;
> > import java.security.PermissionCollection;
> > -import java.util.Collection;
> > +import java.security.UnresolvedPermission;
> > +import java.util.ArrayList;
> > import java.util.Collections;
> > -import java.util.HashSet;
> >
> > import junit.framework.Assert;
> > import junit.framework.TestCase;
> > @@ -292,13 +292,86 @@
> > Assert.assertEquals(initPC.isReadOnly(),
> dserPC.isReadOnly());
> >
> > // verify collection of permissions
> > - Collection<Permission> refCollection = new
> > HashSet<Permission>(
> > - Collections.list(initPC.elements()));
> > - Collection<Permission> tstCollection = new
> > HashSet<Permission>(
> > - Collections.list(dserPC.elements()));
> > + ArrayList<Permission> refList =
> > Collections.list(initPC.elements());
> > + ArrayList<Permission> tstList =
> > Collections.list(dserPC.elements());
> > + Assert.assertEquals(refList.size(), refList.size());
> > +
> > + int size = refList.size();
> > + if (size > 0) {
> > + if (refList.get(0) instanceof UnresolvedPermission) {
> > + boolean found;
> > + UnresolvedPermission refPerm, tstPerm;
> > + for (int i = 0; i < size; i++) {
> > + found = false;
> > + refPerm = (UnresolvedPermission)refList.get(i);
> > + for(int j = 0; j < size; j++){
> > + tstPerm =
> > (UnresolvedPermission)tstList.get(i);
> > + if(equalsUnresolvedPermission(refPerm,
> > tstPerm)){
> > + found = true;
> > + break;
> > + }
> > + }
> > +
> > + Assert.assertTrue(found);
> > + }
> > + } else {
> > + Assert.assertEquals(refList, tstList);
> > + }
> > + }
> > + }
> > +
> > + /*
> > + * check whether the given two UnresolvedPermission objects
> equal
> > to each other
> > + */
> > + private boolean equalsUnresolvedPermission(UnresolvedPermission
> > up1,
> > + UnresolvedPermission up2) {
> > +
> > + java.security.cert.Certificate[] certs =
> > up1.getUnresolvedCerts();
> > + if (certs != null && certs.length == 0) {
> > + if(null == up2.getUnresolvedCerts()){
> > + if (up1.getName().equals(up2.getName())){
> > + String up1Name = up1.getUnresolvedName();
> > + String up2Name = up2.getUnresolvedName();
> > + if(up1Name == null ? up2Name == null :
> > up1Name.equals(up2Name)){
> > + String up1Actions =
> > up1.getUnresolvedActions();
> > + String up2Actions =
> > up2.getUnresolvedActions();
> > + return up1Actions == null ? up2Actions ==
> null
> > : up1Actions.equals(up2Actions);
> > + }
> > + }
> > + }
> > +
> > + return false;
> > + }
> > +
> > + return up1.equals(up2);
> > +
> > + }
> > + };
> > +
> > + /**
> > + * Comparator for java.security.UnresolvedPermission objects
> > + */
> > + public final static SerializableAssert
> > UNRESOLVED_PERMISSION_COMPARATOR = new SerializableAssert() {
> >
> > - Assert.assertEquals(refCollection, tstCollection);
> > + public void assertDeserialized(Serializable initial,
> > + Serializable deserialized) {
> > + UnresolvedPermission initPerm = (UnresolvedPermission)
> > initial;
> > + UnresolvedPermission dserPerm = (UnresolvedPermission)
> > deserialized;
> > +
> > + java.security.cert.Certificate[] certs =
> > initPerm.getUnresolvedCerts();
> > + if (certs != null && certs.length == 0) {
> > + Assert.assertEquals(initPerm.getUnresolvedType(),
> dserPerm
> > + .getUnresolvedType());
> > + Assert.assertEquals(initPerm.getUnresolvedName(),
> dserPerm
> > + .getUnresolvedName());
> > + Assert.assertEquals(initPerm.getUnresolvedActions(),
> > dserPerm
> > + .getUnresolvedActions());
> > + Assert.assertNull(dserPerm.getUnresolvedCerts());
> > + } else {
> > + Assert.assertEquals(initPerm, dserPerm);
> > + }
> > }
> > +
> > };
> >
> > /**
> > @@ -334,6 +407,9 @@
> > if (m.getDeclaringClass() != Object.class) {
> > // one of classes overrides Object.equals(Object) method
> > // use default comparator
> > + if (object instanceof UnresolvedPermission) {
> > + return UNRESOLVED_PERMISSION_COMPARATOR;
> > + }
> > return DEFAULT_COMPARATOR;
> > }
> >
> >
> >
> >
>
Re: svn commit: r689792 - /harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
Posted by chunrong lai <ch...@gmail.com>.
I see the commit only modifies some tests. But it breaks the test cases
org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.KrbServicePermissionCollectionTest
and
org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.KrbDelegationPermissionCollectionTest
of classlib test suites, in our integrity testing platforms.
Should we have a check?
Thanks.
http://people.apache.org/~chunrong/harmony-integrity/windows_x86/classlib-test/
junit.framework.AssertionFailedError:
expected:<[(javax.security.auth.kerberos.DelegationPermission "AAA" "BBB"),
(javax.security.auth.kerberos.DelegationPermission "AAA" "CCC"),
(javax.security.auth.kerberos.DelegationPermission "BBB" "CCC")]> but
was:<[(javax.security.auth.kerberos.DelegationPermission "BBB" "CCC"),
(javax.security.auth.kerberos.DelegationPermission "AAA" "CCC"),
(javax.security.auth.kerberos.DelegationPermission "AAA" "BBB")]>
On 8/28/08, tellison@apache.org <te...@apache.org> wrote:
>
> Author: tellison
> Date: Thu Aug 28 04:56:31 2008
> New Revision: 689792
>
> URL: http://svn.apache.org/viewvc?rev=689792&view=rev
> Log:
> Apply patch for HARMONY-5962 ([classlib][support] Fail on
> UnresolvedPermissionTest and UnresolvedPermissionCollectionTest with Sun
> JDK)
>
> Modified:
>
> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
>
> Modified:
> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
> URL:
> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java?rev=689792&r1=689791&r2=689792&view=diff
>
> ==============================================================================
> ---
> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
> (original)
> +++
> harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
> Thu Aug 28 04:56:31 2008
> @@ -35,9 +35,9 @@
> import java.lang.reflect.Method;
> import java.security.Permission;
> import java.security.PermissionCollection;
> -import java.util.Collection;
> +import java.security.UnresolvedPermission;
> +import java.util.ArrayList;
> import java.util.Collections;
> -import java.util.HashSet;
>
> import junit.framework.Assert;
> import junit.framework.TestCase;
> @@ -292,13 +292,86 @@
> Assert.assertEquals(initPC.isReadOnly(), dserPC.isReadOnly());
>
> // verify collection of permissions
> - Collection<Permission> refCollection = new
> HashSet<Permission>(
> - Collections.list(initPC.elements()));
> - Collection<Permission> tstCollection = new
> HashSet<Permission>(
> - Collections.list(dserPC.elements()));
> + ArrayList<Permission> refList =
> Collections.list(initPC.elements());
> + ArrayList<Permission> tstList =
> Collections.list(dserPC.elements());
> + Assert.assertEquals(refList.size(), refList.size());
> +
> + int size = refList.size();
> + if (size > 0) {
> + if (refList.get(0) instanceof UnresolvedPermission) {
> + boolean found;
> + UnresolvedPermission refPerm, tstPerm;
> + for (int i = 0; i < size; i++) {
> + found = false;
> + refPerm = (UnresolvedPermission)refList.get(i);
> + for(int j = 0; j < size; j++){
> + tstPerm =
> (UnresolvedPermission)tstList.get(i);
> + if(equalsUnresolvedPermission(refPerm,
> tstPerm)){
> + found = true;
> + break;
> + }
> + }
> +
> + Assert.assertTrue(found);
> + }
> + } else {
> + Assert.assertEquals(refList, tstList);
> + }
> + }
> + }
> +
> + /*
> + * check whether the given two UnresolvedPermission objects equal
> to each other
> + */
> + private boolean equalsUnresolvedPermission(UnresolvedPermission
> up1,
> + UnresolvedPermission up2) {
> +
> + java.security.cert.Certificate[] certs =
> up1.getUnresolvedCerts();
> + if (certs != null && certs.length == 0) {
> + if(null == up2.getUnresolvedCerts()){
> + if (up1.getName().equals(up2.getName())){
> + String up1Name = up1.getUnresolvedName();
> + String up2Name = up2.getUnresolvedName();
> + if(up1Name == null ? up2Name == null :
> up1Name.equals(up2Name)){
> + String up1Actions =
> up1.getUnresolvedActions();
> + String up2Actions =
> up2.getUnresolvedActions();
> + return up1Actions == null ? up2Actions == null
> : up1Actions.equals(up2Actions);
> + }
> + }
> + }
> +
> + return false;
> + }
> +
> + return up1.equals(up2);
> +
> + }
> + };
> +
> + /**
> + * Comparator for java.security.UnresolvedPermission objects
> + */
> + public final static SerializableAssert
> UNRESOLVED_PERMISSION_COMPARATOR = new SerializableAssert() {
>
> - Assert.assertEquals(refCollection, tstCollection);
> + public void assertDeserialized(Serializable initial,
> + Serializable deserialized) {
> + UnresolvedPermission initPerm = (UnresolvedPermission)
> initial;
> + UnresolvedPermission dserPerm = (UnresolvedPermission)
> deserialized;
> +
> + java.security.cert.Certificate[] certs =
> initPerm.getUnresolvedCerts();
> + if (certs != null && certs.length == 0) {
> + Assert.assertEquals(initPerm.getUnresolvedType(), dserPerm
> + .getUnresolvedType());
> + Assert.assertEquals(initPerm.getUnresolvedName(), dserPerm
> + .getUnresolvedName());
> + Assert.assertEquals(initPerm.getUnresolvedActions(),
> dserPerm
> + .getUnresolvedActions());
> + Assert.assertNull(dserPerm.getUnresolvedCerts());
> + } else {
> + Assert.assertEquals(initPerm, dserPerm);
> + }
> }
> +
> };
>
> /**
> @@ -334,6 +407,9 @@
> if (m.getDeclaringClass() != Object.class) {
> // one of classes overrides Object.equals(Object) method
> // use default comparator
> + if (object instanceof UnresolvedPermission) {
> + return UNRESOLVED_PERMISSION_COMPARATOR;
> + }
> return DEFAULT_COMPARATOR;
> }
>
>
>
>