directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r721190 - /directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java
Date Thu, 27 Nov 2008 14:37:01 GMT
Author: elecharny
Date: Thu Nov 27 06:37:01 2008
New Revision: 721190

URL: http://svn.apache.org/viewvc?rev=721190&view=rev
Log:
Added a test to chekc that the filter "(&(objectClass=nisNetgroup)(|(nisNetGroupTriple=a*a)(nisNetGroupTriple=\28*,acc1,*\29)))"
is correctly handled.

Modified:
    directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java

Modified: directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java?rev=721190&r1=721189&r2=721190&view=diff
==============================================================================
--- directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java
(original)
+++ directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java
Thu Nov 27 06:37:01 2008
@@ -684,6 +684,55 @@
     }
 
 
+    /**
+     * Test that filters like (&(a=b)(|(c=d)(e=f))) are correctly parsed
+     */
+    @Test
+    public void testAndEqOr_EqEq()
+    {
+        try
+        {
+            BranchNode node = ( BranchNode ) FilterParser.parse("(&(objectClass=nisNetgroup)(|(nisNetGroupTriple=a*a)(nisNetGroupTriple=\\28*,acc1,*\\29)))");
+            assertEquals( 2, node.getChildren().size() );
+            
+            assertTrue( node instanceof AndNode );
+            
+            // Check the (a=b) part
+            ExprNode aEqb = node.getFirstChild();
+            assertTrue( aEqb instanceof EqualityNode );
+            assertEquals( "objectClass", ((EqualityNode<?>)aEqb).getAttribute() );
+            assertEquals( "nisNetgroup", ((EqualityNode<?>)aEqb).getValue().get() );
+            
+            // Check the or node
+            ExprNode orNode = node.getChildren().get( 1 );
+            assertTrue( orNode instanceof OrNode );
+            
+            assertEquals( 2, ((OrNode)orNode).getChildren().size() );
+            
+            ExprNode leftNode = ((OrNode)orNode).getChildren().get( 0 );
+            
+            assertTrue( leftNode instanceof SubstringNode );
+            assertEquals( "nisNetGroupTriple", ((SubstringNode)leftNode).getAttribute() );
+            assertEquals( "a", ((SubstringNode)leftNode).getInitial() );
+            assertEquals( 0, ((SubstringNode)leftNode).getAny().size() );
+            assertEquals( "a", ((SubstringNode)leftNode).getFinal() );
+            
+            ExprNode rightNode = ((OrNode)orNode).getChildren().get( 1 );
+            
+            assertTrue( rightNode instanceof SubstringNode );
+            assertEquals( "nisNetGroupTriple", ((SubstringNode)rightNode).getAttribute()
);
+            assertEquals( "\\28", ((SubstringNode)rightNode).getInitial() );
+            assertEquals( 1, ((SubstringNode)rightNode).getAny().size() );
+            assertEquals( ",acc1,", ((SubstringNode)rightNode).getAny().get( 0 ) );
+            assertEquals( "\\29", ((SubstringNode)rightNode).getFinal() );
+        }
+        catch ( ParseException pe )
+        {
+            assertTrue( true );
+        }
+    }
+    
+    
     /*
     @Test
     public void testPerf() throws ParseException



Mime
View raw message