1 /*
2 * Copyright 2005-2007 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.kns.datadictionary.validation.charlevel;
17
18 import org.junit.Test;
19 import org.kuali.rice.kns.datadictionary.validation.ValidationTestUtils;
20 import org.kuali.rice.test.BaseRiceTestCase;
21
22 public class AnyCharacterValidationPatternTest extends BaseRiceTestCase {
23 private AnyCharacterValidationPattern pattern;
24
25 @Override
26 public void setUp() throws Exception {
27 super.setUp();
28
29 pattern = new AnyCharacterValidationPattern();
30 }
31
32
33 @Test public final void testMatch_allowDefault() {
34 boolean[] expected = { true, // ""
35 true, // "!!!"
36 true, // "[a-9]"
37 true, // "^A-Z"
38 true, // "abc"
39 false, // "a bc"
40 true, // "a_bc"
41 true, // "123"
42 false, // "12 3"
43 true, // "12_3"
44 true, // "a1b2c3"
45 true, // "a1b2_c3"
46 false, // "a 1b2c3"
47 false, // "a 1b2_c3"
48 true, //"foo.bar"
49 true, //"foo.bar_baz"
50 false, //".bar_foo baz"
51 };
52
53 ValidationTestUtils.assertPatternMatches(pattern, expected);
54 }
55
56 @Test public final void testMatch_allowWhitespace() {
57 boolean[] expected = { true, // ""
58 true, // "!!!"
59 true, // "[a-9]"
60 true, // "^A-Z"
61 true, // "abc"
62 true, // "a bc"
63 true, // "a_bc"
64 true, // "123"
65 true, // "12 3"
66 true, // "12_3"
67 true, // "a1b2c3"
68 true, // "a1b2_c3"
69 true, // "a 1b2c3"
70 true, // "a 1b2_c3"
71 true, //"foo.bar"
72 true, //"foo.bar_baz"
73 true, //".bar_foo baz"
74 };
75
76 pattern.setAllowWhitespace(true);
77 ValidationTestUtils.assertPatternMatches(pattern, expected);
78 }
79 }