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 AlphaValidationPatternTest extends KNSTestBase {
23: private AlphaValidationPattern pattern;
24:
25: @Override
26: public void setUp() throws Exception {
27: super .setUp();
28: pattern = new AlphaValidationPattern();
29: }
30:
31: @Test
32: public final void testMatch_allowDefault() {
33: boolean[] expected = { true, // ""
34: false, // "!!!"
35: false, // "[a-9]"
36: false, // "^A-Z"
37: true, // "abc"
38: false, // "a bc"
39: false, // "a_bc"
40: false, // "123"
41: false, // "12 3"
42: false, // "12_3"
43: false, // "a1b2c3"
44: false, // "a1b2_c3"
45: false, // "a 1b2c3"
46: false, // "a 1b2_c3"
47: };
48:
49: ValidationTestUtils.assertPatternMatches(pattern, expected);
50: }
51:
52: @Test
53: public final void testMatch_allowWhitespace() {
54: boolean[] expected = { true, // ""
55: false, // "!!!"
56: false, // "[a-9]"
57: false, // "^A-Z"
58: true, // "abc"
59: true, // "a bc"
60: false, // "a_bc"
61: false, // "123"
62: false, // "12 3"
63: false, // "12_3"
64: false, // "a1b2c3"
65: false, // "a1b2_c3"
66: false, // "a 1b2c3"
67: false, // "a 1b2_c3"
68: };
69:
70: pattern.setAllowWhitespace(true);
71: ValidationTestUtils.assertPatternMatches(pattern, expected);
72: }
73:
74: }
|