Author: seelmann
Date: Tue Jun 3 12:13:03 2008
New Revision: 662861
URL: http://svn.apache.org/viewvc?rev=662861&view=rev
Log:
Partial fix for DIRSHARED-8:
o allow a name for syntax descriptions
o allow quoted oids
Modified:
directory/shared/trunk/ldap/src/main/antlr/schema-qdstring.g
directory/shared/trunk/ldap/src/main/antlr/schema-value.g
directory/shared/trunk/ldap/src/main/antlr/schema.g
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParser.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DITContentRuleDescriptionSyntaxCheckerTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DITStructureRuleDescriptionSyntaxCheckerTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java
Modified: directory/shared/trunk/ldap/src/main/antlr/schema-qdstring.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/schema-qdstring.g?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/schema-qdstring.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/schema-qdstring.g Tue Jun 3 12:13:03 2008
@@ -23,6 +23,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.directory.shared.ldap.schema.parser.ParserMonitor;
+
}
@@ -62,9 +64,6 @@
QDSTRING : ( QUOTE (~'\'')* QUOTE ) ;
-
-
-
/**
* An antlr generated schema parser. This is a sub-parser used to parse
* qdstring and qdstrings according to RFC4512.
@@ -79,12 +78,28 @@
//buildAST=true ;
}
+{
+ private ParserMonitor monitor = null;
+ public void setParserMonitor( ParserMonitor monitor )
+ {
+ this.monitor = monitor;
+ }
+ private void matchedProduction( String msg )
+ {
+ if ( null != monitor )
+ {
+ monitor.matchedProduction( msg );
+ }
+ }
+}
+
/**
* qdstrings = qdstring / ( LPAREN WSP qdstringlist WSP RPAREN )
* qdstringlist = [ qdstring *( SP qdstring ) ]
*/
qdstrings returns [List<String> qdstrings]
{
+ matchedProduction( "AntlrSchemaQdstringParser.qdstrings()" );
qdstrings = new ArrayList<String>();
String qdstring = null;
}
@@ -100,6 +115,9 @@
if(qdstring.endsWith("'")) {
qdstring = qdstring.substring(0, qdstring.length()-1);
}
+ qdstring = qdstring.replaceAll("\\\\5C", "\\\\");
+ qdstring = qdstring.replaceAll("\\\\5c", "\\\\");
+ qdstring = qdstring.replaceAll("\\\\27", "'");
qdstrings.add(qdstring);
}
)
@@ -123,6 +141,9 @@
* QUTF1 = %x00-26 / %x28-5B / %x5D-7F
*/
qdstring returns [String qdstring=null]
+ {
+ matchedProduction( "AntlrSchemaQdstringParser.qdstring()" );
+ }
:
(
q:QDSTRING
Modified: directory/shared/trunk/ldap/src/main/antlr/schema-value.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/schema-value.g?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/schema-value.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/schema-value.g Tue Jun 3 12:13:03 2008
@@ -23,6 +23,8 @@
import java.util.List;
import java.util.ArrayList;
+import org.apache.directory.shared.ldap.schema.parser.ParserMonitor;
+
}
@@ -52,8 +54,11 @@
'\r' (options {greedy=true;} : '\n')? { newline(); }
|
'\n' { newline(); }
+ |
+ '#' (~'\n')* '\n' { newline(); }
)+
{ setText(" "); }
+ //{$setType(Token.SKIP);} //ignore this token
;
LPAR : '(' ;
@@ -61,6 +66,7 @@
protected LDIGIT : '1'..'9' ;
protected DIGIT : '0'..'9' ;
protected NUMBER : DIGIT | ( LDIGIT (DIGIT)+ ) ;
+protected NUMBER2 : (DIGIT)+ ;
protected NUMERICOID : NUMBER ( '.' NUMBER )+ ;
QUOTE : '\'' ;
@@ -68,7 +74,7 @@
LCURLY : '{' ;
RCURLY : '}' ;
DESCR : ( 'a'..'z' ) ( 'a'..'z' | '0'..'9' | '-' )* ;
-LEN : LCURLY n:NUMBER RCURLY { setText(n.getText()); } ;
+LEN : LCURLY n:NUMBER2 RCURLY { setText(n.getText()); } ;
NUMBER_OR_NUMERICOID :
( NUMBER '.' ) => NUMERICOID { $setType( NUMERICOID ); }
@@ -90,18 +96,45 @@
//buildAST=true ;
}
+{
+ private ParserMonitor monitor = null;
+ public void setParserMonitor( ParserMonitor monitor )
+ {
+ this.monitor = monitor;
+ }
+ private void matchedProduction( String msg )
+ {
+ if ( null != monitor )
+ {
+ monitor.matchedProduction( msg );
+ }
+ }
+}
/**
* noidlen = numericoid [ LCURLY len RCURLY ]
* len = number
*/
noidlen returns [AntlrSchemaParser.NoidLen noidlen = new AntlrSchemaParser.NoidLen()]
+ {
+ matchedProduction( "AntlrSchemaValueParser.noidlen()" );
+ }
:
(
- o:NUMERICOID { noidlen.noid = o.getText(); }
- (
- l:LEN { noidlen.len = Integer.parseInt(l.getText()); }
- )?
+ (LPAR)?
+ (WHSP)?
+ (QUOTE)?
+ o:NUMERICOID { noidlen.noid = o.getText(); }
+ (QUOTE)?
+ (WHSP)?
+ (RPAR)?
+ (
+ l:LEN { noidlen.len = Integer.parseInt(l.getText()); }
+ (QUOTE)?
+ (WHSP)?
+ (RPAR)?
+ )?
+
)
;
@@ -110,9 +143,22 @@
* numericoid = number 1*( DOT number )
*/
numericoid returns [String numericoid=null]
+ {
+ matchedProduction( "AntlrSchemaValueParser.numericoid()" );
+ }
:
(
- (WHSP)? n:NUMERICOID (WHSP)? { numericoid = n.getText(); }
+ (WHSP)?
+ (LPAR (WHSP)? )?
+ (
+ ( QUOTE n1:NUMERICOID { numericoid = n1.getText(); } QUOTE )
+ |
+ ( n2:NUMERICOID { numericoid = n2.getText(); } )
+ )
+ (
+ (WHSP)?
+ (RPAR)?
+ )
)
;
@@ -128,15 +174,22 @@
*
*/
oid returns [String oid=null]
+ {
+ matchedProduction( "AntlrSchemaValueParser.oid()" );
+ }
:
(
- (WHSP)?
+ (WHSP)?
(
- n:NUMERICOID { oid = n.getText(); }
- |
- d:DESCR { oid = d.getText(); }
+ ( QUOTE n1:NUMERICOID { oid = n1.getText(); } QUOTE )
+ |
+ ( n2:NUMERICOID { oid = n2.getText(); } )
+ |
+ ( QUOTE d1:DESCR { oid = d1.getText(); } QUOTE )
+ |
+ ( d2:DESCR { oid = d2.getText(); } )
)
- (WHSP)?
+ (options {greedy=true;} : WHSP)?
)
;
@@ -147,6 +200,7 @@
*/
oids returns [List<String> oids]
{
+ matchedProduction( "AntlrSchemaValueParser.oids()" );
oids = new ArrayList<String>();
String oid = null;
}
@@ -156,14 +210,14 @@
oid=oid { oids.add(oid); }
)
|
- (
- LPAR
+ (
+ LPAR
oid=oid { oids.add(oid); }
(
- DOLLAR
+ (DOLLAR)?
oid=oid { oids.add(oid); }
)*
- RPAR
+ RPAR
)
)
;
@@ -173,12 +227,17 @@
* qdescr = SQUOTE descr SQUOTE
*/
qdescr returns [String qdescr=null]
+ {
+ matchedProduction( "AntlrSchemaValueParser.qdescr()" );
+ }
:
(
(WHSP)?
- QUOTE
- d:DESCR { qdescr = d.getText(); }
- QUOTE
+ (
+ ( QUOTE d1:DESCR { qdescr = d1.getText(); } QUOTE )
+ |
+ ( d2:DESCR { qdescr = d2.getText(); } )
+ )
)
;
@@ -189,6 +248,7 @@
*/
qdescrs returns [List<String> qdescrs]
{
+ matchedProduction( "AntlrSchemaValueParser.qdescrs()" );
qdescrs = new ArrayList<String>();
String qdescr = null;
}
@@ -201,11 +261,11 @@
(
LPAR
qdescr=qdescr { qdescrs.add(qdescr); }
+ (options {greedy=true;} : WHSP)?
(
- (options {greedy=true;} : WHSP)?
qdescr=qdescr { qdescrs.add(qdescr); }
- )*
- (WHSP)?
+ (options {greedy=true;} : WHSP)?
+ )*
RPAR
)
)
@@ -217,6 +277,9 @@
*
*/
ruleid returns [Integer ruleid=null]
+ {
+ matchedProduction( "AntlrSchemaValueParser.ruleid()" );
+ }
:
(
(WHSP)?
@@ -231,6 +294,7 @@
*/
ruleids returns [List<Integer> ruleids]
{
+ matchedProduction( "AntlrSchemaValueParser.ruleids()" );
ruleids = new ArrayList<Integer>();
Integer ruleid = null;
}
Modified: directory/shared/trunk/ldap/src/main/antlr/schema.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/schema.g?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/schema.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/schema.g Tue Jun 3 12:13:03 2008
@@ -85,7 +85,7 @@
OBJECTCLASS : ( "objectclass" (WHSP)? ) ;
ATTRIBUTETYPE : ( "attributetype" (WHSP)? ) ;
-STARTNUMERICOID : ( LPAR ( numericoid:VALUE ) ) { setText(numericoid.getText().trim()); } ;
+STARTNUMERICOID : ( LPAR (options {greedy=true;} : WHSP)? ( numericoid:VALUES ) ) { setText(numericoid.getText()); } ;
NAME : ( "name" (options {greedy=true;} : WHSP)? qdstrings:VALUES ) { setText(qdstrings.getText().trim()); } ;
DESC : ( "desc" (options {greedy=true;} : WHSP)? qdstring:VALUES ) { setText(qdstring.getText().trim()); } ;
SUP : ( "sup" (options {greedy=true;} : WHSP)? sup:VALUES ) { setText(sup.getText().trim()); } ;
@@ -424,6 +424,8 @@
:
( oid:STARTNUMERICOID { lsd.setNumericOid(numericoid(oid.getText())); } )
(
+ ( name:NAME { et.track("NAME", name); lsd.setNames(qdescrs(name.getText())); } )
+ |
( desc:DESC { et.track("DESC", desc); lsd.setDescription(qdstring(desc.getText())); } )
|
( extension:EXTENSION {
@@ -860,6 +862,7 @@
matchedProduction( "noidlen()" );
AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
+ parser.setParserMonitor(monitor);
noidlen = parser.noidlen();
}
:
@@ -879,9 +882,10 @@
numericoid [String s] returns [String numericoid]
{
- matchedProduction( "numericoid()" );
+ matchedProduction( "numericoid()");
AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
+ parser.setParserMonitor(monitor);
numericoid = parser.numericoid();
}
:
@@ -890,9 +894,12 @@
oid [String s] returns [String oid]
{
matchedProduction( "oid()" );
- AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
- AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
- oid = parser.oid();
+ List<String> oids = oids(s);
+ if( oids.size() != 1 )
+ {
+ throw new SemanticException( "Exactly one OID expected", null, 0, 0 );
+ }
+ oid = oids.get(0);
}
:
;
@@ -902,6 +909,7 @@
matchedProduction( "oid()" );
AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
+ parser.setParserMonitor(monitor);
oids = parser.oids();
}
:
@@ -910,9 +918,12 @@
qdescr [String s] returns [String qdescr]
{
matchedProduction( "qdescr()" );
- AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
- AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
- qdescr = parser.qdescr();
+ List<String> qdescrs = qdescrs(s);
+ if( qdescrs.size() != 1 )
+ {
+ throw new SemanticException( "Exactly one qdescrs expected", null, 0, 0 );
+ }
+ qdescr = qdescrs.get(0);
}
:
;
@@ -922,6 +933,7 @@
matchedProduction( "qdescrs()" );
AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
+ parser.setParserMonitor(monitor);
qdescrs = parser.qdescrs();
}
:
@@ -930,9 +942,12 @@
qdstring [String s] returns [String qdstring]
{
matchedProduction( "qdstring()" );
- AntlrSchemaQdstringLexer lexer = new AntlrSchemaQdstringLexer(new StringReader(s));
- AntlrSchemaQdstringParser parser = new AntlrSchemaQdstringParser(lexer);
- qdstring = parser.qdstring();
+ List<String> qdstrings = qdstrings(s);
+ if( qdstrings.size() != 1 )
+ {
+ throw new SemanticException( "Exactly one qdstrings expected", null, 0, 0 );
+ }
+ qdstring = qdstrings.get(0);
}
:
;
@@ -942,6 +957,7 @@
matchedProduction( "qdstrings()" );
AntlrSchemaQdstringLexer lexer = new AntlrSchemaQdstringLexer(new StringReader(s));
AntlrSchemaQdstringParser parser = new AntlrSchemaQdstringParser(lexer);
+ parser.setParserMonitor(monitor);
qdstrings = parser.qdstrings();
}
:
@@ -952,6 +968,7 @@
matchedProduction( "ruleid()" );
AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
+ parser.setParserMonitor(monitor);
ruleid = parser.ruleid();
}
:
@@ -962,6 +979,7 @@
matchedProduction( "ruleids()" );
AntlrSchemaValueLexer lexer = new AntlrSchemaValueLexer(new StringReader(s));
AntlrSchemaValueParser parser = new AntlrSchemaValueParser(lexer);
+ parser.setParserMonitor(monitor);
ruleids = parser.ruleids();
}
:
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParser.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParser.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parser/OpenLdapSchemaParser.java Tue Jun 3 12:13:03 2008
@@ -47,15 +47,17 @@
*/
public class OpenLdapSchemaParser extends AbstractSchemaParser
{
- /** the monitor to use for this parser */
- private ParserMonitor monitor = new ParserMonitorAdapter();
-
+
/** The list of parsed schema descriptions */
private List<AbstractSchemaDescription> schemaDescriptions;
+ /** The list of attribute type literals, initialized by splitParsedSchemaDescriptions() */
private List<AttributeTypeLiteral> attributeTypeLiterals;
+
+ /** the list of object class literals, initialized by splitParsedSchemaDescriptions()*/
private List<ObjectClassLiteral> objectClassLiterals;
-
+
+
/**
* Creates a reusable instance of an OpenLdapSchemaParser.
*
@@ -88,36 +90,37 @@
*/
public List<AttributeTypeLiteral> getAttributeTypes()
{
- if(attributeTypeLiterals == null)
+ if ( attributeTypeLiterals == null )
{
splitParsedSchemaDescriptions();
}
-
+
return attributeTypeLiterals;
}
public List<ObjectClassLiteral> getObjectClassTypes()
{
- if(objectClassLiterals == null)
+ if ( objectClassLiterals == null )
{
splitParsedSchemaDescriptions();
}
-
+
return objectClassLiterals;
}
-
+
+
private void splitParsedSchemaDescriptions()
{
objectClassLiterals = new ArrayList<ObjectClassLiteral>();
attributeTypeLiterals = new ArrayList<AttributeTypeLiteral>();
-
+
for ( AbstractSchemaDescription schemaDescription : schemaDescriptions )
{
- if(schemaDescription instanceof AttributeTypeDescription)
+ if ( schemaDescription instanceof AttributeTypeDescription )
{
- AttributeTypeDescription atd = (AttributeTypeDescription)schemaDescription;
- AttributeTypeLiteral literal = new AttributeTypeLiteral(atd.getNumericOid());
+ AttributeTypeDescription atd = ( AttributeTypeDescription ) schemaDescription;
+ AttributeTypeLiteral literal = new AttributeTypeLiteral( atd.getNumericOid() );
literal.setNames( atd.getNames().toArray( new String[atd.getNames().size()] ) );
literal.setDescription( atd.getDescription() );
literal.setSuperior( atd.getSuperType() );
@@ -133,13 +136,14 @@
literal.setUsage( atd.getUsage() );
attributeTypeLiterals.add( literal );
}
- else if(schemaDescription instanceof ObjectClassDescription)
+ else if ( schemaDescription instanceof ObjectClassDescription )
{
- ObjectClassDescription ocd = (ObjectClassDescription)schemaDescription;
- ObjectClassLiteral literal = new ObjectClassLiteral(ocd.getNumericOid());
+ ObjectClassDescription ocd = ( ObjectClassDescription ) schemaDescription;
+ ObjectClassLiteral literal = new ObjectClassLiteral( ocd.getNumericOid() );
literal.setNames( ocd.getNames().toArray( new String[ocd.getNames().size()] ) );
literal.setDescription( ocd.getDescription() );
- literal.setSuperiors( ocd.getSuperiorObjectClasses().toArray( new String[ocd.getSuperiorObjectClasses().size()] ) );
+ literal.setSuperiors( ocd.getSuperiorObjectClasses().toArray(
+ new String[ocd.getSuperiorObjectClasses().size()] ) );
literal.setMay( ocd.getMayAttributeTypes().toArray( new String[ocd.getMayAttributeTypes().size()] ) );
literal.setMust( ocd.getMustAttributeTypes().toArray( new String[ocd.getMustAttributeTypes().size()] ) );
literal.setClassType( ocd.getKind() );
@@ -163,12 +167,18 @@
{
throw new ParseException( "The schemaObject is either null or is " + "the empty String!", 0 );
}
-
+
reset( schemaObject ); // reset and initialize the parser / lexer pair
invokeParser( schemaObject );
-
- // TODO: return
- return null;
+
+ if ( !schemaDescriptions.isEmpty() )
+ {
+ return schemaDescriptions.get( 0 );
+ }
+ else
+ {
+ return null;
+ }
}
@@ -209,7 +219,7 @@
InputStreamReader in = new InputStreamReader( schemaIn );
lexer.prepareNextInput( in );
parser.resetState();
-
+
invokeParser( "schema input stream ==> " + schemaIn.toString() );
}
@@ -226,15 +236,8 @@
FileReader in = new FileReader( schemaFile );
lexer.prepareNextInput( in );
parser.resetState();
-
- invokeParser( "schema file ==> " + schemaFile.getAbsolutePath() );
- }
-
- public void setParserMonitor( ParserMonitor monitor )
- {
- this.monitor = monitor;
- parser.setParserMonitor( monitor );
+ invokeParser( "schema file ==> " + schemaFile.getAbsolutePath() );
}
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/LdapSyntaxDescription.java Tue Jun 3 12:13:03 2008
@@ -47,18 +47,6 @@
}
- public List<String> getNames()
- {
- throw new UnsupportedOperationException( "Not supported by LdapSyntaxDescription" );
- }
-
-
- public void setNames( List<String> names )
- {
- throw new UnsupportedOperationException( "Not supported by LdapSyntaxDescription" );
- }
-
-
public boolean isObsolete()
{
throw new UnsupportedOperationException( "Not supported by LdapSyntaxDescription" );
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AbstractSchemaParser.java Tue Jun 3 12:13:03 2008
@@ -19,9 +19,12 @@
*/
package org.apache.directory.shared.ldap.schema.syntax.parser;
+
import java.io.StringReader;
import java.text.ParseException;
+import org.apache.directory.shared.ldap.schema.parser.ParserMonitor;
+import org.apache.directory.shared.ldap.schema.parser.ParserMonitorAdapter;
import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
@@ -35,20 +38,23 @@
public abstract class AbstractSchemaParser
{
+ /** the monitor to use for this parser */
+ protected ParserMonitor monitor = new ParserMonitorAdapter();
/** the antlr generated parser being wrapped */
protected ReusableAntlrSchemaParser parser;
/** the antlr generated lexer being wrapped */
protected ReusableAntlrSchemaLexer lexer;
-
-
- protected AbstractSchemaParser()
+
+
+ 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
@@ -59,7 +65,15 @@
lexer.prepareNextInput( in );
parser.resetState();
}
-
+
+
+ public void setParserMonitor( ParserMonitor monitor )
+ {
+ this.monitor = monitor;
+ parser.setParserMonitor( monitor );
+ }
+
+
public abstract AbstractSchemaDescription parse( String schemaDescription ) throws ParseException;
-
+
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParser.java Tue Jun 3 12:13:03 2008
@@ -27,6 +27,7 @@
import antlr.RecognitionException;
import antlr.TokenStreamException;
+import antlr.TokenStreamRecognitionException;
/**
@@ -102,6 +103,12 @@
msg += "\nAntlr column: " + re.getColumn();
throw new ParseException( msg, re.getColumn() );
}
+ catch ( TokenStreamRecognitionException tsre )
+ {
+ String msg = "Parser failure on attribute type description:\n\t" + attributeTypeDescription;
+ msg += "\nAntlr message: " + tsre.getMessage();
+ throw new ParseException( msg, 0 );
+ }
catch ( TokenStreamException tse )
{
String msg = "Parser failure on attribute type description:\n\t" + attributeTypeDescription;
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AttributeTypeDescriptionSyntaxCheckerTest.java Tue Jun 3 12:13:03 2008
@@ -45,6 +45,8 @@
assertTrue( checker.isValidSyntax( "( 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 )" ) );
assertTrue( checker.isValidSyntax( "( 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 )" ) );
assertTrue( checker.isValidSyntax( "( 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 )" ) );
+ assertTrue( checker.isValidSyntax( "( 2.5.4.3 NAME cn SUP name )" ) );
+ assertTrue( checker.isValidSyntax( "( 2.5.4.3 name ( 'cn' 'commonName' ) sup name )" ) );
// spaces
assertTrue( checker.isValidSyntax( "(2.5.4.3 SUP name)" ) );
@@ -82,12 +84,6 @@
// missing right parenthesis
assertFalse( checker.isValidSyntax( "( 2.5.4.3 NAME 'cn' SUP name" ) );
- // missing quotes
- assertFalse( checker.isValidSyntax( "( 2.5.4.3 NAME cn SUP name )" ) );
-
- // lowercase NAME, SUP
- assertFalse( checker.isValidSyntax( "( 2.5.4.3 name ( 'cn' 'commonName' ) sup name " ) );
-
// SYNTAX or SUP must be contained
assertFalse( checker.isValidSyntax( "( 2.5.4.3 NAME ( 'cn' 'commonName' ) DESC 'RFC2256: common name(s) for which the entity is known by' )" ) );
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DITContentRuleDescriptionSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DITContentRuleDescriptionSyntaxCheckerTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DITContentRuleDescriptionSyntaxCheckerTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DITContentRuleDescriptionSyntaxCheckerTest.java Tue Jun 3 12:13:03 2008
@@ -53,6 +53,7 @@
.isValidSyntax( "( 2.5.6.4 NAME 'organization' DESC 'content rule for organization' OBSOLETE AUX ( pilotOrganization $ 2.5.6.5 ) MUST ( objectClass $ o ) MAY ( l $ st ) NOT ( 1.2.3.4.5.6.7.8.9.0 $ ou ) )" ) );
assertTrue( checker.isValidSyntax( "(2.5.6.4)" ) );
+ assertTrue( checker.isValidSyntax( "(2.5.6.4 NAME organization)" ) );
assertTrue( checker
.isValidSyntax( "( 2.5.6.4 NAME 'organization' DESC 'content rule for organization' OBSOLETE AUX ( pilotOrganization $ 2.5.6.5 ) MUST ( objectClass $ o ) MAY ( l $ st ) NOT (1.2.3.4.5.6.7.8.9.0 $ ou))" ) );
@@ -82,9 +83,6 @@
// missing right parenthesis
assertFalse( checker.isValidSyntax( "( 2.5.6.4 NAME 'organization'" ) );
-
- // missing quotes
- assertFalse( checker.isValidSyntax( "( 2.5.6.4 NAME organization )" ) );
}
}
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DITStructureRuleDescriptionSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DITStructureRuleDescriptionSyntaxCheckerTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DITStructureRuleDescriptionSyntaxCheckerTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DITStructureRuleDescriptionSyntaxCheckerTest.java Tue Jun 3 12:13:03 2008
@@ -52,6 +52,7 @@
.isValidSyntax( "( 2 NAME 'organization' DESC 'organization structure rule' OBSOLETE FORM 2.5.15.3 SUP ( 1 1234567890 5 ) )" ) );
assertTrue( checker.isValidSyntax( "(2 FORM 2.5.15.3)" ) );
+ assertTrue( checker.isValidSyntax( "(2 NAME organization FORM 2.5.15.3)" ) );
assertTrue( checker
.isValidSyntax( "( 2 NAME 'organization' DESC 'organization structure rule' OBSOLETE FORM 2.5.15.3 SUP (1 1234567890 5 ))" ) );
@@ -81,9 +82,6 @@
// missing right parenthesis
assertFalse( checker.isValidSyntax( "( 2 FORM 2.5.15.3" ) );
- // missing quotes
- assertFalse( checker.isValidSyntax( "( 2 NAME organization FORM 2.5.15.3 )" ) );
-
// missing FORM
assertFalse( checker.isValidSyntax( "( 2 NAME 'organization' DESC 'organization structure rule' )" ) );
}
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxCheckerTest.java Tue Jun 3 12:13:03 2008
@@ -38,6 +38,7 @@
public void testValid()
{
assertTrue( checker.isValidSyntax( "( 2.5.6.6 )" ) );
+ assertTrue( checker.isValidSyntax( "( 2.5.6.6 NAME person )" ) );
assertTrue( checker.isValidSyntax( "( 2.5.6.6 NAME 'person' )" ) );
assertTrue( checker.isValidSyntax( "( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' )" ) );
assertTrue( checker.isValidSyntax( "( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP top )" ) );
@@ -71,9 +72,6 @@
// missing right parenthesis
assertFalse( checker.isValidSyntax( "( 2.5.6.6 NAME 'person'" ) );
- // missing quotes
- assertFalse( checker.isValidSyntax( "( 2.5.6.6 NAME person )" ) );
-
// lowercase NAME, DESC, SUP
assertFalse( checker.isValidSyntax( "( 2.5.6.6 name 'person' desc 'RFC2256: a person' sup top " ) );
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java Tue Jun 3 12:13:03 2008
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.shared.ldap.schema.parser.ConsoleParserMonitor;
import org.apache.directory.shared.ldap.schema.syntax.AttributeTypeDescription;
@@ -42,6 +43,7 @@
protected void setUp() throws Exception
{
parser = new AttributeTypeDescriptionSchemaParser();
+ parser.setParserMonitor( new ConsoleParserMonitor() );
}
@@ -125,29 +127,20 @@
atd = parser.parseAttributeTypeDescription( value );
assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", atd.getSuperType() );
- // no quote allowed
+ // quoted SUP value
value = "( 1.1 SYNTAX 1.1 SUP 'name' )";
- try
- {
- atd = parser.parseAttributeTypeDescription( value );
- fail( "Exception expected, invalid SUP 'name' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "name", atd.getSuperType() );
- // no quote allowed
+ // quoted SUP value
value = "( 1.1 SYNTAX 1.1 SUP '1.2.3.4' )";
- try
- {
- atd = parser.parseAttributeTypeDescription( value );
- fail( "Exception expected, invalid SUP '1.2.3.4' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "1.2.3.4", atd.getSuperType() );
+
+ // quoted SUP value
+ value = "( 1.1 SYNTAX 1.1 SUP ('1.2.3.4') )";
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "1.2.3.4", atd.getSuperType() );
// invalid character
value = "( 1.1 SYNTAX 1.1 SUP 1.2.3.4.A )";
@@ -218,17 +211,15 @@
atd = parser.parseAttributeTypeDescription( value );
assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", atd.getEqualityMatchingRule() );
- // no quote allowed
+ // quoted value
value = "( 1.1 SYNTAX 1.1 EQUALITY 'caseExcactMatch' )";
- try
- {
- atd = parser.parseAttributeTypeDescription( value );
- fail( "Exception expected, invalid EQUALITY 'caseExcactMatch' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "caseExcactMatch", atd.getEqualityMatchingRule() );
+
+ // quote value in parentheses
+ value = "( 1.1 SYNTAX 1.1 EQUALITY ('caseExcactMatch') )";
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "caseExcactMatch", atd.getEqualityMatchingRule() );
}
@@ -263,17 +254,15 @@
atd = parser.parseAttributeTypeDescription( value );
assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", atd.getOrderingMatchingRule() );
- // no quote allowed
+ // quoted value
value = "( 1.1 SYNTAX 1.1 ORDERING 'generalizedTimeOrderingMatch' )";
- try
- {
- atd = parser.parseAttributeTypeDescription( value );
- fail( "Exception expected, invalid ORDERING 'generalizedTimeOrderingMatch' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "generalizedTimeOrderingMatch", atd.getOrderingMatchingRule() );
+
+ // quote value in parentheses
+ value = "( 1.1 SYNTAX 1.1 ORDERING ('generalizedTimeOrderingMatch') )";
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "generalizedTimeOrderingMatch", atd.getOrderingMatchingRule() );
}
@@ -310,17 +299,15 @@
assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", atd
.getSubstringsMatchingRule() );
- // no quote allowed
+ // quoted value
value = "( 1.1 SYNTAX 1.1 SUBSTR 'caseIgnoreSubstringsMatch' )";
- try
- {
- atd = parser.parseAttributeTypeDescription( value );
- fail( "Exception expected, invalid SUBSTR 'caseIgnoreSubstringsMatch' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "caseIgnoreSubstringsMatch", atd.getSubstringsMatchingRule() );
+
+ // quote value in parentheses
+ value = "( 1.1 SYNTAX 1.1 SUBSTR ('caseIgnoreSubstringsMatch') )";
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "caseIgnoreSubstringsMatch", atd.getSubstringsMatchingRule() );
}
@@ -346,6 +333,18 @@
assertEquals( "1.2.3.4567.8.9.0", atd.getSyntax() );
assertEquals( 0, atd.getSyntaxLength() );
+ // quoted numericoid
+ value = "( 1.1 SYNTAX '1.2.3.4567.8.9.0' )";
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "1.2.3.4567.8.9.0", atd.getSyntax() );
+ assertEquals( 0, atd.getSyntaxLength() );
+
+ // quoted numericoid
+ value = "( 1.1 SYNTAX ('1.2.3.4567.8.9.0') )";
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "1.2.3.4567.8.9.0", atd.getSyntax() );
+ assertEquals( 0, atd.getSyntaxLength() );
+
// SYNTAX numericoid and length, no spaces
value = "(1.1 SYNTAX1.2.3.4567.8.9.0{1234567890})";
atd = parser.parseAttributeTypeDescription( value );
@@ -364,19 +363,19 @@
assertEquals( "1.2.3", atd.getSyntax() );
assertEquals( 0, atd.getSyntaxLength() );
- // no quote allowed
+ // quoted value
value = "( 1.1 SYNTAX '1.2.3{32}' )";
- try
- {
- atd = parser.parseAttributeTypeDescription( value );
- fail( "Exception expected, invalid SYNTAX '1.2.3{32}' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "1.2.3", atd.getSyntax() );
+ assertEquals( 32, atd.getSyntaxLength() );
+
+ // quote value in parentheses
+ value = "( 1.1 SYNTAX ( '1.2.3{32}' ) )";
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "1.2.3", atd.getSyntax() );
+ assertEquals( 32, atd.getSyntaxLength() );
- // empty syntax
+ // empty length
value = "( 1.1 SYNTAX 1.2.3.4{} )";
try
{
@@ -390,17 +389,11 @@
// 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 in length)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( "1.2.3.4", atd.getSyntax() );
+ assertEquals( 1, atd.getSyntaxLength() );
- // invalid syntax
+ // invalid syntax length
value = "( 1.1 SYNTAX 1.2.3.4{X} )";
try
{
@@ -591,7 +584,10 @@
atd = parser.parseAttributeTypeDescription( value );
assertEquals( UsageEnum.DSA_OPERATION, atd.getUsage() );
- // TODO: case insensitive?
+ // directoryOperation, case insensitivity
+ value = "( 1.1 SYNTAX 1.1 USAGE DiReCtOrYoPeRaTiOn )";
+ atd = parser.parseAttributeTypeDescription( value );
+ assertEquals( UsageEnum.DIRECTORY_OPERATION, atd.getUsage() );
// ivalid
value = "( 1.1 SYNTAX 1.1 USAGE abc )";
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java Tue Jun 3 12:13:03 2008
@@ -173,27 +173,22 @@
// no quote allowed
value = "( 1.1 AUX 'top' )";
- try
- {
- dcrd = parser.parseDITContentRuleDescription( value );
- fail( "Exception expected, invalid AUX 'top' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ dcrd = parser.parseDITContentRuleDescription( value );
+ assertEquals( 1, dcrd.getAuxiliaryObjectClasses().size() );
+ assertEquals( "top", dcrd.getAuxiliaryObjectClasses().get( 0 ) );
- // no quote allowed
+ // quoted value
value = "( 1.1 AUX '1.2.3.4' )";
- try
- {
- dcrd = parser.parseDITContentRuleDescription( value );
- fail( "Exception expected, invalid AUX '1.2.3.4' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ dcrd = parser.parseDITContentRuleDescription( value );
+ assertEquals( 1, dcrd.getAuxiliaryObjectClasses().size() );
+ assertEquals( "1.2.3.4", dcrd.getAuxiliaryObjectClasses().get( 0 ) );
+
+ // no $ separator
+ value = "( 1.1 AUX ( top1 top2 ) )";
+ dcrd = parser.parseDITContentRuleDescription( value );
+ assertEquals( 2, dcrd.getAuxiliaryObjectClasses().size() );
+ assertEquals( "top1", dcrd.getAuxiliaryObjectClasses().get( 0 ) );
+ assertEquals( "top2", dcrd.getAuxiliaryObjectClasses().get( 1 ) );
// invalid character
value = "( 1.1 AUX 1.2.3.4.A )";
@@ -219,18 +214,6 @@
// expected
}
- // invalid separator
- value = "( 1.1 AUX ( top1 top2 ) )";
- try
- {
- dcrd = parser.parseDITContentRuleDescription( value );
- fail( "Exception expected, invalid separator (no DOLLAR)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
-
// empty AUX
value = "( 1.1 AUX )";
try
@@ -268,7 +251,7 @@
assertEquals( "1.2.3", dcrd.getMustAttributeTypes().get( 0 ) );
// MUST mulitple
- value = "(1.1 MUST (cn$sn $11.22.33.44.55 $ objectClass ))";
+ value = "(1.1 MUST (cn\rsn $11.22.33.44.55 objectClass\t))";
dcrd = parser.parseDITContentRuleDescription( value );
assertEquals( 4, dcrd.getMustAttributeTypes().size() );
assertEquals( "cn", dcrd.getMustAttributeTypes().get( 0 ) );
@@ -358,19 +341,19 @@
String value = null;
DITContentRuleDescription dcrd = null;
- // no MAY
+ // no NOT
value = "( 1.1 )";
dcrd = parser.parseDITContentRuleDescription( value );
assertEquals( 0, dcrd.getNotAttributeTypes().size() );
- // MAY simple numericoid
+ // NOT simple numericoid
value = "( 1.1 NOT 1.2.3 )";
dcrd = parser.parseDITContentRuleDescription( value );
assertEquals( 1, dcrd.getNotAttributeTypes().size() );
assertEquals( "1.2.3", dcrd.getNotAttributeTypes().get( 0 ) );
- // MAY mulitple
- value = "(1.1 NOT (cn$sn $11.22.33.44.55 $ objectClass ))";
+ // NOT mulitple
+ value = "(1.1 NOT (cn\nsn\t$11.22.33.44.55 $ objectClass ))";
dcrd = parser.parseDITContentRuleDescription( value );
assertEquals( 4, dcrd.getNotAttributeTypes().size() );
assertEquals( "cn", dcrd.getNotAttributeTypes().get( 0 ) );
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java Tue Jun 3 12:13:03 2008
@@ -206,29 +206,15 @@
dsrd = parser.parseDITStructureRuleDescription( value );
assertEquals( "abc", dsrd.getForm() );
- // no quote allowed
+ // quoted value
value = "( 1 FORM '1.2.3.4.5.6.7.8.9.0' )";
- try
- {
- dsrd = parser.parseDITStructureRuleDescription( value );
- fail( "Exception expected, invalid FORM '1.2.3.4.5.6.7.8.9.0' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ dsrd = parser.parseDITStructureRuleDescription( value );
+ assertEquals( "1.2.3.4.5.6.7.8.9.0", dsrd.getForm() );
// no quote allowed
- value = "( 1 FORM 'test' )";
- try
- {
- dsrd = parser.parseDITStructureRuleDescription( value );
- fail( "Exception expected, invalid FORM 'test' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ value = "( 1 FORM ('test') )";
+ dsrd = parser.parseDITStructureRuleDescription( value );
+ assertEquals( "test", dsrd.getForm() );
// invalid character
value = "( 1 FORM 1.2.3.4.A )";
@@ -254,7 +240,7 @@
// expected
}
- // no multi value
+ // no multiple values
value = "( 1 FORM ( test1 test2 ) )";
try
{
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/LdapSyntaxDescriptionSchemaParserTest.java Tue Jun 3 12:13:03 2008
@@ -62,6 +62,17 @@
/**
+ * Tests NAMES
+ *
+ * @throws ParseException
+ */
+ public void testNames() throws ParseException
+ {
+ SchemaParserTestUtils.testNames( parser, "1.1", "" );
+ }
+
+
+ /**
* Tests DESC
*
* @throws ParseException
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleDescriptionSchemaParserTest.java Tue Jun 3 12:13:03 2008
@@ -94,6 +94,11 @@
mrd = parser.parseMatchingRuleDescription( value );
assertEquals( "0.1.2.3.4.5.6.7.8.9", mrd.getSyntax() );
+ // quoted value in parentheses
+ value = "( 1.1 SYNTAX ('0.1.2.3.4.5.6.7.8.9') )";
+ mrd = parser.parseMatchingRuleDescription( value );
+ assertEquals( "0.1.2.3.4.5.6.7.8.9", mrd.getSyntax() );
+
// non-numeric not allowed
value = "( test )";
try
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/MatchingRuleUseDescriptionSchemaParserTest.java Tue Jun 3 12:13:03 2008
@@ -144,29 +144,24 @@
assertEquals( "1.2.3.4", mrud.getApplicableAttributes().get( 1 ) );
assertEquals( "test2", mrud.getApplicableAttributes().get( 2 ) );
- // no quote allowed
+ // quoted value
value = "( 1.1 APPLIES 'test' )";
- try
- {
- mrud = parser.parseMatchingRuleUseDescription( value );
- fail( "Exception expected, invalid APPLIES 'test' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ mrud = parser.parseMatchingRuleUseDescription( value );
+ assertEquals( 1, mrud.getApplicableAttributes().size() );
+ assertEquals( "test", mrud.getApplicableAttributes().get( 0 ) );
- // no quote allowed
+ // quoted value
value = "( 1.1 APPLIES '1.2.3.4' )";
- try
- {
- mrud = parser.parseMatchingRuleUseDescription( value );
- fail( "Exception expected, invalid APPLIES '1.2.3.4' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ mrud = parser.parseMatchingRuleUseDescription( value );
+ assertEquals( 1, mrud.getApplicableAttributes().size() );
+ assertEquals( "1.2.3.4", mrud.getApplicableAttributes().get( 0 ) );
+
+ // no $ separator
+ value = "( 1.1 APPLIES ( test1 test2 ) )";
+ mrud = parser.parseMatchingRuleUseDescription( value );
+ assertEquals( 2, mrud.getApplicableAttributes().size() );
+ assertEquals( "test1", mrud.getApplicableAttributes().get( 0 ) );
+ assertEquals( "test2", mrud.getApplicableAttributes().get( 1 ) );
// invalid character
value = "( 1.1 APPLIES 1.2.3.4.A )";
@@ -192,18 +187,6 @@
// 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
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/NameFormDescriptionSchemaParserTest.java Tue Jun 3 12:13:03 2008
@@ -120,29 +120,15 @@
assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", nfd
.getStructuralObjectClass() );
- // no quote allowed
+ // quoted value
value = "( 1.1 MUST m OC '1.2.3.4.5.6.7.8.9.0' )";
- try
- {
- nfd = parser.parseNameFormDescription( value );
- fail( "Exception expected, invalid FORM '1.2.3.4.5.6.7.8.9.0' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ nfd = parser.parseNameFormDescription( value );
+ assertEquals( "1.2.3.4.5.6.7.8.9.0", nfd.getStructuralObjectClass() );
- // no quote allowed
+ // quoted value
value = "( 1.1 MUST m OC 'test' )";
- try
- {
- nfd = parser.parseNameFormDescription( value );
- fail( "Exception expected, invalid OC 'test' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ nfd = parser.parseNameFormDescription( value );
+ assertEquals( "test", nfd.getStructuralObjectClass() );
// invalid character
value = "( 1.1 MUST m OC 1.2.3.4.A )";
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/ObjectClassDescriptionSchemaParserTest.java Tue Jun 3 12:13:03 2008
@@ -172,29 +172,24 @@
assertEquals( "1.2.3.4", ocd.getSuperiorObjectClasses().get( 1 ) );
assertEquals( "top2", ocd.getSuperiorObjectClasses().get( 2 ) );
- // no quote allowed
+ // quoted value
value = "( 1.1 SUP 'top' )";
- try
- {
- ocd = parser.parseObjectClassDescription( value );
- fail( "Exception expected, invalid SUP 'top' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ ocd = parser.parseObjectClassDescription( value );
+ assertEquals( 1, ocd.getSuperiorObjectClasses().size() );
+ assertEquals( "top", ocd.getSuperiorObjectClasses().get( 0 ) );
- // no quote allowed
+ // quoted value
value = "( 1.1 SUP '1.2.3.4' )";
- try
- {
- ocd = parser.parseObjectClassDescription( value );
- fail( "Exception expected, invalid SUP '1.2.3.4' (quoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ ocd = parser.parseObjectClassDescription( value );
+ assertEquals( 1, ocd.getSuperiorObjectClasses().size() );
+ assertEquals( "1.2.3.4", ocd.getSuperiorObjectClasses().get( 0 ) );
+
+ // no $ separator
+ value = "( 1.1 SUP ( top1 top2 ) )";
+ ocd = parser.parseObjectClassDescription( value );
+ assertEquals( 2, ocd.getSuperiorObjectClasses().size() );
+ assertEquals( "top1", ocd.getSuperiorObjectClasses().get( 0 ) );
+ assertEquals( "top2", ocd.getSuperiorObjectClasses().get( 1 ) );
// invalid character
value = "( 1.1 SUP 1.2.3.4.A )";
@@ -220,18 +215,6 @@
// expected
}
- // invalid separator
- value = "( 1.1 SUP ( top1 top2 ) )";
- try
- {
- ocd = parser.parseObjectClassDescription( value );
- fail( "Exception expected, invalid separator (no DOLLAR)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
-
// empty sup
value = "( 1.1 SUP )";
try
@@ -276,7 +259,12 @@
ocd = parser.parseObjectClassDescription( value );
assertEquals( ObjectClassTypeEnum.STRUCTURAL, ocd.getKind() );
- // ivalid
+ // STRUCTURAL, case-insensitive
+ value = "(1.1 sTrUcTuRaL )";
+ ocd = parser.parseObjectClassDescription( value );
+ assertEquals( ObjectClassTypeEnum.STRUCTURAL, ocd.getKind() );
+
+ // invalid
value = "( 1.1 FOO )";
try
{
@@ -312,7 +300,7 @@
assertEquals( 1, ocd.getMustAttributeTypes().size() );
assertEquals( "1.2.3", ocd.getMustAttributeTypes().get( 0 ) );
- // MUST mulitple
+ // MUST multiple
value = "(1.1 MUST(cn$sn\r$11.22.33.44.55 $ objectClass ))";
ocd = parser.parseObjectClassDescription( value );
assertEquals( 4, ocd.getMustAttributeTypes().size() );
@@ -321,6 +309,15 @@
assertEquals( "11.22.33.44.55", ocd.getMustAttributeTypes().get( 2 ) );
assertEquals( "objectClass", ocd.getMustAttributeTypes().get( 3 ) );
+ // MUST multiple, no $ separator
+ value = "(1.1 MUST(cn sn\t'11.22.33.44.55'\n'objectClass'))";
+ ocd = parser.parseObjectClassDescription( value );
+ assertEquals( 4, ocd.getMustAttributeTypes().size() );
+ assertEquals( "cn", ocd.getMustAttributeTypes().get( 0 ) );
+ assertEquals( "sn", ocd.getMustAttributeTypes().get( 1 ) );
+ assertEquals( "11.22.33.44.55", ocd.getMustAttributeTypes().get( 2 ) );
+ assertEquals( "objectClass", ocd.getMustAttributeTypes().get( 3 ) );
+
// invalid value
value = "( 1.1 MUST ( c_n ) )";
try
@@ -369,7 +366,7 @@
assertEquals( 1, ocd.getMayAttributeTypes().size() );
assertEquals( "1.2.3", ocd.getMayAttributeTypes().get( 0 ) );
- // MAY mulitple
+ // MAY multiple
value = "(1.1 MAY(cn$sn $11.22.33.44.55\n$ objectClass ))";
ocd = parser.parseObjectClassDescription( value );
assertEquals( 4, ocd.getMayAttributeTypes().size() );
@@ -378,6 +375,15 @@
assertEquals( "11.22.33.44.55", ocd.getMayAttributeTypes().get( 2 ) );
assertEquals( "objectClass", ocd.getMayAttributeTypes().get( 3 ) );
+ // MAY multiple, no $ separator, quoted
+ value = "(1.1 MAY('cn' sn\t'11.22.33.44.55'\nobjectClass))";
+ ocd = parser.parseObjectClassDescription( value );
+ assertEquals( 4, ocd.getMayAttributeTypes().size() );
+ assertEquals( "cn", ocd.getMayAttributeTypes().get( 0 ) );
+ assertEquals( "sn", ocd.getMayAttributeTypes().get( 1 ) );
+ assertEquals( "11.22.33.44.55", ocd.getMayAttributeTypes().get( 2 ) );
+ assertEquals( "objectClass", ocd.getMayAttributeTypes().get( 3 ) );
+
// invalid value
value = "( 1.1 MAY ( c_n ) )";
try
@@ -456,23 +462,14 @@
public void testUniqueElements()
{
String[] testValues = new String[]
- {
- "( 1.1 NAME 'test1' NAME 'test2' )",
- "( 1.1 DESC 'test1' DESC 'test2' )",
- "( 1.1 OBSOLETE OBSOLETE )",
- "( 1.1 SUP test1 SUP test2 )",
- "( 1.1 STRUCTURAL STRUCTURAL )",
- "( 1.1 ABSTRACT ABSTRACT )",
- "( 1.1 AUXILIARY AUXILIARY )",
- "( 1.1 STRUCTURAL AUXILIARY AUXILIARY )",
- "( 1.1 MUST test1 MUST test2 )",
- "( 1.1 MAY test1 MAY test2 )",
- "( 1.1 X-TEST 'test1' X-TEST 'test2' )"
- };
+ { "( 1.1 NAME 'test1' NAME 'test2' )", "( 1.1 DESC 'test1' DESC 'test2' )", "( 1.1 OBSOLETE OBSOLETE )",
+ "( 1.1 SUP test1 SUP test2 )", "( 1.1 STRUCTURAL STRUCTURAL )", "( 1.1 ABSTRACT ABSTRACT )",
+ "( 1.1 AUXILIARY AUXILIARY )", "( 1.1 STRUCTURAL AUXILIARY AUXILIARY )",
+ "( 1.1 MUST test1 MUST test2 )", "( 1.1 MAY test1 MAY test2 )", "( 1.1 X-TEST 'test1' X-TEST 'test2' )" };
SchemaParserTestUtils.testUnique( parser, testValues );
}
-
-
+
+
/**
* Ensure that element order is ignored
*
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java?rev=662861&r1=662860&r2=662861&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java Tue Jun 3 12:13:03 2008
@@ -94,7 +94,17 @@
Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
// simple with tabs, newline, comment.
- value = "(\t0.1.2.3.4.5.6.7.8.9\n#comment\n\t" + required + "\r\n)\r";
+ value = "(\t0.1.2.3.4.5.6.7.8.9\n#comment\n" + required + "\r\n)\r";
+ asd = parser.parse( value );
+ Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
+
+ // quoted OID
+ value = "( '0.1.2.3.4.5.6.7.8.9' " + required + " )";
+ asd = parser.parse( value );
+ Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
+
+ // quoted OID in parentheses
+ value = "( ('0.1.2.3.4.5.6.7.8.9') " + required + " )";
asd = parser.parse( value );
Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
@@ -146,42 +156,41 @@
// expected
}
- // quotes not allowed
- value = "( '1.1' " + required + " )";
+ // leading 0 not allowed
+ value = "( 01.1 " + required + " )";
try
{
parser.parse( value );
- Assert.fail( "Exception expected, invalid NUMERICOID '1.1' (quoted)" );
+ Assert.fail( "Exception expected, invalid NUMERICOID 01.1 (leading zero)" );
}
catch ( ParseException pe )
{
// expected
}
- // leading 0 not allowed
- value = "( 01.1 " + required + " )";
+ // alpha not allowed
+ value = "( 1.2.a.4 " + required + " )";
try
{
parser.parse( value );
- Assert.fail( "Exception expected, invalid NUMERICOID 01.1 (leading zero)" );
+ Assert.fail( "Exception expected, invalid NUMERICOID 1.2.a.4 (alpha not allowed)" );
}
catch ( ParseException pe )
{
- // expected
+ // excpected
}
- // alpha not allowed
- value = "( 1.2.a.4 " + required + " )";
+ // multiple not allowed
+ value = "( ( 1.2.3 4.5.6 ) " + required + " )";
try
{
parser.parse( value );
- Assert.fail( "Exception expected, invalid NUMERICOID 1.2.a.4 (alpha not allowed)" );
+ Assert.fail( "Exception expected, invalid multiple OIDs not allowed.)" );
}
catch ( ParseException pe )
{
- Assert.assertTrue( true );
+ // excpected
}
-
}
@@ -260,17 +269,18 @@
Assert.assertEquals( 1, asd.getNames().size() );
Assert.assertEquals( "test", asd.getNames().get( 0 ) );
- // unquoted
+ // unquoted NAME value
value = "( " + oid + " " + required + " NAME test )";
- try
- {
- parser.parse( value );
- Assert.fail( "Exception expected, invalid NAME test (unquoted)" );
- }
- catch ( ParseException pe )
- {
- // expected
- }
+ asd = parser.parse( value );
+ Assert.assertEquals( 1, asd.getNames().size() );
+ Assert.assertEquals( "test", asd.getNames().get( 0 ) );
+
+ // multi unquoted NAME values
+ value = " ( " + oid + " " + required + " NAME (test1 test2) ) ";
+ asd = parser.parse( value );
+ Assert.assertEquals( 2, asd.getNames().size() );
+ Assert.assertEquals( "test1", asd.getNames().get( 0 ) );
+ Assert.assertEquals( "test2", asd.getNames().get( 1 ) );
// start with number
value = "( " + oid + " " + required + " NAME '1test' )";
@@ -360,6 +370,11 @@
asd = parser.parse( value );
Assert.assertEquals( "Descripton", asd.getDescription() );
+ // simple parentheses and quotes
+ value = "(" + oid + " " + required + " DESC ('Descripton') )";
+ asd = parser.parse( value );
+ Assert.assertEquals( "Descripton", asd.getDescription() );
+
// unicode
value = "( " + oid + " " + required + " DESC 'Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577' )";
asd = parser.parse( value );
@@ -383,6 +398,23 @@
value = "( " + oid + " " + required + " desc 'Descripton' )";
asd = parser.parse( value );
Assert.assertEquals( "Descripton", asd.getDescription() );
+
+ // empty DESC
+ value = "( " + oid + " " + required + " DESC '' )";
+ asd = parser.parse( value );
+ Assert.assertEquals( "", asd.getDescription() );
+
+ // multiple not allowed
+ value = "(" + oid + " " + required + " DESC ( 'Descripton1' 'Description 2' ) )";
+ try
+ {
+ parser.parse( value );
+ Assert.fail( "Exception expected, invalid multiple DESC not allowed.)" );
+ }
+ catch ( ParseException pe )
+ {
+ // expected
+ }
}
@@ -516,6 +548,11 @@
asd = parser.parse( value );
Assert.assertTrue( asd.isObsolete() );
+ // lowercased obsolete
+ value = "(" + oid + " " + required + " obsolete)";
+ asd = parser.parse( value );
+ Assert.assertTrue( asd.isObsolete() );
+
// invalid
value = "(" + oid + " " + required + " NAME 'test' DESC 'Descripton' OBSOLET )";
try
|