directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r327695 - /directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapDNTest.java
Date Sat, 22 Oct 2005 20:49:15 GMT
Author: elecharny
Date: Sat Oct 22 13:49:11 2005
New Revision: 327695

URL: http://svn.apache.org/viewcvs?rev=327695&view=rev
Log:
Added a test which parse a DN 

Modified:
    directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapDNTest.java

Modified: directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapDNTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapDNTest.java?rev=327695&r1=327694&r2=327695&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapDNTest.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/primitives/LdapDNTest.java
Sat Oct 22 13:49:11 2005
@@ -67,7 +67,8 @@
     public void testLdapDNSimple() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "a = b" );
-        Assert.assertEquals( "a=b", dn.getName() );
+        Assert.assertEquals( "a = b", dn.getName() );
+        Assert.assertEquals( "a=b", dn.toString() );
     }
 
     /**
@@ -76,7 +77,8 @@
     public void testLdapDNComposite() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "a = b, c = d" );
-        Assert.assertEquals( "a=b,c=d", dn.getName() );
+        Assert.assertEquals( "a=b,c=d", dn.toString() );
+        Assert.assertEquals( "a = b, c = d", dn.getName() );
     }
 
     /**
@@ -85,7 +87,8 @@
     public void testLdapDNCompositeWithSpace() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "a=b, a =b, a= b, a = b, a  =  b" );
-        Assert.assertEquals( "a=b,a=b,a=b,a=b,a=b", dn.getName() );
+        Assert.assertEquals( "a=b,a=b,a=b,a=b,a=b", dn.toString() );
+        Assert.assertEquals( "a=b, a =b, a= b, a = b, a  =  b", dn.getName() );
     }
 
     /**
@@ -95,7 +98,8 @@
     public void testLdapDNCompositeSepators() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "a=b;c=d,e=f" );
-        Assert.assertEquals( "a=b,c=d,e=f", dn.getName() );
+        Assert.assertEquals( "a=b,c=d,e=f", dn.toString() );
+        Assert.assertEquals( "a=b;c=d,e=f", dn.getName() );
     }
 
     /**
@@ -104,7 +108,8 @@
     public void testLdapDNSimpleMultivaluedAttribute() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "a = b + c = d" );
-        Assert.assertEquals( "a=b+c=d", dn.getName() );
+        Assert.assertEquals( "a=b+c=d", dn.toString() );
+        Assert.assertEquals( "a = b + c = d", dn.getName() );
     }
 
     /**
@@ -113,7 +118,8 @@
     public void testLdapDNCompositeMultivaluedAttribute() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "a=b+c=d, e=f + g=h + i=j" );
-        Assert.assertEquals( "a=b+c=d,e=f+g=h+i=j", dn.getName() );
+        Assert.assertEquals( "a=b+c=d,e=f+g=h+i=j", dn.toString() );
+        Assert.assertEquals( "a=b+c=d, e=f + g=h + i=j", dn.getName() );
     }
 
     /**
@@ -122,7 +128,8 @@
     public void testLdapDNOidUpper() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "OID.12.34.56 = azerty" );
-        Assert.assertEquals( "oid.12.34.56=azerty", dn.getName() );
+        Assert.assertEquals( "oid.12.34.56=azerty", dn.toString() );
+        Assert.assertEquals( "OID.12.34.56 = azerty", dn.getName() );
     }
 
     /**
@@ -131,7 +138,8 @@
     public void testLdapDNOidLower() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "oid.12.34.56 = azerty" );
-        Assert.assertEquals( "oid.12.34.56=azerty", dn.getName() );
+        Assert.assertEquals( "oid.12.34.56=azerty", dn.toString() );
+        Assert.assertEquals( "oid.12.34.56 = azerty", dn.getName() );
     }
 
     /**
@@ -140,7 +148,8 @@
     public void testLdapDNOidWithoutPrefix() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "12.34.56 = azerty" );
-        Assert.assertEquals( "12.34.56=azerty", dn.getName() );
+        Assert.assertEquals( "12.34.56=azerty", dn.toString() );
+        Assert.assertEquals( "12.34.56 = azerty", dn.getName() );
     }
 
     /**
@@ -149,7 +158,8 @@
     public void testLdapDNCompositeOidWithoutPrefix() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "12.34.56 = azerty; 7.8 = test" );
-        Assert.assertEquals( "12.34.56=azerty,7.8=test", dn.getName() );
+        Assert.assertEquals( "12.34.56=azerty,7.8=test", dn.toString() );
+        Assert.assertEquals( "12.34.56 = azerty; 7.8 = test", dn.getName() );
     }
 
     /**
@@ -158,7 +168,8 @@
     public void testLdapDNPairCharAttributeValue() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\A0\\00" );
-        Assert.assertEquals( "a=\\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\A0\\00", dn.getName()
);
+        Assert.assertEquals( "a=\\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\A0\\00", dn.toString()
);
+        Assert.assertEquals( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\A0\\00", dn.getName()
);
     }
 
     /**
@@ -167,7 +178,8 @@
     public void testLdapDNHexStringAttributeValue() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "a = #0010A0AAFF" );
-        Assert.assertEquals( "a=#0010A0AAFF", dn.getName() );
+        Assert.assertEquals( "a=#0010A0AAFF", dn.toString() );
+        Assert.assertEquals( "a = #0010A0AAFF", dn.getName() );
     }
 
     /**
@@ -176,7 +188,8 @@
     public void testLdapDNQuotedAttributeValue() throws InvalidNameException
     {
         LdapDN dn = new LdapDN( "a = quoted \\\"value" );
-        Assert.assertEquals( "a=quoted \\\"value", dn.getName() );
+        Assert.assertEquals( "a=quoted \\\"value", dn.toString() );
+        Assert.assertEquals( "a = quoted \\\"value", dn.getName() );
     }
 
     // REMOVE operation -------------------------------------------------------
@@ -188,6 +201,7 @@
     {
         LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
         Assert.assertEquals( "e=f", dn.remove( 0 ).toString() );
+        Assert.assertEquals( "a=b,c=d", dn.toString() );
         Assert.assertEquals( "a=b,c=d", dn.getName() );
     }
 
@@ -307,6 +321,7 @@
         LdapDN dn = new LdapDN();
         
         dn.add( "e = f" );
+        Assert.assertEquals( "e=f" , dn.toString() );
         Assert.assertEquals( "e=f" , dn.getName() );
         Assert.assertEquals( 1, dn.size() );
     }
@@ -319,6 +334,7 @@
         LdapDN dn = new LdapDN( "a=b, c=d");
         
         dn.add( "e = f" );
+        Assert.assertEquals( "e=f,a=b,c=d" , dn.toString() );
         Assert.assertEquals( "e=f,a=b,c=d" , dn.getName() );
         Assert.assertEquals( 3, dn.size() );
     }
@@ -335,7 +351,7 @@
         // Warning ! The order of AVAs has changed during the parsing
         // This has no impact on the correctness of the DN, but the
         // String used to do the comparizon should be inverted.
-        Assert.assertEquals( "g=h+e=f,a=b,c=d" , dn.getName() );
+        Assert.assertEquals( "g=h+e=f,a=b,c=d" , dn.toString() );
         Assert.assertEquals( 3, dn.size() );
     }
     
@@ -397,7 +413,8 @@
         LdapDN dn = new LdapDN( "a = b" );
         LdapDN dn2 = new LdapDN();
         dn.addAll( dn2 );
-        Assert.assertEquals( "a=b", dn.getName() );
+        Assert.assertEquals( "a=b", dn.toString() );
+        Assert.assertEquals( "a = b", dn.getName() );
     }
 
     /**
@@ -457,7 +474,8 @@
         LdapDN dn = new LdapDN( "a = b" );
         LdapDN dn2 = new LdapDN();
         dn.addAll( 0, dn2 );
-        Assert.assertEquals( "a=b", dn.getName() );
+        Assert.assertEquals( "a=b", dn.toString() );
+        Assert.assertEquals( "a = b", dn.getName() );
     }
 
     /**
@@ -1025,5 +1043,13 @@
         
         Assert.assertEquals( 30, dn.getNbBytes() );
         Assert.assertEquals("cn=John,ou=People,ou=Marketing", new String( bytes, "UTF-8"
) );
+    }
+    
+    public void testStringParser() throws Exception
+    {
+        LdapDN name = DNParser.parse( "CN = Emmanuel  Lécharny" );
+        
+        Assert.assertEquals( "CN = Emmanuel  Lécharny", name.getName() );
+        Assert.assertEquals( "cn=Emmanuel  Lécharny", name.toString() );
     }
 }



Mime
View raw message