@Test(expected=IllegalArgumentException.class) public void noHttpIsNotValidTest(){ String url = "badurl.net"; UriUtils.checkUrlIsValid(url); }
public static void checkUrlIsValid(String url) throws IllegalArgumentException { logger.debug("Url is : {}",url); boolean urlIsValid; Pattern p = Pattern.compile(URL_PATTERN); Matcher m = p.matcher(url); if (!m.matches()) { p = Pattern.compile(IP_ADDRESS_PATTERN); m = p.matcher(url); urlIsValid = m.matches(); }else{ urlIsValid = true; } if(!urlIsValid){ throw new IllegalArgumentException("Url is not valid"); } URI.create(url); logger.debug("urlIsValid : {}",urlIsValid); }
UriUtils { public static void checkUrlIsValid(String url) throws IllegalArgumentException { logger.debug("Url is : {}",url); boolean urlIsValid; Pattern p = Pattern.compile(URL_PATTERN); Matcher m = p.matcher(url); if (!m.matches()) { p = Pattern.compile(IP_ADDRESS_PATTERN); m = p.matcher(url); urlIsValid = m.matches(); }else{ urlIsValid = true; } if(!urlIsValid){ throw new IllegalArgumentException("Url is not valid"); } URI.create(url); logger.debug("urlIsValid : {}",urlIsValid); } }
UriUtils { public static void checkUrlIsValid(String url) throws IllegalArgumentException { logger.debug("Url is : {}",url); boolean urlIsValid; Pattern p = Pattern.compile(URL_PATTERN); Matcher m = p.matcher(url); if (!m.matches()) { p = Pattern.compile(IP_ADDRESS_PATTERN); m = p.matcher(url); urlIsValid = m.matches(); }else{ urlIsValid = true; } if(!urlIsValid){ throw new IllegalArgumentException("Url is not valid"); } URI.create(url); logger.debug("urlIsValid : {}",urlIsValid); }  }
UriUtils { public static void checkUrlIsValid(String url) throws IllegalArgumentException { logger.debug("Url is : {}",url); boolean urlIsValid; Pattern p = Pattern.compile(URL_PATTERN); Matcher m = p.matcher(url); if (!m.matches()) { p = Pattern.compile(IP_ADDRESS_PATTERN); m = p.matcher(url); urlIsValid = m.matches(); }else{ urlIsValid = true; } if(!urlIsValid){ throw new IllegalArgumentException("Url is not valid"); } URI.create(url); logger.debug("urlIsValid : {}",urlIsValid); }  static void checkUrlIsValid(String url); }
UriUtils { public static void checkUrlIsValid(String url) throws IllegalArgumentException { logger.debug("Url is : {}",url); boolean urlIsValid; Pattern p = Pattern.compile(URL_PATTERN); Matcher m = p.matcher(url); if (!m.matches()) { p = Pattern.compile(IP_ADDRESS_PATTERN); m = p.matcher(url); urlIsValid = m.matches(); }else{ urlIsValid = true; } if(!urlIsValid){ throw new IllegalArgumentException("Url is not valid"); } URI.create(url); logger.debug("urlIsValid : {}",urlIsValid); }  static void checkUrlIsValid(String url); final static String URL_PATTERN; final static String IP_ADDRESS_PATTERN; }