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 2010/10/18 11:31:09 UTC

svn commit: r1023705 - /directory/shared/branches/shared-config/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java

Author: elecharny
Date: Mon Oct 18 09:31:09 2010
New Revision: 1023705

URL: http://svn.apache.org/viewvc?rev=1023705&view=rev
Log:
Added a test to prove that extensions are correctly handled

Modified:
    directory/shared/branches/shared-config/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java

Modified: directory/shared/branches/shared-config/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-config/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java?rev=1023705&r1=1023704&r2=1023705&view=diff
==============================================================================
--- directory/shared/branches/shared-config/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java (original)
+++ directory/shared/branches/shared-config/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java Mon Oct 18 09:31:09 2010
@@ -20,6 +20,11 @@
 package org.apache.directory.shared.ldap.schema.parser;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.InputStream;
 import java.util.HashMap;
 import java.util.List;
@@ -37,11 +42,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 
 /**
  * Tests the OpenLDAP schema parser.
@@ -201,6 +201,51 @@ public class OpenLdapSchemaParserTest
     }
 
 
+
+
+    @Test
+    public void testObjectClassWithExtensionsParse() throws Exception
+    {
+        String objectClassData = "objectclass ( 2.5.6.6 NAME 'person'\n" 
+            + "        DESC 'RFC2256: a person'\n"
+            + "        SUP top STRUCTURAL\n" 
+            + "        MUST ( sn $ cn )\n"
+            + "        MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) \n"
+            + "        X-extension 'test' X-otherExtension ( 'test1' 'test2' ) )";
+        parser.parse( objectClassData );
+        List<ObjectClass> objectClassesList = parser.getObjectClassTypes();
+        Map<String, ObjectClass> objectClasses = mapObjectClasses( objectClassesList );
+        ObjectClass objectClass = objectClasses.get( "2.5.6.6" );
+
+        assertNotNull( objectClass );
+        assertEquals( "2.5.6.6", objectClass.getOid() );
+        assertEquals( "person", objectClass.getName() );
+        assertEquals( "RFC2256: a person", objectClass.getDescription() );
+        assertEquals( ObjectClassTypeEnum.STRUCTURAL, objectClass.getType() );
+        assertEquals( "sn", objectClass.getMustAttributeTypeOids().get(0) );
+        assertEquals( "cn", objectClass.getMustAttributeTypeOids().get(1) );
+        assertEquals( "userPassword", objectClass.getMayAttributeTypeOids().get(0) );
+        assertEquals( "telephoneNumber", objectClass.getMayAttributeTypeOids().get(1) );
+        assertEquals( "seeAlso", objectClass.getMayAttributeTypeOids().get(2) );
+        assertEquals( "description", objectClass.getMayAttributeTypeOids().get(3) );
+        Map<String, List<String>> extensions = objectClass.getExtensions();
+
+        assertNotNull( extensions );
+        
+        List<String> ext1 = extensions.get( "X-extension" );
+        assertNotNull( ext1 );
+        assertEquals( 1, ext1.size() );
+        assertTrue( ext1.contains( "test" ) );
+        
+        List<String> ext2 = extensions.get( "X-otherExtension" );
+        assertNotNull( ext2 );
+        assertEquals( 2, ext2.size() );
+        assertTrue( ext2.contains( "test1" ) );
+        assertTrue( ext2.contains( "test2" ) );
+        
+    }
+
+    
     @Test
     public void testObjectClassMultipleNames() throws Exception
     {