use of com.ibm.watson.developer_cloud.service.exception.InternalServerErrorException in project java-sdk by watson-developer-cloud.
the class ErrorResponseTest method testInternalServerError.
/**
* Test HTTP status code 500 (InternalServerError) error response.
*/
@Test
public void testInternalServerError() {
String message = "The request failed because the moon is full.";
server.enqueue(new MockResponse().setResponseCode(500).addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{\"error\": \"" + message + "\"}"));
try {
GenericModel response = service.testMethod().execute();
} catch (Exception e) {
assertTrue(e instanceof InternalServerErrorException);
InternalServerErrorException ex = (InternalServerErrorException) e;
assertEquals(500, ex.getStatusCode());
assertEquals(message, ex.getMessage());
}
}
Aggregations