directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r420126 - /directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Date Sat, 08 Jul 2006 15:32:02 GMT
Author: elecharny
Date: Sat Jul  8 08:32:02 2006
New Revision: 420126

URL: http://svn.apache.org/viewvc?rev=420126&view=rev
Log:
- Added tests for DIRSERVER 642 and DIR 182
- Replacved toUpName() by getUpName()
- Added a tests for ending spaces

Modified:
    directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java

Modified: directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=420126&r1=420125&r2=420126&view=diff
==============================================================================
--- directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
(original)
+++ directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Sat Jul  8 08:32:02 2006
@@ -17,6 +17,7 @@
 package org.apache.directory.shared.ldap.name;
 
 
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -95,6 +96,16 @@
         Assert.assertEquals( "a=b", dn.toString() );
     }
 
+    /**
+     * test a simple DN with some spaces : "a = b  "
+     */
+    public void testLdapDNSimpleWithSpaces() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b  " );
+        Assert.assertEquals( "a = b  ", dn.getUpName() );
+        Assert.assertEquals( "a=b", dn.toString() );
+    }
+
 
     /**
      * test a composite DN : a = b, d = e
@@ -106,6 +117,16 @@
         Assert.assertEquals( "a = b, c = d", dn.getUpName() );
     }
 
+    /**
+     * test a composite DN with spaces : a = b  , d = e
+     */
+    public void testLdapDNCompositeWithSpaces() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b  , c = d" );
+        Assert.assertEquals( "a=b,c=d", dn.toString() );
+        Assert.assertEquals( "a = b  , c = d", dn.getUpName() );
+    }
+
 
     /**
      * test a composite DN with or without spaces: a=b, a =b, a= b, a = b, a = b
@@ -2095,10 +2116,11 @@
         oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer()
) );
         oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() )
);
 
+        assertTrue( name.getUpName().equals( "ou= Some   People   ,dc = eXample,dc= cOm"
) );
+
         Name result = LdapDN.normalize( name, oids );
 
         assertTrue( result.toString().equals( "ou=some people,dc=example,dc=com" ) );
-        assertTrue( ( ( LdapDN ) result ).toUpName().equals( "ou= Some   People   ,dc = eXample,dc=
cOm" ) );
     }
 
 
@@ -2144,7 +2166,7 @@
 
         assertTrue( result.toString().equals( "dc=and some animals+ou=some people,dc=example,dc=com"
) );
         assertTrue( ( ( LdapDN ) result )
-            .toUpName()
+            .getUpName()
             .equals(
                 "2.5.4.11= Some   People   + 0.9.2342.19200300.100.1.25=  And   Some anImAls,0.9.2342.19200300.100.1.25
= eXample,dc= cOm" ) );
     }
@@ -2171,7 +2193,7 @@
 
         assertTrue( result.toString().equals( "dc=and some animals+ou=some people,dc=example,dc=com"
) );
         assertTrue( ( ( LdapDN ) result )
-            .toUpName()
+            .getUpName()
             .equals(
                 "2.5.4.11= Some   People   + domainComponent=  And   Some anImAls,DomainComponent
= eXample,0.9.2342.19200300.100.1.25= cOm" ) );
     }
@@ -2430,4 +2452,148 @@
             assertEquals(j.nextElement(), a.nextElement());
         }
     }
+    
+    /**
+     * Test for DIRSERVER-642
+     * @throws NamingException
+     */
+    public void testDoubleQuoteInNameDIRSERVER_642() throws NamingException 
+    {
+        Name name1 = new LdapDN( "cn=\"Kylie Minogue\",dc=example,dc=com" );
+        Name name2 = new LdapName( "cn=\"Kylie Minogue\",dc=example,dc=com" );
+
+        Enumeration j = name1.getAll();
+        Enumeration a = name2.getAll();
+        
+        while (j.hasMoreElements())
+        {
+            assertTrue(j.hasMoreElements());
+            assertEquals(j.nextElement(), a.nextElement());
+        }
+    }
+
+    /**
+     * Test for DIRSERVER-642
+     * @throws NamingException
+     */
+    public void testDoubleQuoteInNameDIRSERVER_642_1() throws NamingException 
+    {
+        LdapDN dn = new LdapDN( "cn=\" Kylie Minogue \",dc=example,dc=com" );
+
+        Assert.assertEquals( "cn=\" Kylie Minogue \",dc=example,dc=com", dn.getUpName() );
+        Assert.assertEquals( "cn= Kylie Minogue ,dc=example,dc=com", dn.toString() );
+    }
+
+    /**
+     * Test for DIRSERVER-184
+     * @throws NamingException
+     */
+    public void testLeadingAndTrailingSpacesDIRSERVER_184() throws NamingException 
+    {
+        LdapDN name = new LdapDN( "dn= \\ four spaces leading and 3 trailing \\  " );
+
+        Assert.assertEquals( "dn=\\ four spaces leading and 3 trailing \\ ", name.toString()
);
+        Assert.assertEquals( "dn= \\ four spaces leading and 3 trailing \\  ", name.getUpName()
);
+    }
+
+    /**
+     * Test for DIRSERVER-184
+     * @throws NamingException
+     */
+    public void testDIRSERVER_184_1() throws NamingException 
+    {
+        try
+        {
+            new LdapDN( "dn=middle\\ spaces" );
+        }
+        catch ( InvalidNameException ine )
+        {
+            Assert.assertTrue( true );
+        }
+    }
+    
+    /**
+     * Test for DIRSERVER-184
+     * @throws NamingException
+     */
+    public void testDIRSERVER_184_2() throws NamingException 
+    {
+        try
+        {
+            new LdapDN( "dn=# a leading pound" );
+        }
+        catch ( InvalidNameException ine )
+        {
+            Assert.assertTrue( true );
+        }
+    }
+
+    /**
+     * Test for DIRSERVER-184
+     * @throws NamingException
+     */
+    public void testDIRSERVER_184_3() throws NamingException 
+    {
+        LdapDN name = new LdapDN( "dn=\\# a leading pound" );
+
+        Assert.assertEquals( "dn=\\# a leading pound", name.toString() );
+        Assert.assertEquals( "dn=\\# a leading pound", name.getUpName() );
+    }
+
+    /**
+     * Test for DIRSERVER-184
+     * @throws NamingException
+     */
+    public void testDIRSERVER_184_4() throws NamingException 
+    {
+        LdapDN name = new LdapDN( "dn=a middle \\# pound" );
+
+        Assert.assertEquals( "dn=a middle \\# pound", name.toString() );
+        Assert.assertEquals( "dn=a middle \\# pound", name.getUpName() );
+    }
+
+    /**
+     * Test for DIRSERVER-184
+     * @throws NamingException
+     */
+    public void testDIRSERVER_184_5() throws NamingException 
+    {
+        LdapDN name = new LdapDN( "dn=a trailing pound \\#" );
+        
+        Assert.assertEquals( "dn=a trailing pound \\#", name.toString() );
+        Assert.assertEquals( "dn=a trailing pound \\#", name.getUpName() );
+    }
+
+    /**
+     * Test for DIRSERVER-184
+     * @throws NamingException
+     */
+    public void testDIRSERVER_184_6() throws NamingException 
+    {
+        try
+        {
+            new LdapDN( "dn=a middle # pound" );
+        }
+        catch ( InvalidNameException ine )
+        {
+            Assert.assertTrue( true );
+        }
+    }
+
+    /**
+     * Test for DIRSERVER-184
+     * @throws NamingException
+     */
+    public void testDIRSERVER_184_7() throws NamingException 
+    {
+        try
+        {
+            new LdapDN( "dn=a trailing pound #" );
+        }
+        catch ( InvalidNameException ine )
+        {
+            Assert.assertTrue( true );
+        }
+    }
 }
+



Mime
View raw message