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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations