@Test public void testProxy() throws Exception { assertEquals(0, this.mocker.getComponentUnderTest().check("http: assertTrue("The HTTP server was not called by the link checker", findAll(allRequests()).isEmpty()); System.setProperty("http.proxyHost", "localhost"); System.setProperty("http.proxyPort", "8888"); assertEquals(404, this.mocker.getComponentUnderTest().check("http: assertFalse("The HTTP server was called by the link checker", findAll(allRequests()).isEmpty()); }
@Override public int check(String url) { int responseCode; CloseableHttpResponse httpResponse = null; try { HttpGet httpGet = new HttpGet(url); httpResponse = this.httpClient.execute(httpGet); responseCode = httpResponse.getStatusLine().getStatusCode(); this.logger.debug("Result of pinging [{}]: code = [{}]", url, responseCode); } catch (Exception e) { responseCode = 0; this.logger.debug("Error while checking [{}]", url, e); } finally { if (httpResponse != null) { try { httpResponse.close(); } catch (Exception ee) { this.logger.error("Failed to close HTTP connection for [{}]", url, ee); } } } return responseCode; }
DefaultHTTPChecker implements HTTPChecker, Initializable { @Override public int check(String url) { int responseCode; CloseableHttpResponse httpResponse = null; try { HttpGet httpGet = new HttpGet(url); httpResponse = this.httpClient.execute(httpGet); responseCode = httpResponse.getStatusLine().getStatusCode(); this.logger.debug("Result of pinging [{}]: code = [{}]", url, responseCode); } catch (Exception e) { responseCode = 0; this.logger.debug("Error while checking [{}]", url, e); } finally { if (httpResponse != null) { try { httpResponse.close(); } catch (Exception ee) { this.logger.error("Failed to close HTTP connection for [{}]", url, ee); } } } return responseCode; } }
DefaultHTTPChecker implements HTTPChecker, Initializable { @Override public int check(String url) { int responseCode; CloseableHttpResponse httpResponse = null; try { HttpGet httpGet = new HttpGet(url); httpResponse = this.httpClient.execute(httpGet); responseCode = httpResponse.getStatusLine().getStatusCode(); this.logger.debug("Result of pinging [{}]: code = [{}]", url, responseCode); } catch (Exception e) { responseCode = 0; this.logger.debug("Error while checking [{}]", url, e); } finally { if (httpResponse != null) { try { httpResponse.close(); } catch (Exception ee) { this.logger.error("Failed to close HTTP connection for [{}]", url, ee); } } } return responseCode; }  }
DefaultHTTPChecker implements HTTPChecker, Initializable { @Override public int check(String url) { int responseCode; CloseableHttpResponse httpResponse = null; try { HttpGet httpGet = new HttpGet(url); httpResponse = this.httpClient.execute(httpGet); responseCode = httpResponse.getStatusLine().getStatusCode(); this.logger.debug("Result of pinging [{}]: code = [{}]", url, responseCode); } catch (Exception e) { responseCode = 0; this.logger.debug("Error while checking [{}]", url, e); } finally { if (httpResponse != null) { try { httpResponse.close(); } catch (Exception ee) { this.logger.error("Failed to close HTTP connection for [{}]", url, ee); } } } return responseCode; }  @Override void initialize(); @Override int check(String url); }
DefaultHTTPChecker implements HTTPChecker, Initializable { @Override public int check(String url) { int responseCode; CloseableHttpResponse httpResponse = null; try { HttpGet httpGet = new HttpGet(url); httpResponse = this.httpClient.execute(httpGet); responseCode = httpResponse.getStatusLine().getStatusCode(); this.logger.debug("Result of pinging [{}]: code = [{}]", url, responseCode); } catch (Exception e) { responseCode = 0; this.logger.debug("Error while checking [{}]", url, e); } finally { if (httpResponse != null) { try { httpResponse.close(); } catch (Exception ee) { this.logger.error("Failed to close HTTP connection for [{}]", url, ee); } } } return responseCode; }  @Override void initialize(); @Override int check(String url);  }