1 7 8 package org.sapia.validator.rules; 9 10 import junit.framework.*; 11 import java.util.regex.Matcher ; 12 import java.util.regex.Pattern ; 13 import org.sapia.validator.BeanRule; 14 import org.sapia.validator.Status; 15 import org.sapia.validator.RuleSet; 16 import org.sapia.validator.Vlad; 17 18 22 public class RegExTest extends TestCase { 23 24 public RegExTest(String testName) { 25 super(testName); 26 } 27 28 public void testValidate() throws Exception { 29 Vlad v = new Vlad(); 30 RegEx regEx = new RegEx(); 31 regEx.setPattern("http://[^\\s]+"); 32 RuleSet rs = new RuleSet(); 33 rs.setId("regEx"); 34 rs.addValidatable(regEx); 35 v.addRuleSet(rs); 36 Status st = v.validate("regEx", "http://www.yahoo.com ", java.util.Locale.getDefault()); 37 super.assertTrue("Check failed", st.isError()); 38 39 } 40 41 } 42 | Popular Tags |