HTTPUtils { public static Map<String, List<String>> getHttpConnectionHeaderFields(HttpURLConnection httpConnection) throws IOException { return httpConnection.getHeaderFields(); }  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 testGetHttpConnectionHeaderFields() { if (!isServerReachable) { log.debug(server + " is not reachable. Skipping testGetHttpConnectionHeaderFields()"); return; } Map<String, List<String>> result = null; HttpURLConnection conn = null; try { conn = HTTPUtils.openHttpConnection(new URL("http: } catch (IOException ex) { Logger.getLogger(HTTPUtilsTest.class.getName()).log(Level.SEVERE, null, ex); } try { result = HTTPUtils.getHttpConnectionHeaderFields(HTTPUtils.openHttpConnection(new URL("http: } catch (IOException ex) { Logger.getLogger(HTTPUtilsTest.class.getName()).log(Level.SEVERE, null, ex); } assertFalse(result.isEmpty()); assertNotNull(result.get("Date")); conn.disconnect(); }