Search in sources :

Example 26 with SearchResponse

use of org.apache.directory.api.dsmlv2.response.SearchResponse in project directory-ldap-api by apache.

the class SearchResponseTest method testResponseWith2SRE2SRR1SRD.

/**
 * Test parsing of a Response with 2 Search Result Entry, 2 Search Result Reference and a Search Result Done
 */
@Test
public void testResponseWith2SRE2SRR1SRD() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(SearchResponseTest.class.getResource("response_with_2_SRE_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.getSearchResultEntryList().size());
    assertEquals(2, searchResponse.getSearchResultReferenceList().size());
    assertNotNull(searchResponse.getSearchResultDone());
}
Also used : Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) SearchResponse(org.apache.directory.api.dsmlv2.response.SearchResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 27 with SearchResponse

use of org.apache.directory.api.dsmlv2.response.SearchResponse in project directory-ldap-api by apache.

the class SearchResponseTest method testResponseWith1SRR1SRD.

/**
 * Test parsing of a Response with 1 Search Result Reference and a Search Result Done
 */
@Test
public void testResponseWith1SRR1SRD() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(SearchResponseTest.class.getResource("response_with_1_SRR_1_SRD.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    SearchResponse searchResponse = (SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated();
    assertEquals(1, searchResponse.getSearchResultReferenceList().size());
    assertNotNull(searchResponse.getSearchResultDone());
}
Also used : Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) SearchResponse(org.apache.directory.api.dsmlv2.response.SearchResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 28 with SearchResponse

use of org.apache.directory.api.dsmlv2.response.SearchResponse 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());
}
Also used : Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) SearchResponse(org.apache.directory.api.dsmlv2.response.SearchResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 29 with SearchResponse

use of org.apache.directory.api.dsmlv2.response.SearchResponse 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());
}
Also used : Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) SearchResponse(org.apache.directory.api.dsmlv2.response.SearchResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 30 with SearchResponse

use of org.apache.directory.api.dsmlv2.response.SearchResponse 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"));
}
Also used : Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) LdapResult(org.apache.directory.api.ldap.model.message.LdapResult) SearchResultDone(org.apache.directory.api.ldap.model.message.SearchResultDone) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) SearchResponse(org.apache.directory.api.dsmlv2.response.SearchResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Aggregations

AbstractResponseTest (org.apache.directory.api.dsmlv2.AbstractResponseTest)44 Dsmlv2ResponseParser (org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser)44 SearchResponse (org.apache.directory.api.dsmlv2.response.SearchResponse)44 Test (org.junit.Test)44 LdapURLEncodingException (org.apache.directory.api.ldap.model.exception.LdapURLEncodingException)21 SearchResultDone (org.apache.directory.api.ldap.model.message.SearchResultDone)14 SearchResultEntry (org.apache.directory.api.ldap.model.message.SearchResultEntry)13 DsmlControl (org.apache.directory.api.dsmlv2.DsmlControl)12 Control (org.apache.directory.api.ldap.model.message.Control)12 SearchResultReference (org.apache.directory.api.ldap.model.message.SearchResultReference)9 LdapResult (org.apache.directory.api.ldap.model.message.LdapResult)8 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)6 Entry (org.apache.directory.api.ldap.model.entry.Entry)6 Value (org.apache.directory.api.ldap.model.entry.Value)5 LdapUrl (org.apache.directory.api.ldap.model.url.LdapUrl)5 BatchResponseDsml (org.apache.directory.api.dsmlv2.response.BatchResponseDsml)2 SearchResponseDsml (org.apache.directory.api.dsmlv2.response.SearchResponseDsml)2 AddResponseDsml (org.apache.directory.api.dsmlv2.response.AddResponseDsml)1 BindResponseDsml (org.apache.directory.api.dsmlv2.response.BindResponseDsml)1 CompareResponseDsml (org.apache.directory.api.dsmlv2.response.CompareResponseDsml)1