@Test
public void testSearchBaseWithReferralThrowAfterMoveAndRename() throws Exception
{
DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.OBJECT_SCOPE );
try
{
ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls );
fail( "Should fail here throwing a ReferralException" );
}
catch ( ReferralException re )
{
String referral = ( String ) re.getReferralInfo();
assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??base", referral );
}
( ( LdapContext ) ctx ).setRequestControls( new javax.naming.ldap.Control[]
{ new ManageReferralControl() } );
// Now let's move the entry
ctx.rename( "c=america,ou=Countries,ou=system", "c=us,ou=system" );
controls.setSearchScope( SearchControls.OBJECT_SCOPE );
( ( LdapContext ) ctx ).setRequestControls( new javax.naming.ldap.Control[]
{} );
try