directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r503334 - /directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Date Sat, 03 Feb 2007 23:15:12 GMT
Author: elecharny
Date: Sat Feb  3 15:15:12 2007
New Revision: 503334

URL: http://svn.apache.org/viewvc?view=rev&rev=503334
Log:
Added the tests given in DIRSERVER-823 (at least, similar ones) to be sure that the fix is
correct.

Modified:
    directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java

Modified: directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java?view=diff&rev=503334&r1=503333&r2=503334
==============================================================================
--- directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
(original)
+++ directory/apacheds/branches/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Sat Feb  3 15:15:12 2007
@@ -199,6 +199,46 @@
         return results;
     }
 
+    protected void checkWhetherFilterFindsEntry( String filter, String sn1, String sn2 )
throws NamingException
+    {
+
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        // Check entry
+        NamingEnumeration enm = ctx.search( "", filter, sctls );
+        assertTrue( "check whether " + filter + " matches an entry", enm.hasMore() );
+        
+        HashSet set = new HashSet();
+        
+        set.add( sn1 );
+        
+        if ( sn2 != null )
+        {
+            set.add( sn2 );
+        }
+        
+        while ( enm.hasMore() )
+        {
+            SearchResult sr = ( SearchResult ) enm.next();
+            Attributes attrs = sr.getAttributes();
+            Attribute sn = attrs.get( "sn" );
+            assertNotNull( sn );
+            
+            String value = (String)sn.get();
+            
+            assertTrue( set.size() > 0 );
+            assertTrue( set.contains( value ) );
+            
+            set.remove( value );
+        }
+        
+        enm.close();
+    }
+
+
+    
+    
     protected void checkForAttributes( Attributes attrs, String[] attrNames )
     {
         for ( int i = 0; i < attrNames.length; i++ )
@@ -995,5 +1035,55 @@
         }
 
         result.close();
+    }
+    
+    // In the following tests, the sn=Minogue does not exist
+    // but as the search is a |, we should find at least the
+    // cn=Tori Amos entry.
+    public void testWithOriginalIssueFilter() throws NamingException
+    {
+        String filter = "(&(objectClass=person)(cn=Tori*))";
+        checkWhetherFilterFindsEntry( filter, "Amos", null );
+
+        filter = "(&(objectClass=person)(|(cn=Tori*)(sn=Jagger)))";
+        checkWhetherFilterFindsEntry( filter, "Amos", "Jagger" );
+
+        filter = "(&(objectClass=person)(|(cn=Tori*)(sn=Jagger)))";
+        checkWhetherFilterFindsEntry( filter, "Amos", "Jagger" );
+    }
+
+
+    public void testWithOriginalIssueFilterWithoutAsterisk() throws NamingException
+    {
+        String filter = "(&(objectClass=person)(|(cn=Tori Amos)(sn=Jagger)))";
+        checkWhetherFilterFindsEntry( filter , "Amos", "Jagger");
+    }
+
+
+    public void testWithFilterWithAsteriskNotNecessary() throws NamingException
+    {
+        String filter = "(&(objectClass=person)(|(cn=Tori*)(sn=Amos)))";
+        checkWhetherFilterFindsEntry( filter, "Amos", null );
+    }
+
+
+    public void testWithReducedOriginalFilter() throws NamingException
+    {
+        String filter = "(|(cn=Tori*)(sn=Jagger))";
+        checkWhetherFilterFindsEntry( filter, "Amos", "Jagger" );
+    }
+
+
+    public void testWithOriginalFilterPermutation1() throws NamingException
+    {
+        String filter = "(&(objectClass=person)(|(sn=Jagger)(cn=Tori*)))";
+        checkWhetherFilterFindsEntry( filter, "Amos", "Jagger" );
+    }
+
+
+    public void testWithOriginalFilterPermutation2() throws NamingException
+    {
+        String filter = "(&(|(cn=Tori*)(sn=Jagger))(objectClass=person))";
+        checkWhetherFilterFindsEntry( filter, "Amos", "Jagger" );
     }
 }



Mime
View raw message