KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > validator > rules > RegExTest


1 /*
2  * RegExTest.java
3  * JUnit based test
4  *
5  * Created on May 6, 2005, 9:52 AM
6  */

7
8 package org.sapia.validator.rules;
9
10 import junit.framework.*;
11 import java.util.regex.Matcher JavaDoc;
12 import java.util.regex.Pattern JavaDoc;
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 /**
19  *
20  * @author yduchesne
21  */

22 public class RegExTest extends TestCase {
23   
24   public RegExTest(String JavaDoc testName) {
25     super(testName);
26   }
27
28     public void testValidate() throws Exception JavaDoc{
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