directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r807104 - in /directory/shared/branches/shared-schema/ldap/src: main/antlr/ main/java/org/apache/directory/shared/ldap/schema/ test/java/org/apache/directory/shared/ldap/schema/syntax/parser/
Date Mon, 24 Aug 2009 07:14:17 GMT
Author: elecharny
Date: Mon Aug 24 07:14:16 2009
New Revision: 807104

URL: http://svn.apache.org/viewvc?rev=807104&view=rev
Log:
o Fixed the LdapSyntax parser to get the real OID
o Fixed the parser tests, as the names are now case insensitives
o The extensions are now initialized in the SchemaObject constructor
o Other minor fixes

Modified:
    directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
    directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java
    directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java
    directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java

Modified: directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g?rev=807104&r1=807103&r2=807104&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g Mon Aug 24 07:14:16
2009
@@ -482,7 +482,7 @@
         ElementTracker et = new ElementTracker();
     }
     :
-    ( oid:STARTNUMERICOID { lsd = new LdapSyntaxDescription(oid.getText()); } )
+    ( oid:STARTNUMERICOID { lsd = new LdapSyntaxDescription(numericoid(oid.getText())); }
)
     (
         ( name:NAME { et.track("NAME", name); lsd.setNames(qdescrs(name.getText())); } )
         |

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java?rev=807104&r1=807103&r2=807104&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
Mon Aug 24 07:14:16 2009
@@ -91,7 +91,7 @@
     //private final NormalizerRegistry normalizerRegistry;
     
     /** The associated Comparator */
-    private LdapComparator<?> ldapComparator;
+    private LdapComparator<? super Object> ldapComparator;
 
     /** The associated Normalizer */
     private Normalizer normalizer;
@@ -116,7 +116,7 @@
         try
         {
             // Gets the associated C 
-            ldapComparator = registries.getComparatorRegistry().lookup( oid );
+            ldapComparator = (LdapComparator<? super Object>)registries.getComparatorRegistry().lookup(
oid );
 
             // Gets the associated N 
             normalizer = registries.getNormalizerRegistry().lookup( oid );
@@ -150,7 +150,7 @@
      * @return the ordering LdapComparator
      * @throws NamingException if there is a failure resolving the object
      */
-    public LdapComparator<?> getLdapComparator() throws NamingException
+    public LdapComparator<? super Object> getLdapComparator() throws NamingException
     {
         return ldapComparator;
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java?rev=807104&r1=807103&r2=807104&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
Mon Aug 24 07:14:16 2009
@@ -111,6 +111,7 @@
         this.oid = oid;
         isEnabled = true;
         isReadOnly = false;
+        extensions = new HashMap<String, List<String>>();
     }
     
     
@@ -350,11 +351,6 @@
     {
         if ( !isReadOnly )
         {
-            if ( extensions == null )
-            {
-                extensions = new HashMap<String, List<String>>();
-            }
-            
             extensions.put( key, values );
         }
     }
@@ -459,20 +455,17 @@
         }
         
         // The extensions, if any
-        if ( extensions != null )
+        for ( String key : extensions.keySet() )
         {
-            for ( String key : extensions.keySet() )
+            h += h*17 + key.hashCode();
+            
+            List<String> values = extensions.get( key );
+            
+            if ( values != null )
             {
-                h += h*17 + key.hashCode();
-                
-                List<String> values = extensions.get( key );
-                
-                if ( values != null )
+                for ( String value:values )
                 {
-                    for ( String value:values )
-                    {
-                        h += h*17 + value.hashCode();
-                    }
+                    h += h*17 + value.hashCode();
                 }
             }
         }

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java?rev=807104&r1=807103&r2=807104&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java
Mon Aug 24 07:14:16 2009
@@ -171,9 +171,9 @@
         value = "( 1.2.3.4.5.6.7.8.9.0 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789'
'test' ) DESC 'Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577' OBSOLETE SYNTAX 0.1.2.3.4.5.6.7.8.9
X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )";
         mrd = parser.parseMatchingRuleDescription( value );
 
-        assertEquals( "1.2.3.4.5.6.7.8.9.0", mrd.getNumericOid() );
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", mrd.getOid() );
         assertEquals( 2, mrd.getNames().size() );
-        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789",
mrd.getNames().get( 0 ) );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-0123456789",
mrd.getNames().get( 0 ) );
         assertEquals( "test", mrd.getNames().get( 1 ) );
         assertEquals( "Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577", mrd.getDescription()
);
         assertTrue( mrd.isObsolete() );
@@ -247,9 +247,9 @@
         String value = "( 2.5.13.5 NAME 'caseExactMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
)";
         MatchingRuleDescription mrd = parser.parseMatchingRuleDescription( value );
 
-        assertEquals( "2.5.13.5", mrd.getNumericOid() );
+        assertEquals( "2.5.13.5", mrd.getOid() );
         assertEquals( 1, mrd.getNames().size() );
-        assertEquals( "caseExactMatch", mrd.getNames().get( 0 ) );
+        assertEquals( "caseexactmatch", mrd.getNames().get( 0 ) );
         assertNull( mrd.getDescription() );
         assertFalse( mrd.isObsolete() );
         assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", mrd.getSyntax() );
@@ -263,9 +263,9 @@
         String value = "( 2.5.13.5 NAME 'caseExactMatch' DESC 'Case Exact Matching on Directory
String [defined in X.520]' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )";
         MatchingRuleDescription mrd = parser.parseMatchingRuleDescription( value );
 
-        assertEquals( "2.5.13.5", mrd.getNumericOid() );
+        assertEquals( "2.5.13.5", mrd.getOid() );
         assertEquals( 1, mrd.getNames().size() );
-        assertEquals( "caseExactMatch", mrd.getNames().get( 0 ) );
+        assertEquals( "caseexactmatch", mrd.getNames().get( 0 ) );
         assertEquals( "Case Exact Matching on Directory String [defined in X.520]", mrd.getDescription()
);
         assertFalse( mrd.isObsolete() );
         assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", mrd.getSyntax() );
@@ -296,9 +296,9 @@
         else
         {
             MatchingRuleDescription mrd = parser.parseMatchingRuleDescription( value );
-            assertEquals( "1.3.6.1.4.1.42.2.27.9.4.34.3.6", mrd.getNumericOid() );
+            assertEquals( "1.3.6.1.4.1.42.2.27.9.4.34.3.6", mrd.getOid() );
             assertEquals( 1, mrd.getNames().size() );
-            assertEquals( "caseExactSubstringMatch-2.16.840.1.113730.3.3.2.11.3", mrd.getNames().get(
0 ) );
+            assertEquals( "caseexactsubstringmatch-2.16.840.1.113730.3.3.2.11.3", mrd.getNames().get(
0 ) );
             assertEquals( "en", mrd.getDescription() );
             assertFalse( mrd.isObsolete() );
             assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", mrd.getSyntax() );

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java?rev=807104&r1=807103&r2=807104&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java
Mon Aug 24 07:14:16 2009
@@ -31,6 +31,7 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertNotNull;
 
 
@@ -258,9 +259,9 @@
         value = "( 1.2.3.4.5.6.7.8.9.0 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789'
'test' ) DESC 'Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577' OBSOLETE APPLIES ( 0.1.2.3.4.5.6.7.8.9
$ abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 ) X-TEST-a ('test1-1' 'test1-2')
X-TEST-b ('test2-1' 'test2-2') )";
         mrud = parser.parseMatchingRuleUseDescription( value );
 
-        assertEquals( "1.2.3.4.5.6.7.8.9.0", mrud.getNumericOid() );
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", mrud.getOid() );
         assertEquals( 2, mrud.getNames().size() );
-        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789",
mrud.getNames().get( 0 ) );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-0123456789",
mrud.getNames().get( 0 ) );
         assertEquals( "test", mrud.getNames().get( 1 ) );
         assertEquals( "Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577", mrud.getDescription()
);
         assertTrue( mrud.isObsolete() );
@@ -337,10 +338,10 @@
         String value = "( 2.5.13.17 NAME 'octetStringMatch' APPLIES ( javaSerializedData
$ userPassword ) )";
         MatchingRuleUseDescription mrud = parser.parseMatchingRuleUseDescription( value );
 
-        assertEquals( "2.5.13.17", mrud.getNumericOid() );
+        assertEquals( "2.5.13.17", mrud.getOid() );
         assertEquals( 1, mrud.getNames().size() );
-        assertEquals( "octetStringMatch", mrud.getNames().get( 0 ) );
-        assertEquals( "", mrud.getDescription() );
+        assertEquals( "octetstringmatch", mrud.getNames().get( 0 ) );
+        assertNull( mrud.getDescription() );
         assertFalse( mrud.isObsolete() );
         assertEquals( 2, mrud.getApplicableAttributes().size() );
         assertEquals( "javaSerializedData", mrud.getApplicableAttributes().get( 0 ) );

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java?rev=807104&r1=807103&r2=807104&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java
Mon Aug 24 07:14:16 2009
@@ -24,7 +24,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import static junit.framework.Assert.assertNull;
 import static junit.framework.Assert.fail;
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNotNull;
@@ -33,7 +32,6 @@
 
 import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.parsers.AbstractSchemaParser;
-import org.junit.Test;
 
 
 /**
@@ -218,14 +216,14 @@
         value = "( " + oid + " " + required + " NAME 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
)";
         asd = parser.parse( value );
         assertEquals( 1, asd.getNames().size() );
-        assertEquals( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", asd.getNames().get(
0 ) );
+        assertEquals( "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", asd.getNames().get(
0 ) );
 
         // alpha-num-hypen
         value = "( " + oid + " " + required
             + " NAME 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' )";
         asd = parser.parse( value );
         assertEquals( 1, asd.getNames().size() );
-        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789",
asd.getNames().get( 0 ) );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-0123456789",
asd.getNames().get( 0 ) );
 
         // with parentheses
         value = "( " + oid + " " + required + " NAME ( 'a-z-0-9' ) )";
@@ -443,7 +441,7 @@
         // no extension
         value = "( " + oid + " " + required + " )";
         asd = parser.parse( value );
-        assertNull( asd.getExtensions() );
+        assertEquals( 0, asd.getExtensions().size() );
 
         // single extension with one value
         value = "( " + oid + " " + required + " X-TEST 'test' )";



Mime
View raw message