directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r663597 - in /directory/shared/trunk/ldap/src: main/antlr/ main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ test/java/org/apache/directory/shared/ldap/schema/syntax/parser/
Date Thu, 05 Jun 2008 12:52:50 GMT
Author: seelmann
Date: Thu Jun  5 05:52:49 2008
New Revision: 663597

URL: http://svn.apache.org/viewvc?rev=663597&view=rev
Log:
Fix for DIRSHARED-8: Added quirks mode for schema parsers that
  o allows non-numeric OIDs like 'nsAdminGroup-oid'
  o disables constraints like 'NO-USER-MODIFICATION requries operational USAGE'



Modified:
    directory/shared/trunk/ldap/src/main/antlr/schema-value.g
    directory/shared/trunk/ldap/src/main/antlr/schema.g
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParserTest.java

Modified: directory/shared/trunk/ldap/src/main/antlr/schema-value.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/schema-value.g?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/schema-value.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/schema-value.g Thu Jun  5 05:52:49 2008
@@ -63,25 +63,43 @@
 
 LPAR : '(' ;
 RPAR : ')' ;
+protected CHAR : 'a'..'z' ;
 protected LDIGIT : '1'..'9' ;
 protected DIGIT : '0'..'9' ; 
 protected NUMBER : DIGIT | ( LDIGIT (DIGIT)+ ) ;
 protected NUMBER2 : (DIGIT)+ ;
 protected NUMERICOID : NUMBER ( '.' NUMBER )+ ;
+protected HYPEN : '-';
+protected OTHER : '_' | ';' | '.';
+protected DESCR: CHAR ( CHAR | DIGIT | HYPEN )* ;
+protected QUIRKS_DESCR: ( CHAR | DIGIT | HYPEN | OTHER )+ ;
 
 QUOTE : '\'' ;
 DOLLAR : '$' ;
 LCURLY : '{' ;
 RCURLY : '}' ;
-DESCR : ( 'a'..'z' ) ( 'a'..'z' | '0'..'9' | '-' )* ;
 LEN : LCURLY n:NUMBER2 RCURLY { setText(n.getText()); } ;
 
-NUMBER_OR_NUMERICOID :
+
+DESCR_OR_QUIRKS_DESCR :
+    ( NUMERICOID QUIRKS_DESCR ) => QUIRKS_DESCR { $setType( QUIRKS_DESCR ); }
+    |
+    ( NUMBER QUIRKS_DESCR ) => QUIRKS_DESCR { $setType( QUIRKS_DESCR ); }
+    |
+    ( HYPEN QUIRKS_DESCR ) => QUIRKS_DESCR { $setType( QUIRKS_DESCR ); }
+    |
+    ( OTHER QUIRKS_DESCR ) => QUIRKS_DESCR { $setType( QUIRKS_DESCR ); }
+    |
+    ( DESCR QUIRKS_DESCR ) => QUIRKS_DESCR { $setType( QUIRKS_DESCR ); }
+    |
+    ( DESCR ) { $setType( DESCR ); }
+    |
     ( NUMBER '.' ) => NUMERICOID { $setType( NUMERICOID ); }
     |
     ( NUMBER ) { $setType( NUMBER ); }
     ;
 
+
 /**
  * An antlr generated schema parser. This is a sub-parser used to parse
  * numericoid, oid, oids, qdescr, qdescrs according to RFC4512.
@@ -140,6 +158,41 @@
 
 
     /**
+     * noidlen = numericoid [ LCURLY len RCURLY ]
+     * len = number
+     */
+quirksNoidlen returns [AntlrSchemaParser.NoidLen noidlen = new AntlrSchemaParser.NoidLen()]
+    {
+        matchedProduction( "AntlrSchemaValueParser.quirksNoidlen()" );
+    }
+    :
+    (
+        (WHSP)?
+        (
+            ( QUOTE q1:QUIRKS_DESCR { noidlen.noid = q1.getText(); } QUOTE )
+            |
+            ( q2:QUIRKS_DESCR { noidlen.noid = q2.getText(); } )
+            |
+            ( QUOTE d3:DESCR { noidlen.noid = d3.getText(); } QUOTE )
+            |
+            ( d4:DESCR { noidlen.noid = d4.getText(); } )
+            |
+            ( QUOTE n1:NUMERICOID { noidlen.noid = n1.getText(); } QUOTE  )
+            |
+            ( n2:NUMERICOID { noidlen.noid = n2.getText(); } )
+        )
+        (
+            l:LEN { noidlen.len = Integer.parseInt(l.getText()); }
+            (QUOTE)?
+            (WHSP)?
+            (RPAR)?
+        )?
+        
+    )
+    ;
+
+
+    /**
      * numericoid = number 1*( DOT number )
      */
 numericoid returns [String numericoid=null]
@@ -258,19 +311,90 @@
             qdescr=qdescr { qdescrs.add(qdescr); } 
         )
     |
-        ( 
+        (             
+        
             LPAR 
             qdescr=qdescr { qdescrs.add(qdescr); } 
             (options {greedy=true;} : WHSP)?
+            (DOLLAR)?
+            (options {greedy=true;} : WHSP)?
             (
                 qdescr=qdescr { qdescrs.add(qdescr); } 
                 (options {greedy=true;} : WHSP)?
+                (DOLLAR)?
+                (options {greedy=true;} : WHSP)?
+            )*
+            RPAR 
+        )
+    )
+    ;
+    
+    
+    
+    /**
+     * qdescr = SQUOTE descr SQUOTE
+     */
+quirksQdescr returns [String qdescr=null]
+    {
+        matchedProduction( "AntlrSchemaValueParser.qdescr()" );
+    }
+    : 
+    ( 
+        (WHSP)?
+        (
+            ( QUOTE d1:QUIRKS_DESCR { qdescr = d1.getText(); } QUOTE )
+            |
+            ( d2:QUIRKS_DESCR { qdescr = d2.getText(); } )
+            |
+            ( QUOTE d3:DESCR { qdescr = d3.getText(); } QUOTE )
+            |
+            ( d4:DESCR { qdescr = d4.getText(); } )
+            |
+            ( QUOTE n1:NUMERICOID { qdescr = n1.getText(); } QUOTE  )
+            |
+            ( n2:NUMERICOID { qdescr = n2.getText(); } )
+        )
+        (options {greedy=true;} : WHSP)?
+    )
+    ; 
+
+
+    /**
+     * qdescrs = qdescr / ( LPAREN WSP qdescrlist WSP RPAREN )
+     * qdescrlist = [ qdescr *( SP qdescr ) ]
+     */
+quirksQdescrs returns [List<String> qdescrs]
+    {
+        matchedProduction( "AntlrSchemaValueParser.qdescrs()" );
+        qdescrs = new ArrayList<String>();
+        String qdescr = null;
+    }
+    :
+    (
+        ( 
+            qdescr=quirksQdescr { qdescrs.add(qdescr); } 
+        )
+    |
+        ( 
+            LPAR 
+            qdescr=quirksQdescr { qdescrs.add(qdescr); } 
+            (options {greedy=true;} : WHSP)?
+            (DOLLAR)?
+            (options {greedy=true;} : WHSP)?
+            (
+                qdescr=quirksQdescr { qdescrs.add(qdescr); } 
+                (options {greedy=true;} : WHSP)?
+                (DOLLAR)?
+                (options {greedy=true;} : WHSP)?
             )*
             RPAR 
         )
     )
     ;
     
+    
+    
+    
     /**
      * ruleid = number
      * number  = DIGIT / ( LDIGIT 1*DIGIT )

Modified: directory/shared/trunk/ldap/src/main/antlr/schema.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/schema.g?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/schema.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/schema.g Thu Jun  5 05:52:49 2008
@@ -106,7 +106,7 @@
 
 protected VALUES : ( VALUE | LPAR  VALUE ( (DOLLAR)? VALUE )* RPAR ) ;
 protected VALUE : (WHSP)? ( QUOTED_STRING | UNQUOTED_STRING ) (options {greedy=true;}: WHSP)? ;
-protected UNQUOTED_STRING : (options{greedy=true;}: 'a'..'z' | '0'..'9' | '-' | ';' | '.' )+ ;
+protected UNQUOTED_STRING : (options{greedy=true;}: 'a'..'z' | '0'..'9' | '-' | '_' | ';' | '.' )+ ;
 protected QUOTED_STRING : ( QUOTE (~'\'')* QUOTE ) ;
 protected FQCN_VALUE : ( FQCN_IDENTIFIER ( '.' FQCN_IDENTIFIER )* ) ;
 protected FQCN_IDENTIFIER : ( FQCN_LETTER ( FQCN_LETTERORDIGIT )* ) ;
@@ -161,6 +161,7 @@
 
 {
     private ParserMonitor monitor = null;
+    private boolean isQuirksModeEnabled = false;
     public void setParserMonitor( ParserMonitor monitor )
     {
         this.monitor = monitor;
@@ -172,6 +173,14 @@
             monitor.matchedProduction( msg );
         }
     }
+    public void setQuirksMode( boolean enabled )
+    {
+        this.isQuirksModeEnabled = enabled;
+    }
+    public boolean isQuirksMode()
+    {
+        return this.isQuirksModeEnabled;
+    }
     static class Extension
     {
         String key = "";
@@ -384,22 +393,25 @@
     )*    
     RPAR
     {
-        // semantic check: required elements
-        if( !et.contains("SYNTAX") && !et.contains("SUP") ) 
+        if( !isQuirksModeEnabled )
         {
-            throw new SemanticException( "One of SYNTAX or SUP is required", null, 0, 0 );
-        }
+            // semantic check: required elements
+            if( !et.contains("SYNTAX") && !et.contains("SUP") ) 
+            {
+                throw new SemanticException( "One of SYNTAX or SUP is required", null, 0, 0 );
+            }
         
-        // COLLECTIVE requires USAGE userApplications
-        if ( atd.isCollective() && ( atd.getUsage() != UsageEnum.USER_APPLICATIONS ) )
-        {
-            throw new SemanticException( "COLLECTIVE requires USAGE userApplications", null, 0, 0 );
-        }
+            // COLLECTIVE requires USAGE userApplications
+            if ( atd.isCollective() && ( atd.getUsage() != UsageEnum.USER_APPLICATIONS ) )
+            {
+                throw new SemanticException( "COLLECTIVE requires USAGE userApplications", null, 0, 0 );
+            }
         
-        // NO-USER-MODIFICATION requires an operational USAGE.
-        if ( !atd.isUserModifiable() && ( atd.getUsage() == UsageEnum.USER_APPLICATIONS ) )
-        {
-            throw new SemanticException( "NO-USER-MODIFICATION requires an operational USAGE", null, 0, 0 );
+            // NO-USER-MODIFICATION requires an operational USAGE.
+            if ( !atd.isUserModifiable() && ( atd.getUsage() == UsageEnum.USER_APPLICATIONS ) )
+            {
+                throw new SemanticException( "NO-USER-MODIFICATION requires an operational USAGE", null, 0, 0 );
+            }
         }
     }
     ;
@@ -477,9 +489,12 @@
     )*
     RPAR
     {
-        // semantic check: required elements
-        if( !et.contains("SYNTAX") ) {
-            throw new SemanticException( "SYNTAX is required", null, 0, 0 );
+        if( !isQuirksModeEnabled )
+        {    
+            // semantic check: required elements
+            if( !et.contains("SYNTAX") ) {
+                throw new SemanticException( "SYNTAX is required", null, 0, 0 );
+            }
         }
     }
     ;
@@ -523,9 +538,12 @@
     )*
     RPAR
     {
-        // semantic check: required elements
-        if( !et.contains("APPLIES") ) {
-            throw new SemanticException( "APPLIES is required", null, 0, 0 );
+        if( !isQuirksModeEnabled )
+        {
+            // semantic check: required elements
+            if( !et.contains("APPLIES") ) {
+                throw new SemanticException( "APPLIES is required", null, 0, 0 );
+            }
         }
     }
     ;
@@ -625,9 +643,12 @@
     )*
     RPAR
     {
-        // semantic check: required elements
-        if( !et.contains("FORM") ) {
-            throw new SemanticException( "FORM is required", null, 0, 0 );
+        if( !isQuirksModeEnabled )
+        {
+            // semantic check: required elements
+            if( !et.contains("FORM") ) {
+                throw new SemanticException( "FORM is required", null, 0, 0 );
+            }
         }
     }
     ;
@@ -677,21 +698,24 @@
     )*
     RPAR
     {
-        // semantic check: required elements
-        if( !et.contains("MUST") ) {
-            throw new SemanticException( "MUST is required", null, 0, 0 );
-        }
-        if( !et.contains("OC") ) {
-            throw new SemanticException( "OC is required", null, 0, 0 );
-        }
+        if( !isQuirksModeEnabled )
+        {
+            // semantic check: required elements
+            if( !et.contains("MUST") ) {
+                throw new SemanticException( "MUST is required", null, 0, 0 );
+            }
+            if( !et.contains("OC") ) {
+                throw new SemanticException( "OC is required", null, 0, 0 );
+            }
         
-        // semantic check: MUST and MAY must be disjoint
-        //List<String> aList = new ArrayList<String>( nfd.getMustAttributeTypes() );
-        //aList.retainAll( nfd.getMayAttributeTypes() );
-        //if( !aList.isEmpty() ) 
-        //{
-        //    throw new SemanticException( "MUST and MAY must be disjoint, "+aList.get( 0 )+" appears in both", null, 0, 0 );
-        //}
+            // semantic check: MUST and MAY must be disjoint
+            //List<String> aList = new ArrayList<String>( nfd.getMustAttributeTypes() );
+            //aList.retainAll( nfd.getMayAttributeTypes() );
+            //if( !aList.isEmpty() ) 
+            //{
+            //    throw new SemanticException( "MUST and MAY must be disjoint, "+aList.get( 0 )+" appears in both", null, 0, 0 );
+            //}
+        }
     }
     ;
     
@@ -736,14 +760,17 @@
     )*
     RPAR
     {
-        // semantic check: required elements
-        if( !et.contains("FQCN") ) {
-            throw new SemanticException( "FQCN is required", null, 0, 0 );
-        }
+        if( !isQuirksModeEnabled )
+        {
+            // semantic check: required elements
+            if( !et.contains("FQCN") ) {
+                throw new SemanticException( "FQCN is required", null, 0, 0 );
+            }
         
-        // semantic check: length should be divisible by 4
-        if( cd.getBytecode() != null && ( cd.getBytecode().length() % 4 != 0 ) ) {
-            throw new SemanticException( "BYTECODE must be divisible by 4", null, 0, 0 );
+            // semantic check: length should be divisible by 4
+            if( cd.getBytecode() != null && ( cd.getBytecode().length() % 4 != 0 ) ) {
+                throw new SemanticException( "BYTECODE must be divisible by 4", null, 0, 0 );
+            }
         }
     }
     ;
@@ -789,15 +816,18 @@
     )*
     RPAR
     {
-        // semantic check: required elements
-        if( !et.contains("FQCN") ) {
-            throw new SemanticException( "FQCN is required", null, 0, 0 );
-        }
+        if( !isQuirksModeEnabled )
+        {
+            // semantic check: required elements
+            if( !et.contains("FQCN") ) {
+                throw new SemanticException( "FQCN is required", null, 0, 0 );
+            }
         
-        // semantic check: length should be divisible by 4
-        if( nd.getBytecode() != null && ( nd.getBytecode().length() % 4 != 0 ) ) {
-            throw new SemanticException( "BYTECODE must be divisible by 4", null, 0, 0 );
-        }        
+            // semantic check: length should be divisible by 4
+            if( nd.getBytecode() != null && ( nd.getBytecode().length() % 4 != 0 ) ) {
+                throw new SemanticException( "BYTECODE must be divisible by 4", null, 0, 0 );
+            }     
+        }   
     }
     ;
     
@@ -842,15 +872,18 @@
     )*
     RPAR
     {
-        // semantic check: required elements
-        if( !et.contains("FQCN") ) {
-            throw new SemanticException( "FQCN is required", null, 0, 0 );
-        }
+        if( !isQuirksModeEnabled )
+        {
+            // semantic check: required elements
+            if( !et.contains("FQCN") ) {
+                throw new SemanticException( "FQCN is required", null, 0, 0 );
+            }
         
-        // semantic check: length should be divisible by 4
-        if( scd.getBytecode() != null && ( scd.getBytecode().length() % 4 != 0 ) ) {
-            throw new SemanticException( "BYTECODE must be divisible by 4", null, 0, 0 );
-        }        
+            // semantic check: length should be divisible by 4
+            if( scd.getBytecode() != null && ( scd.getBytecode().length() % 4 != 0 ) ) {
+                throw new SemanticException( "BYTECODE must be divisible by 4", null, 0, 0 );
+            }  
+        }      
     }
     ;
     
@@ -863,7 +896,7 @@
         AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
         AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
         parser.setParserMonitor(monitor);
-        noidlen = parser.noidlen();
+        noidlen = isQuirksModeEnabled ? parser.quirksNoidlen() : parser.noidlen();
     }
     :
     ;
@@ -883,10 +916,17 @@
 numericoid [String s] returns [String numericoid]
     {
         matchedProduction( "numericoid()");
-        AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
-        AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
-        parser.setParserMonitor(monitor);
-        numericoid = parser.numericoid();
+        if(isQuirksModeEnabled)
+        {
+             numericoid = oid(s);
+        }
+        else
+        {
+	        AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
+	        AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
+	        parser.setParserMonitor(monitor);
+	        numericoid = parser.numericoid();
+        }
     }
     :
     ;
@@ -906,11 +946,18 @@
 
 oids [String s] returns [List<String> oids]
     {
-        matchedProduction( "oid()" );
-        AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
-        AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
-        parser.setParserMonitor(monitor);
-        oids = parser.oids();
+        matchedProduction( "oids()" );
+        if(isQuirksModeEnabled)
+        {
+             oids = qdescrs(s);
+        }
+        else
+        {
+	        AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
+	        AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
+	        parser.setParserMonitor(monitor);
+	        oids = parser.oids();
+	    }
     }
     :
     ;
@@ -934,7 +981,7 @@
         AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
         AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
         parser.setParserMonitor(monitor);
-        qdescrs = parser.qdescrs();
+        qdescrs = isQuirksModeEnabled ? parser.quirksQdescrs() : parser.qdescrs();
     }
     :
     ;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java Thu Jun  5 05:52:49 2008
@@ -67,6 +67,11 @@
     }
 
 
+    /**
+     * Sets the parser monitor.
+     * 
+     * @param monitor the new parser monitor
+     */
     public void setParserMonitor( ParserMonitor monitor )
     {
         this.monitor = monitor;
@@ -74,6 +79,31 @@
     }
 
 
+    /**
+     * Sets the quirks mode. 
+     * 
+     * If enabled the parser accepts non-numeric OIDs and some 
+     * special characters in descriptions.
+     * 
+     * @param enabled the new quirks mode
+     */
+    public void setQuirksMode( boolean enabled )
+    {
+        parser.setQuirksMode( enabled );
+    }
+
+
+    /**
+     * Checks if quirks mode is enabled.
+     * 
+     * @return true, if is quirks mode is enabled
+     */
+    public boolean isQuirksMode()
+    {
+        return parser.isQuirksMode();
+    }
+
+
     public abstract AbstractSchemaDescription parse( String schemaDescription ) throws ParseException;
 
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -22,6 +22,7 @@
 
 import java.text.ParseException;
 
+import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import org.apache.directory.shared.ldap.schema.UsageEnum;
@@ -702,17 +703,19 @@
         assertNull( atd.getSyntax() );
         assertNotNull( atd.getSuperType() );
 
-        value = "( 1.2.3.4.5.6.7.8.9.0 )";
-        try
+        if ( !parser.isQuirksMode() )
         {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, SYNTAX or SUP is required" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
+            value = "( 1.2.3.4.5.6.7.8.9.0 )";
+            try
+            {
+                parser.parseAttributeTypeDescription( value );
+                fail( "Exception expected, SYNTAX or SUP is required" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
         }
-
     }
 
 
@@ -737,39 +740,41 @@
         assertTrue( atd.isCollective() );
         assertEquals( UsageEnum.USER_APPLICATIONS, atd.getUsage() );
 
-        value = "( 1.1 SYNTAX 1.1 COLLECTIVE USAGE directoryOperation )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, COLLECTIVE requires USAGE userApplications" );
-        }
-        catch ( ParseException pe )
+        if ( !parser.isQuirksMode() )
         {
-            // expected
-        }
+            value = "( 1.1 SYNTAX 1.1 COLLECTIVE USAGE directoryOperation )";
+            try
+            {
+                parser.parseAttributeTypeDescription( value );
+                fail( "Exception expected, COLLECTIVE requires USAGE userApplications" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
 
-        value = "( 1.1 SYNTAX 1.1 COLLECTIVE USAGE dSAOperation )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, COLLECTIVE requires USAGE userApplications" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+            value = "( 1.1 SYNTAX 1.1 COLLECTIVE USAGE dSAOperation )";
+            try
+            {
+                parser.parseAttributeTypeDescription( value );
+                fail( "Exception expected, COLLECTIVE requires USAGE userApplications" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
 
-        value = "( 1.1 SYNTAX 1.1 COLLECTIVE USAGE distributedOperation )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, COLLECTIVE requires USAGE userApplications" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
+            value = "( 1.1 SYNTAX 1.1 COLLECTIVE USAGE distributedOperation )";
+            try
+            {
+                parser.parseAttributeTypeDescription( value );
+                fail( "Exception expected, COLLECTIVE requires USAGE userApplications" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
         }
-
     }
 
 
@@ -799,26 +804,29 @@
         assertFalse( atd.isUserModifiable() );
         assertEquals( UsageEnum.DISTRIBUTED_OPERATION, atd.getUsage() );
 
-        value = "( 1.1 SYNTAX 1.1 NO-USER-MODIFICATION USAGE userApplications )";
-        try
+        if ( !parser.isQuirksMode() )
         {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, NO-USER-MODIFICATION requires an operational USAGE" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+            value = "( 1.1 SYNTAX 1.1 NO-USER-MODIFICATION USAGE userApplications )";
+            try
+            {
+                parser.parseAttributeTypeDescription( value );
+                fail( "Exception expected, NO-USER-MODIFICATION requires an operational USAGE" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
 
-        value = "( 1.1 SYNTAX 1.1 NO-USER-MODIFICATION )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, NO-USER-MODIFICATION requires an operational USAGE" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
+            value = "( 1.1 SYNTAX 1.1 NO-USER-MODIFICATION )";
+            try
+            {
+                parser.parseAttributeTypeDescription( value );
+                fail( "Exception expected, NO-USER-MODIFICATION requires an operational USAGE" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
         }
     }
 
@@ -882,7 +890,7 @@
     /**
      * Tests the parse of a simple AttributeType
      */
-    public void testAddAttributeType() throws Exception
+    public void testAddAttributeType() throws ParseException
     {
         String substrate = "( 1.3.6.1.4.1.18060.0.4.0.2.10000 NAME ( 'bogus' 'bogusName' ) "
             + "DESC 'bogus description' SUP name SINGLE-VALUE )";
@@ -899,7 +907,7 @@
     /**
      * Tests the parse of a simple AttributeType with the schema extension.
      */
-    public void testAttributeTypeWithSchemaExtension() throws Exception
+    public void testAttributeTypeWithSchemaExtension() throws ParseException
     {
         String substrate = "( 1.3.6.1.4.1.18060.0.4.0.2.10000 NAME ( 'bogus' 'bogusName' ) "
             + "DESC 'bogus description' SUP name SINGLE-VALUE X-SCHEMA 'blah' )";
@@ -917,7 +925,7 @@
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -928,4 +936,87 @@
         SchemaParserTestUtils.testMultiThreaded( parser, testValues );
     }
 
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        SchemaParserTestUtils.testQuirksMode( parser, "SYNTAX 1.1" );
+
+        try
+        {
+            String value = null;
+            AttributeTypeDescription atd = null;
+
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericOid();
+            testNames();
+            testDescription();
+            testObsolete();
+            testSuperType();
+            testEquality();
+            testOrdering();
+            testSubstring();
+            testSingleValue();
+            testCollective();
+            testNoUserModification();
+            testUsage();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testRequiredElements();
+            testCollecitveConstraint();
+            testNoUserModificatonConstraint();
+            testIgnoreElementOrder();
+            testRfcUid();
+            testAddAttributeType();
+            testMultiThreaded();
+
+            // NAME with special chars
+            value = "( 1.2.3 SYNTAX te_st NAME 't-e_s.t;' )";
+            atd = parser.parseAttributeTypeDescription( value );
+            Assert.assertEquals( 1, atd.getNames().size() );
+            Assert.assertEquals( "t-e_s.t;", atd.getNames().get( 0 ) );
+
+            // SYNTAX with underscore
+            value = "( 1.1 SYNTAX te_st )";
+            atd = parser.parseAttributeTypeDescription( value );
+            assertEquals( "te_st", atd.getSyntax() );
+
+            // SUPERTYPE with underscore
+            value = "( 1.1 SYNTAX 1.1 SUP te_st )";
+            atd = parser.parseAttributeTypeDescription( value );
+            assertEquals( "te_st", atd.getSuperType() );
+
+            // EQUALITY with underscore
+            value = "( 1.1 SYNTAX 1.1 EQUALITY te_st )";
+            atd = parser.parseAttributeTypeDescription( value );
+            assertEquals( "te_st", atd.getEqualityMatchingRule() );
+
+            // SUBSTR with underscore
+            value = "( 1.1 SYNTAX 1.1 SUBSTR te_st )";
+            atd = parser.parseAttributeTypeDescription( value );
+            assertEquals( "te_st", atd.getSubstringsMatchingRule() );
+
+            // ORDERING with underscore
+            value = "( 1.1 SYNTAX 1.1 ORDERING te_st )";
+            atd = parser.parseAttributeTypeDescription( value );
+            assertEquals( "te_st", atd.getOrderingMatchingRule() );
+
+            // Netscape attribute 
+            value = "( nsAdminGroupName-oid NAME 'nsAdminGroupName' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape' )";
+            atd = parser.parseAttributeTypeDescription( value );
+            assertEquals( "nsAdminGroupName-oid", atd.getNumericOid() );
+            assertEquals( 1, atd.getNames().size() );
+            assertEquals( "nsAdminGroupName", atd.getNames().get( 0 ) );
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
+
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -50,7 +50,7 @@
     }
 
 
-    public void testNumericOid() throws Exception
+    public void testNumericOid() throws ParseException
     {
         SchemaParserTestUtils.testNumericOid( parser, "FQCN org.apache.directory.SimpleComparator" );
     }
@@ -108,6 +108,7 @@
 
     public void testFull()
     {
+        // TODO
     }
 
 
@@ -118,6 +119,7 @@
      */
     public void testUniqueElements()
     {
+        // TODO
     }
 
 
@@ -128,14 +130,44 @@
      */
     public void testRequiredElements()
     {
+        // TODO
     }
 
 
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
+        // TODO
+    }
+
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        SchemaParserTestUtils.testQuirksMode( parser, "FQCN org.apache.directory.SimpleComparator" );
+
+        try
+        {
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericOid();
+            testDescription();
+            testFqcn();
+            testBytecode();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testMultiThreaded();
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
     }
 
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -202,18 +202,6 @@
             // expected
         }
 
-        // invalid start
-        value = "( 1.1 AUX ( top1 $ -top2 ) )";
-        try
-        {
-            dcrd = parser.parseDITContentRuleDescription( value );
-            fail( "Exception expected, invalid AUX '-top' (starts with hypen)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // empty AUX
         value = "( 1.1 AUX )";
         try
@@ -225,6 +213,21 @@
         {
             // expected
         }
+
+        if ( !parser.isQuirksMode() )
+        {
+            // invalid start
+            value = "( 1.1 AUX ( top1 $ -top2 ) )";
+            try
+            {
+                dcrd = parser.parseDITContentRuleDescription( value );
+                fail( "Exception expected, invalid AUX '-top' (starts with hypen)" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+        }
     }
 
 
@@ -259,18 +262,6 @@
         assertEquals( "11.22.33.44.55", dcrd.getMustAttributeTypes().get( 2 ) );
         assertEquals( "objectClass", dcrd.getMustAttributeTypes().get( 3 ) );
 
-        // invalid value
-        value = "( 1.1 MUST ( c_n ) )";
-        try
-        {
-            dcrd = parser.parseDITContentRuleDescription( value );
-            fail( "Exception expected, invalid value c_n" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // no MUST values
         value = "( 1.1 MUST )";
         try
@@ -282,6 +273,21 @@
         {
             // expected
         }
+
+        if ( !parser.isQuirksMode() )
+        {
+            // invalid value
+            value = "( 1.1 MUST ( c_n ) )";
+            try
+            {
+                dcrd = parser.parseDITContentRuleDescription( value );
+                fail( "Exception expected, invalid value c_n" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+        }
     }
 
 
@@ -316,16 +322,19 @@
         assertEquals( "11.22.33.44.55", dcrd.getMayAttributeTypes().get( 2 ) );
         assertEquals( "objectClass", dcrd.getMayAttributeTypes().get( 3 ) );
 
-        // invalid value
-        value = "( 1.1 MAY ( c_n ) )";
-        try
+        if ( !parser.isQuirksMode() )
         {
-            dcrd = parser.parseDITContentRuleDescription( value );
-            fail( "Exception expected, invalid value c_n" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
+            // invalid value
+            value = "( 1.1 MAY ( c_n ) )";
+            try
+            {
+                dcrd = parser.parseDITContentRuleDescription( value );
+                fail( "Exception expected, invalid value c_n" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
         }
     }
 
@@ -361,16 +370,19 @@
         assertEquals( "11.22.33.44.55", dcrd.getNotAttributeTypes().get( 2 ) );
         assertEquals( "objectClass", dcrd.getNotAttributeTypes().get( 3 ) );
 
-        // invalid value
-        value = "( 1.1 NOT ( c_n ) )";
-        try
+        if ( !parser.isQuirksMode() )
         {
-            dcrd = parser.parseDITContentRuleDescription( value );
-            fail( "Exception expected, invalid value c_n" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
+            // invalid value
+            value = "( 1.1 NOT ( c_n ) )";
+            try
+            {
+                dcrd = parser.parseDITContentRuleDescription( value );
+                fail( "Exception expected, invalid value c_n" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
         }
     }
 
@@ -452,7 +464,7 @@
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -464,4 +476,35 @@
 
     }
 
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        SchemaParserTestUtils.testQuirksMode( parser, "" );
+
+        try
+        {
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericOid();
+            testDescription();
+            testObsolete();
+            testAux();
+            testMust();
+            testMay();
+            testNot();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testMultiThreaded();
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
+
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -228,18 +228,6 @@
             // expected
         }
 
-        // invalid start
-        value = "( 1 FORM -test ) )";
-        try
-        {
-            dsrd = parser.parseDITStructureRuleDescription( value );
-            fail( "Exception expected, invalid FORM '-test' (starts with hypen)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // no multiple values
         value = "( 1 FORM ( test1 test2 ) )";
         try
@@ -252,6 +240,20 @@
             // expected
         }
 
+        if ( !parser.isQuirksMode() )
+        {
+            // invalid start
+            value = "( 1 FORM -test ) )";
+            try
+            {
+                dsrd = parser.parseDITStructureRuleDescription( value );
+                fail( "Exception expected, invalid FORM '-test' (starts with hypen)" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+        }
     }
 
 
@@ -410,7 +412,7 @@
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -422,4 +424,32 @@
 
     }
 
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        try
+        {
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericRuleId();
+            testNames();
+            testDescription();
+            testObsolete();
+            testForm();
+            testSup();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testMultiThreaded();
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
+
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -118,7 +118,6 @@
         assertEquals( 2, lsd.getExtensions().get( "X-TEST-b" ).size() );
         assertEquals( "test2-1", lsd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
         assertEquals( "test2-2", lsd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
-
     }
 
 
@@ -156,7 +155,7 @@
     /**
      * Tests the parse of a simple AttributeType with the schema extension.
      */
-    public void testSyntaxWithExtensions() throws Exception
+    public void testSyntaxWithExtensions() throws ParseException
     {
         String substrate = "( 1.3.6.1.4.1.18060.0.4.0.2.10000 DESC 'bogus description' X-SCHEMA 'blah' X-IS-HUMAN-READABLE 'true' )";
         LdapSyntaxDescription desc = parser.parseLdapSyntaxDescription( substrate );
@@ -169,7 +168,7 @@
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -180,4 +179,32 @@
         SchemaParserTestUtils.testMultiThreaded( parser, testValues );
     }
 
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        SchemaParserTestUtils.testQuirksMode( parser, "" );
+
+        try
+        {
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericOid();
+            testNames();
+            testDescription();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testRfcBinary();
+            testSyntaxWithExtensions();
+            testMultiThreaded();
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -50,13 +50,13 @@
     }
 
 
-    public void testNumericOid() throws Exception
+    public void testNumericOid() throws ParseException
     {
         SchemaParserTestUtils.testNumericOid( parser, "SYNTAX 1.1" );
     }
 
 
-    public void testNames() throws Exception
+    public void testNames() throws ParseException
     {
         SchemaParserTestUtils.testNames( parser, "1.1", "SYNTAX 1.1" );
     }
@@ -99,30 +99,6 @@
         mrd = parser.parseMatchingRuleDescription( value );
         assertEquals( "0.1.2.3.4.5.6.7.8.9", mrd.getSyntax() );
 
-        // non-numeric not allowed
-        value = "( test )";
-        try
-        {
-            parser.parse( value );
-            fail( "Exception expected, invalid SYNTAX test" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // SYNTAX is required
-        value = "( 1.1 )";
-        try
-        {
-            mrd = parser.parseMatchingRuleDescription( value );
-            fail( "Exception expected, SYNTAX is required" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // SYNTAX must only appear once
         value = "( 1.1 SYNTAX 2.2 SYNTAX 3.3 )";
         try
@@ -135,6 +111,32 @@
             assertTrue( true );
         }
 
+        if ( !parser.isQuirksMode() )
+        {
+            // non-numeric not allowed
+            value = "( test )";
+            try
+            {
+                parser.parse( value );
+                fail( "Exception expected, SYNTAX is require" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+
+            // SYNTAX is required
+            value = "( 1.1 )";
+            try
+            {
+                mrd = parser.parseMatchingRuleDescription( value );
+                fail( "Exception expected, SYNTAX is required" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+        }
     }
 
 
@@ -200,17 +202,19 @@
         mrd = parser.parseMatchingRuleDescription( value );
         assertNotNull( mrd.getSyntax() );
 
-        value = "( 1.2.3.4.5.6.7.8.9.0 )";
-        try
-        {
-            parser.parseMatchingRuleDescription( value );
-            fail( "Exception expected, SYNTAX is required" );
-        }
-        catch ( ParseException pe )
+        if ( !parser.isQuirksMode() )
         {
-            assertTrue( true );
+            value = "( 1.2.3.4.5.6.7.8.9.0 )";
+            try
+            {
+                parser.parseMatchingRuleDescription( value );
+                fail( "Exception expected, SYNTAX is required" );
+            }
+            catch ( ParseException pe )
+            {
+                assertTrue( true );
+            }
         }
-
     }
 
 
@@ -252,17 +256,31 @@
      * This is a real matching rule from Sun Directory 5.2. It has an invalid 
      * syntax, no DOTs allowed in NAME value. 
      */
-    public void testSun2()
+    public void testSun2() throws ParseException
     {
         String value = "( 1.3.6.1.4.1.42.2.27.9.4.34.3.6 NAME 'caseExactSubstringMatch-2.16.840.1.113730.3.3.2.11.3' DESC 'en' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )";
-        try
+        if ( !parser.isQuirksMode() )
         {
-            parser.parseMatchingRuleDescription( value );
-            fail( "Exception expected, invalid NAME value 'caseExactSubstringMatch-2.16.840.1.113730.3.3.2.11.3' (contains DOTs)" );
+            try
+            {
+                parser.parseMatchingRuleDescription( value );
+                fail( "Exception expected, invalid NAME value 'caseExactSubstringMatch-2.16.840.1.113730.3.3.2.11.3' (contains DOTs)" );
+            }
+            catch ( ParseException pe )
+            {
+                assertTrue( true );
+            }
         }
-        catch ( ParseException pe )
+        else
         {
-            assertTrue( true );
+            MatchingRuleDescription mrd = parser.parseMatchingRuleDescription( value );
+            assertEquals( "1.3.6.1.4.1.42.2.27.9.4.34.3.6", mrd.getNumericOid() );
+            assertEquals( 1, mrd.getNames().size() );
+            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() );
+            assertEquals( 0, mrd.getExtensions().size() );
         }
     }
 
@@ -270,7 +288,7 @@
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -281,4 +299,37 @@
         SchemaParserTestUtils.testMultiThreaded( parser, testValues );
     }
 
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        SchemaParserTestUtils.testQuirksMode( parser, "SYNTAX 1.1" );
+
+        try
+        {
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericOid();
+            testNames();
+            testDescription();
+            testObsolete();
+            testSyntax();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testRequiredElements();
+            testRfc1();
+            testSun1();
+            testSun2();
+            testMultiThreaded();
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
+
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -50,13 +50,13 @@
     }
 
 
-    public void testNumericOid() throws Exception
+    public void testNumericOid() throws ParseException
     {
         SchemaParserTestUtils.testNumericOid( parser, "APPLIES 1.1" );
     }
 
 
-    public void testNames() throws Exception
+    public void testNames() throws ParseException
     {
         SchemaParserTestUtils.testNames( parser, "1.1", "APPLIES 1.1" );
     }
@@ -175,18 +175,6 @@
             // expected
         }
 
-        // invalid start
-        value = "( 1.1 APPLIES ( test1 $ -test2 ) )";
-        try
-        {
-            mrud = parser.parseMatchingRuleUseDescription( value );
-            fail( "Exception expected, invalid APPLIES '-test' (starts with hypen)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // empty APPLIES
         value = "( 1.1 APPLIES )";
         try
@@ -199,18 +187,6 @@
             // expected
         }
 
-        // APPLIES is required
-        value = "( 1.1 )";
-        try
-        {
-            mrud = parser.parseMatchingRuleUseDescription( value );
-            fail( "Exception expected, APPLIES is required" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // APPLIES must only appear once
         value = "( 1.1 APPLIES test1 APPLIES test2 )";
         try
@@ -222,6 +198,33 @@
         {
             // expected
         }
+
+        if ( !parser.isQuirksMode() )
+        {
+            // APPLIES is required
+            value = "( 1.1 )";
+            try
+            {
+                mrud = parser.parseMatchingRuleUseDescription( value );
+                fail( "Exception expected, APPLIES is required" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+
+            // invalid start
+            value = "( 1.1 APPLIES ( test1 $ -test2 ) )";
+            try
+            {
+                mrud = parser.parseMatchingRuleUseDescription( value );
+                fail( "Exception expected, invalid APPLIES '-test' (starts with hypen)" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+        }
     }
 
 
@@ -290,17 +293,19 @@
         mrud = parser.parseMatchingRuleUseDescription( value );
         assertEquals( 1, mrud.getApplicableAttributes().size() );
 
-        value = "( 1.2.3.4.5.6.7.8.9.0 )";
-        try
-        {
-            parser.parseMatchingRuleUseDescription( value );
-            fail( "Exception expected, APPLIES is required" );
-        }
-        catch ( ParseException pe )
+        if ( !parser.isQuirksMode() )
         {
-            // expected
+            value = "( 1.2.3.4.5.6.7.8.9.0 )";
+            try
+            {
+                parser.parseMatchingRuleUseDescription( value );
+                fail( "Exception expected, APPLIES is required" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
         }
-
     }
 
 
@@ -328,7 +333,7 @@
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -339,4 +344,35 @@
         SchemaParserTestUtils.testMultiThreaded( parser, testValues );
     }
 
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        SchemaParserTestUtils.testQuirksMode( parser, "APPLIES 1.1" );
+
+        try
+        {
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericOid();
+            testNames();
+            testDescription();
+            testObsolete();
+            testApplies();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testRequiredElements();
+            testOpenldap1();
+            testMultiThreaded();
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
+
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -142,18 +142,6 @@
             // expected
         }
 
-        // invalid start
-        value = "( 1.1 MUST m OC -test ) )";
-        try
-        {
-            nfd = parser.parseNameFormDescription( value );
-            fail( "Exception expected, invalid OC '-test' (starts with hypen)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // no multi value allowed
         value = "( 1.1 MUST m OC ( test1 test2 ) )";
         try
@@ -166,18 +154,6 @@
             // expected
         }
 
-        // OC is required
-        value = "( 1.1 MUST m )";
-        try
-        {
-            nfd = parser.parseNameFormDescription( value );
-            fail( "Exception expected, OC is required" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // OC must only appear once
         value = "( 1.1 MUST m OC test1 OC test2 )";
         try
@@ -190,6 +166,32 @@
             // expected
         }
 
+        if ( !parser.isQuirksMode() )
+        {
+            // OC is required
+            value = "( 1.1 MUST m )";
+            try
+            {
+                nfd = parser.parseNameFormDescription( value );
+                fail( "Exception expected, OC is required" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+
+            // invalid start
+            value = "( 1.1 MUST m OC -test ) )";
+            try
+            {
+                nfd = parser.parseNameFormDescription( value );
+                fail( "Exception expected, invalid OC '-test' (starts with hypen)" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+        }
     }
 
 
@@ -218,18 +220,6 @@
         assertEquals( "11.22.33.44.55", nfd.getMustAttributeTypes().get( 2 ) );
         assertEquals( "objectClass", nfd.getMustAttributeTypes().get( 3 ) );
 
-        // invalid value
-        value = "( 1.1 OC o MUST ( c_n ) )";
-        try
-        {
-            nfd = parser.parseNameFormDescription( value );
-            fail( "Exception expected, invalid value c_n" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // no MUST values
         value = "( 1.1 OC o MUST )";
         try
@@ -242,18 +232,6 @@
             // expected
         }
 
-        // MUST is required
-        value = "( 1.1 OC o )";
-        try
-        {
-            nfd = parser.parseNameFormDescription( value );
-            fail( "Exception expected, MUST is required" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // MUST must only appear once
         value = "( 1.1 OC o MUST test1 MUST test2 )";
         try
@@ -265,6 +243,33 @@
         {
             // expected
         }
+
+        if ( !parser.isQuirksMode() )
+        {
+            // MUST is required
+            value = "( 1.1 OC o )";
+            try
+            {
+                nfd = parser.parseNameFormDescription( value );
+                fail( "Exception expected, MUST is required" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+
+            // invalid value
+            value = "( 1.1 OC o MUST ( c_n ) )";
+            try
+            {
+                nfd = parser.parseNameFormDescription( value );
+                fail( "Exception expected, invalid value c_n" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+        }
     }
 
 
@@ -298,18 +303,6 @@
         assertEquals( "11.22.33.44.55", nfd.getMayAttributeTypes().get( 2 ) );
         assertEquals( "objectClass", nfd.getMayAttributeTypes().get( 3 ) );
 
-        // invalid value
-        value = "( 1.1 OC o MUST m MAY ( c_n ) )";
-        try
-        {
-            nfd = parser.parseNameFormDescription( value );
-            fail( "Exception expected, invalid value c_n" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // MAY must only appear once
         value = "( 1.1 OC o MUST m MAY test1 MAY test2 )";
         try
@@ -322,6 +315,20 @@
             // expected
         }
 
+        if ( !parser.isQuirksMode() )
+        {
+            // invalid value
+            value = "( 1.1 OC o MUST m MAY ( c_n ) )";
+            try
+            {
+                nfd = parser.parseNameFormDescription( value );
+                fail( "Exception expected, invalid value c_n" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+        }
     }
 
 
@@ -409,26 +416,29 @@
         assertNotNull( nfd.getStructuralObjectClass() );
         assertEquals( 1, nfd.getMustAttributeTypes().size() );
 
-        value = "( 1.2.3.4.5.6.7.8.9.0 MUST m )";
-        try
-        {
-            nfd = parser.parseNameFormDescription( value );
-            fail( "Exception expected, OC is required" );
-        }
-        catch ( ParseException pe )
+        if ( !parser.isQuirksMode() )
         {
-            // expected
-        }
+            value = "( 1.2.3.4.5.6.7.8.9.0 MUST m )";
+            try
+            {
+                nfd = parser.parseNameFormDescription( value );
+                fail( "Exception expected, OC is required" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
 
-        value = "( 1.2.3.4.5.6.7.8.9.0 OC o )";
-        try
-        {
-            nfd = parser.parseNameFormDescription( value );
-            fail( "Exception expected, MUST is required" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
+            value = "( 1.2.3.4.5.6.7.8.9.0 OC o )";
+            try
+            {
+                nfd = parser.parseNameFormDescription( value );
+                fail( "Exception expected, MUST is required" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
         }
     }
 
@@ -477,7 +487,7 @@
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -489,4 +499,36 @@
 
     }
 
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        SchemaParserTestUtils.testQuirksMode( parser, "OC o MUST m" );
+
+        try
+        {
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericOid();
+            testNames();
+            testDescription();
+            testObsolete();
+            testOc();
+            testMust();
+            testMay();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testRequiredElements();
+            testMultiThreaded();
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
+
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -50,15 +50,15 @@
     }
 
 
-    public void testNumericOid() throws Exception
+    public void testNumericOid() throws ParseException
     {
-        SchemaParserTestUtils.testNumericOid( parser, "FQCN org.apache.directory.SimpleComparator" );
+        SchemaParserTestUtils.testNumericOid( parser, "FQCN org.apache.directory.SimpleNormalizer" );
     }
 
 
     public void testDescription() throws ParseException
     {
-        SchemaParserTestUtils.testDescription( parser, "1.1", "FQCN org.apache.directory.SimpleComparator" );
+        SchemaParserTestUtils.testDescription( parser, "1.1", "FQCN org.apache.directory.SimpleNormalizer" );
     }
 
 
@@ -68,10 +68,10 @@
         NormalizerDescription nd = null;
 
         // FQCN simple p
-        value = "( 1.1 FQCN org.apache.directory.SimpleComparator )";
+        value = "( 1.1 FQCN org.apache.directory.SimpleNormalizer )";
         nd = parser.parseNormalizerDescription( value );
         assertNotNull( nd.getFqcn() );
-        assertEquals( "org.apache.directory.SimpleComparator", nd.getFqcn() );
+        assertEquals( "org.apache.directory.SimpleNormalizer", nd.getFqcn() );
     }
 
 
@@ -90,12 +90,13 @@
 
     public void testExtensions() throws ParseException
     {
-        SchemaParserTestUtils.testExtensions( parser, "1.1", "FQCN org.apache.directory.SimpleComparator" );
+        SchemaParserTestUtils.testExtensions( parser, "1.1", "FQCN org.apache.directory.SimpleNormalizer" );
     }
 
 
     public void testFull()
     {
+        // TODO
     }
 
 
@@ -106,6 +107,7 @@
      */
     public void testUniqueElements()
     {
+        // TODO
     }
 
 
@@ -116,14 +118,44 @@
      */
     public void testRequiredElements()
     {
+        // TODO
     }
 
 
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
+        // TODO
     }
 
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        SchemaParserTestUtils.testQuirksMode( parser, "FQCN org.apache.directory.SimpleNormalizer" );
+
+        try
+        {
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericOid();
+            testDescription();
+            testFqcn();
+            testBytecode();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testRequiredElements();
+            testMultiThreaded();
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -22,6 +22,7 @@
 
 import java.text.ParseException;
 
+import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
@@ -203,18 +204,6 @@
             // expected
         }
 
-        // invalid start
-        value = "( 1.1 SUP ( top1 $ -top2 ) )";
-        try
-        {
-            ocd = parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid SUP '-top' (starts with hypen)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // empty sup
         value = "( 1.1 SUP )";
         try
@@ -226,6 +215,21 @@
         {
             // expected
         }
+
+        if ( !parser.isQuirksMode() )
+        {
+            // invalid start
+            value = "( 1.1 SUP ( top1 $ -top2 ) )";
+            try
+            {
+                ocd = parser.parseObjectClassDescription( value );
+                fail( "Exception expected, invalid SUP '-top' (starts with hypen)" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+        }
     }
 
 
@@ -318,18 +322,6 @@
         assertEquals( "11.22.33.44.55", ocd.getMustAttributeTypes().get( 2 ) );
         assertEquals( "objectClass", ocd.getMustAttributeTypes().get( 3 ) );
 
-        // invalid value
-        value = "( 1.1 MUST ( c_n ) )";
-        try
-        {
-            ocd = parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid value c_n" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // no MUST values
         value = "( 1.1 MUST )";
         try
@@ -341,6 +333,21 @@
         {
             // expected
         }
+
+        if ( !parser.isQuirksMode() )
+        {
+            // invalid value
+            value = "( 1.1 MUST ( c_n ) )";
+            try
+            {
+                ocd = parser.parseObjectClassDescription( value );
+                fail( "Exception expected, invalid value c_n" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+        }
     }
 
 
@@ -384,16 +391,19 @@
         assertEquals( "11.22.33.44.55", ocd.getMayAttributeTypes().get( 2 ) );
         assertEquals( "objectClass", ocd.getMayAttributeTypes().get( 3 ) );
 
-        // invalid value
-        value = "( 1.1 MAY ( c_n ) )";
-        try
+        if ( !parser.isQuirksMode() )
         {
-            ocd = parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid value c_n" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
+            // invalid value
+            value = "( 1.1 MAY ( c_n ) )";
+            try
+            {
+                ocd = parser.parseObjectClassDescription( value );
+                fail( "Exception expected, invalid value c_n" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
         }
     }
 
@@ -725,9 +735,9 @@
 
 
     /**
-     * Tests the multithreaded use of a single parser.
+     * Tests the multi-threaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -737,4 +747,80 @@
                 "( 2.16.840.1.113719.1.1.6.1.30 NAME 'List' SUP Top STRUCTURAL MUST cn MAY ( description $ l $ member $ ou $ o $ eMailAddress $ mailboxLocation $ mailboxID $ owner $ seeAlso $ fullName ) X-NDS_NAMING 'cn' X-NDS_CONTAINMENT ( 'Organization' 'organizationalUnit' 'domain' ) X-NDS_NOT_CONTAINER '1' X-NDS_NONREMOVABLE '1' X-NDS_ACL_TEMPLATES '2#entry#[Root Template]#member' )" };
         SchemaParserTestUtils.testMultiThreaded( parser, testValues );
     }
+
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        SchemaParserTestUtils.testQuirksMode( parser, "" );
+
+        try
+        {
+            String value = null;
+            ObjectClassDescription ocd = null;
+
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericOid();
+            testNames();
+            testDescription();
+            testObsolete();
+            testSuperior();
+            testKind();
+            testMust();
+            testMay();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testIgnoreElementOrder();
+            testRfcTop();
+            testRfcSimpleSecurityObject();
+            testSunAlias();
+            testNovellDcObject();
+            testNovellList();
+            testMicrosoftAds2000Locality();
+            testMicrosoftAds2003Msieee();
+            testSiemensDirxX500Subschema();
+            testMultiThreaded();
+
+            // NAME with special chars
+            value = "( 1.2.3 NAME 't-e_s.t;' )";
+            ocd = parser.parseObjectClassDescription( value );
+            Assert.assertEquals( 1, ocd.getNames().size() );
+            Assert.assertEquals( "t-e_s.t;", ocd.getNames().get( 0 ) );
+
+            // SUP with underscore
+            value = "( 1.1 SUP te_st )";
+            ocd = parser.parseObjectClassDescription( value );
+            assertEquals( 1, ocd.getSuperiorObjectClasses().size() );
+            assertEquals( "te_st", ocd.getSuperiorObjectClasses().get( 0 ) );
+
+            // MAY with underscore
+            value = "( 1.1 MAY te_st )";
+            ocd = parser.parseObjectClassDescription( value );
+            assertEquals( 1, ocd.getMayAttributeTypes().size() );
+            assertEquals( "te_st", ocd.getMayAttributeTypes().get( 0 ) );
+
+            // MUST with underscore
+            value = "( 1.1 MUST te_st )";
+            ocd = parser.parseObjectClassDescription( value );
+            assertEquals( 1, ocd.getMustAttributeTypes().size() );
+            assertEquals( "te_st", ocd.getMustAttributeTypes().get( 0 ) );
+
+            // Netscape object class 
+            value = "( nsAdminGroup-oid NAME 'nsAdminGroup' DESC 'Netscape defined objectclass' SUP top STRUCTURAL MUST cn MAY ( nsAdminGroupName $ description $ nsConfigRoot $ nsAdminSIEDN ) X-ORIGIN 'Netscape' )";
+            ocd = parser.parseObjectClassDescription( value );
+            assertEquals( "nsAdminGroup-oid", ocd.getNumericOid() );
+            assertEquals( 1, ocd.getNames().size() );
+            assertEquals( "nsAdminGroup", ocd.getNames().get( 0 ) );
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
+
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java Thu Jun  5 05:52:49 2008
@@ -108,19 +108,7 @@
         asd = parser.parse( value );
         Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
 
-        // non-numeric not allowed
-        value = "( test " + required + " )";
-        try
-        {
-            parser.parse( value );
-            Assert.fail( "Exception expected, invalid NUMERICOID test" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // to short
+        // too short
         value = "( 1 " + required + " )";
         try
         {
@@ -156,30 +144,6 @@
             // expected
         }
 
-        // leading 0 not allowed
-        value = "( 01.1 " + required + " )";
-        try
-        {
-            parser.parse( value );
-            Assert.fail( "Exception expected, invalid NUMERICOID 01.1 (leading zero)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // alpha not allowed
-        value = "( 1.2.a.4 " + required + " )";
-        try
-        {
-            parser.parse( value );
-            Assert.fail( "Exception expected, invalid NUMERICOID 1.2.a.4 (alpha not allowed)" );
-        }
-        catch ( ParseException pe )
-        {
-            // excpected
-        }
-
         // multiple not allowed
         value = "( ( 1.2.3 4.5.6 ) " + required + " )";
         try
@@ -191,6 +155,46 @@
         {
             // excpected
         }
+
+        if ( !parser.isQuirksMode() )
+        {
+            // non-numeric not allowed
+            value = "( test " + required + " )";
+            try
+            {
+                parser.parse( value );
+                Assert.fail( "Exception expected, invalid NUMERICOID test" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+
+            // leading 0 not allowed
+            value = "( 01.1 " + required + " )";
+            try
+            {
+                parser.parse( value );
+                Assert.fail( "Exception expected, invalid NUMERICOID 01.1 (leading zero)" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+
+            // alpha not allowed
+            value = "( 1.2.a.4 " + required + " )";
+            try
+            {
+                parser.parse( value );
+                Assert.fail( "Exception expected, invalid NUMERICOID 1.2.a.4 (alpha not allowed)" );
+            }
+            catch ( ParseException pe )
+            {
+                // excpected
+            }
+
+        }
     }
 
 
@@ -282,42 +286,6 @@
         Assert.assertEquals( "test1", asd.getNames().get( 0 ) );
         Assert.assertEquals( "test2", asd.getNames().get( 1 ) );
 
-        // start with number
-        value = "( " + oid + " " + required + " NAME '1test' )";
-        try
-        {
-            parser.parse( value );
-            Assert.fail( "Exception expected, invalid NAME 1test (starts with number)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // start with hypen
-        value = "( " + oid + " " + required + " NAME '-test' )";
-        try
-        {
-            parser.parse( value );
-            Assert.fail( "Exception expected, invalid NAME -test (starts with hypen)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // invalid character
-        value = "( " + oid + " " + required + " NAME 'te_st' )";
-        try
-        {
-            parser.parse( value );
-            Assert.fail( "Exception expected, invalid NAME te_st (contains invalid character)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // NAM unknown
         value = "( " + oid + " " + required + " NAM 'test' )";
         try
@@ -330,16 +298,55 @@
             // expected
         }
 
-        // one valid, one invalid
-        value = "( " + oid + " " + required + " NAME ( 'test' 'te_st' ) )";
-        try
-        {
-            parser.parse( value );
-            Assert.fail( "Exception expected, invalid NAME te_st (contains invalid character)" );
-        }
-        catch ( ParseException pe )
+        if ( !parser.isQuirksMode() )
         {
-            // expected
+            // start with number
+            value = "( " + oid + " " + required + " NAME '1test' )";
+            try
+            {
+                parser.parse( value );
+                Assert.fail( "Exception expected, invalid NAME 1test (starts with number)" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+
+            // start with hypen
+            value = "( " + oid + " " + required + " NAME '-test' )";
+            try
+            {
+                parser.parse( value );
+                Assert.fail( "Exception expected, invalid NAME -test (starts with hypen)" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+
+            // invalid character
+            value = "( " + oid + " " + required + " NAME 'te_st' )";
+            try
+            {
+                parser.parse( value );
+                Assert.fail( "Exception expected, invalid NAME te_st (contains invalid character)" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
+
+            // one valid, one invalid
+            value = "( " + oid + " " + required + " NAME ( 'test' 'te_st' ) )";
+            try
+            {
+                parser.parse( value );
+                Assert.fail( "Exception expected, invalid NAME te_st (contains invalid character)" );
+            }
+            catch ( ParseException pe )
+            {
+                // expected
+            }
         }
     }
 
@@ -643,6 +650,46 @@
 
     }
 
+
+    /**
+     * Tests quirks mode.
+     */
+    public static void testQuirksMode( AbstractSchemaParser parser, String required ) throws ParseException
+    {
+        try
+        {
+            String value = null;
+            AbstractSchemaDescription asd = null;
+            
+            parser.setQuirksMode( true );
+            
+            // alphanum OID
+            value = "( abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 " + required + " )";
+            asd = parser.parse( value );
+            Assert.assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789", asd
+                .getNumericOid() );
+
+            // start with hypen
+            value = "( -oid " + required + " )";
+            asd = parser.parse( value );
+            Assert.assertEquals( "-oid", asd.getNumericOid() );
+
+            // start with number
+            value = "( 1oid " + required + " )";
+            asd = parser.parse( value );
+            Assert.assertEquals( "1oid", asd.getNumericOid() );
+
+            // start with dot
+            value = "( .oid " + required + " )";
+            asd = parser.parse( value );
+            Assert.assertEquals( ".oid", asd.getNumericOid() );
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
+
     static class ParseSpecification implements Runnable
     {
         private final AbstractSchemaParser parser;

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParserTest.java?rev=663597&r1=663596&r2=663597&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParserTest.java Thu Jun  5 05:52:49 2008
@@ -56,7 +56,7 @@
     }
 
 
-    public void testNumericOid() throws Exception
+    public void testNumericOid() throws ParseException
     {
         SchemaParserTestUtils.testNumericOid( parser, "FQCN org.apache.directory.SimpleComparator" );
     }
@@ -128,7 +128,7 @@
     }
 
 
-    public void testSimpleSyntaxChecker() throws Exception
+    public void testSimpleSyntaxChecker() throws ParseException
     {
         String simple = "( " + OID + " FQCN " + FQCN + " )";
         SyntaxCheckerDescription desc = parser.parseSyntaxCheckerDescription( simple );
@@ -140,7 +140,7 @@
     }
 
 
-    public void testSyntaxCheckerWithDesc() throws Exception
+    public void testSyntaxCheckerWithDesc() throws ParseException
     {
         String simple = "( " + OID + " DESC '" + DESC + "' FQCN " + FQCN + " )";
         SyntaxCheckerDescription desc = parser.parseSyntaxCheckerDescription( simple );
@@ -152,7 +152,7 @@
     }
 
 
-    public void testSyntaxCheckerWithDescAndByteCode() throws Exception
+    public void testSyntaxCheckerWithDescAndByteCode() throws ParseException
     {
         String simple = "( " + OID + " DESC '" + DESC + "' FQCN " + FQCN + " BYTECODE " + BYTECODE + " )";
         SyntaxCheckerDescription desc = parser.parseSyntaxCheckerDescription( simple );
@@ -164,7 +164,7 @@
     }
 
 
-    public void testSyntaxCheckerExample() throws Exception
+    public void testSyntaxCheckerExample() throws ParseException
     {
         String simple = "( 1.3.6.1.4.1.18060.0.4.1.0.10000 DESC 'bogus desc' FQCN org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker )";
         SyntaxCheckerDescription desc = parser.parseSyntaxCheckerDescription( simple );
@@ -172,7 +172,7 @@
     }
 
 
-    public void testRealByteCodeExample() throws Exception
+    public void testRealByteCodeExample() throws ParseException
     {
         String simple = "( 1.3.6.1.4.1.18060.0.4.1.0.10002 DESC 'bogus desc' "
             + "FQCN DummySyntaxChecker BYTECODE yv66vgAAADEAHgoABAAYCQADABkHABoHABsHABwBAANvaWQBABJMam"
@@ -200,9 +200,42 @@
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         // TODO
     }
 
+
+    /**
+     * Tests quirks mode.
+     */
+    public void testQuirksMode() throws ParseException
+    {
+        SchemaParserTestUtils.testQuirksMode( parser, "FQCN org.apache.directory.SimpleComparator" );
+
+        try
+        {
+            parser.setQuirksMode( true );
+
+            // ensure all other test pass in quirks mode
+            testNumericOid();
+            testDescription();
+            testFqcn();
+            testBytecode();
+            testExtensions();
+            testFull();
+            testUniqueElements();
+            testSimpleSyntaxChecker();
+            testSyntaxCheckerWithDesc();
+            testSyntaxCheckerWithDescAndByteCode();
+            testSyntaxCheckerExample();
+            testRealByteCodeExample();
+            testMultiThreaded();
+        }
+        finally
+        {
+            parser.setQuirksMode( false );
+        }
+    }
+
 }



Mime
View raw message