Search in sources :

Example 36 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class LdapUrlTest method testLdapURLNoDNNoAttrsScopeNoFilterExtension.

/**
 * test a LdapUrl with no Dn, no attributes, a scope, no filter and some extensions
 */
@Test
public void testLdapURLNoDNNoAttrsScopeNoFilterExtension() throws LdapURLEncodingException {
    LdapUrl url = new LdapUrl("ldap://localhost:123/??sub??!a=b,!c");
    assertEquals("ldap://localhost:123/??sub??!a=b,!c", url.toString());
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Test(org.junit.Test)

Example 37 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class LdapUrlTest method testLdapURLNoDNNoAttrsScopeFilterExtension.

/**
 * test a LdapUrl with no Dn, no attributes, a scope, a filter and some extensions
 */
@Test
public void testLdapURLNoDNNoAttrsScopeFilterExtension() throws LdapURLEncodingException {
    LdapUrl url = new LdapUrl("ldap://localhost:123/??sub?(cn=test)?!a=b,!c");
    assertEquals("ldap://localhost:123/??sub?(cn=test)?!a=b,!c", url.toString());
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Test(org.junit.Test)

Example 38 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class LdapUrlTest method testDnSetDn.

/**
 * test the setDn() method
 */
@Test
public void testDnSetDn() throws LdapURLEncodingException, LdapInvalidDnException {
    LdapUrl url = new LdapUrl();
    assertNull(url.getDn());
    Dn dn = new Dn("dc=example,dc=com");
    url.setDn(dn);
    assertEquals(dn, url.getDn());
    assertEquals("ldap:///dc=example,dc=com", url.toString());
    url.setDn(null);
    assertNull(url.getDn());
    assertEquals("ldap:///", url.toString());
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Dn(org.apache.directory.api.ldap.model.name.Dn) Test(org.junit.Test)

Example 39 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class LdapUrlTest method testLdapURLExtensionOrder.

/**
 * Test the extension order of an LdapUrl.
 */
@Test
public void testLdapURLExtensionOrder() throws LdapURLEncodingException {
    LdapUrl url = new LdapUrl("ldap://localhost:123/????!a=b,!c,!x,d=e,f=g,!h=i");
    assertEquals("ldap://localhost:123/????!a=b,!c,!x,d=e,f=g,!h=i", url.toString());
    List<Extension> extensions = url.getExtensions();
    assertTrue(extensions.get(0).isCritical());
    assertEquals("a", extensions.get(0).getType());
    assertEquals("b", extensions.get(0).getValue());
    assertTrue(extensions.get(1).isCritical());
    assertEquals("c", extensions.get(1).getType());
    assertNull(extensions.get(1).getValue());
    assertTrue(extensions.get(2).isCritical());
    assertEquals("x", extensions.get(2).getType());
    assertNull(extensions.get(2).getValue());
    assertFalse(extensions.get(3).isCritical());
    assertEquals("d", extensions.get(3).getType());
    assertEquals("e", extensions.get(3).getValue());
    assertFalse(extensions.get(4).isCritical());
    assertEquals("f", extensions.get(4).getType());
    assertEquals("g", extensions.get(4).getValue());
    assertTrue(extensions.get(5).isCritical());
    assertEquals("h", extensions.get(5).getType());
    assertEquals("i", extensions.get(5).getValue());
}
Also used : Extension(org.apache.directory.api.ldap.model.url.LdapUrl.Extension) LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Test(org.junit.Test)

Example 40 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class LdapUrlTest method testLdapURLNoDNNoAttrsNoScopeNoFilterNoExtension.

/**
 * test a LdapUrl with no Dn, no attributes, no scope, no filter and no extension
 */
@Test
public void testLdapURLNoDNNoAttrsNoScopeNoFilterNoExtension() throws LdapURLEncodingException {
    LdapUrl url = new LdapUrl("ldap://localhost:123/????");
    assertEquals("ldap://localhost:123/", url.toString());
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Test(org.junit.Test)

Aggregations

LdapUrl (org.apache.directory.api.ldap.model.url.LdapUrl)98 Test (org.junit.Test)95 LdapURLEncodingException (org.apache.directory.api.ldap.model.exception.LdapURLEncodingException)27 AbstractResponseTest (org.apache.directory.api.dsmlv2.AbstractResponseTest)24 Dsmlv2ResponseParser (org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser)24 LdapResult (org.apache.directory.api.ldap.model.message.LdapResult)23 DecoderException (org.apache.directory.api.asn1.DecoderException)5 SearchResponse (org.apache.directory.api.dsmlv2.response.SearchResponse)5 Dn (org.apache.directory.api.ldap.model.name.Dn)5 Extension (org.apache.directory.api.ldap.model.url.LdapUrl.Extension)5 BindResponse (org.apache.directory.api.ldap.model.message.BindResponse)3 CompareResponse (org.apache.directory.api.ldap.model.message.CompareResponse)3 DeleteResponse (org.apache.directory.api.ldap.model.message.DeleteResponse)3 ExtendedResponse (org.apache.directory.api.ldap.model.message.ExtendedResponse)3 ModifyDnResponse (org.apache.directory.api.ldap.model.message.ModifyDnResponse)3 ModifyResponse (org.apache.directory.api.ldap.model.message.ModifyResponse)3 SearchResultDone (org.apache.directory.api.ldap.model.message.SearchResultDone)3 SearchResultReference (org.apache.directory.api.ldap.model.message.SearchResultReference)3 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)2 Referral (org.apache.directory.api.ldap.model.message.Referral)2