Add files via upload

This commit is contained in:
Ashish Gupta 2021-08-07 12:38:09 +05:30 committed by GitHub
parent 6b7dcdf847
commit 0d22a1fdee
1 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,59 @@
package com.baeldung.emailvalidation;
import static org.junit.Assert.assertEquals;
import org.apache.commons.validator.routines.EmailValidator;
import org.junit.Test;
public class EmailValidationUnitTest {
private String emailAddress;
@Test
public void testUsingEmailValidator() {
emailAddress = "username@domain.com";
assertEquals(EmailValidator.getInstance()
.isValid(emailAddress), true);
}
@Test
public void testUsingSimpleRegex() {
emailAddress = "username@domain.com";
assertEquals(EmailValidation.usingSimpleRegex(emailAddress), true);
}
@Test
public void testUsingStrictRegex() {
emailAddress = "username@domain.com";
assertEquals(EmailValidation.usingStrictRegex(emailAddress), true);
}
@Test
public void testUsingUnicodeRegex() {
emailAddress = "用户名@领域.电脑";
assertEquals(EmailValidation.usingUnicodeRegex(emailAddress), true);
}
@Test
public void testUsingRFC5322Regex() {
emailAddress = "username@domain.com";
assertEquals(EmailValidation.usingRFC5322Regex(emailAddress), true);
}
@Test
public void testRestrictDots() {
emailAddress = "username@domain.com";
assertEquals(EmailValidation.restrictDots(emailAddress), true);
}
@Test
public void testOwaspValidation() {
emailAddress = "username@domain.com";
assertEquals(EmailValidation.owaspValidation(emailAddress), true);
}
@Test
public void testTopLevelDomain() {
emailAddress = "username@domain.com";
assertEquals(EmailValidation.topLevelDomain(emailAddress), true);
}
}