directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1073442 - in /directory/shared/trunk: integ/src/test/java/org/apache/directory/shared/ldap/name/ ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/ ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/
Date Tue, 22 Feb 2011 18:13:42 GMT
Author: elecharny
Date: Tue Feb 22 18:13:41 2011
New Revision: 1073442

URL: http://svn.apache.org/viewvc?rev=1073442&view=rev
Log:
o The Ava class does not implement the Comparable interface anymore
o Made the constructor that takes up and norm types/values private
o Removed the Ava.compareTo(), Ava.compareToIgnoreCase, Ava.compareType and Ava.compareValue
methods
o Used an ArrayList instead of a TreeSet to store the Avas in a Rdn
o The Rdn class does not implement the Comparable interface anymore
o Removed the Rdn.compareTo() method
o Modified the Rdn.equals() method to work without the compareTo() method
o Fixed the tests accordingly

Modified:
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java
    directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java
    directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
    directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
    directory/shared/trunk/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
    directory/shared/trunk/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java?rev=1073442&r1=1073441&r2=1073442&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java
(original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java
Tue Feb 22 18:13:41 2011
@@ -177,7 +177,7 @@ public class AvaTest
         Ava atav1 = new Ava( schemaManager, "cn", "b" );
         Ava atav2 = new Ava( schemaManager, "cn", "b" );
 
-        assertEquals( 0, atav1.compareTo( atav2 ) );
+        assertTrue( atav1.equals( atav2 ) );
     }
 
 
@@ -190,7 +190,7 @@ public class AvaTest
         Ava atav1 = new Ava( schemaManager, "cn", "b" );
         Ava atav2 = new Ava( schemaManager, "CN", "b" );
 
-        assertEquals( 0, atav1.compareTo( atav2 ) );
+        assertTrue( atav1.equals( atav2 ) );
     }
 
 

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java?rev=1073442&r1=1073441&r2=1073442&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
(original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
Tue Feb 22 18:13:41 2011
@@ -2051,7 +2051,7 @@ public class DnTest
 
         assertEquals(
             ( result ).getNormName(),
-            "0.9.2342.19200300.100.1.25=and some animals+2.5.4.11=some people,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com"
);
+            "2.5.4.11=some people+0.9.2342.19200300.100.1.25=and some animals,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com"
);
         assertTrue( ( result )
             .getName()
             .equals(
@@ -2073,7 +2073,7 @@ public class DnTest
         assertTrue( result
             .getNormName()
             .equals(
-                "0.9.2342.19200300.100.1.25=and some animals+2.5.4.11=some people,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com"
) );
+                "2.5.4.11=some people+0.9.2342.19200300.100.1.25=and some animals,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com"
) );
         assertTrue( result
             .getName()
             .equals(

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java?rev=1073442&r1=1073441&r2=1073442&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java
(original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java
Tue Feb 22 18:13:41 2011
@@ -130,15 +130,12 @@ public class MultiThreadedTest
     @Test
     public void testNormalizeCompare() throws Exception
     {
-        sharedAva.normalize();
-        assertEquals( 0, sharedAva.compareTo( referenceAva ) );
-        assertEquals( 0, referenceAva.compareTo( sharedAva ) );
+        assertTrue( sharedAva.equals( referenceAva ) );
+        assertTrue( referenceAva.equals( sharedAva ) );
 
-        sharedRdn.normalize( schemaManager );
-        assertEquals( 0, referenceRdn.compareTo( sharedRdn ) );
-        assertEquals( 0, sharedRdn.compareTo( referenceRdn ) );
+        assertTrue( referenceRdn.equals( sharedRdn ) );
+        assertTrue( sharedRdn.equals( referenceRdn ) );
 
-        sharedDn.normalize( schemaManager );
         assertEquals( referenceDn, sharedDn );
         assertEquals( sharedDn, referenceDn );
     }

Modified: directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java?rev=1073442&r1=1073441&r2=1073442&view=diff
==============================================================================
--- directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java
(original)
+++ directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java
Tue Feb 22 18:13:41 2011
@@ -24,7 +24,6 @@ import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-import java.util.Arrays;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.model.entry.BinaryValue;
@@ -57,7 +56,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class Ava implements Cloneable, Comparable<Object>, Externalizable
+public final class Ava implements Externalizable, Cloneable
 {
     /**
      * Declares the Serial Version Uid.
@@ -173,7 +172,7 @@ public final class Ava implements Clonea
      * @param upValue The User Provided value
      * @param normValue The normalized value
      */
-    public Ava( SchemaManager schemaManager, String upType, Value<?> upValue ) throws
LdapInvalidDnException
+    private Ava( SchemaManager schemaManager, String upType, Value<?> upValue ) throws
LdapInvalidDnException
     {
         AttributeType attributeType = null;
         
@@ -448,144 +447,6 @@ public final class Ava implements Clonea
     }
 
 
-    /**
-     * Compares two NameComponents. They are equals if : 
-     * - types are equals, case insensitive, 
-     * - values are equals, case sensitive
-     *
-     * @param object
-     * @return 0 if both NC are equals, otherwise a positive value if the
-     *         original NC is superior to the second one, a negative value if
-     *         the second NC is superior.
-     */
-    public int compareTo( Object object )
-    {
-        if ( object instanceof Ava)
-        {
-            Ava nc = (Ava) object;
-
-            int res = compareType( normType, nc.normType );
-
-            if ( res != 0 )
-            {
-                return res;
-            }
-            else
-            {
-                return compareValue( normValue, nc.normValue, CASE_SENSITIVE );
-            }
-        }
-        else
-        {
-            return 1;
-        }
-    }
-
-
-    /**
-     * Compares two NameComponents. They are equals if : 
-     * - types are equals, case insensitive, 
-     * - values are equals, case insensitive
-     *
-     * @param object
-     * @return 0 if both NC are equals, otherwise a positive value if the
-     *         original NC is superior to the second one, a negative value if
-     *         the second NC is superior.
-     */
-    public int compareToIgnoreCase( Object object )
-    {
-        if ( object instanceof Ava)
-        {
-            Ava nc = (Ava) object;
-
-            int res = compareType( normType, nc.normType );
-
-            if ( res != 0 )
-            {
-                return res;
-            }
-            else
-            {
-                return compareValue( normValue, nc.normValue, CASE_INSENSITIVE );
-            }
-        }
-        else
-        {
-            return 1;
-        }
-    }
-
-
-    /**
-     * Compare two types, trimed and case insensitive
-     *
-     * @param val1 First String
-     * @param val2 Second String
-     * @return true if both strings are equals or null.
-     */
-    private int compareType( String val1, String val2 )
-    {
-        if ( Strings.isEmpty(val1) )
-        {
-            return Strings.isEmpty(val2) ? 0 : -1;
-        }
-        else if ( Strings.isEmpty(val2) )
-        {
-            return 1;
-        }
-        else
-        {
-            return ( Strings.trim(val1) ).compareToIgnoreCase( Strings.trim(val2) );
-        }
-    }
-
-
-    /**
-     * Compare two values
-     *
-     * @param val1 First value
-     * @param val2 Second value
-     * @param sensitivity A flag to define the case sensitivity
-     * @return -1 if the first value is inferior to the second one, +1 if
-     * its superior, 0 if both values are equal
-     */
-    private int compareValue( Value<?> val1, Value<?> val2, boolean sensitivity
)
-    {
-        if ( !val1.isBinary() )
-        {
-            if ( !val2.isBinary() )
-            {
-                int val = ( sensitivity == CASE_SENSITIVE )
-                    ? ( val1.getString() ).compareTo( val2.getString() )
-                        : ( val1.getString() ).compareToIgnoreCase( val2.getString() );
-
-                return ( val < 0 ? -1 : ( val > 0 ? 1 : val ) );
-            }
-            else
-            {
-                return 1;
-            }
-        }
-        else
-        {
-            if ( val2.isBinary() )
-            {
-                if ( Arrays.equals( val1.getBytes(), val2.getBytes() ) )
-                {
-                    return 0;
-                }
-                else
-                {
-                    return 1;
-                }
-            }
-            else
-            {
-                return 1;
-            }
-        }
-    }
-
     private static final boolean[] DN_ESCAPED_CHARS = new boolean[]
         {
         true,  true,  true,  true,  true,  true,  true,  true,  // 0x00 -> 0x07

Modified: directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java?rev=1073442&r1=1073441&r2=1073442&view=diff
==============================================================================
--- directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
(original)
+++ directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
Tue Feb 22 18:13:41 2011
@@ -931,7 +931,7 @@ public final class Dn implements Iterabl
             Rdn nameRdn = dn.rdns.get( dn.rdns.size() - i - 1 );
             Rdn ldapRdn = rdns.get( rdns.size() - i - 1 );
 
-            if ( nameRdn.compareTo( ldapRdn ) != 0 )
+            if ( !nameRdn.equals( ldapRdn ) )
             {
                 return false;
             }
@@ -1508,7 +1508,7 @@ public final class Dn implements Iterabl
 
             for ( int i = 0; i < this.size(); i++ )
             {
-                if ( name.rdns.get( i ).compareTo( rdns.get( i ) ) != 0 )
+                if ( !name.rdns.get( i ).equals( rdns.get( i ) ) )
                 {
                     return false;
                 }

Modified: directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java?rev=1073442&r1=1073441&r2=1073442&view=diff
==============================================================================
--- directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
(original)
+++ directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
Tue Feb 22 18:13:41 2011
@@ -24,11 +24,11 @@ import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.commons.collections.MultiMap;
@@ -115,7 +115,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class Rdn implements Cloneable, Comparable<Rdn>, Externalizable, Iterable<Ava>
+public class Rdn implements Cloneable, Externalizable, Iterable<Ava>
 {
     /** The LoggerFactory used by this class */
     protected static final Logger LOG = LoggerFactory.getLogger( Rdn.class );
@@ -144,7 +144,7 @@ public class Rdn implements Cloneable, C
      * because we want the ATAVs to be sorted. An atav may contain more than one
      * value. In this case, the values are String stored in a List.
      */
-    private Set<Ava> atavs = null;
+    private List<Ava> atavs = null;
 
     /**
      * We also keep a set of types, in order to use manipulations. A type is
@@ -409,7 +409,7 @@ public class Rdn implements Cloneable, C
 
             default:
                 // We must duplicate the treeSet and the hashMap
-                atavs = new TreeSet<Ava>();
+                atavs = new ArrayList<Ava>();
                 atavTypes = new MultiValueMap();
 
                 for ( Ava currentAtav : rdn.atavs )
@@ -575,7 +575,7 @@ public class Rdn implements Cloneable, C
                 // We already have an atav. We have to put it in the HashMap
                 // before adding a new one.
                 // First, create the HashMap,
-                atavs = new TreeSet<Ava>();
+                atavs = new ArrayList<Ava>();
 
                 // and store the existing AttributeTypeAndValue into it.
                 atavs.add( atav );
@@ -625,7 +625,7 @@ public class Rdn implements Cloneable, C
                 // We already have an atav. We have to put it in the HashMap
                 // before adding a new one.
                 // First, create the HashMap,
-                atavs = new TreeSet<Ava>();
+                atavs = new ArrayList<Ava>();
 
                 // and store the existing AttributeTypeAndValue into it.
                 atavs.add( atav );
@@ -834,7 +834,7 @@ public class Rdn implements Cloneable, C
                 default:
                     // We must duplicate the treeSet and the hashMap
                     rdn.atavTypes = new MultiValueMap();
-                    rdn.atavs = new TreeSet<Ava>();
+                    rdn.atavs = new ArrayList<Ava>();
 
                     for ( Ava currentAtav : this.atavs )
                     {
@@ -866,7 +866,7 @@ public class Rdn implements Cloneable, C
      * @param rdn the Rdn to be compared
      * @return 0 if both RDNs are equals. -1 if the current Rdn is inferior, 1 if
      *         the current Rdn is superior, UNDEFINED otherwise.
-     */
+     *
     public int compareTo( Rdn rdn )
     {
         if ( rdn == null )
@@ -981,7 +981,7 @@ public class Rdn implements Cloneable, C
                 return atav;
 
             default:
-                return ( ( TreeSet<Ava> ) atavs ).first().clone();
+                return atavs.get( 0 ).clone();
         }
     }
 
@@ -1002,7 +1002,7 @@ public class Rdn implements Cloneable, C
                 return atav.getUpType();
 
             default:
-                return ( ( TreeSet<Ava> ) atavs ).first().getUpType();
+                return atavs.get( 0 ).getUpType();
         }
     }
 
@@ -1023,7 +1023,7 @@ public class Rdn implements Cloneable, C
                 return atav.getNormType();
 
             default:
-                return ( ( TreeSet<Ava> ) atavs ).first().getNormType();
+                return atavs.get( 0 ).getNormType();
         }
     }
 
@@ -1044,7 +1044,7 @@ public class Rdn implements Cloneable, C
                 return atav.getUpValue();
 
             default:
-                return ( ( TreeSet<Ava> ) atavs ).first().getUpValue();
+                return atavs.get( 0 ).getUpValue();
         }
     }
 
@@ -1065,7 +1065,7 @@ public class Rdn implements Cloneable, C
                 return atav.getNormValue();
 
             default:
-                return ( ( TreeSet<Ava> ) atavs ).first().getNormValue();
+                return atavs.get( 0 ).getNormValue();
         }
     }
 
@@ -1080,19 +1080,71 @@ public class Rdn implements Cloneable, C
      *            Rdn to be compared for equality with this Rdn
      * @return true if the specified object is equal to this Rdn
      */
-    public boolean equals( Object rdn )
+    public boolean equals( Object that )
     {
-        if ( this == rdn )
+        if ( this == that )
         {
             return true;
         }
 
-        if ( !( rdn instanceof Rdn) )
+        if ( !( that instanceof Rdn) )
+        {
+            return false;
+        }
+        
+        Rdn rdn = (Rdn)that;
+
+        if ( rdn.nbAtavs != nbAtavs )
         {
+            // We don't have the same number of ATAVs. The Rdn which
+            // has the higher number of Atav is the one which is
+            // superior
             return false;
         }
 
-        return compareTo( (Rdn) rdn ) == EQUAL;
+        switch ( nbAtavs )
+        {
+            case 0:
+                return true;
+
+            case 1:
+                return atav.equals( rdn.atav );
+
+            default:
+                // We have more than one value. We will
+                // go through all of them.
+
+                // the types are already normalized and sorted in the atavs Map
+                // so we could compare the first element with all of the second
+                // Ava elemnts, etc.
+                Iterator<Ava> localIterator = atavs.iterator();
+
+                while ( localIterator.hasNext() )
+                {
+                    Iterator<Ava> paramIterator = rdn.atavs.iterator();
+
+                    Ava localAtav = localIterator.next();
+                    boolean equals = false;
+
+                    while ( paramIterator.hasNext() )
+                    {
+                        Ava paramAtav = paramIterator.next();
+                        
+                        if ( localAtav.equals( paramAtav ) )
+                        {
+                            equals = true;
+                            break;
+                        }
+                    }
+
+                    if ( equals == false )
+                    {
+                        return false;
+                    }
+                }
+
+                return true;
+        }
     }
 
 
@@ -1573,7 +1625,7 @@ public class Rdn implements Cloneable, C
                 break;
 
             default:
-                atavs = new TreeSet<Ava>();
+                atavs = new ArrayList<Ava>();
 
                 atavTypes = new MultiValueMap();
 

Modified: directory/shared/trunk/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java?rev=1073442&r1=1073441&r2=1073442&view=diff
==============================================================================
--- directory/shared/trunk/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
(original)
+++ directory/shared/trunk/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
Tue Feb 22 18:13:41 2011
@@ -21,6 +21,7 @@ package org.apache.directory.shared.ldap
 
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -165,7 +166,7 @@ public class AvaTest
         Ava atav1 = new Ava( "a", "a","b", "b" );
         Ava atav2 = new Ava( "a", "a","b", "b" );
 
-        assertEquals( 0, atav1.compareTo( atav2 ) );
+        assertTrue( atav1.equals( atav2 ) );
     }
 
 
@@ -178,7 +179,7 @@ public class AvaTest
         Ava atav1 = new Ava( "a", "a", "b", "b" );
         Ava atav2 = new Ava( "A", "A", "b", "b" );
 
-        assertEquals( 0, atav1.compareTo( atav2 ) );
+        assertTrue( atav1.equals( atav2 ) );
     }
 
 
@@ -193,7 +194,7 @@ public class AvaTest
             
         Ava atav2 = new Ava( "a", "a", "b", "b" );
 
-        assertEquals( 1, atav1.compareTo( atav2 ) );
+        assertFalse( atav1.equals( atav2 ) );
     }
 
 
@@ -207,7 +208,7 @@ public class AvaTest
         Ava atav1 = new Ava( "a", "a", "b", "b" );
         Ava atav2 = new Ava( "b", "b", "b", "b" );
 
-        assertEquals( -1, atav1.compareTo( atav2 ) );
+        assertFalse( atav1.equals( atav2 ) );
     }
 
 
@@ -221,7 +222,7 @@ public class AvaTest
         Ava atav1 = new Ava( "a", "a", "b", "b" );
         Ava atav2 = new Ava( "a", "a", "a", "a" );
 
-        assertEquals( 1, atav1.compareTo( atav2 ) );
+        assertFalse( atav1.equals( atav2 ) );
     }
 
 
@@ -235,7 +236,7 @@ public class AvaTest
         Ava atav1 = new Ava( "a", "a", "a", "a" );
         Ava atav2 = new Ava( "a", "a", "b", "b" );
 
-        assertEquals( -1, atav1.compareTo( atav2 ) );
+        assertFalse( atav1.equals( atav2 ) );
     }
 
 

Modified: directory/shared/trunk/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java?rev=1073442&r1=1073441&r2=1073442&view=diff
==============================================================================
--- directory/shared/trunk/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
(original)
+++ directory/shared/trunk/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
Tue Feb 22 18:13:41 2011
@@ -33,17 +33,14 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.Iterator;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.name.Ava;
-import org.apache.directory.shared.ldap.model.name.Rdn;
-import org.apache.directory.shared.ldap.model.name.RdnParser;
-import org.apache.directory.shared.ldap.model.name.RdnSerializer;
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Test the class Rdn
@@ -341,7 +338,7 @@ public class RdnTest
 
 
     /**
-     * Test the compareTo method for a Rdn.
+     * Test the equals method for a Rdn.
      * 
      * @throws LdapException
      */
@@ -350,7 +347,7 @@ public class RdnTest
     {
         Rdn rdn1 = new Rdn( " a = b + c = d + a = f + g = h " );
         Rdn rdn2 = null;
-        assertTrue( rdn1.compareTo( rdn2 ) > 0 );
+        assertFalse( rdn1.equals( rdn2 ) );
     }
 
 
@@ -364,7 +361,7 @@ public class RdnTest
     {
         Rdn rdn1 = new Rdn( " a = b + c = d + a = f + g = h " );
         Rdn rdn2 = new Rdn( " a = b " );
-        assertTrue( rdn1.compareTo( rdn2 ) > 0 );
+        assertFalse( rdn1.equals( rdn2 ) );
     }
 
 
@@ -379,7 +376,7 @@ public class RdnTest
         Rdn rdn1 = new Rdn( " a = b " );
         Rdn rdn2 = new Rdn( " a = b + c = d + a = f + g = h " );
 
-        assertTrue( rdn1.compareTo( rdn2 ) < 0 );
+        assertFalse( rdn1.equals( rdn2 ) );
     }
 
 
@@ -394,7 +391,7 @@ public class RdnTest
         Rdn rdn1 = new Rdn( " a = b + c = d + a = f + g = h " );
         Rdn rdn2 = new Rdn( " a = b + c = d + a = f + g = h " );
 
-        assertEquals( 0, rdn1.compareTo( rdn2 ) );
+        assertTrue( rdn1.equals( rdn2 ) );
     }
 
 
@@ -409,7 +406,7 @@ public class RdnTest
         Rdn rdn1 = new Rdn( " a = b + a = f + g = h + c = d " );
         Rdn rdn2 = new Rdn( " a = b + c = d + a = f + g = h " );
 
-        assertEquals( 0, rdn1.compareTo( rdn2 ) );
+        assertTrue( rdn1.equals( rdn2 ) );
     }
 
 
@@ -424,9 +421,8 @@ public class RdnTest
         Rdn rdn1 = new Rdn( " a = f + g = h + c = d " );
         Rdn rdn2 = new Rdn( " c = d + a = h + g = h " );
 
-        assertTrue( rdn1.compareTo( rdn2 ) < 0 );
-        assertTrue( rdn2.compareTo( rdn1 ) > 0 );
-        assertEquals( 0, rdn1.compareTo( rdn2 ) + rdn2.compareTo( rdn1 ) );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
     }
 
 
@@ -442,23 +438,20 @@ public class RdnTest
         // 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 );
-        assertTrue( rdn2.compareTo( rdn1 ) > 0 );
-        assertEquals( 0, rdn1.compareTo( rdn2 ) + rdn2.compareTo( rdn1 ) );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
 
         // 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 );
-        assertTrue( rdn4.compareTo( rdn3 ) > 0 );
-        assertEquals( 0, rdn3.compareTo( rdn4 ) + rdn4.compareTo( rdn3 ) );
+        assertFalse( rdn3.equals( rdn4 ) );
+        assertFalse( rdn4.equals( rdn3 ) );
 
         // 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 );
-        assertTrue( rdn6.compareTo( rdn5 ) > 0 );
-        assertEquals( 0, rdn5.compareTo( rdn6 ) + rdn6.compareTo( rdn5 ) );
+        assertFalse( rdn5.equals( rdn6 ) );
+        assertFalse( rdn6.equals( rdn5 ) );
     }
 
 
@@ -474,25 +467,23 @@ public class RdnTest
     {
         Rdn rdn1 = new Rdn( " a = b + c = d " );
         Rdn rdn2 = new Rdn( " c = d + a = b " );
-        assertEquals( 0, rdn1.compareTo( rdn2 ) );
+        assertTrue( rdn1.equals( rdn2 ) );
 
         rdn1 = new Rdn( " a = b + c = e " );
         rdn2 = new Rdn( " c = d + a = b " );
-        assertTrue( rdn1.compareTo( rdn2 ) > 0 );
-        assertTrue( rdn2.compareTo( rdn1 ) < 0 );
-        assertEquals( 0, rdn1.compareTo( rdn2 ) + rdn2.compareTo( rdn1 ) );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
 
         rdn1 = new Rdn( " a = b + c = d " );
         rdn2 = new Rdn( " e = f + g = h " );
-        assertTrue( rdn1.compareTo( rdn2 ) < 0 );
-        assertTrue( rdn2.compareTo( rdn1 ) > 0 );
-        assertEquals( 0, rdn1.compareTo( rdn2 ) + rdn2.compareTo( rdn1 ) );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
     }
 
 
     /**
      * Test for DIRSHARED-3.
-     * Tests that compareTo() is invertable for single-valued RDNs.
+     * Tests that equals() is invertable for single-valued RDNs.
      * 
      * @throws LdapException
      */
@@ -501,16 +492,15 @@ public class RdnTest
     {
         Rdn rdn1 = new Rdn( " a = b " );
         Rdn rdn2 = new Rdn( " a = c " );
-        assertTrue( rdn1.compareTo( rdn2 ) < 0 );
-        assertTrue( rdn2.compareTo( rdn1 ) > 0 );
-        assertEquals( 0, rdn1.compareTo( rdn2 ) + rdn2.compareTo( rdn1 ) );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
 
     }
 
 
     /**
      * Test for DIRSHARED-3.
-     * Tests that compareTo() is invertable for multi-valued RDNs with different values.
+     * Tests that equals() is invertable for multi-valued RDNs with different values.
      * 
      * @throws LdapException
      */
@@ -519,15 +509,14 @@ public class RdnTest
     {
         Rdn rdn1 = new Rdn( " a = b + a = c " );
         Rdn rdn2 = new Rdn( " a = b + a = y " );
-        assertTrue( rdn1.compareTo( rdn2 ) < 0 );
-        assertTrue( rdn2.compareTo( rdn1 ) > 0 );
-        assertEquals( 0, rdn1.compareTo( rdn2 ) + rdn2.compareTo( rdn1 ) );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
     }
 
 
     /**
      * Test for DIRSHARED-3.
-     * Tests that compareTo() is invertable for multi-valued RDNs with different types.
+     * Tests that equals() is invertable for multi-valued RDNs with different types.
      * 
      * @throws org.apache.directory.shared.ldap.model.exception.LdapException
      */
@@ -536,15 +525,14 @@ public class RdnTest
     {
         Rdn rdn1 = new Rdn( " a = b + c = d  " );
         Rdn rdn2 = new Rdn( " e = f + g = h " );
-        assertTrue( rdn1.compareTo( rdn2 ) < 0 );
-        assertTrue( rdn2.compareTo( rdn1 ) > 0 );
-        assertEquals( 0, rdn1.compareTo( rdn2 ) + rdn2.compareTo( rdn1 ) );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
     }
 
 
     /**
      * Test for DIRSHARED-3.
-     * Tests that compareTo() is invertable for multi-valued RDNs with different order.
+     * Tests that equals() is invertable for multi-valued RDNs with different order.
      * 
      * @throws LdapException
      */
@@ -553,9 +541,8 @@ public class RdnTest
     {
         Rdn rdn1 = new Rdn( " c = d + a = b " );
         Rdn rdn2 = new Rdn( " a = b + e = f " );
-        assertTrue( rdn1.compareTo( rdn2 ) < 0 );
-        assertTrue( rdn2.compareTo( rdn1 ) > 0 );
-        assertEquals( 0, rdn1.compareTo( rdn2 ) + rdn2.compareTo( rdn1 ) );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
     }
 
 
@@ -569,7 +556,7 @@ public class RdnTest
     {
         Rdn rdn1 = new Rdn( " a = b " );
 
-        assertEquals( 1, rdn1.compareTo( null ) );
+        assertFalse( rdn1.equals( null ) );
     }
 
 
@@ -584,7 +571,7 @@ public class RdnTest
         Rdn rdn1 = new Rdn( " a = b " );
         Rdn rdn2 = new Rdn( " a = b " );
 
-        assertEquals( 0, rdn1.compareTo( rdn2 ) );
+        assertTrue( rdn1.equals( rdn2 ) );
     }
 
 
@@ -599,8 +586,7 @@ public class RdnTest
         Rdn rdn1 = new Rdn( " a = b " );
         Rdn rdn2 = new Rdn( " A = b " );
 
-        assertEquals( 0, rdn1.compareTo( rdn2 ) );
-        assertEquals( true, rdn1.equals( rdn2 ) );
+        assertTrue( rdn1.equals( rdn2 ) );
     }
 
 
@@ -615,7 +601,7 @@ public class RdnTest
         Rdn rdn1 = new Rdn( " a = b " );
         Rdn rdn2 = new Rdn( " A = d " );
 
-        assertTrue( rdn1.compareTo( rdn2 ) < 0 );
+        assertFalse( rdn1.equals( rdn2 ) );
     }
 
 
@@ -1385,7 +1371,7 @@ public class RdnTest
 
 
     /**
-     * Tests the equals and compareTo results of cloned multi-valued RDNs.
+     * Tests the equals and equals results of cloned multi-valued RDNs.
      * Test for DIRSHARED-9.
      * 
      * @throws LdapException
@@ -1398,13 +1384,12 @@ public class RdnTest
         Rdn rdn = new Rdn( " A = b + C = d" );
         Rdn clonedRdn = (Rdn) rdn.clone();
 
-        assertEquals( 0, rdn.compareTo( clonedRdn ) );
-        assertEquals( true, rdn.equals( clonedRdn ) );
+        assertTrue( rdn.equals( clonedRdn ) );
     }
 
 
     /**
-     * Tests the equals and compareTo results of copy constructed multi-valued RDNs.
+     * Tests the equals and equals results of copy constructed multi-valued RDNs.
      * Test for DIRSHARED-9.
      * 
      * @throws LdapException
@@ -1417,8 +1402,7 @@ public class RdnTest
         Rdn rdn = new Rdn( " A = b + C = d" );
         Rdn copiedRdn = new Rdn( rdn );
 
-        assertEquals( 0, rdn.compareTo( copiedRdn ) );
-        assertEquals( true, rdn.equals( copiedRdn ) );
+        assertTrue( rdn.equals( copiedRdn ) );
     }
 
 



Mime
View raw message