use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class AbstractUnsecuredService_callWithRetryTest method testCallWithRetry_ioException_assertServiceException.
@Test
@SuppressWarnings("unchecked")
public void testCallWithRetry_ioException_assertServiceException() throws Exception {
HttpClient client = mock(HttpClient.class);
MockService svc = new MockService("http://localhost/mock", client);
ServiceRequest<Object, Exception> req = mock(ServiceRequest.class);
doThrow(new IOException("Pass through")).when(req).call();
boolean exceptionOccured = false;
try {
svc.mockCallNoReturn(req);
} catch (ServiceException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class UnsecuredServiceRequestBase method call.
/**
* {@inheritDoc}}
*/
@Override
public T call() throws E, IOException, ServiceException {
HttpUriRequest request = createRequest();
if (request == null)
throw new ServiceException("Could not create request object");
HttpResponse response = httpClient.execute(request);
try {
final int statusCode = response.getStatusLine().getStatusCode();
return interpretResponse(statusCode, response);
} finally {
closeConnection(response);
}
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class AbstractDeleteRequest method createRequest.
/**
* {@inheritDoc}
*/
@Override
protected final HttpUriRequest createRequest() throws IOException {
try {
HttpDelete delete = new HttpDelete(getRequestUri());
delete.setHeader("Accept", MediaType.APPLICATION_JSON);
return delete;
} catch (ServiceException e) {
throw new IOException("Error creating request URI.", e);
}
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class AbstractPostRequest method createRequest.
/**
* {@inheritDoc}
*/
@Override
protected final HttpUriRequest createRequest() throws IOException {
try {
HttpPost post = new HttpPost(getRequestUri());
post.setHeader("Accept", MediaType.APPLICATION_JSON);
return buildEntityRequest(post, makeContent(), MediaType.APPLICATION_JSON);
} catch (ServiceException e) {
throw new IOException("Error creating request URI.", e);
}
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class AbstractPutRequest method createRequest.
/**
* {@inheritDoc}
*/
@Override
protected HttpUriRequest createRequest() throws IOException {
try {
HttpPut post = new HttpPut(getRequestUri());
post.setHeader("Accept", MediaType.APPLICATION_JSON);
return buildEntityRequest(post, makeContent(), MediaType.APPLICATION_JSON);
} catch (ServiceException e) {
throw new IOException("Error creating request URI.", e);
}
}
Aggregations