public void testRefreshSearchContinuation() throws Exception
{
// preparation: add referral entry and set referral handling
String url = "ldap://localhost:" + ldapServer.getPort() + "/ou=users,ou=system";
ServerEntry refEntry = new DefaultServerEntry( ldapServer.getDirectoryService().getRegistries() );
refEntry.setDn( new LdapDN( "cn=referral,ou=system" ) );
refEntry.add( "objectClass", "top", "referral", "extensibleObject" );
refEntry.add( "cn", "referral" );
refEntry.add( "ref", url );
ldapServer.getDirectoryService().getAdminSession().add( refEntry );
connection.getConnectionParameter().setExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD,
ReferralHandlingMethod.FOLLOW_MANUALLY.ordinal() );
browserViewBot.selectEntry( "DIT", "Root DSE" );
browserViewBot.refresh();
// check the entry doesn't exist yet
ReferralDialogBot refDialog = browserViewBot.expandEntryExpectingReferralDialog( "DIT", "Root DSE",
"ou=system", url );
refDialog.clickOkButton();
assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" ) );
// add the entry directly in the server
ServerEntry entry = new DefaultServerEntry( ldapServer.getDirectoryService().getRegistries() );
entry.setDn( new LdapDN( "cn=refresh,ou=users,ou=system" ) );
entry.add( "objectClass", "top", "person" );
entry.add( "cn", "refresh" );
entry.add( "sn", "refresh" );
ldapServer.getDirectoryService().getAdminSession().add( entry );
// check the entry still isn't visible in the tree
assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" ) );
// refresh search continuation
browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", url );
browserViewBot.refresh();
// check the entry exists now
browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", url );
assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" ) );
browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" );
// delete the entry directly in the server
ldapServer.getDirectoryService().getAdminSession().delete( new LdapDN( "cn=refresh,ou=users,ou=system" ) );
// check the entry still is now visible in the tree
assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" ) );
// refresh search continuation