Search in sources :

Example 1 with ReferralImpl

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));
}
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) BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl) LdapResultImpl(org.apache.directory.api.ldap.model.message.LdapResultImpl) Test(org.junit.Test)

Example 2 with ReferralImpl

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));
}
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 3 with ReferralImpl

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

Example 4 with ReferralImpl

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

Example 5 with ReferralImpl

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");
    }
}
Also used : ResultResponse(org.apache.directory.api.ldap.model.message.ResultResponse) DecoderException(org.apache.directory.api.asn1.DecoderException) LdapResult(org.apache.directory.api.ldap.model.message.LdapResult) Referral(org.apache.directory.api.ldap.model.message.Referral) ReferralImpl(org.apache.directory.api.ldap.model.message.ReferralImpl) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

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