harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r540863 - 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 Wed, 23 May 2007 07:03:36 GMT
Author: pyang
Date: Wed May 23 00:03:36 2007
New Revision: 540863

URL: http://svn.apache.org/viewvc?view=rev&rev=540863
Log:
Apply patch for HARMONY-3884([classlib][jndi] Class PagedResultsResponseControl is not serialization
compatible)

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

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/PagedResultsResponseControl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/PagedResultsResponseControl.java?view=diff&rev=540863&r1=540862&r2=540863
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/PagedResultsResponseControl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/PagedResultsResponseControl.java
Wed May 23 00:03:36 2007
@@ -31,9 +31,10 @@
  */
 public final class PagedResultsResponseControl extends BasicControl {
 
-    private PagedResultSearchControlValue pgscv;
-
     private static final long serialVersionUID = -8819778744844514666L;
+    
+    private int resultSize;
+    private byte[] cookie;
 
     /**
      * @ar.org.fitc.spec_ref
@@ -46,18 +47,20 @@
     public PagedResultsResponseControl(String id, boolean criticality,
             byte[] value) throws IOException {
         super(id, criticality, value);
-        this.pgscv = (PagedResultSearchControlValue) PagedResultsControl.ASN1_ENCODER
+        PagedResultSearchControlValue pgscv = (PagedResultSearchControlValue) PagedResultsControl.ASN1_ENCODER
                 .decode(value);
+        resultSize = pgscv.getSize();
+        cookie = pgscv.getCookie();
     }
 
     /**
      * @ar.org.fitc.spec_ref
      */
     public byte[] getCookie() {
-        if (pgscv.getCookie().length == 0) {
+        if (cookie.length == 0) {
             return null;
         } else {
-            return pgscv.getCookie();
+            return cookie;
         }
     }
 
@@ -65,7 +68,7 @@
      * @ar.org.fitc.spec_ref
      */
     public int getResultSize() {
-        return pgscv.getSize();
+        return resultSize;
     }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestPagedResultsResponseControl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestPagedResultsResponseControl.java?view=diff&rev=540863&r1=540862&r2=540863
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestPagedResultsResponseControl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestPagedResultsResponseControl.java
Wed May 23 00:03:36 2007
@@ -23,8 +23,12 @@
 package org.apache.harmony.jndi.tests.javax.naming.ldap;
 
 import java.io.IOException;
+import java.io.Serializable;
+import java.util.Arrays;
 import javax.naming.ldap.PagedResultsResponseControl;
 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 PagedResultsControls class.</p>
@@ -328,4 +332,30 @@
 			fail("Failed with:"+e);
 		}
 	}
+
+    public void testSerializationCompatibility() throws Exception{
+        byte[] b={48,5,2,1,0,4,0};
+        PagedResultsResponseControl object=new PagedResultsResponseControl("test", true,
b);
+        SerializationTest.verifyGolden(this, object, PAGEDRESULTSRESPONSECONTROL_COMPARATOR);
+    }
+    
+    // comparator for PagedResultsResponseControl
+    private static final SerializableAssert PAGEDRESULTSRESPONSECONTROL_COMPARATOR = new
SerializableAssert() {
+        public void assertDeserialized(Serializable initial,
+                Serializable deserialized) {
+
+            PagedResultsResponseControl initThr = (PagedResultsResponseControl) initial;
+            PagedResultsResponseControl dserThr = (PagedResultsResponseControl) deserialized;
+
+            // verify ResultSize
+            int initResultSize = initThr.getResultSize();
+            int dserResultSize = dserThr.getResultSize();
+            assertTrue(initResultSize == dserResultSize);
+            
+            // verify Cookie
+            byte[] initCookie = initThr.getCookie();
+            byte[] dserCookie = dserThr.getCookie();
+            assertTrue(Arrays.equals(initCookie, dserCookie));
+        }
+    };
 }

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/serialization/org/apache/harmony/jndi/tests/javax/naming/ldap/TestPagedResultsResponseControl.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/TestPagedResultsResponseControl.golden.ser?view=auto&rev=540863
==============================================================================
Binary file - no diff available.

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



Mime
View raw message