harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548593 - 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 05:20:07 GMT
Author: tonywu
Date: Mon Jun 18 22:20:06 2007
New Revision: 548593

URL: http://svn.apache.org/viewvc?view=rev&rev=548593
Log:
Apply patch HARMONY-4228 [[classlib][jndi] Rdn.toAttributes() returns different result from
RI)

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=548593&r1=548592&r2=548593
==============================================================================
--- 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 22:20:06 2007
@@ -31,10 +31,12 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
 
 import org.apache.harmony.jndi.internal.nls.Messages;
 import org.apache.harmony.jndi.internal.parser.LdapRdnParser;
+import org.apache.harmony.jndi.internal.parser.LdapTypeAndValueList;
 
 /**
  * 
@@ -182,13 +184,18 @@
     }
 
     private List<Attribute> convertToAttributeArrayList(Attributes attrList) {
-        List<Attribute> myList = new ArrayList<Attribute>();
+        LdapTypeAndValueList myList = new LdapTypeAndValueList();
 
         NamingEnumeration<? extends Attribute> ne = attrList.getAll();
-        while (ne.hasMoreElements()) {
-            myList.add((Attribute)ne.nextElement().clone());
+        try {
+            while (ne.hasMoreElements()) {
+                Attribute attr = ne.nextElement();
+                myList.put(attr.getID(), attr.get());
+            }
+        } catch (NamingException e){
+            
         }
-        return myList;
+        return myList.toAttributeList();
     }
 
     /**
@@ -309,11 +316,21 @@
      * @ar.org.fitc.spec_ref
      */
     public Attributes toAttributes() {
-        BasicAttributes ba = new BasicAttributes(true);
+        BasicAttributes bas = new BasicAttributes(true);
         for (Iterator<Attribute> iter = list.iterator(); iter.hasNext();) {
-            ba.put((Attribute) iter.next().clone());
+            Attribute attr = iter.next();
+            BasicAttribute ba = new BasicAttribute(attr.getID(), false);
+            try {
+                NamingEnumeration nameEnum = attr.getAll();
+                while (nameEnum.hasMore()) {
+                    ba.add(nameEnum.next());
+                }
+            } catch (NamingException ne) {
+
+            }
+            bas.put(ba);
         }
-        return ba;
+        return bas;
     }
 
     /**

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=548593&r1=548592&r2=548593
==============================================================================
--- 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 22:20:06 2007
@@ -544,6 +544,15 @@
         } catch (InvalidNameException e) {}
     }
 
+    public void testRdnString027() {
+        try {
+            Rdn rdn1 = new Rdn("t", "test");
+            Rdn rdn2 = new Rdn("t = test + t = test");
+            assertFalse(rdn1.equals(rdn2));
+            assertEquals(rdn1.toAttributes(), rdn2.toAttributes());            
+        } catch (InvalidNameException e) {}
+    }
+
     /**
      * <p>
      * Test method for 'javax.naming.ldap.Rdn.Rdn(Rdn)'



Mime
View raw message