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 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  }