You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/11/07 01:31:53 UTC
svn commit: rev 56795 - in incubator/directory/ldap/trunk/common/src: antlr test/org/apache/ldap/common/filter
Author: akarasulu
Date: Sat Nov 6 16:31:53 2004
New Revision: 56795
Modified:
incubator/directory/ldap/trunk/common/src/antlr/filter-parser.g
incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/filter/FilterParserImplTest.java
Log:
Caught bug where we are not trimming values extracted.
Modified: incubator/directory/ldap/trunk/common/src/antlr/filter-parser.g
==============================================================================
--- incubator/directory/ldap/trunk/common/src/antlr/filter-parser.g (original)
+++ incubator/directory/ldap/trunk/common/src/antlr/filter-parser.g Sat Nov 6 16:31:53 2004
@@ -283,12 +283,12 @@
case( AbstractExprNode.APPROXIMATE ):
case( AbstractExprNode.GREATEREQ ):
case( AbstractExprNode.LESSEQ ):
- node = new SimpleNode( attribute, ( String ) value, type );
+ node = new SimpleNode( attribute, ( ( String ) value).trim(), type );
break;
case( AbstractExprNode.EQUALITY ):
if ( value instanceof String )
{
- node = new SimpleNode( attribute, ( String ) value, type );
+ node = new SimpleNode( attribute, ( ( String ) value ).trim(), type );
}
else
{
@@ -318,12 +318,12 @@
// A L T E R N A T I V E 1 :
attributeAlt1:ATTRIBUTEDESCRIPTION
{
- attribute = attributeAlt1.getText();
+ attribute = attributeAlt1.getText().trim();
}
( DN { dnAttrs = true; } )?
( COLON matchingRuleAlt1:ATTRIBUTEDESCRIPTION
{
- matchingRule = matchingRuleAlt1.getText();
+ matchingRule = matchingRuleAlt1.getText().trim();
int idx = matchingRule.indexOf( ';' );
if ( idx != -1 )
{
@@ -335,14 +335,14 @@
)? COLONEQUALS
{
selector.select( valueLexer );
- value = ( String ) valueParser.value( attribute );
+ value = ( ( String ) valueParser.value( attribute ) ).trim();
}
|
// A L T E R N A T I V E 2 :
( DN { dnAttrs = true; })? COLON matchingRuleAlt2:ATTRIBUTEDESCRIPTION
{
- matchingRule = matchingRuleAlt2.getText();
+ matchingRule = matchingRuleAlt2.getText().trim();
int idx = matchingRule.indexOf( ';' );
if ( idx != -1 )
{
@@ -354,14 +354,14 @@
COLONEQUALS
{
selector.select( valueLexer );
- value = ( String ) valueParser.value( attribute );
+ value = ( ( String ) valueParser.value( attribute ) ).trim();
}
|
// A L T E R N A T I V E 3 :
COLONEQUALS
{
selector.select( valueLexer );
- value = ( String ) valueParser.value( attribute );
+ value = ( ( String ) valueParser.value( attribute ) ).trim();
}
)
{
Modified: incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/filter/FilterParserImplTest.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/filter/FilterParserImplTest.java (original)
+++ incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/filter/FilterParserImplTest.java Sat Nov 6 16:31:53 2004
@@ -26,6 +26,7 @@
/**
* Tests the FilterParserImpl class.
*
+ * @todo add some substring expressions there are none here
* @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
@@ -48,7 +49,10 @@
public void testItemFilter() throws IOException, ParseException
{
- parser.parse( "( ou ~= people )" );
+ SimpleNode node = ( SimpleNode ) parser.parse( "( ou ~= people )" );
+ assertEquals( "ou", node.getAttribute() );
+ assertEquals( "people", node.getValue() );
+ assertEquals( AbstractExprNode.APPROXIMATE, node.getAssertionType() );
}