directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r418529 - /directory/branches/shared/optimization/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Date Sat, 01 Jul 2006 23:48:03 GMT
Author: elecharny
Date: Sat Jul  1 16:48:03 2006
New Revision: 418529

URL: http://svn.apache.org/viewvc?rev=418529&view=rev
Log:
Added tests for DIRSERVER-191

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=418529&r1=418528&r2=418529&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  1 16:48:03 2006
@@ -33,6 +33,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;
@@ -2255,5 +2257,177 @@
             "2.5.4.11=some people+domainComponent=and some animals,DomainComponent=example,0.9.2342.19200300.100.1.25=com"
);
 
         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());
+        }
     }
 }



Mime
View raw message