use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class LdapResultImplTest method testNotEqualsDiffErrorMessage.
/**
* Tests for inequality when the error message is different.
*/
@Test
public void testNotEqualsDiffErrorMessage() throws LdapException {
LdapResultImpl r0 = new LdapResultImpl();
LdapResultImpl r1 = new LdapResultImpl();
r0.setDiagnosticMessage("blah blah blah");
r1.setDiagnosticMessage("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");
assertFalse("results with different error messages should " + "not be equal", r0.equals(r1));
assertFalse("results with different error messages 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 LdapResultImplTest method testHashCodeCarbonCopy.
/**
* Tests two non default carbon copies for equal hashCode.
*/
@Test
public void testHashCodeCarbonCopy() 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");
assertTrue(r0.hashCode() == r1.hashCode());
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class ReferralImplTest method testHashCodeExactCopyWithRedundancy.
/**
* Tests to make sure to get equal hashCode for two objects that are the
* same exact copy of one another but there are redundant entries.
*/
@Test
public void testHashCodeExactCopyWithRedundancy() {
ReferralImpl refs0 = new ReferralImpl();
refs0.addLdapUrl("ldap://blah0");
refs0.addLdapUrl("ldap://blah1");
refs0.addLdapUrl("ldap://blah2");
refs0.addLdapUrl("ldap://blah2");
ReferralImpl refs1 = new ReferralImpl();
refs1.addLdapUrl("ldap://blah0");
refs1.addLdapUrl("ldap://blah1");
refs1.addLdapUrl("ldap://blah2");
refs1.addLdapUrl("ldap://blah2");
assertTrue(refs0.hashCode() == refs1.hashCode());
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class ReferralImplTest method testHashCodeExactCopy.
/**
* Tests to make sure to get equal hashCode for two objects that are the
* same exact copy of one another.
*/
@Test
public void testHashCodeExactCopy() {
ReferralImpl refs0 = new ReferralImpl();
refs0.addLdapUrl("ldap://blah0");
refs0.addLdapUrl("ldap://blah1");
refs0.addLdapUrl("ldap://blah2");
ReferralImpl refs1 = new ReferralImpl();
refs1.addLdapUrl("ldap://blah0");
refs1.addLdapUrl("ldap://blah1");
refs1.addLdapUrl("ldap://blah2");
assertTrue(refs0.hashCode() == refs1.hashCode());
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class ReferralImplTest method testEqualsSameNumberButDifferentUrls.
/**
* Tests to make sure the equals method works for two objects that are the
* not exact copies of one another but have the same number of URLs.
*/
@Test
public void testEqualsSameNumberButDifferentUrls() {
ReferralImpl refs0 = new ReferralImpl();
refs0.addLdapUrl("ldap://blah0");
refs0.addLdapUrl("ldap://blah1");
refs0.addLdapUrl("ldap://blah2");
refs0.addLdapUrl("ldap://blah3");
ReferralImpl refs1 = new ReferralImpl();
refs1.addLdapUrl("ldap://blah0");
refs1.addLdapUrl("ldap://blah1");
refs1.addLdapUrl("ldap://blah2");
refs1.addLdapUrl("ldap://blah4");
assertFalse("Referrals should not be equal", refs0.equals(refs1));
assertFalse("Referrals should not be equal", refs1.equals(refs0));
}
Aggregations