use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser in project directory-ldap-api by apache.
the class SearchResponseTest method testResponseWith2SRR1SRD.
/**
* Test parsing of a Response with 2 Search Result Reference and a Search Result Done
*/
@Test
public void testResponseWith2SRR1SRD() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(SearchResponseTest.class.getResource("response_with_2_SRR_1_SRD.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchResponse searchResponse = (SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated();
assertEquals(2, searchResponse.getSearchResultReferenceList().size());
assertNotNull(searchResponse.getSearchResultDone());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser in project directory-ldap-api by apache.
the class SearchResponseTest method testResponseWith2SRE1SRD.
/**
* Test parsing of a Response with 2 Search Result Entry and a Search Result Done
*/
@Test
public void testResponseWith2SRE1SRD() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(SearchResponseTest.class.getResource("response_with_2_SRE_1_SRD.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchResponse searchResponse = (SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated();
assertEquals(2, searchResponse.getSearchResultEntryList().size());
assertNotNull(searchResponse.getSearchResultDone());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser in project directory-ldap-api by apache.
the class SearchResultDoneTest method testResponseWithMatchedDNAttribute.
/**
* Test parsing of a response with MatchedDN attribute
*/
@Test
public void testResponseWithMatchedDNAttribute() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(SearchResultDoneTest.class.getResource("response_with_matchedDN_attribute.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchResultDone searchResultDone = ((SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated()).getSearchResultDone();
LdapResult ldapResult = searchResultDone.getLdapResult();
assertTrue(ldapResult.getMatchedDn().equals("cn=Bob Rush,ou=Dev,dc=Example,dc=COM"));
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser in project directory-ldap-api by apache.
the class SearchResultDoneTest method testResponseWithResultCode.
/**
* Test parsing of a response with Result Code
*/
@Test
public void testResponseWithResultCode() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(SearchResultDoneTest.class.getResource("response_with_result_code.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchResultDone searchResultDone = ((SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated()).getSearchResultDone();
LdapResult ldapResult = searchResultDone.getLdapResult();
assertEquals(ResultCodeEnum.PROTOCOL_ERROR, ldapResult.getResultCode());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser in project directory-ldap-api by apache.
the class SearchResultDoneTest method testResponseWithEmptyErrorMessage.
/**
* Test parsing of a response with empty Error Message
*/
@Test
public void testResponseWithEmptyErrorMessage() {
Dsmlv2ResponseParser parser = null;
try {
parser = new Dsmlv2ResponseParser(getCodec());
parser.setInput(SearchResultDoneTest.class.getResource("response_with_empty_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();
assertNull(ldapResult.getDiagnosticMessage());
}
Aggregations