@Test
public void testAncestorReferral() throws Exception
{
LOG.debug( "" );
LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
LDAPConstraints constraints = new LDAPConstraints();
conn.setConstraints( constraints );
// referrals failure
LDAPAttributeSet attrSet = new LDAPAttributeSet();
attrSet.add( new LDAPAttribute( "objectClass", "organizationalUnit" ) );
attrSet.add( new LDAPAttribute( "ou", "UnderReferral" ) );
LDAPEntry entry = new LDAPEntry( "ou=UnderReferral,ou=Computers,uid=akarasuluref,ou=users,ou=system", attrSet );
LDAPResponseListener listener = conn.add( entry, null, constraints );
LDAPResponse response = listener.getResponse();
assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
assertEquals( "ldap://localhost:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system", response
.getReferrals()[0] );
assertEquals( "ldap://foo:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system", response
.getReferrals()[1] );
assertEquals( "ldap://bar:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system", response
.getReferrals()[2] );
conn.disconnect();
}