Search in sources :

Example 16 with Referral

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

the class LdapResultImplTest method testNotEqualsDiffMatchedDn.

/**
 * Tests for inequality when the matchedDn properties are not the same.
 */
@Test
public void testNotEqualsDiffMatchedDn() 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=apache,dc=org"));
    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 matchedDn properties " + "should not be equal", r0.equals(r1));
    assertFalse("results with different matchedDn properties " + "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 17 with Referral

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

the class LdapResultImplTest method testEqualsCarbonCopy.

/**
 * Tests two non default carbon copies for equality.
 */
@Test
public void testEqualsCarbonCopy() 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("exact copy should be equal", r0.equals(r1));
    assertTrue("exact copy should 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 18 with Referral

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

the class LdapResultImplTest method testNotEqualsDiffResultCode.

/**
 * Tests for inequality when the resultCode properties are not the same.
 */
@Test
public void testNotEqualsDiffResultCode() 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.SIZE_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 result codes should not be equal", r0.equals(r1));
    assertFalse("results with different result codes 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 19 with Referral

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

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

Aggregations

Referral (org.apache.directory.api.ldap.model.message.Referral)23 Test (org.junit.Test)16 ReferralImpl (org.apache.directory.api.ldap.model.message.ReferralImpl)11 Dn (org.apache.directory.api.ldap.model.name.Dn)10 DecoderException (org.apache.directory.api.asn1.DecoderException)9 LdapResultImpl (org.apache.directory.api.ldap.model.message.LdapResultImpl)9 EncoderException (org.apache.directory.api.asn1.EncoderException)8 ByteBuffer (java.nio.ByteBuffer)6 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)6 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)6 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)6 SearchResultReference (org.apache.directory.api.ldap.model.message.SearchResultReference)5 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)3 AddResponseDecorator (org.apache.directory.api.ldap.codec.decorators.AddResponseDecorator)3 SearchResultReferenceDecorator (org.apache.directory.api.ldap.codec.decorators.SearchResultReferenceDecorator)3 AddResponse (org.apache.directory.api.ldap.model.message.AddResponse)3 LdapResult (org.apache.directory.api.ldap.model.message.LdapResult)3 BufferOverflowException (java.nio.BufferOverflowException)2 HashSet (java.util.HashSet)2 LdapURLEncodingException (org.apache.directory.api.ldap.model.exception.LdapURLEncodingException)2