View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
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.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  }