Java Code Examples for org.apache.directory.api.ldap.model.url.LdapUrl#setHost()
The following examples show how to use
org.apache.directory.api.ldap.model.url.LdapUrl#setHost() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LdapUrlTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * 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 }, StandardCharsets.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() ); }
Example 2
Source File: LdapUrlTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * 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() ); }
Example 3
Source File: LdapUrlTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * 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() ); }
Example 4
Source File: LdapUrlTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test comma in extension value. */ @Test public void testLdapURLExtensionWithCommaValue() 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", "," ) ); assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=%2c", url1.toString() ); LdapUrl url2 = new LdapUrl( "ldap://localhost:123/????X-CONNECTION-NAME=%2c" ); assertEquals( ",", url1.getExtensionValue( "X-CONNECTION-NAME" ) ); assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=%2c", url2.toString() ); }
Example 5
Source File: LdapUrlTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test with RFC 3986 reserved characters in extension value. * * reserved = gen-delims / sub-delims * gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" * / "*" / "+" / "," / ";" / "=" * * RFC 4516 specifies that '?' and a ',' must be percent encoded. * */ @Test public void testLdapURLExtensionWithRFC3986ReservedCharsAndRFC4616Exception() 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", ":/?#[]@!$&'()*+,;=" ) ); assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=:/%3F#[]@!$&'()*+%2c;=", url1.toString() ); LdapUrl url2 = new LdapUrl( "ldap://localhost:123/????X-CONNECTION-NAME=:/%3f#[]@!$&'()*+%2c;=" ); assertEquals( ":/?#[]@!$&'()*+,;=", url1.getExtensionValue( "X-CONNECTION-NAME" ) ); assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=:/%3F#[]@!$&'()*+%2c;=", url2.toString() ); }