Author: tn Date: Tue Dec 2 09:34:17 2014 New Revision: 1642830 URL: http://svn.apache.org/r1642830 Log: [EMAIL-146] Added getter for bounce address. Thanks to Alexander Lehmann.
Modified: commons/proper/email/trunk/src/changes/changes.xml commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java Modified: commons/proper/email/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/changes/changes.xml?rev=1642830&r1=1642829&r2=1642830&view=diff ============================================================================== --- commons/proper/email/trunk/src/changes/changes.xml (original) +++ commons/proper/email/trunk/src/changes/changes.xml Tue Dec 2 09:34:17 2014 @@ -23,6 +23,9 @@ <body> <release version="1.4.0" date="2014-??-??"> + <action dev="tn" type="add" issue="EMAIL-146" date="2014-12-01" due-to="Alexander Lehmann"> + Added getter for the bounce address of an email to class Email. + </action> <action dev="ggregory" type="update" issue="EMAIL-144" date="2014-10-15"> Update Oracle JavaMail dependency from 1.4.5 to 1.5.2. </action> Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java?rev=1642830&r1=1642829&r2=1642830&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java Tue Dec 2 09:34:17 2014 @@ -1215,6 +1215,17 @@ public abstract class Email } /** + * Gets the "bounce address" of this email. + * + * @return the bounce address as string + * @since 1.4 + */ + public String getBounceAddress() + { + return this.bounceAddress; + } + + /** * Set the "bounce address" - the address to which undeliverable messages * will be returned. If this value is never set, then the message will be * sent to the address specified with the System property "mail.smtp.from", @@ -1232,7 +1243,6 @@ public abstract class Email return this; } - /** * Define the content of the mail. It should be overridden by the * subclasses. Modified: commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java?rev=1642830&r1=1642829&r2=1642830&view=diff ============================================================================== --- commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java (original) +++ commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java Tue Dec 2 09:34:17 2014 @@ -16,17 +16,8 @@ */ package org.apache.commons.mail; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; -import javax.mail.Session; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMultipart; -import javax.mail.internet.ParseException; import java.io.File; import java.nio.charset.Charset; import java.nio.charset.IllegalCharsetNameException; @@ -40,6 +31,12 @@ import java.util.List; import java.util.Map; import java.util.Properties; +import javax.mail.Session; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; +import javax.mail.internet.ParseException; + import org.apache.commons.mail.mocks.MockEmailConcrete; import org.junit.Before; import org.junit.Test; @@ -1215,5 +1212,18 @@ public class EmailTest extends AbstractE final MimeMessage msg = email.getMimeMessage(); msg.saveChanges(); assertEquals("image/png", msg.getContentType()); - } + } + + @Test + public void testGetSetBounceAddress() + { + assertNull(email.getBounceAddress()); + + final String bounceAddress = "test_bou...@apache.org"; + email.setBounceAddress(bounceAddress); + + // tests + assertEquals(bounceAddress, email.getBounceAddress()); + } + }