results.close();
assertEquals( 1, nbFound );
// Ok, now replace the cn
Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "cn", "New cn" );
connection.modify( dn, modification );
// The Substring index on CN should still work
// The old cn should still be present anymore
results = connection.search( "dc=example,dc=com", "(cn=e*)", SearchScope.SUBTREE, "*" );
nbFound = 0;
while ( results.next() )
{
Entry result = results.get();
assertTrue( result.contains( "cn", "entryTest" ) );
nbFound++;
}
assertEquals( 1, nbFound );
results.close();
// Check that we can find the new cn
results = connection.search( "dc=example,dc=com", "(cn=n*)", SearchScope.SUBTREE, "*" );
nbFound = 0;
while ( results.next() )
{
Entry result = results.get();
assertTrue( result.contains( "cn", "New cn" ) );
nbFound++;
}
assertEquals( 1, nbFound );
results.close();
// Now, check the presence index
results = connection.search( "dc=example,dc=com", "(cn=*)", SearchScope.SUBTREE, "*" );
nbFound = 0;
while ( results.next() )
{
Entry result = results.get();
assertTrue( result.contains( "cn", "New cn", "entryTest" ) );
nbFound++;
}
assertEquals( 1, nbFound );
results.close();
// Now, check that the index on displayName is correctly updated
modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "displayName", "testUser" );
connection.modify( dn, modification );
// Check the displayName index
results = connection.search( "dc=example,dc=com", "(displayName=t*)", SearchScope.SUBTREE, "*" );