use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.
the class SearchResultDoneTest method testResponseWith1ReferralAndAnErrorMessage.
/**
* Test parsing of a response with a Referral and an Error Message
*/
@Test
public void testResponseWith1ReferralAndAnErrorMessage() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(SearchResultDoneTest.class.getResource("response_with_1_referral_and_error_message.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchResultDone searchResultDone = ((SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated()).getSearchResultDone();
LdapResult ldapResult = searchResultDone.getLdapResult();
Collection<String> referrals = ldapResult.getReferral().getLdapUrls();
assertEquals(1, referrals.size());
try {
assertTrue(referrals.contains(new LdapUrl("ldap://www.apache.org/").toString()));
} catch (LdapURLEncodingException e) {
fail();
}
}
use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.
the class LdapUrlTest method testLdapURLNoDNNoAttrs.
/**
* test a LdapUrl with no Dn and no attributes
*/
@Test
public void testLdapURLNoDNNoAttrs() throws LdapURLEncodingException {
LdapUrl url = new LdapUrl("ldap://localhost:123/?");
assertEquals("ldap://localhost:123/", url.toString());
}
use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.
the class LdapUrlTest method testLdapURLNoDNNoAttrsScopeFilter.
/**
* test a LdapUrl with no Dn, no attributes, a scope and filter
*/
@Test
public void testLdapURLNoDNNoAttrsScopeFilter() throws LdapURLEncodingException {
LdapUrl url = new LdapUrl("ldap://localhost:123/??sub?(cn=test)");
assertEquals("ldap://localhost:123/??sub?(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 testLdapURLDNAttrsScope.
/**
* test a LdapUrl with a Dn, some attributes an scope
*/
@Test
public void testLdapURLDNAttrsScope() throws LdapURLEncodingException {
LdapUrl url = new LdapUrl("ldap://localhost:123/ou=system?ou,cn?sub");
assertEquals("ldap://localhost:123/ou=system?ou,cn?sub", url.toString());
}
use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.
the class LdapUrlTest method testLdapURLNoDNNoAttrsScopeBaseFilterExtension.
/**
* test a LdapUrl with no Dn, no attributes, a base scope, a filter and some extensions
*/
@Test
public void testLdapURLNoDNNoAttrsScopeBaseFilterExtension() throws LdapURLEncodingException {
LdapUrl url = new LdapUrl("ldap://localhost:123/??base?(cn=test)?!a=b,!c");
assertEquals("ldap://localhost:123/???(cn=test)?!a=b,!c", url.toString());
}
Aggregations