Search in sources :

Example 56 with LdapUrl

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

the class LdapUrlTest method testLdapURLNoDNAttrsScopeFilter.

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

Example 57 with LdapUrl

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

the class LdapUrlTest method testLdapURLDNNoAttrsNoScopeFilterExtension.

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

Example 58 with LdapUrl

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

the class LdapUrlTest method testLdapURLNoDNNoAttrsDefaultScope.

/**
 * test a LdapUrl with no Dn, no attributes an default scope
 */
@Test
public void testLdapURLNoDNNoAttrsDefaultScope() 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)

Example 59 with LdapUrl

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

the class LdapUrlTest method testLdapURLNoDNAttrsScopeNoFilterExtension.

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

Example 60 with LdapUrl

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

the class LdapUrlTest method testLdapURLExtensionWithUtf8Values.

/**
 * Test UTF-8 values in extension values.
 */
@Test
public void testLdapURLExtensionWithUtf8Values() throws Exception {
    String germanChars = new String(new byte[] { (byte) 0xC3, (byte) 0x84, (byte) 0xC3, (byte) 0x96, (byte) 0xC3, (byte) 0x9C, (byte) 0xC3, (byte) 0x9F, (byte) 0xC3, (byte) 0xA4, (byte) 0xC3, (byte) 0xB6, (byte) 0xC3, (byte) 0xBC }, "UTF-8");
    LdapUrl url1 = new LdapUrl();
    url1.setHost("localhost");
    url1.setPort(123);
    url1.setDn(Dn.EMPTY_DN);
    url1.getExtensions().add(new Extension(false, "X-CONNECTION-NAME", germanChars));
    assertEquals("ldap://localhost:123/????X-CONNECTION-NAME=%C3%84%C3%96%C3%9C%C3%9F%C3%A4%C3%B6%C3%BC", url1.toString());
    LdapUrl url2 = new LdapUrl("ldap://localhost:123/????X-CONNECTION-NAME=%c3%84%c3%96%c3%9c%c3%9f%c3%a4%c3%b6%c3%bc");
    assertEquals(germanChars, url1.getExtensionValue("X-CONNECTION-NAME"));
    assertEquals("ldap://localhost:123/????X-CONNECTION-NAME=%C3%84%C3%96%C3%9C%C3%9F%C3%A4%C3%B6%C3%BC", url2.toString());
}
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)

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