Search in sources :

Example 36 with Dsmlv2ResponseParser

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

the class BatchResponseTest method testResponseWith1ExtendedResponse.

/**
 * Test parsing of a Response with the 1 ExtendedResponse
 */
@Test
public void testResponseWith1ExtendedResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_1_ExtendedResponse.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchResponseDsml batchResponse = parser.getBatchResponse();
    assertEquals(1, batchResponse.getResponses().size());
    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
    if (response instanceof ExtendedResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) ExtendedResponse(org.apache.directory.api.ldap.model.message.ExtendedResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 37 with Dsmlv2ResponseParser

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

the class BatchResponseTest method testResponseWith2AuthResponse.

/**
 * Test parsing of a Response with the 2 AuthResponse
 */
@Test
public void testResponseWith2AuthResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_2_AuthResponse.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchResponseDsml batchResponse = parser.getBatchResponse();
    assertEquals(2, batchResponse.getResponses().size());
    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
    if (response instanceof BindResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) BindResponse(org.apache.directory.api.ldap.model.message.BindResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 38 with Dsmlv2ResponseParser

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

the class BatchResponseTest method testResponseWith1SearchResponse.

/**
 * Test parsing of a Response with the 1 SearchResponse
 */
@Test
public void testResponseWith1SearchResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_1_SearchResponse.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchResponseDsml batchResponse = parser.getBatchResponse();
    assertEquals(1, batchResponse.getResponses().size());
    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
    if (response.getDecorated() instanceof SearchResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) 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 39 with Dsmlv2ResponseParser

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

the class BatchResponseTest method testResponseWith2SearchResponse.

/**
 * Test parsing of a Response with the 2 SearchResponse
 */
@Test
public void testResponseWith2SearchResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_2_SearchResponse.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchResponseDsml batchResponse = parser.getBatchResponse();
    assertEquals(2, batchResponse.getResponses().size());
    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
    if (response.getDecorated() instanceof SearchResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) 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 40 with Dsmlv2ResponseParser

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

the class BatchResponseTest method testResponseWith1ErrorResponse.

/**
 * Test parsing of a Response with the 1 ErrorResponse
 */
@Test
public void testResponseWith1ErrorResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_1_ErrorResponse.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    BatchResponseDsml batchResponse = parser.getBatchResponse();
    assertEquals(1, batchResponse.getResponses().size());
    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
    if (response instanceof ErrorResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) ErrorResponse(org.apache.directory.api.dsmlv2.response.ErrorResponse) 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