Search in sources :

Example 56 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class BindRequestImplTest method testNotEqualDiffId.

/**
 * Test for inequality when only the IDs are different.
 */
@Test
public void testNotEqualDiffId() throws LdapException {
    BindRequestImpl req0 = new BindRequestImpl();
    req0.setMessageId(7);
    req0.setCredentials(PASSWORD);
    req0.setDn(new Dn("cn=admin,dc=example,dc=com"));
    req0.setSimple(true);
    req0.setVersion3(true);
    BindRequestImpl req1 = new BindRequestImpl();
    req1.setMessageId(5);
    req1.setCredentials(PASSWORD);
    req1.setDn(new Dn("cn=admin,dc=example,dc=com"));
    req1.setSimple(true);
    req1.setVersion3(true);
    assertFalse(req0.equals(req1));
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) Test(org.junit.Test)

Example 57 with Dn

use of org.apache.directory.api.ldap.model.name.Dn 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 58 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class CompareRequestImplTest method testNotEqualDiffAttributeIds.

/**
 * Test for inequality when only the attributeIds are different.
 */
@Test
public void testNotEqualDiffAttributeIds() throws LdapException {
    CompareRequestImpl req0 = new CompareRequestImpl();
    req0.setMessageId(5);
    req0.setName(new Dn("cn=admin,dc=apache,dc=org"));
    req0.setAttributeId("dc");
    req0.setAssertionValue("apache.org");
    CompareRequestImpl req1 = new CompareRequestImpl();
    req1.setMessageId(5);
    req1.setName(new Dn("cn=admin,dc=apache,dc=org"));
    req1.setAttributeId("nisDomain");
    req1.setAssertionValue("apache.org");
    assertFalse(req0.equals(req1));
    assertFalse(req1.equals(req0));
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) Test(org.junit.Test)

Example 59 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class CompareRequestImplTest method testNotEqualDiffValue.

/**
 * Test for inequality when only the Assertion values are different.
 */
@Test
public void testNotEqualDiffValue() throws LdapException {
    CompareRequestImpl req0 = new CompareRequestImpl();
    req0.setMessageId(5);
    req0.setName(new Dn("cn=admin,dc=apache,dc=org"));
    req0.setAttributeId("dc");
    req0.setAssertionValue("apache.org");
    CompareRequestImpl req1 = new CompareRequestImpl();
    req1.setMessageId(5);
    req1.setName(new Dn("cn=admin,dc=apache,dc=org"));
    req1.setAttributeId("dc");
    req1.setAssertionValue("nagoya.apache.org");
    assertFalse(req0.equals(req1));
    assertFalse(req1.equals(req0));
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) Test(org.junit.Test)

Example 60 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class CompareRequestImplTest method testEqualsExactCopy.

/**
 * Tests for equality using exact copies.
 */
@Test
public void testEqualsExactCopy() throws LdapException {
    CompareRequestImpl req0 = new CompareRequestImpl();
    req0.setMessageId(5);
    req0.setName(new Dn("cn=admin,dc=example,dc=com"));
    req0.setAttributeId("objectClass");
    req0.setAssertionValue("top");
    CompareRequestImpl req1 = new CompareRequestImpl();
    req1.setMessageId(5);
    req1.setName(new Dn("cn=admin,dc=example,dc=com"));
    req1.setAttributeId("objectClass");
    req1.setAssertionValue("top");
    assertTrue(req0.equals(req1));
    assertTrue(req1.equals(req0));
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) Test(org.junit.Test)

Aggregations

Dn (org.apache.directory.api.ldap.model.name.Dn)307 Test (org.junit.Test)183 Rdn (org.apache.directory.api.ldap.model.name.Rdn)63 LdifEntry (org.apache.directory.api.ldap.model.ldif.LdifEntry)50 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)39 Entry (org.apache.directory.api.ldap.model.entry.Entry)34 DnNode (org.apache.directory.api.ldap.util.tree.DnNode)30 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)20 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)19 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)17 Modification (org.apache.directory.api.ldap.model.entry.Modification)17 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)16 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)10 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)10 ModifyRequest (org.apache.directory.api.ldap.model.message.ModifyRequest)10 Referral (org.apache.directory.api.ldap.model.message.Referral)10 File (java.io.File)9 ArrayList (java.util.ArrayList)9 ResponseCarryingException (org.apache.directory.api.ldap.codec.api.ResponseCarryingException)8 Value (org.apache.directory.api.ldap.model.entry.Value)8