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
24
25
26
27
28 public class UTF8AnyCharacterValidationPatternTest extends BaseRiceTestCase {
29 private UTF8AnyCharacterValidationPattern pattern;
30
31 @Override
32 public void setUp() throws Exception {
33 super.setUp();
34
35 pattern = new UTF8AnyCharacterValidationPattern();
36 }
37
38 @Test public final void testMatch_allUTF8ExceptWhiteSpace() {
39 boolean[] expected = { true,
40 true,
41 true,
42 true,
43 true,
44 false,
45 true,
46 true,
47 false,
48 true,
49 true,
50 true,
51 false,
52 false,
53 true,
54 true,
55 false,
56 true,
57 true,
58 false,
59 false,
60
61 };
62
63 UTF8ValidationTestUtils.assertPatternMatches(pattern, expected);
64 }
65
66 @Test public final void testMatch_allowALLUTF8() {
67 boolean[] expected = { 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 true,
84 true,
85 true,
86 true,
87 true,
88 };
89
90 pattern.setAllowWhitespace(true);
91 UTF8ValidationTestUtils.assertPatternMatches(pattern, expected);
92 }
93 }