// Use the client API as JNDI cannot be used to do a search without
// first binding. (hmmm, even client API won't allow searching without binding)
connection.bind( "uid=admin,ou=system", "secret" );
// Searches for all the entries in ou=system
EntryCursor cursor = connection.search( "ou=system", "(ObjectClass=*)",
SearchScope.ONELEVEL, "*" );
int i = 0;
while ( cursor.next() )
{
cursor.get();
++i;
}
cursor.close();
assertEquals( 5, i );
for ( int j = 0; j < 10000; j++ )
{
cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.ONELEVEL, "*" );
while ( cursor.next() )
{
cursor.get();
}
cursor.close();
}
Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" );
SearchRequest searchRequest = new SearchRequestImpl();
searchRequest.setBase( dn );
searchRequest.setFilter( "(ObjectClass=*)" );
searchRequest.setScope( SearchScope.ONELEVEL );
searchRequest.addAttributes( "*" );
searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );
long t0 = System.currentTimeMillis();
long t00 = 0L;
long tt0 = System.currentTimeMillis();
int nbIterations = 200000;
int count = 0;
for ( int j = 0; j < nbIterations; j++ )
{
if ( j % 10000 == 0 )
{
long tt1 = System.currentTimeMillis();
System.out.println( j + ", " + ( tt1 - tt0 ) );
tt0 = tt1;
}
if ( j == 50000 )
{
t00 = System.currentTimeMillis();
}
cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.ONELEVEL, "*" );
while ( cursor.next() )
{
count++;
cursor.get();
}
cursor.close();
}
long t1 = System.currentTimeMillis();
Long deltaWarmed = ( t1 - t00 );