Search in sources :

Example 11 with ErrorResponse

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

the class ErrorResponseTest method testResponseWithTypeNotAttempted.

/**
 * Test parsing of a response with type == notAttempted
 */
@Test
public void testResponseWithTypeNotAttempted() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(ErrorResponseTest.class.getResource("response_with_type_notAttempted.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ErrorResponse errorResponse = (ErrorResponse) parser.getBatchResponse().getCurrentResponse();
    assertEquals(ErrorResponseType.NOT_ATTEMPTED, 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 12 with ErrorResponse

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

the class ErrorResponseTest method testResponseWithMessage.

/**
 * Test parsing of a response with Message
 */
@Test
public void testResponseWithMessage() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(ErrorResponseTest.class.getResource("response_with_message.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ErrorResponse errorResponse = (ErrorResponse) parser.getBatchResponse().getCurrentResponse();
    assertEquals("Connection refused", 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 13 with ErrorResponse

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

the class ErrorResponseTest method testResponseWithTypeAuthenticationFailed.

/**
 * Test parsing of a response with type == authenticationFailed
 */
@Test
public void testResponseWithTypeAuthenticationFailed() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(ErrorResponseTest.class.getResource("response_with_type_authenticationFailed.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    ErrorResponse errorResponse = (ErrorResponse) parser.getBatchResponse().getCurrentResponse();
    assertEquals(ErrorResponseType.AUTHENTICATION_FAILED, 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 14 with ErrorResponse

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

the class ErrorResponseTest method testResponseWithTypeConnectionClosed.

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

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