1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.nuiton.validator.xwork2.field;
23
24 import org.junit.Test;
25 import org.nuiton.validator.model.Contact;
26
27
28
29
30
31 public class EmailFieldValidatorTest extends AbstractFieldValidatorTest<Contact> {
32
33 public EmailFieldValidatorTest() {
34 super(Contact.class);
35 }
36
37 @Test
38 @Override
39 public void testValidator() throws Exception {
40
41 assertNull(bean.getEmail());
42
43
44 bean.setEmail("toto@toto.com");
45 assertFieldInError(Contact.PROPERTY_EMAIL, "contact.email.format", false);
46
47
48 bean.setEmail("toto+validation@toto.com");
49 assertFieldInError(Contact.PROPERTY_EMAIL, "contact.email.format", false);
50
51
52 bean.setEmail("toto");
53 assertFieldInError(Contact.PROPERTY_EMAIL, "contact.email.format", true);
54
55
56 bean.setEmail("");
57 assertFieldInError(Contact.PROPERTY_EMAIL, "contact.email.format",
58 false);
59
60
61 bean.setEmail(null);
62 assertFieldInError(Contact.PROPERTY_EMAIL, "contact.email.format",
63 false);
64
65 }
66 }