Search in sources :

Example 66 with Dsmlv2ResponseParser

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

the class SearchResponseTest method testResponseWithSRD.

/**
 * Test parsing of a Response with a Search Result Done
 */
@Test
public void testResponseWithSRD() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(SearchResponseTest.class.getResource("response_with_1_SRD.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    SearchResponse searchResponse = (SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated();
    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 67 with Dsmlv2ResponseParser

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

the class SearchResponseTest method testResponseWith0SRE1SRD.

/**
 * Test parsing of a Response with 1 Search Result Entry and a Search Result Done
 */
@Test
public void testResponseWith0SRE1SRD() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(SearchResponseTest.class.getResource("response_with_0_SRE_1_SRD.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    SearchResponse searchResponse = (SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated();
    assertEquals(0, 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 68 with Dsmlv2ResponseParser

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

the class SearchResponseTest method testResponseWith1SRE1SRR1SRD.

/**
 * Test parsing of a Response with 1 Search Result Entry, 1 Search Result Reference and a Search Result Done
 */
@Test
public void testResponseWith1SRE1SRR1SRD() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(SearchResponseTest.class.getResource("response_with_1_SRE_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.getSearchResultEntryList().size());
    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 69 with Dsmlv2ResponseParser

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

the class SearchResponseTest method testResponseWithRequestId.

/**
 * Test parsing of a Response with the (optional) requestID attribute
 */
@Test
public void testResponseWithRequestId() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(SearchResponseTest.class.getResource("response_with_requestID_attribute.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    SearchResponse searchResponse = (SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated();
    assertEquals(456, searchResponse.getMessageId());
}
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 70 with Dsmlv2ResponseParser

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

the class SearchResponseTest method testResponseWith1SRE1SRD.

/**
 * Test parsing of a Response with 1 Search Result Entry and a Search Result Done
 */
@Test
public void testResponseWith1SRE1SRD() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(SearchResponseTest.class.getResource("response_with_1_SRE_1_SRD.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    SearchResponse searchResponse = (SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated();
    assertEquals(1, 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)

Aggregations

Test (org.junit.Test)172 AbstractResponseTest (org.apache.directory.api.dsmlv2.AbstractResponseTest)171 Dsmlv2ResponseParser (org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser)171 LdapURLEncodingException (org.apache.directory.api.ldap.model.exception.LdapURLEncodingException)118 LdapResult (org.apache.directory.api.ldap.model.message.LdapResult)64 SearchResponse (org.apache.directory.api.dsmlv2.response.SearchResponse)44 DsmlControl (org.apache.directory.api.dsmlv2.DsmlControl)40 Control (org.apache.directory.api.ldap.model.message.Control)40 LdapUrl (org.apache.directory.api.ldap.model.url.LdapUrl)24 BatchResponseDsml (org.apache.directory.api.dsmlv2.response.BatchResponseDsml)21 DecoderException (org.apache.directory.api.asn1.DecoderException)19 ExtendedResponse (org.apache.directory.api.ldap.model.message.ExtendedResponse)17 AddResponse (org.apache.directory.api.ldap.model.message.AddResponse)15 BindResponse (org.apache.directory.api.ldap.model.message.BindResponse)15 CompareResponse (org.apache.directory.api.ldap.model.message.CompareResponse)15 DeleteResponse (org.apache.directory.api.ldap.model.message.DeleteResponse)15 ModifyDnResponse (org.apache.directory.api.ldap.model.message.ModifyDnResponse)15 ModifyResponse (org.apache.directory.api.ldap.model.message.ModifyResponse)15 ErrorResponse (org.apache.directory.api.dsmlv2.response.ErrorResponse)13 SearchResultDone (org.apache.directory.api.ldap.model.message.SearchResultDone)13