ConverterUtil { protected static String extractHost(String hostname) { int index = hostname.lastIndexOf(':'); if (index != -1) { try { String port = hostname.substring(index + 1); if (NumberUtils.isDigits(port)) { hostname = hostname.substring(0, index); } } catch (Exception e) { LOG.error("Error parsing host"); } } return hostname; }  static HDWorkload convertScriptToHdWorkload(Script script); static HDWorkload convertWorkload(Workload workload, BaseJob job); static String getWorkloadXML(HDWorkload hdWorkload); static boolean isAssignment(RequestData data); static List<Header> getPostData(Set<RequestData> postData); static List<ResponseData> getResponseData(Set<RequestData> responseData); static List<Header> getResponseHeaders(Set<RequestData> responseHeaders, Set<RequestData> responseCookies); static List<Header> getRequestHeaders(Set<RequestData> headers, Set<RequestData> cookies); static boolean includedHeader(String header);  }
@Test public void testParseHost() { String hostname = "www.company.com"; String result = ConverterUtil.extractHost(hostname); assertEquals(hostname, result); hostname = "www.company.com:8080"; result = ConverterUtil.extractHost(hostname); assertEquals("www.company.com", result); hostname = "denis:angleton@www.company.com"; result = ConverterUtil.extractHost(hostname); assertEquals("denis:angleton@www.company.com", result); hostname = "denis:angleton@www.company.com:8080"; result = ConverterUtil.extractHost(hostname); assertEquals("denis:angleton@www.company.com", result); }