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 JavaClassValidationPatternTest extends KNSTestBase {
24: JavaClassValidationPattern pattern;
25:
26: @Override
27: public void setUp() throws Exception {
28: super .setUp();
29:
30: pattern = new JavaClassValidationPattern();
31: }
32:
33: @Test
34: public final void testMatches_actualClass() {
35: assertTrue(pattern.matches(String.class.getName()));
36: }
37:
38: @Test
39: public final void testMatches_fictitiousClass() {
40: assertTrue(pattern.matches("something.wicked.this.way.Comes"));
41: }
42:
43: @Test
44: public final void testMatches_unqualifiedClass() {
45: assertTrue(pattern.matches("String"));
46: }
47:
48: @Test
49: public final void testMatches_invalidClassname1() {
50: assertFalse(pattern.matches("23Tests"));
51: }
52:
53: @Test
54: public final void testMatches_invalidClassname2() {
55: assertFalse(pattern.matches("more tests"));
56: }
57:
58: @Test
59: public final void testMatches_invalidClassname3() {
60: assertFalse(pattern.matches("more.and.more:tests"));
61: }
62:
63: @Test
64: public final void testMatches_invalidClassname4() {
65: assertFalse(pattern.matches("still.more.tests."));
66: }
67: }
|