Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleUseDescriptionSyntaxCheckerTest.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleUseDescriptionSyntaxCheckerTest.java	(Revision 0)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleUseDescriptionSyntaxCheckerTest.java	(Revision 0)
@@ -0,0 +1,88 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test cases for MatchingRuleUseDescriptionSyntaxChecker.
+ * 
+ * There are also many test cases in SchemaParserMatchingRuleUseDescriptionTest.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class MatchingRuleUseDescriptionSyntaxCheckerTest extends TestCase
+{
+    private MatchingRuleUseDescriptionSyntaxChecker checker = new MatchingRuleUseDescriptionSyntaxChecker();
+
+
+    public void testValid()
+    {
+        assertTrue( checker.isValidSyntax( ( "( 2.5.13.17 APPLIES userPassword )" ) ) );
+        assertTrue( checker.isValidSyntax( ( "( 2.5.13.17 APPLIES ( javaSerializedData $ userPassword ) )" ) ) );
+        assertTrue( checker.isValidSyntax( ( "( 2.5.13.17 NAME 'octetStringMatch' APPLIES ( javaSerializedData $ userPassword ) )" ) ) );
+        assertTrue( checker.isValidSyntax( ( "( 2.5.13.17 NAME 'octetStringMatch' DESC 'octetStringMatch' APPLIES ( javaSerializedData $ userPassword ) )" ) ) );
+        assertTrue( checker.isValidSyntax( ( "( 2.5.13.17 NAME 'octetStringMatch' DESC 'octetStringMatch' APPLIES ( javaSerializedData $ userPassword ) X-ABC-DEF 'test' )" ) ) );
+
+        // spaces
+        assertTrue( checker.isValidSyntax( ( "(2.5.13.17 APPLIES userPassword)" ) ) );
+        assertTrue( checker.isValidSyntax( ( "(   2.5.13.17   NAME   'octetStringMatch'   DESC   'octetStringMatch'   APPLIES   (javaSerializedData   $    userPassword)  X-ABC-DEF     'test'   )" ) ) );
+    }
+
+
+    public void testInvalid()
+    {
+        // null 
+        assertFalse( checker.isValidSyntax( null ) );
+        
+        // empty 
+        assertFalse( checker.isValidSyntax( "" ) );
+        
+        // missing/invalid OID
+        assertFalse( checker.isValidSyntax( "()" ) );
+        assertFalse( checker.isValidSyntax( "(  )" ) );
+        assertFalse( checker.isValidSyntax( "( . )" ) );
+        assertFalse( checker.isValidSyntax( "( 1 )" ) );
+        assertFalse( checker.isValidSyntax( "( 1. )" ) );
+        assertFalse( checker.isValidSyntax( "( 1.2. )" ) );
+        assertFalse( checker.isValidSyntax( "( 1.A )" ) );
+        assertFalse( checker.isValidSyntax( "( A.B )" ) );
+
+        // missing right parenthesis
+        assertFalse( checker.isValidSyntax( "( 2.5.13.17 APPLIES userPassword " ) );
+
+        // missing quotes
+        assertFalse( checker.isValidSyntax( "( 2.5.13.17 DESC Directory String APPLIES userPassword )" ) );
+
+        // lowercase DESC
+        assertFalse( checker.isValidSyntax( "( 2.5.13.17 desc 'Directory String' APPLIES userPassword )" ) );
+
+        // invalid extension
+        assertFalse( checker.isValidSyntax( "( 2.5.13.17 APPLIES userPassword X-ABC-DEF )" ) );
+        assertFalse( checker.isValidSyntax( "( 2.5.13.17 APPLIES userPassword X-ABC-123 'test' )" ) );
+        
+        // APPLIES is required
+        assertFalse( checker.isValidSyntax( ( "( 2.5.13.17 NAME 'octetStringMatch' )" ) ) );
+    }
+
+}
Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserMatchingRuleUseDescriptionTest.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserMatchingRuleUseDescriptionTest.java	(Revision 0)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserMatchingRuleUseDescriptionTest.java	(Revision 0)
@@ -0,0 +1,297 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import java.text.ParseException;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.shared.ldap.schema.syntax.parser.MatchingRuleUseDescriptionSchemaParser;
+
+
+/**
+ * Tests the MatchingRuleUseDescriptionSchemaParser class.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SchemaParserMatchingRuleUseDescriptionTest extends TestCase
+{
+    /** the parser instance */
+    private MatchingRuleUseDescriptionSchemaParser parser;
+
+
+    protected void setUp() throws Exception
+    {
+        parser = new MatchingRuleUseDescriptionSchemaParser();
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        parser = null;
+    }
+
+
+    public void testNumericOid() throws Exception
+    {
+        SchemaParserTestUtils.testNumericOid( parser );
+    }
+
+
+    public void testNames() throws Exception
+    {
+        SchemaParserTestUtils.testNames( parser );
+    }
+
+
+    public void testDescription() throws ParseException
+    {
+        SchemaParserTestUtils.testDescription( parser );
+    }
+
+
+    public void testObsolete() throws ParseException
+    {
+        SchemaParserTestUtils.testObsolete( parser );
+    }
+
+
+    public void testApplies() throws ParseException
+    {
+
+        String value = null;
+        MatchingRuleUseDescription mrud = null;
+
+        // no APPLIES
+        value = "( 1.1 )";
+        mrud = parser.parseMatchingRuleUseDescription( value );
+        assertEquals( 0, mrud.getApplicableAttributes().size() );
+
+        // APPLIES simple numericoid
+        value = "( 1.1 APPLIES 1.2.3.4.5.6.7.8.9.0 )";
+        mrud = parser.parseMatchingRuleUseDescription( value );
+        assertEquals( 1, mrud.getApplicableAttributes().size() );
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", mrud.getApplicableAttributes().get( 0 ) );
+
+        // SUP simple descr
+        value = "( 1.1 APPLIES abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 )";
+        mrud = parser.parseMatchingRuleUseDescription( value );
+        assertEquals( 1, mrud.getApplicableAttributes().size() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", mrud
+            .getApplicableAttributes().get( 0 ) );
+
+        // APPLIES single numericoid
+        value = "( 1.1 APPLIES ( 123.4567.890 ) )";
+        mrud = parser.parseMatchingRuleUseDescription( value );
+        assertEquals( 1, mrud.getApplicableAttributes().size() );
+        assertEquals( "123.4567.890", mrud.getApplicableAttributes().get( 0 ) );
+
+        // APPLIES single descr
+        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 ) );
+
+        // APPLIES multi numericoid
+        value = "( 1.1 APPLIES ( 1.2.3 $ 4.5.6 $ 7.8.90 ) )";
+        mrud = parser.parseMatchingRuleUseDescription( value );
+        assertEquals( 3, mrud.getApplicableAttributes().size() );
+        assertEquals( "1.2.3", mrud.getApplicableAttributes().get( 0 ) );
+        assertEquals( "4.5.6", mrud.getApplicableAttributes().get( 1 ) );
+        assertEquals( "7.8.90", mrud.getApplicableAttributes().get( 2 ) );
+
+        // APPLIES multi descr
+        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 ) );
+
+        // APPLIES multi mixed
+        value = "( 1.1 APPLIES ( test1 $ 1.2.3.4 $ test2 ) )";
+        mrud = parser.parseMatchingRuleUseDescription( value );
+        assertEquals( 3, mrud.getApplicableAttributes().size() );
+        assertEquals( "test1", mrud.getApplicableAttributes().get( 0 ) );
+        assertEquals( "1.2.3.4", mrud.getApplicableAttributes().get( 1 ) );
+        assertEquals( "test2", mrud.getApplicableAttributes().get( 2 ) );
+
+        // APPLIES multi mixed no space
+        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 ) );
+        assertEquals( "1.2.3.4", mrud.getApplicableAttributes().get( 1 ) );
+        assertEquals( "TEST-2", mrud.getApplicableAttributes().get( 2 ) );
+
+        // APPLIES multi mixed many spaces
+        value = "(          1.1          APPLIES          (          test1          $          1.2.3.4$test2          )          )";
+        mrud = parser.parseMatchingRuleUseDescription( value );
+        assertEquals( 3, mrud.getApplicableAttributes().size() );
+        assertEquals( "test1", mrud.getApplicableAttributes().get( 0 ) );
+        assertEquals( "1.2.3.4", mrud.getApplicableAttributes().get( 1 ) );
+        assertEquals( "test2", mrud.getApplicableAttributes().get( 2 ) );
+
+        // no quote allowed
+        value = "( 1.1 APPLIES 'test' )";
+        try
+        {
+            mrud = parser.parseMatchingRuleUseDescription( value );
+            fail( "Exception expected, invalid APPLIES 'test' (quoted)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // no quote allowed
+        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
+        }
+
+        // invalid character
+        value = "( 1.1 APPLIES 1.2.3.4.A )";
+        try
+        {
+            mrud = parser.parseMatchingRuleUseDescription( value );
+            fail( "Exception expected, invalid APPLIES '1.2.3.4.A' (invalid character)" );
+        }
+        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
+        }
+
+        // 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
+        {
+            mrud = parser.parseMatchingRuleUseDescription( value );
+            fail( "Exception expected, no APPLIES value" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+    }
+
+
+    public void testExtensions() throws ParseException
+    {
+        SchemaParserTestUtils.testExtensions( parser );
+    }
+
+
+    public void testFull() throws ParseException
+    {
+        String value = null;
+        MatchingRuleUseDescription mrud = null;
+
+        value = "( 1.2.3.4.5.6.7.8.9.0 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' 'test' ) DESC 'Descripton äöüß 部長' OBSOLETE APPLIES ( 0.1.2.3.4.5.6.7.8.9 $ abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 ) X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )";
+        mrud = parser.parseMatchingRuleUseDescription( value );
+
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", mrud.getNumericOid() );
+        assertEquals( 2, mrud.getNames().size() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", mrud.getNames().get( 0 ) );
+        assertEquals( "test", mrud.getNames().get( 1 ) );
+        assertEquals( "Descripton äöüß 部長", mrud.getDescription() );
+        assertTrue( mrud.isObsolete() );
+        assertEquals( 2, mrud.getApplicableAttributes().size() );
+        assertEquals( "0.1.2.3.4.5.6.7.8.9", mrud.getApplicableAttributes().get( 0 ) );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", mrud
+            .getApplicableAttributes().get( 1 ) );
+        assertEquals( 2, mrud.getExtensions().size() );
+        assertNotNull( mrud.getExtensions().get( "X-TEST-a" ) );
+        assertEquals( 2, mrud.getExtensions().get( "X-TEST-a" ).size() );
+        assertEquals( "test1-1", mrud.getExtensions().get( "X-TEST-a" ).get( 0 ) );
+        assertEquals( "test1-2", mrud.getExtensions().get( "X-TEST-a" ).get( 1 ) );
+        assertNotNull( mrud.getExtensions().get( "X-TEST-b" ) );
+        assertEquals( 2, mrud.getExtensions().get( "X-TEST-b" ).size() );
+        assertEquals( "test2-1", mrud.getExtensions().get( "X-TEST-b" ).get( 0 ) );
+        assertEquals( "test2-2", mrud.getExtensions().get( "X-TEST-b" ).get( 1 ) );
+    }
+
+
+    ////////////////////////////////////////////////////////////////
+    //       Some real-world matching rule use descriptons        //
+    ////////////////////////////////////////////////////////////////
+
+    public void testOpenldap1() throws ParseException
+    {
+        String value = "( 2.5.13.17 NAME 'octetStringMatch' APPLIES ( javaSerializedData $ userPassword ) )";
+        MatchingRuleUseDescription mrud = parser.parseMatchingRuleUseDescription( value );
+
+        assertEquals( "2.5.13.17", mrud.getNumericOid() );
+        assertEquals( 1, mrud.getNames().size() );
+        assertEquals( "octetStringMatch", mrud.getNames().get( 0 ) );
+        assertEquals( "", mrud.getDescription() );
+        assertFalse( mrud.isObsolete() );
+        assertEquals( 2, mrud.getApplicableAttributes().size() );
+        assertEquals( "javaSerializedData", mrud.getApplicableAttributes().get( 0 ) );
+        assertEquals( "userPassword", mrud.getApplicableAttributes().get( 1 ) );
+        assertEquals( 0, mrud.getExtensions().size() );
+    }
+
+
+    /**
+     * Tests the multithreaded use of a single parser.
+     */
+    public void testMultiThreaded() throws Exception
+    {
+        String[] testValues = new String[]
+            {
+                "( 1.1 )",
+                "( 2.5.13.17 NAME 'octetStringMatch' APPLIES ( javaSerializedData $ userPassword ) )",
+                "( 2.5.13.1 NAME 'distinguishedNameMatch' APPLIES ( memberOf $ dITRedirect $ associatedName $ secretary $ documentAuthor $ manager $ seeAlso $ roleOccupant $ owner $ member $ distinguishedName $ aliasedObjectName $ namingContexts $ subschemaSubentry $ modifiersName $ creatorsName ) )",
+                "( 1.2.3.4.5.6.7.8.9.0 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' 'test' ) DESC 'Descripton äöüß 部長' OBSOLETE APPLIES ( 0.1.2.3.4.5.6.7.8.9 $ abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 ) X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )" };
+        SchemaParserTestUtils.testMultiThreaded( parser, testValues );
+    }
+
+}
Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java	(Revision 487671)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java	(Arbeitskopie)
@@ -33,30 +33,8 @@
  */
 public class AttributeTypeDescriptionSyntaxCheckerTest extends TestCase
 {
-    AttributeTypeDescriptionSyntaxChecker checker = new AttributeTypeDescriptionSyntaxChecker();
+    private AttributeTypeDescriptionSyntaxChecker checker = new AttributeTypeDescriptionSyntaxChecker();
 
-
-    public void testNullString()
-    {
-        assertFalse( checker.isValidSyntax( null ) );
-    }
-
-
-    public void testEmptyString()
-    {
-        assertFalse( checker.isValidSyntax( "" ) );
-    }
-
-
-    public void testOneCharString()
-    {
-        assertFalse( checker.isValidSyntax( "A" ) );
-        assertFalse( checker.isValidSyntax( "1" ) );
-        assertFalse( checker.isValidSyntax( "-" ) );
-        assertFalse( checker.isValidSyntax( "(" ) );
-    }
-
-
     public void testValid()
     {
         assertTrue( checker.isValidSyntax( "( 2.5.4.3 NAME 'cn' SUP name )" ) );
@@ -80,12 +58,17 @@
         assertTrue( checker.isValidSyntax( "( 2.5.4.3 NAME 'cn' SUP name NO-USER-MODIFICATION USAGE dSAOperation )" ) );
         assertTrue( checker.isValidSyntax( "( 2.5.4.3 NAME 'cn' SUP name NO-USER-MODIFICATION USAGE directoryOperation )" ) );
         assertTrue( checker.isValidSyntax( "( 2.5.4.3 NAME 'cn' SUP name NO-USER-MODIFICATION USAGE distributedOperation )" ) );
-
     }
 
 
     public void testInvalid()
     {
+        // null 
+        assertFalse( checker.isValidSyntax( null ) );
+        
+        // empty 
+        assertFalse( checker.isValidSyntax( "" ) );
+        
         // missing/invalid OID
         assertFalse( checker.isValidSyntax( "()" ) );
         assertFalse( checker.isValidSyntax( "(  )" ) );
Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserAttributeTypeDescriptionTest.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserAttributeTypeDescriptionTest.java	(Revision 487671)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserAttributeTypeDescriptionTest.java	(Arbeitskopie)
@@ -21,8 +21,6 @@
 
 
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -40,10 +38,7 @@
     /** the parser instance */
     private AttributeTypeDescriptionSchemaParser parser;
 
-    /** holds multithreaded success value */
-    boolean isSuccessMultithreaded = true;
 
-
     protected void setUp() throws Exception
     {
         parser = new AttributeTypeDescriptionSchemaParser();
@@ -63,102 +58,7 @@
      */
     public void testNumericOid() throws ParseException
     {
-        String value = null;
-        AttributeTypeDescription atd = null;
-
-        // null test
-        value = null;
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, null" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // no oid
-        value = "( )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, no NUMERICOID" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // simple
-        value = "( 1.1 )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "1.1", atd.getNumericOid() );
-
-        // simple with spaces
-        value = "(          1.1          )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "1.1", atd.getNumericOid() );
-
-        // non-numeric not allowed
-        value = "( cn )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NUMERICOID top" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // to short
-        value = "( 1 )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NUMERICOID 1" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // dot only
-        value = "( . )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NUMERICOID ." );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // ends with dot
-        value = "( 1.1. )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NUMERICOID 1.1." );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // quotes not allowed
-        value = "( '1.1' )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NUMERICOID '1.1' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        SchemaParserTestUtils.testNumericOid( parser );
     }
 
 
@@ -169,151 +69,7 @@
      */
     public void testNames() throws ParseException
     {
-        String value = null;
-        AttributeTypeDescription atd = null;
-
-        // alpha
-        value = "( 1.1 NAME 'test' )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( 1, atd.getNames().size() );
-        assertEquals( "test", atd.getNames().get( 0 ) );
-
-        // alpha-num-hypen
-        value = "( 1.1 NAME 'a-z-0-9' )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( 1, atd.getNames().size() );
-        assertEquals( "a-z-0-9", atd.getNames().get( 0 ) );
-
-        // with parentheses
-        value = "( 1.1 NAME ( 'a-z-0-9' ) )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( 1, atd.getNames().size() );
-        assertEquals( "a-z-0-9", atd.getNames().get( 0 ) );
-
-        // with parentheses, without space
-        value = "( 1.1 NAME ('a-z-0-9') )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( 1, atd.getNames().size() );
-        assertEquals( "a-z-0-9", atd.getNames().get( 0 ) );
-
-        // multi with space
-        value = "( 1.1 NAME ( 'test' 'a-z-0-9' ) )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( 2, atd.getNames().size() );
-        assertEquals( "test", atd.getNames().get( 0 ) );
-        assertEquals( "a-z-0-9", atd.getNames().get( 1 ) );
-
-        // multi without space
-        value = "( 1.1 NAME ('test' 'a-z-0-9' 'givenName') )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( 3, atd.getNames().size() );
-        assertEquals( "test", atd.getNames().get( 0 ) );
-        assertEquals( "a-z-0-9", atd.getNames().get( 1 ) );
-        assertEquals( "givenName", atd.getNames().get( 2 ) );
-
-        // multi with many spaces
-        value = "(          1.1          NAME          (          'test'          'a-z-0-9'          'givenName'          )          )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( 3, atd.getNames().size() );
-        assertEquals( "test", atd.getNames().get( 0 ) );
-        assertEquals( "a-z-0-9", atd.getNames().get( 1 ) );
-        assertEquals( "givenName", atd.getNames().get( 2 ) );
-
-        // lowercase
-        value = "( 1.1 name 'test' )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, NAME is lowercase" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // unquoted
-        value = "( 1.1 NAME test )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NAME test (unquoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // start with number
-        value = "( 1.1 NAME '1test' )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NAME 1test (starts with number)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // start with hypen
-        value = "( 1.1 NAME '-test' )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NAME -test (starts with hypen)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // invalid character
-        value = "( 1.1 NAME 'te_st' )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NAME te_st (contains invalid character)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // NAM unknown
-        value = "( 1.1 NAM 'test' )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid token NAM" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // one valid, one invalid
-        value = "( 1.1 NAME ( 'test' 'te_st' ) )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NAME te_st (contains invalid character)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // no space between values
-        value = "( 1.1 NAME ( 'test''test2' ) )";
-        try
-        {
-            atd = parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid NAME values (no space between values)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        SchemaParserTestUtils.testNames( parser );
     }
 
 
@@ -324,30 +80,7 @@
      */
     public void testDescription() throws ParseException
     {
-        String value = null;
-        AttributeTypeDescription atd = null;
-
-        // simple
-        value = "(1.1 NAME 'test' DESC 'Descripton')";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "Descripton", atd.getDescription() );
-
-        // unicode
-        value = "( 1.1 NAME 'test' DESC 'Descripton äöüß 部長' )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "Descripton äöüß 部長", atd.getDescription() );
-
-        // lowercase
-        value = "( 1.1 desc 'Descripton' )";
-        try
-        {
-            parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, DESC is lowercase" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        SchemaParserTestUtils.testDescription( parser );
     }
 
 
@@ -358,40 +91,12 @@
      */
     public void testObsolete() throws ParseException
     {
-        String value = null;
-        AttributeTypeDescription atd = null;
-
-        // not obsolete
-        value = "( 1.1 NAME 'test' DESC 'Descripton' )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertFalse( atd.isObsolete() );
-
-        // obsolete
-        value = "(1.1 NAME 'test' DESC 'Descripton' OBSOLETE)";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertTrue( atd.isObsolete() );
-
-        // obsolete 
-        value = "(1.1 OBSOLETE)";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertTrue( atd.isObsolete() );
-
-        // ivalid
-        value = "(1.1 NAME 'test' DESC 'Descripton' OBSOLET )";
-        try
-        {
-            atd = parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid OBSOLETE value" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        SchemaParserTestUtils.testObsolete( parser );
     }
 
 
     /**
-     * Test SUP and its values.
+     * Test SUP and its value.
      * 
      * @throws ParseException
      */
@@ -406,14 +111,14 @@
         assertNull( atd.getSuperType() );
 
         // SUP numericoid
-        value = "( 1.1 SUP 1.2.3 )";
+        value = "( 1.1 SUP 1.2.3.4.5.6.7.8.9.0 )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "1.2.3", atd.getSuperType() );
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", atd.getSuperType() );
 
         // SUP descr
-        value = "( 1.1 SUP name )";
+        value = "( 1.1 SUP abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "name", atd.getSuperType() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", atd.getSuperType() );
 
         // no quote allowed
         value = "( 1.1 SUP 'name' )";
@@ -494,14 +199,14 @@
         assertNull( atd.getEqualityMatchingRule() );
 
         // EQUALITY numericoid
-        value = "( 1.1 EQUALITY 1.2.3 )";
+        value = "( 1.1 EQUALITY 1.2.3.4567.8.9.0 )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "1.2.3", atd.getEqualityMatchingRule() );
+        assertEquals( "1.2.3.4567.8.9.0", atd.getEqualityMatchingRule() );
 
         // EQUALITY descr
-        value = "( 1.1 EQUALITY caseExcactMatch )";
+        value = "( 1.1 EQUALITY abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "caseExcactMatch", atd.getEqualityMatchingRule() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", atd.getEqualityMatchingRule() );
 
         // no quote allowed
         value = "( 1.1 EQUALITY 'caseExcactMatch' )";
@@ -534,21 +239,21 @@
         assertNull( atd.getOrderingMatchingRule() );
 
         // EQUALITY numericoid
-        value = "( 1.1 ORDERING 1.2.3 )";
+        value = "( 1.1 ORDERING 1.2.3.4567.8.9.0 )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "1.2.3", atd.getOrderingMatchingRule() );
+        assertEquals( "1.2.3.4567.8.9.0", atd.getOrderingMatchingRule() );
 
         // EQUALITY descr
-        value = "( 1.1 ORDERING generalizedTimeOrderingMatch )";
+        value = "( 1.1 ORDERING abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "generalizedTimeOrderingMatch", atd.getOrderingMatchingRule() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", atd.getOrderingMatchingRule() );
 
         // no quote allowed
         value = "( 1.1 ORDERING 'generalizedTimeOrderingMatch' )";
         try
         {
             atd = parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid ORDERING 'caseExcactMatch' (quoted)" );
+            fail( "Exception expected, invalid ORDERING 'generalizedTimeOrderingMatch' (quoted)" );
         }
         catch ( ParseException pe )
         {
@@ -574,21 +279,22 @@
         assertNull( atd.getSubstringsMatchingRule() );
 
         // EQUALITY numericoid
-        value = "( 1.1 SUBSTR 1.2.3 )";
+        value = "( 1.1 SUBSTR 1.2.3.4567.8.9.0 )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "1.2.3", atd.getSubstringsMatchingRule() );
+        assertEquals( "1.2.3.4567.8.9.0", atd.getSubstringsMatchingRule() );
 
         // EQUALITY descr
-        value = "( 1.1 SUBSTR caseIgnoreSubstringsMatch )";
+        value = "( 1.1 SUBSTR abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "caseIgnoreSubstringsMatch", atd.getSubstringsMatchingRule() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", atd
+            .getSubstringsMatchingRule() );
 
         // no quote allowed
-        value = "( 1.1 SUBSTR 'generalizedTimeOrderingMatch' )";
+        value = "( 1.1 SUBSTR 'caseIgnoreSubstringsMatch' )";
         try
         {
             atd = parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid SUBSTR 'generalizedTimeOrderingMatch' (quoted)" );
+            fail( "Exception expected, invalid SUBSTR 'caseIgnoreSubstringsMatch' (quoted)" );
         }
         catch ( ParseException pe )
         {
@@ -614,16 +320,16 @@
         assertEquals( 0, atd.getSyntaxLength() );
 
         // SYNTAX numericoid
-        value = "( 1.1 SYNTAX 1.2.3 )";
+        value = "( 1.1 SYNTAX 1.2.3.4567.8.9.0 )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "1.2.3", atd.getSyntax() );
+        assertEquals( "1.2.3.4567.8.9.0", atd.getSyntax() );
         assertEquals( 0, atd.getSyntaxLength() );
 
         // SYNTAX numericoid and length
-        value = "( 1.1 SYNTAX 1.2.3{32} )";
+        value = "( 1.1 SYNTAX 1.2.3.4567.8.9.0{1234567890} )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( "1.2.3", atd.getSyntax() );
-        assertEquals( 32, atd.getSyntaxLength() );
+        assertEquals( "1.2.3.4567.8.9.0", atd.getSyntax() );
+        assertEquals( 1234567890, atd.getSyntaxLength() );
 
         // SYNTAX numericoid and zero length
         value = "( 1.1 SYNTAX 1.2.3{0} )";
@@ -655,12 +361,12 @@
             // expected
         }
 
-        // zero syntax
+        // leading zero in length
         value = "( 1.1 SYNTAX 1.2.3.4{01} )";
         try
         {
             atd = parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid SYNTAX 1.2.3.4{01} (leading zero length)" );
+            fail( "Exception expected, invalid SYNTAX 1.2.3.4{01} (leading zero in length)" );
         }
         catch ( ParseException pe )
         {
@@ -672,7 +378,7 @@
         try
         {
             atd = parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid SYNTAX 1.2.3.4{X} (zero length)" );
+            fail( "Exception expected, invalid SYNTAX 1.2.3.4{X} (invalid length)" );
         }
         catch ( ParseException pe )
         {
@@ -691,6 +397,18 @@
             // expected
         }
 
+        // length overflow
+        value = "( 1.1 SYNTAX 1.2.3.4{123456789012} )";
+        try
+        {
+            atd = parser.parseAttributeTypeDescription( value );
+            fail( "Exception expected, invalid SYNTAX 1.2.3.4{123456789012} (length overflow)" );
+        }
+        catch ( NumberFormatException nfe )
+        {
+            // expected
+        }
+
     }
 
 
@@ -869,35 +587,41 @@
      */
     public void testExtensions() throws ParseException
     {
+        SchemaParserTestUtils.testExtensions( parser );
+    }
+
+
+    /**
+     * Test full attribute type description.
+     * 
+     * @throws ParseException
+     */
+    public void testFull() throws ParseException
+    {
         String value = null;
         AttributeTypeDescription atd = null;
 
-        // no extension
-        value = "( 1.1 )";
+        value = "( 1.2.3.4.5.6.7.8.9.0 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' 'test' ) DESC 'Descripton äöüß 部長' OBSOLETE SUP abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 EQUALITY 2.3.4.5.6.7.8.9.0.1 ORDERING 3.4.5.6.7.8.9.0.1.2 SUBSTR 4.5.6.7.8.9.0.1.2.3 SYNTAX 5.6.7.8.9.0.1.2.3.4{1234567890} SINGLE-VALUE COLLECTIVE NO-USER-MODIFICATION USAGE dSAOperation X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )";
         atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( 0, atd.getExtensions().size() );
 
-        // single extension with one value
-        value = "( 1.1 X-TEST 'test' )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( 1, atd.getExtensions().size() );
-        assertNotNull( atd.getExtensions().get( "X-TEST" ) );
-        assertEquals( 1, atd.getExtensions().get( "X-TEST" ).size() );
-        assertEquals( "test", atd.getExtensions().get( "X-TEST" ).get( 0 ) );
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", atd.getNumericOid() );
+        assertEquals( 2, atd.getNames().size() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", atd.getNames().get( 0 ) );
+        assertEquals( "test", atd.getNames().get( 1 ) );
+        assertEquals( "Descripton äöüß 部長", atd.getDescription() );
+        assertTrue( atd.isObsolete() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", atd.getSuperType() );
+        assertEquals( "2.3.4.5.6.7.8.9.0.1", atd.getEqualityMatchingRule() );
+        assertEquals( "3.4.5.6.7.8.9.0.1.2", atd.getOrderingMatchingRule() );
+        assertEquals( "4.5.6.7.8.9.0.1.2.3", atd.getSubstringsMatchingRule() );
+        assertEquals( "5.6.7.8.9.0.1.2.3.4", atd.getSyntax() );
+        assertEquals( 1234567890, atd.getSyntaxLength() );
 
-        // single extension with multiple values
-        value = "( 1.1 X-TEST-ABC ('test1' 'test äöüß'       'test 部長' ) )";
-        atd = parser.parseAttributeTypeDescription( value );
-        assertEquals( 1, atd.getExtensions().size() );
-        assertNotNull( atd.getExtensions().get( "X-TEST-ABC" ) );
-        assertEquals( 3, atd.getExtensions().get( "X-TEST-ABC" ).size() );
-        assertEquals( "test1", atd.getExtensions().get( "X-TEST-ABC" ).get( 0 ) );
-        assertEquals( "test äöüß", atd.getExtensions().get( "X-TEST-ABC" ).get( 1 ) );
-        assertEquals( "test 部長", atd.getExtensions().get( "X-TEST-ABC" ).get( 2 ) );
+        assertTrue( atd.isSingleValued() );
+        assertTrue( atd.isCollective() );
+        assertFalse( atd.isUserModifiable() );
+        assertEquals( UsageEnum.DSA_OPERATION, atd.getUsage() );
 
-        // multiple extensions
-        value = "(1.1 X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2'))";
-        atd = parser.parseAttributeTypeDescription( value );
         assertEquals( 2, atd.getExtensions().size() );
         assertNotNull( atd.getExtensions().get( "X-TEST-a" ) );
         assertEquals( 2, atd.getExtensions().get( "X-TEST-a" ).size() );
@@ -907,22 +631,14 @@
         assertEquals( 2, atd.getExtensions().get( "X-TEST-b" ).size() );
         assertEquals( "test2-1", atd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
         assertEquals( "test2-2", atd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
-
-        // invalid extension, no number allowed
-        value = "( 1.1 X-TEST1 'test' )";
-        try
-        {
-            atd = parser.parseAttributeTypeDescription( value );
-            fail( "Exception expected, invalid extension X-TEST1 (no number allowed)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
     }
 
 
+    /**
+     * Ensure that element order is ignored
+     * 
+     * @throws ParseException
+     */
     public void testIgnoreElementOrder() throws ParseException
     {
         String value = "( 2.5.4.3 SUP name SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE userApplications DESC 'RFC2256: common name(s) for which the entity is known by'  EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch NAME ( 'cn' 'commonName' )  )";
@@ -979,77 +695,14 @@
      */
     public void testMultiThreaded() throws Exception
     {
-        // start up and track all threads (40 threads)
-        List<Thread> threads = new ArrayList<Thread>();
-        for ( int ii = 0; ii < 10; ii++ )
-        {
-            Thread t0 = new Thread( new ParseSpecification( "( 1.1 )" ) );
-            Thread t1 = new Thread(
-                new ParseSpecification(
-                    "( 2.5.4.41 NAME 'name' DESC 'RFC2256: common supertype of name attributes'  EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} USAGE userApplications )" ) );
-            Thread t2 = new Thread(
-                new ParseSpecification(
-                    "( 2.5.4.3 NAME ( 'cn' 'commonName' ) DESC 'RFC2256: common name(s) for which the entity is known by'  SUP name EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE userApplications )" ) );
-            Thread t3 = new Thread(
-                new ParseSpecification(
-                    "( 2.5.18.3 NAME 'creatorsName' DESC 'RFC2252: name of creator'  EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )" ) );
-            threads.add( t0 );
-            threads.add( t1 );
-            threads.add( t2 );
-            threads.add( t3 );
-            t0.start();
-            t1.start();
-            t2.start();
-            t3.start();
-        }
-
-        // wait until all threads have died
-        boolean hasLiveThreads = false;
-        do
-        {
-            hasLiveThreads = false;
-
-            for ( int ii = 0; ii < threads.size(); ii++ )
+        String[] testValues = new String[]
             {
-                Thread t = ( Thread ) threads.get( ii );
-                hasLiveThreads = hasLiveThreads || t.isAlive();
-            }
-        }
-        while ( hasLiveThreads );
+                "( 1.1 )",
+                "( 2.5.4.41 NAME 'name' DESC 'RFC2256: common supertype of name attributes'  EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} USAGE userApplications )",
+                "( 2.5.4.3 NAME ( 'cn' 'commonName' ) DESC 'RFC2256: common name(s) for which the entity is known by'  SUP name EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE userApplications )",
+                "( 1.2.3.4.5.6.7.8.9.0 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' 'test' ) DESC 'Descripton äöüß 部長' OBSOLETE SUP abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 EQUALITY 2.3.4.5.6.7.8.9.0.1 ORDERING 3.4.5.6.7.8.9.0.1.2 SUBSTR 4.5.6.7.8.9.0.1.2.3 SYNTAX 5.6.7.8.9.0.1.2.3.4{1234567890} SINGLE-VALUE COLLECTIVE NO-USER-MODIFICATION USAGE dSAOperation X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )" };
+        SchemaParserTestUtils.testMultiThreaded( parser, testValues );
 
-        // check that no one thread failed to parse and generate a SS object
-        assertTrue( isSuccessMultithreaded );
     }
 
-    /**
-     * Used to test multithreaded use of a single parser.
-     */
-    class ParseSpecification implements Runnable
-    {
-        private final String atd;
-
-        AttributeTypeDescription result;
-
-
-        public ParseSpecification( String atd )
-        {
-            this.atd = atd;
-        }
-
-
-        public void run()
-        {
-            try
-            {
-                result = parser.parseAttributeTypeDescription( atd );
-            }
-            catch ( ParseException e )
-            {
-                e.printStackTrace();
-            }
-
-            isSuccessMultithreaded = isSuccessMultithreaded && ( result != null );
-        }
-    }
-
 }
Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleDescriptionSyntaxCheckerTest.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleDescriptionSyntaxCheckerTest.java	(Revision 0)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleDescriptionSyntaxCheckerTest.java	(Revision 0)
@@ -0,0 +1,87 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test cases for MatchingRuleDescriptionSyntaxChecker.
+ * 
+ * There are also many test cases in SchemaParserMatchingRuleDescriptionTest.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class MatchingRuleDescriptionSyntaxCheckerTest extends TestCase
+{
+    private MatchingRuleDescriptionSyntaxChecker checker = new MatchingRuleDescriptionSyntaxChecker();
+
+    public void testValid()
+    {
+        assertTrue( checker.isValidSyntax( ( "( 2.5.13.5 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )" ) ) );
+        assertTrue( checker.isValidSyntax( ( "( 2.5.13.5 NAME 'caseExactMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )" ) ) );
+        assertTrue( checker.isValidSyntax( ( "( 2.5.13.5 NAME 'caseExactMatch' DESC 'caseExactMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )" ) ) );
+        assertTrue( checker.isValidSyntax( ( "( 2.5.13.5 NAME 'caseExactMatch' DESC 'caseExactMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ABC-DEF 'test' )" ) ) );
+
+        // spaces
+        assertTrue( checker.isValidSyntax( "(2.5.13.5 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15)" ) );
+        assertTrue( checker.isValidSyntax( "(    2.5.13.5     NAME    'caseExactMatch'     DESC    'caseExactMatch'      SYNTAX       1.3.6.1.4.1.1466.115.121.1.15     X-ABC-DEF     'test')" ) );
+    }
+
+
+    public void testInvalid()
+    {
+        // null 
+        assertFalse( checker.isValidSyntax( null ) );
+        
+        // empty 
+        assertFalse( checker.isValidSyntax( "" ) );
+        
+        // missing/invalid OID
+        assertFalse( checker.isValidSyntax( "()" ) );
+        assertFalse( checker.isValidSyntax( "(  )" ) );
+        assertFalse( checker.isValidSyntax( "( . )" ) );
+        assertFalse( checker.isValidSyntax( "( 1 )" ) );
+        assertFalse( checker.isValidSyntax( "( 1. )" ) );
+        assertFalse( checker.isValidSyntax( "( 1.2. )" ) );
+        assertFalse( checker.isValidSyntax( "( 1.A )" ) );
+        assertFalse( checker.isValidSyntax( "( A.B )" ) );
+
+        // missing right parenthesis
+        assertFalse( checker.isValidSyntax( "( 2.5.13.5 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " ) );
+
+        // missing quotes
+        assertFalse( checker.isValidSyntax( "( 2.5.13.5 DESC Description SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )" ) );
+
+        // lowercase DESC
+        assertFalse( checker.isValidSyntax( "( 2.5.13.5 desc 'Directory String' )" ) );
+
+        // invalid extension
+        assertFalse( checker.isValidSyntax( "( 2.5.13.5 DESC 'Description' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ABC-DEF )" ) );
+        assertFalse( checker.isValidSyntax( "( 2.5.13.5 DESC 'Description' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ABC-123 'test' )" ) );
+        
+        // SYNTAX is required
+        assertFalse( checker.isValidSyntax( "( 2.5.13.5 NAME 'caseExactMatch' )" ) );
+
+    }
+
+}
Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserMatchingRuleDescriptionTest.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserMatchingRuleDescriptionTest.java	(Revision 0)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserMatchingRuleDescriptionTest.java	(Revision 0)
@@ -0,0 +1,213 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import java.text.ParseException;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.shared.ldap.schema.syntax.parser.MatchingRuleDescriptionSchemaParser;
+
+
+/**
+ * Tests the MatchingRuleDescriptionSchemaParser class.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SchemaParserMatchingRuleDescriptionTest extends TestCase
+{
+    /** the parser instance */
+    private MatchingRuleDescriptionSchemaParser parser;
+
+    protected void setUp() throws Exception
+    {
+        parser = new MatchingRuleDescriptionSchemaParser();
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        parser = null;
+    }
+
+
+    public void testNumericOid() throws Exception
+    {
+        SchemaParserTestUtils.testNumericOid( parser );
+    }
+
+
+    public void testNames() throws Exception
+    {
+        SchemaParserTestUtils.testNames( parser );
+    }
+
+
+    public void testDescription() throws ParseException
+    {
+        SchemaParserTestUtils.testDescription( parser );
+    }
+
+
+    public void testObsolete() throws ParseException
+    {
+        SchemaParserTestUtils.testObsolete( parser );
+    }
+
+
+    public void testSyntax() throws ParseException
+    {
+
+        String value = null;
+        MatchingRuleDescription mrd = null;
+
+        // simple
+        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() );
+
+        // simple
+        value = "( 1.1 SYNTAX 123.456.789.0 )";
+        mrd = parser.parseMatchingRuleDescription( value );
+        assertEquals( "123.456.789.0", mrd.getSyntax() );
+
+        // simple with spaces
+        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() );
+
+        // non-numeric not allowed
+        value = "( test )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid SYNTAX test" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+    }
+
+
+    public void testExtensions() throws ParseException
+    {
+        SchemaParserTestUtils.testExtensions( parser );
+    }
+
+
+    public void testFull() throws ParseException
+    {
+        String value = null;
+        MatchingRuleDescription mrd = null;
+
+        value = "( 1.2.3.4.5.6.7.8.9.0 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' 'test' ) DESC 'Descripton äöüß 部長' OBSOLETE SYNTAX 0.1.2.3.4.5.6.7.8.9 X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )";
+        mrd = parser.parseMatchingRuleDescription( value );
+
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", mrd.getNumericOid() );
+        assertEquals( 2, mrd.getNames().size() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", mrd.getNames().get( 0 ) );
+        assertEquals( "test", mrd.getNames().get( 1 ) );
+        assertEquals( "Descripton äöüß 部長", mrd.getDescription() );
+        assertTrue( mrd.isObsolete() );
+        assertEquals( "0.1.2.3.4.5.6.7.8.9", mrd.getSyntax() );
+        assertEquals( 2, mrd.getExtensions().size() );
+        assertNotNull( mrd.getExtensions().get( "X-TEST-a" ) );
+        assertEquals( 2, mrd.getExtensions().get( "X-TEST-a" ).size() );
+        assertEquals( "test1-1", mrd.getExtensions().get( "X-TEST-a" ).get( 0 ) );
+        assertEquals( "test1-2", mrd.getExtensions().get( "X-TEST-a" ).get( 1 ) );
+        assertNotNull( mrd.getExtensions().get( "X-TEST-b" ) );
+        assertEquals( 2, mrd.getExtensions().get( "X-TEST-b" ).size() );
+        assertEquals( "test2-1", mrd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
+        assertEquals( "test2-2", mrd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
+    }
+
+
+    ////////////////////////////////////////////////////////////////
+    //         Some real-world matching rule descriptons          //
+    ////////////////////////////////////////////////////////////////
+
+    public void testRfc1() throws ParseException
+    {
+        String value = "( 2.5.13.5 NAME 'caseExactMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )";
+        MatchingRuleDescription mrd = parser.parseMatchingRuleDescription( value );
+
+        assertEquals( "2.5.13.5", mrd.getNumericOid() );
+        assertEquals( 1, mrd.getNames().size() );
+        assertEquals( "caseExactMatch", mrd.getNames().get( 0 ) );
+        assertEquals( "", mrd.getDescription() );
+        assertFalse( mrd.isObsolete() );
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", mrd.getSyntax() );
+        assertEquals( 0, mrd.getExtensions().size() );
+    }
+
+
+    public void testSun1() throws ParseException
+    {
+        String value = "( 2.5.13.5 NAME 'caseExactMatch' DESC 'Case Exact Matching on Directory String [defined in X.520]' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )";
+        MatchingRuleDescription mrd = parser.parseMatchingRuleDescription( value );
+
+        assertEquals( "2.5.13.5", mrd.getNumericOid() );
+        assertEquals( 1, mrd.getNames().size() );
+        assertEquals( "caseExactMatch", mrd.getNames().get( 0 ) );
+        assertEquals( "Case Exact Matching on Directory String [defined in X.520]", mrd.getDescription() );
+        assertFalse( mrd.isObsolete() );
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", mrd.getSyntax() );
+        assertEquals( 0, mrd.getExtensions().size() );
+    }
+
+
+    /**
+     * 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() 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
+        {
+            parser.parseMatchingRuleDescription( value );
+            TestCase
+                .fail( "Exception expected, invalid NAME value 'caseExactSubstringMatch-2.16.840.1.113730.3.3.2.11.3' (contains DOTs)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+    }
+
+
+    /**
+     * Tests the multithreaded use of a single parser.
+     */
+    public void testMultiThreaded() throws Exception
+    {
+        String[] testValues = new String[]
+            {
+                "( 1.1 )",
+                "( 2.5.13.5 NAME 'caseExactMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
+                "( 2.5.13.5 NAME 'caseExactMatch' DESC 'Case Exact Matching on Directory String [defined in X.520]' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
+                "( 1.2.3.4.5.6.7.8.9.0 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' 'test' ) DESC 'Descripton äöüß 部長' OBSOLETE SYNTAX 0.1.2.3.4.5.6.7.8.9 X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )" };
+        SchemaParserTestUtils.testMultiThreaded( parser, testValues );
+    }
+
+}
Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescriptionSyntaxCheckerTest.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescriptionSyntaxCheckerTest.java	(Revision 487671)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescriptionSyntaxCheckerTest.java	(Arbeitskopie)
@@ -33,30 +33,9 @@
  */
 public class LdapSyntaxDescriptionSyntaxCheckerTest extends TestCase
 {
-    LdapSyntaxDescriptionSyntaxChecker checker = new LdapSyntaxDescriptionSyntaxChecker();
+    private LdapSyntaxDescriptionSyntaxChecker checker = new LdapSyntaxDescriptionSyntaxChecker();
 
 
-    public void testNullString()
-    {
-        assertFalse( checker.isValidSyntax( null ) );
-    }
-
-
-    public void testEmptyString()
-    {
-        assertFalse( checker.isValidSyntax( "" ) );
-    }
-
-
-    public void testOneCharString()
-    {
-        assertFalse( checker.isValidSyntax( "A" ) );
-        assertFalse( checker.isValidSyntax( "1" ) );
-        assertFalse( checker.isValidSyntax( "-" ) );
-        assertFalse( checker.isValidSyntax( "(" ) );
-    }
-
-
     public void testValid()
     {
         assertTrue( checker.isValidSyntax( ( "( 1.3.6.1.4.1.1466.115.121.1.15 )" ) ) );
@@ -72,6 +51,12 @@
 
     public void testInvalid()
     {
+        // null 
+        assertFalse( checker.isValidSyntax( null ) );
+        
+        // empty 
+        assertFalse( checker.isValidSyntax( "" ) );
+        
         // missing/invalid OID
         assertFalse( checker.isValidSyntax( "()" ) );
         assertFalse( checker.isValidSyntax( "(  )" ) );
Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserLdapSyntaxDescriptionTest.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserLdapSyntaxDescriptionTest.java	(Revision 487671)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserLdapSyntaxDescriptionTest.java	(Arbeitskopie)
@@ -21,8 +21,6 @@
 
 
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -39,10 +37,7 @@
     /** the parser instance */
     private LdapSyntaxDescriptionSchemaParser parser;
 
-    /** holds multithreaded success value */
-    boolean isSuccessMultithreaded = true;
 
-
     protected void setUp() throws Exception
     {
         parser = new LdapSyntaxDescriptionSchemaParser();
@@ -62,115 +57,7 @@
      */
     public void testNumericOid() throws ParseException
     {
-        String value = null;
-        LdapSyntaxDescription lsd = null;
-
-        // null test
-        value = null;
-        try
-        {
-            parser.parseLdapSyntaxDescription( value );
-            fail( "Exception expected, null" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // no oid
-        value = "( )";
-        try
-        {
-            parser.parseLdapSyntaxDescription( value );
-            fail( "Exception expected, no NUMERICOID" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // simple
-        value = "( 1.1 )";
-        lsd = parser.parseLdapSyntaxDescription( value );
-        assertEquals( "1.1", lsd.getNumericOid() );
-
-        // simple with spaces
-        value = "(          1.1          )";
-        lsd = parser.parseLdapSyntaxDescription( value );
-        assertEquals( "1.1", lsd.getNumericOid() );
-
-        // non-numeric not allowed
-        value = "( cn )";
-        try
-        {
-            parser.parseLdapSyntaxDescription( value );
-            fail( "Exception expected, invalid NUMERICOID top" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // to short
-        value = "( 1 )";
-        try
-        {
-            parser.parseLdapSyntaxDescription( value );
-            fail( "Exception expected, invalid NUMERICOID 1" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // dot only
-        value = "( . )";
-        try
-        {
-            parser.parseLdapSyntaxDescription( value );
-            fail( "Exception expected, invalid NUMERICOID ." );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // ends with dot
-        value = "( 1.1. )";
-        try
-        {
-            parser.parseLdapSyntaxDescription( value );
-            fail( "Exception expected, invalid NUMERICOID 1.1." );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // quotes not allowed
-        value = "( '1.1' )";
-        try
-        {
-            parser.parseLdapSyntaxDescription( value );
-            fail( "Exception expected, invalid NUMERICOID '1.1' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // leading 0 not allowed
-        value = "( 01.1 )";
-        try
-        {
-            parser.parseLdapSyntaxDescription( value );
-            fail( "Exception expected, invalid NUMERICOID 01.1 (leading zero)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
+        SchemaParserTestUtils.testNumericOid( parser );
     }
 
 
@@ -181,30 +68,7 @@
      */
     public void testDescription() throws ParseException
     {
-        String value = null;
-        LdapSyntaxDescription lsd = null;
-
-        // simple
-        value = "(1.1 DESC 'Descripton')";
-        lsd = parser.parseLdapSyntaxDescription( value );
-        assertEquals( "Descripton", lsd.getDescription() );
-
-        // unicode
-        value = "( 1.1 DESC 'Descripton äöüß 部長' )";
-        lsd = parser.parseLdapSyntaxDescription( value );
-        assertEquals( "Descripton äöüß 部長", lsd.getDescription() );
-
-        // lowercase
-        value = "( 1.1 desc 'Descripton' )";
-        try
-        {
-            parser.parseLdapSyntaxDescription( value );
-            fail( "Exception expected, DESC is lowercase" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        SchemaParserTestUtils.testDescription( parser );
     }
 
 
@@ -215,35 +79,25 @@
      */
     public void testExtensions() throws ParseException
     {
+        SchemaParserTestUtils.testExtensions( parser );
+    }
+
+
+    /**
+     * Test full sytax description.
+     * 
+     * @throws ParseException
+     */
+    public void testFull() throws ParseException
+    {
         String value = null;
         LdapSyntaxDescription lsd = null;
 
-        // no extension
-        value = "( 1.1 )";
+        value = "( 1.2.3.4.5.6.7.8.9.0 DESC 'Descripton äöüß 部長' X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )";
         lsd = parser.parseLdapSyntaxDescription( value );
-        assertEquals( 0, lsd.getExtensions().size() );
 
-        // single extension with one value
-        value = "( 1.1 X-TEST 'test' )";
-        lsd = parser.parseLdapSyntaxDescription( value );
-        assertEquals( 1, lsd.getExtensions().size() );
-        assertNotNull( lsd.getExtensions().get( "X-TEST" ) );
-        assertEquals( 1, lsd.getExtensions().get( "X-TEST" ).size() );
-        assertEquals( "test", lsd.getExtensions().get( "X-TEST" ).get( 0 ) );
-
-        // single extension with multiple values
-        value = "( 1.1 X-TEST-ABC ('test1' 'test äöüß'       'test 部長' ) )";
-        lsd = parser.parseLdapSyntaxDescription( value );
-        assertEquals( 1, lsd.getExtensions().size() );
-        assertNotNull( lsd.getExtensions().get( "X-TEST-ABC" ) );
-        assertEquals( 3, lsd.getExtensions().get( "X-TEST-ABC" ).size() );
-        assertEquals( "test1", lsd.getExtensions().get( "X-TEST-ABC" ).get( 0 ) );
-        assertEquals( "test äöüß", lsd.getExtensions().get( "X-TEST-ABC" ).get( 1 ) );
-        assertEquals( "test 部長", lsd.getExtensions().get( "X-TEST-ABC" ).get( 2 ) );
-
-        // multiple extensions
-        value = "(1.1 X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2'))";
-        lsd = parser.parseLdapSyntaxDescription( value );
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", lsd.getNumericOid() );
+        assertEquals( "Descripton äöüß 部長", lsd.getDescription() );
         assertEquals( 2, lsd.getExtensions().size() );
         assertNotNull( lsd.getExtensions().get( "X-TEST-a" ) );
         assertEquals( 2, lsd.getExtensions().get( "X-TEST-a" ).size() );
@@ -254,18 +108,6 @@
         assertEquals( "test2-1", lsd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
         assertEquals( "test2-2", lsd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
 
-        // invalid extension, no number allowed
-        value = "( 1.1 X-TEST1 'test' )";
-        try
-        {
-            lsd = parser.parseLdapSyntaxDescription( value );
-            fail( "Exception expected, invalid extension X-TEST1 (no number allowed)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
     }
 
 
@@ -292,72 +134,13 @@
      */
     public void testMultiThreaded() throws Exception
     {
-        // start up and track all threads (40 threads)
-        List<Thread> threads = new ArrayList<Thread>();
-        for ( int ii = 0; ii < 10; ii++ )
-        {
-            Thread t0 = new Thread( new ParseSpecification( "( 1.1 )" ) );
-            Thread t1 = new Thread( new ParseSpecification(
-                "( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' X-NOT-HUMAN-READABLE 'TRUE' )" ) );
-            Thread t2 = new Thread( new ParseSpecification( "( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )" ) );
-            Thread t3 = new Thread( new ParseSpecification( "( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )" ) );
-            threads.add( t0 );
-            threads.add( t1 );
-            threads.add( t2 );
-            threads.add( t3 );
-            t0.start();
-            t1.start();
-            t2.start();
-            t3.start();
-        }
-
-        // wait until all threads have died
-        boolean hasLiveThreads = false;
-        do
-        {
-            hasLiveThreads = false;
-
-            for ( int ii = 0; ii < threads.size(); ii++ )
-            {
-                Thread t = ( Thread ) threads.get( ii );
-                hasLiveThreads = hasLiveThreads || t.isAlive();
-            }
-        }
-        while ( hasLiveThreads );
-
-        // check that no one thread failed to parse and generate a SS object
-        assertTrue( isSuccessMultithreaded );
+        String[] testValues = new String[]
+            { 
+                "( 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 äöüß 部長' X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )" };
+        SchemaParserTestUtils.testMultiThreaded( parser, testValues );
     }
 
-    /**
-     * Used to test multithreaded use of a single parser.
-     */
-    class ParseSpecification implements Runnable
-    {
-        private final String lsd;
-
-        LdapSyntaxDescription result;
-
-
-        public ParseSpecification( String lsd )
-        {
-            this.lsd = lsd;
-        }
-
-
-        public void run()
-        {
-            try
-            {
-                result = parser.parseLdapSyntaxDescription( lsd );
-            }
-            catch ( ParseException e )
-            {
-                e.printStackTrace();
-            }
-
-            isSuccessMultithreaded = isSuccessMultithreaded && ( result != null );
-        }
-    }
-
 }
Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java	(Revision 487671)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java	(Arbeitskopie)
@@ -33,30 +33,8 @@
  */
 public class ObjectClassDescriptionSyntaxCheckerTest extends TestCase
 {
-    ObjectClassDescriptionSyntaxChecker checker = new ObjectClassDescriptionSyntaxChecker();
+    private ObjectClassDescriptionSyntaxChecker checker = new ObjectClassDescriptionSyntaxChecker();
 
-
-    public void testNullString()
-    {
-        assertFalse( checker.isValidSyntax( null ) );
-    }
-
-
-    public void testEmptyString()
-    {
-        assertFalse( checker.isValidSyntax( "" ) );
-    }
-
-
-    public void testOneCharString()
-    {
-        assertFalse( checker.isValidSyntax( "A" ) );
-        assertFalse( checker.isValidSyntax( "1" ) );
-        assertFalse( checker.isValidSyntax( "-" ) );
-        assertFalse( checker.isValidSyntax( "(" ) );
-    }
-
-
     public void testValid()
     {
         assertTrue( checker.isValidSyntax( "( 2.5.6.6 )" ) );
@@ -74,6 +52,12 @@
 
     public void testInvalid()
     {
+        // null 
+        assertFalse( checker.isValidSyntax( null ) );
+        
+        // empty 
+        assertFalse( checker.isValidSyntax( "" ) );
+        
         // missing/invalid OID
         assertFalse( checker.isValidSyntax( "()" ) );
         assertFalse( checker.isValidSyntax( "(  )" ) );
Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserObjectClassDescriptionTest.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserObjectClassDescriptionTest.java	(Revision 487671)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserObjectClassDescriptionTest.java	(Arbeitskopie)
@@ -21,13 +21,10 @@
 
 
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
 
 import junit.framework.TestCase;
 
 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
-import org.apache.directory.shared.ldap.schema.syntax.ObjectClassDescription;
 import org.apache.directory.shared.ldap.schema.syntax.parser.ObjectClassDescriptionSchemaParser;
 
 
@@ -41,10 +38,7 @@
     /** the parser instance */
     private ObjectClassDescriptionSchemaParser parser;
 
-    /** holds multithreaded success value */
-    boolean isSuccessMultithreaded = true;
 
-
     protected void setUp() throws Exception
     {
         parser = new ObjectClassDescriptionSchemaParser();
@@ -64,119 +58,7 @@
      */
     public void testNumericOid() throws ParseException
     {
-        String value = null;
-        ObjectClassDescription ocd = null;
-
-        // null test
-        value = null;
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, null" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // no oid
-        value = "( )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, no NUMERICOID" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // simple
-        value = "( 1.1 )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( "1.1", ocd.getNumericOid() );
-
-        // simple
-        value = "( 0.0 )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( "0.0", ocd.getNumericOid() );
-        
-        // simple with spaces
-        value = "(          1.1          )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( "1.1", ocd.getNumericOid() );
-
-        // non-numeric not allowed
-        value = "( top )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NUMERICOID top" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // to short
-        value = "( 1 )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NUMERICOID 1" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // dot only
-        value = "( . )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NUMERICOID ." );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // ends with dot
-        value = "( 1.1. )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NUMERICOID 1.1." );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // quotes not allowed
-        value = "( '1.1' )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NUMERICOID '1.1' (quoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-        
-        // leading 0
-        value = "( 01.1 )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NUMERICOID 01.1." );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        SchemaParserTestUtils.testNumericOid( parser );
     }
 
 
@@ -187,151 +69,7 @@
      */
     public void testNames() throws ParseException
     {
-        String value = null;
-        ObjectClassDescription ocd = null;
-
-        // alpha
-        value = "( 1.1 NAME 'test' )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( 1, ocd.getNames().size() );
-        assertEquals( "test", ocd.getNames().get( 0 ) );
-
-        // alpha-num-hypen
-        value = "( 1.1 NAME 'a-z-0-9' )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( 1, ocd.getNames().size() );
-        assertEquals( "a-z-0-9", ocd.getNames().get( 0 ) );
-
-        // with parentheses
-        value = "( 1.1 NAME ( 'a-z-0-9' ) )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( 1, ocd.getNames().size() );
-        assertEquals( "a-z-0-9", ocd.getNames().get( 0 ) );
-
-        // with parentheses, without space
-        value = "( 1.1 NAME ('a-z-0-9') )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( 1, ocd.getNames().size() );
-        assertEquals( "a-z-0-9", ocd.getNames().get( 0 ) );
-
-        // multi with space
-        value = "( 1.1 NAME ( 'test' 'a-z-0-9' ) )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( 2, ocd.getNames().size() );
-        assertEquals( "test", ocd.getNames().get( 0 ) );
-        assertEquals( "a-z-0-9", ocd.getNames().get( 1 ) );
-
-        // multi without space
-        value = "( 1.1 NAME ('test' 'a-z-0-9' 'top') )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( 3, ocd.getNames().size() );
-        assertEquals( "test", ocd.getNames().get( 0 ) );
-        assertEquals( "a-z-0-9", ocd.getNames().get( 1 ) );
-        assertEquals( "top", ocd.getNames().get( 2 ) );
-
-        // multi with many spaces
-        value = "(          1.1          NAME          (          'test'          'a-z-0-9'          'top'          )          )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( 3, ocd.getNames().size() );
-        assertEquals( "test", ocd.getNames().get( 0 ) );
-        assertEquals( "a-z-0-9", ocd.getNames().get( 1 ) );
-        assertEquals( "top", ocd.getNames().get( 2 ) );
-
-        // lowercase
-        value = "( 1.1 name 'test' )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, NAME is lowercase" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // unquoted
-        value = "( 1.1 NAME test )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NAME test (unquoted)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // start with number
-        value = "( 1.1 NAME '1test' )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NAME 1test (starts with number)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // start with hypen
-        value = "( 1.1 NAME '-test' )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NAME -test (starts with hypen)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // invalid character
-        value = "( 1.1 NAME 'te_st' )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NAME te_st (contains invalid character)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // NAM unknown
-        value = "( 1.1 NAM 'test' )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid token NAM" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // one valid, one invalid
-        value = "( 1.1 NAME ( 'test' 'te_st' ) )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NAME te_st (contains invalid character)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
-        // no space between values
-        value = "( 1.1 NAME ( 'test''test2' ) )";
-        try
-        {
-            ocd = parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid NAME values (no space between values)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        SchemaParserTestUtils.testNames( parser );
     }
 
 
@@ -342,30 +80,7 @@
      */
     public void testDescription() throws ParseException
     {
-        String value = null;
-        ObjectClassDescription ocd = null;
-
-        // simple
-        value = "(1.1 NAME 'test' DESC 'Descripton')";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( "Descripton", ocd.getDescription() );
-
-        // unicode
-        value = "( 1.1 NAME 'test' DESC 'Descripton äöüß 部長' )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( "Descripton äöüß 部長", ocd.getDescription() );
-
-        // lowercase
-        value = "( 1.1 desc 'Descripton' )";
-        try
-        {
-            parser.parseObjectClassDescription( value );
-            fail( "Exception expected, DESC is lowercase" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        SchemaParserTestUtils.testDescription( parser );
     }
 
 
@@ -376,30 +91,7 @@
      */
     public void testObsolete() throws ParseException
     {
-        String value = null;
-        ObjectClassDescription ocd = null;
-
-        // not obsolete
-        value = "( 1.1 NAME 'test' DESC 'Descripton' )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertFalse( ocd.isObsolete() );
-
-        // obsolete
-        value = "(1.1 NAME 'test' DESC 'Descripton' OBSOLETE)";
-        ocd = parser.parseObjectClassDescription( value );
-        assertTrue( ocd.isObsolete() );
-
-        // ivalid
-        value = "(1.1 NAME 'test' DESC 'Descripton' OBSOLET )";
-        try
-        {
-            ocd = parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid OBSOLETE value" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
+        SchemaParserTestUtils.testObsolete( parser );
     }
 
 
@@ -707,35 +399,43 @@
      */
     public void testExtensions() throws ParseException
     {
-        String value = null;
-        ObjectClassDescription ocd = null;
+        SchemaParserTestUtils.testExtensions( parser );
 
-        // no extension
-        value = "( 1.1 )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( 0, ocd.getExtensions().size() );
+    }
 
-        // single extension with one value
-        value = "( 1.1 X-TEST 'test' )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( 1, ocd.getExtensions().size() );
-        assertNotNull( ocd.getExtensions().get( "X-TEST" ) );
-        assertEquals( 1, ocd.getExtensions().get( "X-TEST" ).size() );
-        assertEquals( "test", ocd.getExtensions().get( "X-TEST" ).get( 0 ) );
 
-        // single extension with multiple values
-        value = "( 1.1 X-TEST-ABC ('test1' 'test äöüß'       'test 部長' ) )";
-        ocd = parser.parseObjectClassDescription( value );
-        assertEquals( 1, ocd.getExtensions().size() );
-        assertNotNull( ocd.getExtensions().get( "X-TEST-ABC" ) );
-        assertEquals( 3, ocd.getExtensions().get( "X-TEST-ABC" ).size() );
-        assertEquals( "test1", ocd.getExtensions().get( "X-TEST-ABC" ).get( 0 ) );
-        assertEquals( "test äöüß", ocd.getExtensions().get( "X-TEST-ABC" ).get( 1 ) );
-        assertEquals( "test 部長", ocd.getExtensions().get( "X-TEST-ABC" ).get( 2 ) );
+    /**
+     * Test full object class description.
+     * 
+     * @throws ParseException
+     */
+    public void testFull() throws ParseException
+    {
+        String value = null;
+        ObjectClassDescription ocd = null;
 
-        // multiple extensions
-        value = "(1.1 X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2'))";
+        value = "( 1.2.3.4.5.6.7.8.9.0 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' 'test' ) DESC 'Descripton äöüß 部長' OBSOLETE SUP ( 2.3.4.5.6.7.8.9.0.1 $ abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 ) STRUCTURAL MUST ( 3.4.5.6.7.8.9.0.1.2 $ abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 ) MAY ( 4.5.6.7.8.9.0.1.2.3 $ abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 ) X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )";
         ocd = parser.parseObjectClassDescription( value );
+
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", ocd.getNumericOid() );
+        assertEquals( 2, ocd.getNames().size() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ocd.getNames().get( 0 ) );
+        assertEquals( "test", ocd.getNames().get( 1 ) );
+        assertEquals( "Descripton äöüß 部長", ocd.getDescription() );
+        assertTrue( ocd.isObsolete() );
+        assertEquals( 2, ocd.getSuperiorObjectClasses().size() );
+        assertEquals( "2.3.4.5.6.7.8.9.0.1", ocd.getSuperiorObjectClasses().get( 0 ) );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ocd
+            .getSuperiorObjectClasses().get( 1 ) );
+        assertEquals( ObjectClassTypeEnum.STRUCTURAL, ocd.getKind() );
+        assertEquals( 2, ocd.getMustAttributeTypes().size() );
+        assertEquals( "3.4.5.6.7.8.9.0.1.2", ocd.getMustAttributeTypes().get( 0 ) );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ocd.getMustAttributeTypes()
+            .get( 1 ) );
+        assertEquals( 2, ocd.getMayAttributeTypes().size() );
+        assertEquals( "4.5.6.7.8.9.0.1.2.3", ocd.getMayAttributeTypes().get( 0 ) );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ocd.getMayAttributeTypes()
+            .get( 1 ) );
         assertEquals( 2, ocd.getExtensions().size() );
         assertNotNull( ocd.getExtensions().get( "X-TEST-a" ) );
         assertEquals( 2, ocd.getExtensions().get( "X-TEST-a" ).size() );
@@ -745,22 +445,14 @@
         assertEquals( 2, ocd.getExtensions().get( "X-TEST-b" ).size() );
         assertEquals( "test2-1", ocd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
         assertEquals( "test2-2", ocd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
-
-        // invalid extension, no number allowed
-        value = "( 1.1 X-TEST1 'test' )";
-        try
-        {
-            ocd = parser.parseObjectClassDescription( value );
-            fail( "Exception expected, invalid extension X-TEST1 (no number allowed)" );
-        }
-        catch ( ParseException pe )
-        {
-            // expected
-        }
-
     }
 
 
+    /**
+     * Ensure that element order is ignored
+     * 
+     * @throws ParseException
+     */
     public void testIgnoreElementOrder() throws ParseException
     {
         String value = "( 2.5.6.6 STRUCTURAL MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) SUP top DESC 'RFC2256: a person' MUST ( sn $ cn ) NAME 'person' )";
@@ -1015,76 +707,14 @@
      */
     public void testMultiThreaded() throws Exception
     {
-        // start up and track all threads (40 threads)
-        List<Thread> threads = new ArrayList<Thread>();
-        for ( int ii = 0; ii < 10; ii++ )
-        {
-            Thread t0 = new Thread( new ParseSpecification( "( 1.1 )" ) );
-            Thread t1 = new Thread( new ParseSpecification(
-                "( 2.5.6.0 NAME 'top' DESC 'top of the superclass chain' ABSTRACT MUST objectClass )" ) );
-            Thread t2 = new Thread(
-                new ParseSpecification(
-                    "( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP top STRUCTURAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )" ) );
-            Thread t3 = new Thread(
-                new ParseSpecification(
-                    "( 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' )" ) );
-            threads.add( t0 );
-            threads.add( t1 );
-            threads.add( t2 );
-            threads.add( t3 );
-            t0.start();
-            t1.start();
-            t2.start();
-            t3.start();
-        }
-
-        // wait until all threads have died
-        boolean hasLiveThreads = false;
-        do
-        {
-            hasLiveThreads = false;
-
-            for ( int ii = 0; ii < threads.size(); ii++ )
+        String[] testValues = new String[]
             {
-                Thread t = ( Thread ) threads.get( ii );
-                hasLiveThreads = hasLiveThreads || t.isAlive();
-            }
-        }
-        while ( hasLiveThreads );
+                "( 1.1 )",
+                "( 2.5.6.0 NAME 'top' DESC 'top of the superclass chain' ABSTRACT MUST objectClass )",
+                "( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP top STRUCTURAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )",
+                "( 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 );
 
-        // check that no one thread failed to parse and generate a SS object
-        assertTrue( isSuccessMultithreaded );
     }
 
-    /**
-     * Used to test multithreaded use of a single parser.
-     */
-    class ParseSpecification implements Runnable
-    {
-        private final String ocd;
-
-        ObjectClassDescription result;
-
-
-        public ParseSpecification( String ocd )
-        {
-            this.ocd = ocd;
-        }
-
-
-        public void run()
-        {
-            try
-            {
-                result = parser.parseObjectClassDescription( ocd );
-            }
-            catch ( ParseException e )
-            {
-                e.printStackTrace();
-            }
-
-            isSuccessMultithreaded = isSuccessMultithreaded && ( result != null );
-        }
-    }
-
 }
Index: shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserTestUtils.java
===================================================================
--- shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserTestUtils.java	(Revision 0)
+++ shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserTestUtils.java	(Revision 0)
@@ -0,0 +1,531 @@
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.shared.ldap.schema.syntax.parser.AbstractSchemaParser;
+
+
+public abstract class SchemaParserTestUtils 
+{
+
+    /**
+     * Test numericoid
+     * 
+     * @throws ParseException
+     */
+    public static void testNumericOid( AbstractSchemaParser parser ) throws ParseException
+    {
+        String value = null;
+        AbstractSchemaDescription asd = null;
+
+        // null test
+        value = null;
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, null" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // no oid
+        value = "( )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, no NUMERICOID" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // simple
+        value = "( 0.1.2.3.4.5.6.7.8.9 )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
+
+        // simple
+        value = "( 123.4567.890 )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( "123.4567.890", asd.getNumericOid() );
+        
+        // simple with spaces
+        value = "(          0.1.2.3.4.5.6.7.8.9          )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
+
+        // non-numeric not allowed
+        value = "( test )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NUMERICOID test" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // to short
+        value = "( 1 )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NUMERICOID 1" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // dot only
+        value = "( . )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NUMERICOID ." );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // ends with dot
+        value = "( 1.1. )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NUMERICOID 1.1." );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // quotes not allowed
+        value = "( '1.1' )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NUMERICOID '1.1' (quoted)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // leading 0 not allowed
+        value = "( 01.1 )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NUMERICOID 01.1 (leading zero)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // alpha not allowed
+        value = "( 1.2.a.4 )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NUMERICOID 1.2.a.4 (alpha not allowed)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+        
+    }
+    
+    /**
+     * Tests NAME and its values
+     * 
+     * @throws ParseException
+     */
+    public static void testNames( AbstractSchemaParser parser ) throws ParseException
+    {
+        String value = null;
+        AbstractSchemaDescription asd = null;
+
+        // alpha
+        value = "( 1.1 NAME 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 1, asd.getNames().size() );
+        TestCase.assertEquals( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", asd.getNames().get( 0 ) );
+
+        // alpha-num-hypen
+        value = "( 1.1 NAME 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 1, asd.getNames().size() );
+        TestCase.assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", asd.getNames().get( 0 ) );
+
+        // with parentheses
+        value = "( 1.1 NAME ( 'a-z-0-9' ) )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 1, asd.getNames().size() );
+        TestCase.assertEquals( "a-z-0-9", asd.getNames().get( 0 ) );
+
+        // with parentheses, without space
+        value = "( 1.1 NAME ('a-z-0-9') )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 1, asd.getNames().size() );
+        TestCase.assertEquals( "a-z-0-9", asd.getNames().get( 0 ) );
+
+        // multi with space
+        value = "( 1.1 NAME ( 'test1' 'test2' ) )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 2, asd.getNames().size() );
+        TestCase.assertEquals( "test1", asd.getNames().get( 0 ) );
+        TestCase.assertEquals( "test2", asd.getNames().get( 1 ) );
+
+        // multi without space
+        value = "( 1.1 NAME ('test1' 'test2' 'test3') )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 3, asd.getNames().size() );
+        TestCase.assertEquals( "test1", asd.getNames().get( 0 ) );
+        TestCase.assertEquals( "test2", asd.getNames().get( 1 ) );
+        TestCase.assertEquals( "test3", asd.getNames().get( 2 ) );
+
+        // multi with many spaces
+        value = "(          1.1          NAME          (          'test1'          'test2'          'test3'          )          )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 3, asd.getNames().size() );
+        TestCase.assertEquals( "test1", asd.getNames().get( 0 ) );
+        TestCase.assertEquals( "test2", asd.getNames().get( 1 ) );
+        TestCase.assertEquals( "test3", asd.getNames().get( 2 ) );
+
+        // lowercase
+        value = "( 1.1 name 'test' )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, NAME is lowercase" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // unquoted
+        value = "( 1.1 NAME test )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NAME test (unquoted)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // start with number
+        value = "( 1.1 NAME '1test' )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NAME 1test (starts with number)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // start with hypen
+        value = "( 1.1 NAME '-test' )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NAME -test (starts with hypen)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // invalid character
+        value = "( 1.1 NAME 'te_st' )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NAME te_st (contains invalid character)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // NAM unknown
+        value = "( 1.1 NAM 'test' )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid token NAM" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // one valid, one invalid
+        value = "( 1.1 NAME ( 'test' 'te_st' ) )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NAME te_st (contains invalid character)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+        // no space between values
+        value = "( 1.1 NAME ( 'test1''test2' ) )";
+        try
+        {
+            asd = parser.parse( value );
+            TestCase.fail( "Exception expected, invalid NAME values (no space between values)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+    }
+    
+    
+    /**
+     * Tests DESC
+     * 
+     * @throws ParseException
+     */
+    public static void testDescription( AbstractSchemaParser parser ) throws ParseException
+    {
+        String value = null;
+        AbstractSchemaDescription asd = null;
+
+        // simple
+        value = "(1.1 DESC 'Descripton')";
+        asd = parser.parse( value );
+        TestCase.assertEquals( "Descripton", asd.getDescription() );
+
+        // unicode
+        value = "( 1.1 DESC 'Descripton äöüß 部長' )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( "Descripton äöüß 部長", asd.getDescription() );
+
+        // lowercase
+        value = "( 1.1 desc 'Descripton' )";
+        try
+        {
+            parser.parse( value );
+            TestCase.fail( "Exception expected, DESC is lowercase" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+        
+    }
+    
+    
+    /**
+     * Test extensions.
+     * 
+     * @throws ParseException
+     */
+    public static void testExtensions( AbstractSchemaParser parser ) throws ParseException
+    {
+        String value = null;
+        AbstractSchemaDescription asd = null;
+
+        // no extension
+        value = "( 1.1 )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 0, asd.getExtensions().size() );
+
+        // single extension with one value
+        value = "( 1.1 X-TEST 'test' )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 1, asd.getExtensions().size() );
+        TestCase.assertNotNull( asd.getExtensions().get( "X-TEST" ) );
+        TestCase.assertEquals( 1, asd.getExtensions().get( "X-TEST" ).size() );
+        TestCase.assertEquals( "test", asd.getExtensions().get( "X-TEST" ).get( 0 ) );
+
+        // single extension with multiple values
+        value = "( 1.1 X-TEST-ABC ('test1' 'test äöüß'       'test 部長' ) )";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 1, asd.getExtensions().size() );
+        TestCase.assertNotNull( asd.getExtensions().get( "X-TEST-ABC" ) );
+        TestCase.assertEquals( 3, asd.getExtensions().get( "X-TEST-ABC" ).size() );
+        TestCase.assertEquals( "test1", asd.getExtensions().get( "X-TEST-ABC" ).get( 0 ) );
+        TestCase.assertEquals( "test äöüß", asd.getExtensions().get( "X-TEST-ABC" ).get( 1 ) );
+        TestCase.assertEquals( "test 部長", asd.getExtensions().get( "X-TEST-ABC" ).get( 2 ) );
+
+        // multiple extensions
+        value = "(1.1 X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2'))";
+        asd = parser.parse( value );
+        TestCase.assertEquals( 2, asd.getExtensions().size() );
+        TestCase.assertNotNull( asd.getExtensions().get( "X-TEST-a" ) );
+        TestCase.assertEquals( 2, asd.getExtensions().get( "X-TEST-a" ).size() );
+        TestCase.assertEquals( "test1-1", asd.getExtensions().get( "X-TEST-a" ).get( 0 ) );
+        TestCase.assertEquals( "test1-2", asd.getExtensions().get( "X-TEST-a" ).get( 1 ) );
+        TestCase.assertNotNull( asd.getExtensions().get( "X-TEST-b" ) );
+        TestCase.assertEquals( 2, asd.getExtensions().get( "X-TEST-b" ).size() );
+        TestCase.assertEquals( "test2-1", asd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
+        TestCase.assertEquals( "test2-2", asd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
+
+        // invalid extension, no number allowed
+        value = "( 1.1 X-TEST1 'test' )";
+        try
+        {
+            asd = parser.parse( value );
+            TestCase.fail( "Exception expected, invalid extension X-TEST1 (no number allowed)" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+
+    }
+
+    
+    /**
+     * Tests OBSOLETE
+     * 
+     * @throws ParseException
+     */
+    public static void testObsolete( AbstractSchemaParser parser ) throws ParseException
+    {
+        String value = null;
+        AbstractSchemaDescription asd = null;
+
+        // not obsolete
+        value = "( 1.1 )";
+        asd = parser.parse( value );
+        TestCase.assertFalse( asd.isObsolete() );
+
+        // not obsolete
+        value = "( 1.1 NAME 'test' DESC 'Descripton' )";
+        asd = parser.parse( value );
+        TestCase.assertFalse( asd.isObsolete() );
+        
+        // obsolete
+        value = "(1.1 NAME 'test' DESC 'Descripton' OBSOLETE)";
+        asd = parser.parse( value );
+        TestCase.assertTrue( asd.isObsolete() );
+
+        // obsolete 
+        value = "(1.1 OBSOLETE)";
+        asd = parser.parse( value );
+        TestCase.assertTrue( asd.isObsolete() );
+
+        // ivalid
+        value = "(1.1 NAME 'test' DESC 'Descripton' OBSOLET )";
+        try
+        {
+            asd = parser.parse( value );
+            TestCase.fail( "Exception expected, invalid OBSOLETE value" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+        
+        // trailing value not allowed
+        value = "(1.1 NAME 'test' DESC 'Descripton' OBSOLETE 'true' )";
+        try
+        {
+            asd = parser.parse( value );
+            TestCase.fail( "Exception expected, trailing value ('true') now allowed" );
+        }
+        catch ( ParseException pe )
+        {
+            // expected
+        }
+        
+    }
+    
+    
+    
+    /**
+     * Tests the multithreaded use of a single parser.
+     */
+    public static void testMultiThreaded( AbstractSchemaParser parser, String[] testValues ) throws ParseException
+    {
+        final boolean[] isSuccessMultithreaded = new boolean[1];
+        isSuccessMultithreaded[0] = true;
+        
+        // start up and track all threads (40 threads)
+        List<Thread> threads = new ArrayList<Thread>();
+        for ( int ii = 0; ii < 10; ii++ )
+        {
+            for ( int i = 0; i < testValues.length; i++ )
+            {
+                Thread t = new Thread( new ParseSpecification( parser, testValues[i], isSuccessMultithreaded ) );
+                threads.add( t );
+                t.start();
+            }
+        }
+
+        // wait until all threads have died
+        boolean hasLiveThreads = false;
+        do
+        {
+            hasLiveThreads = false;
+
+            for ( int ii = 0; ii < threads.size(); ii++ )
+            {
+                Thread t = ( Thread ) threads.get( ii );
+                hasLiveThreads = hasLiveThreads || t.isAlive();
+            }
+        }
+        while ( hasLiveThreads );
+
+        // check that no one thread failed to parse and generate a SS object
+        TestCase.assertTrue( isSuccessMultithreaded[0] );
+        
+    }
+
+    static class ParseSpecification implements Runnable
+    {
+        private final AbstractSchemaParser parser;
+        private final String value;
+        private final boolean[] isSuccessMultithreaded;
+        
+        private AbstractSchemaDescription result;
+        
+        public ParseSpecification( AbstractSchemaParser parser, String value, boolean[] isSuccessMultithreaded )
+        {
+            this.parser = parser;
+            this.value = value;
+            this.isSuccessMultithreaded = isSuccessMultithreaded;
+        }
+        
+        
+        public void run()
+        {
+            try
+            {
+                result = parser.parse( value );
+            }
+            catch ( ParseException e )
+            {
+                e.printStackTrace();
+            }
+            
+            isSuccessMultithreaded[0] = isSuccessMultithreaded[0] && ( result != null );
+        }
+    }
+    
+    
+}
Index: shared/ldap/src/main/antlr/schema.g
===================================================================
--- shared/ldap/src/main/antlr/schema.g	(Revision 487359)
+++ shared/ldap/src/main/antlr/schema.g	(Arbeitskopie)
@@ -277,6 +277,79 @@
     ;
 
 
+
+    /**
+     * Production for matching rule descriptions. It is fault-tolerant
+     * against element ordering.
+     *
+     * <pre>
+     * MatchingRuleDescription = LPAREN WSP
+     *    numericoid                 ; object identifier
+     *    [ SP "NAME" SP qdescrs ]   ; short names (descriptors)
+     *    [ SP "DESC" SP qdstring ]  ; description
+     *    [ SP "OBSOLETE" ]          ; not active
+     *    SP "SYNTAX" SP numericoid  ; assertion syntax
+     *    extensions WSP RPAREN      ; extensions
+     * </pre>
+    */
+matchingRuleDescription returns [MatchingRuleDescription mrd = new MatchingRuleDescription()]
+     :
+    ( oid:STARTNUMERICOID { mrd.setNumericOid(numericoid(oid.getText())); } )
+    (
+	    ( name:NAME { mrd.setNames(qdescrs(name.getText())); } )
+	    |
+	    ( desc:DESC { mrd.setDescription(qdstring(desc.getText())); } )
+	    |
+	    ( OBSOLETE { mrd.setObsolete( true ); } )
+	    |
+        ( syntax:SYNTAX { mrd.setSyntax(numericoid(syntax.getText())); } )
+	    |
+	    ( extension:EXTENSION { 
+	        Extension ex = extension(extension.getText());
+	        mrd.addExtension(ex.key, ex.values); 
+	     } )
+    )*
+    RPAR
+    ;
+
+
+    /**
+     * Production for matching rule use descriptions. It is fault-tolerant
+     * against element ordering.
+     *
+     * <pre>
+     * MatchingRuleUseDescription = LPAREN WSP
+     *    numericoid                 ; object identifier
+     *    [ SP "NAME" SP qdescrs ]   ; short names (descriptors)
+     *    [ SP "DESC" SP qdstring ]  ; description
+     *    [ SP "OBSOLETE" ]          ; not active
+     *    SP "APPLIES" SP oids       ; attribute types
+     *    extensions WSP RPAREN      ; extensions
+     * </pre>
+    */
+matchingRuleUseDescription returns [MatchingRuleUseDescription mrud = new MatchingRuleUseDescription()]
+     :
+    ( oid:STARTNUMERICOID { mrud.setNumericOid(numericoid(oid.getText())); } )
+    (
+	    ( name:NAME { mrud.setNames(qdescrs(name.getText())); } )
+	    |
+	    ( desc:DESC { mrud.setDescription(qdstring(desc.getText())); } )
+	    |
+	    ( OBSOLETE { mrud.setObsolete( true ); } )
+	    |
+        ( applies:APPLIES { mrud.setApplicableAttributes(oids(applies.getText())); } )
+	    |
+	    ( extension:EXTENSION { 
+	        Extension ex = extension(extension.getText());
+	        mrud.addExtension(ex.key, ex.values); 
+	     } )
+    )*
+    RPAR
+    ;
+
+
+
+
 noidlen [String s] returns [NoidLen noidlen]
     {
         noidlen = new NoidLen();
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleUseDescriptionSyntaxChecker.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleUseDescriptionSyntaxChecker.java	(Revision 0)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleUseDescriptionSyntaxChecker.java	(Revision 0)
@@ -0,0 +1,135 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import java.text.ParseException;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.schema.syntax.parser.MatchingRuleUseDescriptionSchemaParser;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * A SyntaxChecker which verifies that a value follows the
+ * matching rule use descripton syntax according to RFC 4512, par 4.2.4:
+ * 
+ *  <pre>
+ * MatchingRuleUseDescription = LPAREN WSP
+ *    numericoid                 ; object identifier
+ *    [ SP "NAME" SP qdescrs ]   ; short names (descriptors)
+ *    [ SP "DESC" SP qdstring ]  ; description
+ *    [ SP "OBSOLETE" ]          ; not active
+ *    SP "APPLIES" SP oids       ; attribute types
+ *    extensions WSP RPAREN      ; extensions
+ * 
+ * </pre>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class MatchingRuleUseDescriptionSyntaxChecker implements SyntaxChecker
+{
+
+    /** The Syntax OID, according to RFC 4517, par. 3.3.20 */
+    public static final String OID = "1.3.6.1.4.1.1466.115.121.1.31";
+
+	/** The schema parser used to parse the MatchingRuleUseDescription Syntax */
+    private MatchingRuleUseDescriptionSchemaParser schemaParser = new MatchingRuleUseDescriptionSchemaParser();
+
+
+    /**
+     * 
+     * Creates a new instance of MatchingRuleUseDescriptionSchemaParser.
+     *
+     */
+    public MatchingRuleUseDescriptionSyntaxChecker()
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#getSyntaxOid()
+     */
+    public String getSyntaxOid()
+    {
+        return OID;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#assertSyntax(java.lang.Object)
+     */
+    public void assertSyntax( Object value ) throws NamingException
+    {
+        if ( !isValidSyntax( value ) )
+        {
+            throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#isValidSyntax(java.lang.Object)
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        String strValue;
+
+        if ( value == null )
+        {
+            return false;
+        }
+
+        if ( value instanceof String )
+        {
+            strValue = ( String ) value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            strValue = StringTools.utf8ToString( ( byte[] ) value );
+        }
+        else
+        {
+            strValue = value.toString();
+        }
+
+        try
+        {
+            MatchingRuleUseDescription mrud = schemaParser.parseMatchingRuleUseDescription( strValue );
+            
+            // APPLIES must be present
+            if ( ( mrud.getApplicableAttributes()== null ) || ( mrud.getApplicableAttributes().isEmpty() ) ) 
+            {
+                return false;
+            }
+                
+            return true;
+        }
+        catch ( ParseException pe )
+        {
+            return false;
+        }
+    }
+    
+}
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescription.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescription.java	(Revision 487671)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescription.java	(Arbeitskopie)
@@ -22,9 +22,7 @@
 
 
 import java.util.ArrayList;
-import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
 
@@ -34,16 +32,8 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ObjectClassDescription
+public class ObjectClassDescription extends AbstractSchemaDescription
 {
-    private String numericOid;
-
-    private List<String> names;
-
-    private String description;
-
-    private boolean isObsolete;
-
     private List<String> superiorObjectClasses;
 
     private ObjectClassTypeEnum kind;
@@ -52,59 +42,16 @@
 
     private List<String> mayAttributeTypes;
 
-    private Map<String, List<String>> extensions;
 
-
     public ObjectClassDescription()
     {
-        numericOid = "";
-        names = new ArrayList<String>();
-        description = "";
-        isObsolete = false;
         superiorObjectClasses = new ArrayList<String>();
         kind = ObjectClassTypeEnum.STRUCTURAL;
         mustAttributeTypes = new ArrayList<String>();
         mayAttributeTypes = new ArrayList<String>();
-        extensions = new LinkedHashMap<String, List<String>>();
     }
 
 
-    public String getDescription()
-    {
-        return description;
-    }
-
-
-    public void setDescription( String description )
-    {
-        this.description = description;
-    }
-
-
-    public Map<String, List<String>> getExtensions()
-    {
-        return extensions;
-    }
-
-
-    public void setExtensions( Map<String, List<String>> extensions )
-    {
-        this.extensions = extensions;
-    }
-
-
-    public boolean isObsolete()
-    {
-        return isObsolete;
-    }
-
-
-    public void setObsolete( boolean isObsolete )
-    {
-        this.isObsolete = isObsolete;
-    }
-
-
     public List<String> getMayAttributeTypes()
     {
         return mayAttributeTypes;
@@ -129,30 +76,6 @@
     }
 
 
-    public List<String> getNames()
-    {
-        return names;
-    }
-
-
-    public void setNames( List<String> names )
-    {
-        this.names = names;
-    }
-
-
-    public String getNumericOid()
-    {
-        return numericOid;
-    }
-
-
-    public void setNumericOid( String numericOid )
-    {
-        this.numericOid = numericOid;
-    }
-
-
     public List<String> getSuperiorObjectClasses()
     {
         return superiorObjectClasses;
@@ -194,9 +117,4 @@
         mayAttributeTypes.add( oid );
     }
 
-
-    public void addExtension( String key, List<String> values )
-    {
-        extensions.put( key, values );
-    }
-}
\ Kein Zeilenvorschub am Ende der Datei
+}
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleUseDescription.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleUseDescription.java	(Revision 0)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleUseDescription.java	(Revision 0)
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+
+/**
+ * RFC 4512 - 4.1.4. Matching Rule Use Description
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MatchingRuleUseDescription extends AbstractSchemaDescription
+{
+    private List<String> applicableAttributes;
+
+
+    public MatchingRuleUseDescription()
+    {
+        numericOid = "";
+        names = new ArrayList<String>();
+        description = "";
+        isObsolete = false;
+        applicableAttributes = new ArrayList<String>();
+        extensions = new LinkedHashMap<String, List<String>>();
+    }
+
+
+    public List<String> getApplicableAttributes()
+    {
+        return applicableAttributes;
+    }
+
+
+    public void setApplicableAttributes( List<String> applicableAttributes )
+    {
+        this.applicableAttributes = applicableAttributes;
+    }
+
+}
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescription.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescription.java	(Revision 487671)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescription.java	(Arbeitskopie)
@@ -20,60 +20,40 @@
 
 package org.apache.directory.shared.ldap.schema.syntax;
 
- 
- 
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
 
 import org.apache.directory.shared.ldap.schema.UsageEnum;
- 
- 
+
+
 /**
  * RFC 4512 - 4.1.2. Attribute Types
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AttributeTypeDescription
+public class AttributeTypeDescription extends AbstractSchemaDescription
 {
-    private String numericOid;
- 
-    private List<String> names;
- 
-    private String description;
- 
-    private boolean isObsolete;
- 
     private String superType;
- 
+
     private String equalityMatchingRule;
- 
+
     private String orderingMatchingRule;
- 
+
     private String substringsMatchingRule;
- 
+
     private String syntax;
- 
+
     private int syntaxLength;
- 
+
     private boolean isSingleValued;
- 
+
     private boolean isCollective;
- 
+
     private boolean isUserModifiable;
- 
+
     private UsageEnum usage;
- 
-    private Map<String, List<String>> extensions;
- 
- 
-    public AttributeTypeDescription( )
+
+
+    public AttributeTypeDescription()
     {
-        this.numericOid = "";
-        names = new ArrayList<String>();
-        description = "";
-        isObsolete = false;
         superType = null;
         equalityMatchingRule = null;
         orderingMatchingRule = null;
@@ -84,192 +64,126 @@
         isCollective = false;
         isUserModifiable = true;
         usage = UsageEnum.USER_APPLICATIONS;
-        extensions = new LinkedHashMap<String, List<String>>();;
     }
- 
- 
-    public String getDescription()
-    {
-        return description;
-    }
- 
- 
-    public void setDescription( String description )
-    {
-        this.description = description;
-    }
- 
- 
+
+
     public String getEqualityMatchingRule()
     {
         return equalityMatchingRule;
     }
- 
- 
+
+
     public void setEqualityMatchingRule( String equalityMatchingRule )
     {
         this.equalityMatchingRule = equalityMatchingRule;
     }
- 
- 
-    public Map<String, List<String>> getExtensions()
-    {
-        return extensions;
-    }
- 
- 
-    public void setExtensions( Map<String, List<String>> extensions )
-    {
-        this.extensions = extensions;
-    }
- 
- 
+
+
     public boolean isCollective()
     {
         return isCollective;
     }
- 
- 
+
+
     public void setCollective( boolean isCollective )
     {
         this.isCollective = isCollective;
     }
- 
- 
-    public boolean isObsolete()
-    {
-        return isObsolete;
-    }
- 
- 
-    public void setObsolete( boolean isObsolete )
-    {
-        this.isObsolete = isObsolete;
-    }
- 
- 
+
+
     public boolean isUserModifiable()
     {
         return isUserModifiable;
     }
- 
- 
+
+
     public void setUserModifiable( boolean isUserModifiable )
     {
         this.isUserModifiable = isUserModifiable;
     }
- 
- 
-    public List<String> getNames()
-    {
-        return names;
-    }
- 
- 
-    public void setNames( List<String> names )
-    {
-        this.names = names;
-    }
- 
- 
-    public String getNumericOid()
-    {
-        return numericOid;
-    }
- 
- 
-    public void setNumericOid( String oid )
-    {
-        this.numericOid = oid;
-    }
- 
- 
+
+
     public String getOrderingMatchingRule()
     {
         return orderingMatchingRule;
     }
- 
- 
+
+
     public void setOrderingMatchingRule( String orderingMatchingRule )
     {
         this.orderingMatchingRule = orderingMatchingRule;
     }
- 
- 
+
+
     public boolean isSingleValued()
     {
         return isSingleValued;
     }
- 
- 
+
+
     public void setSingleValued( boolean singleValued )
     {
         this.isSingleValued = singleValued;
     }
- 
- 
+
+
     public String getSubstringsMatchingRule()
     {
         return substringsMatchingRule;
     }
- 
- 
+
+
     public void setSubstringsMatchingRule( String substringsMatchingRule )
     {
         this.substringsMatchingRule = substringsMatchingRule;
     }
- 
- 
+
+
     public String getSuperType()
     {
         return superType;
     }
- 
- 
+
+
     public void setSuperType( String superType )
     {
         this.superType = superType;
     }
- 
- 
+
+
     public String getSyntax()
     {
         return syntax;
     }
- 
- 
+
+
     public void setSyntax( String syntax )
     {
         this.syntax = syntax;
     }
- 
- 
+
+
     public int getSyntaxLength()
     {
         return syntaxLength;
     }
- 
- 
+
+
     public void setSyntaxLength( int syntaxLenght )
     {
         this.syntaxLength = syntaxLenght;
     }
- 
- 
+
+
     public UsageEnum getUsage()
     {
         return usage;
     }
- 
- 
+
+
     public void setUsage( UsageEnum usage )
     {
         this.usage = usage;
     }
-    
-    public void addExtension( String key, List<String> values )
-    {
-        this.extensions.put( key, values );
-    }
- 
+
 }
\ Kein Zeilenvorschub am Ende der Datei
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java	(Revision 0)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java	(Revision 0)
@@ -0,0 +1,38 @@
+package org.apache.directory.shared.ldap.schema.syntax.parser;
+
+import java.io.StringReader;
+import java.text.ParseException;
+
+import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
+
+public abstract class AbstractSchemaParser
+{
+
+
+    /** the antlr generated parser being wrapped */
+    protected ReusableAntlrSchemaParser parser;
+
+    /** the antlr generated lexer being wrapped */
+    protected ReusableAntlrSchemaLexer lexer;
+    
+    
+    protected AbstractSchemaParser() 
+    {
+        lexer = new ReusableAntlrSchemaLexer( new StringReader( "" ) );
+        parser = new ReusableAntlrSchemaParser( lexer );
+    }
+    
+    /**
+     * Initializes the plumbing by creating a pipe and coupling the parser/lexer
+     * pair with it. param spec the specification to be parsed
+     */
+    protected void reset( String spec )
+    {
+        StringReader in = new StringReader( spec );
+        lexer.prepareNextInput( in );
+        parser.resetState();
+    }
+    
+    public abstract AbstractSchemaDescription parse( String schemaDescription ) throws ParseException;
+    
+}
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParser.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParser.java	(Revision 0)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParser.java	(Revision 0)
@@ -0,0 +1,107 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax.parser;
+
+
+import java.text.ParseException;
+
+import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
+import org.apache.directory.shared.ldap.schema.syntax.MatchingRuleUseDescription;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+
+/**
+ * A parser for RFC 4512 matching rule use descriptions.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MatchingRuleUseDescriptionSchemaParser extends AbstractSchemaParser
+{
+
+    /**
+     * Creates a schema parser instance.
+     */
+    public MatchingRuleUseDescriptionSchemaParser()
+    {
+        super();
+    }
+
+
+    /**
+     * Parses a matching rule use description according to RFC 4512:
+     * 
+     * <pre>
+     * MatchingRuleUseDescription = LPAREN WSP
+     *    numericoid                 ; object identifier
+     *    [ SP "NAME" SP qdescrs ]   ; short names (descriptors)
+     *    [ SP "DESC" SP qdstring ]  ; description
+     *    [ SP "OBSOLETE" ]          ; not active
+     *    SP "APPLIES" SP oids       ; attribute types
+     *    extensions WSP RPAREN      ; extensions
+     * 
+     * extensions = *( SP xstring SP qdstrings )
+     * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 
+     * </pre>
+     * 
+     * @param matchingRuleUseDescription the matching rule use description to be parsed
+     * @return the parsed MatchingRuleUseDescription bean
+     * @throws ParseException if there are any recognition errors (bad syntax)
+     */
+    public synchronized MatchingRuleUseDescription parseMatchingRuleUseDescription( String matchingRuleUseDescription )
+        throws ParseException
+    {
+
+        if ( matchingRuleUseDescription == null )
+        {
+            throw new ParseException( "Null", 0 );
+        }
+
+        reset( matchingRuleUseDescription ); // reset and initialize the parser / lexer pair
+
+        try
+        {
+            MatchingRuleUseDescription mrud = parser.matchingRuleUseDescription();
+            return mrud;
+        }
+        catch ( RecognitionException re )
+        {
+            String msg = "Parser failure on matching rule description:\n\t" + matchingRuleUseDescription;
+            msg += "\nAntlr message: " + re.getMessage();
+            msg += "\nAntlr column: " + re.getColumn();
+            throw new ParseException( msg, re.getColumn() );
+        }
+        catch ( TokenStreamException tse )
+        {
+            String msg = "Parser failure on matching rule description:\n\t" + matchingRuleUseDescription;
+            msg += "\nAntlr message: " + tse.getMessage();
+            throw new ParseException( msg, 0 );
+        }
+
+    }
+
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseMatchingRuleUseDescription( schemaDescription );
+    }
+
+}
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParser.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParser.java	(Revision 0)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParser.java	(Revision 0)
@@ -0,0 +1,107 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax.parser;
+
+
+import java.text.ParseException;
+
+import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
+import org.apache.directory.shared.ldap.schema.syntax.MatchingRuleDescription;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+
+/**
+ * A parser for RFC 4512 matching rule descriptions.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MatchingRuleDescriptionSchemaParser extends AbstractSchemaParser
+{
+
+    /**
+     * Creates a schema parser instance.
+     */
+    public MatchingRuleDescriptionSchemaParser()
+    {
+        super();
+    }
+
+
+    /**
+     * Parses a matching rule description according to RFC 4512:
+     * 
+     * <pre>
+     * MatchingRuleDescription = LPAREN WSP
+     *    numericoid                 ; object identifier
+     *    [ SP "NAME" SP qdescrs ]   ; short names (descriptors)
+     *    [ SP "DESC" SP qdstring ]  ; description
+     *    [ SP "OBSOLETE" ]          ; not active
+     *    SP "SYNTAX" SP numericoid  ; assertion syntax
+     *    extensions WSP RPAREN      ; extensions
+     * 
+     * extensions = *( SP xstring SP qdstrings )
+     * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 
+     * </pre>
+     * 
+     * @param matchingRuleDescription the matching rule description to be parsed
+     * @return the parsed MatchingRuleDescription bean
+     * @throws ParseException if there are any recognition errors (bad syntax)
+     */
+    public synchronized MatchingRuleDescription parseMatchingRuleDescription( String matchingRuleDescription )
+        throws ParseException
+    {
+
+        if ( matchingRuleDescription == null )
+        {
+            throw new ParseException( "Null", 0 );
+        }
+
+        reset( matchingRuleDescription ); // reset and initialize the parser / lexer pair
+
+        try
+        {
+            MatchingRuleDescription mrd = parser.matchingRuleDescription();
+            return mrd;
+        }
+        catch ( RecognitionException re )
+        {
+            String msg = "Parser failure on matching rule description:\n\t" + matchingRuleDescription;
+            msg += "\nAntlr message: " + re.getMessage();
+            msg += "\nAntlr column: " + re.getColumn();
+            throw new ParseException( msg, re.getColumn() );
+        }
+        catch ( TokenStreamException tse )
+        {
+            String msg = "Parser failure on matching rule description:\n\t" + matchingRuleDescription;
+            msg += "\nAntlr message: " + tse.getMessage();
+            throw new ParseException( msg, 0 );
+        }
+
+    }
+
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseMatchingRuleDescription( schemaDescription );
+    }
+
+}
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java	(Revision 487671)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java	(Arbeitskopie)
@@ -20,9 +20,9 @@
 package org.apache.directory.shared.ldap.schema.syntax.parser;
 
 
-import java.io.StringReader;
 import java.text.ParseException;
 
+import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
 import org.apache.directory.shared.ldap.schema.syntax.AttributeTypeDescription;
 
 import antlr.RecognitionException;
@@ -34,41 +34,18 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AttributeTypeDescriptionSchemaParser
+public class AttributeTypeDescriptionSchemaParser extends AbstractSchemaParser
 {
 
-    /** the antlr generated parser being wrapped */
-    private ReusableAntlrSchemaParser parser;
-
-    /** the antlr generated lexer being wrapped */
-    private ReusableAntlrSchemaLexer lexer;
-    
-    static
-    {
-    }
-
-
     /**
      * Creates a schema parser instance.
      */
     public AttributeTypeDescriptionSchemaParser()
     {
-        lexer = new ReusableAntlrSchemaLexer( new StringReader( "" ) );
-        parser = new ReusableAntlrSchemaParser( lexer );
+        super();
     }
     
-    /**
-     * Initializes the plumbing by creating a pipe and coupling the parser/lexer
-     * pair with it. param spec the specification to be parsed
-     */
-    private void reset( String spec )
-    {
-        StringReader in = new StringReader( spec );
-        lexer.prepareNextInput( in );
-        parser.resetState();
-    }
 
-
     /**
      * Parses a attribute type description according to RFC 4512:
      * 
@@ -134,4 +111,11 @@
 
     }
 
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseAttributeTypeDescription( schemaDescription );
+    }
+
+
 }
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParser.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParser.java	(Revision 487671)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParser.java	(Arbeitskopie)
@@ -20,9 +20,9 @@
 package org.apache.directory.shared.ldap.schema.syntax.parser;
 
 
-import java.io.StringReader;
 import java.text.ParseException;
 
+import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
 import org.apache.directory.shared.ldap.schema.syntax.LdapSyntaxDescription;
 
 import antlr.RecognitionException;
@@ -34,39 +34,16 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapSyntaxDescriptionSchemaParser
+public class LdapSyntaxDescriptionSchemaParser extends AbstractSchemaParser
 {
 
-    /** the antlr generated parser being wrapped */
-    private ReusableAntlrSchemaParser parser;
-
-    /** the antlr generated lexer being wrapped */
-    private ReusableAntlrSchemaLexer lexer;
-    
-    static
-    {
-    }
-
-
     /**
      * Creates a schema parser instance.
      */
     public LdapSyntaxDescriptionSchemaParser()
     {
-        lexer = new ReusableAntlrSchemaLexer( new StringReader( "" ) );
-        parser = new ReusableAntlrSchemaParser( lexer );
+        super();
     }
-    
-    /**
-     * Initializes the plumbing by creating a pipe and coupling the parser/lexer
-     * pair with it. param spec the specification to be parsed
-     */
-    private void reset( String spec )
-    {
-        StringReader in = new StringReader( spec );
-        lexer.prepareNextInput( in );
-        parser.resetState();
-    }
 
 
     /**
@@ -115,4 +92,10 @@
 
     }
 
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseLdapSyntaxDescription( schemaDescription );
+    }
+
 }
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParser.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParser.java	(Revision 487671)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParser.java	(Arbeitskopie)
@@ -20,9 +20,9 @@
 package org.apache.directory.shared.ldap.schema.syntax.parser;
 
 
-import java.io.StringReader;
 import java.text.ParseException;
 
+import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
 import org.apache.directory.shared.ldap.schema.syntax.ObjectClassDescription;
 
 import antlr.RecognitionException;
@@ -34,39 +34,16 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ObjectClassDescriptionSchemaParser
+public class ObjectClassDescriptionSchemaParser extends AbstractSchemaParser
 {
 
-    /** the antlr generated parser being wrapped */
-    private ReusableAntlrSchemaParser parser;
-
-    /** the antlr generated lexer being wrapped */
-    private ReusableAntlrSchemaLexer lexer;
-    
-    static
-    {
-    }
-
-
     /**
      * Creates a schema parser instance.
      */
     public ObjectClassDescriptionSchemaParser()
     {
-        lexer = new ReusableAntlrSchemaLexer( new StringReader( "" ) );
-        parser = new ReusableAntlrSchemaParser( lexer );
+        super();
     }
-    
-    /**
-     * Initializes the plumbing by creating a pipe and coupling the parser/lexer
-     * pair with it. param spec the specification to be parsed
-     */
-    private void reset( String spec )
-    {
-        StringReader in = new StringReader( spec );
-        lexer.prepareNextInput( in );
-        parser.resetState();
-    }
 
 
     /**
@@ -125,4 +102,11 @@
         }
 
     }
+
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseObjectClassDescription( schemaDescription );
+    }
+
 }
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleDescriptionSyntaxChecker.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleDescriptionSyntaxChecker.java	(Revision 0)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleDescriptionSyntaxChecker.java	(Revision 0)
@@ -0,0 +1,138 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import java.text.ParseException;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.schema.syntax.parser.MatchingRuleDescriptionSchemaParser;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * A SyntaxChecker which verifies that a value follows the
+ * matching rule descripton syntax according to RFC 4512, par 4.2.3:
+ * 
+ *  <pre>
+ * MatchingRuleDescription = LPAREN WSP
+ *    numericoid                 ; object identifier
+ *    [ SP "NAME" SP qdescrs ]   ; short names (descriptors)
+ *    [ SP "DESC" SP qdstring ]  ; description
+ *    [ SP "OBSOLETE" ]          ; not active
+ *    SP "SYNTAX" SP numericoid  ; assertion syntax
+ *    extensions WSP RPAREN      ; extensions
+ * 
+ * extensions = *( SP xstring SP qdstrings )
+ * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 
+ * 
+ * </pre>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class MatchingRuleDescriptionSyntaxChecker implements SyntaxChecker
+{
+
+    /** The Syntax OID, according to RFC 4517, par. 3.3.19 */
+    public static final String OID = "1.3.6.1.4.1.1466.115.121.1.30";
+
+	/** The schema parser used to parse the MatchingRuleDescription Syntax */
+    private MatchingRuleDescriptionSchemaParser schemaParser = new MatchingRuleDescriptionSchemaParser();
+
+
+    /**
+     * 
+     * Creates a new instance of MatchingRuleDescriptionSchemaParser.
+     *
+     */
+    public MatchingRuleDescriptionSyntaxChecker()
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#getSyntaxOid()
+     */
+    public String getSyntaxOid()
+    {
+        return OID;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#assertSyntax(java.lang.Object)
+     */
+    public void assertSyntax( Object value ) throws NamingException
+    {
+        if ( !isValidSyntax( value ) )
+        {
+            throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#isValidSyntax(java.lang.Object)
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        String strValue;
+
+        if ( value == null )
+        {
+            return false;
+        }
+
+        if ( value instanceof String )
+        {
+            strValue = ( String ) value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            strValue = StringTools.utf8ToString( ( byte[] ) value );
+        }
+        else
+        {
+            strValue = value.toString();
+        }
+
+        try
+        {
+            MatchingRuleDescription mrd = schemaParser.parseMatchingRuleDescription( strValue );
+            
+            // SYNTAX must be present
+            if ( ( mrd.getSyntax() == null ) ) 
+            {
+                return false;
+            }
+            
+            return true;
+        }
+        catch ( ParseException pe )
+        {
+            return false;
+        }
+    }
+    
+}
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleDescription.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleDescription.java	(Revision 0)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/MatchingRuleDescription.java	(Revision 0)
@@ -0,0 +1,52 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+/**
+ * RFC 4512 - 4.1.3. Matching Rule Description
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MatchingRuleDescription extends AbstractSchemaDescription
+{
+
+    private String syntax;
+
+
+    public MatchingRuleDescription()
+    {
+        syntax = null;
+    }
+
+
+    public String getSyntax()
+    {
+        return syntax;
+    }
+
+
+    public void setSyntax( String syntax )
+    {
+        this.syntax = syntax;
+    }
+
+}
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AbstractSchemaDescription.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AbstractSchemaDescription.java	(Revision 0)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AbstractSchemaDescription.java	(Revision 0)
@@ -0,0 +1,95 @@
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+
+public class AbstractSchemaDescription
+{
+
+    protected String numericOid;
+    protected List<String> names;
+    protected String description;
+    protected boolean isObsolete;
+    protected Map<String, List<String>> extensions;
+
+
+    protected AbstractSchemaDescription()
+    {
+        numericOid = "";
+        names = new ArrayList<String>();
+        description = "";
+        isObsolete = false;
+        extensions = new LinkedHashMap<String, List<String>>();
+    }
+
+
+    public String getDescription()
+    {
+        return description;
+    }
+
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+
+    public Map<String, List<String>> getExtensions()
+    {
+        return extensions;
+    }
+
+
+    public void setExtensions( Map<String, List<String>> extensions )
+    {
+        this.extensions = extensions;
+    }
+
+
+    public boolean isObsolete()
+    {
+        return isObsolete;
+    }
+
+
+    public void setObsolete( boolean isObsolete )
+    {
+        this.isObsolete = isObsolete;
+    }
+
+
+    public List<String> getNames()
+    {
+        return names;
+    }
+
+
+    public void setNames( List<String> names )
+    {
+        this.names = names;
+    }
+
+
+    public String getNumericOid()
+    {
+        return numericOid;
+    }
+
+
+    public void setNumericOid( String oid )
+    {
+        this.numericOid = oid;
+    }
+
+
+    public void addExtension( String key, List<String> values )
+    {
+        extensions.put( key, values );
+    }
+
+}
Index: shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java
===================================================================
--- shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java	(Revision 487671)
+++ shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java	(Arbeitskopie)
@@ -20,75 +20,48 @@
 
 package org.apache.directory.shared.ldap.schema.syntax;
 
- 
- 
+
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
- 
- 
+
+
 /**
  * RFC 4512 - 4.1.5. LDAP Syntaxes
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapSyntaxDescription
+public class LdapSyntaxDescription extends AbstractSchemaDescription
 {
- 
-    private String numericOid;
- 
-    private String description;
- 
-    private Map<String, List<String>> extensions;
- 
- 
-    public LdapSyntaxDescription( )
+
+    public LdapSyntaxDescription()
     {
         this.numericOid = "";
         description = "";
         extensions = new LinkedHashMap<String, List<String>>();
     }
- 
- 
-    public String getDescription()
+
+
+    public List<String> getNames()
     {
-        return description;
+        throw new UnsupportedOperationException( "Not supported by LdapSyntaxDescription" );
     }
- 
- 
-    public void setDescription( String description )
+
+
+    public void setNames( List<String> names )
     {
-        this.description = description;
+        throw new UnsupportedOperationException( "Not supported by LdapSyntaxDescription" );
     }
- 
- 
-    public Map<String, List<String>> getExtensions()
+
+
+    public boolean isObsolete()
     {
-        return extensions;
+        throw new UnsupportedOperationException( "Not supported by LdapSyntaxDescription" );
     }
- 
- 
-    public void setExtensions( Map<String, List<String>> extensions )
+
+
+    public void setObsolete( boolean isObsolete )
     {
-        this.extensions = extensions;
+        throw new UnsupportedOperationException( "Not supported by LdapSyntaxDescription" );
     }
- 
- 
-    public String getNumericOid()
-    {
-        return numericOid;
-    }
- 
- 
-    public void setNumericOid( String oid )
-    {
-        numericOid = oid;
-    }
- 
-    
-    public void addExtension( String key, List<String> values )
-    {
-        extensions.put( key, values );
-    }
- 
-}
\ Kein Zeilenvorschub am Ende der Datei
+
+}
