You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2008/06/10 23:09:33 UTC
svn commit: r666329 - 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
Author: seelmann
Date: Tue Jun 10 14:09:33 2008
New Revision: 666329
URL: http://svn.apache.org/viewvc?rev=666329&view=rev
Log:
Fix for DIRSHARED-9: use normalized attribute types to compare RDNs
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=666329&r1=666328&r2=666329&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 Tue Jun 10 14:09:33 2008
@@ -300,7 +300,7 @@
for ( AttributeTypeAndValue currentAtav:rdn.atavs )
{
atavs.add( (AttributeTypeAndValue)currentAtav.clone() );
- atavTypes.put( currentAtav.getUpType(), currentAtav );
+ atavTypes.put( currentAtav.getNormType(), currentAtav );
}
return;
@@ -693,7 +693,7 @@
for ( AttributeTypeAndValue currentAtav:this.atavs )
{
rdn.atavs.add( (AttributeTypeAndValue)currentAtav.clone() );
- rdn.atavTypes.put( currentAtav.getUpType(), currentAtav );
+ rdn.atavTypes.put( currentAtav.getNormType(), currentAtav );
}
break;
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=666329&r1=666328&r2=666329&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 Tue Jun 10 14:09:33 2008
@@ -20,6 +20,12 @@
package org.apache.directory.shared.ldap.name;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -33,13 +39,6 @@
import javax.naming.directory.Attributes;
import org.apache.directory.shared.ldap.util.StringTools;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import org.junit.Test;
@@ -420,7 +419,7 @@
Rdn rdn6 = new Rdn( " a = b + a = y " );
assertTrue( rdn5.compareTo( rdn6 ) != 0 );
}
-
+
/**
* Test for DIRSHARED-3.
@@ -447,7 +446,8 @@
assertEquals( 1, rdn2.compareTo( rdn1 ) );
}
-
+
+
/**
* Compares with a null RDN.
*
@@ -1257,6 +1257,7 @@
assertEquals( "a=", new Rdn( "a=" ).toString() );
}
+
/**
* test an RDN with escaped comma
*/
@@ -1275,4 +1276,43 @@
assertEquals( "a=\"b\\,c\"", new Rdn( "a=\"b\\,c\"" ).getUpName() );
assertEquals( "a=b\\,c", new Rdn( "a=\"b\\,c\"" ).toString() );
}
+
+
+ /**
+ * Tests the equals and compareTo results of cloned multi-valued RDNs.
+ * Test for DIRSHARED-9.
+ *
+ * @throws InvalidNameException
+ */
+ @Test
+ public void testComparingOfClonedMultiValuedRDNs() throws InvalidNameException
+ {
+ // Use upper case attribute types to test if normalized types are used
+ // for comparison
+ Rdn rdn = new Rdn( " A = b + C = d" );
+ Rdn clonedRdn = ( Rdn ) rdn.clone();
+
+ assertEquals( 0, rdn.compareTo( clonedRdn ) );
+ assertEquals( true, rdn.equals( clonedRdn ) );
+ }
+
+
+ /**
+ * Tests the equals and compareTo results of copy constructed multi-valued RDNs.
+ * Test for DIRSHARED-9.
+ *
+ * @throws InvalidNameException
+ */
+ @Test
+ public void testComparingOfCopyConstructedMultiValuedRDNs() throws InvalidNameException
+ {
+ // Use upper case attribute types to test if normalized types are used
+ // for comparison
+ Rdn rdn = new Rdn( " A = b + C = d" );
+ Rdn copiedRdn = new Rdn( rdn );
+
+ assertEquals( 0, rdn.compareTo( copiedRdn ) );
+ assertEquals( true, rdn.equals( copiedRdn ) );
+ }
+
}