public void testPsearchMove() throws Exception
{
LdapNetworkConnection connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
connection.bind( "uid=admin,ou=system", "secret" );
Entry newOu = new DefaultEntry( "uid=persist, ou=users,ou=system" );
newOu.add( "objectClass", "inetOrgPerson" );
newOu.add( "cn", "persist_cn" );
newOu.add( "sn", "persist_sn" );
connection.add( newOu );
SearchRequest sr = new SearchRequestImpl();
sr.setBase( new Dn( BASE ) );
sr.setFilter( "(objectClass=*)" );
sr.setScope( SearchScope.SUBTREE );
PersistentSearch ps = new PersistentSearchImpl();
ps.setChangesOnly( true );
ps.setReturnECs( true );
ps.setCritical( true );
sr.addControl( ps );
final SearchCursor cursor = connection.search( sr );
final List<Entry> entryList = new ArrayList<Entry>();
Runnable r = new Runnable()
{
@Override
public void run()
{
try
{
while( cursor.next() )
{
entryList.add( cursor.getEntry() );
}
}
catch( Exception e )
{
throw new RuntimeException( e );
}
}
};
new Thread( r ).start();
connection.move( newOu.getDn(), newOu.getDn().getParent().getParent() );
Thread.sleep( 1000 );
assertFalse( entryList.isEmpty() );
assertEquals( 1, entryList.size() );
assertEquals( "uid=persist,ou=system", entryList.get( 0 ).getDn().getName() );