directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 56802 - incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/filter
Date Sun, 07 Nov 2004 02:35:15 GMT
Author: akarasulu
Date: Sat Nov  6 18:35:15 2004
New Revision: 56802

Modified:
   incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/filter/FilterParserImplTest.java
Log:
more tests

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 18:35:15 2004
@@ -128,37 +128,71 @@
 
     public void testNumericoidPresentFilter() throws IOException, ParseException
     {
-        parser.parse( "( 1.2.3.4 = * )" );
+        PresenceNode node = ( PresenceNode ) parser.parse( "( 1.2.3.4 = * )" );
+        assertEquals( "1.2.3.4", node.getAttribute() );
+
+        node = ( PresenceNode ) parser.parse( "( 1.2.3.4 =  * )" );
+        assertEquals( "1.2.3.4", node.getAttribute() );
+
+        node = ( PresenceNode ) parser.parse( "(  1.2.3.4 = *)" );
+        assertEquals( "1.2.3.4", node.getAttribute() );
+
+        node = ( PresenceNode ) parser.parse( "( 1.2.3.4 =* ) " );
+        assertEquals( "1.2.3.4", node.getAttribute() );
+
+        node = ( PresenceNode ) parser.parse( "( 1.2.3.4 =*)" );
+        assertEquals( "1.2.3.4", node.getAttribute() );
     }
 
 
     public void testEqualsFilter() throws IOException, ParseException
     {
-        parser.parse( "( ou = people )" );
+        SimpleNode node = ( SimpleNode ) parser.parse( "( ou = people )" );
+        assertEquals( "ou", node.getAttribute() );
+        assertEquals( "people", node.getValue() );
+        assertEquals( AbstractExprNode.EQUALITY, node.getAssertionType() );
     }
 
 
     public void testEqualsWithForwardSlashFilter() throws IOException, ParseException
     {
-        parser.parse( "( ou = people/in/my/company )" );
+        SimpleNode node = ( SimpleNode ) parser.parse( "( ou = people/in/my/company )" );
+        assertEquals( "ou", node.getAttribute() );
+        assertEquals( "people/in/my/company", node.getValue() );
+        assertEquals( AbstractExprNode.EQUALITY, node.getAssertionType() );
     }
 
 
     public void testExtensibleFilterForm1() throws IOException, ParseException
     {
-        parser.parse( "( ou :dn :stupidMatch := dummyAssertion\\23\\ac )" );
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( ou :dn :stupidMatch :=
dummyAssertion\\23\\ac )" );
+        assertEquals( "ou", node.getAttribute() );
+        assertEquals( "dummyAssertion\\23\\ac", node.getValue() );
+        assertEquals( "stupidMatch", node.getMatchingRuleId() );
+        assertTrue( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
     }
 
 
     public void testExtensibleFilterForm1WithNumericOid() throws IOException, ParseException
     {
-        parser.parse( "( 1.2.3.4 :dn :1.3434.23.2 := dummyAssertion\\23\\ac )" );
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( 1.2.3.4 :dn :1.3434.23.2
:= dummyAssertion\\23\\ac )" );
+        assertEquals( "1.2.3.4", node.getAttribute() );
+        assertEquals( "dummyAssertion\\23\\ac", node.getValue() );
+        assertEquals( "1.3434.23.2", node.getMatchingRuleId() );
+        assertTrue( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
     }
 
 
     public void testExtensibleFilterForm1NoDnAttr() throws IOException, ParseException
     {
-        parser.parse( "( ou :stupidMatch := dummyAssertion\\23\\ac )" );
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( ou :stupidMatch := dummyAssertion\\23\\ac
)" );
+        assertEquals( "ou", node.getAttribute() );
+        assertEquals( "dummyAssertion\\23\\ac", node.getValue() );
+        assertEquals( "stupidMatch", node.getMatchingRuleId() );
+        assertFalse( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
     }
 
 
@@ -180,19 +214,34 @@
 
     public void testExtensibleFilterForm1NoAttrNoMatchingRule() throws IOException, ParseException
     {
-        parser.parse( "( ou := dummyAssertion\\23\\ac )" );
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( ou := dummyAssertion\\23\\ac
)" );
+        assertEquals( "ou", node.getAttribute() );
+        assertEquals( "dummyAssertion\\23\\ac", node.getValue() );
+        assertEquals( null, node.getMatchingRuleId() );
+        assertFalse( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
     }
 
 
     public void testExtensibleFilterForm1NoDnAttrWithNumericOidNoAttr() throws IOException,
ParseException
     {
-        parser.parse( "( 1.2.3.4 :1.3434.23.2 := dummyAssertion\\23\\ac )" );
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( 1.2.3.4 :1.3434.23.2 :=
dummyAssertion\\23\\ac )" );
+        assertEquals( "1.2.3.4", node.getAttribute() );
+        assertEquals( "dummyAssertion\\23\\ac", node.getValue() );
+        assertEquals( "1.3434.23.2", node.getMatchingRuleId() );
+        assertFalse( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
     }
 
 
     public void testExtensibleFilterForm2() throws IOException, ParseException
     {
-        parser.parse( "( :dn :stupidMatch := dummyAssertion\\23\\ac )" );
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( :dn :stupidMatch := dummyAssertion\\23\\ac
)" );
+        assertEquals( null, node.getAttribute() );
+        assertEquals( "dummyAssertion\\23\\ac", node.getValue() );
+        assertEquals( "stupidMatch", node.getMatchingRuleId() );
+        assertTrue( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
     }
 
 
@@ -214,25 +263,56 @@
 
     public void testExtensibleFilterForm2WithNumericOid() throws IOException, ParseException
     {
-        parser.parse( "( :dn :1.3434.23.2 := dummyAssertion\\23\\ac )" );
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( :dn :1.3434.23.2 := dummyAssertion\\23\\ac
)" );
+        assertEquals( null, node.getAttribute() );
+        assertEquals( "dummyAssertion\\23\\ac", node.getValue() );
+        assertEquals( "1.3434.23.2", node.getMatchingRuleId() );
+        assertTrue( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
     }
 
 
     public void testExtensibleFilterForm2NoDnAttr() throws IOException, ParseException
     {
-        parser.parse( "( :stupidMatch := dummyAssertion\\23\\ac )" );
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( :stupidMatch := dummyAssertion\\23\\ac
)" );
+        assertEquals( null, node.getAttribute() );
+        assertEquals( "dummyAssertion\\23\\ac", node.getValue() );
+        assertEquals( "stupidMatch", node.getMatchingRuleId() );
+        assertFalse( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
     }
 
 
     public void testExtensibleFilterForm2NoDnAttrWithNumericOidNoAttr() throws IOException,
ParseException
     {
-        parser.parse( "( :1.3434.23.2 := dummyAssertion\\23\\ac )" );
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( :1.3434.23.2 := dummyAssertion\\23\\ac
)" );
+        assertEquals( null, node.getAttribute() );
+        assertEquals( "dummyAssertion\\23\\ac", node.getValue() );
+        assertEquals( "1.3434.23.2", node.getMatchingRuleId() );
+        assertFalse( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
     }
 
 
     public void testExtensibleFilterForm3() throws IOException, ParseException
     {
-        parser.parse( "( := dummyAssertion\\23\\ac )" );
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( := dummyAssertion )" );
+        assertEquals( null, node.getAttribute() );
+        assertEquals( "dummyAssertion", node.getValue() );
+        assertEquals( null, node.getMatchingRuleId() );
+        assertFalse( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
+    }
+
+
+    public void testExtensibleFilterForm3WithEscapes() throws IOException, ParseException
+    {
+        ExtensibleNode node = ( ExtensibleNode ) parser.parse( "( := dummyAssertion\\23\\ac
)" );
+        assertEquals( null, node.getAttribute() );
+        assertEquals( "dummyAssertion\\23\\ac", node.getValue() );
+        assertEquals( null, node.getMatchingRuleId() );
+        assertFalse( node.dnAttributes() );
+        assertEquals( AbstractExprNode.EXTENSIBLE, node.getAssertionType() );
     }
 
 

Mime
View raw message