BotsHttpClient extends CloseableHttpClient { @Override public CloseableHttpResponse execute(HttpUriRequest request) throws IOException, ClientProtocolException { HttpRequestWrapper wrap = HttpRequestWrapper.wrap(request); adviseRobotsTxt(wrap.getURI()); wrap.setURI(applyPHP(wrap.getURI())); return client.execute(wrap); } BotsHttpClient(CloseableHttpClient client, Bots bots);  BotsHttpClient(Bots bots); @Override HttpParams getParams(); @Override ClientConnectionManager getConnectionManager(); @Override CloseableHttpResponse execute(HttpUriRequest request); @Override CloseableHttpResponse execute(HttpUriRequest request, HttpContext context); @Override CloseableHttpResponse execute(HttpHost target, HttpRequest request); @Override CloseableHttpResponse execute(HttpHost target, HttpRequest request, HttpContext context); @Override T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler); @Override T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context); @Override T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler); @Override T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context); @Override void close();  }
@Test(expected = IOException.class) public void testAccessDenied() throws IOException { Bots bots = BotsUtils.readBots("http: BotsHttpClient client = new BotsHttpClient(bots); HttpGet request = new HttpGet("http: client.execute(request); }
@Test public void testAccessGrandted() throws IOException { Bots bots = BotsUtils.readBots("http: BotsHttpClient client = new BotsHttpClient(bots); HttpGet request = new HttpGet("http: HttpResponse response = client.execute(request); assertNotNull("No response", response); try (InputStream input = response.getEntity().getContent()) { String content = IOUtils.toString(input, "UTF-8"); assertEquals(content, "some data"); } }