directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r359047 - /directory/shared/ldap/branches/DN-refactoring/common/src/test/org/apache/ldap/common/name/LdapDNTest.java
Date Mon, 26 Dec 2005 10:19:19 GMT
Author: elecharny
Date: Mon Dec 26 02:19:15 2005
New Revision: 359047

URL: http://svn.apache.org/viewcvs?rev=359047&view=rev
Log:
- Added a method to test getAllRdn()
- Fixed the usage of getAll()

Modified:
    directory/shared/ldap/branches/DN-refactoring/common/src/test/org/apache/ldap/common/name/LdapDNTest.java

Modified: directory/shared/ldap/branches/DN-refactoring/common/src/test/org/apache/ldap/common/name/LdapDNTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/DN-refactoring/common/src/test/org/apache/ldap/common/name/LdapDNTest.java?rev=359047&r1=359046&r2=359047&view=diff
==============================================================================
--- directory/shared/ldap/branches/DN-refactoring/common/src/test/org/apache/ldap/common/name/LdapDNTest.java
(original)
+++ directory/shared/ldap/branches/DN-refactoring/common/src/test/org/apache/ldap/common/name/LdapDNTest.java
Mon Dec 26 02:19:15 2005
@@ -830,7 +830,7 @@
         Enumeration nc = dn.getAll();
         
         Assert.assertEquals( true, nc.hasMoreElements() );
-        Assert.assertEquals( "a=b", nc.nextElement().toString() );
+        Assert.assertEquals( "a=b", nc.nextElement() );
         Assert.assertEquals( false, nc.hasMoreElements() );
     }
     
@@ -843,11 +843,11 @@
         Enumeration nc = dn.getAll();
         
         Assert.assertEquals( true, nc.hasMoreElements() );
-        Assert.assertEquals( "c=d", nc.nextElement().toString() );
+        Assert.assertEquals( "c=d", nc.nextElement() );
         Assert.assertEquals( true, nc.hasMoreElements() );
-        Assert.assertEquals( "a=b", nc.nextElement().toString() );
+        Assert.assertEquals( "a=b", nc.nextElement() );
         Assert.assertEquals( true, nc.hasMoreElements() );
-        Assert.assertEquals( "e=f+g=h", nc.nextElement().toString() );
+        Assert.assertEquals( "e=f+g=h", nc.nextElement() );
         Assert.assertEquals( false, nc.hasMoreElements() );
     }
     
@@ -860,13 +860,13 @@
         Enumeration nc = dn.getAll();
         
         Assert.assertEquals( true, nc.hasMoreElements() );
-        Assert.assertEquals( "c=d", nc.nextElement().toString() );
+        Assert.assertEquals( "c=d", nc.nextElement() );
         Assert.assertEquals( true, nc.hasMoreElements() );
-        Assert.assertEquals( "a=b", nc.nextElement().toString() );
+        Assert.assertEquals( "a=b", nc.nextElement() );
         Assert.assertEquals( true, nc.hasMoreElements() );
         
         // The lowest atav should be the first one
-        Assert.assertEquals( "e=f+g=h", nc.nextElement().toString() );
+        Assert.assertEquals( "e=f+g=h", nc.nextElement() );
         Assert.assertEquals( false, nc.hasMoreElements() );
     }
     
@@ -1326,7 +1326,7 @@
 
 
     /**
-     * Class to test for getSuffix
+     * Class to test for getAll
      * @throws Exception if anything goes wrong. 
      */
     public void testGetAll() 
@@ -1348,11 +1348,11 @@
         
         for ( int i = 0 ; enum1.hasMoreElements(); i++ ) 
         {
-            Rdn element = ( Rdn ) enum1.nextElement() ;
+            String element = ( String ) enum1.nextElement() ;
             
             if ( i == 0 ) 
             {
-                assertEquals( "ou=East", element.toString() ) ;
+                assertEquals( "ou=East", element ) ;
             }
         }
         
@@ -1361,7 +1361,7 @@
         
         for ( int i = 0 ; enum2.hasMoreElements(); i++ ) 
         {
-        	Rdn element = ( Rdn ) enum2.nextElement() ;
+        	String element = ( String ) enum2.nextElement() ;
             
             if ( i == 0 ) 
             {
@@ -1379,7 +1379,7 @@
         
         for ( int i = 0 ; enum3.hasMoreElements(); i++ ) 
         {
-        	Rdn element = ( Rdn ) enum3.nextElement() ;
+        	String element = ( String ) enum3.nextElement() ;
             
             if ( i == 0 ) 
             {
@@ -1402,7 +1402,7 @@
         
         for ( int i = 0 ; enum4.hasMoreElements(); i++ ) 
         {
-        	Rdn element = ( Rdn ) enum4.nextElement() ;
+        	String element = ( String ) enum4.nextElement() ;
             
             if ( i == 0 ) 
             {
@@ -1430,7 +1430,7 @@
         
         for ( int i = 0 ; enum5.hasMoreElements(); i++ ) 
         {
-        	Rdn element = ( Rdn ) enum5.nextElement() ;
+        	String element = ( String ) enum5.nextElement() ;
             
             if ( i == 0 ) 
             {
@@ -1463,7 +1463,55 @@
         
         for ( int i = 0 ; enum6.hasMoreElements(); i++ ) 
         {
-        	Rdn element = ( Rdn ) enum6.nextElement() ;
+        	String element = ( String ) enum6.nextElement() ;
+            
+            if ( i == 0 ) 
+            {
+                assertEquals( "ou=West", element.toString() ) ;
+            }
+            
+            if ( i == 1 ) 
+            {
+                assertEquals( "ou=Marketing", element.toString() ) ;
+            }
+            
+            if ( i == 2 ) 
+            {
+                assertEquals( "cn=John", element.toString() ) ;
+            }
+            
+            if ( i == 3 ) 
+            {
+                assertEquals( "cn=HomeDir", element.toString() ) ;
+            }
+            
+            if ( i == 4 ) 
+            {
+                assertEquals( "cn=Website", element.toString() ) ;
+            }
+            
+            if ( i == 5 ) 
+            {
+                assertEquals( "cn=Airline", element.toString() ) ;
+            }
+        }
+    }
+
+    /**
+     * Class to test for getAllRdn
+     * @throws Exception if anything goes wrong. 
+     */
+    public void testGetAllRdn() 
+        throws Exception
+    {
+        LdapDN name = new LdapDN( "cn=Airline,cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West"
) ;
+                        
+        Enumeration rdns = name.getAllRdn() ;
+        assertEquals( true, rdns.hasMoreElements() ) ; 
+        
+        for ( int i = 0 ; rdns.hasMoreElements(); i++ ) 
+        {
+        	Rdn element = ( Rdn ) rdns.nextElement() ;
             
             if ( i == 0 ) 
             {



Mime
View raw message