Search in sources :

Example 1 with LdapResultImpl

use of org.apache.directory.api.ldap.model.message.LdapResultImpl 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 LdapResultImpl

use of org.apache.directory.api.ldap.model.message.LdapResultImpl 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 LdapResultImpl

use of org.apache.directory.api.ldap.model.message.LdapResultImpl in project directory-ldap-api by apache.

the class LdapResultImplTest method testEqualsDiffImpl.

/**
 * Tests for equality when the lockable parent is the same.
 */
@Test
public void testEqualsDiffImpl() {
    LdapResultImpl r0 = new LdapResultImpl();
    LdapResult r1 = new LdapResult() {

        public ResultCodeEnum getResultCode() {
            return ResultCodeEnum.SUCCESS;
        }

        public void setResultCode(ResultCodeEnum a_resultCode) {
        }

        public Dn getMatchedDn() {
            return null;
        }

        public void setMatchedDn(Dn dn) {
        }

        public String getDiagnosticMessage() {
            return null;
        }

        public void setDiagnosticMessage(String diagnosticMessage) {
        }

        public boolean isReferral() {
            return false;
        }

        public Referral getReferral() {
            return null;
        }

        public void setReferral(Referral referral) {
        }

        public boolean isDefaultSuccess() {
            return false;
        }
    };
    assertTrue("r0 equals should see other impl r1 as equal", r0.equals(r1));
    assertFalse("r1 impl uses Object.equals() so it should not see " + "r0 as the same object", r1.equals(r0));
}
Also used : LdapResult(org.apache.directory.api.ldap.model.message.LdapResult) Referral(org.apache.directory.api.ldap.model.message.Referral) Dn(org.apache.directory.api.ldap.model.name.Dn) LdapResultImpl(org.apache.directory.api.ldap.model.message.LdapResultImpl) ResultCodeEnum(org.apache.directory.api.ldap.model.message.ResultCodeEnum) Test(org.junit.Test)

Example 4 with LdapResultImpl

use of org.apache.directory.api.ldap.model.message.LdapResultImpl in project directory-ldap-api by apache.

the class BindResponseImplTest method testHashCodeWithTheWorks.

/**
 * Tests for equal hashCode of two fully loaded identical BindResponse PDUs.
 */
@Test
public void testHashCodeWithTheWorks() 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(resp0.hashCode() == resp1.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) BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl) LdapResultImpl(org.apache.directory.api.ldap.model.message.LdapResultImpl) Test(org.junit.Test)

Example 5 with LdapResultImpl

use of org.apache.directory.api.ldap.model.message.LdapResultImpl in project directory-ldap-api by apache.

the class LdapResultImplTest method testHashCodeSameObj.

/**
 * Tests to make sure the two same objects have equal HashCode.
 */
@Test
public void testHashCodeSameObj() {
    LdapResultImpl r0 = new LdapResultImpl();
    assertTrue(r0.hashCode() == r0.hashCode());
}
Also used : LdapResultImpl(org.apache.directory.api.ldap.model.message.LdapResultImpl) Test(org.junit.Test)

Aggregations

LdapResultImpl (org.apache.directory.api.ldap.model.message.LdapResultImpl)15 Test (org.junit.Test)15 Referral (org.apache.directory.api.ldap.model.message.Referral)9 Dn (org.apache.directory.api.ldap.model.name.Dn)9 ReferralImpl (org.apache.directory.api.ldap.model.message.ReferralImpl)8 BindResponseImpl (org.apache.directory.api.ldap.model.message.BindResponseImpl)2 LdapResult (org.apache.directory.api.ldap.model.message.LdapResult)1 ResultCodeEnum (org.apache.directory.api.ldap.model.message.ResultCodeEnum)1