directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r427793 [6/6] - in /directory/branches/shared/0.9.5: asn1/src/main/java/org/apache/directory/shared/asn1/ber/ asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/ ldap/ ldap/src/main/antlr/ ldap/src/main/java/org/apache/director...
Date Tue, 01 Aug 2006 23:35:23 GMT
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java?rev=427793&r1=427792&r2=427793&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
(original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
Tue Aug  1 16:35:20 2006
@@ -1,5 +1,18 @@
 /*
- * Copyright (c) 2005 Your Corporation. All Rights Reserved.
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
  */
 package org.apache.directory.shared.ldap.ldif;
 
@@ -27,11 +40,14 @@
 public class LdifReaderTest extends TestCase
 {
     private byte[] data;
-
+    
+    private static File HJENSEN_JPEG_FILE = null;
+    private static File FIONA_JPEG_FILE = null;
+    
     private File createFile( String name, byte[] data ) throws IOException
     {
-        File jpeg = new File( "/tmp/" + name );
-
+        File jpeg = File.createTempFile( name, "jpg" );
+        
         jpeg.createNewFile();
 
         DataOutputStream os = new DataOutputStream( new FileOutputStream( jpeg ) );
@@ -60,8 +76,8 @@
             data[i] = (byte) i;
         }
 
-        createFile( "hjensen.jpg", data );
-        createFile( "fiona.jpg", data );
+        HJENSEN_JPEG_FILE = createFile( "hjensen", data );
+        FIONA_JPEG_FILE = createFile( "fiona", data );
     }
 
     public void testLdifNull() throws NamingException
@@ -467,7 +483,7 @@
         assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
 
         Attribute attr = entry.get( "cn" );
-        assertTrue( attr.contains( "Emmanuel Lécharny".getBytes( "UTF-8" ) ) );
+        assertTrue( attr.contains( "Emmanuel L\u00e9charny".getBytes( "UTF-8" ) ) );
 
         attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
@@ -510,7 +526,7 @@
         assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
 
         Attribute attr = entry.get( "cn" );
-        assertTrue( attr.contains( "Emmanuel Lécharny  ".getBytes( "UTF-8" ) ) );
+        assertTrue( attr.contains( "Emmanuel L\u00e9charny  ".getBytes( "UTF-8" ) ) );
 
         attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
@@ -771,11 +787,13 @@
     public void testLdifParserRFC2849Sample4() throws NamingException, Exception
     {
         String ldif = 
-            "version: 1\n" + "dn:: b3U95Za25qWt6YOoLG89QWlyaXVz\n" + 
+            "version: 1\n" + 
+            "dn:: b3U95Za25qWt6YOoLG89QWlyaXVz\n" + 
             "# dn:: ou=営業部,o=Airius\n" + 
             "objectclass: top\n" + 
             "objectclass: organizationalUnit\n" + 
-            "ou:: 5Za25qWt6YOo\n" + "# ou:: 営業部\n" + 
+            "ou:: 5Za25qWt6YOo\n" + 
+            "# ou:: 営業部\n" + 
             "ou;lang-ja:: 5Za25qWt6YOo\n" + 
             "# ou;lang-ja:: 営業部\n" + 
             "ou;lang-ja;phonetic:: 44GI44GE44GO44KH44GG44G2\n" + 
@@ -810,12 +828,11 @@
             "title:: 5Za25qWt6YOoIOmDqOmVtw==\n" + 
             "# title:: 営業部 部長\n" + 
             "givenname;lang-ja;phonetic:: 44KN44Gp44Gr44O8\n" + 
-            "# givenname;lang-ja;phonetic::\n" + 
-              " ろどにー\n" + 
+            "# givenname;lang-ja;phonetic:: ろどにー\n" + 
             "sn;lang-ja;phonetic:: 44GK44GM44GV44KP44KJ\n" + 
             "# sn;lang-ja;phonetic:: おがさわら\n" + 
             "cn;lang-ja;phonetic:: 44GK44GM44GV44KP44KJIOOCjeOBqeOBq+ODvA==\n" + 
-            "# cn;lang-ja;phonetic:: おがさわら ろどにー\n"
+ 
+            "# cn;lang-ja;phonetic:: おがぎわら ろどにー\n"
+
             "title;lang-ja;phonetic:: 44GI44GE44GO44KH44GG44G2IOOBtuOBoeOCh+OBhg==\n" + 
             "# title;lang-ja;phonetic::\n" + 
               "# えいぎょうぶ ぶちょう\n" + 
@@ -830,16 +847,17 @@
         String[][][] values =
             {
                 {
-                    { "dn", "ou=営業部,o=Airius" },
+                    { "dn", "ou=\u55b6\u696d\u90e8,o=Airius" }, // 55b6 = 営, 696d =
業, 90e8 = 部 
                     { "objectclass", "top" },
                     { "objectclass", "organizationalUnit" },
-                    { "ou", "営業部" },
-                    { "ou;lang-ja", "営業部" },
-                    { "ou;lang-ja;phonetic", "えいぎょうぶ" },
+                    { "ou", "\u55b6\u696d\u90e8" },
+                    { "ou;lang-ja", "\u55b6\u696d\u90e8" },
+                    { "ou;lang-ja;phonetic", "\u3048\u3044\u304e\u3087\u3046\u3076" }, //
3048 = え, 3044 = い, 304e = ぎ
+                                                                                    // 3087
= ょ, 3046 = う, 3076 = ぶ
                     { "ou;lang-en", "Sales" },
                     { "description", "Japanese office" } },
                     {
-                    { "dn", "uid=rogasawara,ou=営業部,o=Airius" },
+                    { "dn", "uid=rogasawara,ou=\u55b6\u696d\u90e8,o=Airius" },
                     { "userpassword", "{SHA}O3HSv1MusyL4kTjP+HKI5uxuNoM=" },
                     { "objectclass", "top" },
                     { "objectclass", "person" },
@@ -847,19 +865,19 @@
                     { "objectclass", "inetOrgPerson" },
                     { "uid", "rogasawara" },
                     { "mail", "rogasawara@airius.co.jp" },
-                    { "givenname;lang-ja", "ロドニー" },
-                    { "sn;lang-ja", "小笠原" },
-                    { "cn;lang-ja", "小笠原 ロドニー" },
-                    { "title;lang-ja", "営業部 部長" },
+                    { "givenname;lang-ja", "\u30ed\u30c9\u30cb\u30fc" },    // 30ed = ロ,
30c9 = ド, 30cb = ニ, 30fc = ー   
+                    { "sn;lang-ja", "\u5c0f\u7b20\u539f" },    // 5c0f = 小, 7b20 = 笠,
539f = 原  
+                    { "cn;lang-ja", "\u5c0f\u7b20\u539f \u30ed\u30c9\u30cb\u30fc" },
+                    { "title;lang-ja", "\u55b6\u696d\u90e8 \u90e8\u9577" },   // 9577 = 長
                     { "preferredlanguage", "ja" },
-                    { "givenname", "ロドニー" },
-                    { "sn", "小笠原" },
-                    { "cn", "小笠原 ロドニー" },
-                    { "title", "営業部 部長" },
-                    { "givenname;lang-ja;phonetic", "ろどにー" },
-                    { "sn;lang-ja;phonetic", "おがさわら" },
-                    { "cn;lang-ja;phonetic", "おがさわら ろどにー"
},
-                    { "title;lang-ja;phonetic", "えいぎょうぶ ぶちょう"
},
+                    { "givenname", "\u30ed\u30c9\u30cb\u30fc" },
+                    { "sn", "\u5c0f\u7b20\u539f" },
+                    { "cn", "\u5c0f\u7b20\u539f \u30ed\u30c9\u30cb\u30fc" },
+                    { "title", "\u55b6\u696d\u90e8 \u90e8\u9577" },
+                    { "givenname;lang-ja;phonetic", "\u308d\u3069\u306b\u30fc" },  // 308d
= ろ,3069 = ど, 306b = に
+                    { "sn;lang-ja;phonetic", "\u304a\u304c\u3055\u308f\u3089" }, // 304a
= お, 304c = が,3055 = さ,308f = わ, 3089 = ら    
+                    { "cn;lang-ja;phonetic", "\u304a\u304c\u3055\u308f\u3089 \u308d\u3069\u306b\u30fc"
},
+                    { "title;lang-ja;phonetic", "\u3048\u3044\u304e\u3087\u3046\u3076 \u3076\u3061\u3087\u3046"
}, // 304E = ぎ, 3061 = ち
                     { "givenname;lang-en", "Rodney" },
                     { "sn;lang-en", "Ogasawara" },
                     { "cn;lang-en", "Rodney Ogasawara" },
@@ -911,7 +929,7 @@
             "sn: Jensen\n" + 
             "uid: hjensen\n" + 
             "telephonenumber: +1 408 555 1212\n" + 
-            "jpegphoto:< file:///tmp/hjensen.jpg";
+            "jpegphoto:< file:" + HJENSEN_JPEG_FILE.getAbsolutePath() + "\n";
 
         LdifReader reader = new LdifReader();
         List entries = reader.parseLdif( ldif );
@@ -976,7 +994,7 @@
             "sn: Jensen\n" + 
             "uid: hjensen\n" + 
             "telephonenumber: +1 408 555 1212\n" + 
-            "jpegphoto:< file:///tmp/hjensen.jpg";
+            "jpegphoto:< file:" + HJENSEN_JPEG_FILE.getAbsolutePath() + "\n";
 
         LdifReader reader = new LdifReader();
         reader.setSizeLimit( 128 );
@@ -1007,7 +1025,7 @@
             "sn: Jensen\n" +
             "uid: fiona\n" +
             "telephonenumber: +1 408 555 1212\n" +
-            "jpegphoto:< file:///tmp/fiona.jpg\n" +
+            "jpegphoto:< file:"  + FIONA_JPEG_FILE.getAbsolutePath() + "\n" +
             "\n" +
             // Second entry modification : DELETE
             "# Delete an existing entry\n" +

Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributesImplTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributesImplTest.java?rev=427793&r1=427792&r2=427793&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributesImplTest.java
(original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributesImplTest.java
Tue Aug  1 16:35:20 2006
@@ -25,7 +25,6 @@
 import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
 import org.apache.directory.shared.ldap.util.ArrayUtils;
 
-
 /**
  * Test cases for the methods of the LockableAttributeImpl class.
  * 

Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=427793&r1=427792&r2=427793&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
(original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Tue Aug  1 16:35:20 2006
@@ -17,6 +17,7 @@
 package org.apache.directory.shared.ldap.name;
 
 
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -33,6 +34,8 @@
 
 import javax.naming.InvalidNameException;
 import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapName;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
@@ -93,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
@@ -104,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
@@ -2093,11 +2116,11 @@
         oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer()
) );
         oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() )
);
 
-        LdapDN.setOidsMap( oids );
-        Name result = LdapDN.normalize( name );
+        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" ) );
     }
 
 
@@ -2117,8 +2140,7 @@
         oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer()
) );
         oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() )
);
 
-        LdapDN.setOidsMap( oids );
-        Name result = LdapDN.normalize( name );
+        Name result = LdapDN.normalize( name, oids );
         assertTrue( result.toString().equals( "" ) );
     }
 
@@ -2140,12 +2162,11 @@
         oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer()
) );
         oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() )
);
 
-        LdapDN.setOidsMap( oids );
-        Name result = LdapDN.normalize( name );
+        Name result = LdapDN.normalize( name, oids );
 
         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" ) );
     }
@@ -2168,12 +2189,11 @@
         oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer()
) );
         oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() )
);
 
-        LdapDN.setOidsMap( oids );
-        LdapDN result = LdapDN.normalize( name );
+        LdapDN result = LdapDN.normalize( name, oids );
 
         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" ) );
     }
@@ -2260,4 +2280,320 @@
 
         assertEquals( name1.hashCode(), name2.hashCode() );
     }
+    
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testName() throws NamingException
+    {
+        Name jName = new javax.naming.ldap.LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+        assertEquals(jName.toString(), "cn=four,cn=three,cn=two,cn=one");
+        assertEquals(aName.toString(), "cn=four,cn=three,cn=two,cn=one");
+        assertEquals(jName.toString(), aName.toString());
+    }
+
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testGetPrefixName() throws NamingException
+    {
+        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+        
+        assertEquals(jName.getPrefix(0).toString(), aName.getPrefix(0).toString());
+        assertEquals(jName.getPrefix(1).toString(), aName.getPrefix(1).toString());
+        assertEquals(jName.getPrefix(2).toString(), aName.getPrefix(2).toString());
+        assertEquals(jName.getPrefix(3).toString(), aName.getPrefix(3).toString());
+        assertEquals(jName.getPrefix(4).toString(), aName.getPrefix(4).toString());
+    }
+    
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testGetSuffix() throws NamingException
+    {
+        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+    
+        assertEquals(jName.getSuffix(0).toString(), aName.getSuffix(0).toString());
+        assertEquals(jName.getSuffix(1).toString(), aName.getSuffix(1).toString());
+        assertEquals(jName.getSuffix(2).toString(), aName.getSuffix(2).toString());
+        assertEquals(jName.getSuffix(3).toString(), aName.getSuffix(3).toString());
+        assertEquals(jName.getSuffix(4).toString(), aName.getSuffix(4).toString());
+    }
+    
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testAddStringName() throws NamingException
+    {
+        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+    
+        assertSame(jName, jName.add("cn=five"));
+        assertSame(aName, aName.add("cn=five"));
+        assertEquals(jName.toString(), aName.toString());
+    }
+    
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testAddIntString() throws NamingException
+    {
+        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+
+        assertSame(jName, jName.add(0,"cn=zero"));
+        assertSame(aName, aName.add(0,"cn=zero"));
+        assertEquals(jName.toString(), aName.toString());
+        
+        assertSame(jName, jName.add(2,"cn=one.5"));
+        assertSame(aName, aName.add(2,"cn=one.5"));
+        assertEquals(jName.toString(), aName.toString());
+        
+        assertSame(jName, jName.add(jName.size(),"cn=five"));
+        assertSame(aName, aName.add(aName.size(),"cn=five"));
+        assertEquals(jName.toString(), aName.toString());
+    }
+
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testAddAllName() throws NamingException
+    {
+        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+    
+        assertSame(jName, jName.addAll(new LdapName("cn=seven,cn=six")));
+        assertSame(aName, aName.addAll(new LdapDN("cn=seven,cn=six")));
+        assertEquals(jName.toString(), aName.toString());
+    }
+    
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testAddAllIntName() throws NamingException
+    {
+        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+        
+        assertSame(jName, jName.addAll(0, new LdapName("cn=zero,cn=zero.5")));
+        assertSame(aName, aName.addAll(0, new LdapDN("cn=zero,cn=zero.5")));
+        assertEquals(jName.toString(), aName.toString());
+
+        
+        assertSame(jName, jName.addAll(2, new LdapName("cn=zero,cn=zero.5")));
+        assertSame(aName, aName.addAll(2, new LdapDN("cn=zero,cn=zero.5")));
+        assertEquals(jName.toString(), aName.toString());
+    
+        
+        assertSame(jName, jName.addAll(jName.size(), new LdapName("cn=zero,cn=zero.5")));
+        assertSame(aName, aName.addAll(aName.size(), new LdapDN("cn=zero,cn=zero.5")));
+        assertEquals(jName.toString(), aName.toString());
+    }
+
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testStartsWithName() throws NamingException
+    {
+        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+    
+        assertEquals(jName.startsWith(new LdapName("cn=seven,cn=six,cn=five")),
+                aName.startsWith(new LdapDN("cn=seven,cn=six,cn=five")));
+        assertEquals(jName.startsWith(new LdapName("cn=three,cn=two,cn=one")),
+                aName.startsWith(new LdapDN("cn=three,cn=two,cn=one")));
+    }
+    
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testEndsWithName() throws NamingException
+    {
+        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+    
+        assertEquals(jName.endsWith(new LdapName("cn=seven,cn=six,cn=five")),
+                aName.endsWith(new LdapDN("cn=seven,cn=six,cn=five")));
+        assertEquals(jName.endsWith(new LdapName("cn=three,cn=two,cn=one")),
+                aName.endsWith(new LdapDN("cn=three,cn=two,cn=one")));
+    }
+    
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testRemoveName() throws NamingException
+    {
+        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+        
+        assertEquals(jName.remove(0).toString(), aName.remove(0).toString());
+        assertEquals(jName.toString(), aName.toString());
+    
+        assertEquals(jName.remove(jName.size() - 1).toString(), aName.remove(aName.size()
- 1).toString());
+        assertEquals(jName.toString(), aName.toString());
+    }
+    
+    /**
+     * Test for DIRSERVER-191
+     */
+    public void testGetAllName() throws NamingException
+    {
+        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
+        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
+
+        Enumeration j = jName.getAll();
+        Enumeration a = aName.getAll();
+        while (j.hasMoreElements())
+        {
+            assertTrue(j.hasMoreElements());
+            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 );
+        }
+    }
 }
+

Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java?rev=427793&r1=427792&r2=427793&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
(original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
Tue Aug  1 16:35:20 2006
@@ -324,7 +324,7 @@
 
         assertEquals( "RFC1779_1 : ",
             "CN=Marshall T. Rose, O=Dover Beach Consulting, L=Santa Clara, ST=California,
C=US",
-            ( ( LdapDN ) nameRFC1779_1 ).toUpName() );
+            ( ( LdapDN ) nameRFC1779_1 ).getUpName() );
         assertEquals( "RFC1779_1 : ", "cn=Marshall T. Rose,o=Dover Beach Consulting,l=Santa
Clara,st=California,c=US",
             nameRFC1779_1.toString() );
     }
@@ -342,7 +342,7 @@
 
         Name nameRFC2253_1 = parser.parse( "CN=Steve Kille,O=Isode limited,C=GB" );
 
-        assertEquals( "RFC2253_1 : ", "CN=Steve Kille,O=Isode limited,C=GB", ( ( LdapDN )
nameRFC2253_1 ).toUpName() );
+        assertEquals( "RFC2253_1 : ", "CN=Steve Kille,O=Isode limited,C=GB", ( ( LdapDN )
nameRFC2253_1 ).getUpName() );
     }
 
 
@@ -359,11 +359,10 @@
         Name nameRFC2253_2 = parser.parse( "CN = Sales + CN =   J. Smith , O = Widget Inc.
, C = US" );
 
         assertEquals( "RFC2253_2 : ", "CN = Sales + CN =   J. Smith , O = Widget Inc. , C
= US",
-            ( ( LdapDN ) nameRFC2253_2 ).toUpName() );
+            ( ( LdapDN ) nameRFC2253_2 ).getUpName() );
         assertEquals( "RFC2253_2 : ", "cn=J. Smith+cn=Sales,o=Widget Inc.,c=US", nameRFC2253_2.toString()
);
     }
 
-
     /**
      * Class under test for Name parse(String)
      * 
@@ -377,7 +376,7 @@
         Name nameRFC2253_3 = parser.parse( "CN=L. Eagle,   O=Sue\\, Grabbit and Runn, C=GB"
);
 
         assertEquals( "RFC2253_3 : ", "CN=L. Eagle,   O=Sue\\, Grabbit and Runn, C=GB", (
( LdapDN ) nameRFC2253_3 )
-            .toUpName() );
+            .getUpName() );
         assertEquals( "RFC2253_3 : ", "cn=L. Eagle,o=Sue\\, Grabbit and Runn,c=GB", nameRFC2253_3.toString()
);
     }
 
@@ -393,7 +392,7 @@
         NameParser parser = LdapDnParser.getNameParser();
 
         Name nameRFC2253_4 = parser.parse( "CN=Before\\0DAfter,O=Test,C=GB" );
-        assertEquals( "RFC2253_4 : ", "CN=Before\\0DAfter,O=Test,C=GB", ( ( LdapDN ) nameRFC2253_4
).toUpName() );
+        assertEquals( "RFC2253_4 : ", "CN=Before\\0DAfter,O=Test,C=GB", ( ( LdapDN ) nameRFC2253_4
).getUpName() );
     }
 
 
@@ -410,7 +409,7 @@
         Name nameRFC2253_5 = parser.parse( "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB" );
 
         assertEquals( "RFC2253_5 : ", "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB", ( ( LdapDN
) nameRFC2253_5 )
-            .toUpName() );
+            .getUpName() );
     }
 
 
@@ -426,7 +425,7 @@
 
         Name nameRFC2253_6 = parser.parse( "SN=Lu\\C4\\8Di\\C4\\87" );
 
-        assertEquals( "RFC2253_6 : ", "SN=Lu\\C4\\8Di\\C4\\87", ( ( LdapDN ) nameRFC2253_6
).toUpName() );
+        assertEquals( "RFC2253_6 : ", "SN=Lu\\C4\\8Di\\C4\\87", ( ( LdapDN ) nameRFC2253_6
).getUpName() );
     }
 
 
@@ -476,7 +475,7 @@
         String path = "windowsFilePath=C:\\\\cygwin";
         NameParser parser = LdapDnParser.getNameParser();
         Name result = parser.parse( path );
-        assertEquals( path, ( ( LdapDN ) result ).toUpName() );
+        assertEquals( path, ( ( LdapDN ) result ).getUpName() );
         assertEquals( "windowsfilepath=C:\\\\cygwin", result.toString() );
     }
 

Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java?rev=427793&r1=427792&r2=427793&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
(original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
Tue Aug  1 16:35:20 2006
@@ -100,7 +100,7 @@
     public SubtreeSpecificationParserTest()
     {
         super();
-        parser = new SubtreeSpecificationParser();
+        parser = new SubtreeSpecificationParser( null );
     }
 
 
@@ -110,7 +110,7 @@
     public SubtreeSpecificationParserTest(String s)
     {
         super( s );
-        parser = new SubtreeSpecificationParser();
+        parser = new SubtreeSpecificationParser( null );
     }
 
 

Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java?rev=427793&r1=427792&r2=427793&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java
(original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java
Tue Aug  1 16:35:20 2006
@@ -187,7 +187,7 @@
             || "elem2 = '[name2, 2]', elem1 = '[name1, 1]', elem3 = '[name3, 3]'".equals(
result )
             || "elem2 = '[name2, 2]', elem3 = '[name3, 3]', elem1 = '[name1, 1]'".equals(
result )
             || "elem3 = '[name3, 3]', elem1 = '[name1, 1]', elem2 = '[name2, 2]'".equals(
result )
-            || "elem3 = '[name3, 3]', elem3 = '[name2, 2]', elem1 = '[name1, 1]'".equals(
result );
+            || "elem3 = '[name3, 3]', elem2 = '[name2, 2]', elem1 = '[name1, 1]'".equals(
result );
 
         Assert.assertTrue( res );
     }
@@ -279,5 +279,38 @@
         assertEquals( "a b", StringTools.deepTrim( "a  b", false ) );
         assertEquals( "a b", StringTools.deepTrim( " a b", false ) );
         assertEquals( "a b", StringTools.deepTrim( "a b ", false ) );
+    }
+
+    public void testTrim()
+    {
+        assertEquals( "", StringTools.trim( (String)null ) );
+        assertEquals( "", StringTools.trim( "" ) );
+        assertEquals( "", StringTools.trim( " " ) );
+        assertEquals( "", StringTools.trim( "  " ) );
+        assertEquals( "a", StringTools.trim( "a  " ) );
+        assertEquals( "a", StringTools.trim( "  a" ) );
+        assertEquals( "a", StringTools.trim( "  a  " ) );
+    }
+
+    public void testTrimLeft()
+    {
+        assertEquals( "", StringTools.trimLeft( (String)null ) );
+        assertEquals( "", StringTools.trimLeft( "" ) );
+        assertEquals( "", StringTools.trimLeft( " " ) );
+        assertEquals( "", StringTools.trimLeft( "  " ) );
+        assertEquals( "a  ", StringTools.trimLeft( "a  " ) );
+        assertEquals( "a", StringTools.trimLeft( "  a" ) );
+        assertEquals( "a  ", StringTools.trimLeft( "  a  " ) );
+    }
+
+    public void testTrimRight()
+    {
+        assertEquals( "", StringTools.trimRight( (String)null ) );
+        assertEquals( "", StringTools.trimRight( "" ) );
+        assertEquals( "", StringTools.trimRight( " " ) );
+        assertEquals( "", StringTools.trimRight( "  " ) );
+        assertEquals( "a", StringTools.trimRight( "a  " ) );
+        assertEquals( "  a", StringTools.trimRight( "  a" ) );
+        assertEquals( "  a", StringTools.trimRight( "  a  " ) );
     }
 }



Mime
View raw message