harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548555 - in /harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/javax/naming/ldap/Rdn.java test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/RdnTest.java
Date Tue, 19 Jun 2007 01:59:27 GMT
Author: tonywu
Date: Mon Jun 18 18:59:26 2007
New Revision: 548555

URL: http://svn.apache.org/viewvc?view=rev&rev=548555
Log:
Apply patch HARMONY-4211 ([classlib][jndi] Rdn.hashCode() returns different value for the
same rdn strings)

Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/Rdn.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/RdnTest.java

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/Rdn.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/Rdn.java?view=diff&rev=548555&r1=548554&r2=548555
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/Rdn.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/Rdn.java
Mon Jun 18 18:59:26 2007
@@ -68,7 +68,7 @@
         return LdapRdnParser.unescapeValue(val);
     }
 
-    private List<Attribute> list;
+    private transient List<Attribute> list;
 
     private transient LdapRdnParser parser;
 
@@ -280,6 +280,9 @@
 
             while (en.hasMoreElements()) {
                 Object obj = en.nextElement();
+                if (obj instanceof byte[]) {
+                    obj = new String((byte[])obj);
+                }
                 try {
                     String s = (String) obj;
                     sum += escapeValue(s.toLowerCase()).hashCode();

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/RdnTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/RdnTest.java?view=diff&rev=548555&r1=548554&r2=548555
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/RdnTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/RdnTest.java
Mon Jun 18 18:59:26 2007
@@ -23,10 +23,8 @@
  */
 package org.apache.harmony.jndi.tests.javax.naming.ldap;
 
-import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.NoSuchElementException;
-import java.util.concurrent.atomic.AtomicIntegerArray;
 
 import javax.naming.InvalidNameException;
 import javax.naming.NamingEnumeration;
@@ -735,6 +733,26 @@
         int y = new Rdn("T=TEST\\, THAT+S=THIS").hashCode();
         assertNotSame(0, x & y);
         assertEquals(x, y);
+    }
+
+    /**
+     * <p>
+     * Test method for 'javax.naming.ldap.Rdn.hashCode()'
+     * </p>
+     * <p>
+     * Here we are testing if this method returns the hash code of this RDN, in
+     * this case we are testing if the hashcode returned by this method is the
+     * correct one, the only hash that we know something is of the Rdn empty,
+     * this hash has to be zero.
+     * </p>
+     * <p>
+     * The expected result is the hashcode of the rdn.
+     * </p>
+     */
+    public void testHashCode002() throws Exception {
+        int x = new Rdn("t= #20").hashCode();
+        int y = new Rdn("t= #20").hashCode();
+        assertTrue(x == y);
     }
 
     /**



Mime
View raw message