directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r543736 - /directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java
Date Sat, 02 Jun 2007 13:33:46 GMT
Author: elecharny
Date: Sat Jun  2 06:33:45 2007
New Revision: 543736

URL: http://svn.apache.org/viewvc?view=rev&rev=543736
Log:
Added some unit test to check that using BasicAttributes() with case sensitive 
attributeTypes is ok

Modified:
    directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java

Modified: directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java?view=diff&rev=543736&r1=543735&r2=543736
==============================================================================
--- directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java
(original)
+++ directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java
Sat Jun  2 06:33:45 2007
@@ -26,6 +26,8 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
@@ -257,5 +259,108 @@
 
         //sysRoot.createSubcontext(relativeName.toString(), attrs);//Passes!
         sysRoot.createSubcontext( relativeName, attrs );//Fails!
+    }
+
+    /**
+     * Tests the creation and subsequent read of a new JNDI context under the
+     * system context root.
+     *
+     * @throws javax.naming.NamingException if there are failures
+     */
+    public void testCreateContextWithBasicAttributesCaseSensitive() throws NamingException
+    {
+        /*
+         * create ou=testing00,ou=system
+         */
+        Attributes attributes = new BasicAttributes();
+        attributes.put("objectClass", "organizationalUnit");
+        attributes.put("description", "Test OU");
+        attributes.put("OU", "Test");
+        
+        DirContext ctx = sysRoot.createSubcontext( "ou=Test", attributes );
+        assertNotNull( ctx );
+
+        ctx = ( DirContext ) sysRoot.lookup( "ou=Test" );
+        assertNotNull( ctx );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "Test", attributes.get( "ou" ).get() );
+        assertEquals( "Test OU", attributes.get( "Description" ).get() );
+        Attribute attribute = attributes.get( "objectclass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         * create ou=testing01,ou=system
+         */
+        attributes = new BasicAttributes();
+        attribute = new BasicAttribute( "objectClass" );
+        attribute.add( "top" );
+        attribute.add( "organizationalUnit" );
+        attributes.put( attribute );
+        attributes.put( "ou", "testing01" );
+        ctx = sysRoot.createSubcontext( "ou=testing01", attributes );
+        assertNotNull( ctx );
+
+        ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" );
+        assertNotNull( ctx );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing01", attributes.get( "ou" ).get() );
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         * create ou=testing02,ou=system
+         */
+        attributes = new BasicAttributes();
+        attribute = new BasicAttribute( "objectClass" );
+        attribute.add( "top" );
+        attribute.add( "organizationalUnit" );
+        attributes.put( attribute );
+        attributes.put( "ou", "testing02" );
+        ctx = sysRoot.createSubcontext( "ou=testing02", attributes );
+        assertNotNull( ctx );
+
+        ctx = ( DirContext ) sysRoot.lookup( "ou=testing02" );
+        assertNotNull( ctx );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing02", attributes.get( "ou" ).get() );
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         * create ou=subtest,ou=testing01,ou=system
+         */
+        ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" );
+
+        attributes = new BasicAttributes();
+        attribute = new BasicAttribute( "objectClass" );
+        attribute.add( "top" );
+        attribute.add( "organizationalUnit" );
+        attributes.put( attribute );
+        attributes.put( "ou", "subtest" );
+        ctx = ctx.createSubcontext( "ou=subtest", attributes );
+        assertNotNull( ctx );
+
+        ctx = ( DirContext ) sysRoot.lookup( "ou=subtest,ou=testing01" );
+        assertNotNull( ctx );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "subtest", attributes.get( "ou" ).get() );
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
     }
 }



Mime
View raw message