directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r428463 - in /directory/branches/apacheds/1.0: core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Date Thu, 03 Aug 2006 18:04:07 GMT
Author: akarasulu
Date: Thu Aug  3 11:04:06 2006
New Revision: 428463

URL: http://svn.apache.org/viewvc?rev=428463&view=rev
Log:
some test cases showing serious issues with search

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

Modified: directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java?rev=428463&r1=428462&r2=428463&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java
(original)
+++ directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java
Thu Aug  3 11:04:06 2006
@@ -171,6 +171,70 @@
     }
 
 
+    public void testSearchOneLevelSubstring() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setDerefLinkFlag( false );
+        sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName()
);
+        HashMap map = new HashMap();
+
+        NamingEnumeration list = sysRoot.search( "", "(ou=testing*)", controls );
+        while ( list.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) list.next();
+            map.put( result.getName(), result.getAttributes() );
+        }
+
+        assertEquals( "Expected number of results returned was incorrect!", 3, map.size()
);
+        assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
+        assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
+        assertTrue( map.containsKey( "ou=testing02,ou=system" ) );
+    }
+
+
+    public void testSearchOneLevelOr() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setDerefLinkFlag( false );
+        sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName()
);
+        HashMap map = new HashMap();
+
+        NamingEnumeration list = sysRoot.search( "", "(| (ou=testing00) (ou=testing01) )",
controls );
+        while ( list.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) list.next();
+            map.put( result.getName(), result.getAttributes() );
+        }
+
+        assertEquals( "Expected number of results returned was incorrect!", 2, map.size()
);
+        assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
+        assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
+    }
+
+
+    public void testSearchOneLevelOrSubstring() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        controls.setDerefLinkFlag( false );
+        sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName()
);
+        HashMap map = new HashMap();
+
+        NamingEnumeration list = sysRoot.search( "", "(| (ou=testing*0) (ou=*01) )", controls
);
+        while ( list.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) list.next();
+            map.put( result.getName(), result.getAttributes() );
+        }
+
+        assertEquals( "Expected number of results returned was incorrect!", 2, map.size()
);
+        assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
+        assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
+    }
+
+
     public void testSearchSubTreeLevel() throws NamingException
     {
         SearchControls controls = new SearchControls();

Modified: directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java?rev=428463&r1=428462&r2=428463&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
(original)
+++ directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Thu Aug  3 11:04:06 2006
@@ -17,6 +17,7 @@
 package org.apache.directory.server;
 
 
+import java.util.HashSet;
 import java.util.Hashtable;
 
 import javax.naming.NamingEnumeration;
@@ -105,6 +106,32 @@
         ctx.close();
         ctx = null;
         super.tearDown();
+    }
+    
+    
+    public void testDirserver635() throws NamingException
+    {
+        // create additional entry
+        Attributes attributes = this.getPersonAttributes( "Bush", "Kate Bush" );
+        ctx.createSubcontext( "cn=Kate Bush", attributes );
+        
+        // setup and search
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        NamingEnumeration ii = ctx.search( "", "( | ( cn=Kate Bush ) ( cn=Tori Amos) )",
controls );
+        
+        // collect all results 
+        HashSet results = new HashSet();
+        while ( ii.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) ii.next();
+            results.add( result.getName() );
+        }
+        
+        // make sure we get the results we need
+        assertEquals( "returned size of results", 2, results.size() );
+        assertTrue( "contains cn=Tori Amos,ou=system", results.contains( "cn=Tori Amos,ou=system"
) );
+        assertTrue( "contains cn=Kate Bush,ou=system", results.contains( "cn=Kate Bush,ou=system"
) );
     }
 
 



Mime
View raw message