Search in sources :

Example 41 with LdapUrl

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

the class LdapUrlTest method testDnSetHost.

/**
 * test the setHost() method
 */
@Test
public void testDnSetHost() throws LdapURLEncodingException {
    LdapUrl url = new LdapUrl();
    assertNull(url.getHost());
    url.setHost("ldap.apache.org");
    assertEquals("ldap.apache.org", url.getHost());
    assertEquals("ldap://ldap.apache.org/", url.toString());
    url.setHost(null);
    assertNull(url.getHost());
    assertEquals("ldap:///", url.toString());
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Test(org.junit.Test)

Example 42 with LdapUrl

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

the class LdapUrlTest method testDnSetAttributes.

/**
 * test the setAttributes() method
 */
@Test
public void testDnSetAttributes() throws LdapURLEncodingException, LdapInvalidDnException {
    LdapUrl url = new LdapUrl();
    assertNotNull(url.getAttributes());
    assertTrue(url.getAttributes().isEmpty());
    List<String> attributes = new ArrayList<String>();
    url.setDn(new Dn("dc=example,dc=com"));
    url.setAttributes(null);
    assertNotNull(url.getAttributes());
    assertTrue(url.getAttributes().isEmpty());
    assertEquals("ldap:///dc=example,dc=com", url.toString());
    attributes.add("cn");
    url.setAttributes(attributes);
    assertNotNull(url.getAttributes());
    assertEquals(1, url.getAttributes().size());
    assertEquals("ldap:///dc=example,dc=com?cn", url.toString());
    attributes.add("userPassword;binary");
    url.setAttributes(attributes);
    assertNotNull(url.getAttributes());
    assertEquals(2, url.getAttributes().size());
    assertEquals("ldap:///dc=example,dc=com?cn,userPassword;binary", url.toString());
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) ArrayList(java.util.ArrayList) Dn(org.apache.directory.api.ldap.model.name.Dn) Test(org.junit.Test)

Example 43 with LdapUrl

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

the class LdapUrlTest method testLdapURLNoDNAttrsScopeBaseFilter.

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

Example 44 with LdapUrl

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

the class LdapUrlTest method testLdapURLNoDNAttrsNoScopeNoFilterExtension.

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

Example 45 with LdapUrl

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

the class LdapUrlTest method testLdapURLNoDNNoAttrsNoScope.

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