Rfc822ValidatorTestpublic class Rfc822ValidatorTest extends TestCase
Fields Summary |
---|
static final String[] | VALID_EMAILS | static final String[] | INVALID_EMAILS |
Methods Summary |
---|
public void | testEmailValidator()
Rfc822Validator validator = new Rfc822Validator("gmail.com");
for (String email : VALID_EMAILS) {
assertTrue(email + " should be a valid email address", validator.isValid(email));
}
for (String email : INVALID_EMAILS) {
assertFalse(email + " should not be a valid email address", validator.isValid(email));
}
Map<String, String> fixes = new HashMap<String, String>();
fixes.put("a", "<a@gmail.com>");
fixes.put("a b", "<ab@gmail.com>");
fixes.put("a@b", "<a@b>");
fixes.put("()~><@not.work", "");
for (Map.Entry<String, String> e : fixes.entrySet()) {
assertEquals(e.getValue(), validator.fixText(e.getKey()).toString());
}
| public void | testEmailValidatorNullDomain()
Rfc822Validator validator = new Rfc822Validator(null);
Map<String, String> fixes = new HashMap<String, String>();
fixes.put("a", "<a>");
fixes.put("a b", "<a b>");
fixes.put("a@b", "<a@b>");
fixes.put("a@b.com", "<a@b.com>"); // this one is correct
for (Map.Entry<String, String> e : fixes.entrySet()) {
assertEquals(e.getValue(), validator.fixText(e.getKey()).toString());
}
| public void | testEmailValidatorRemoveInvalid()
Rfc822Validator validator = new Rfc822Validator("google.com");
validator.setRemoveInvalid(true);
Map<String, String> fixes = new HashMap<String, String>();
fixes.put("a", "");
fixes.put("a b", "");
fixes.put("a@b", "");
fixes.put("a@b.com", "<a@b.com>"); // this one is correct
for (Map.Entry<String, String> e : fixes.entrySet()) {
assertEquals(e.getValue(), validator.fixText(e.getKey()).toString());
}
|
|