HttpRequest { public static JSONObject executeGet(String restUrl, String username, String password) throws Exception { HttpGet get; JSONObject result = new JSONObject(); CloseableHttpResponse response = null; try { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost post = new HttpPost(restUrl); String auth=new StringBuffer(username).append(":").append(password).toString(); byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII"))); String authHeader = "Basic " + new String(encodedAuth); post.addHeader("Authorization", authHeader); post.addHeader("Content-Type", "application/json"); response = httpclient.execute(post); BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); StringBuffer res = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { res.append(line); } result = new JSONObject(res.toString()); } catch (IOException e) { LOG.debug("Failed to execute http get request ", e); } finally { if(response !=null)response.close(); } return result; }  static JSONObject executeGet(String restUrl, String username, String password);  }
@Test public void TestExecuteGet() throws Exception { }