use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.
the class SearchResultDoneTest method testResponseWith2Referrals.
/**
* Test parsing of a response with 2 Referral elements
*/
@Test
public void testResponseWith2Referrals() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(SearchResultDoneTest.class.getResource("response_with_2_referrals.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(2, referrals.size());
try {
assertTrue(referrals.contains(new LdapUrl("ldap://www.apache.org/").toString()));
} catch (LdapURLEncodingException e) {
fail();
}
try {
assertTrue(referrals.contains(new LdapUrl("ldap://www.apple.com/").toString()));
} catch (LdapURLEncodingException e) {
fail();
}
}
use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.
the class SearchResultReferenceTest method testResponseWith1Ref.
/**
* Test parsing of a Response with 1 Ref
*/
@Test
public void testResponseWith1Ref() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(SearchResultReferenceTest.class.getResource("response_with_1_ref.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchResultReference searchResultReference = ((SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated()).getCurrentSearchResultReference();
Collection<String> references = searchResultReference.getReferral().getLdapUrls();
assertEquals(1, references.size());
try {
assertTrue(references.contains(new LdapUrl("ldap://localhost").toString()));
} catch (LdapURLEncodingException e) {
fail();
}
}
use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.
the class SearchResultReferenceTest method testResponseWith2Ref.
/**
* Test parsing of a Response with 2 Ref
*/
@Test
public void testResponseWith2Ref() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(SearchResultReferenceTest.class.getResource("response_with_2_ref.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchResultReference searchResultReference = ((SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated()).getCurrentSearchResultReference();
Collection<String> references = searchResultReference.getReferral().getLdapUrls();
assertEquals(2, references.size());
try {
assertTrue(references.contains(new LdapUrl("ldap://localhost").toString()));
} catch (LdapURLEncodingException e) {
fail();
}
try {
assertTrue(references.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 CompareResponseTest method testResponseWith1Referral.
/**
* Test parsing of a response with a Referral
*/
@Test
public void testResponseWith1Referral() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(CompareResponseTest.class.getResource("response_with_1_referral.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
CompareResponse compareResponse = (CompareResponse) parser.getBatchResponse().getCurrentResponse();
LdapResult ldapResult = compareResponse.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 CompareResponseTest 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(CompareResponseTest.class.getResource("response_with_1_referral_and_error_message.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
CompareResponse compareResponse = (CompareResponse) parser.getBatchResponse().getCurrentResponse();
LdapResult ldapResult = compareResponse.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();
}
}
Aggregations