public void testSearchWithIndexBinaryAttribute() throws Exception
{
LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
// Do a search with a filter based on certificate, get back all the entries
EntryCursor responses = connection.search( "ou=system", "(userCertificate=*)",
SearchScope.SUBTREE, "*" );
int i = 0;
while ( responses.next() )
{
responses.get();
++i;
}
responses.close();
// We should have 3 entries
assertEquals( 4, i );
// Now, filter the entry with a cn starting with testing, and a certificate
responses = connection.search( "ou=system", "(&(cn=testing*)(userCertificate=*))", SearchScope.SUBTREE, "*" );
i = 0;
while ( responses.next() )
{
responses.get();
++i;
}
responses.close();
// Now, only 2 entries
assertEquals( 3, i );
// Now, just get back the entry with a certificate equals to 0x01 0x02 0x03 0x04
responses = connection.search( "ou=system", "(userCertificate=\\01\\02\\03\\04)", SearchScope.SUBTREE, "*" );
i = 0;
while ( responses.next() )
{
responses.get();
++i;
}
responses.close();
assertEquals( 2, i );
// Last, check that searching for an entry using a SUBSTR filter does not work
responses = connection.search( "ou=system", "(userCertificate=\\01\\02*)", SearchScope.SUBTREE, "*" );
i = 0;
while ( responses.next() )
{
responses.get();
++i;
}
responses.close();
assertEquals( 0, i );
connection.close();
}