use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class ReferralImplTest method testEqualsExactCopy.
/**
* Tests to make sure the equals method works for two objects that are the
* same exact copy of one another.
*/
@Test
public void testEqualsExactCopy() {
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("exact copies of Referrals should be equal", refs0.equals(refs1));
assertTrue("exact copies of Referrals should be equal", refs1.equals(refs0));
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class ReferralImplTest method testEqualsSubset.
/**
* Tests to make sure the equals method works for two objects that are the
* not exact copies of one another and one has a subset of the urls of the
* other.
*/
@Test
public void testEqualsSubset() {
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");
assertFalse("Referrals should not be equal", refs0.equals(refs1));
assertFalse("Referrals should not be equal", refs1.equals(refs0));
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class ReferralImplTest method testEqualsExactCopyWithRedundancy.
/**
* Tests to make sure the equals method works for two objects that are the
* same exact copy of one another but there are redundant entries.
*/
@Test
public void testEqualsExactCopyWithRedundancy() {
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("exact copies of Referrals should be equal", refs0.equals(refs1));
assertTrue("exact copies of Referrals should be equal", refs1.equals(refs0));
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class ReferralImplTest method testEqualsDifferentImpls.
@Test
public void testEqualsDifferentImpls() {
Referral refs0 = new Referral() {
public Collection<String> getLdapUrls() {
return Collections.emptyList();
}
public void addLdapUrl(String url) {
}
public void removeLdapUrl(String url) {
}
public void addLdapUrlBytes(byte[] urlBytes) {
}
public Collection<byte[]> getLdapUrlsBytes() {
return null;
}
public int getReferralLength() {
return 0;
}
public void setReferralLength(int referralLength) {
}
};
ReferralImpl refs1 = new ReferralImpl();
assertFalse("Object.equals() in effect because we did not redefine " + " equals for the new impl above", refs0.equals(refs1));
assertTrue("Empty Referrals should be equal even if they are different" + " implementation classes", refs1.equals(refs0));
}
Aggregations