HTTPUtils { public static InputStream sendPacket(URL url, String requestMethod) throws IOException { HttpURLConnection httpConnection = openHttpConnection(url, requestMethod); return getHttpConnectionInputStream(httpConnection); }  static InputStream sendPacket(URL url, String requestMethod); static String getStringFromInputStream(InputStream is); static HttpURLConnection openHttpConnection(final URL url, final HTTPConnectionMethods httpConnectionMethod); static HttpURLConnection openHttpConnection(URL url, String requestMethod); static InputStream getHttpConnectionInputStream(HttpURLConnection httpConnection); static Map<String, List<String>> getHttpConnectionHeaderFields(HttpURLConnection httpConnection);  }
@Test public void testSendPacket() { if (!isServerReachable) { log.debug(server + " is not reachable. Skipping testSendPacket()"); return; } InputStream result = null; try { result = HTTPUtils.sendPacket(new URL("http: assertTrue(result.read() > -1); } catch (IOException ex) { Logger.getLogger(HTTPUtilsTest.class.getName()).log(Level.SEVERE, null, ex); } try { result.close(); } catch (IOException ex) { Logger.getLogger(HTTPUtilsTest.class.getName()).log(Level.SEVERE, null, ex); } }