Search in sources :

Example 6 with BindResponseImpl

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

the class BindResponseImplTest method testNotEqualsNewWithDiffId.

/**
 * Tests to make sure newly created objects with same different id are not
 * equal.
 */
@Test
public void testNotEqualsNewWithDiffId() {
    BindResponseImpl resp0 = new BindResponseImpl(1);
    BindResponseImpl resp1 = new BindResponseImpl(2);
    assertFalse("different id objects should not be equal", resp0.equals(resp1));
    assertFalse("different id objects should not be equal", resp1.equals(resp0));
}
Also used : BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl) Test(org.junit.Test)

Example 7 with BindResponseImpl

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

the class BindResponseImplTest method testEqualsSameObj.

/**
 * Tests to make sure the same object returns true with equals().
 */
@Test
public void testEqualsSameObj() {
    BindResponseImpl resp = new BindResponseImpl(1);
    assertTrue("same object should be equal", resp.equals(resp));
}
Also used : BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl) Test(org.junit.Test)

Example 8 with BindResponseImpl

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

the class BindResponseImplTest method testNotEqualsNewWithDiffSaslCreds.

/**
 * Tests to make sure newly created objects with same different saslCreds
 * are not equal.
 */
@Test
public void testNotEqualsNewWithDiffSaslCreds() {
    BindResponseImpl resp0 = new BindResponseImpl(1);
    resp0.setServerSaslCreds(new byte[2]);
    BindResponseImpl resp1 = new BindResponseImpl(1);
    resp1.setServerSaslCreds(new byte[3]);
    assertFalse("different serverSaslCreds objects should not be equal", resp0.equals(resp1));
    assertFalse("different serverSaslCreds objects should not be equal", resp1.equals(resp0));
}
Also used : BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl) Test(org.junit.Test)

Example 9 with BindResponseImpl

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

the class BindResponseImplTest method testHashCodeNewWithSameId.

/**
 * Tests to make sure newly created objects with same id have the same hashCode.
 */
@Test
public void testHashCodeNewWithSameId() {
    BindResponseImpl resp0 = new BindResponseImpl(1);
    BindResponseImpl resp1 = new BindResponseImpl(1);
    assertTrue(resp1.hashCode() == resp0.hashCode());
}
Also used : BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl) Test(org.junit.Test)

Example 10 with BindResponseImpl

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

Aggregations

BindResponseImpl (org.apache.directory.api.ldap.model.message.BindResponseImpl)12 Test (org.junit.Test)10 ResponseCarryingException (org.apache.directory.api.ldap.codec.api.ResponseCarryingException)3 ByteBuffer (java.nio.ByteBuffer)2 DecoderException (org.apache.directory.api.asn1.DecoderException)2 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)2 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)2 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)2 BindRequest (org.apache.directory.api.ldap.model.message.BindRequest)2 LdapResultImpl (org.apache.directory.api.ldap.model.message.LdapResultImpl)2 Message (org.apache.directory.api.ldap.model.message.Message)2 Referral (org.apache.directory.api.ldap.model.message.Referral)2 ReferralImpl (org.apache.directory.api.ldap.model.message.ReferralImpl)2 Dn (org.apache.directory.api.ldap.model.name.Dn)2 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)1 MessageDecorator (org.apache.directory.api.ldap.codec.api.MessageDecorator)1 BindRequestDecorator (org.apache.directory.api.ldap.codec.decorators.BindRequestDecorator)1 BindResponseDecorator (org.apache.directory.api.ldap.codec.decorators.BindResponseDecorator)1