directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r662535 - /directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
Date Mon, 02 Jun 2008 19:50:34 GMT
Author: seelmann
Date: Mon Jun  2 12:50:34 2008
New Revision: 662535

URL: http://svn.apache.org/viewvc?rev=662535&view=rev
Log:
Added generics and for-each loop

Modified:
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java?rev=662535&r1=662534&r2=662535&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParserTest.java
Mon Jun  2 12:50:34 2008
@@ -65,9 +65,9 @@
             + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.25 )";
 
         parser.parse( attributeTypeData );
-        List attributeTypeList = parser.getAttributeTypes();
-        Map attributeTypes = mapAttributeTypes( attributeTypeList );
-        AttributeTypeLiteral type = ( AttributeTypeLiteral ) attributeTypes.get( "2.5.4.14"
);
+        List<AttributeTypeLiteral> attributeTypeList = parser.getAttributeTypes();
+        Map<String, AttributeTypeLiteral> attributeTypes = mapAttributeTypes( attributeTypeList
);
+        AttributeTypeLiteral type = attributeTypes.get( "2.5.4.14" );
 
         assertNotNull( type );
         assertEquals( "2.5.4.14", type.getOid() );
@@ -77,13 +77,12 @@
     }
 
 
-    private Map mapAttributeTypes( List attributeTypeList )
+    private Map<String, AttributeTypeLiteral> mapAttributeTypes( List<AttributeTypeLiteral>
attributeTypeList )
     {
-        Map m = new HashMap();
+        Map<String, AttributeTypeLiteral> m = new HashMap<String, AttributeTypeLiteral>();
         
-        for ( int ii = 0 ; ii < attributeTypeList.size(); ii++ )
+        for ( AttributeTypeLiteral type : attributeTypeList )
         {
-            AttributeTypeLiteral type = ( AttributeTypeLiteral ) attributeTypeList.get( ii
);
             m.put( type.getOid(), type );
         }
         
@@ -97,9 +96,9 @@
             + "        DESC 'RFC2256: knowledge information'\n" + "        EQUALITY caseIgnoreMatch\n"
             + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
         parser.parse( attributeTypeData );
-        List attributeTypeList = parser.getAttributeTypes();
-        Map attributeTypes = mapAttributeTypes( attributeTypeList );
-        AttributeTypeLiteral type = ( AttributeTypeLiteral ) attributeTypes.get( "2.5.4.2"
);
+        List<AttributeTypeLiteral> attributeTypeList = parser.getAttributeTypes();
+        Map<String, AttributeTypeLiteral> attributeTypes = mapAttributeTypes( attributeTypeList
);
+        AttributeTypeLiteral type = attributeTypes.get( "2.5.4.2" );
 
         assertNotNull( type );
         assertEquals( "2.5.4.2", type.getOid() );
@@ -116,9 +115,9 @@
             + "        DESC 'RFC2256: \"knowledge\" information'\n" + "        EQUALITY caseIgnoreMatch\n"
             + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
         parser.parse( attributeTypeData );
-        List attributeTypeList = parser.getAttributeTypes();
-        Map attributeTypes = mapAttributeTypes( attributeTypeList );
-        AttributeTypeLiteral type = ( AttributeTypeLiteral ) attributeTypes.get( "2.5.4.2"
);
+        List<AttributeTypeLiteral> attributeTypeList = parser.getAttributeTypes();
+        Map<String, AttributeTypeLiteral> attributeTypes = mapAttributeTypes( attributeTypeList
);
+        AttributeTypeLiteral type = attributeTypes.get( "2.5.4.2" );
 
         assertNotNull( type );
         assertEquals( "2.5.4.2", type.getOid() );
@@ -136,9 +135,9 @@
             + "        DESC 'RFC2256: knowledge information'\n" + "        EQUALITY caseIgnoreMatch\n"
             + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
         parser.parse( attributeTypeData );
-        List attributeTypeList = parser.getAttributeTypes();
-        Map attributeTypes = mapAttributeTypes( attributeTypeList );
-        AttributeTypeLiteral type = ( AttributeTypeLiteral ) attributeTypes.get( "2.5.4.2"
);
+        List<AttributeTypeLiteral> attributeTypeList = parser.getAttributeTypes();
+        Map<String, AttributeTypeLiteral> attributeTypes = mapAttributeTypes( attributeTypeList
);
+        AttributeTypeLiteral type = attributeTypes.get( "2.5.4.2" );
 
         assertNotNull( type );
         assertEquals( "2.5.4.2", type.getOid() );
@@ -149,14 +148,13 @@
     }
 
 
-    private Map mapObjectClasses( List attributeTypeList )
+    private Map<String, ObjectClassLiteral> mapObjectClasses( List<ObjectClassLiteral>
objectClassList )
     {
-        Map m = new HashMap();
+        Map<String, ObjectClassLiteral> m = new HashMap<String, ObjectClassLiteral>();
         
-        for ( int ii = 0 ; ii < attributeTypeList.size(); ii++ )
+        for ( ObjectClassLiteral objectClassLiteral : objectClassList )
         {
-            ObjectClassLiteral type = ( ObjectClassLiteral ) attributeTypeList.get( ii );
-            m.put( type.getOid(), type );
+            m.put( objectClassLiteral.getOid(), objectClassLiteral );
         }
         
         return m;
@@ -169,9 +167,9 @@
             + "        SUP top STRUCTURAL\n" + "        MUST ( sn $ cn )\n"
             + "        MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )";
         parser.parse( objectClassData );
-        List objectClassesList = parser.getObjectClassTypes();
-        Map objectClasses = mapObjectClasses( objectClassesList );
-        ObjectClassLiteral objectClass = ( ObjectClassLiteral ) objectClasses.get( "2.5.6.6"
);
+        List<ObjectClassLiteral> objectClassesList = parser.getObjectClassTypes();
+        Map<String, ObjectClassLiteral> objectClasses = mapObjectClasses( objectClassesList
);
+        ObjectClassLiteral objectClass = objectClasses.get( "2.5.6.6" );
 
         assertNotNull( objectClass );
         assertEquals( "2.5.6.6", objectClass.getOid() );
@@ -199,9 +197,9 @@
             + "\t\tpagerTelephoneNumber $ organizationalStatus $\n"
             + "\t\tmailPreferenceOption $ personalSignature )\n" + "\t)";
         parser.parse( objectClassData );
-        List objectClassesList = parser.getObjectClassTypes();
-        Map objectClasses = mapObjectClasses( objectClassesList );
-        ObjectClassLiteral objectClass = ( ObjectClassLiteral ) objectClasses.get( "0.9.2342.19200300.100.4.4"
);
+        List<ObjectClassLiteral> objectClassesList = parser.getObjectClassTypes();
+        Map<String, ObjectClassLiteral> objectClasses = mapObjectClasses( objectClassesList
);
+        ObjectClassLiteral objectClass = objectClasses.get( "0.9.2342.19200300.100.4.4" );
 
         assertNotNull( objectClass );
         assertEquals( "0.9.2342.19200300.100.4.4", objectClass.getOid() );
@@ -229,6 +227,6 @@
         assertEquals( "organizationalStatus", objectClass.getMay()[16] );
         assertEquals( "mailPreferenceOption", objectClass.getMay()[17] );
         assertEquals( "personalSignature", objectClass.getMay()[18] );
-
     }
+
 }



Mime
View raw message