directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r808063 - in /directory/shared/branches/shared-schema/ldap/src: main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
Date Wed, 26 Aug 2009 15:49:44 GMT
Author: elecharny
Date: Wed Aug 26 15:49:44 2009
New Revision: 808063

URL: http://svn.apache.org/viewvc?rev=808063&view=rev
Log:
Fixed the OpenLdapSchema parser and tests

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

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java?rev=808063&r1=808062&r2=808063&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/OpenLdapSchemaParser.java
Wed Aug 26 15:49:44 2009
@@ -32,6 +32,7 @@
 import java.util.Map;
 
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.syntaxChecker.OpenLdapObjectIdentifierMacro;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
@@ -55,8 +56,8 @@
     /** The list of attribute type, initialized by splitParsedSchemaDescriptions() */
     private List<AttributeType> attributeTypes;
 
-    /** The list of object class literals, initialized by splitParsedSchemaDescriptions()*/
-    private List<ObjectClassLiteral> objectClassLiterals;
+    /** The list of object classes, initialized by splitParsedSchemaDescriptions()*/
+    private List<ObjectClass> objectClasses;
 
     /** The map of object identifier macros, initialized by splitParsedSchemaDescriptions()*/
     private Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros;
@@ -101,9 +102,9 @@
      * 
      * @return the object class types
      */
-    public List<ObjectClassLiteral> getObjectClassTypes()
+    public List<ObjectClass> getObjectClassTypes()
     {
-        return objectClassLiterals;
+        return objectClasses;
     }
 
 
@@ -126,7 +127,7 @@
      */
     private void afterParse() throws ParseException
     {
-        objectClassLiterals = new ArrayList<ObjectClassLiteral>();
+        objectClasses = new ArrayList<ObjectClass>();
         attributeTypes = new ArrayList<AttributeType>();
         objectIdentifierMacros = new HashMap<String, OpenLdapObjectIdentifierMacro>();
 
@@ -144,19 +145,11 @@
 
                 attributeTypes.add( attributeType );
             }
-            else if ( obj instanceof ObjectClassDescription )
+            else if ( obj instanceof ObjectClass )
             {
-                ObjectClassDescription ocd = ( ObjectClassDescription ) obj;
-                ObjectClassLiteral literal = new ObjectClassLiteral( ocd.getNumericOid()
);
-                literal.setNames( ocd.getNames().toArray( new String[ocd.getNames().size()]
) );
-                literal.setDescription( ocd.getDescription() );
-                literal.setSuperiors( ocd.getSuperiorObjectClasses().toArray(
-                    new String[ocd.getSuperiorObjectClasses().size()] ) );
-                literal.setMay( ocd.getMayAttributeTypes().toArray( new String[ocd.getMayAttributeTypes().size()]
) );
-                literal.setMust( ocd.getMustAttributeTypes().toArray( new String[ocd.getMustAttributeTypes().size()]
) );
-                literal.setClassType( ocd.getKind() );
-                literal.setObsolete( ocd.isObsolete() );
-                objectClassLiterals.add( literal );
+                ObjectClass objectClass = ( ObjectClass ) obj;
+
+                objectClasses.add( objectClass );
             }
         }
 
@@ -169,9 +162,9 @@
             }
 
             // apply object identifier macros to object classes
-            for ( ObjectClassLiteral ocl : objectClassLiterals )
+            for ( ObjectClass objectClass : objectClasses )
             {
-                ocl.setOid( getResolveOid( ocl.getOid() ) );
+                objectClass.changeOid( getResolveOid( objectClass.getOid() ) );
             }
             
             // apply object identifier macros to attribute types
@@ -263,7 +256,7 @@
         {
             for ( Object obj : schemaDescriptions )
             {
-                if ( obj instanceof AbstractSchemaDescription )
+                if ( obj instanceof SchemaObject )
                 {
                     return ( SchemaObject ) obj;
                 }

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java?rev=808063&r1=808062&r2=808063&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
Wed Aug 26 15:49:44 2009
@@ -21,14 +21,13 @@
 
 
 import java.io.InputStream;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
-import org.apache.directory.shared.ldap.schema.parsers.ObjectClassLiteral;
 import org.apache.directory.shared.ldap.schema.parsers.OpenLdapSchemaParser;
 import org.apache.directory.shared.ldap.schema.syntaxChecker.OpenLdapObjectIdentifierMacro;
 import org.junit.After;
@@ -160,13 +159,13 @@
     }
 
 
-    private Map<String, ObjectClassLiteral> mapObjectClasses( List<ObjectClassLiteral>
objectClassList )
+    private Map<String, ObjectClass> mapObjectClasses( List<ObjectClass> objectClassList
)
     {
-        Map<String, ObjectClassLiteral> m = new HashMap<String, ObjectClassLiteral>();
+        Map<String, ObjectClass> m = new HashMap<String, ObjectClass>();
 
-        for ( ObjectClassLiteral objectClassLiteral : objectClassList )
+        for ( ObjectClass objectClass : objectClassList )
         {
-            m.put( objectClassLiteral.getOid(), objectClassLiteral );
+            m.put( objectClass.getOid(), objectClass );
         }
 
         return m;
@@ -180,21 +179,21 @@
             + "        SUP top STRUCTURAL\n" + "        MUST ( sn $ cn )\n"
             + "        MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )";
         parser.parse( objectClassData );
-        List<ObjectClassLiteral> objectClassesList = parser.getObjectClassTypes();
-        Map<String, ObjectClassLiteral> objectClasses = mapObjectClasses( objectClassesList
);
-        ObjectClassLiteral objectClass = objectClasses.get( "2.5.6.6" );
+        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.getNames()[0] );
+        assertEquals( "person", objectClass.getName() );
         assertEquals( "RFC2256: a person", objectClass.getDescription() );
-        assertEquals( ObjectClassTypeEnum.STRUCTURAL, objectClass.getClassType() );
-        assertEquals( "sn", objectClass.getMust()[0] );
-        assertEquals( "cn", objectClass.getMust()[1] );
-        assertEquals( "userPassword", objectClass.getMay()[0] );
-        assertEquals( "telephoneNumber", objectClass.getMay()[1] );
-        assertEquals( "seeAlso", objectClass.getMay()[2] );
-        assertEquals( "description", objectClass.getMay()[3] );
+        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) );
     }
 
 
@@ -211,36 +210,36 @@
             + "\t\tpagerTelephoneNumber $ organizationalStatus $\n"
             + "\t\tmailPreferenceOption $ personalSignature )\n" + "\t)";
         parser.parse( objectClassData );
-        List<ObjectClassLiteral> objectClassesList = parser.getObjectClassTypes();
-        Map<String, ObjectClassLiteral> objectClasses = mapObjectClasses( objectClassesList
);
-        ObjectClassLiteral objectClass = objectClasses.get( "0.9.2342.19200300.100.4.4" );
+        List<ObjectClass> objectClassesList = parser.getObjectClassTypes();
+        Map<String, ObjectClass> objectClasses = mapObjectClasses( objectClassesList
);
+        ObjectClass objectClass = objectClasses.get( "0.9.2342.19200300.100.4.4" );
 
         assertNotNull( objectClass );
         assertEquals( "0.9.2342.19200300.100.4.4", objectClass.getOid() );
-        assertEquals( "pilotPerson", objectClass.getNames()[0] );
-        assertEquals( "newPilotPerson", objectClass.getNames()[1] );
-        assertEquals( ObjectClassTypeEnum.STRUCTURAL, objectClass.getClassType() );
-        assertEquals( "person", objectClass.getSuperiors()[0] );
-
-        assertEquals( "userid", objectClass.getMay()[0] );
-        assertEquals( "textEncodedORAddress", objectClass.getMay()[1] );
-        assertEquals( "rfc822Mailbox", objectClass.getMay()[2] );
-        assertEquals( "favouriteDrink", objectClass.getMay()[3] );
-        assertEquals( "roomNumber", objectClass.getMay()[4] );
-        assertEquals( "userClass", objectClass.getMay()[5] );
-        assertEquals( "homeTelephoneNumber", objectClass.getMay()[6] );
-        assertEquals( "homePostalAddress", objectClass.getMay()[7] );
-        assertEquals( "secretary", objectClass.getMay()[8] );
-        assertEquals( "personalTitle", objectClass.getMay()[9] );
-        assertEquals( "preferredDeliveryMethod", objectClass.getMay()[10] );
-        assertEquals( "businessCategory", objectClass.getMay()[11] );
-        assertEquals( "janetMailbox", objectClass.getMay()[12] );
-        assertEquals( "otherMailbox", objectClass.getMay()[13] );
-        assertEquals( "mobileTelephoneNumber", objectClass.getMay()[14] );
-        assertEquals( "pagerTelephoneNumber", objectClass.getMay()[15] );
-        assertEquals( "organizationalStatus", objectClass.getMay()[16] );
-        assertEquals( "mailPreferenceOption", objectClass.getMay()[17] );
-        assertEquals( "personalSignature", objectClass.getMay()[18] );
+        assertEquals( "pilotPerson", objectClass.getName() );
+        assertEquals( "newPilotPerson", objectClass.getNames().get(1) );
+        assertEquals( ObjectClassTypeEnum.STRUCTURAL, objectClass.getType() );
+        assertEquals( "person", objectClass.getSuperiorOids().get(0) );
+
+        assertEquals( "userid", objectClass.getMayAttributeTypeOids().get(0) );
+        assertEquals( "textEncodedORAddress", objectClass.getMayAttributeTypeOids().get(1)
);
+        assertEquals( "rfc822Mailbox", objectClass.getMayAttributeTypeOids().get(2) );
+        assertEquals( "favouriteDrink", objectClass.getMayAttributeTypeOids().get(3) );
+        assertEquals( "roomNumber", objectClass.getMayAttributeTypeOids().get(4) );
+        assertEquals( "userClass", objectClass.getMayAttributeTypeOids().get(5) );
+        assertEquals( "homeTelephoneNumber", objectClass.getMayAttributeTypeOids().get(6)
);
+        assertEquals( "homePostalAddress", objectClass.getMayAttributeTypeOids().get(7) );
+        assertEquals( "secretary", objectClass.getMayAttributeTypeOids().get(8) );
+        assertEquals( "personalTitle", objectClass.getMayAttributeTypeOids().get(9) );
+        assertEquals( "preferredDeliveryMethod", objectClass.getMayAttributeTypeOids().get(10)
);
+        assertEquals( "businessCategory", objectClass.getMayAttributeTypeOids().get(11) );
+        assertEquals( "janetMailbox", objectClass.getMayAttributeTypeOids().get(12) );
+        assertEquals( "otherMailbox", objectClass.getMayAttributeTypeOids().get(13) );
+        assertEquals( "mobileTelephoneNumber", objectClass.getMayAttributeTypeOids().get(14)
);
+        assertEquals( "pagerTelephoneNumber", objectClass.getMayAttributeTypeOids().get(15)
);
+        assertEquals( "organizationalStatus", objectClass.getMayAttributeTypeOids().get(16)
);
+        assertEquals( "mailPreferenceOption", objectClass.getMayAttributeTypeOids().get(17)
);
+        assertEquals( "personalSignature", objectClass.getMayAttributeTypeOids().get(18)
);
     }
 
 
@@ -251,7 +250,7 @@
         parser.parse( input );
 
         List<AttributeType> attributeTypes = parser.getAttributeTypes();
-        List<ObjectClassLiteral> objectClassTypes = parser.getObjectClassTypes();
+        List<ObjectClass> objectClassTypes = parser.getObjectClassTypes();
         Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
 
         assertEquals( 52, attributeTypes.size() );
@@ -267,7 +266,7 @@
         parser.parse( input );
 
         List<AttributeType> attributeTypes = parser.getAttributeTypes();
-        List<ObjectClassLiteral> objectClassTypes = parser.getObjectClassTypes();
+        List<ObjectClass> objectClassTypes = parser.getObjectClassTypes();
         Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
 
         assertEquals( 9, attributeTypes.size() );
@@ -283,7 +282,7 @@
         parser.parse( input );
 
         List<AttributeType> attributeTypes = parser.getAttributeTypes();
-        List<ObjectClassLiteral> objectClassTypes = parser.getObjectClassTypes();
+        List<ObjectClass> objectClassTypes = parser.getObjectClassTypes();
         Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
 
         assertEquals( 13, attributeTypes.size() );
@@ -303,7 +302,7 @@
         parser.parse( input );
 
         List<AttributeType> attributeTypes = parser.getAttributeTypes();
-        List<ObjectClassLiteral> objectClassTypes = parser.getObjectClassTypes();
+        List<ObjectClass> objectClassTypes = parser.getObjectClassTypes();
         Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
 
         assertEquals( 2, attributeTypes.size() );
@@ -319,16 +318,16 @@
         }
 
         // check that OIDs in attribute types and object classes are resolved
-        for ( ObjectClassLiteral objectClassLiteral : objectClassTypes )
+        for ( ObjectClass objectClass : objectClassTypes )
         {
-            List<String> asList = Arrays.asList( objectClassLiteral.getNames() );
+            List<String> asList = objectClass.getNames();
             if ( asList.contains( "groupOfURLs" ) )
             {
-                assertEquals( "2.16.840.1.113730.3.2.33", objectClassLiteral.getOid() );
+                assertEquals( "2.16.840.1.113730.3.2.33", objectClass.getOid() );
             }
             else if ( asList.contains( "dgIdentityAux" ) )
             {
-                assertEquals( "1.3.6.1.4.1.4203.666.11.8.2.1", objectClassLiteral.getOid()
);
+                assertEquals( "1.3.6.1.4.1.4203.666.11.8.2.1", objectClass.getOid() );
             }
             else
             {



Mime
View raw message