harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548266 - in /harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/javax/naming/ldap/ test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/ test/resources/serialization/org/apache/harmony/jndi/tests/javax/naming/ldap/
Date Mon, 18 Jun 2007 09:03:29 GMT
Author: tonywu
Date: Mon Jun 18 02:03:27 2007
New Revision: 548266

URL: http://svn.apache.org/viewvc?view=rev&rev=548266
Log:
Apply patch HARMONY-4207 ([classlib][jndi] Class javax.naming.ldap.SortResponseControl is
not serialization compatible
)

Added:
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/serialization/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.golden.ser
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortResponseControl.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortResponseControl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortResponseControl.java?view=diff&rev=548266&r1=548265&r2=548266
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortResponseControl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortResponseControl.java
Mon Jun 18 02:03:27 2007
@@ -93,9 +93,11 @@
     
     private static final long serialVersionUID = 5142939176006310877L;
     
-    private SortResult sr;
+    private int resultCode;
     
-    private boolean sorted = false;
+    private String badAttrId;    
+    
+    private transient boolean sorted = false;
     
     /**
      * @ar.org.fitc.spec_ref
@@ -107,7 +109,10 @@
      */
     public SortResponseControl(String id, boolean criticality, byte[] value) throws IOException
{
         super(OID,criticality,value);
-        this.sr = (SortResult) ASN1_SORTRESPONSE.decode(value);
+        SortResult sr;
+        sr = (SortResult) ASN1_SORTRESPONSE.decode(value);
+        resultCode = sr.getSortresult();
+        badAttrId = sr.getAttributeType();
         if (getResultCode() == 0) {
             sorted = true;
         } else {
@@ -119,14 +124,14 @@
      * @ar.org.fitc.spec_ref
      */
     public String getAttributeID () {
-        return sr.getAttributeType();    
+        return badAttrId;
     }
     
     /**
      * @ar.org.fitc.spec_ref
      */
     public int getResultCode () {
-        return sr.getSortresult();
+        return resultCode;
     }
     
     /**

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java?view=diff&rev=548266&r1=548265&r2=548266
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java
Mon Jun 18 02:03:27 2007
@@ -23,6 +23,8 @@
 package org.apache.harmony.jndi.tests.javax.naming.ldap;
 
 import java.io.IOException;
+import java.io.Serializable;
+
 import javax.naming.AuthenticationNotSupportedException;
 import javax.naming.LimitExceededException;
 import javax.naming.NamingException;
@@ -33,8 +35,12 @@
 import javax.naming.directory.InvalidSearchFilterException;
 import javax.naming.directory.NoSuchAttributeException;
 import javax.naming.ldap.SortResponseControl;
+
 import junit.framework.TestCase;
 
+import org.apache.harmony.testframework.serialization.SerializationTest;
+import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
+
 /**        
  * <p>This Test class is testing the SortControl class.</p>
  * <p>In the next tables we are gonna see the methods that we test in this class:</p>
@@ -805,4 +811,32 @@
 		
 	}
 
+    public void testSerializationCompatibility() throws Exception{
+        String Id = "test";
+        boolean crit = true;
+        SortResponseControl object;
+        byte[] ber = { 48, 3, 10, 1, 0 };
+        object = new SortResponseControl(Id, crit, ber);
+        SerializationTest.verifyGolden(this, object, SORTRESPONSECONTROL_COMPARATOR);
+    }
+
+    // comparator for SortResponseControl
+    private static final SerializableAssert SORTRESPONSECONTROL_COMPARATOR = new SerializableAssert()
{
+        public void assertDeserialized(Serializable initial,
+                Serializable deserialized) {
+
+            SortResponseControl initThr = (SortResponseControl) initial;
+            SortResponseControl dserThr = (SortResponseControl) deserialized;
+
+            // verify ResultCode
+            int initResultCode = initThr.getResultCode();
+            int dserResultCode = dserThr.getResultCode();
+            assertTrue(initResultCode == dserResultCode);
+            
+            // verify BadAttrId
+            String initBadAttrId = initThr.getAttributeID();
+            String dserBadAttrId = dserThr.getAttributeID();
+            assertEquals(initBadAttrId, dserBadAttrId);
+        }
+    };
 }

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/serialization/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.golden.ser
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/serialization/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.golden.ser?view=auto&rev=548266
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/serialization/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.golden.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message