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