use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.
the class LdapUrlTest method testLdapURLNoDNNoAttrsNoScopeNoFilterExtension.
/**
* test a LdapUrl with no Dn, no attributes, no scope, no filter and some extensions
*/
@Test
public void testLdapURLNoDNNoAttrsNoScopeNoFilterExtension() throws LdapURLEncodingException {
LdapUrl url = new LdapUrl("ldap://localhost:123/????!a=b,!c");
assertEquals("ldap://localhost:123/????!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 testLdapURLNoDNAttrsNoScopeFilterExtension.
/**
* test a LdapUrl with no Dn, some attributes, no scope, a filter and some extensions
*/
@Test
public void testLdapURLNoDNAttrsNoScopeFilterExtension() throws LdapURLEncodingException {
LdapUrl url = new LdapUrl("ldap://localhost:123/?cn,dc,ou??(cn=test)?!a=b,!c");
assertEquals("ldap://localhost:123/?cn,dc,ou??(cn=test)?!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 testLdapURLExtensionWithRFC3986UnreservedChars.
/**
* Test with RFC 3986 unreserved characters in extension value.
*
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
*/
@Test
public void testLdapURLExtensionWithRFC3986UnreservedChars() throws Exception {
LdapUrl url1 = new LdapUrl();
url1.setHost("localhost");
url1.setPort(123);
url1.setDn(Dn.EMPTY_DN);
url1.getExtensions().add(new Extension(false, "X-CONNECTION-NAME", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~"));
assertEquals("ldap://localhost:123/????X-CONNECTION-NAME=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", url1.toString());
LdapUrl url2 = new LdapUrl("ldap://localhost:123/????X-CONNECTION-NAME=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~");
assertEquals("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", url1.getExtensionValue("X-CONNECTION-NAME"));
assertEquals("ldap://localhost:123/????X-CONNECTION-NAME=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", url2.toString());
}
use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.
the class LdapUrlTest method testDnSetScope.
/**
* test the setScope() method
*/
@Test
public void testDnSetScope() throws LdapURLEncodingException, LdapInvalidDnException {
LdapUrl url = new LdapUrl();
assertEquals(SearchScope.OBJECT, url.getScope());
url.setDn(new Dn("dc=example,dc=com"));
url.setScope(SearchScope.ONELEVEL);
assertEquals(SearchScope.ONELEVEL, url.getScope());
assertEquals("ldap:///dc=example,dc=com??one", url.toString());
url.setScope(SearchScope.SUBTREE);
assertEquals(SearchScope.SUBTREE, url.getScope());
assertEquals("ldap:///dc=example,dc=com??sub", url.toString());
url.setScope(-1);
assertEquals(SearchScope.OBJECT, url.getScope());
assertEquals("ldap:///dc=example,dc=com", url.toString());
}
use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.
the class LdapUrlTest method testLdapURLNoDNAttrs.
/**
* test a LdapUrl with no Dn and attributes
*/
@Test
public void testLdapURLNoDNAttrs() throws LdapURLEncodingException {
LdapUrl url = new LdapUrl("ldap://localhost:123/?ou,dc,cn");
assertEquals("ldap://localhost:123/?ou,dc,cn", url.toString());
}
Aggregations