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.fieldlevel;
17:
18: import org.junit.Test;
19: import org.kuali.test.KNSTestBase;
20: import org.kuali.test.KNSWithTestSpringContext;
21:
22: @KNSWithTestSpringContext
23: public class DateValidationPatternTest extends KNSTestBase {
24: DateValidationPattern pattern;
25:
26: @Override
27: public void setUp() throws Exception {
28: super .setUp();
29:
30: pattern = new DateValidationPattern();
31: String foo = pattern.getRegexPattern().pattern();
32: String bar = "none";
33: }
34:
35: @Test
36: public final void testMatches_valid1() {
37: assertTrue(pattern.matches("1966-5-1"));
38: }
39:
40: @Test
41: public final void testMatches_valid2() {
42: assertTrue(pattern.matches("1966-05-01"));
43: }
44:
45: @Test
46: public final void testMatches_valid3() {
47: assertTrue(pattern.matches("1966-5-01"));
48: }
49:
50: @Test
51: public final void testMatches_valid4() {
52: assertTrue(pattern.matches("1966-05-1"));
53: }
54:
55: @Test
56: public final void testMatches_valid5() {
57: assertTrue(pattern.matches("2237-5-1"));
58: }
59:
60: @Test
61: public final void testMatches_invalid1() {
62: assertFalse(pattern.matches("1966/05/01"));
63: }
64:
65: @Test
66: public final void testMatches_invalid2() {
67: assertFalse(pattern.matches("05/1966/01"));
68: }
69:
70: @Test
71: public final void testMatches_invalid3() {
72: assertFalse(pattern.matches("5/1/196"));
73: }
74:
75: @Test
76: public final void testMatches_invalid4() {
77: assertFalse(pattern.matches("5/1/66"));
78: }
79:
80: @Test
81: public final void testMatches_invalid5() {
82: assertFalse(pattern.matches("5/32/1966"));
83: }
84:
85: @Test
86: public final void testMatches_invalid6() {
87: assertFalse(pattern.matches("13/01/1966"));
88: }
89:
90: @Test
91: public final void testMatches_invalid7() {
92: assertFalse(pattern.matches("05/01/3103"));
93: }
94: }
|