ConverterUtil { protected static String extractPort(String hostname) { int index = hostname.lastIndexOf(':'); String port = null; if (index != -1 && index + 1 < hostname.length()) { String candidate = hostname.substring(index + 1); if (NumberUtils.isDigits(candidate)) { port = candidate; } } return port; }  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 testParsePort() { String hostname = "www.company.com"; String result = ConverterUtil.extractPort(hostname); assertNull(result); hostname = "www.company.com:8080"; result = ConverterUtil.extractPort(hostname); assertEquals("8080", result); hostname = "denis:angleton@www.company.com"; result = ConverterUtil.extractPort(hostname); assertNull(result); hostname = "denis:angleton@www.company.com:8080"; result = ConverterUtil.extractPort(hostname); assertEquals("8080", result); }