directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 21188 - incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/search
Date Mon, 14 Jun 2004 04:44:15 GMT
Author: akarasulu
Date: Sun Jun 13 21:44:15 2004
New Revision: 21188

Modified:
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/search/SearchRequestTest.java
Log:
add extra test for nested negated expressions

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/search/SearchRequestTest.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/search/SearchRequestTest.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/search/SearchRequestTest.java
Sun Jun 13 21:44:15 2004
@@ -460,7 +460,7 @@
     /**
      * Tests an search request decode with a simple equality match filter.
      */
-    public void testNotFilter() throws Exception
+    public void testNotFilter0() throws Exception
     {
         SearchRequestImpl req = new SearchRequestImpl( 33 );
         req.setBase( "dc=example,dc=com" );
@@ -511,9 +511,74 @@
         node = req.getFilter();
         StringBuffer buf0 = new StringBuffer();
         node.printToBuffer( buf0 );
+        System.out.println( buf0.toString() );
         node = decoded.getFilter();
         StringBuffer buf1 = new StringBuffer();
         node.printToBuffer( buf1 );
+        System.out.println( buf1.toString() );
+        assertEquals(buf0.toString(), buf1.toString()) ;
+    }
+
+
+    /**
+     * Tests an search request decode with a simple equality match filter.
+     */
+    public void testNotFilter1() throws Exception
+    {
+        SearchRequestImpl req = new SearchRequestImpl( 33 );
+        req.setBase( "dc=example,dc=com" );
+        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        req.setScope( ScopeEnum.BASEOBJECT );
+        req.setSizeLimit( 2 );
+        req.setTimeLimit( 3 );
+        req.setTypesOnly( true );
+
+        req.addAttribute( "attr0" );
+        req.addAttribute( "attr1" );
+        req.addAttribute( "attr2" );
+
+
+        FilterParserImpl parser = new FilterParserImpl();
+        ExprNode node = null ;
+        node = parser.parse(
+                "( !( ! ( ou = Human Resources ) ) )" ) ;
+        req.setFilter( node );
+
+        System.out.println( "Generated SearchRequest for test:" );
+        System.out.println( TestUtils.printTupleTree( req ) );
+
+        SearchRequest decoded = ( SearchRequest )
+                snickersDecode( snaccEncode( req ) );
+        assertNotNull( decoded );
+
+        // test that we have all the properties set
+        assertEquals( req.getBase(), decoded.getBase() );
+        assertEquals( req.getScope(), decoded.getScope() );
+        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
+        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
+        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
+        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
+
+        // test that we have all the attributes
+        Iterator list = req.getAttributes().iterator();
+        Collection attributes = decoded.getAttributes();
+        while( list.hasNext() )
+        {
+            assertTrue( attributes.contains( list.next() ) );
+        }
+
+        // control test should not exist
+        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
+
+        // filter tests
+        node = req.getFilter();
+        StringBuffer buf0 = new StringBuffer();
+        node.printToBuffer( buf0 );
+        System.out.println( buf0.toString() );
+        node = decoded.getFilter();
+        StringBuffer buf1 = new StringBuffer();
+        node.printToBuffer( buf1 );
+        System.out.println( buf1.toString() );
         assertEquals(buf0.toString(), buf1.toString()) ;
     }
 }

Mime
View raw message