directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r546145 - in /directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core: exception/ExceptionServiceITest.java jndi/CreateContextITest.java
Date Mon, 11 Jun 2007 13:30:07 GMT
Author: elecharny
Date: Mon Jun 11 06:30:06 2007
New Revision: 546145

URL: http://svn.apache.org/viewvc?view=rev&rev=546145
Log:
Fixed a bug in createSubContext( name ) : the JavaContainer ObjectClass was added
but overloaded by the 'top' objectClass
Added three tests in CreateContextITest
Fixed ExceptionServiceITest to handle the correct exception

Modified:
    directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceITest.java
    directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java

Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceITest.java?view=diff&rev=546145&r1=546144&r2=546145
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceITest.java
(original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceITest.java
Mon Jun 11 06:30:06 2007
@@ -34,6 +34,7 @@
 import org.apache.directory.shared.ldap.exception.LdapNameAlreadyBoundException;
 import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
+import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
@@ -445,10 +446,9 @@
             sysRoot.createSubcontext( "ou=blah,cn=toanother" );
             fail( "Execution should never get here due to exception!" );
         }
-        catch ( LdapNamingException e )
+        catch ( LdapSchemaViolationException e )
         {
-            assertEquals( "cn=toanother,ou=system", e.getResolvedName().toString() );
-            assertEquals( ResultCodeEnum.ALIAS_PROBLEM, e.getResultCode() );
+            assertEquals( ResultCodeEnum.OBJECT_CLASS_VIOLATION, e.getResultCode() );
         }
     }
 
@@ -464,10 +464,9 @@
             sysRoot.createSubcontext( "ou=blah,ou=abc" );
             fail( "Execution should never get here due to exception!" );
         }
-        catch ( LdapNameNotFoundException e )
+        catch ( LdapSchemaViolationException e )
         {
-            assertEquals( "ou=system", e.getResolvedName().toString() );
-            assertEquals( ResultCodeEnum.NO_SUCH_OBJECT, e.getResultCode() );
+            assertEquals( ResultCodeEnum.OBJECT_CLASS_VIOLATION, e.getResultCode() );
         }
     }
 

Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java?view=diff&rev=546145&r1=546144&r2=546145
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java
(original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/jndi/CreateContextITest.java
Mon Jun 11 06:30:06 2007
@@ -33,6 +33,7 @@
 import javax.naming.directory.SearchResult;
 
 import org.apache.directory.server.core.unit.AbstractAdminTestCase;
+import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 
@@ -362,5 +363,48 @@
         assertNotNull( attribute );
         assertTrue( attribute.contains( "top" ) );
         assertTrue( attribute.contains( "organizationalUnit" ) );
+    }
+
+    public void testCreateContextWithNoObjectClass() throws Exception
+    {
+        Attributes attrs = new AttributesImpl( true );
+
+        try
+        {
+            sysRoot.createSubcontext( "ou=subtest", attrs );// should Fails!
+            fail( "It is not allowed to create a context with a bad entry");
+        }
+        catch ( NamingException e )
+        {
+            assertNotNull( e );
+        }
+    }
+
+    public void testCreateJavaContainer() throws Exception
+    {
+        DirContext ctx = (DirContext)sysRoot.createSubcontext( "cn=subtest" );
+        assertNotNull( ctx );
+        
+        Attributes attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        
+        assertEquals( "subtest", attributes.get( "cn" ).get() );
+        Attribute attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "javaContainer" ) );
+    }
+    
+    public void testCreateJavaContainerBadRDN() throws Exception
+    {
+        try
+        {
+            sysRoot.createSubcontext( "ou=subtest" );
+            fail( "It is not allowed to create a context with a bad RDN. CN is mandatory");
+        }
+        catch ( LdapSchemaViolationException ne )
+        {
+            assertTrue( true );
+        }
     }
 }



Mime
View raw message