You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2013/08/14 14:47:26 UTC

svn commit: r1513852 - in /directory/apacheds/trunk: core-integ/src/test/java/org/apache/directory/server/core/operations/search/ ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/

Author: elecharny
Date: Wed Aug 14 12:47:26 2013
New Revision: 1513852

URL: http://svn.apache.org/r1513852
Log:
Added tests to check that DIRSERVER-1883 works

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java?rev=1513852&r1=1513851&r2=1513852&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java Wed Aug 14 12:47:26 2013
@@ -187,16 +187,15 @@ import org.junit.runner.RunWith;
         "objectClass: top",
         "objectClass: posixGroup",
         "cn: testGroup5",
-        "gidNumber: 5"
-})
+        "gidNumber: 5" })
 public class SearchIT extends AbstractLdapTestUnit
 {
     private static final String RDN = "cn=Heather Nova";
     private static final String FILTER = "(objectclass=*)";
-    
+
     public static LdapContext sysRoot;
-    
-    
+
+
     /**
      * @param sysRoot the system root to add entries to
      * @throws NamingException on errors
@@ -206,8 +205,8 @@ public class SearchIT extends AbstractLd
     {
         sysRoot = getSystemContext( getService() );
     }
-    
-    
+
+
     @Test
     public void testSearchOneLevel() throws Exception
     {
@@ -217,24 +216,24 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=*)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 9, map.size() );
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
         assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
         assertTrue( map.containsKey( "ou=testing02,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchSubTreeLevel() throws Exception
     {
@@ -243,18 +242,18 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=*)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect", 14, map.size() );
         assertTrue( map.containsKey( "ou=system" ) );
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
@@ -262,8 +261,8 @@ public class SearchIT extends AbstractLd
         assertTrue( map.containsKey( "ou=testing02,ou=system" ) );
         assertTrue( map.containsKey( "ou=subtest,ou=testing01,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchSubTreeLevelNoAttributes() throws Exception
     {
@@ -272,28 +271,28 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         controls.setReturningAttributes( new String[]
             { "1.1" } );
-    
+
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing02)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect", 1, map.size() );
         assertTrue( map.containsKey( "ou=testing02,ou=system" ) );
         Attributes attrs = map.get( "ou=testing02,ou=system" );
         assertEquals( 0, attrs.size() );
     }
-    
-    
+
+
     @Test
     public void testSearchSubstringSubTreeLevel() throws Exception
     {
@@ -302,18 +301,18 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(objectClass=organ*)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         // 16 because it also matches organizationalPerson which the admin is
         assertEquals( "Expected number of results returned was incorrect", 17, map.size() );
         assertTrue( map.containsKey( "ou=system" ) );
@@ -330,8 +329,8 @@ public class SearchIT extends AbstractLd
         assertTrue( map.containsKey( "prefNodeName=sysPrefRoot,ou=system" ) );
         assertTrue( map.containsKey( "uid=admin,ou=system" ) );
     }
-    
-    
+
+
     /**
      * Tests to make sure undefined attributes in filter assertions are pruned and do not
      * result in exceptions.
@@ -341,46 +340,46 @@ public class SearchIT extends AbstractLd
     {
         boolean oldSetAllowAnnonymousAccess = getService().isAllowAnonymousAccess();
         getService().setAllowAnonymousAccess( true );
-    
+
         SearchControls cons = new SearchControls();
         NamingEnumeration<SearchResult> e = sysRoot.search( "", "(bogusAttribute=abc123)", cons );
         assertNotNull( e );
-    
+
         e.close();
-    
+
         e = sysRoot.search( "", "(!(bogusAttribute=abc123))", cons );
         assertNotNull( e );
         assertFalse( e.hasMore() );
-    
+
         e.close();
-    
+
         e = sysRoot.search( "", "(|(bogusAttribute=abc123)(bogusAttribute=abc123))", cons );
         assertNotNull( e );
         assertFalse( e.hasMore() );
-    
+
         e.close();
-    
+
         e = sysRoot.search( "", "(|(bogusAttribute=abc123)(ou=abc123))", cons );
         assertNotNull( e );
         assertFalse( e.hasMore() );
-    
+
         e.close();
-    
+
         e = sysRoot.search( "", "(OBJECTclass=*)", cons );
         assertNotNull( e );
         assertTrue( e.hasMore() );
-    
+
         e.close();
-    
+
         e = sysRoot.search( "", "(objectclass=*)", cons );
         assertNotNull( e );
-    
+
         e.close();
-    
+
         getService().setAllowAnonymousAccess( oldSetAllowAnnonymousAccess );
     }
-    
-    
+
+
     @Test
     public void testSearchFilterArgs() throws Exception
     {
@@ -390,24 +389,24 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(|(ou={0})(ou={1}))", new Object[]
             { "testing00", "testing01" }, controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         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" ) );
     }
-    
-    
+
+
     @Test
     public void testFilterExpansion0() throws Exception
     {
@@ -416,23 +415,23 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(name=testing00)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "size of results", 1, map.size() );
         assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testFilterExpansion1() throws Exception
     {
@@ -441,18 +440,18 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(name=*)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "size of results", 23, map.size() );
         assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system" ) );
         assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
@@ -472,8 +471,8 @@ public class SearchIT extends AbstractLd
         assertTrue( "contains cn=administrators,ou=groups,ou=system", map
             .containsKey( "cn=Administrators,ou=groups,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testFilterExpansion2() throws Exception
     {
@@ -482,24 +481,24 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(|(name=testing00)(name=testing01))", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "size of results", 2, map.size() );
         assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system" ) );
         assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testFilterExpansion4() throws Exception
     {
@@ -508,18 +507,18 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(name=testing*)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "size of results", 6, map.size() );
         assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system" ) );
         assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
@@ -528,8 +527,8 @@ public class SearchIT extends AbstractLd
         assertTrue( "contains ou=testing04,ou=system", map.containsKey( "ou=testing04,ou=system" ) );
         assertTrue( "contains ou=testing05,ou=system", map.containsKey( "ou=testing05,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testFilterExpansion5() throws Exception
     {
@@ -538,7 +537,7 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
         String filter = "(|(2.5.4.11.1=testing*)(2.5.4.54=testing*)(2.5.4.10=testing*)"
             + "(2.5.4.6=testing*)(2.5.4.43=testing*)(2.5.4.7.1=testing*)(2.5.4.10.1=testing*)"
@@ -546,15 +545,15 @@ public class SearchIT extends AbstractLd
             + "(2.5.4.12=testing*)(1.3.6.1.4.1.18060.0.4.1.2.3=testing*)"
             + "(2.5.4.7=testing*)(2.5.4.3=testing*)(2.5.4.8=testing*)(2.5.4.42=testing*))";
         NamingEnumeration<SearchResult> list = sysRoot.search( "", filter, controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "size of results", 6, map.size() );
         assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system" ) );
         assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system" ) );
@@ -563,8 +562,8 @@ public class SearchIT extends AbstractLd
         assertTrue( "contains ou=testing04,ou=system", map.containsKey( "ou=testing04,ou=system" ) );
         assertTrue( "contains ou=testing05,ou=system", map.containsKey( "ou=testing05,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testOpAttrDenormalizationOff() throws Exception
     {
@@ -576,25 +575,25 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing00)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
         Attributes attrs = map.get( "ou=testing00,ou=system" );
         assertEquals( "normalized creator's name", "0.9.2342.19200300.100.1.1=admin,2.5.4.11=system", attrs.get(
             "creatorsName" ).get() );
     }
-    
-    
+
+
     @Test
     public void testOpAttrDenormalizationOn() throws Exception
     {
@@ -607,24 +606,24 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing00)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
         Attributes attrs = map.get( "ou=testing00,ou=system" );
         assertEquals( "normalized creator's name", "uid=admin,ou=system", attrs.get( "creatorsName" ).get() );
     }
-    
-    
+
+
     /**
      * Creation of required attributes of a person entry.
      *
@@ -636,26 +635,26 @@ public class SearchIT extends AbstractLd
     {
         Attributes attributes = LdifUtils.createJndiAttributes( "objectClass: top", "objectClass: top",
             "objectClass: person", "cn", cn, "sn", sn );
-    
+
         return attributes;
     }
-    
-    
+
+
     @Test
     public void testBinaryAttributesInFilter() throws Exception
     {
         byte[] certData = new byte[]
             { 0x34, 0x56, 0x4e, 0x5f };
-    
+
         // First let's add a some binary data representing a userCertificate
         Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
         attrs.put( "userCertificate", certData );
-    
+
         Attribute objectClasses = attrs.get( "objectClass" );
         objectClasses.add( "strongAuthenticationUser" );
-    
+
         sysRoot.createSubcontext( "cn=Kate Bush", attrs );
-    
+
         // Search for kate by cn first
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
@@ -664,22 +663,22 @@ public class SearchIT extends AbstractLd
         SearchResult sr = enm.next();
         assertNotNull( sr );
         assertFalse( enm.hasMore() );
-    
+
         enm.close();
-    
+
         assertEquals( "cn=Kate Bush,ou=system", sr.getName() );
-    
+
         enm = sysRoot.search( "", "(userCertificate=\\34\\56\\4E\\5F)", controls );
         assertTrue( enm.hasMore() );
         sr = enm.next();
         assertNotNull( sr );
         assertFalse( enm.hasMore() );
         assertEquals( "cn=Kate Bush,ou=system", sr.getName() );
-    
+
         enm.close();
     }
-    
-    
+
+
     @Test
     public void testSearchOperationalAttr() throws Exception
     {
@@ -691,28 +690,28 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing01)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
         Attributes attrs = map.get( "ou=testing01,ou=system" );
-    
+
         assertNotNull( attrs.get( "createTimestamp" ) );
         assertNotNull( attrs.get( "creatorsName" ) );
         assertNull( attrs.get( "objectClass" ) );
         assertNull( attrs.get( "ou" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchUserAttr() throws Exception
     {
@@ -724,28 +723,28 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing01)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
         Attributes attrs = map.get( "ou=testing01,ou=system" );
-    
+
         assertNotNull( attrs.get( "objectClass" ) );
         assertNotNull( attrs.get( "ou" ) );
         assertNull( attrs.get( "createTimestamp" ) );
         assertNull( attrs.get( "creatorsName" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchUserAttrAndOpAttr() throws Exception
     {
@@ -757,28 +756,28 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing01)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
         Attributes attrs = map.get( "ou=testing01,ou=system" );
-    
+
         assertNotNull( attrs.get( "objectClass" ) );
         assertNotNull( attrs.get( "ou" ) );
         assertNotNull( attrs.get( "creatorsName" ) );
         assertNull( attrs.get( "createTimestamp" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchUserAttrAndNoAttr() throws Exception
     {
@@ -790,28 +789,28 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing01)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
         Attributes attrs = map.get( "ou=testing01,ou=system" );
-    
+
         assertNull( attrs.get( "objectClass" ) );
         assertNotNull( attrs.get( "ou" ) );
         assertNull( attrs.get( "creatorsName" ) );
         assertNull( attrs.get( "createTimestamp" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchNoAttr() throws Exception
     {
@@ -823,28 +822,28 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing01)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
         Attributes attrs = map.get( "ou=testing01,ou=system" );
-    
+
         assertNull( attrs.get( "objectClass" ) );
         assertNull( attrs.get( "ou" ) );
         assertNull( attrs.get( "creatorsName" ) );
         assertNull( attrs.get( "createTimestamp" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchAllAttr() throws Exception
     {
@@ -856,28 +855,28 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing01)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
         Attributes attrs = map.get( "ou=testing01,ou=system" );
-    
+
         assertNotNull( attrs.get( "createTimestamp" ) );
         assertNotNull( attrs.get( "creatorsName" ) );
         assertNotNull( attrs.get( "objectClass" ) );
         assertNotNull( attrs.get( "ou" ) );
     }
-    
-    
+
+
     /**
      * Search an entry and fetch an attribute with unknown option
      * @throws NamingException if there are errors
@@ -890,18 +889,18 @@ public class SearchIT extends AbstractLd
         ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
         ctls.setReturningAttributes( new String[]
             { "cn", "sn;unknownOption", "badAttr" } );
-    
+
         NamingEnumeration<SearchResult> result = sysRoot.search( RDN, FILTER, ctls );
-    
+
         if ( result.hasMore() )
         {
             SearchResult entry = result.next();
             Attributes attrs = entry.getAttributes();
             Attribute cn = attrs.get( "cn" );
-    
+
             assertNotNull( cn );
             assertEquals( "Heather Nova", cn.get().toString() );
-    
+
             Attribute sn = attrs.get( "sn" );
             assertNull( sn );
         }
@@ -909,11 +908,11 @@ public class SearchIT extends AbstractLd
         {
             fail( "entry " + RDN + " not found" );
         }
-    
+
         result.close();
     }
-    
-    
+
+
     /**
      * Search an entry and fetch an attribute and all its subtypes
      * @throws NamingException if there are errors
@@ -925,23 +924,23 @@ public class SearchIT extends AbstractLd
         ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
         ctls.setReturningAttributes( new String[]
             { "name" } );
-    
+
         NamingEnumeration<SearchResult> result = sysRoot.search( RDN, FILTER, ctls );
-    
+
         if ( result.hasMore() )
         {
             SearchResult entry = result.next();
             Attributes attrs = entry.getAttributes();
-    
+
             // We should have get cn and sn only
             assertEquals( 2, attrs.size() );
-    
+
             // Check CN
             Attribute cn = attrs.get( "cn" );
-    
+
             assertNotNull( cn );
             assertEquals( "Heather Nova", cn.get().toString() );
-    
+
             // Assert SN
             Attribute sn = attrs.get( "sn" );
             assertNotNull( sn );
@@ -951,11 +950,11 @@ public class SearchIT extends AbstractLd
         {
             fail( "entry " + RDN + " not found" );
         }
-    
+
         result.close();
     }
-    
-    
+
+
     /**
      * Search an entry and fetch an attribute with twice the same attributeType
      * @throws NamingException if there are errors
@@ -967,15 +966,15 @@ public class SearchIT extends AbstractLd
         ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
         ctls.setReturningAttributes( new String[]
             { "cn", "cn" } );
-    
+
         NamingEnumeration<SearchResult> result = sysRoot.search( RDN, FILTER, ctls );
-    
+
         if ( result.hasMore() )
         {
             SearchResult entry = result.next();
             Attributes attrs = entry.getAttributes();
             Attribute cn = attrs.get( "cn" );
-    
+
             assertNotNull( cn );
             assertEquals( "Heather Nova", cn.get().toString() );
         }
@@ -983,11 +982,11 @@ public class SearchIT extends AbstractLd
         {
             fail( "entry " + RDN + " not found" );
         }
-    
+
         result.close();
     }
-    
-    
+
+
     // this one is failing because it returns the admin user twice: count = 15
     //    public void testFilterExpansion3() throws Exception
     //    {
@@ -1019,7 +1018,7 @@ public class SearchIT extends AbstractLd
     //        assertTrue( "contains uid=admin,ou=system", map.contains( "uid=admin,ou=system" ) );
     //        assertTrue( "contains cn=administrators,ou=groups,ou=system", map.contains( "cn=administrators,ou=groups,ou=system" ) );
     //    }
-    
+
     /**
      *  Convenience method that performs a one level search using the
      *  specified filter returning their DNs as Strings in a set.
@@ -1035,22 +1034,22 @@ public class SearchIT extends AbstractLd
         {
             controls = new SearchControls();
         }
-    
+
         Set<String> results = new HashSet<String>();
         NamingEnumeration<SearchResult> list = getSystemContext( getService() ).search( "ou=groups", filter, controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             results.add( result.getName() );
         }
-    
+
         list.close();
-    
+
         return results;
     }
-    
-    
+
+
     /**
      *  Convenience method that performs a one level search using the
      *  specified filter returning their DNs as Strings in a set.
@@ -1063,8 +1062,8 @@ public class SearchIT extends AbstractLd
     {
         return searchGroups( filter, null );
     }
-    
-    
+
+
     /**
      *  Convenience method that performs a one level search using the
      *  specified filter returning their DNs as Strings in a set.
@@ -1076,22 +1075,22 @@ public class SearchIT extends AbstractLd
     public Set<String> searchRevisions( String filter ) throws Exception
     {
         SearchControls controls = new SearchControls();
-    
+
         Set<String> results = new HashSet<String>();
         NamingEnumeration<SearchResult> list = getSystemContext( getService() ).search( "", filter, controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             results.add( result.getName() );
         }
-    
+
         list.close();
-    
+
         return results;
     }
-    
-    
+
+
     /**
      *  Convenience method that performs a one level search using the
      *  specified filter returning their DNs as Strings in a set.
@@ -1107,22 +1106,22 @@ public class SearchIT extends AbstractLd
         {
             controls = new SearchControls();
         }
-    
+
         Set<String> results = new HashSet<String>();
         NamingEnumeration<SearchResult> list = getSystemContext( getService() ).search( "", filter, controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             results.add( result.getName() );
         }
-    
+
         list.close();
-    
+
         return results;
     }
-    
-    
+
+
     @Test
     public void testSetup() throws Exception
     {
@@ -1134,8 +1133,8 @@ public class SearchIT extends AbstractLd
         assertTrue( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testLessThanSearch() throws Exception
     {
@@ -1146,7 +1145,7 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup3,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
-    
+
         results = searchGroups( "(gidNumber<=4)" );
         assertTrue( results.contains( "cn=testGroup0,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup1,ou=groups,ou=system" ) );
@@ -1154,7 +1153,7 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup3,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
-    
+
         results = searchGroups( "(gidNumber<=3)" );
         assertTrue( results.contains( "cn=testGroup0,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup1,ou=groups,ou=system" ) );
@@ -1162,7 +1161,7 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup3,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
-    
+
         results = searchGroups( "(gidNumber<=0)" );
         assertTrue( results.contains( "cn=testGroup0,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup1,ou=groups,ou=system" ) );
@@ -1170,7 +1169,7 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup3,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
-    
+
         results = searchGroups( "(gidNumber<=-1)" );
         assertFalse( results.contains( "cn=testGroup0,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup1,ou=groups,ou=system" ) );
@@ -1179,8 +1178,8 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testGreaterThanSearch() throws Exception
     {
@@ -1191,7 +1190,7 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup3,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
-    
+
         results = searchGroups( "(gidNumber>=1)" );
         assertFalse( results.contains( "cn=testGroup0,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup1,ou=groups,ou=system" ) );
@@ -1199,7 +1198,7 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup3,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
-    
+
         results = searchGroups( "(gidNumber>=3)" );
         assertFalse( results.contains( "cn=testGroup0,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup1,ou=groups,ou=system" ) );
@@ -1207,7 +1206,7 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup3,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
-    
+
         results = searchGroups( "(gidNumber>=6)" );
         assertFalse( results.contains( "cn=testGroup0,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup1,ou=groups,ou=system" ) );
@@ -1216,8 +1215,8 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertFalse( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testNotOperator() throws Exception
     {
@@ -1229,14 +1228,14 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testNotOperatorSubtree() throws Exception
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-    
+
         Set<String> results = searchGroups( "(!(gidNumber=4))", controls );
         assertTrue( results.contains( "cn=testGroup0,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup1,ou=groups,ou=system" ) );
@@ -1245,73 +1244,75 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "cn=testGroup4,ou=groups,ou=system" ) );
         assertTrue( results.contains( "cn=testGroup5,ou=groups,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchWithEscapedCharsInFilter() throws Exception
     {
         // Create entry cn=Sid Vicious, ou=system
-        Attributes vicious = LdifUtils.createJndiAttributes( "objectClass: top", "objectClass: person", "cn: Sid Vicious",
+        Attributes vicious = LdifUtils.createJndiAttributes( "objectClass: top", "objectClass: person",
+            "cn: Sid Vicious",
             "sn: Vicious", "description: (sex*pis\\tols)" );
-    
+
         DirContext ctx = sysRoot.createSubcontext( "cn=Sid Vicious", vicious );
         assertNotNull( ctx );
-    
+
         ctx = ( DirContext ) sysRoot.lookup( "cn=Sid Vicious" );
         assertNotNull( ctx );
-    
+
         Attributes attributes = ctx.getAttributes( "" );
-    
+
         assertEquals( "(sex*pis\\tols)", attributes.get( "description" ).get() );
-    
+
         // Now, search for the description
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
         controls.setDerefLinkFlag( false );
-    
+
         controls.setReturningAttributes( new String[]
             { "*" } );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot
             .search( "", "(description=\\28sex\\2Apis\\5Ctols\\29)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
         Attributes attrs = map.get( "cn=Sid Vicious,ou=system" );
-    
+
         assertNotNull( attrs.get( "objectClass" ) );
         assertNotNull( attrs.get( "cn" ) );
     }
-    
-    
+
+
     @Test
     public void testSubstringSearchWithEscapedCharsInFilter() throws Exception
     {
         // Create entry cn=Sid Vicious, ou=system
-        Attributes vicious = LdifUtils.createJndiAttributes( "objectClass: top", "objectClass: person", "cn: Sid Vicious",
+        Attributes vicious = LdifUtils.createJndiAttributes( "objectClass: top", "objectClass: person",
+            "cn: Sid Vicious",
             "sn: Vicious", "description: (sex*pis\\tols)" );
-    
+
         DirContext ctx = sysRoot.createSubcontext( "cn=Sid Vicious", vicious );
         assertNotNull( ctx );
-    
+
         ctx = ( DirContext ) sysRoot.lookup( "cn=Sid Vicious" );
         assertNotNull( ctx );
-    
+
         Attributes attributes = ctx.getAttributes( "" );
-    
+
         assertEquals( "(sex*pis\\tols)", attributes.get( "description" ).get() );
-    
+
         // Now, search for the description
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
@@ -1320,64 +1321,64 @@ public class SearchIT extends AbstractLd
             { "*" } );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         String[] filters = new String[]
             { "(description=*\\28*)", "(description=*\\29*)", "(description=*\\2A*)", "(description=*\\5C*)" };
-    
+
         for ( String filter : filters )
         {
             HashMap<String, Attributes> map = new HashMap<String, Attributes>();
             NamingEnumeration<SearchResult> list = sysRoot.search( "", filter, controls );
-    
+
             while ( list.hasMore() )
             {
                 SearchResult result = list.next();
                 map.put( result.getName(), result.getAttributes() );
             }
-    
+
             list.close();
-    
+
             assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
             Attributes attrs = map.get( "cn=Sid Vicious,ou=system" );
-    
+
             assertNotNull( attrs.get( "objectClass" ) );
             assertNotNull( attrs.get( "cn" ) );
         }
     }
-    
-    
+
+
     @Test
     public void testSubstringSearchWithEscapedAsterisksInFilter_DIRSERVER_1181() throws Exception
     {
         Attributes vicious = LdifUtils.createJndiAttributes( "objectClass: top", "objectClass: person", "cn: x*y*z*",
             "sn: x*y*z*", "description: (sex*pis\\tols)" );
-    
+
         sysRoot.createSubcontext( "cn=x*y*z*", vicious );
-    
+
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         controls.setReturningAttributes( new String[]
             { "cn" } );
         NamingEnumeration<SearchResult> res;
-    
+
         res = sysRoot.search( "", "(cn=*x\\2Ay\\2Az\\2A*)", controls );
         assertTrue( res.hasMore() );
         assertEquals( "x*y*z*", res.next().getAttributes().get( "cn" ).get() );
         assertFalse( res.hasMore() );
-    
+
         res.close();
-    
+
         res = sysRoot.search( "", "(cn=*{0}*)", new String[]
             { "x*y*z*" }, controls );
         assertTrue( res.hasMore() );
         assertEquals( "x*y*z*", res.next().getAttributes().get( "cn" ).get() );
         assertFalse( res.hasMore() );
-    
+
         res.close();
     }
-    
-    
+
+
     /**
      * Test a search with a bad filter : there is a missing closing ')'
      */
@@ -1389,7 +1390,7 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         try
         {
             sysRoot.search( "", "(|(name=testing00)(name=testing01)", controls );
@@ -1400,8 +1401,8 @@ public class SearchIT extends AbstractLd
             assertTrue( true );
         }
     }
-    
-    
+
+
     /**
      * Search operation with a base Dn with quotes
      * Commented as it's not valid by RFC 5514
@@ -1439,7 +1440,7 @@ public class SearchIT extends AbstractLd
         }
     }
     */
-    
+
     /**
     * Added to test correct comparison of integer attribute types when searching.
     * testGreaterThanSearch and testLesserThanSearch fail to detect the problem using values less than 10.
@@ -1458,8 +1459,8 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "ou=testing04,ou=system" ) );
         assertFalse( results.contains( "ou=testing05,ou=system" ) );
     }
-    
-    
+
+
     /**
      * Added to test correct comparison of integer attribute types when searching.
      * testGreaterThanSearch and testLesserThanSearch fail to detect the problem using values less than 10.
@@ -1478,8 +1479,8 @@ public class SearchIT extends AbstractLd
         assertTrue( results.contains( "ou=testing04,ou=system" ) );
         assertTrue( results.contains( "ou=testing05,ou=system" ) );
     }
-    
-    
+
+
     /**
      * Added to test correct comparison of integer attribute types when searching.
      * testGreaterThanSearch and testLesserThanSearch fail to detect the problem using values less than 10.
@@ -1498,8 +1499,8 @@ public class SearchIT extends AbstractLd
         assertTrue( results.contains( "ou=testing04,ou=system" ) );
         assertTrue( results.contains( "ou=testing05,ou=system" ) );
     }
-    
-    
+
+
     /**
      * Added to test correct comparison of integer attribute types when searching.
      * testGreaterThanSearch and testLesserThanSearch fail to detect the problem using values less than 10.
@@ -1519,31 +1520,31 @@ public class SearchIT extends AbstractLd
         assertFalse( results.contains( "ou=testing04,ou=system" ) );
         assertTrue( results.contains( "ou=testing05,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchTelephoneNumber() throws Exception
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(telephoneNumber=18015551212)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 2, map.size() );
         assertTrue( map.containsKey( "cn=Heather Nova, ou=system" ) || map.containsKey( "cn=Heather Nova,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchDN() throws Exception
     {
@@ -1552,24 +1553,24 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(manager=cn=Heather Nova, ou=system)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect", 1, map.size() );
         assertTrue( map.containsKey( "cn=with-dn, ou=system" ) || map.containsKey( "cn=with-dn,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testComplexFilter() throws Exception
     {
@@ -1578,25 +1579,25 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
-    
+
         // Create an entry which does not match
         Attributes attrs = LdifUtils.createJndiAttributes( "objectClass: top", "objectClass: groupOfUniqueNames",
             "cn: testGroup3", "uniqueMember: uid=admin,ou=system" );
-    
+
         getSystemContext( getService() ).createSubcontext( "cn=testGroup3,ou=groups", attrs );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
         String filter = "(|(&(|(2.5.4.0=posixgroup)(2.5.4.0=groupofuniquenames)(2.5.4.0=groupofnames)(2.5.4.0=group))(!(|(2.5.4.50=uid=admin,ou=system)(2.5.4.31=0.9.2342.19200300.100.1.1=admin,2.5.4.11=system))))(objectClass=referral))";
         NamingEnumeration<SearchResult> list = sysRoot.search( "", filter, controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "size of results", 5, map.size() );
         assertTrue( map.containsKey( "cn=testGroup0,ou=groups,ou=system" ) );
         assertTrue( map.containsKey( "cn=testGroup1,ou=groups,ou=system" ) );
@@ -1605,8 +1606,8 @@ public class SearchIT extends AbstractLd
         assertTrue( map.containsKey( "cn=testGroup5,ou=groups,ou=system" ) );
         assertFalse( map.containsKey( "cn=testGroup3,ou=groups,ou=system" ) );
     }
-    
-    
+
+
     /**
      *  NO attributes should be returned
      */
@@ -1621,27 +1622,27 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         sysRoot.addToEnvironment( "java.naming.ldap.typesOnly", "true" );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing01)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
         Attributes attrs = map.get( "ou=testing01,ou=system" );
-    
+
         assertEquals( 0, attrs.size() );
     }
-    
-    
+
+
     /**
      * operational attributes with no values must be returned
      */
@@ -1656,31 +1657,31 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         sysRoot.addToEnvironment( "java.naming.ldap.typesOnly", "true" );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing01)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
         Attributes attrs = map.get( "ou=testing01,ou=system" );
-    
+
         assertNotNull( attrs.get( SchemaConstants.ENTRY_UUID_AT ) );
         assertNotNull( attrs.get( SchemaConstants.CREATORS_NAME_AT ) );
-    
+
         assertEquals( 0, attrs.get( SchemaConstants.ENTRY_UUID_AT ).size() );
         assertEquals( 0, attrs.get( SchemaConstants.CREATORS_NAME_AT ).size() );
     }
-    
-    
+
+
     /**
      * all user attributes with no values must be returned
      */
@@ -1693,115 +1694,115 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         sysRoot.addToEnvironment( "java.naming.ldap.typesOnly", "true" );
-    
+
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(ou=testing01)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
-    
+
         Attributes attrs = map.get( "ou=testing01,ou=system" );
-    
+
         assertNotNull( attrs.get( SchemaConstants.OU_AT ) );
         assertNotNull( attrs.get( "integerAttribute" ) );
-    
+
         assertEquals( 0, attrs.get( SchemaConstants.OU_AT ).size() );
         assertEquals( 0, attrs.get( "integerAttribute" ).size() );
-    
+
         assertNull( attrs.get( SchemaConstants.ENTRY_UUID_AT ) );
         assertNull( attrs.get( SchemaConstants.CREATORS_NAME_AT ) );
     }
-    
-    
+
+
     @Test
     public void testSearchEmptyDNWithOneLevelScope() throws Exception
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         controls.setDerefLinkFlag( false );
-    
+
         LdapContext nullRootCtx = getRootContext( getService() );
-    
+
         NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(objectClass=*)", controls );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( 2, map.size() );
-    
+
         assertTrue( map.containsKey( "ou=system" ) );
         assertTrue( map.containsKey( "ou=schema" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchEmptyDNWithSubLevelScope() throws Exception
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
         controls.setDerefLinkFlag( false );
-    
+
         LdapContext nullRootCtx = getRootContext( getService() );
-    
+
         NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(objectClass=organizationalUnit)", controls );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertTrue( map.size() > 2 );
-    
+
         assertTrue( map.containsKey( "ou=system" ) );
         assertTrue( map.containsKey( "ou=schema" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchEmptyDNWithObjectScopeAndNoObjectClassPresenceFilter() throws Exception
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
         controls.setDerefLinkFlag( false );
-    
+
         LdapContext nullRootCtx = getRootContext( getService() );
-    
+
         NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(objectClass=domain)", controls );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( 0, map.size() );
-    
+
         assertFalse( map.containsKey( "ou=system" ) );
         assertFalse( map.containsKey( "ou=schema" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchRootDSE() throws Exception
     {
@@ -1810,22 +1811,22 @@ public class SearchIT extends AbstractLd
         controls.setDerefLinkFlag( false );
         controls.setReturningAttributes( new String[]
             { "*", "+" } );
-    
+
         LdapContext nullRootCtx = getRootContext( getService() );
-    
+
         NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(objectClass=*)", controls );
         Attributes rootDse = null;
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             rootDse = result.getAttributes();
         }
-    
+
         list.close();
-    
+
         assertNotNull( rootDse );
-    
+
         assertEquals( 10, rootDse.size() );
         assertNotNull( rootDse.get( "objectClass" ) );
         assertNotNull( rootDse.get( "entryUUID" ) );
@@ -1838,89 +1839,89 @@ public class SearchIT extends AbstractLd
         assertNotNull( rootDse.get( "vendorName" ) );
         assertNotNull( rootDse.get( "vendorVersion" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchEmptyDNWithOneLevelScopeAndNoObjectClassPresenceFilter() throws Exception
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         controls.setDerefLinkFlag( false );
-    
+
         LdapContext nullRootCtx = getRootContext( getService() );
-    
+
         NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(cn=*)", controls );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( 0, map.size() );
-    
+
         assertFalse( map.containsKey( "ou=system" ) );
         assertFalse( map.containsKey( "ou=schema" ) );
     }
-    
-    
+
+
     @Test
     public void testCsnLessEqualitySearch() throws Exception
     {
         LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
-    
+
         Dn dn = new Dn( "cn=testLowerCsnAdd,ou=system" );
         Entry entry = new DefaultEntry( dn );
         entry.add( "objectClass", SchemaConstants.PERSON_OC );
         entry.add( "cn", "testLowerCsnAdd_cn" );
         entry.add( "sn", "testLowerCsnAdd_sn" );
-    
+
         connection.add( entry );
-    
+
         // add an entry to have a entry with higher CSN value
         Dn dn2 = new Dn( "cn=testHigherCsnAdd,ou=system" );
         Entry entry2 = new DefaultEntry( dn2,
             "objectClass :person",
             "cn: testHigherCsnAdd_cn",
             "sn: testHigherCsnAdd_sn" );
-    
+
         connection.add( entry2 );
-    
+
         entry = connection.lookup( dn.getName(), "+" );
         entry2 = connection.lookup( dn2.getName(), "+" );
-    
+
         String lowerCsn = entry.get( "entryCsn" ).getString();
         String higherCsn = entry2.get( "entryCsn" ).getString();
-    
+
         // usecases
         // 1.1 Less than or Equal ( with the lower csn value)
         testUseCases( lowerCsn, new String[]
             { lowerCsn }, connection, 1 );
-    
+
         // 1.2 Less than or equals with a highest csn value
         testUseCases( higherCsn, new String[]
             { higherCsn, lowerCsn }, connection, 1 );
-    
+
         // 2.1 Greater than or Equal ( with the highest csn value )
         testUseCases( higherCsn, new String[]
             { higherCsn }, connection, 2 );
-    
+
         // 2.2 Greater than or Equal ( with lower csn value )
         testUseCases( lowerCsn, new String[]
             { higherCsn, lowerCsn }, connection, 2 );
     }
-    
-    
+
+
     private void testUseCases( String filterCsnVal, String[] expectedCsns, LdapConnection connection, int useCaseNum )
         throws Exception
     {
         Value<String> val = new StringValue( filterCsnVal );
         AttributeType entryCsnAt = getService().getSchemaManager().getAttributeType( SchemaConstants.ENTRY_CSN_AT );
         ExprNode filter = null;
-    
+
         if ( useCaseNum == 1 )
         {
             filter = new LessEqNode( entryCsnAt, val );
@@ -1929,29 +1930,29 @@ public class SearchIT extends AbstractLd
         {
             filter = new GreaterEqNode( entryCsnAt, val );
         }
-    
+
         Entry loadedEntry = null;
-    
+
         Set<String> csnSet = new HashSet<String>( expectedCsns.length );
         EntryCursor cursor = connection.search( "ou=system", filter.toString(), SearchScope.ONELEVEL, "*", "+" );
-    
+
         while ( cursor.next() )
         {
             loadedEntry = cursor.get();
             csnSet.add( loadedEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );
         }
-    
+
         cursor.close();
-    
+
         assertTrue( csnSet.size() >= expectedCsns.length );
-    
+
         for ( String csn : expectedCsns )
         {
             assertTrue( csnSet.contains( csn ) );
         }
     }
-    
-    
+
+
     @Test
     public void testSearchFilterWithBadAttributeType() throws Exception
     {
@@ -1961,23 +1962,23 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(|(badAttr={0})(ou={1}))", new Object[]
             { "testing00", "testing01" }, controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
         assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
     }
-    
-    
+
+
     @Test
     public void testSearchFilterBadAttributeType() throws Exception
     {
@@ -1987,17 +1988,43 @@ public class SearchIT extends AbstractLd
         sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES
             .getJndiValue() );
         HashMap<String, Attributes> map = new HashMap<String, Attributes>();
-    
+
         NamingEnumeration<SearchResult> list = sysRoot.search( "", "(badAttr=*)", controls );
-    
+
         while ( list.hasMore() )
         {
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
-    
+
         list.close();
-    
+
         assertEquals( "Expected number of results returned was incorrect!", 0, map.size() );
     }
+
+
+    @Test
+    public void testSearchRootDSESubtree() throws Exception
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+        controls.setDerefLinkFlag( false );
+        controls.setReturningAttributes( new String[]
+            { "*", "+" } );
+
+        LdapContext nullRootCtx = getRootContext( getService() );
+
+        NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(ou=testing01)", controls );
+        Attributes rootDse = null;
+
+        while ( list.hasMore() )
+        {
+            SearchResult result = list.next();
+            rootDse = result.getAttributes();
+        }
+
+        list.close();
+
+        assertNotNull( rootDse );
+    }
 }

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java?rev=1513852&r1=1513851&r2=1513852&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java Wed Aug 14 12:47:26 2013
@@ -22,9 +22,12 @@ package org.apache.directory.shared.clie
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.directory.api.ldap.model.cursor.CursorException;
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
@@ -34,6 +37,8 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.entry.Modification;
 import org.apache.directory.api.ldap.model.entry.ModificationOperation;
 import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.api.ldap.model.message.SearchResultDone;
 import org.apache.directory.api.ldap.model.message.SearchScope;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
@@ -73,10 +78,26 @@ import org.junit.runner.RunWith;
                         @CreateIndex(attribute = "sn"),
                         @CreateIndex(attribute = "cn"),
                         @CreateIndex(attribute = "displayName")
+                }),
+            @CreatePartition(
+                name = "test",
+                suffix = "dc=test,dc=com",
+                contextEntry = @ContextEntry(
+                    entryLdif =
+                    "dn: dc=test,dc=com\n" +
+                        "dc: test\n" +
+                        "objectClass: top\n" +
+                        "objectClass: domain\n\n"),
+                indexes =
+                    {
+                        @CreateIndex(attribute = "objectClass"),
+                        @CreateIndex(attribute = "sn"),
+                        @CreateIndex(attribute = "cn"),
+                        @CreateIndex(attribute = "displayName")
                 })
 
     },
-    enableChangeLog = false)
+    enableChangeLog = true)
 @CreateLdapServer(transports =
     {
         @CreateTransport(protocol = "LDAP"),
@@ -735,4 +756,63 @@ public class OperationWithIndexTest exte
         // Delete the entry
         connection.delete( dn );
     }
+
+
+    /**
+     * Check that we can find entries in more than one partition 
+     */
+    @Test
+    public void testSimpleSearch() throws Exception
+    {
+        // Add an entry in ou=system
+        Dn dn1 = new Dn( "cn=test,ou=system" );
+        Entry entry1 = new DefaultEntry( getService().getSchemaManager(), dn1,
+            "ObjectClass: top",
+            "ObjectClass: person",
+            "sn: TEST",
+            "cn: test" );
+
+        connection.add( entry1 );
+
+        // Add an entry in dc=test
+        Dn dn2 = new Dn( "cn=test,dc=test,dc=com" );
+        Entry entry2 = new DefaultEntry( getService().getSchemaManager(), dn2,
+            "ObjectClass: top",
+            "ObjectClass: person",
+            "sn: TEST",
+            "cn: test" );
+
+        connection.add( entry2 );
+
+        // Add an entry in dc=example
+        Dn dn3 = new Dn( "cn=test,dc=example,dc=com" );
+        Entry entry3 = new DefaultEntry( getService().getSchemaManager(), dn3,
+            "ObjectClass: top",
+            "ObjectClass: person",
+            "sn: TEST",
+            "cn: test" );
+
+        connection.add( entry3 );
+
+        // Now search the entry from the root
+        EntryCursor cursor = connection.search( "", "(cn=test)", SearchScope.SUBTREE );
+        List<String> entries = new ArrayList<String>();
+
+        while ( cursor.next() )
+        {
+            Entry entryFound = cursor.get();
+            assertNotNull( entryFound );
+            entries.add( entryFound.getDn().getName() );
+        }
+
+        SearchResultDone done = cursor.getSearchResultDone();
+
+        assertNotNull( done );
+        assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
+        assertEquals( 3, entries.size() );
+        assertTrue( entries.contains( "cn=test,dc=test,dc=com" ) );
+        assertTrue( entries.contains( "cn=test,dc=example,dc=com" ) );
+        assertTrue( entries.contains( "cn=test,ou=system" ) );
+        cursor.close();
+    }
 }