Search in sources :

Example 16 with ReferralImpl

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

Example 17 with ReferralImpl

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

Example 18 with ReferralImpl

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

Example 19 with ReferralImpl

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