package edu.harvard.iq.dataverse;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

public class EMailValidatorTest {

    @Test
    public void testIsEmailValid() {
        assertEquals(true, EMailValidator.isEmailValid("pete@mailinator.com", null));
        assertEquals(false, EMailValidator.isEmailValid("pete1@mailinator.com;pete2@mailinator.com", null));
        assertEquals(false, EMailValidator.isEmailValid("", null));
        /**
         * @todo How can null as an email address be valid?!?
         */
        assertEquals(true, EMailValidator.isEmailValid(null, null));
    }

}

@@ -366,32 +366,1323 @@
 r.com%22, null));%0A
+        boolean issue2998resolved = false;%0A        /**%0A         * @todo Evaluate if we should upgrade to commons-validator 1.5 or%0A         * newer, which seems to allow these non-ASCII email addresses to pass%0A         * validation.%0A         *%0A         * %22In addition to the above ASCII characters, international characters%0A         * above U+007F, encoded as UTF-8, are permitted by RFC 6531, though%0A         * mail systems may restrict which characters to use when assigning%0A         * local parts.%22 https://en.wikipedia.org/wiki/Email_address%0A         *%0A         * These examples are all from https://randomuser.me and seem to be%0A         * valid according to%0A         * http://sphinx.mythic-beasts.com/~pdw/cgi-bin/emailvalidate (except%0A         * %D8%B1%D9%88%D9%86%DB%8C%DA%A9%D8%A7.%D9%85%D8%AD%D9%85%D8%AF%D8%AE%D8%A7%D9%86@example.com).%0A         *%0A         * See https://github.com/IQSS/dataverse/issues/2998%0A         */%0A        assertEquals(issue2998resolved, EMailValidator.isEmailValid(%22mich%C3%A9lle.pereboom@example.com%22, null));%0A        assertEquals(issue2998resolved, EMailValidator.isEmailValid(%22beg%C3%BCm.vriezen@example.com%22, null));%0A        assertEquals(issue2998resolved, EMailValidator.isEmailValid(%22l%C3%B3tus.gon%C3%A7alves@example.com%22, null));%0A        assertEquals(issue2998resolved, EMailValidator.isEmailValid(%22%D8%B1%D9%88%D9%86%DB%8C%DA%A9%D8%A7.%D9%85%D8%AD%D9%85%D8%AF%D8%AE%D8%A7%D9%86@example.com%22, null));%0A
         assertEq

add tests for non-ASCII email validation #2998