1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.validation.charlevel;
17
18 import org.junit.Test;
19 import org.kuali.rice.kns.datadictionary.validation.charlevel.RegexValidationPattern;
20 import org.kuali.rice.test.BaseRiceTestCase;
21
22 import static org.junit.Assert.assertFalse;
23 import static org.junit.Assert.assertTrue;
24
25
26
27
28
29
30
31 public class RegexValidationPatternTest extends BaseRiceTestCase {
32 private RegexValidationPattern regexValidationPattern;
33
34 public void setUp() throws Exception {
35 regexValidationPattern=new RegexValidationPattern();
36 }
37
38 @Test public final void testNumericPattern() {
39 regexValidationPattern.setPattern("[0-9]");
40
41 assertTrue(regexValidationPattern.matches("123456789"));
42 assertFalse(regexValidationPattern.matches("abc"));
43 }
44
45 @Test public final void testAlphaPattern() {
46 regexValidationPattern.setPattern("[a-zA-Z]");
47
48 assertTrue(regexValidationPattern.matches("abc"));
49 assertFalse(regexValidationPattern.matches("a12345"));
50 }
51
52 @Test public final void testAlphaNumericPattern() {
53 regexValidationPattern.setPattern("[a-zA-Z0-9]");
54
55 assertTrue(regexValidationPattern.matches("ab12345c"));
56 assertFalse(regexValidationPattern.matches("a1*234?"));
57 }
58
59 }