HttpUtil { public static String executeUrl(String httpMethod, String url, int timeout) throws IOException { return executeUrl(httpMethod, url, null, null, timeout); }  static String executeUrl(String httpMethod, String url, int timeout); static String executeUrl(String httpMethod, String url, InputStream content, String contentType, int timeout); static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content,
            String contentType, int timeout); static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content,
            String contentType, int timeout, String proxyHost, Integer proxyPort, String proxyUser,
            String proxyPassword, String nonProxyHosts); static HttpMethod createHttpMethod(String httpMethodString); static RawType downloadImage(String url); static RawType downloadImage(String url, int timeout); static RawType downloadImage(String url, boolean scanTypeInContent, long maxContentLength); static RawType downloadImage(String url, boolean scanTypeInContent, long maxContentLength, int timeout); static RawType downloadData(String url, String contentTypeRegex, boolean scanTypeInContent,
            long maxContentLength); static RawType downloadData(String url, String contentTypeRegex, boolean scanTypeInContent,
            long maxContentLength, int timeout); static String guessContentTypeFromData(byte[] data);  }
@Test public void baseTest() throws Exception { mockResponse(HttpStatus.OK_200); String result = HttpUtil.executeUrl("GET", URL, 500); assertEquals("Some content", result); verify(httpClientMock).newRequest(URL); verify(requestMock).method(HttpMethod.GET); verify(requestMock).timeout(500, TimeUnit.MILLISECONDS); verify(requestMock).send(); }
@Test public void testAuthentication() throws Exception { when(httpClientMock.newRequest("http: mockResponse(HttpStatus.OK_200); String result = HttpUtil.executeUrl("GET", "http: assertEquals("Some content", result); verify(requestMock).header(HttpHeader.AUTHORIZATION, "Basic am9objpkb2U="); }