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 EmailAddressValidationPatternTest extends KNSTestCase {
25      private EmailAddressValidationPattern pattern;
26  
27      @Override
28      public void setUp() throws Exception {
29          super.setUp();
30  
31          pattern = new EmailAddressValidationPattern();
32      }
33  
34  
35      @Test public final void testMatches_valid1() {
36          assertTrue(pattern.matches("ww5@a.b.c.org"));
37      }
38  
39      @Test public final void testMatches_valid2() {
40          assertTrue(pattern.matches("something.else@a2.com"));
41      }
42  
43      @Test public final void testMatches_valid3() {
44          assertTrue(pattern.matches("something_else@something.else.com"));
45      }
46  
47      @Test public final void testMatches_valid4() {
48          assertTrue(pattern.matches("something-else@et-tu.com"));
49      }
50  
51  
52      @Test public final void testMatches_invalid1() {
53          assertFalse(pattern.matches("a"));
54      }
55  
56      @Test public final void testMatches_invalid2() {
57          assertFalse(pattern.matches("@a.b.c.org"));
58      }
59  
60      @Test public final void testMatches_invalid3() {
61          assertFalse(pattern.matches("1@a.b.c.org"));
62      }
63  
64      @Test public final void testMatches_invalid4() {
65          assertFalse(pattern.matches("1@org"));
66      }
67  
68      @Test public final void testMatches_invalid5() {
69          assertFalse(pattern.matches("1@a"));
70      }
71  
72      @Test public final void testMatches_invalid6() {
73          assertFalse(pattern.matches(".@a.org"));
74      }
75  
76      @Test public final void testMatches_invalid7() {
77          assertFalse(pattern.matches("_@a.org"));
78      }
79  
80      @Test public final void testMatches_invalid8() {
81          assertFalse(pattern.matches("something@a.o-rg"));
82      }
83  }