@Test public void timeoutInputStream() throws MalformedURLException, ODataClientException { thrown.expect(ODataClientTimeout.class); caller.getInputStream(emptyMap(), buildUrlToCall(HTTP_CLIENT_TIMEOUT)); }
@Override public InputStream getInputStream(Map<String, String> requestProperties, URL url) throws ODataClientException { LOG.debug("Preparing for getting an input stream by calling endpoint for given url: {}", url); try { RequestBuilder requestBuilder = RequestBuilder.get().setUri(url.toURI()); requestProperties.entrySet().stream() .forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue())); CloseableHttpResponse closeableResponse = closeableHttpClient.execute(requestBuilder.build()); if (closeableResponse.getStatusLine().getStatusCode() >= HTTP_BAD_REQUEST) { throw buildException(EntityUtils.toString(closeableResponse.getEntity(), "UTF-8"), closeableResponse.getStatusLine().getStatusCode()); } return closeableResponse.getEntity().getContent(); } catch (URISyntaxException e) { throw new ODataClientException(WRONG_URL_MESSAGE + url, e); } catch (IOException e) { throw new ODataClientRuntimeException(REQUEST_FAILED_MESSAGE + url, e); } }
TracingEndpointCaller implements EndpointCaller { @Override public InputStream getInputStream(Map<String, String> requestProperties, URL url) throws ODataClientException { LOG.debug("Preparing for getting an input stream by calling endpoint for given url: {}", url); try { RequestBuilder requestBuilder = RequestBuilder.get().setUri(url.toURI()); requestProperties.entrySet().stream() .forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue())); CloseableHttpResponse closeableResponse = closeableHttpClient.execute(requestBuilder.build()); if (closeableResponse.getStatusLine().getStatusCode() >= HTTP_BAD_REQUEST) { throw buildException(EntityUtils.toString(closeableResponse.getEntity(), "UTF-8"), closeableResponse.getStatusLine().getStatusCode()); } return closeableResponse.getEntity().getContent(); } catch (URISyntaxException e) { throw new ODataClientException(WRONG_URL_MESSAGE + url, e); } catch (IOException e) { throw new ODataClientRuntimeException(REQUEST_FAILED_MESSAGE + url, e); } } }
TracingEndpointCaller implements EndpointCaller { @Override public InputStream getInputStream(Map<String, String> requestProperties, URL url) throws ODataClientException { LOG.debug("Preparing for getting an input stream by calling endpoint for given url: {}", url); try { RequestBuilder requestBuilder = RequestBuilder.get().setUri(url.toURI()); requestProperties.entrySet().stream() .forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue())); CloseableHttpResponse closeableResponse = closeableHttpClient.execute(requestBuilder.build()); if (closeableResponse.getStatusLine().getStatusCode() >= HTTP_BAD_REQUEST) { throw buildException(EntityUtils.toString(closeableResponse.getEntity(), "UTF-8"), closeableResponse.getStatusLine().getStatusCode()); } return closeableResponse.getEntity().getContent(); } catch (URISyntaxException e) { throw new ODataClientException(WRONG_URL_MESSAGE + url, e); } catch (IOException e) { throw new ODataClientRuntimeException(REQUEST_FAILED_MESSAGE + url, e); } } TracingEndpointCaller(Properties properties); }
TracingEndpointCaller implements EndpointCaller { @Override public InputStream getInputStream(Map<String, String> requestProperties, URL url) throws ODataClientException { LOG.debug("Preparing for getting an input stream by calling endpoint for given url: {}", url); try { RequestBuilder requestBuilder = RequestBuilder.get().setUri(url.toURI()); requestProperties.entrySet().stream() .forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue())); CloseableHttpResponse closeableResponse = closeableHttpClient.execute(requestBuilder.build()); if (closeableResponse.getStatusLine().getStatusCode() >= HTTP_BAD_REQUEST) { throw buildException(EntityUtils.toString(closeableResponse.getEntity(), "UTF-8"), closeableResponse.getStatusLine().getStatusCode()); } return closeableResponse.getEntity().getContent(); } catch (URISyntaxException e) { throw new ODataClientException(WRONG_URL_MESSAGE + url, e); } catch (IOException e) { throw new ODataClientRuntimeException(REQUEST_FAILED_MESSAGE + url, e); } } TracingEndpointCaller(Properties properties); @Override String callEndpoint(Map<String, String> requestProperties, URL url); @Override InputStream getInputStream(Map<String, String> requestProperties, URL url); @Override String doPostEntity(Map<String, String> requestProperties, URL url, String body,
                               MediaType contentType, MediaType acceptType); @Override String doPutEntity(Map<String, String> requestProperties, URL url, String body, MediaType type); @Override void doDeleteEntity(Map<String, String> requestProperties, URL url); }
TracingEndpointCaller implements EndpointCaller { @Override public InputStream getInputStream(Map<String, String> requestProperties, URL url) throws ODataClientException { LOG.debug("Preparing for getting an input stream by calling endpoint for given url: {}", url); try { RequestBuilder requestBuilder = RequestBuilder.get().setUri(url.toURI()); requestProperties.entrySet().stream() .forEach(entry -> requestBuilder.addHeader(entry.getKey(), entry.getValue())); CloseableHttpResponse closeableResponse = closeableHttpClient.execute(requestBuilder.build()); if (closeableResponse.getStatusLine().getStatusCode() >= HTTP_BAD_REQUEST) { throw buildException(EntityUtils.toString(closeableResponse.getEntity(), "UTF-8"), closeableResponse.getStatusLine().getStatusCode()); } return closeableResponse.getEntity().getContent(); } catch (URISyntaxException e) { throw new ODataClientException(WRONG_URL_MESSAGE + url, e); } catch (IOException e) { throw new ODataClientRuntimeException(REQUEST_FAILED_MESSAGE + url, e); } } TracingEndpointCaller(Properties properties); @Override String callEndpoint(Map<String, String> requestProperties, URL url); @Override InputStream getInputStream(Map<String, String> requestProperties, URL url); @Override String doPostEntity(Map<String, String> requestProperties, URL url, String body,
                               MediaType contentType, MediaType acceptType); @Override String doPutEntity(Map<String, String> requestProperties, URL url, String body, MediaType type); @Override void doDeleteEntity(Map<String, String> requestProperties, URL url);  }