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.UTF8AnyCharacterValidationPattern;
20 import org.kuali.rice.krad.datadictionary.validation.UTF8ValidationTestUtils;
21 import org.kuali.rice.test.BaseRiceTestCase;
22
23 public class UTF8AnyCharacterValidationPatternTest extends BaseRiceTestCase {
24 private UTF8AnyCharacterValidationPattern pattern;
25
26 @Override
27 public void setUp() throws Exception {
28 super.setUp();
29
30 pattern = new UTF8AnyCharacterValidationPattern();
31 }
32
33 @Test public final void testMatch_allUTF8ExceptWhiteSpace() {
34 boolean[] expected = { true,
35 true,
36 true,
37 true,
38 true,
39 false,
40 true,
41 true,
42 false,
43 true,
44 true,
45 true,
46 false,
47 false,
48 true,
49 true,
50 false,
51 true,
52 true,
53 false,
54 false,
55
56 };
57
58 UTF8ValidationTestUtils.assertPatternMatches(pattern, expected);
59 }
60
61 @Test public final void testMatch_allowALLUTF8() {
62 boolean[] expected = { true,
63 true,
64 true,
65 true,
66 true,
67 true,
68 true,
69 true,
70 true,
71 true,
72 true,
73 true,
74 true,
75 true,
76 true,
77 true,
78 true,
79 true,
80 true,
81 true,
82 true,
83 };
84
85 pattern.setAllowWhitespace(true);
86 UTF8ValidationTestUtils.assertPatternMatches(pattern, expected);
87 }
88 }