You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/07/31 20:46:56 UTC
svn commit: r427201 [2/2] - in
/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap:
aci/ codec/search/ ldif/ message/ name/ subtree/ util/
Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java?rev=427201&r1=427200&r2=427201&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java Mon Jul 31 11:46:55 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,15 +40,18 @@
public class LdifReaderTest extends TestCase
{
private byte[] data;
-
+
+ private static File HJENSEN_JPEG_FILE = null;
+ private static File FIONA_JPEG_FILE = null;
+
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 = File.createTempFile( name, "jpg" );
-
- jpeg.createNewFile();
+
+ jpeg.createNewFile();
DataOutputStream os = new DataOutputStream( new FileOutputStream( jpeg ) );
@@ -121,7 +137,7 @@
" is is still a comment\n" +
"\n" +
"version:\n" +
- " 1\n" +
+ " 1\n" +
"# end";
LdifReader reader = new LdifReader();
@@ -470,7 +486,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" ) );
@@ -513,7 +529,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" ) );
@@ -774,11 +790,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" +
@@ -813,12 +831,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" +
@@ -833,16 +850,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" },
@@ -850,19 +868,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" },
Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributesImplTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributesImplTest.java?rev=427201&r1=427200&r2=427201&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributesImplTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributesImplTest.java Mon Jul 31 11:46:55 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/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=427201&r1=427200&r2=427201&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java Mon Jul 31 11:46:55 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/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java?rev=427201&r1=427200&r2=427201&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java Mon Jul 31 11:46:55 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/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java?rev=427201&r1=427200&r2=427201&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java Mon Jul 31 11:46:55 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/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java?rev=427201&r1=427200&r2=427201&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java Mon Jul 31 11:46:55 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 );
}
@@ -280,4 +280,37 @@
assertEquals( "a b", StringTools.deepTrim( " a b", false ) );
assertEquals( "a b", StringTools.deepTrim( "a b ", false ) );
}
-}
\ No newline at end of file
+
+ 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 " ) );
+ }
+}