* @author Simon Brown
*/
public class MailUtilsTest extends TestCase {
public void testValidEmailAddresses() {
ValidationContext context = new ValidationContext();
MailUtils.validate("somebody@somedomain.com", context);
assertFalse(context.hasErrors());
MailUtils.validate("somebody@somedomain.co.uk", context);
assertFalse(context.hasErrors());
MailUtils.validate("somebody1234567890@somedomain.com", context);
assertFalse(context.hasErrors());
MailUtils.validate("firstname.lastname@somedomain.com", context);
assertFalse(context.hasErrors());
MailUtils.validate("firstname_lastname@somedomain.com", context);
assertFalse(context.hasErrors());
MailUtils.validate("firstname-lastname@somedomain.com", context);
assertFalse(context.hasErrors());
MailUtils.validate("firstname+lastname@somedomain.com", context);
assertFalse(context.hasErrors());
MailUtils.validate("firstname#lastname@somedomain.com", context);
assertFalse(context.hasErrors());
MailUtils.validate("me&you@somedomain.com", context);
assertFalse(context.hasErrors());
MailUtils.validate("me$you@somedomain.com", context);
assertFalse(context.hasErrors());
MailUtils.validate("somebody@some-domain.com", context);
assertFalse(context.hasErrors());
context = new ValidationContext();
MailUtils.validate("first,last@some-domain.com", context);
assertTrue(context.hasErrors());
context = new ValidationContext();
MailUtils.validate("first@last@some-domain.com", context);
assertTrue(context.hasErrors());
context = new ValidationContext();
MailUtils.validate("first last@some-domain.com", context);
assertTrue(context.hasErrors());
}