@Test public void uriUtilsMethodsBehaviorNoProtocolLocalhost(){ String uriString = "localhost:8080/"; thrown.expect(IllegalArgumentException.class); URIUtils.getHost(uriString); }
public static String getHost(String uriString) { try { URI uri = new URI(uriString); if(uri.getHost()==null) { throw new IllegalArgumentException("Invalid URI syntax. Scheme and host must be provided (port number is optional): " + uriString); } if (uri.getAuthority().startsWith("@") && !uri.getHost().startsWith("@")) { return "@" + uri.getHost(); } return uri.getHost(); } catch (URISyntaxException e) { try { return (new NetworkInterfaceURI(uriString)).getHost(); } catch (IllegalArgumentException ne) { throw new IllegalArgumentException(ne.getMessage(), ne); } } }
URIUtils { public static String getHost(String uriString) { try { URI uri = new URI(uriString); if(uri.getHost()==null) { throw new IllegalArgumentException("Invalid URI syntax. Scheme and host must be provided (port number is optional): " + uriString); } if (uri.getAuthority().startsWith("@") && !uri.getHost().startsWith("@")) { return "@" + uri.getHost(); } return uri.getHost(); } catch (URISyntaxException e) { try { return (new NetworkInterfaceURI(uriString)).getHost(); } catch (IllegalArgumentException ne) { throw new IllegalArgumentException(ne.getMessage(), ne); } } } }
URIUtils { public static String getHost(String uriString) { try { URI uri = new URI(uriString); if(uri.getHost()==null) { throw new IllegalArgumentException("Invalid URI syntax. Scheme and host must be provided (port number is optional): " + uriString); } if (uri.getAuthority().startsWith("@") && !uri.getHost().startsWith("@")) { return "@" + uri.getHost(); } return uri.getHost(); } catch (URISyntaxException e) { try { return (new NetworkInterfaceURI(uriString)).getHost(); } catch (IllegalArgumentException ne) { throw new IllegalArgumentException(ne.getMessage(), ne); } } }  }
URIUtils { public static String getHost(String uriString) { try { URI uri = new URI(uriString); if(uri.getHost()==null) { throw new IllegalArgumentException("Invalid URI syntax. Scheme and host must be provided (port number is optional): " + uriString); } if (uri.getAuthority().startsWith("@") && !uri.getHost().startsWith("@")) { return "@" + uri.getHost(); } return uri.getHost(); } catch (URISyntaxException e) { try { return (new NetworkInterfaceURI(uriString)).getHost(); } catch (IllegalArgumentException ne) { throw new IllegalArgumentException(ne.getMessage(), ne); } } }  static String uriToString(URI uri); static String uriToString(NetworkInterfaceURI uri); static String getHost(String uriString); static String getScheme(String uriString); static String getAuthority(String uriString); static String getFragment(String uriString); static String getPath(String uriString); static String getQuery(String uriString); static int getPort(String uriString); static String getUserInfo(String uriString); static String buildURIAsString(String scheme, String authority, String path,
            String query, String fragment); static String buildURIAsString(String scheme, String userInfo,
            String host, int port, String path, String query, String fragment); static String resolve(String uriInitial, String uriString); static String modifyURIScheme(String uri, String newScheme); static String modifyURIAuthority(String uri, String newAuthority); static String modifyURIPort(String uri, int newPort); static String modifyURIPath(String uri, String newPath); static boolean isAbsolute(String uri); static String getCanonicalURI(String uriString, boolean canonicalizePath); static String getCanonicalizedURI(String uri, boolean canonicalizePath); }
URIUtils { public static String getHost(String uriString) { try { URI uri = new URI(uriString); if(uri.getHost()==null) { throw new IllegalArgumentException("Invalid URI syntax. Scheme and host must be provided (port number is optional): " + uriString); } if (uri.getAuthority().startsWith("@") && !uri.getHost().startsWith("@")) { return "@" + uri.getHost(); } return uri.getHost(); } catch (URISyntaxException e) { try { return (new NetworkInterfaceURI(uriString)).getHost(); } catch (IllegalArgumentException ne) { throw new IllegalArgumentException(ne.getMessage(), ne); } } }  static String uriToString(URI uri); static String uriToString(NetworkInterfaceURI uri); static String getHost(String uriString); static String getScheme(String uriString); static String getAuthority(String uriString); static String getFragment(String uriString); static String getPath(String uriString); static String getQuery(String uriString); static int getPort(String uriString); static String getUserInfo(String uriString); static String buildURIAsString(String scheme, String authority, String path,
            String query, String fragment); static String buildURIAsString(String scheme, String userInfo,
            String host, int port, String path, String query, String fragment); static String resolve(String uriInitial, String uriString); static String modifyURIScheme(String uri, String newScheme); static String modifyURIAuthority(String uri, String newAuthority); static String modifyURIPort(String uri, int newPort); static String modifyURIPath(String uri, String newPath); static boolean isAbsolute(String uri); static String getCanonicalURI(String uriString, boolean canonicalizePath); static String getCanonicalizedURI(String uri, boolean canonicalizePath); static final String NETWORK_INTERFACE_AUTHORITY_PORT; static final String NETWORK_INTERFACE_AUTHORITY; }