01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.core.datadictionary.validation.charlevel;
17:
18: import org.junit.Test;
19: import org.kuali.core.datadictionary.validation.ValidationTestUtils;
20: import org.kuali.test.KNSTestBase;
21:
22: public class AnyCharacterValidationPatternTest extends KNSTestBase {
23: private AnyCharacterValidationPattern pattern;
24:
25: @Override
26: public void setUp() throws Exception {
27: super .setUp();
28:
29: pattern = new AnyCharacterValidationPattern();
30: }
31:
32: @Test
33: 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: };
49:
50: ValidationTestUtils.assertPatternMatches(pattern, expected);
51: }
52:
53: @Test
54: public final void testMatch_allowWhitespace() {
55: boolean[] expected = { true, // ""
56: true, // "!!!"
57: true, // "[a-9]"
58: true, // "^A-Z"
59: true, // "abc"
60: true, // "a bc"
61: true, // "a_bc"
62: true, // "123"
63: true, // "12 3"
64: true, // "12_3"
65: true, // "a1b2c3"
66: true, // "a1b2_c3"
67: true, // "a 1b2c3"
68: true, // "a 1b2_c3"
69: };
70:
71: pattern.setAllowWhitespace(true);
72: ValidationTestUtils.assertPatternMatches(pattern, expected);
73: }
74: }
|