HttpUtils { public static String readUrl(URL url, String charsetName) throws IOException { Assert.assertNotNull(url, charsetName); BufferedReader reader = null; try { HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); reader = new BufferedReader(new InputStreamReader( connection.getInputStream(), Charset.forName(charsetName))); StringBuilder stringBuilder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { stringBuilder.append(line); } return stringBuilder.toString(); } finally { try { if (reader != null) reader.close(); } catch (IOException e) { Log.error("Failed to close reader", e); } } } private  HttpUtils(); static String readUrl(URL url, String charsetName); static URI appendTrailingSlash(URI uri); static URI getSanitizedPath(UriInfo uriInfo); static URI getDirectoryURI(UriInfo uriInfo);  }
@Test(expected = NullPointerException.class) public void testHttpJsonReaderWithNullUrl() throws IOException { HttpUtils.readUrl(null, null); }
@Test() public void testGetJSON() throws IOException { HttpUtils.readUrl(new URL(testUrl), "UTF-8"); }