test/org/ohmage/validator/UserValidatorsTest.java
@Test
	public void testValidateEmailAddress() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(UserValidators.validateEmailAddress(emptyValue));
			}
			
			try {
				UserValidators.validateEmailAddress("Invalid value.");
				fail("The email address value is invalid.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("@a.aa");
				fail("Local part missing.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a@.aa");
				fail("Domain is missing.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a@a");
				fail("TLD is missing.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			 
			try {
				UserValidators.validateEmailAddress("a(@a.aa");
				fail("Invalid character, '(', present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a)@a.aa");
				fail("Invalid character, ')', present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a,@a.aa");
				fail("Invalid character, ',', present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a:@a.aa");
				fail("Invalid character, ':', present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			 
			try {
				UserValidators.validateEmailAddress("a;@a.aa");
				fail("Invalid character, ';', present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a<@a.aa");
				fail("Invalid character, '<', present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a>@a.aa");
				fail("Invalid character, '>', present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a[@a.aa");
				fail("Invalid character, '[', present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a]@a.aa");
				fail("Invalid character, ']', present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a\\@a.aa");
				fail("Invalid character, '\\', present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a@@a.aa");
				fail("Multiple '@' symbols present.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress(".a@a.aa");
				fail("Begins with a period, '.'.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a.@a.aa");
				fail("Ends with a period, '.'.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a..a@a.aa");
				fail("Multiple consecutive periods exist.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			/*
			try {
				UserValidators.validateEmailAddress("12345678901234567890123456789012345678901234567890123456789012345@a.aa");
				fail("Local part is too long.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a@a.345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234");
				fail("Domain is too long.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("1234567890123456789012345678901234567890123456789012345678901234@a.34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123");
				fail("Local part and domain are both within their length bounds, but the entire address is still too long.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			*/

			try {
				UserValidators.validateEmailAddress("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@a.aa");
			}
			catch(ValidationException e) {
				fail("Using only valid characters, the email verification still failed.");
			}
			
			/*
			try {
				UserValidators.validateEmailAddress("'`~!#$%^&*+\\-/=?{|}@a.aa");
			}
			catch(ValidationException e) {
				fail("Using only valid characters, the email verification still failed.");
			}
			*/
			
			try {
				UserValidators.validateEmailAddress("a.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@a.aa");
			}
			catch(ValidationException e) {
				fail("Using only valid characters after a period, '.', the email verification still failed.");
			}
			
			/*
			try {
				UserValidators.validateEmailAddress("a.'`~!#$%^&*+@a.aa");
			}
			catch(ValidationException e) {
				fail("Using only valid characters after a period, '.', the email verification still failed.");
			}
			*/
			
			try {
				UserValidators.validateEmailAddress("a@a.aa");
			}
			catch(ValidationException e) {
				fail("The shortest, simplest email address failed.");
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
/**
	 * Tests the email address validator.
	 */
Tests the email address validator.
Tests the email address validator .
@Test
	public void testValidateEmailAddress() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(UserValidators.validateEmailAddress(emptyValue));
			}
			try {
				UserValidators.validateEmailAddress("Invalid value.");
				fail("The email address value is invalid.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("@a.aa");
				fail("Local part missing.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a@.aa");
				fail("Domain is missing.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a@a");
				fail("TLD is missing.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a(@a.aa");
				fail("Invalid character, '(', present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a)@a.aa");
				fail("Invalid character, ')', present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a,@a.aa");
				fail("Invalid character, ',', present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a:@a.aa");
				fail("Invalid character, ':', present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a;@a.aa");
				fail("Invalid character, ';', present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a<@a.aa");
				fail("Invalid character, '<', present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a>@a.aa");
				fail("Invalid character, '>', present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a[@a.aa");
				fail("Invalid character, '[', present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a]@a.aa");
				fail("Invalid character, ']', present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a\\@a.aa");
				fail("Invalid character, '\\', present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a@@a.aa");
				fail("Multiple '@' symbols present.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress(".a@a.aa");
				fail("Begins with a period, '.'.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a.@a.aa");
				fail("Ends with a period, '.'.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a..a@a.aa");
				fail("Multiple consecutive periods exist.");
			}
			catch(ValidationException e) {
			}
			/*
			try {
				UserValidators.validateEmailAddress("12345678901234567890123456789012345678901234567890123456789012345@a.aa");
				fail("Local part is too long.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("a@a.345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234");
				fail("Domain is too long.");
			}
			catch(ValidationException e) {
			}
			try {
				UserValidators.validateEmailAddress("1234567890123456789012345678901234567890123456789012345678901234@a.34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123");
				fail("Local part and domain are both within their length bounds, but the entire address is still too long.");
			}
			catch(ValidationException e) {
			}
			*/
			try {
				UserValidators.validateEmailAddress("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@a.aa");
			}
			catch(ValidationException e) {
				fail("Using only valid characters, the email verification still failed.");
			}
			/*
			try {
				UserValidators.validateEmailAddress("'`~!#$%^&*+\\-/=?{|}@a.aa");
			}
			catch(ValidationException e) {
				fail("Using only valid characters, the email verification still failed.");
			}
			*/
			try {
				UserValidators.validateEmailAddress("a.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@a.aa");
			}
			catch(ValidationException e) {
				fail("Using only valid characters after a period, '.', the email verification still failed.");
			}
			/*
			try {
				UserValidators.validateEmailAddress("a.'`~!#$%^&*+@a.aa");
			}
			catch(ValidationException e) {
				fail("Using only valid characters after a period, '.', the email verification still failed.");
			}
			*/
			try {
				UserValidators.validateEmailAddress("a@a.aa");
			}
			catch(ValidationException e) {
				fail("The shortest, simplest email address failed.");
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
@ Test public void testValidateEmailAddress ( ) { try { for ( String emptyValue : ParameterSets . getEmptyValues ( ) ) { Assert . assertNull ( UserValidators . validateEmailAddress ( emptyValue ) ) ; } try { UserValidators . validateEmailAddress ( "Invalid value." ) ; fail ( "The email address value is invalid." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "@a.aa" ) ; fail ( "Local part missing." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a@.aa" ) ; fail ( "Domain is missing." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a@a" ) ; fail ( "TLD is missing." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a(@a.aa" ) ; fail ( "Invalid character, '(', present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a)@a.aa" ) ; fail ( "Invalid character, ')', present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a,@a.aa" ) ; fail ( "Invalid character, ',', present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a:@a.aa" ) ; fail ( "Invalid character, ':', present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a;@a.aa" ) ; fail ( "Invalid character, ';', present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a<@a.aa" ) ; fail ( "Invalid character, '<', present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a>@a.aa" ) ; fail ( "Invalid character, '>', present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a[@a.aa" ) ; fail ( "Invalid character, '[', present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a]@a.aa" ) ; fail ( "Invalid character, ']', present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a\\@a.aa" ) ; fail ( "Invalid character, '\\', present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a@@a.aa" ) ; fail ( "Multiple '@' symbols present." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( ".a@a.aa" ) ; fail ( "Begins with a period, '.'." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a.@a.aa" ) ; fail ( "Ends with a period, '.'." ) ; } catch ( ValidationException e ) { } try { UserValidators . validateEmailAddress ( "a..a@a.aa" ) ; fail ( "Multiple consecutive periods exist." ) ; } catch ( ValidationException e ) { } /*
			try {
				UserValidators.validateEmailAddress("12345678901234567890123456789012345678901234567890123456789012345@a.aa");
				fail("Local part is too long.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("a@a.345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234");
				fail("Domain is too long.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			try {
				UserValidators.validateEmailAddress("1234567890123456789012345678901234567890123456789012345678901234@a.34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123");
				fail("Local part and domain are both within their length bounds, but the entire address is still too long.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			*/ try { UserValidators . validateEmailAddress ( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@a.aa" ) ; } catch ( ValidationException e ) { fail ( "Using only valid characters, the email verification still failed." ) ; } /*
			try {
				UserValidators.validateEmailAddress("'`~!#$%^&*+\\-/=?{|}@a.aa");
			}
			catch(ValidationException e) {
				fail("Using only valid characters, the email verification still failed.");
			}
			*/ try { UserValidators . validateEmailAddress ( "a.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@a.aa" ) ; } catch ( ValidationException e ) { fail ( "Using only valid characters after a period, '.', the email verification still failed." ) ; } /*
			try {
				UserValidators.validateEmailAddress("a.'`~!#$%^&*+@a.aa");
			}
			catch(ValidationException e) {
				fail("Using only valid characters after a period, '.', the email verification still failed.");
			}
			*/ try { UserValidators . validateEmailAddress ( "a@a.aa" ) ; } catch ( ValidationException e ) { fail ( "The shortest, simplest email address failed." ) ; } } catch ( ValidationException e ) { fail ( "A validation exception was thrown: " + e . getMessage ( ) ) ; } }
Tests the email address validator.
Tests the email address validator .
// Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed. // Passed.