directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r487835 - in /directory/trunks/shared/ldap/src: main/antlr/ main/java/org/apache/directory/shared/ldap/schema/syntax/ main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ test/java/org/apache/directory/shared/ldap/schema/syntax/
Date Sat, 16 Dec 2006 17:51:12 GMT
Author: akarasulu
Date: Sat Dec 16 09:51:11 2006
New Revision: 487835

URL: http://svn.apache.org/viewvc?view=rev&rev=487835
Log:
applying patch from seelmann associated with DIRSERVER-793

Modified:
    directory/trunks/shared/ldap/src/main/antlr/schema.g
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescription.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescription.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParser.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParser.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescriptionSyntaxCheckerTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserAttributeTypeDescriptionTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserLdapSyntaxDescriptionTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserObjectClassDescriptionTest.java

Modified: directory/trunks/shared/ldap/src/main/antlr/schema.g
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/antlr/schema.g?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/main/antlr/schema.g (original)
+++ directory/trunks/shared/ldap/src/main/antlr/schema.g Sat Dec 16 09:51:11 2006
@@ -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();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescription.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescription.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescription.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescription.java Sat Dec 16 09:51:11 2006
@@ -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( )
-    {
-        this.numericOid = "";
-        names = new ArrayList<String>();
-        description = "";
-        isObsolete = false;
+
+
+    public AttributeTypeDescription()
+    {
         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 );
-    }
- 
+
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java Sat Dec 16 09:51:11 2006
@@ -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 );
-    }
- 
-}
\ No newline at end of file
+
+}

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescription.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescription.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescription.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescription.java Sat Dec 16 09:51:11 2006
@@ -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,56 +42,13 @@
 
     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;
     }
 
 
@@ -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 );
-    }
-}
\ No newline at end of file
+}

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java Sat Dec 16 09:51:11 2006
@@ -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,40 +34,17 @@
  * 
  * @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:
@@ -133,5 +110,12 @@
         }
 
     }
+
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseAttributeTypeDescription( schemaDescription );
+    }
+
 
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParser.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParser.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParser.java Sat Dec 16 09:51:11 2006
@@ -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,38 +34,15 @@
  * 
  * @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 );
-    }
-    
-    /**
-     * 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();
+        super();
     }
 
 
@@ -113,6 +90,12 @@
             throw new ParseException( msg, 0 );
         }
 
+    }
+
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseLdapSyntaxDescription( schemaDescription );
     }
 
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParser.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParser.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParser.java Sat Dec 16 09:51:11 2006
@@ -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,38 +34,15 @@
  * 
  * @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 );
-    }
-    
-    /**
-     * 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();
+        super();
     }
 
 
@@ -125,4 +102,11 @@
         }
 
     }
+
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseObjectClassDescription( schemaDescription );
+    }
+
 }

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java Sat Dec 16 09:51:11 2006
@@ -33,29 +33,7 @@
  */
 public class AttributeTypeDescriptionSyntaxCheckerTest extends TestCase
 {
-    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( "(" ) );
-    }
-
+    private AttributeTypeDescriptionSyntaxChecker checker = new AttributeTypeDescriptionSyntaxChecker();
 
     public void testValid()
     {
@@ -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( "(  )" ) );

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescriptionSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescriptionSyntaxCheckerTest.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescriptionSyntaxCheckerTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescriptionSyntaxCheckerTest.java Sat Dec 16 09:51:11 2006
@@ -33,28 +33,7 @@
  */
 public class LdapSyntaxDescriptionSyntaxCheckerTest extends TestCase
 {
-    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( "(" ) );
-    }
+    private LdapSyntaxDescriptionSyntaxChecker checker = new LdapSyntaxDescriptionSyntaxChecker();
 
 
     public void testValid()
@@ -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( "(  )" ) );

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java Sat Dec 16 09:51:11 2006
@@ -33,29 +33,7 @@
  */
 public class ObjectClassDescriptionSyntaxCheckerTest extends TestCase
 {
-    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( "(" ) );
-    }
-
+    private ObjectClassDescriptionSyntaxChecker checker = new ObjectClassDescriptionSyntaxChecker();
 
     public void testValid()
     {
@@ -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( "(  )" ) );

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserAttributeTypeDescriptionTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserAttributeTypeDescriptionTest.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserAttributeTypeDescriptionTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserAttributeTypeDescriptionTest.java Sat Dec 16 09:51:11 2006
@@ -21,8 +21,6 @@
 
 
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -40,9 +38,6 @@
     /** the parser instance */
     private AttributeTypeDescriptionSchemaParser parser;
 
-    /** holds multithreaded success value */
-    boolean isSuccessMultithreaded = true;
-
 
     protected void setUp() throws Exception
     {
@@ -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 ) );
-
-        // 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 ) );
+        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() );
+
+        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 );
-
-        // check that no one thread failed to parse and generate a SS object
-        assertTrue( isSuccessMultithreaded );
-    }
+                "( 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 );
 
-    /**
-     * 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 );
-        }
     }
 
 }

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserLdapSyntaxDescriptionTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserLdapSyntaxDescriptionTest.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserLdapSyntaxDescriptionTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserLdapSyntaxDescriptionTest.java Sat Dec 16 09:51:11 2006
@@ -21,8 +21,6 @@
 
 
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -39,9 +37,6 @@
     /** the parser instance */
     private LdapSyntaxDescriptionSchemaParser parser;
 
-    /** holds multithreaded success value */
-    boolean isSuccessMultithreaded = true;
-
 
     protected void setUp() throws Exception
     {
@@ -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
     {
-        String value = null;
-        LdapSyntaxDescription lsd = null;
+        SchemaParserTestUtils.testExtensions( parser );
+    }
 
-        // no extension
-        value = "( 1.1 )";
-        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 ) );
+    /**
+     * Test full sytax description.
+     * 
+     * @throws ParseException
+     */
+    public void testFull() throws ParseException
+    {
+        String value = null;
+        LdapSyntaxDescription lsd = null;
 
-        // single extension with multiple values
-        value = "( 1.1 X-TEST-ABC ('test1' 'test äöüß'       'test 部長' ) )";
+        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( 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 );
-    }
-
-    /**
-     * 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 );
-        }
+        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 );
     }
 
 }

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserObjectClassDescriptionTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserObjectClassDescriptionTest.java?view=diff&rev=487835&r1=487834&r2=487835
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserObjectClassDescriptionTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserObjectClassDescriptionTest.java Sat Dec 16 09:51:11 2006
@@ -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,9 +38,6 @@
     /** the parser instance */
     private ObjectClassDescriptionSchemaParser parser;
 
-    /** holds multithreaded success value */
-    boolean isSuccessMultithreaded = true;
-
 
     protected void setUp() throws Exception
     {
@@ -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 );
-
-        // check that no one thread failed to parse and generate a SS object
-        assertTrue( isSuccessMultithreaded );
-    }
+                "( 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 );
 
-    /**
-     * 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 );
-        }
     }
 
 }



Mime
View raw message