directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r650268 - in /directory/shared/branches/bigbang/ldap/src: main/java/org/apache/directory/shared/ldap/name/Rdn.java test/java/org/apache/directory/shared/ldap/name/RdnTest.java
Date Mon, 21 Apr 2008 21:03:42 GMT
Author: seelmann
Date: Mon Apr 21 14:03:39 2008
New Revision: 650268

URL: http://svn.apache.org/viewvc?rev=650268&view=rev
Log:
Fix for DIRSHARED-2: compare all ATAVs of an multi-valued RDN before returning EQUALS.

Modified:
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
    directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java?rev=650268&r1=650267&r2=650268&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
Mon Apr 21 14:03:39 2008
@@ -784,7 +784,13 @@
                                AttributeTypeAndValue atavLocal = ( AttributeTypeAndValue
) atavLocalList.get( 0 );
                                AttributeTypeAndValue atavParam = ( AttributeTypeAndValue
) atavParamList.get( 0 );
 
-                               return atavLocal.compareTo( atavParam );
+                               // If the ATAVs are different we are finished.
+                               // It the ATAVs are equal we must compare the remaining ATAVs,
too. 
+                               int result = atavLocal.compareTo( atavParam );
+                               if ( result != 0 )
+                               {
+                            	   return result;
+                               }
                            }
                            else
                            {
@@ -813,14 +819,11 @@
 
                                    if ( !found )
                                    {
-                                       // The ATAV does not exist in the second
-                                       // RDN
+                                       // The ATAV does not exist in the second RDN
                                        return SUPERIOR;
                                    }
                                }
                            }
-
-                           return EQUALS;
                        }
                        else
                        {

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java?rev=650268&r1=650267&r2=650268&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
Mon Apr 21 14:03:39 2008
@@ -356,6 +356,29 @@
 
 
     /**
+     * Test for DIRSHARED-2.
+     * The first ATAV is equal, the second or following ATAV differs.
+     */
+    @Test
+    public void test_DIRSHARED_2() throws InvalidNameException
+    {
+        // the second ATAV differs
+        Rdn rdn1 = new Rdn( " a = b + c = d " );
+        Rdn rdn2 = new Rdn( " a = b + c = y " );
+        assertTrue( rdn1.compareTo( rdn2 ) != 0 );
+
+        // the third ATAV differs
+        Rdn rdn3 = new Rdn( " a = b + c = d + e = f " );
+        Rdn rdn4 = new Rdn( " a = b + c = d + e = y " );
+        assertTrue( rdn3.compareTo( rdn4 ) != 0 );
+
+        // the second ATAV differs in value only
+        Rdn rdn5 = new Rdn( " a = b + a = c " );
+        Rdn rdn6 = new Rdn( " a = b + a = y " );
+        assertTrue( rdn5.compareTo( rdn6 ) != 0 );
+    }
+    
+    /**
      * Compares with a null RDN.
      */
     @Test



Mime
View raw message