{
DN adminDn = new DN( "uid=admin,ou=system" ).normalize( schemaManager.getNormalizerMapping() );
CoreSession session = new MockCoreSession( new LdapPrincipal( adminDn, AuthenticationLevel.STRONG ), new MockDirectoryService( 1 ) );
AddOperationContext addCtx = new AddOperationContext( session );
ClonedServerEntry entry1 = createEntry( "dc=test,ou=test,ou=system" );
entry1.put( "ObjectClass", "top", "domain" );
entry1.put( "dc", "test" );
addCtx.setEntry( entry1 );
partition.add( addCtx );
ClonedServerEntry entry2 = createEntry( "dc=test1,dc=test,ou=test,ou=system" );
entry2.put( "ObjectClass", "top", "domain" );
entry2.put( "dc", "test1" );
addCtx.setEntry( entry2 );
partition.add( addCtx );
ClonedServerEntry entry3 = createEntry( "dc=test2,dc=test,ou=test,ou=system" );
entry3.put( "ObjectClass", "top", "domain" );
entry3.put( "dc", "test2" );
addCtx.setEntry( entry3 );
partition.add( addCtx );
SearchOperationContext searchCtx = new SearchOperationContext( session );
DN dn = new DN( "dc=test,ou=test,ou=system" );
dn.normalize( schemaManager.getNormalizerMapping() );
searchCtx.setDn( dn );
ExprNode filter = FilterParser.parse( "(ObjectClass=domain)" );
searchCtx.setFilter( filter );
searchCtx.setScope( SearchScope.SUBTREE );
EntryFilteringCursor cursor = partition.search( searchCtx );
assertNotNull( cursor );
Set<String> expectedDns = new HashSet<String>();
expectedDns.add( entry1.getDn().getNormName() );
expectedDns.add( entry2.getDn().getNormName() );
expectedDns.add( entry3.getDn().getNormName() );
cursor.beforeFirst();
int nbRes = 0;
while ( cursor.next() )