Search in sources :

Example 11 with BatchResponseDsml

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

the class BatchResponseTest method testResponseWith1ModifyResponse.

/**
 * Test parsing of a Response with the 1 ModifyResponse
 */
@Test
public void testResponseWith1ModifyResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_1_ModifyResponse.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 ModifyResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) ModifyResponse(org.apache.directory.api.ldap.model.message.ModifyResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 12 with BatchResponseDsml

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

the class BatchResponseTest method testResponseWith1AddResponse.

/**
 * Test parsing of a Response with the 1 AddResponse
 */
@Test
public void testResponseWith1AddResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_1_AddResponse.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 AddResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) AddResponse(org.apache.directory.api.ldap.model.message.AddResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 13 with BatchResponseDsml

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

the class BatchResponseTest method testResponseWith2ErrorResponse.

/**
 * Test parsing of a Response with the 2 ErrorResponse
 */
@Test
public void testResponseWith2ErrorResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_2_ErrorResponse.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 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)

Example 14 with BatchResponseDsml

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

the class BatchResponseTest method testResponseWith2DelResponse.

/**
 * Test parsing of a Response with the 2 DelResponse
 */
@Test
public void testResponseWith2DelResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_2_DelResponse.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 DeleteResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) DeleteResponse(org.apache.directory.api.ldap.model.message.DeleteResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 15 with BatchResponseDsml

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

the class BatchResponseTest method testResponseWith1ModDNResponse.

/**
 * Test parsing of a Response with the 1 ModDNResponse
 */
@Test
public void testResponseWith1ModDNResponse() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(BatchResponseTest.class.getResource("response_with_1_ModDNResponse.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 ModifyDnResponse) {
        assertTrue(true);
    } else {
        fail();
    }
}
Also used : BatchResponseDsml(org.apache.directory.api.dsmlv2.response.BatchResponseDsml) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) ModifyDnResponse(org.apache.directory.api.ldap.model.message.ModifyDnResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Aggregations

BatchResponseDsml (org.apache.directory.api.dsmlv2.response.BatchResponseDsml)21 Test (org.junit.Test)21 AbstractResponseTest (org.apache.directory.api.dsmlv2.AbstractResponseTest)20 Dsmlv2ResponseParser (org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser)20 ErrorResponse (org.apache.directory.api.dsmlv2.response.ErrorResponse)2 SearchResponse (org.apache.directory.api.dsmlv2.response.SearchResponse)2 AddResponse (org.apache.directory.api.ldap.model.message.AddResponse)2 BindResponse (org.apache.directory.api.ldap.model.message.BindResponse)2 CompareResponse (org.apache.directory.api.ldap.model.message.CompareResponse)2 DeleteResponse (org.apache.directory.api.ldap.model.message.DeleteResponse)2 ExtendedResponse (org.apache.directory.api.ldap.model.message.ExtendedResponse)2 ModifyDnResponse (org.apache.directory.api.ldap.model.message.ModifyDnResponse)2 ModifyResponse (org.apache.directory.api.ldap.model.message.ModifyResponse)2 BatchRequestTest (org.apache.directory.api.dsmlv2.batchRequest.BatchRequestTest)1 BatchResponseTest (org.apache.directory.api.dsmlv2.batchResponse.BatchResponseTest)1