Search in sources :

Example 1 with ErrorResponse

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

the class ErrorResponseTest method testResponseWithEmptyMessage.

/**
 * Test parsing of a response with empty Message
 */
@Test
public void testResponseWithEmptyMessage() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(ErrorResponseTest.class.getResource("response_with_empty_message.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ErrorResponse errorResponse = (ErrorResponse) parser.getBatchResponse().getCurrentResponse();
    assertNull(errorResponse.getMessage());
}
Also used : 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 2 with ErrorResponse

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

the class ErrorResponseTest method testResponseWithTypeMalformedRequest.

/**
 * Test parsing of a response with type == malformedRequest
 */
@Test
public void testResponseWithTypeMalformedRequest() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(ErrorResponseTest.class.getResource("response_with_type_malformedRequest.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ErrorResponse errorResponse = (ErrorResponse) parser.getBatchResponse().getCurrentResponse();
    assertEquals(ErrorResponseType.MALFORMED_REQUEST, errorResponse.getErrorType());
}
Also used : 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 3 with ErrorResponse

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

the class ErrorResponseTest method testResponseWithTypeGatewayInternalError.

/**
 * Test parsing of a response with type == gatewayInternalError
 */
@Test
public void testResponseWithTypeGatewayInternalError() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(ErrorResponseTest.class.getResource("response_with_type_gatewayInternalError.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ErrorResponse errorResponse = (ErrorResponse) parser.getBatchResponse().getCurrentResponse();
    assertEquals(ErrorResponseType.GATEWAY_INTERNAL_ERROR, errorResponse.getErrorType());
}
Also used : 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 4 with ErrorResponse

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

the class ErrorResponseTest method testResponseWithTypeOther.

/**
 * Test parsing of a response with type == other
 */
@Test
public void testResponseWithTypeOther() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(ErrorResponseTest.class.getResource("response_with_type_other.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ErrorResponse errorResponse = (ErrorResponse) parser.getBatchResponse().getCurrentResponse();
    assertEquals(ErrorResponseType.OTHER, errorResponse.getErrorType());
}
Also used : 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 5 with ErrorResponse

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

the class ErrorResponseTest 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(ErrorResponseTest.class.getResource("response_with_requestID_attribute.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ErrorResponse errorResponse = (ErrorResponse) parser.getBatchResponse().getCurrentResponse();
    assertEquals(456, errorResponse.getMessageId());
}
Also used : 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

ErrorResponse (org.apache.directory.api.dsmlv2.response.ErrorResponse)14 AbstractResponseTest (org.apache.directory.api.dsmlv2.AbstractResponseTest)13 Dsmlv2ResponseParser (org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser)13 Test (org.junit.Test)13 BatchResponseDsml (org.apache.directory.api.dsmlv2.response.BatchResponseDsml)2 BufferedWriter (java.io.BufferedWriter)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 DecoderException (org.apache.directory.api.asn1.DecoderException)1 EncoderException (org.apache.directory.api.asn1.EncoderException)1 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)1 Namespace (org.dom4j.Namespace)1 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)1