Search in sources :

Example 11 with ReferralImpl

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));
}
Also used : Referral(org.apache.directory.api.ldap.model.message.Referral) ReferralImpl(org.apache.directory.api.ldap.model.message.ReferralImpl) Dn(org.apache.directory.api.ldap.model.name.Dn) LdapResultImpl(org.apache.directory.api.ldap.model.message.LdapResultImpl) Test(org.junit.Test)

Example 12 with ReferralImpl

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());
}
Also used : Referral(org.apache.directory.api.ldap.model.message.Referral) ReferralImpl(org.apache.directory.api.ldap.model.message.ReferralImpl) Dn(org.apache.directory.api.ldap.model.name.Dn) LdapResultImpl(org.apache.directory.api.ldap.model.message.LdapResultImpl) Test(org.junit.Test)

Example 13 with ReferralImpl

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());
}
Also used : ReferralImpl(org.apache.directory.api.ldap.model.message.ReferralImpl) Test(org.junit.Test)

Example 14 with ReferralImpl

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());
}
Also used : ReferralImpl(org.apache.directory.api.ldap.model.message.ReferralImpl) Test(org.junit.Test)

Example 15 with ReferralImpl

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));
}
Also used : ReferralImpl(org.apache.directory.api.ldap.model.message.ReferralImpl) Test(org.junit.Test)

Aggregations

ReferralImpl (org.apache.directory.api.ldap.model.message.ReferralImpl)19 Test (org.junit.Test)17 Referral (org.apache.directory.api.ldap.model.message.Referral)11 LdapResultImpl (org.apache.directory.api.ldap.model.message.LdapResultImpl)8 Dn (org.apache.directory.api.ldap.model.name.Dn)8 DecoderException (org.apache.directory.api.asn1.DecoderException)2 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)2 BindResponseImpl (org.apache.directory.api.ldap.model.message.BindResponseImpl)2 LdapURLEncodingException (org.apache.directory.api.ldap.model.exception.LdapURLEncodingException)1 LdapResult (org.apache.directory.api.ldap.model.message.LdapResult)1 ResultResponse (org.apache.directory.api.ldap.model.message.ResultResponse)1 SearchResultReference (org.apache.directory.api.ldap.model.message.SearchResultReference)1 LdapUrl (org.apache.directory.api.ldap.model.url.LdapUrl)1