directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r664290 [12/13] - in /directory/shared/branches/bigbang: ./ asn1/src/main/java/org/apache/directory/shared/asn1/ asn1/src/main/java/org/apache/directory/shared/asn1/ber/ asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/ asn1/...
Date Sat, 07 Jun 2008 06:28:15 GMT
Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParserTest.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParserTest.java Fri Jun  6 23:28:06 2008
@@ -50,7 +50,7 @@
     }
 
 
-    public void testNumericOid() throws Exception
+    public void testNumericOid() throws ParseException
     {
         SchemaParserTestUtils.testNumericOid( parser, "FQCN org.apache.directory.SimpleComparator" );
     }
@@ -58,29 +58,25 @@
 
     public void testDescription() throws ParseException
     {
-        SchemaParserTestUtils
-            .testDescription( parser, "1.1", "FQCN org.apache.directory.SimpleComparator" );
+        SchemaParserTestUtils.testDescription( parser, "1.1", "FQCN org.apache.directory.SimpleComparator" );
     }
 
 
     public void testFqcn() throws ParseException
     {
-
         String value = null;
         ComparatorDescription cd = null;
 
-        // FQCN simple p
+        // FQCN simple
         value = "( 1.1 FQCN org.apache.directory.SimpleComparator )";
         cd = parser.parseComparatorDescription( value );
         assertNotNull( cd.getFqcn() );
         assertEquals( "org.apache.directory.SimpleComparator", cd.getFqcn() );
-
     }
 
 
     public void testBytecode() throws ParseException
     {
-
         String value = null;
         ComparatorDescription cd = null;
 
@@ -90,6 +86,17 @@
         assertNotNull( cd.getBytecode() );
         assertEquals( "ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====", cd.getBytecode() );
 
+        // FQCN simple, no spaces
+        value = "(1.1 FQCNorg.apache.directory.SimpleComparator BYTECODEABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====)";
+        cd = parser.parseComparatorDescription( value );
+        assertNotNull( cd.getBytecode() );
+        assertEquals( "ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====", cd.getBytecode() );
+
+        // FQCN simple, tabs
+        value = "\t(\t1.1\tFQCN\torg.apache.directory.SimpleComparator\tBYTECODE\tABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====\t)\t";
+        cd = parser.parseComparatorDescription( value );
+        assertNotNull( cd.getBytecode() );
+        assertEquals( "ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====", cd.getBytecode() );
     }
 
 
@@ -101,6 +108,7 @@
 
     public void testFull()
     {
+        // TODO
     }
 
 
@@ -111,6 +119,7 @@
      */
     public void testUniqueElements()
     {
+        // TODO
     }
 
 
@@ -121,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/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java Fri Jun  6 23:28:06 2008
@@ -156,7 +156,7 @@
         assertEquals( "top2", dcrd.getAuxiliaryObjectClasses().get( 2 ) );
 
         // AUX multi mixed no space
-        value = "( 1.1 AUX (TOP-1$1.2.3.4$TOP-2) )";
+        value = "(1.1 AUX(TOP-1$1.2.3.4$TOP-2))";
         dcrd = parser.parseDITContentRuleDescription( value );
         assertEquals( 3, dcrd.getAuxiliaryObjectClasses().size() );
         assertEquals( "TOP-1", dcrd.getAuxiliaryObjectClasses().get( 0 ) );
@@ -173,27 +173,22 @@
 
         // no quote allowed
         value = "( 1.1 AUX 'top' )";
-        try
-        {
-            dcrd = parser.parseDITContentRuleDescription( value );
-            fail( "Exception expected, invalid AUX 'top' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        dcrd = parser.parseDITContentRuleDescription( value );
+        assertEquals( 1, dcrd.getAuxiliaryObjectClasses().size() );
+        assertEquals( "top", dcrd.getAuxiliaryObjectClasses().get( 0 ) );
 
-        // no quote allowed
+        // quoted value
         value = "( 1.1 AUX '1.2.3.4' )";
-        try
-        {
-            dcrd = parser.parseDITContentRuleDescription( value );
-            fail( "Exception expected, invalid AUX '1.2.3.4' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        dcrd = parser.parseDITContentRuleDescription( value );
+        assertEquals( 1, dcrd.getAuxiliaryObjectClasses().size() );
+        assertEquals( "1.2.3.4", dcrd.getAuxiliaryObjectClasses().get( 0 ) );
+
+        // no $ separator
+        value = "( 1.1 AUX ( top1 top2 ) )";
+        dcrd = parser.parseDITContentRuleDescription( value );
+        assertEquals( 2, dcrd.getAuxiliaryObjectClasses().size() );
+        assertEquals( "top1", dcrd.getAuxiliaryObjectClasses().get( 0 ) );
+        assertEquals( "top2", dcrd.getAuxiliaryObjectClasses().get( 1 ) );
 
         // invalid character
         value = "( 1.1 AUX 1.2.3.4.A )";
@@ -207,30 +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
-        }
-
-        // invalid separator
-        value = "( 1.1 AUX ( top1 top2 ) )";
-        try
-        {
-            dcrd = parser.parseDITContentRuleDescription( value );
-            fail( "Exception expected, invalid separator (no DOLLAR)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // empty AUX
         value = "( 1.1 AUX )";
         try
@@ -242,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
+            }
+        }
     }
 
 
@@ -255,7 +241,7 @@
     {
         String value = null;
         DITContentRuleDescription dcrd = null;
-        
+
         // no MUST
         value = "( 1.1 )";
         dcrd = parser.parseDITContentRuleDescription( value );
@@ -268,7 +254,7 @@
         assertEquals( "1.2.3", dcrd.getMustAttributeTypes().get( 0 ) );
 
         // MUST mulitple
-        value = "(1.1 MUST (cn$sn       $11.22.33.44.55         $  objectClass   ))";
+        value = "(1.1 MUST (cn\rsn       $11.22.33.44.55            objectClass\t))";
         dcrd = parser.parseDITContentRuleDescription( value );
         assertEquals( 4, dcrd.getMustAttributeTypes().size() );
         assertEquals( "cn", dcrd.getMustAttributeTypes().get( 0 ) );
@@ -276,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
@@ -299,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
+            }
+        }
     }
 
 
@@ -333,19 +322,23 @@
         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
-        {
-            dcrd = parser.parseDITContentRuleDescription( value );
-            fail( "Exception expected, invalid value c_n" );
-        }
-        catch ( ParseException pe )
+        if ( !parser.isQuirksMode() )
         {
-            // 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
+            }
         }
     }
 
+
     /**
      * Test NOT and its values.
      * Very similar to AUX, so here are less test cases. 
@@ -357,19 +350,19 @@
         String value = null;
         DITContentRuleDescription dcrd = null;
 
-        // no MAY
+        // no NOT
         value = "( 1.1 )";
         dcrd = parser.parseDITContentRuleDescription( value );
         assertEquals( 0, dcrd.getNotAttributeTypes().size() );
 
-        // MAY simple numericoid
+        // NOT simple numericoid
         value = "( 1.1 NOT 1.2.3 )";
         dcrd = parser.parseDITContentRuleDescription( value );
         assertEquals( 1, dcrd.getNotAttributeTypes().size() );
         assertEquals( "1.2.3", dcrd.getNotAttributeTypes().get( 0 ) );
 
-        // MAY mulitple
-        value = "(1.1 NOT (cn$sn       $11.22.33.44.55         $  objectClass   ))";
+        // NOT mulitple
+        value = "(1.1 NOT (cn\nsn\t$11.22.33.44.55         $  objectClass   ))";
         dcrd = parser.parseDITContentRuleDescription( value );
         assertEquals( 4, dcrd.getNotAttributeTypes().size() );
         assertEquals( "cn", dcrd.getNotAttributeTypes().get( 0 ) );
@@ -377,19 +370,22 @@
         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
+            }
         }
     }
-    
+
 
     /**
      * Test extensions.
@@ -449,7 +445,7 @@
         assertEquals( "test2-2", dcrd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
     }
 
-    
+
     /**
      * Test unique elements.
      * 
@@ -458,24 +454,17 @@
     public void testUniqueElements()
     {
         String[] testValues = new String[]
-            { 
-                "( 1.1 NAME 'test1' NAME 'test2' )", 
-                "( 1.1 DESC 'test1' DESC 'test2' )",
-                "( 1.1 OBSOLETE OBSOLETE )", 
-                "( 1.1 AUX test1 AUX test2 )",
-                "( 1.1 MUST test1 MUST test2 )",
-                "( 1.1 MAY test1 MAY test2 )",
-                "( 1.1 NOT test1 NOT test2 )",
-                "( 1.1 X-TEST 'test1' X-TEST 'test2' )" 
-            };
+            { "( 1.1 NAME 'test1' NAME 'test2' )", "( 1.1 DESC 'test1' DESC 'test2' )", "( 1.1 OBSOLETE OBSOLETE )",
+                "( 1.1 AUX test1 AUX test2 )", "( 1.1 MUST test1 MUST test2 )", "( 1.1 MAY test1 MAY test2 )",
+                "( 1.1 NOT test1 NOT test2 )", "( 1.1 X-TEST 'test1' X-TEST 'test2' )" };
         SchemaParserTestUtils.testUnique( parser, testValues );
     }
-    
-    
+
+
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -487,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/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java Fri Jun  6 23:28:06 2008
@@ -196,29 +196,25 @@
         dsrd = parser.parseDITStructureRuleDescription( value );
         assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", dsrd.getForm() );
 
-        // no quote allowed
+        // descr, no space
+        value = "(1 FORMabc)";
+        dsrd = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "abc", dsrd.getForm() );
+
+        // descr, tab
+        value = "\t(\t1\tFORM\tabc\t)\t";
+        dsrd = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "abc", dsrd.getForm() );
+
+        // quoted value
         value = "( 1 FORM '1.2.3.4.5.6.7.8.9.0' )";
-        try
-        {
-            dsrd = parser.parseDITStructureRuleDescription( value );
-            fail( "Exception expected, invalid FORM '1.2.3.4.5.6.7.8.9.0' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        dsrd = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", dsrd.getForm() );
 
         // no quote allowed
-        value = "( 1 FORM 'test' )";
-        try
-        {
-            dsrd = parser.parseDITStructureRuleDescription( value );
-            fail( "Exception expected, invalid FORM 'test' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        value = "( 1 FORM ('test') )";
+        dsrd = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "test", dsrd.getForm() );
 
         // invalid character
         value = "( 1 FORM 1.2.3.4.A )";
@@ -232,19 +228,7 @@
             // 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 multi value
+        // no multiple values
         value = "( 1 FORM ( test1 test2 ) )";
         try
         {
@@ -256,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
+            }
+        }
     }
 
 
@@ -287,7 +285,7 @@
         assertEquals( new Integer( 1 ), dsrd.getSuperRules().get( 0 ) );
 
         // SUP multi number
-        value = "( 1 FORM 1.1 SUP (12345 67890) )";
+        value = "( 1 FORM 1.1 SUP(12345 67890))";
         dsrd = parser.parseDITStructureRuleDescription( value );
         assertEquals( 2, dsrd.getSuperRules().size() );
         assertEquals( new Integer( 12345 ), dsrd.getSuperRules().get( 0 ) );
@@ -353,9 +351,9 @@
         assertTrue( dsrd.isObsolete() );
         assertEquals( "2.3.4.5.6.7.8.9.0.1", dsrd.getForm() );
         assertEquals( 3, dsrd.getSuperRules().size() );
-        assertEquals( new Integer(1), dsrd.getSuperRules().get( 0 ) );
-        assertEquals( new Integer(1234567890), dsrd.getSuperRules().get( 1 ) );
-        assertEquals( new Integer(5), dsrd.getSuperRules().get( 2 ) );
+        assertEquals( new Integer( 1 ), dsrd.getSuperRules().get( 0 ) );
+        assertEquals( new Integer( 1234567890 ), dsrd.getSuperRules().get( 1 ) );
+        assertEquals( new Integer( 5 ), dsrd.getSuperRules().get( 2 ) );
         assertEquals( 2, dsrd.getExtensions().size() );
         assertNotNull( dsrd.getExtensions().get( "X-TEST-a" ) );
         assertEquals( 2, dsrd.getExtensions().get( "X-TEST-a" ).size() );
@@ -367,7 +365,7 @@
         assertEquals( "test2-2", dsrd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
     }
 
-    
+
     /**
      * Test unique elements.
      * 
@@ -376,18 +374,13 @@
     public void testUniqueElements()
     {
         String[] testValues = new String[]
-            { 
-                "( 1 FORM 1.1 NAME 'test1' NAME 'test2' )", 
-                "( 1 FORM 1.1 DESC 'test1' DESC 'test2' )",
-                "( 1 FORM 1.1 OBSOLETE OBSOLETE )", 
-                "( 1 FORM 1.1 FORM test1 FORM test2 )",
-                "( 1 FORM 1.1 SUP 1 SUP 2 )",
-                "( 1 FORM 1.1 X-TEST 'test1' X-TEST 'test2' )" 
-            };
+            { "( 1 FORM 1.1 NAME 'test1' NAME 'test2' )", "( 1 FORM 1.1 DESC 'test1' DESC 'test2' )",
+                "( 1 FORM 1.1 OBSOLETE OBSOLETE )", "( 1 FORM 1.1 FORM test1 FORM test2 )",
+                "( 1 FORM 1.1 SUP 1 SUP 2 )", "( 1 FORM 1.1 X-TEST 'test1' X-TEST 'test2' )" };
         SchemaParserTestUtils.testUnique( parser, testValues );
     }
-    
-    
+
+
     /**
      * Test required elements.
      * 
@@ -412,14 +405,14 @@
         {
             // expected
         }
-        
+
     }
 
 
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -431,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/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java Fri Jun  6 23:28:06 2008
@@ -62,6 +62,17 @@
 
 
     /**
+     * Tests NAMES
+     * 
+     * @throws ParseException
+     */
+    public void testNames() throws ParseException
+    {
+        SchemaParserTestUtils.testNames( parser, "1.1", "" );
+    }
+
+
+    /**
      * Tests DESC
      * 
      * @throws ParseException
@@ -107,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 ) );
-
     }
 
 
@@ -119,13 +129,10 @@
     public void testUniqueElements()
     {
         String[] testValues = new String[]
-            { 
-                "( 1.1 DESC 'test1' DESC 'test2' )",
-                "( 1.1 X-TEST 'test1' X-TEST 'test2' )" 
-            };
+            { "( 1.1 DESC 'test1' DESC 'test2' )", "( 1.1 X-TEST 'test1' X-TEST 'test2' )" };
         SchemaParserTestUtils.testUnique( parser, testValues );
     }
-    
+
 
     ////////////////////////////////////////////////////////////////
     //         Some real-world attribute type definitions         //
@@ -144,11 +151,11 @@
         assertEquals( "TRUE", lsd.getExtensions().get( "X-NOT-HUMAN-READABLE" ).get( 0 ) );
     }
 
-    
+
     /**
      * 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 );
@@ -157,19 +164,47 @@
         assertNotNull( desc.getExtensions().get( "X-IS-HUMAN-READABLE" ) );
     }
 
-    
+
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
-            { 
-                "( 1.1 )", 
+            {
+                "( 1.1 )",
                 "( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
                 "( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' X-NOT-HUMAN-READABLE 'TRUE' )",
                 "( 1.2.3.4.5.6.7.8.9.0 DESC 'Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577' X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )" };
         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/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java Fri Jun  6 23:28:06 2008
@@ -37,6 +37,7 @@
     /** the parser instance */
     private MatchingRuleDescriptionSchemaParser parser;
 
+
     protected void setUp() throws Exception
     {
         parser = new MatchingRuleDescriptionSchemaParser();
@@ -49,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" );
     }
@@ -75,7 +76,6 @@
 
     public void testSyntax() throws ParseException
     {
-
         String value = null;
         MatchingRuleDescription mrd = null;
 
@@ -85,7 +85,7 @@
         assertEquals( "0.1.2.3.4.5.6.7.8.9", mrd.getSyntax() );
 
         // simple
-        value = "( 1.1 SYNTAX 123.456.789.0 )";
+        value = "(1.1 SYNTAX 123.456.789.0)";
         mrd = parser.parseMatchingRuleDescription( value );
         assertEquals( "123.456.789.0", mrd.getSyntax() );
 
@@ -94,31 +94,12 @@
         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
-        }
+        // quoted value in parentheses
+        value = "( 1.1    SYNTAX ('0.1.2.3.4.5.6.7.8.9')    )";
+        mrd = parser.parseMatchingRuleDescription( value );
+        assertEquals( "0.1.2.3.4.5.6.7.8.9", mrd.getSyntax() );
 
-        // OC must only appear once
+        // SYNTAX must only appear once
         value = "( 1.1 SYNTAX 2.2 SYNTAX 3.3 )";
         try
         {
@@ -129,7 +110,33 @@
         {
             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
+            }
+        }
     }
 
 
@@ -164,8 +171,8 @@
         assertEquals( "test2-1", mrd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
         assertEquals( "test2-2", mrd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
     }
-    
-    
+
+
     /**
      * Test unique elements.
      * 
@@ -174,13 +181,9 @@
     public void testUniqueElements()
     {
         String[] testValues = new String[]
-            { 
-                "( 1.1 SYNTAX 1.1 NAME 'test1' NAME 'test2' )", 
-                "( 1.1 SYNTAX 1.1 DESC 'test1' DESC 'test2' )",
-                "( 1.1 SYNTAX 1.1 OBSOLETE OBSOLETE )", 
-                "( 1.1 SYNTAX 1.1 SYNTAX 2.2 SYNTAX 3.3 )",
-                "( 1.1 SYNTAX 1.1 X-TEST 'test1' X-TEST 'test2' )" 
-            };
+            { "( 1.1 SYNTAX 1.1 NAME 'test1' NAME 'test2' )", "( 1.1 SYNTAX 1.1 DESC 'test1' DESC 'test2' )",
+                "( 1.1 SYNTAX 1.1 OBSOLETE OBSOLETE )", "( 1.1 SYNTAX 1.1 SYNTAX 2.2 SYNTAX 3.3 )",
+                "( 1.1 SYNTAX 1.1 X-TEST 'test1' X-TEST 'test2' )" };
         SchemaParserTestUtils.testUnique( parser, testValues );
     }
 
@@ -199,20 +202,22 @@
         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 );
+            }
         }
-
     }
-    
-    
+
+
     ////////////////////////////////////////////////////////////////
     //         Some real-world matching rule descriptons          //
     ////////////////////////////////////////////////////////////////
@@ -251,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() );
         }
     }
 
@@ -269,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[]
             {
@@ -280,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/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java Fri Jun  6 23:28:06 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" );
     }
@@ -100,7 +100,7 @@
         assertEquals( "123.4567.890", mrud.getApplicableAttributes().get( 0 ) );
 
         // APPLIES single descr
-        value = "( 1.1 APPLIES ( a-z-A-Z-0-9 ) )";
+        value = "(1.1 APPLIES(a-z-A-Z-0-9))";
         mrud = parser.parseMatchingRuleUseDescription( value );
         assertEquals( 1, mrud.getApplicableAttributes().size() );
         assertEquals( "a-z-A-Z-0-9", mrud.getApplicableAttributes().get( 0 ) );
@@ -120,8 +120,8 @@
         assertEquals( "test1", mrud.getApplicableAttributes().get( 0 ) );
         assertEquals( "test2", mrud.getApplicableAttributes().get( 1 ) );
 
-        // APPLIES multi mixed
-        value = "( 1.1 APPLIES ( test1 $ 1.2.3.4 $ test2 ) )";
+        // APPLIES multi mixed, tabs
+        value = "\t(\t1.1\tAPPLIES\t(\ttest1\t$\t1.2.3.4\t$\ttest2\t)\t)\t";
         mrud = parser.parseMatchingRuleUseDescription( value );
         assertEquals( 3, mrud.getApplicableAttributes().size() );
         assertEquals( "test1", mrud.getApplicableAttributes().get( 0 ) );
@@ -129,7 +129,7 @@
         assertEquals( "test2", mrud.getApplicableAttributes().get( 2 ) );
 
         // APPLIES multi mixed no space
-        value = "( 1.1 APPLIES (TEST-1$1.2.3.4$TEST-2) )";
+        value = "(1.1 APPLIES(TEST-1$1.2.3.4$TEST-2))";
         mrud = parser.parseMatchingRuleUseDescription( value );
         assertEquals( 3, mrud.getApplicableAttributes().size() );
         assertEquals( "TEST-1", mrud.getApplicableAttributes().get( 0 ) );
@@ -144,29 +144,24 @@
         assertEquals( "1.2.3.4", mrud.getApplicableAttributes().get( 1 ) );
         assertEquals( "test2", mrud.getApplicableAttributes().get( 2 ) );
 
-        // no quote allowed
+        // quoted value
         value = "( 1.1 APPLIES 'test' )";
-        try
-        {
-            mrud = parser.parseMatchingRuleUseDescription( value );
-            fail( "Exception expected, invalid APPLIES 'test' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        mrud = parser.parseMatchingRuleUseDescription( value );
+        assertEquals( 1, mrud.getApplicableAttributes().size() );
+        assertEquals( "test", mrud.getApplicableAttributes().get( 0 ) );
 
-        // no quote allowed
+        // quoted value
         value = "( 1.1 APPLIES '1.2.3.4' )";
-        try
-        {
-            mrud = parser.parseMatchingRuleUseDescription( value );
-            fail( "Exception expected, invalid APPLIES '1.2.3.4' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        mrud = parser.parseMatchingRuleUseDescription( value );
+        assertEquals( 1, mrud.getApplicableAttributes().size() );
+        assertEquals( "1.2.3.4", mrud.getApplicableAttributes().get( 0 ) );
+
+        // no $ separator
+        value = "( 1.1 APPLIES ( test1 test2 ) )";
+        mrud = parser.parseMatchingRuleUseDescription( value );
+        assertEquals( 2, mrud.getApplicableAttributes().size() );
+        assertEquals( "test1", mrud.getApplicableAttributes().get( 0 ) );
+        assertEquals( "test2", mrud.getApplicableAttributes().get( 1 ) );
 
         // invalid character
         value = "( 1.1 APPLIES 1.2.3.4.A )";
@@ -180,30 +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
-        }
-
-        // invalid separator
-        value = "( 1.1 APPLIES ( test1 test2 ) )";
-        try
-        {
-            mrud = parser.parseMatchingRuleUseDescription( value );
-            fail( "Exception expected, invalid separator (no DOLLAR)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // empty APPLIES
         value = "( 1.1 APPLIES )";
         try
@@ -215,18 +186,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 )";
@@ -239,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
+            }
+        }
     }
 
 
@@ -286,17 +272,13 @@
     public void testUniqueElements()
     {
         String[] testValues = new String[]
-            { 
-                "( 1.1 APPLIES 1.1 NAME 'test1' NAME 'test2' )",
-                "( 1.1 APPLIES 1.1 DESC 'test1' DESC 'test2' )",
-                "( 1.1 APPLIES 1.1 OBSOLETE OBSOLETE )", 
-                "( 1.1 APPLIES 1.1 APPLIES test1 APPLIES test2 )",
-                "( 1.1 APPLIES 1.1 X-TEST 'test1' X-TEST 'test2' )" 
-            };
+            { "( 1.1 APPLIES 1.1 NAME 'test1' NAME 'test2' )", "( 1.1 APPLIES 1.1 DESC 'test1' DESC 'test2' )",
+                "( 1.1 APPLIES 1.1 OBSOLETE OBSOLETE )", "( 1.1 APPLIES 1.1 APPLIES test1 APPLIES test2 )",
+                "( 1.1 APPLIES 1.1 X-TEST 'test1' X-TEST 'test2' )" };
         SchemaParserTestUtils.testUnique( parser, testValues );
-    }    
-    
-    
+    }
+
+
     /**
      * Test required elements.
      * 
@@ -311,20 +293,22 @@
         mrud = parser.parseMatchingRuleUseDescription( value );
         assertEquals( 1, mrud.getApplicableAttributes().size() );
 
-        value = "( 1.2.3.4.5.6.7.8.9.0 )";
-        try
+        if ( !parser.isQuirksMode() )
         {
-            parser.parseMatchingRuleUseDescription( value );
-            fail( "Exception expected, APPLIES is required" );
-        }
-        catch ( ParseException pe )
-        {
-            // 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
+            }
         }
-
     }
-    
-    
+
+
     ////////////////////////////////////////////////////////////////
     //       Some real-world matching rule use descriptons        //
     ////////////////////////////////////////////////////////////////
@@ -349,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[]
             {
@@ -360,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/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java Fri Jun  6 23:28:06 2008
@@ -120,29 +120,15 @@
         assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", nfd
             .getStructuralObjectClass() );
 
-        // no quote allowed
+        // quoted value
         value = "( 1.1 MUST m OC '1.2.3.4.5.6.7.8.9.0' )";
-        try
-        {
-            nfd = parser.parseNameFormDescription( value );
-            fail( "Exception expected, invalid FORM '1.2.3.4.5.6.7.8.9.0' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        nfd = parser.parseNameFormDescription( value );
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", nfd.getStructuralObjectClass() );
 
-        // no quote allowed
+        // quoted value
         value = "( 1.1 MUST m OC 'test' )";
-        try
-        {
-            nfd = parser.parseNameFormDescription( value );
-            fail( "Exception expected, invalid OC 'test' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        nfd = parser.parseNameFormDescription( value );
+        assertEquals( "test", nfd.getStructuralObjectClass() );
 
         // invalid character
         value = "( 1.1 MUST m OC 1.2.3.4.A )";
@@ -156,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
@@ -180,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
@@ -204,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
+            }
+        }
     }
 
 
@@ -232,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
@@ -256,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
@@ -279,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
+            }
+        }
     }
 
 
@@ -312,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
@@ -336,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
+            }
+        }
     }
 
 
@@ -400,15 +393,10 @@
     public void testUniqueElements()
     {
         String[] testValues = new String[]
-            { 
-                "( 1.1 OC o MUST m NAME 'test1' NAME 'test2' )", 
-                "( 1.1 OC o MUST m DESC 'test1' DESC 'test2' )",
-                "( 1.1 OC o MUST m OBSOLETE OBSOLETE )", 
-                "( 1.1 OC o MUST m OC test1 OC test2 )",
-                "( 1.1 OC o MUST m MUST test1 MUST test2 )",
-                "( 1.1 OC o MUST m MAY test1 MAY test2 )",
-                "( 1.1 OC o MUST m X-TEST 'test1' X-TEST 'test2' )" 
-            };
+            { "( 1.1 OC o MUST m NAME 'test1' NAME 'test2' )", "( 1.1 OC o MUST m DESC 'test1' DESC 'test2' )",
+                "( 1.1 OC o MUST m OBSOLETE OBSOLETE )", "( 1.1 OC o MUST m OC test1 OC test2 )",
+                "( 1.1 OC o MUST m MUST test1 MUST test2 )", "( 1.1 OC o MUST m MAY test1 MAY test2 )",
+                "( 1.1 OC o MUST m X-TEST 'test1' X-TEST 'test2' )" };
         SchemaParserTestUtils.testUnique( parser, testValues );
     }
 
@@ -428,76 +416,78 @@
         assertNotNull( nfd.getStructuralObjectClass() );
         assertEquals( 1, nfd.getMustAttributeTypes().size() );
 
-        value = "( 1.2.3.4.5.6.7.8.9.0 MUST m )";
-        try
+        if ( !parser.isQuirksMode() )
         {
-            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 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
+            }
         }
     }
 
 
-//    /**
-//     * Test if MUST and MAY are disjoint.
-//     * 
-//     * Problem: What if MUST is a numeric oid and MAY is a name?
-//     * 
-//     * @throws ParseException
-//     */
-//    public void testDisjoint() throws ParseException
-//    {
-//        String value = null;
-//        NameFormDescription nfd = null;
-//
-//        value = "( 1.2.3.4.5.6.7.8.9.0 OC o MUST test1 MAY test2 )";
-//        nfd = parser.parseNameFormDescription( value );
-//        assertNotNull( nfd.getStructuralObjectClass() );
-//        assertEquals( 1, nfd.getMustAttributeTypes().size() );
-//
-//        value = "( 1.2.3.4.5.6.7.8.9.0 OC o MUST test1 MAY test1 )";
-//        try
-//        {
-//            nfd = parser.parseNameFormDescription( value );
-//            fail( "Exception expected, MUST and MAY must be disjoint" );
-//        }
-//        catch ( ParseException pe )
-//        {
-//            // expected
-//        }
-//
-//        value = "( 1.2.3.4.5.6.7.8.9.0 OC o MUST ( test1 $ test2 ) MAY ( test4 $ test3 $ test2 ) )";
-//        try
-//        {
-//            nfd = parser.parseNameFormDescription( value );
-//            fail( "Exception expected, MUST and MAY must be disjoint" );
-//        }
-//        catch ( ParseException pe )
-//        {
-//            // expected
-//        }
-//
-//    }
-
+    //    /**
+    //     * Test if MUST and MAY are disjoint.
+    //     * 
+    //     * Problem: What if MUST is a numeric oid and MAY is a name?
+    //     * 
+    //     * @throws ParseException
+    //     */
+    //    public void testDisjoint() throws ParseException
+    //    {
+    //        String value = null;
+    //        NameFormDescription nfd = null;
+    //
+    //        value = "( 1.2.3.4.5.6.7.8.9.0 OC o MUST test1 MAY test2 )";
+    //        nfd = parser.parseNameFormDescription( value );
+    //        assertNotNull( nfd.getStructuralObjectClass() );
+    //        assertEquals( 1, nfd.getMustAttributeTypes().size() );
+    //
+    //        value = "( 1.2.3.4.5.6.7.8.9.0 OC o MUST test1 MAY test1 )";
+    //        try
+    //        {
+    //            nfd = parser.parseNameFormDescription( value );
+    //            fail( "Exception expected, MUST and MAY must be disjoint" );
+    //        }
+    //        catch ( ParseException pe )
+    //        {
+    //            // expected
+    //        }
+    //
+    //        value = "( 1.2.3.4.5.6.7.8.9.0 OC o MUST ( test1 $ test2 ) MAY ( test4 $ test3 $ test2 ) )";
+    //        try
+    //        {
+    //            nfd = parser.parseNameFormDescription( value );
+    //            fail( "Exception expected, MUST and MAY must be disjoint" );
+    //        }
+    //        catch ( ParseException pe )
+    //        {
+    //            // expected
+    //        }
+    //
+    //    }
 
     /**
      * Tests the multithreaded use of a single parser.
      */
-    public void testMultiThreaded() throws Exception
+    public void testMultiThreaded() throws ParseException
     {
         String[] testValues = new String[]
             {
@@ -509,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/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParserTest.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParserTest.java Fri Jun  6 23:28:06 2008
@@ -50,37 +50,33 @@
     }
 
 
-    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" );
     }
 
 
     public void testFqcn() throws ParseException
     {
-
         String value = null;
         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() );
     }
 
 
     public void testBytecode() throws ParseException
     {
-
         String value = null;
         NormalizerDescription nd = null;
 
@@ -89,18 +85,18 @@
         nd = parser.parseNormalizerDescription( value );
         assertNotNull( nd.getBytecode() );
         assertEquals( "ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====", nd.getBytecode() );
-
     }
 
 
     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
     }
 
 
@@ -111,6 +107,7 @@
      */
     public void testUniqueElements()
     {
+        // TODO
     }
 
 
@@ -121,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/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java Fri Jun  6 23:28:06 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;
@@ -148,16 +149,16 @@
         assertEquals( "top1", ocd.getSuperiorObjectClasses().get( 0 ) );
         assertEquals( "top2", ocd.getSuperiorObjectClasses().get( 1 ) );
 
-        // SUP multi mixed
-        value = "( 1.1 SUP ( top1 $ 1.2.3.4 $ top2 ) )";
+        // SUP multi mixed, tabs
+        value = "\t(\t1.1\tSUP\t(\ttop1\t$\t1.2.3.4\t$\ttop2\t)\t)\t";
         ocd = parser.parseObjectClassDescription( value );
         assertEquals( 3, ocd.getSuperiorObjectClasses().size() );
         assertEquals( "top1", ocd.getSuperiorObjectClasses().get( 0 ) );
         assertEquals( "1.2.3.4", ocd.getSuperiorObjectClasses().get( 1 ) );
         assertEquals( "top2", ocd.getSuperiorObjectClasses().get( 2 ) );
 
-        // SUP multi mixed no space
-        value = "( 1.1 SUP (TOP-1$1.2.3.4$TOP-2) )";
+        // SUP multi mixed, no space
+        value = "(1.1 SUP(TOP-1$1.2.3.4$TOP-2))";
         ocd = parser.parseObjectClassDescription( value );
         assertEquals( 3, ocd.getSuperiorObjectClasses().size() );
         assertEquals( "TOP-1", ocd.getSuperiorObjectClasses().get( 0 ) );
@@ -172,29 +173,24 @@
         assertEquals( "1.2.3.4", ocd.getSuperiorObjectClasses().get( 1 ) );
         assertEquals( "top2", ocd.getSuperiorObjectClasses().get( 2 ) );
 
-        // no quote allowed
+        // quoted value
         value = "( 1.1 SUP 'top' )";
-        try
-        {
-            ocd = parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid SUP 'top' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        ocd = parser.parseObjectClassDescription( value );
+        assertEquals( 1, ocd.getSuperiorObjectClasses().size() );
+        assertEquals( "top", ocd.getSuperiorObjectClasses().get( 0 ) );
 
-        // no quote allowed
+        // quoted value
         value = "( 1.1 SUP '1.2.3.4' )";
-        try
-        {
-            ocd = parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid SUP '1.2.3.4' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        ocd = parser.parseObjectClassDescription( value );
+        assertEquals( 1, ocd.getSuperiorObjectClasses().size() );
+        assertEquals( "1.2.3.4", ocd.getSuperiorObjectClasses().get( 0 ) );
+
+        // no $ separator
+        value = "( 1.1 SUP ( top1 top2 ) )";
+        ocd = parser.parseObjectClassDescription( value );
+        assertEquals( 2, ocd.getSuperiorObjectClasses().size() );
+        assertEquals( "top1", ocd.getSuperiorObjectClasses().get( 0 ) );
+        assertEquals( "top2", ocd.getSuperiorObjectClasses().get( 1 ) );
 
         // invalid character
         value = "( 1.1 SUP 1.2.3.4.A )";
@@ -208,30 +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
-        }
-
-        // invalid separator
-        value = "( 1.1 SUP ( top1 top2 ) )";
-        try
-        {
-            ocd = parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid separator (no DOLLAR)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
         // empty sup
         value = "( 1.1 SUP )";
         try
@@ -243,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
+            }
+        }
     }
 
 
@@ -266,17 +253,22 @@
         ocd = parser.parseObjectClassDescription( value );
         assertEquals( ObjectClassTypeEnum.ABSTRACT, ocd.getKind() );
 
-        // AUXILIARY
-        value = "( 1.1 AUXILIARY )";
+        // AUXILIARY, tab
+        value = "\t(\t1.1\tAUXILIARY\t)\t";
         ocd = parser.parseObjectClassDescription( value );
         assertEquals( ObjectClassTypeEnum.AUXILIARY, ocd.getKind() );
 
-        // STRUCTURAL
-        value = "( 1.1 STRUCTURAL )";
+        // STRUCTURAL, no space
+        value = "(1.1 STRUCTURAL)";
         ocd = parser.parseObjectClassDescription( value );
         assertEquals( ObjectClassTypeEnum.STRUCTURAL, ocd.getKind() );
 
-        // ivalid
+        // STRUCTURAL, case-insensitive
+        value = "(1.1 sTrUcTuRaL )";
+        ocd = parser.parseObjectClassDescription( value );
+        assertEquals( ObjectClassTypeEnum.STRUCTURAL, ocd.getKind() );
+
+        // invalid
         value = "( 1.1 FOO )";
         try
         {
@@ -312,8 +304,8 @@
         assertEquals( 1, ocd.getMustAttributeTypes().size() );
         assertEquals( "1.2.3", ocd.getMustAttributeTypes().get( 0 ) );
 
-        // MUST mulitple
-        value = "(1.1 MUST (cn$sn       $11.22.33.44.55         $  objectClass   ))";
+        // MUST multiple
+        value = "(1.1 MUST(cn$sn\r$11.22.33.44.55         $  objectClass   ))";
         ocd = parser.parseObjectClassDescription( value );
         assertEquals( 4, ocd.getMustAttributeTypes().size() );
         assertEquals( "cn", ocd.getMustAttributeTypes().get( 0 ) );
@@ -321,17 +313,14 @@
         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
-        }
+        // MUST multiple, no $ separator
+        value = "(1.1 MUST(cn sn\t'11.22.33.44.55'\n'objectClass'))";
+        ocd = parser.parseObjectClassDescription( value );
+        assertEquals( 4, ocd.getMustAttributeTypes().size() );
+        assertEquals( "cn", ocd.getMustAttributeTypes().get( 0 ) );
+        assertEquals( "sn", ocd.getMustAttributeTypes().get( 1 ) );
+        assertEquals( "11.22.33.44.55", ocd.getMustAttributeTypes().get( 2 ) );
+        assertEquals( "objectClass", ocd.getMustAttributeTypes().get( 3 ) );
 
         // no MUST values
         value = "( 1.1 MUST )";
@@ -344,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
+            }
+        }
     }
 
 
@@ -369,8 +373,8 @@
         assertEquals( 1, ocd.getMayAttributeTypes().size() );
         assertEquals( "1.2.3", ocd.getMayAttributeTypes().get( 0 ) );
 
-        // MAY mulitple
-        value = "(1.1 MAY (cn$sn       $11.22.33.44.55         $  objectClass   ))";
+        // MAY multiple
+        value = "(1.1 MAY(cn$sn       $11.22.33.44.55\n$  objectClass   ))";
         ocd = parser.parseObjectClassDescription( value );
         assertEquals( 4, ocd.getMayAttributeTypes().size() );
         assertEquals( "cn", ocd.getMayAttributeTypes().get( 0 ) );
@@ -378,16 +382,28 @@
         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
-        {
-            ocd = parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid value c_n" );
-        }
-        catch ( ParseException pe )
+        // MAY multiple, no $ separator, quoted
+        value = "(1.1 MAY('cn' sn\t'11.22.33.44.55'\nobjectClass))";
+        ocd = parser.parseObjectClassDescription( value );
+        assertEquals( 4, ocd.getMayAttributeTypes().size() );
+        assertEquals( "cn", ocd.getMayAttributeTypes().get( 0 ) );
+        assertEquals( "sn", ocd.getMayAttributeTypes().get( 1 ) );
+        assertEquals( "11.22.33.44.55", ocd.getMayAttributeTypes().get( 2 ) );
+        assertEquals( "objectClass", ocd.getMayAttributeTypes().get( 3 ) );
+
+        if ( !parser.isQuirksMode() )
         {
-            // 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
+            }
         }
     }
 
@@ -456,23 +472,14 @@
     public void testUniqueElements()
     {
         String[] testValues = new String[]
-            { 
-                "( 1.1 NAME 'test1' NAME 'test2' )", 
-                "( 1.1 DESC 'test1' DESC 'test2' )",
-                "( 1.1 OBSOLETE OBSOLETE )", 
-                "( 1.1 SUP test1 SUP test2 )",
-                "( 1.1 STRUCTURAL STRUCTURAL )",
-                "( 1.1 ABSTRACT ABSTRACT )",
-                "( 1.1 AUXILIARY AUXILIARY )",
-                "( 1.1 STRUCTURAL AUXILIARY AUXILIARY )",
-                "( 1.1 MUST test1 MUST test2 )",
-                "( 1.1 MAY test1 MAY test2 )",
-                "( 1.1 X-TEST 'test1' X-TEST 'test2' )" 
-            };
+            { "( 1.1 NAME 'test1' NAME 'test2' )", "( 1.1 DESC 'test1' DESC 'test2' )", "( 1.1 OBSOLETE OBSOLETE )",
+                "( 1.1 SUP test1 SUP test2 )", "( 1.1 STRUCTURAL STRUCTURAL )", "( 1.1 ABSTRACT ABSTRACT )",
+                "( 1.1 AUXILIARY AUXILIARY )", "( 1.1 STRUCTURAL AUXILIARY AUXILIARY )",
+                "( 1.1 MUST test1 MUST test2 )", "( 1.1 MAY test1 MAY test2 )", "( 1.1 X-TEST 'test1' X-TEST 'test2' )" };
         SchemaParserTestUtils.testUnique( parser, testValues );
     }
-    
-    
+
+
     /**
      * Ensure that element order is ignored
      * 
@@ -728,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[]
             {
@@ -740,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 );
+        }
+    }
+
 }



Mime
View raw message