use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser 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());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser 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());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser 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());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser 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());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser 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());
}
Aggregations