Adds additional example URLs to check if validation works properly

This commit is contained in:
Lukasz Lenart
2016-11-25 19:35:15 +01:00
parent b12864dd38
commit 54dff362f5
@@ -17,7 +17,6 @@ package com.opensymphony.xwork2.validator;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.XWorkTestCase;
import com.opensymphony.xwork2.util.URLUtil;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.validator.validators.URLValidator;
@@ -132,14 +131,18 @@ public class URLValidatorTest extends XWorkTestCase {
public void testValidUrlWithDefaultRegex() throws Exception {
URLValidator validator = new URLValidator();
Pattern pattern = Pattern.compile(validator.getUrlRegex());
Pattern pattern = Pattern.compile(validator.getUrlRegex(), Pattern.CASE_INSENSITIVE);
assertFalse(pattern.matcher("myapp://test.com").matches());
assertFalse(pattern.matcher("myap://test.com").matches());
assertFalse(pattern.matcher("").matches());
assertFalse(pattern.matcher(" ").matches());
assertFalse(pattern.matcher("no url").matches());
assertFalse(pattern.matcher("http://example.com////////////////////////////////////////////////////////////////////////////////////??").matches());
assertFalse(pattern.matcher("http://example.com////////////////////////////////////////////////////////////////////////////////////??").matches());
assertTrue(pattern.matcher("http://www.legalspace.com/__media__/js/netsoltrademark.php?d=www.a-vos-travaux.fr%2Facheter-un-aspirateur-sans-sac-pas-cher%2F").matches());
assertTrue(pattern.matcher("http://www.duadmin.isaev.Infoduadmin.Isaev.info/?a%5B%5D=%3Ca%20href%3Dhttp%3A%2F%2Fwww.aspert.fr%2Fun-seche-cheveux-lisseur-est-il-vraiment-utile%2F%3Eseche%20cheveux%20dyson%20test%3C%2Fa").matches());
assertTrue(pattern.matcher("http://netsol-underconstruction-page-monitor-1.com/__media__/js/netsoltrademark.php?d=www.le-soutien-scolaire.fr%2Favis-et-test-comparatifs-des-robots-multifonctions%2F").matches());
assertTrue(pattern.matcher("http://www.opensymphony.com").matches());
assertTrue(pattern.matcher("https://www.opensymphony.com").matches());
@@ -181,7 +184,7 @@ public class URLValidatorTest extends XWorkTestCase {
}
public String getTestingUrl5() {
return "http://yahoo.com/articles?id=123";
return "http://yahoo.com/articles?id=123\n";
}
}