diff --git a/pom.xml b/pom.xml index e3dc345f63302c1dbe5807be883d82ac8ab24129..7c4d303b56c9a43bade46407c6a4cd662b215bf7 100644 --- a/pom.xml +++ b/pom.xml @@ -1704,6 +1704,20 @@ <groupId>commons-validator</groupId> <artifactId>commons-validator</artifactId> <version>1.5.0</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>commons-digester</groupId> + <artifactId>commons-digester</artifactId> + </exclusion> + <exclusion> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <!-- Used by at least commons-fileupload, webdriver --> diff --git a/src/test/java/org/olat/core/util/mail/manager/MailTest.java b/src/test/java/org/olat/core/util/mail/manager/MailTest.java index 0d859333d226886c272de9e814748c3b1487d8d4..a41d5276f22e0c9c6aed47c84b4f9a7aa6e32078 100644 --- a/src/test/java/org/olat/core/util/mail/manager/MailTest.java +++ b/src/test/java/org/olat/core/util/mail/manager/MailTest.java @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.velocity.VelocityContext; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DBFactory; @@ -43,12 +44,14 @@ import org.olat.core.id.User; import org.olat.core.id.UserConstants; import org.olat.core.util.mail.MailBundle; import org.olat.core.util.mail.MailContext; +import org.olat.core.util.mail.MailHelper; import org.olat.core.util.mail.MailManager; import org.olat.core.util.mail.MailTemplate; import org.olat.core.util.mail.MailerResult; import org.olat.test.JunitTestHelper; import org.olat.test.OlatTestCase; import org.springframework.beans.factory.annotation.Autowired; + /** * Description:<br> @@ -87,7 +90,26 @@ public class MailTest extends OlatTestCase { id4 = JunitTestHelper.createAndPersistIdentityAsUser("four"); id6 = JunitTestHelper.createAndPersistIdentityAsUser("six"); } - + + @Test + public void testValidEmailAddresses() { + Assert.assertTrue(MailHelper.isValidEmailAddress("gnaegi@frentix.com")); + Assert.assertTrue(MailHelper.isValidEmailAddress("login@w.pl")); + Assert.assertTrue(MailHelper.isValidEmailAddress("christian.reichel@on-point.consulting")); + Assert.assertTrue(MailHelper.isValidEmailAddress("gnägi@frentix.com")); + Assert.assertTrue(MailHelper.isValidEmailAddress("someone@[192.168.1.100]")); + } + + @Test + public void testInvalidEmailAddresses() { + Assert.assertFalse(MailHelper.isValidEmailAddress(null)); + Assert.assertFalse(MailHelper.isValidEmailAddress("")); + Assert.assertFalse(MailHelper.isValidEmailAddress("gnaegi @ frentix.com")); + Assert.assertFalse(MailHelper.isValidEmailAddress("gnaegi@frentix_com")); + Assert.assertFalse(MailHelper.isValidEmailAddress("\"Florian Gnaegi\" <gnaegi@frentix.com>")); + Assert.assertFalse(MailHelper.isValidEmailAddress("g@g")); + } + /** * this is more a playground method to understand the evaluate method than a * rela testcase