1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.datadictionary.validation.fieldlevel;
17
18 import org.junit.Test;
19 import org.kuali.test.KNSTestCase;
20 import org.kuali.test.KNSWithTestSpringContext;
21
22
23 @KNSWithTestSpringContext
24 public class JavaClassValidationPatternTest extends KNSTestCase {
25 JavaClassValidationPattern pattern;
26
27 @Override
28 public void setUp() throws Exception {
29 super.setUp();
30
31 pattern = new JavaClassValidationPattern();
32 }
33
34 @Test public final void testMatches_actualClass() {
35 assertTrue(pattern.matches(String.class.getName()));
36 }
37
38 @Test public final void testMatches_fictitiousClass() {
39 assertTrue(pattern.matches("something.wicked.this.way.Comes"));
40 }
41
42 @Test public final void testMatches_unqualifiedClass() {
43 assertTrue(pattern.matches("String"));
44 }
45
46 @Test public final void testMatches_invalidClassname1() {
47 assertFalse(pattern.matches("23Tests"));
48 }
49
50 @Test public final void testMatches_invalidClassname2() {
51 assertFalse(pattern.matches("more tests"));
52 }
53
54 @Test public final void testMatches_invalidClassname3() {
55 assertFalse(pattern.matches("more.and.more:tests"));
56 }
57
58 @Test public final void testMatches_invalidClassname4() {
59 assertFalse(pattern.matches("still.more.tests."));
60 }
61 }