use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class BindResponseImplTest method testEqualsWithTheWorks.
/**
* Tests for equality of two fully loaded identical BindResponse PDUs.
*/
@Test
public void testEqualsWithTheWorks() throws LdapException {
LdapResultImpl r0 = new LdapResultImpl();
LdapResultImpl r1 = new LdapResultImpl();
r0.setDiagnosticMessage("blah blah blah");
r1.setDiagnosticMessage("blah blah blah");
r0.setMatchedDn(new Dn("dc=example,dc=com"));
r1.setMatchedDn(new Dn("dc=example,dc=com"));
r0.setResultCode(ResultCodeEnum.TIME_LIMIT_EXCEEDED);
r1.setResultCode(ResultCodeEnum.TIME_LIMIT_EXCEEDED);
Referral refs0 = new ReferralImpl();
refs0.addLdapUrl("ldap://someserver.com");
refs0.addLdapUrl("ldap://anotherserver.org");
Referral refs1 = new ReferralImpl();
refs1.addLdapUrl("ldap://someserver.com");
refs1.addLdapUrl("ldap://anotherserver.org");
BindResponseImpl resp0 = new BindResponseImpl(1);
BindResponseImpl resp1 = new BindResponseImpl(1);
resp0.setServerSaslCreds(PASSWORD);
resp1.setServerSaslCreds(PASSWORD);
assertTrue("loaded carbon copies should be equal", resp0.equals(resp1));
assertTrue("loaded carbon copies should be equal", resp1.equals(resp0));
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class LdapResultImplTest method testNotEqualsDiffReferrals.
/**
* Tests for inequality when the referrals are not the same.
*/
@Test
public void testNotEqualsDiffReferrals() throws LdapException {
LdapResultImpl r0 = new LdapResultImpl();
LdapResultImpl r1 = new LdapResultImpl();
r0.setDiagnosticMessage("blah blah blah");
r1.setDiagnosticMessage("blah blah blah");
r0.setMatchedDn(new Dn("dc=example,dc=com"));
r1.setMatchedDn(new Dn("dc=example,dc=com"));
r0.setResultCode(ResultCodeEnum.TIME_LIMIT_EXCEEDED);
r1.setResultCode(ResultCodeEnum.TIME_LIMIT_EXCEEDED);
Referral refs0 = new ReferralImpl();
r0.setReferral(refs0);
refs0.addLdapUrl("ldap://someserver.com");
refs0.addLdapUrl("ldap://anotherserver.org");
Referral refs1 = new ReferralImpl();
r1.setReferral(refs1);
refs1.addLdapUrl("ldap://abc.com");
refs1.addLdapUrl("ldap://anotherserver.org");
assertFalse("results with different referrals should not be equal", r0.equals(r1));
assertFalse("results with different referrals should not be equal", r1.equals(r0));
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class ReferralImplTest method testEqualsSameObject.
/**
* Tests to make sure the equals method works for the same exact object.
*/
@Test
public void testEqualsSameObject() {
ReferralImpl refs = new ReferralImpl();
assertTrue("equals method should work for the same object", refs.equals(refs));
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class ReferralImplTest method testHashCodeSameObject.
/**
* Tests to make sure to get equal hashCode for the same exact object.
*/
@Test
public void testHashCodeSameObject() {
ReferralImpl refs = new ReferralImpl();
assertTrue(refs.hashCode() == refs.hashCode());
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class InitReferrals method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<MessageDecorator<? extends Message>> container) throws DecoderException {
TLV tlv = container.getCurrentTLV();
// If we hae a Referrals sequence, then it should not be empty
if (tlv.getLength() == 0) {
String msg = I18n.err(I18n.ERR_04011);
LOG.error(msg);
// This will generate a PROTOCOL_ERROR
throw new DecoderException(msg);
}
ResultResponse response = (ResultResponse) container.getMessage();
LdapResult ldapResult = response.getLdapResult();
Referral referral = new ReferralImpl();
ldapResult.setReferral(referral);
if (IS_DEBUG) {
LOG.debug("Initialising a referrals list");
}
}
Aggregations