You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/07/07 17:06:33 UTC
svn commit: r961400 - in /directory/shared/trunk/ldap-aci: ./
src/main/antlr/ src/main/java/org/apache/directory/shared/ldap/aci/
src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/
src/main/java/org/apache/directory/shared/ldap/schema/sy...
Author: elecharny
Date: Wed Jul 7 15:06:33 2010
New Revision: 961400
URL: http://svn.apache.org/viewvc?rev=961400&view=rev
Log:
adding the subtree handling
Added:
directory/shared/trunk/ldap-aci/src/main/antlr/SubtreeSpecificationChecker.g
directory/shared/trunk/ldap-aci/src/main/antlr/subtree-specification.g
directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java
directory/shared/trunk/ldap-aci/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java
Modified:
directory/shared/trunk/ldap-aci/pom.xml
directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RangeOfValuesItem.java
Modified: directory/shared/trunk/ldap-aci/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-aci/pom.xml?rev=961400&r1=961399&r2=961400&view=diff
==============================================================================
--- directory/shared/trunk/ldap-aci/pom.xml (original)
+++ directory/shared/trunk/ldap-aci/pom.xml Wed Jul 7 15:06:33 2010
@@ -84,7 +84,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antlr-plugin</artifactId>
<configuration>
- <grammars>ACIItem.g ACIItemChecker.g</grammars>
+ <grammars>ACIItem.g ACIItemChecker.g subtree-specification.g SubtreeSpecificationChecker.g</grammars>
</configuration>
<executions>
<execution>
Added: directory/shared/trunk/ldap-aci/src/main/antlr/SubtreeSpecificationChecker.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-aci/src/main/antlr/SubtreeSpecificationChecker.g?rev=961400&view=auto
==============================================================================
--- directory/shared/trunk/ldap-aci/src/main/antlr/SubtreeSpecificationChecker.g (added)
+++ directory/shared/trunk/ldap-aci/src/main/antlr/SubtreeSpecificationChecker.g Wed Jul 7 15:06:33 2010
@@ -0,0 +1,466 @@
+header
+{
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+
+package org.apache.directory.shared.ldap.subtree;
+
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.BranchNode;
+import org.apache.directory.shared.ldap.filter.AndNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
+import org.apache.directory.shared.ldap.filter.FilterParser;
+import org.apache.directory.shared.ldap.util.ComponentsMonitor;
+import org.apache.directory.shared.ldap.util.OptionalComponentsMonitor;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+}
+
+
+// ----------------------------------------------------------------------------
+// parser class definition
+// ----------------------------------------------------------------------------
+
+/**
+ * The antlr generated subtree specification parser.
+ *
+ * @see <a href="http://www.faqs.org/rfcs/rfc3672.html">RFC 3672</a>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+class AntlrSubtreeSpecificationChecker extends Parser;
+
+
+// ----------------------------------------------------------------------------
+// parser options
+// ----------------------------------------------------------------------------
+
+options
+{
+ k = 1;
+ defaultErrorHandler = false;
+}
+
+
+// ----------------------------------------------------------------------------
+// parser initialization
+// ----------------------------------------------------------------------------
+
+{
+ private static final Logger log = LoggerFactory.getLogger( AntlrSubtreeSpecificationChecker.class );
+
+ private ComponentsMonitor subtreeSpecificationComponentsMonitor = null;
+
+ /** The SchemaManager */
+ private SchemaManager schemaManager;
+
+ /**
+ * Initiaize the checker
+ */
+ public void init( SchemaManager schemaManager )
+ {
+ this.schemaManager = schemaManager;
+ }
+
+
+ private int token2Integer( Token token ) throws RecognitionException
+ {
+ int i = 0;
+
+ try
+ {
+ i = Integer.parseInt( token.getText());
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new RecognitionException( "Value of INTEGER token " +
+ token.getText() +
+ " cannot be converted to an Integer" );
+ }
+
+ return i;
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// parser productions
+// ----------------------------------------------------------------------------
+
+wrapperEntryPoint
+{
+ log.debug( "entered wrapperEntryPoint()" );
+} :
+ subtreeSpecification "end"
+ ;
+
+subtreeSpecification
+{
+ log.debug( "entered subtreeSpecification()" );
+ subtreeSpecificationComponentsMonitor = new OptionalComponentsMonitor(
+ new String [] { "base", "specificExclusions", "minimum", "maximum", "specificationFilter" } );
+}
+ :
+ OPEN_CURLY ( SP )*
+ ( subtreeSpecificationComponent ( SP )*
+ ( SEP ( SP )* subtreeSpecificationComponent ( SP )* )* )?
+ CLOSE_CURLY
+ ;
+
+subtreeSpecificationComponent
+{
+ log.debug( "entered subtreeSpecification()" );
+}
+ :
+ ss_base
+ {
+ subtreeSpecificationComponentsMonitor.useComponent( "base" );
+ }
+ | ss_specificExclusions
+ {
+ subtreeSpecificationComponentsMonitor.useComponent( "specificExclusions" );
+ }
+ | ss_minimum
+ {
+ subtreeSpecificationComponentsMonitor.useComponent( "minimum" );
+ }
+ | ss_maximum
+ {
+ subtreeSpecificationComponentsMonitor.useComponent( "maximum" );
+ }
+ | ss_specificationFilter
+ {
+ subtreeSpecificationComponentsMonitor.useComponent( "specificationFilter" );
+ }
+ ;
+ exception
+ catch [IllegalArgumentException e]
+ {
+ throw new RecognitionException( e.getMessage() );
+ }
+
+ss_base
+{
+ log.debug( "entered ss_base()" );
+}
+ :
+ ID_base ( SP )+ distinguishedName
+ ;
+
+ss_specificExclusions
+{
+ log.debug( "entered ss_specificExclusions()" );
+}
+ :
+ ID_specificExclusions ( SP )+ specificExclusions
+ ;
+
+specificExclusions
+{
+ log.debug( "entered specificExclusions()" );
+}
+ :
+ OPEN_CURLY ( SP )*
+ ( specificExclusion ( SP )*
+ ( SEP ( SP )* specificExclusion ( SP )* )*
+ )?
+ CLOSE_CURLY
+ ;
+
+specificExclusion
+{
+ log.debug( "entered specificExclusion()" );
+}
+ :
+ chopBefore | chopAfter
+ ;
+
+chopBefore
+{
+ log.debug( "entered chopBefore()" );
+}
+ :
+ ID_chopBefore ( SP )* COLON ( SP )* distinguishedName
+ ;
+
+chopAfter
+{
+ log.debug( "entered chopAfter()" );
+}
+ :
+ ID_chopAfter ( SP )* COLON ( SP )* distinguishedName
+ ;
+
+ss_minimum
+{
+ log.debug( "entered ss_minimum()" );
+}
+ :
+ ID_minimum ( SP )+ baseDistance
+ ;
+
+ss_maximum
+{
+ log.debug( "entered ss_maximum()" );
+}
+ :
+ ID_maximum ( SP )+ baseDistance
+ ;
+
+ss_specificationFilter
+{
+ log.debug( "entered ss_specificationFilter()" );
+}
+ :
+ ID_specificationFilter
+ ( SP )+
+ (
+ ( refinement )
+ |
+ ( filter )
+ )
+ ;
+
+filter
+{
+ log.debug( "entered filter()" );
+}
+ :
+ ( filterToken:FILTER { FilterParser.parse( filterToken.getText() ); } )
+ ;
+ exception
+ catch [Exception e]
+ {
+ throw new RecognitionException( "filterParser failed. " + e.getMessage() );
+ }
+
+
+distinguishedName
+{
+ log.debug( "entered distinguishedName()" );
+}
+ :
+ token:SAFEUTF8STRING
+ {
+ new DN( token.getText() );
+ log.debug( "recognized a DistinguishedName: " + token.getText() );
+ }
+ ;
+ exception
+ catch [Exception e]
+ {
+ throw new RecognitionException( "dnParser failed for " + token.getText() + " " + e.getMessage() );
+ }
+
+baseDistance
+{
+ log.debug( "entered baseDistance()" );
+}
+ :
+ token:INTEGER
+ {
+ token2Integer(token);
+ }
+ ;
+
+oid
+{
+ log.debug( "entered oid()" );
+ Token token = null;
+}
+ :
+ { token = LT( 1 ); } // an interesting trick goes here ;-)
+ ( DESCR | NUMERICOID )
+ {
+ log.debug( "recognized an oid: " + token.getText() );
+ }
+ ;
+
+refinement
+{
+ log.debug( "entered refinement()" );
+}
+ :
+ item | and | or | not
+ ;
+
+item
+{
+ log.debug( "entered item()" );
+}
+ :
+ ID_item ( SP )* COLON ( SP )* oid
+ ;
+
+and
+{
+ log.debug( "entered and()" );
+}
+ :
+ ID_and ( SP )* COLON ( SP )* refinements
+ ;
+
+or
+{
+ log.debug( "entered or()" );
+}
+ :
+ ID_or ( SP )* COLON ( SP )* refinements
+ ;
+
+not
+{
+ log.debug( "entered not()" );
+}
+ :
+ ID_not ( SP )* COLON ( SP )* refinement
+ ;
+
+refinements
+{
+ log.debug( "entered refinements()" );
+}
+ :
+ OPEN_CURLY ( SP )*
+ (
+ refinement ( SP )*
+ ( SEP ( SP )* refinement ( SP )* )*
+ )? CLOSE_CURLY
+ ;
+
+
+// ----------------------------------------------------------------------------
+// lexer class definition
+// ----------------------------------------------------------------------------
+
+/**
+ * The parser's primary lexer.
+ *
+ * @see <a href="http://www.faqs.org/rfcs/rfc3672.html">RFC 3672</a>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+class AntlrSubtreeSpecificationCheckerLexer extends Lexer;
+
+
+// ----------------------------------------------------------------------------
+// lexer options
+// ----------------------------------------------------------------------------
+
+options
+{
+ k = 2;
+
+ charVocabulary = '\u0001'..'\u0127';
+}
+
+tokens
+{
+ ID_base = "base";
+ ID_specificExclusions = "specificExclusions";
+ ID_chopBefore = "chopBefore";
+ ID_chopAfter = "chopAfter";
+ ID_minimum = "minimum";
+ ID_maximum = "maximum";
+ ID_specificationFilter = "specificationFilter";
+ ID_item = "item";
+ ID_and = "and";
+ ID_or = "or";
+ ID_not = "not";
+}
+
+
+//----------------------------------------------------------------------------
+// lexer initialization
+//----------------------------------------------------------------------------
+
+{
+ private static final Logger log = LoggerFactory.getLogger( AntlrSubtreeSpecificationLexer.class );
+}
+
+
+// ----------------------------------------------------------------------------
+// attribute description lexer rules from models
+// ----------------------------------------------------------------------------
+
+SP : ' ';
+
+COLON : ':' { log.debug( "matched COLON(':')" ); } ;
+
+OPEN_CURLY : '{' { log.debug( "matched LBRACKET('{')" ); } ;
+
+CLOSE_CURLY : '}' { log.debug( "matched RBRACKET('}')" ); } ;
+
+SEP : ',' { log.debug( "matched SEP(',')" ); } ;
+
+SAFEUTF8STRING : '"'! ( SAFEUTF8CHAR )* '"'! { log.debug( "matched SAFEUTF8CHAR: \"" + getText() + "\"" ); } ;
+
+DESCR : ALPHA ( ALPHA | DIGIT | '-' )* { log.debug( "matched DESCR" ); } ;
+
+INTEGER_OR_NUMERICOID
+ :
+ ( INTEGER DOT ) => NUMERICOID
+ {
+ $setType( NUMERICOID );
+ }
+ |
+ INTEGER
+ {
+ $setType( INTEGER );
+ }
+ ;
+
+protected INTEGER: DIGIT | ( LDIGIT ( DIGIT )+ ) { log.debug( "matched INTEGER: " + getText() ); } ;
+
+protected NUMERICOID: INTEGER ( DOT INTEGER )+ { log.debug( "matched NUMERICOID: " + getText() ); } ;
+
+protected DOT: '.' ;
+
+protected DIGIT: '0' | LDIGIT ;
+
+protected LDIGIT: '1'..'9' ;
+
+protected ALPHA: 'A'..'Z' | 'a'..'z' ;
+
+// This is all messed up - could not figure out how to get antlr to represent
+// the safe UTF-8 character set from RFC 3642 for production SafeUTF8Character
+
+protected SAFEUTF8CHAR:
+ '\u0001'..'\u0021' |
+ '\u0023'..'\u007F' |
+ '\u00c0'..'\u00d6' |
+ '\u00d8'..'\u00f6' |
+ '\u00f8'..'\u00ff' |
+ '\u0100'..'\u1fff' |
+ '\u3040'..'\u318f' |
+ '\u3300'..'\u337f' |
+ '\u3400'..'\u3d2d' |
+ '\u4e00'..'\u9fff' |
+ '\uf900'..'\ufaff' ;
+
+FILTER : '(' ( ( '&' (SP)* (FILTER)+ ) | ( '|' (SP)* (FILTER)+ ) | ( '!' (SP)* FILTER ) | FILTER_VALUE ) ')' (SP)* ;
+
+protected FILTER_VALUE : (options{greedy=true;}: ~( ')' | '(' | '&' | '|' | '!' ) ( ~(')') )* ) ;
+
\ No newline at end of file
Added: directory/shared/trunk/ldap-aci/src/main/antlr/subtree-specification.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-aci/src/main/antlr/subtree-specification.g?rev=961400&view=auto
==============================================================================
--- directory/shared/trunk/ldap-aci/src/main/antlr/subtree-specification.g (added)
+++ directory/shared/trunk/ldap-aci/src/main/antlr/subtree-specification.g Wed Jul 7 15:06:33 2010
@@ -0,0 +1,592 @@
+header
+{
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+
+package org.apache.directory.shared.ldap.subtree;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.BranchNode;
+import org.apache.directory.shared.ldap.filter.AndNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
+import org.apache.directory.shared.ldap.filter.FilterParser;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
+import org.apache.directory.shared.ldap.subtree.SubtreeSpecificationModifier;
+import org.apache.directory.shared.ldap.schema.NormalizerMappingResolver;
+import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.util.ComponentsMonitor;
+import org.apache.directory.shared.ldap.util.OptionalComponentsMonitor;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.StringValue;
+import org.apache.directory.shared.ldap.exception.LdapException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+}
+
+
+// ----------------------------------------------------------------------------
+// parser class definition
+// ----------------------------------------------------------------------------
+
+/**
+ * The antlr generated subtree specification parser.
+ *
+ * @see <a href="http://www.faqs.org/rfcs/rfc3672.html">RFC 3672</a>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+class AntlrSubtreeSpecificationParser extends Parser;
+
+
+// ----------------------------------------------------------------------------
+// parser options
+// ----------------------------------------------------------------------------
+
+options
+{
+ k = 1;
+ defaultErrorHandler = false;
+}
+
+
+// ----------------------------------------------------------------------------
+// parser initialization
+// ----------------------------------------------------------------------------
+
+{
+ private static final Logger log = LoggerFactory.getLogger( AntlrSubtreeSpecificationParser.class );
+
+ private NormalizerMappingResolver resolver;
+
+ private Set<DN> chopBeforeExclusions = null;
+ private Set<DN> chopAfterExclusions = null;
+
+ private SubtreeSpecificationModifier ssModifier = null;
+
+ /** The schemaManager */
+ private SchemaManager schemaManager;
+
+ private ComponentsMonitor subtreeSpecificationComponentsMonitor = null;
+
+
+
+ /**
+ * Does nothing.
+ */
+ public void init( SchemaManager schemaManager )
+ {
+ this.schemaManager = schemaManager;
+ }
+
+
+ public void setNormalizerMappingResolver( NormalizerMappingResolver resolver )
+ {
+ this.resolver = resolver;
+ }
+
+
+ public boolean isNormalizing()
+ {
+ return this.resolver != null;
+ }
+
+
+ private int token2Integer( Token token ) throws RecognitionException
+ {
+ int i = 0;
+
+ try
+ {
+ i = Integer.parseInt( token.getText());
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new RecognitionException( "Value of INTEGER token " +
+ token.getText() +
+ " cannot be converted to an Integer" );
+ }
+
+ return i;
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// parser productions
+// ----------------------------------------------------------------------------
+
+wrapperEntryPoint returns [SubtreeSpecification ss]
+{
+ log.debug( "entered wrapperEntryPoint()" );
+ ss = null;
+ SubtreeSpecification tempSs = null;
+} :
+ tempSs=subtreeSpecification "end"
+ {
+ ss = tempSs;
+ }
+ ;
+
+subtreeSpecification returns [SubtreeSpecification ss]
+{
+ log.debug( "entered subtreeSpecification()" );
+ // clear out ss, ssModifier, subtreeSpecificationComponentsMonitor,
+ // chopBeforeExclusions and chopAfterExclusions
+ // in case something is left from the last parse
+ ss = null;
+ ssModifier = new SubtreeSpecificationModifier();
+ subtreeSpecificationComponentsMonitor = new OptionalComponentsMonitor(
+ new String [] { "base", "specificExclusions", "minimum", "maximum", "specificationFilter" } );
+ chopBeforeExclusions = new HashSet<DN>();
+ chopAfterExclusions = new HashSet<DN>();
+ // always create a new filter parser in case we may have some statefulness problems with it
+}
+ :
+ OPEN_CURLY ( SP )*
+ ( subtreeSpecificationComponent ( SP )*
+ ( SEP ( SP )* subtreeSpecificationComponent ( SP )* )* )?
+ CLOSE_CURLY
+ {
+ ss = ssModifier.getSubtreeSpecification();
+ }
+ ;
+
+subtreeSpecificationComponent
+{
+ log.debug( "entered subtreeSpecification()" );
+}
+ :
+ ss_base
+ {
+ subtreeSpecificationComponentsMonitor.useComponent( "base" );
+ }
+ | ss_specificExclusions
+ {
+ subtreeSpecificationComponentsMonitor.useComponent( "specificExclusions" );
+ }
+ | ss_minimum
+ {
+ subtreeSpecificationComponentsMonitor.useComponent( "minimum" );
+ }
+ | ss_maximum
+ {
+ subtreeSpecificationComponentsMonitor.useComponent( "maximum" );
+ }
+ | ss_specificationFilter
+ {
+ subtreeSpecificationComponentsMonitor.useComponent( "specificationFilter" );
+ }
+ ;
+ exception
+ catch [IllegalArgumentException e]
+ {
+ throw new RecognitionException( e.getMessage() );
+ }
+
+ss_base
+{
+ log.debug( "entered ss_base()" );
+ DN base = null;
+}
+ :
+ ID_base ( SP )+ base=distinguishedName
+ {
+ ssModifier.setBase( base );
+ }
+ ;
+
+ss_specificExclusions
+{
+ log.debug( "entered ss_specificExclusions()" );
+}
+ :
+ ID_specificExclusions ( SP )+ specificExclusions
+ {
+ ssModifier.setChopBeforeExclusions( chopBeforeExclusions );
+ ssModifier.setChopAfterExclusions( chopAfterExclusions );
+ }
+ ;
+
+specificExclusions
+{
+ log.debug( "entered specificExclusions()" );
+}
+ :
+ OPEN_CURLY ( SP )*
+ ( specificExclusion ( SP )*
+ ( SEP ( SP )* specificExclusion ( SP )* )*
+ )?
+ CLOSE_CURLY
+ ;
+
+specificExclusion
+{
+ log.debug( "entered specificExclusion()" );
+}
+ :
+ chopBefore | chopAfter
+ ;
+
+chopBefore
+{
+ log.debug( "entered chopBefore()" );
+ DN chopBeforeExclusion = null;
+}
+ :
+ ID_chopBefore ( SP )* COLON ( SP )* chopBeforeExclusion=distinguishedName
+ {
+ chopBeforeExclusions.add( chopBeforeExclusion );
+ }
+ ;
+
+chopAfter
+{
+ log.debug( "entered chopAfter()" );
+ DN chopAfterExclusion = null;
+}
+ :
+ ID_chopAfter ( SP )* COLON ( SP )* chopAfterExclusion=distinguishedName
+ {
+ chopAfterExclusions.add( chopAfterExclusion );
+ }
+ ;
+
+ss_minimum
+{
+ log.debug( "entered ss_minimum()" );
+ int minimum = 0;
+}
+ :
+ ID_minimum ( SP )+ minimum=baseDistance
+ {
+ ssModifier.setMinBaseDistance( minimum );
+ }
+ ;
+
+ss_maximum
+{
+ log.debug( "entered ss_maximum()" );
+ int maximum = 0;
+}
+ :
+ ID_maximum ( SP )+ maximum=baseDistance
+ {
+ ssModifier.setMaxBaseDistance( maximum );
+ }
+ ;
+
+ss_specificationFilter
+{
+ log.debug( "entered ss_specificationFilter()" );
+ ExprNode filterExpr = null;
+}
+ :
+ ID_specificationFilter
+ ( SP )+
+ (
+ ( filterExpr=refinement )
+ |
+ ( filterExpr=filter )
+ )
+ { ssModifier.setRefinement( filterExpr ); }
+ ;
+
+
+filter returns [ ExprNode filterExpr = null ]
+{
+ log.debug( "entered filter()" );
+}
+ :
+ ( filterToken:FILTER { filterExpr=FilterParser.parse( filterToken.getText() ); } )
+ ;
+ exception
+ catch [Exception e]
+ {
+ throw new RecognitionException( "filterParser failed. " + e.getMessage() );
+ }
+
+distinguishedName returns [ DN name ]
+{
+ log.debug( "entered distinguishedName()" );
+ name = null;
+}
+ :
+ token:SAFEUTF8STRING
+ {
+ name = new DN( token.getText() );
+ name.normalize( schemaManager.getNormalizerMapping() );
+
+ log.debug( "recognized a DistinguishedName: " + token.getText() );
+ }
+ ;
+ exception
+ catch [Exception e]
+ {
+ throw new RecognitionException( "dnParser failed for " + token.getText() + " " + e.getMessage() );
+ }
+
+baseDistance returns [ int distance ]
+{
+ log.debug( "entered baseDistance()" );
+ distance = 0;
+}
+ :
+ token:INTEGER
+ {
+ distance = token2Integer( token );
+ }
+ ;
+
+oid returns [ String result ]
+{
+ log.debug( "entered oid()" );
+ result = null;
+ Token token = null;
+}
+ :
+ { token = LT( 1 ); } // an interesting trick goes here ;-)
+ ( DESCR | NUMERICOID )
+ {
+ result = token.getText();
+ log.debug( "recognized an oid: " + result );
+ }
+ ;
+
+refinement returns [ ExprNode node ]
+{
+ log.debug( "entered refinement()" );
+ node = null;
+}
+ :
+ node=item | node=and | node=or | node=not
+ ;
+
+item returns [ LeafNode node ]
+{
+ log.debug( "entered item()" );
+ node = null;
+ String oid = null;
+ ObjectClass objectClass = null;
+}
+ :
+ ID_item ( SP )* COLON ( SP )* oid=oid
+ {
+ try
+ {
+ objectClass = schemaManager.lookupObjectClassRegistry( oid );
+ }
+ catch ( LdapException le )
+ {
+ // The oid does not exist
+ // TODO : deal with such an exception
+ }
+
+ node = new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, new StringValue( oid ) );
+ }
+ ;
+
+and returns [ BranchNode node ]
+{
+ log.debug( "entered and()" );
+ node = null;
+ List<ExprNode> children = null;
+}
+ :
+ ID_and ( SP )* COLON ( SP )* children=refinements
+ {
+ node = new AndNode( children );
+ }
+ ;
+
+or returns [ BranchNode node ]
+{
+ log.debug( "entered or()" );
+ node = null;
+ List<ExprNode> children = null;
+}
+ :
+ ID_or ( SP )* COLON ( SP )* children=refinements
+ {
+ node = new OrNode( children );
+ }
+ ;
+
+not returns [ BranchNode node ]
+{
+ log.debug( "entered not()" );
+ node = null;
+ ExprNode child = null;
+}
+ :
+ ID_not ( SP )* COLON ( SP )* child=refinement
+ {
+ node = new NotNode( child );
+ }
+ ;
+
+refinements returns [ List<ExprNode> children ]
+{
+ log.debug( "entered refinements()" );
+ children = null;
+ ExprNode child = null;
+ List<ExprNode> tempChildren = new ArrayList<ExprNode>();
+}
+ :
+ OPEN_CURLY ( SP )*
+ (
+ child=refinement ( SP )*
+ {
+ tempChildren.add( child );
+ }
+ ( SEP ( SP )* child=refinement ( SP )*
+ {
+ tempChildren.add( child );
+ } )*
+ )? CLOSE_CURLY
+ {
+ children = tempChildren;
+ }
+ ;
+
+
+// ----------------------------------------------------------------------------
+// lexer class definition
+// ----------------------------------------------------------------------------
+
+/**
+ * The parser's primary lexer.
+ *
+ * @see <a href="http://www.faqs.org/rfcs/rfc3672.html">RFC 3672</a>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+class AntlrSubtreeSpecificationLexer extends Lexer;
+
+
+// ----------------------------------------------------------------------------
+// lexer options
+// ----------------------------------------------------------------------------
+
+options
+{
+ k = 5;
+
+ charVocabulary = '\u0001'..'\u0127';
+}
+
+tokens
+{
+ ID_base = "base";
+ ID_specificExclusions = "specificExclusions";
+ ID_chopBefore = "chopBefore";
+ ID_chopAfter = "chopAfter";
+ ID_minimum = "minimum";
+ ID_maximum = "maximum";
+ ID_specificationFilter = "specificationFilter";
+ ID_item = "item";
+ ID_and = "and";
+ ID_or = "or";
+ ID_not = "not";
+}
+
+
+//----------------------------------------------------------------------------
+// lexer initialization
+//----------------------------------------------------------------------------
+
+{
+ private static final Logger log = LoggerFactory.getLogger( AntlrSubtreeSpecificationLexer.class );
+}
+
+
+// ----------------------------------------------------------------------------
+// attribute description lexer rules from models
+// ----------------------------------------------------------------------------
+
+SP : ' ';
+
+COLON : ':' { log.debug( "matched COLON(':')" ); } ;
+
+OPEN_CURLY : '{' { log.debug( "matched LBRACKET('{')" ); } ;
+
+CLOSE_CURLY : '}' { log.debug( "matched RBRACKET('}')" ); } ;
+
+SEP : ',' { log.debug( "matched SEP(',')" ); } ;
+
+SAFEUTF8STRING : '"'! ( SAFEUTF8CHAR )* '"'! { log.debug( "matched SAFEUTF8CHAR: \"" + getText() + "\"" ); } ;
+
+DESCR : ALPHA ( ALPHA | DIGIT | '-' )* { log.debug( "matched DESCR" ); } ;
+
+INTEGER_OR_NUMERICOID
+ :
+ ( INTEGER DOT ) => NUMERICOID
+ {
+ $setType( NUMERICOID );
+ }
+ |
+ INTEGER
+ {
+ $setType( INTEGER );
+ }
+ ;
+
+protected INTEGER: DIGIT | ( LDIGIT ( DIGIT )+ ) { log.debug( "matched INTEGER: " + getText() ); } ;
+
+protected NUMERICOID: INTEGER ( DOT INTEGER )+ { log.debug( "matched NUMERICOID: " + getText() ); } ;
+
+protected DOT: '.' ;
+
+protected DIGIT: '0' | LDIGIT ;
+
+protected LDIGIT: '1'..'9' ;
+
+protected ALPHA: 'A'..'Z' | 'a'..'z' ;
+
+// This is all messed up - could not figure out how to get antlr to represent
+// the safe UTF-8 character set from RFC 3642 for production SafeUTF8Character
+
+protected SAFEUTF8CHAR:
+ '\u0001'..'\u0021' |
+ '\u0023'..'\u007F' |
+ '\u00c0'..'\u00d6' |
+ '\u00d8'..'\u00f6' |
+ '\u00f8'..'\u00ff' |
+ '\u0100'..'\u1fff' |
+ '\u3040'..'\u318f' |
+ '\u3300'..'\u337f' |
+ '\u3400'..'\u3d2d' |
+ '\u4e00'..'\u9fff' |
+ '\uf900'..'\ufaff' ;
+
+FILTER : '(' ( ( '&' (SP)* (FILTER)+ ) | ( '|' (SP)* (FILTER)+ ) | ( '!' (SP)* FILTER ) | FILTER_VALUE ) ')' (SP)* ;
+
+protected FILTER_VALUE : (options{greedy=true;}: ~( ')' | '(' | '&' | '|' | '!' ) ( ~(')') )* ) ;
Modified: directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java?rev=961400&r1=961399&r2=961400&view=diff
==============================================================================
--- directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java (original)
+++ directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java Wed Jul 7 15:06:33 2010
@@ -372,7 +372,7 @@ public abstract class UserClass implemen
buffer.append( ", " );
}
- ss.printToBuffer( buffer );
+ ss.toString( buffer );
}
buffer.append( " }" );
Modified: directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RangeOfValuesItem.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RangeOfValuesItem.java?rev=961400&r1=961399&r2=961400&view=diff
==============================================================================
--- directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RangeOfValuesItem.java (original)
+++ directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RangeOfValuesItem.java Wed Jul 7 15:06:33 2010
@@ -28,7 +28,7 @@ import org.apache.directory.shared.ldap.
*/
public class RangeOfValuesItem extends ProtectedItem
{
- private final ExprNode filter;
+ private final ExprNode refinement;
/**
@@ -36,23 +36,23 @@ public class RangeOfValuesItem extends P
*
* @param filter the expression
*/
- public RangeOfValuesItem( ExprNode filter )
+ public RangeOfValuesItem( ExprNode refinement )
{
- if ( filter == null )
+ if ( refinement == null )
{
- throw new IllegalArgumentException( "filter" );
+ throw new IllegalArgumentException( "refinement" );
}
- this.filter = filter;
+ this.refinement = refinement;
}
/**
* Returns the expression.
*/
- public ExprNode getFilter()
+ public ExprNode getRefinement()
{
- return filter;
+ return refinement;
}
@@ -63,7 +63,7 @@ public class RangeOfValuesItem extends P
public int hashCode()
{
int hash = 37;
- hash = hash * 17 + filter.hashCode();
+ hash = hash * 17 + refinement.hashCode();
return hash;
}
@@ -82,7 +82,7 @@ public class RangeOfValuesItem extends P
if ( o instanceof RangeOfValuesItem )
{
RangeOfValuesItem that = ( RangeOfValuesItem ) o;
- return this.filter.equals( that.filter );
+ return this.refinement.equals( that.refinement );
}
return false;
@@ -97,7 +97,7 @@ public class RangeOfValuesItem extends P
StringBuilder buf = new StringBuilder();
buf.append( "rangeOfValues " );
- buf.append( filter.toString() );
+ buf.append( refinement.toString() );
return buf.toString();
}
Added: directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java?rev=961400&view=auto
==============================================================================
--- directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java (added)
+++ directory/shared/trunk/ldap-aci/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java Wed Jul 7 15:06:33 2010
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.schema.syntaxCheckers;
+
+import java.text.ParseException;
+
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.SyntaxChecker;
+import org.apache.directory.shared.ldap.subtree.SubtreeSpecificationChecker;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A SyntaxChecker which verifies that a value is a subtree specification.
+ *
+ * It has been removed in RFC 4517
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SubtreeSpecificationSyntaxChecker extends SyntaxChecker
+{
+ /** A logger for this class */
+ private static final Logger LOG = LoggerFactory.getLogger( SubtreeSpecificationSyntaxChecker.class );
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ /** The associated checker */
+ private static SubtreeSpecificationChecker SUBTREE_SPECIFICATION_CHECKER;
+
+ /**
+ * Creates an instance of SubtreeSpecificationSyntaxChecker
+ */
+ public SubtreeSpecificationSyntaxChecker()
+ {
+ super( SchemaConstants.SUBTREE_SPECIFICATION_SYNTAX );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isValidSyntax( Object value )
+ {
+ String strValue = null;
+
+ if ( value == null )
+ {
+ LOG.debug( "Syntax invalid for 'null'" );
+ return false;
+ }
+
+ if ( value instanceof String )
+ {
+ strValue = ( String ) value;
+ }
+ else if ( value instanceof byte[] )
+ {
+ strValue = StringTools.utf8ToString( ( byte[] ) value );
+ }
+ else
+ {
+ strValue = value.toString();
+ }
+
+ if ( strValue.length() == 0 )
+ {
+ LOG.debug( "Syntax invalid for '{}'", value );
+ return false;
+ }
+
+ try
+ {
+ synchronized( SUBTREE_SPECIFICATION_CHECKER )
+ {
+ SUBTREE_SPECIFICATION_CHECKER.parse( strValue );
+ }
+
+ LOG.debug( "Syntax valid for '{}'", value );
+ return true;
+ }
+ catch ( ParseException pe )
+ {
+ LOG.debug( "Syntax invalid for '{}'", value );
+ return false;
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setSchemaManager( SchemaManager schemaManager )
+ {
+ SUBTREE_SPECIFICATION_CHECKER = new SubtreeSpecificationChecker( schemaManager );
+ }
+}
Added: directory/shared/trunk/ldap-aci/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-aci/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java?rev=961400&view=auto
==============================================================================
--- directory/shared/trunk/ldap-aci/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java (added)
+++ directory/shared/trunk/ldap-aci/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java Wed Jul 7 15:06:33 2010
@@ -0,0 +1,288 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.schema.syntaxCheckers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test cases for SubtreeSpecificationSyntaxChecker.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class SubtreeSpecificationSyntaxCheckerTest
+{
+ private static SubtreeSpecificationSyntaxChecker checker ;
+
+
+ /**
+ * Initialization
+ */
+ @BeforeClass
+ public static void init() throws Exception
+ {
+ JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+ SchemaManager schemaManager = new DefaultSchemaManager( loader );
+
+ schemaManager.loadAllEnabled();
+
+ checker = new SubtreeSpecificationSyntaxChecker();
+ checker.setSchemaManager( schemaManager );
+ }
+
+ @Test
+ public void testNullString()
+ {
+ assertFalse( checker.isValidSyntax( null ) );
+ }
+
+
+ @Test
+ public void testEmptyString()
+ {
+ assertFalse( checker.isValidSyntax( "" ) );
+ }
+
+ @Test
+ public void testOid()
+ {
+ assertEquals( "1.3.6.1.4.1.1466.115.121.1.45", checker.getOid() );
+ }
+
+ @Test
+ public void testCorrectCase()
+ {
+ }
+
+ /** A valid empty specification with single white space between brackets */
+ private static final String EMPTY_SPEC = "{ }";
+
+ /** A valid specification only with base set */
+ private static final String SPEC_WITH_BASE = "{ base \"ou=system\" }";
+
+ /** An invalid specification with missing white space and base set */
+ private static final String INVALID_SPEC_WITH_BASE_AND_MISSING_WS = "{ base\"ou=system\"}";
+
+ /** A valid specification with some specific exclusions set */
+ private static final String SPEC_WITH_SPECIFICEXCLUSIONS = "{ specificExclusions { chopAfter:\"ef=gh\", chopBefore:\"ab=cd\" } }";
+
+ /** A valid specification with empty specific exclusions set */
+ private static final String SPEC_WITH_EMPTY_SPECIFICEXCLUSIONS = "{ specificExclusions { } }";
+
+ /** A valid specification with minimum and maximum set */
+ private static final String SPEC_WITH_MINIMUM_AND_MAXIMUM = "{ minimum 1, maximum 2 }";
+
+ /** A valid specification with base and minimum and maximum set */
+ private static final String SPEC_WITH_BASE_AND_MINIMUM_AND_MAXIMUM = "{ base \"ou=ORGANIZATION UNIT\", minimum 1, maximum 2 }";
+
+ /**
+ * A valid specification with base and specific exclusions and minimum and
+ * maximum set
+ */
+ private static final String SPEC_WITH_BASE_AND_SPECIFICEXCLUSIONS_AND_MINIMUM_AND_MAXIMUM = "{ base \"ou=people\", specificExclusions { chopBefore:\"x=y\""
+ + ", chopAfter:\"k=l\", chopBefore:\"y=z\", chopAfter:\"l=m\" }, minimum 7, maximum 77 }";
+
+ /** A valid specification with refinement set */
+ private static final String SPEC_WITH_REFINEMENT = "{ base \"ou=system\", specificationFilter and:{ and:{ item:1.2.3"
+ + ", or:{ item:4.5.6, item:person-7 } }, not: item:10.11.12 } }";
+
+ /** A valid specification with base and an empty refinement set */
+ private static final String SPEC_WITH_BASE_AND_EMPTY_REFINEMENT = "{ base \"ou=system\", specificationFilter and:{ } }";
+
+ /** A valid specification with ALL IN ONE */
+ private static final String SPEC_WITH_ALL_IN_ONE = "{ base \"ou=departments\""
+ + ", specificExclusions { chopBefore:\"x=y\", chopAfter:\"k=l\", chopBefore:\"y=z\", chopAfter:\"l=m\" }"
+ + ", minimum 7, maximum 77"
+ + ", specificationFilter and:{ and:{ item:1.2.3, or:{ item:4.5.6, item:7.8.9 } }, not: item:10.11.12 } }";
+
+ /** An valid specification with unordinary component order */
+ private static final String SPEC_ORDER_OF_COMPONENTS_DOES_NOT_MATTER = "{ base \"ou=system\", minimum 3, specificExclusions { chopBefore:\"x=y\" } }";
+
+ /** An invalid specification with completely unrelated content */
+ private static final String INVALID_SILLY_THING = "How much wood would a wood chuck chuck if a wood chuck would chuck wood?";
+
+ /** A valid specification with filter expression */
+ private static final String SPEC_WITH_FILTER = "{ base \"ou=system\", specificationFilter (&(cn=test)(sn=test)) }";
+
+ /**
+ * Tests the parser with a valid empty specification.
+ */
+ @Test
+ public void testEmptySpec() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( EMPTY_SPEC ) );
+
+ // try a second time
+ assertTrue( checker.isValidSyntax( EMPTY_SPEC ) );
+
+ // try a third time
+ assertTrue( checker.isValidSyntax( EMPTY_SPEC ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with base set.
+ */
+ @Test
+ public void testSpecWithBase() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_BASE ) );
+ }
+
+
+ /**
+ * Tests the parser with an invalid specification with missing white spaces
+ * and base set.
+ */
+ @Test
+ public void testInvalidSpecWithBaseAndMissingWS() throws Exception
+ {
+ assertFalse( checker.isValidSyntax( INVALID_SPEC_WITH_BASE_AND_MISSING_WS ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with some specific exclusions
+ * set.
+ */
+ @Test
+ public void testSpecWithSpecificExclusions() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_SPECIFICEXCLUSIONS ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with an empty specific
+ * exclusions set.
+ */
+ @Test
+ public void testSpecWithEmptySpecificExclusions() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_EMPTY_SPECIFICEXCLUSIONS ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with minimum and maximum set.
+ */
+ @Test
+ public void testSpecWithMinimumAndMaximum() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_MINIMUM_AND_MAXIMUM ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with base and minimum and
+ * maximum set.
+ */
+ @Test
+ public void testWithBaseAndMinimumAndMaximum() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_BASE_AND_MINIMUM_AND_MAXIMUM ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with base and specific
+ * exclusions and minimum and maximum set.
+ */
+ @Test
+ public void testSpecWithBaseAndSpecificExclusionsAndMinimumAndMaximum() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_BASE_AND_SPECIFICEXCLUSIONS_AND_MINIMUM_AND_MAXIMUM ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with refinement set.
+ */
+ @Test
+ public void testSpecWithRefinement() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_REFINEMENT ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with base and empty
+ * refinement set.
+ */
+ @Test
+ public void testSpecWithBaseAndEmptyRefinement() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_BASE_AND_EMPTY_REFINEMENT ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with all components set.
+ */
+ @Test
+ public void testSpecWithAllInOne() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_ALL_IN_ONE ) );
+
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with unordinary component
+ * order.
+ */
+ @Test
+ public void testSpecOrderOfComponentsDoesNotMatter() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_ORDER_OF_COMPONENTS_DOES_NOT_MATTER ) );
+ }
+
+ /**
+ * Tests the parser with a valid specification with unordinary component
+ * order.
+ */
+ @Test
+ public void testBadAssertion() throws Exception
+ {
+ assertFalse( checker.isValidSyntax( INVALID_SILLY_THING ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with refinement set.
+ */
+ @Test
+ public void testSpecWithFilter() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_FILTER ) );
+ }
+}