You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/12/16 16:04:56 UTC

(commons-email) 03/03: Add missing getters and setters

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-email.git

commit b4f21b3fed8591c3368577e2145da883b75871cf
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 16 11:04:33 2023 -0500

    Add missing getters and setters
    
    - Affects EMail and subclasses
    - Deprecate access to protected instance variables.
    - Use getters and setters instead
---
 src/changes/changes.xml                            |   1 +
 src/main/java/org/apache/commons/mail/Email.java   | 373 +++++++++++++++++++--
 .../java/org/apache/commons/mail/HtmlEmail.java    |  41 ++-
 .../org/apache/commons/mail/ImageHtmlEmail.java    |   2 +-
 .../org/apache/commons/mail/MultiPartEmail.java    |   4 +-
 .../java/org/apache/commons/mail/EmailTest.java    |  22 +-
 .../org/apache/commons/mail/HtmlEmailTest.java     |  30 +-
 .../apache/commons/mail/ImageHtmlEmailTest.java    |   6 +-
 .../commons/mail/SendWithAttachmentsTest.java      |   8 +-
 .../org/apache/commons/mail/SimpleEmailTest.java   |   6 +-
 .../commons/mail/mocks/MockEmailConcrete.java      | 116 +------
 .../commons/mail/mocks/MockHtmlEmailConcrete.java  |  27 --
 .../mail/mocks/MockImageHtmlEmailConcrete.java     |   8 -
 .../mail/mocks/MockMultiPartEmailConcrete.java     |  10 -
 .../apache/commons/mail/mocks/MockSimpleEmail.java |  11 +-
 15 files changed, 423 insertions(+), 242 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a2710b2..9b09138 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -39,6 +39,7 @@
       <action issue="EMAIL-206" type="fix" dev="ggregory" due-to="Lee Jaeheon, Gary Gregory">Use SharedByteArrayInputStream for memory usage #157.</action>
       <action dev="ggregory" type="fix" due-to="Loki-Afro, Gary Gregory">Migrate to JUnit 5 #186.</action>
       <action issue="EMAIL-174" type="fix" due-to="Vegard Stuen">Bump javax.mail dependency to 1.6.1, so that i18n is supported for email addresses.</action>
+      <action dev="ggregory" type="fix" due-to="Loki-Afro, Gary Gregory">Add missing getters and setters in EMail and subclasses; deprecate access to protected instance variables.</action>
       <!-- ADD -->
       <action type="add" due-to="Dependabot" dev="ggregory">Add github/codeql-action #75.</action>
       <action type="add" due-to="Gary Gregory" dev="ggregory">Add Maven plugin JapiCmp and remove Clirr.</action>
diff --git a/src/main/java/org/apache/commons/mail/Email.java b/src/main/java/org/apache/commons/mail/Email.java
index c2d0856..96ab9a9 100644
--- a/src/main/java/org/apache/commons/mail/Email.java
+++ b/src/main/java/org/apache/commons/mail/Email.java
@@ -173,90 +173,191 @@ public abstract class Email {
     @Deprecated
     public static final String MAIL_SMTP_TIMEOUT = EmailConstants.MAIL_SMTP_TIMEOUT;
 
-    /** The email message to send. */
+    /**
+     * The email message to send.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected MimeMessage message;
 
-    /** The charset to use for this message. */
+    /**
+     * The charset to use for this message.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected String charset;
 
-    /** The Address of the sending party, mandatory. */
+    /**
+     * The Address of the sending party, mandatory.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected InternetAddress fromAddress;
 
-    /** The Subject. */
+    /**
+     * The Subject.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected String subject;
 
-    /** An attachment. */
+    /**
+     * An attachment.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected MimeMultipart emailBody;
 
-    /** The content. */
+    /**
+     * The content.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected Object content;
 
-    /** The content type. */
+    /**
+     * The content type.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected String contentType;
 
-    /** Set session debugging on or off. */
+    /**
+     * Set session debugging on or off.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected boolean debug;
 
-    /** Sent date. */
+    /**
+     * Sent date.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected Date sentDate;
 
     /**
      * Instance of an {@code Authenticator} object that will be used when authentication is requested from the mail server.
+     *
+     * @deprecated Use getters and getters.
      */
+    @Deprecated
     protected Authenticator authenticator;
 
     /**
      * The hostname of the mail server with which to connect. If null will try to get property from system.properties. If still null, quit.
+     *
+     * @deprecated Use getters and getters.
      */
+    @Deprecated
     protected String hostName;
 
     /**
      * The port number of the mail server to connect to. Defaults to the standard port ( 25 ).
+     *
+     * @deprecated Use getters and getters.
      */
+    @Deprecated
     protected String smtpPort = "25";
 
     /**
      * The port number of the SSL enabled SMTP server; defaults to the standard port, 465.
+     *
+     * @deprecated Use getters and getters.
      */
+    @Deprecated
     protected String sslSmtpPort = "465";
 
-    /** List of "to" email addresses. */
+    /**
+     * List of "to" email addresses.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected List<InternetAddress> toList = new ArrayList<>();
 
-    /** List of "cc" email addresses. */
+    /**
+     * List of "cc" email addresses.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected List<InternetAddress> ccList = new ArrayList<>();
 
-    /** List of "bcc" email addresses. */
+    /**
+     * List of "bcc" email addresses.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected List<InternetAddress> bccList = new ArrayList<>();
 
-    /** List of "replyTo" email addresses. */
+    /**
+     * List of "replyTo" email addresses.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected List<InternetAddress> replyList = new ArrayList<>();
 
     /**
      * Address to which undeliverable mail should be sent. Because this is handled by JavaMail as a String property in the mail session, this property is of
      * type {@code String} rather than {@code InternetAddress}.
+     *
+     * @deprecated Use getters and getters.
      */
+    @Deprecated
     protected String bounceAddress;
 
     /**
      * Used to specify the mail headers. Example:
      *
      * X-Mailer: Sendmail, X-Priority: 1( highest ) or 2( high ) 3( normal ) 4( low ) and 5( lowest ) Disposition-Notification-To: user@domain.net
+     *
+     * @deprecated Use getters and getters.
      */
+    @Deprecated
     protected Map<String, String> headers = new HashMap<>();
 
     /**
-     * Used to determine whether to use pop3 before SMTP, and if so the settings.
+     * Whether to use POP3 before SMTP, and if so the settings.
+     *
+     * @deprecated Use getters and getters.
      */
+    @Deprecated
     protected boolean popBeforeSmtp;
 
-    /** The host name of the pop3 server. */
+    /**
+     * The host name of the POP3 server.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected String popHost;
 
-    /** The user name to log into the pop3 server. */
+    /**
+     * The user name to log into the POP3 server.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected String popUsername;
 
-    /** The password to log into the pop3 server. */
+    /**
+     * The password to log into the POP3 server.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected String popPassword;
 
     /**
@@ -303,7 +404,9 @@ public abstract class Email {
      */
     private boolean startTlsRequired;
 
-    /** Does the current transport use SSL/TLS encryption upon connection? */
+    /**
+     * Does the current transport use SSL/TLS encryption upon connection?
+     */
     private boolean sslOnConnect;
 
     /**
@@ -319,7 +422,9 @@ public abstract class Email {
      */
     private boolean sendPartial;
 
-    /** The Session to mail with. */
+    /**
+     * The Session to mail with.
+     */
     private Session session;
 
     /**
@@ -741,6 +846,16 @@ public abstract class Email {
         return new MimeMessage(aSession);
     }
 
+    /**
+     * Gets the authenticator.
+     *
+     * @return the authenticator.
+     * @since 1.6.0
+     */
+    public Authenticator getAuthenticator() {
+        return authenticator;
+    }
+
     /**
      * Gets the list of "Bcc" addresses.
      *
@@ -769,6 +884,46 @@ public abstract class Email {
         return ccList;
     }
 
+    /**
+     * Gets the Charset.
+     *
+     * @return the Charset.
+     * @since 1.6.0
+     */
+    public String getCharsetName() {
+        return charset;
+    }
+
+    /**
+     * Gets the content.
+     *
+     * @return the content.
+     * @since 1.6.0
+     */
+    public Object getContent() {
+        return content;
+    }
+
+    /**
+     * Gets the content type.
+     *
+     * @return the content type.
+     * @since 1.6.0
+     */
+    public String getContentType() {
+        return contentType;
+    }
+
+    /**
+     * Gets the email body.
+     *
+     * @return the email body.
+     * @since 1.6.0
+     */
+    public MimeMultipart getEmailBody() {
+        return emailBody;
+    }
+
     /**
      * Gets the sender of the email.
      *
@@ -877,6 +1032,16 @@ public abstract class Email {
         return session;
     }
 
+    /**
+     * Gets the message.
+     *
+     * @return the message.
+     * @since 1.6.0
+     */
+    public MimeMessage getMessage() {
+        return message;
+    }
+
     /**
      * Gets the internal MimeMessage. Please note that the MimeMessage is built by the buildMimeMessage() method.
      *
@@ -886,6 +1051,36 @@ public abstract class Email {
         return message;
     }
 
+    /**
+     * Gets the POP3 host.
+     *
+     * @return the POP3 host.
+     * @since 1.6.0
+     */
+    public String getPopHost() {
+        return popHost;
+    }
+
+    /**
+     * Gets the POP3 password.
+     *
+     * @return the POP3 password.
+     * @since 1.6.0
+     */
+    public String getPopPassword() {
+        return popPassword;
+    }
+
+    /**
+     * Gets the POP3 user name.
+     *
+     * @return the POP3 user name.
+     * @since 1.6.0
+     */
+    public String getPopUserName() {
+        return popUsername;
+    }
+
     /**
      * Gets the list of "Reply-To" addresses.
      *
@@ -976,6 +1171,26 @@ public abstract class Email {
         return toList;
     }
 
+    /**
+     * Tests whether debug is on.
+     *
+     * @return whether debug is on.
+     * @since 1.6.0
+     */
+    public boolean isDebug() {
+        return debug;
+    }
+
+    /**
+     * Tests whether to use POP3 before SMTP, and if so the settings.
+     *
+     * @return whether to use POP3 before SMTP, and if so the settings.
+     * @since 1.6.0
+     */
+    public boolean isPopBeforeSmtp() {
+        return popBeforeSmtp;
+    }
+
     /**
      * Tests whether partial sending of email is enabled.
      *
@@ -989,8 +1204,8 @@ public abstract class Email {
     /**
      * Tests whether SSL/TLS encryption for the transport is currently enabled (SMTPS/POPS). See EMAIL-105 for reason of deprecation.
      *
-     * @deprecated since 1.3, use {@link #isSSLOnConnect()} instead.
      * @return true if SSL enabled for the transport.
+     * @deprecated since 1.3, use {@link #isSSLOnConnect()} instead.
      */
     @Deprecated
     public boolean isSSL() {
@@ -1186,6 +1401,18 @@ public abstract class Email {
         this.emailBody = mimeMultipart;
     }
 
+    /**
+     * Sets the content.
+     *
+     * @param content the content.
+     * @return this.
+     * @since 1.6.0
+     */
+    public Email setContent(final Object content) {
+        this.content = content;
+        return this;
+    }
+
     /**
      * Sets the content and contentType.
      *
@@ -1198,6 +1425,18 @@ public abstract class Email {
         updateContentType(contentType);
     }
 
+    /**
+     * Sets the content type.
+     *
+     * @param contentType the content type.
+     * @return this.
+     * @since 1.6.0
+     */
+    public Email setContentType(final String contentType) {
+        this.contentType = contentType;
+        return this;
+    }
+
     /**
      * Sets the display of debug information.
      *
@@ -1252,6 +1491,19 @@ public abstract class Email {
         return this;
     }
 
+    /**
+     * Sets the From address.
+     *
+     * @param fromAddress the From address.
+     * @return this.
+     * @since 1.6.0
+     */
+    public Email setFromAddress(final InternetAddress fromAddress) {
+        this.fromAddress = fromAddress;
+        return this;
+
+    }
+
     /**
      * Sets the mail headers. Example:
      *
@@ -1284,7 +1536,7 @@ public abstract class Email {
      * Sets a mail Session object to use. Please note that passing a user name and password (in the case of mail authentication) will create a new mail session
      * with a DefaultAuthenticator. This is a convenience but might come unexpected.
      *
-     * If mail authentication is used but NO username and password is supplied the implementation assumes that you have set a authenticator and will use the
+     * If mail authentication is used but NO user name and password is supplied the implementation assumes that you have set a authenticator and will use the
      * existing mail session (as expected).
      *
      * @param session mail session to be used
@@ -1337,6 +1589,15 @@ public abstract class Email {
         setMailSession((Session) ctx.lookup(jndiName));
     }
 
+    /**
+     * Sets the MIME message.
+     *
+     * @param message the MIME message.
+     */
+    public void setMessage(final MimeMessage message) {
+        this.message = message;
+    }
+
     /**
      * Sets the content of the mail. It should be overridden by the subclasses.
      *
@@ -1348,19 +1609,71 @@ public abstract class Email {
     public abstract Email setMsg(String msg) throws EmailException;
 
     /**
-     * Sets details regarding "pop3 before SMTP" authentication.
+     * Sets whether to use POP3 before SMTP, and if so the settings.
      *
-     * @param popBeforeSmtp Whether or not to log into pop3 server before sending mail.
-     * @param popHost       The pop3 host to use.
-     * @param popUsername   The pop3 username.
-     * @param popPassword   The pop3 password.
+     * @param popBeforeSmtp whether to use POP3 before SMTP, and if so the settings.
+     * @return this.
+     * @since 1.6.0
+     */
+    public Email setPopBeforeSmtp(final boolean popBeforeSmtp) {
+        this.popBeforeSmtp = popBeforeSmtp;
+        return this;
+
+    }
+
+    /**
+     * Sets details regarding "POP3 before SMTP" authentication.
+     *
+     * @param popBeforeSmtp Whether or not to log into POP3 server before sending mail.
+     * @param popHost       The POP3 host to use.
+     * @param popUserName   The POP3 user name.
+     * @param popPassword   The POP3 password.
      * @since 1.0
      */
-    public void setPopBeforeSmtp(final boolean popBeforeSmtp, final String popHost, final String popUsername, final String popPassword) {
+    public void setPopBeforeSmtp(final boolean popBeforeSmtp, final String popHost, final String popUserName, final String popPassword) {
         this.popBeforeSmtp = popBeforeSmtp;
         this.popHost = popHost;
-        this.popUsername = popUsername;
+        this.popUsername = popUserName;
+        this.popPassword = popPassword;
+    }
+
+    /**
+     * Sets the POP3 host.
+     *
+     * @param popHost The POP3 host.
+     * @return this.
+     * @since 1.6.0
+     */
+    public Email setPopHost(final String popHost) {
+        this.popHost = popHost;
+        return this;
+
+    }
+
+    /**
+     * Sets the POP3 password.
+     *
+     * @param popPassword the POP3 password.
+     * @return this.
+     * @since 1.6.0
+     */
+    public Email setPopPassword(final String popPassword) {
         this.popPassword = popPassword;
+        return this;
+
+    }
+
+    /**
+     * Sets the POP3 user name.
+     *
+     * @param popUserName the POP3 user name.
+     * @return this.
+     * @since 1.6.0
+     */
+    public Email setPopUsername(final String popUserName) {
+        this.popUsername = popUserName;
+        return this;
+
     }
 
     /**
@@ -1483,8 +1796,8 @@ public abstract class Email {
     /**
      * Sets whether SSL/TLS encryption should be enabled for the SMTP transport upon connection (SMTPS/POPS). See EMAIL-105 for reason of deprecation.
      *
-     * @deprecated since 1.3, use setSSLOnConnect() instead
      * @param ssl whether to enable the SSL transport
+     * @deprecated since 1.3, use {@link #setSSLOnConnect(boolean)} instead.
      */
     @Deprecated
     public void setSSL(final boolean ssl) {
@@ -1583,9 +1896,9 @@ public abstract class Email {
     /**
      * Sets or disable the STARTTLS encryption. Please see EMAIL-105 for the reasons of deprecation.
      *
-     * @deprecated since 1.3, use setStartTLSEnabled() instead
      * @param withTLS true if STARTTLS requested, false otherwise
      * @since 1.1
+     * @deprecated since 1.3, use {@link #setStartTLSEnabled(boolean)} instead.
      */
     @Deprecated
     public void setTLS(final boolean withTLS) {
diff --git a/src/main/java/org/apache/commons/mail/HtmlEmail.java b/src/main/java/org/apache/commons/mail/HtmlEmail.java
index b5a8ff6..401839d 100644
--- a/src/main/java/org/apache/commons/mail/HtmlEmail.java
+++ b/src/main/java/org/apache/commons/mail/HtmlEmail.java
@@ -164,10 +164,18 @@ public class HtmlEmail extends MultiPartEmail {
 
     /**
      * Text part of the message. This will be used as alternative text if the email client does not support HTML messages.
+     *
+     * @deprecated Use getters and getters.
      */
+    @Deprecated
     protected String text;
 
-    /** HTML part of the message. */
+    /**
+     * HTML part of the message.
+     *
+     * @deprecated Use getters and getters.
+     */
+    @Deprecated
     protected String html;
 
     /**
@@ -178,7 +186,10 @@ public class HtmlEmail extends MultiPartEmail {
 
     /**
      * Embedded images Map&lt;String, InlineImage&gt; where the key is the user-defined image name.
+     *
+     * @deprecated Use getters and getters.
      */
+    @Deprecated
     protected Map<String, InlineImage> inlineEmbeds = new HashMap<>();
 
     /**
@@ -236,7 +247,7 @@ public class HtmlEmail extends MultiPartEmail {
 
             // EMAIL-104: call explicitly setText to use default mime charset
             // (property "mail.mime.charset") in case none has been set
-            msgHtml.setText(html, charset, EmailConstants.TEXT_SUBTYPE_HTML);
+            msgHtml.setText(html, getCharsetName(), EmailConstants.TEXT_SUBTYPE_HTML);
 
             // EMAIL-147: work-around for buggy JavaMail implementations;
             // in case setText(...) does not set the correct content type,
@@ -244,8 +255,8 @@ public class HtmlEmail extends MultiPartEmail {
             final String contentType = msgHtml.getContentType();
             if (contentType == null || !contentType.equals(EmailConstants.TEXT_HTML)) {
                 // apply default charset if one has been set
-                if (EmailUtils.isNotEmpty(charset)) {
-                    msgHtml.setContent(html, EmailConstants.TEXT_HTML + "; charset=" + charset);
+                if (EmailUtils.isNotEmpty(getCharsetName())) {
+                    msgHtml.setContent(html, EmailConstants.TEXT_HTML + "; charset=" + getCharsetName());
                 } else {
                     // unfortunately, MimeUtility.getDefaultMIMECharset() is package private
                     // and thus can not be used to set the default system charset in case
@@ -265,7 +276,7 @@ public class HtmlEmail extends MultiPartEmail {
 
             // EMAIL-104: call explicitly setText to use default mime charset
             // (property "mail.mime.charset") in case none has been set
-            msgText.setText(text, charset);
+            msgText.setText(text, getCharsetName());
         }
     }
 
@@ -493,6 +504,26 @@ public class HtmlEmail extends MultiPartEmail {
         return embed(new URLDataSource(url), name);
     }
 
+    /**
+     * Gets the HTML content.
+     *
+     * @return the HTML content.
+     * @since 1.6.0
+     */
+    public String getHtml() {
+        return html;
+    }
+
+    /**
+     * Gets the message text.
+     *
+     * @return the message text.
+     * @since 1.6.0
+     */
+    public String getText() {
+        return text;
+    }
+
     /**
      * Sets the HTML content.
      *
diff --git a/src/main/java/org/apache/commons/mail/ImageHtmlEmail.java b/src/main/java/org/apache/commons/mail/ImageHtmlEmail.java
index cb9d775..e2b71db 100644
--- a/src/main/java/org/apache/commons/mail/ImageHtmlEmail.java
+++ b/src/main/java/org/apache/commons/mail/ImageHtmlEmail.java
@@ -73,7 +73,7 @@ public class ImageHtmlEmail extends HtmlEmail {
     public void buildMimeMessage() throws EmailException {
         try {
             // embed all the matching image and script resources within the email
-            String temp = replacePattern(super.html, IMG_PATTERN);
+            String temp = replacePattern(getHtml(), IMG_PATTERN);
             temp = replacePattern(temp, SCRIPT_PATTERN);
             setHtmlMsg(temp);
             super.buildMimeMessage();
diff --git a/src/main/java/org/apache/commons/mail/MultiPartEmail.java b/src/main/java/org/apache/commons/mail/MultiPartEmail.java
index d93fb69..97ad9a4 100644
--- a/src/main/java/org/apache/commons/mail/MultiPartEmail.java
+++ b/src/main/java/org/apache/commons/mail/MultiPartEmail.java
@@ -417,8 +417,8 @@ public class MultiPartEmail extends Email {
         EmailException.checkNonEmpty(msg, () -> "Invalid message.");
         try {
             final BodyPart primary = getPrimaryBodyPart();
-            if (primary instanceof MimePart && EmailUtils.isNotEmpty(charset)) {
-                ((MimePart) primary).setText(msg, charset);
+            if (primary instanceof MimePart && EmailUtils.isNotEmpty(getCharsetName())) {
+                ((MimePart) primary).setText(msg, getCharsetName());
             } else {
                 primary.setText(msg);
             }
diff --git a/src/test/java/org/apache/commons/mail/EmailTest.java b/src/test/java/org/apache/commons/mail/EmailTest.java
index 2cc7435..a7f8f2a 100644
--- a/src/test/java/org/apache/commons/mail/EmailTest.java
+++ b/src/test/java/org/apache/commons/mail/EmailTest.java
@@ -604,11 +604,11 @@ public class EmailTest extends AbstractEmailTest {
     public void testGetSetCharset() {
         Charset set = StandardCharsets.US_ASCII;
         email.setCharset(set.name());
-        assertEquals(set.name(), email.getCharset());
+        assertEquals(set.name(), email.getCharsetName());
 
         set = StandardCharsets.UTF_8;
         email.setCharset(set.name());
-        assertEquals(set.name(), email.getCharset());
+        assertEquals(set.name(), email.getCharsetName());
     }
 
     @Test
@@ -767,7 +767,7 @@ public class EmailTest extends AbstractEmailTest {
         email.setHostName(strTestMailServer);
         email.setSmtpPort(getMailServerPort());
         email.addTo("me@home.com");
-        email.getSession().getProperties().setProperty(EmailConstants.MAIL_FROM, "me@home.com");
+        email.getMailSession().getProperties().setProperty(EmailConstants.MAIL_FROM, "me@home.com");
 
         email.send();
     }
@@ -830,7 +830,7 @@ public class EmailTest extends AbstractEmailTest {
         final MimeMultipart part = new MimeMultipart();
         email.setContent(part);
 
-        assertEquals(part, email.getContentMimeMultipart());
+        assertEquals(part, email.getEmailBody());
     }
 
     @Test
@@ -838,13 +838,13 @@ public class EmailTest extends AbstractEmailTest {
         final MimeMultipart part = new MimeMultipart("abc123");
         email.setContent(part);
 
-        assertEquals(part, email.getContentMimeMultipart());
+        assertEquals(part, email.getEmailBody());
     }
 
     @Test
     public void testSetContentNull() throws Exception {
         email.setContent(null);
-        assertNull(email.getContentMimeMultipart());
+        assertNull(email.getEmailBody());
     }
 
     @Test
@@ -854,7 +854,7 @@ public class EmailTest extends AbstractEmailTest {
         String testContentType = " ; charset=" + EmailConstants.US_ASCII;
 
         email.setContent(testObject, testContentType);
-        assertEquals(testObject, email.getContentObject());
+        assertEquals(testObject, email.getContent());
         assertEquals(testContentType, email.getContentType());
 
         // test (null string object and valid content type)
@@ -862,7 +862,7 @@ public class EmailTest extends AbstractEmailTest {
         testContentType = " ; charset=" + EmailConstants.US_ASCII + " some more here";
 
         email.setContent(testObject, testContentType);
-        assertEquals(testObject, email.getContentObject());
+        assertEquals(testObject, email.getContent());
         assertEquals(testContentType, email.getContentType());
 
         // test (string object and null content type)
@@ -870,7 +870,7 @@ public class EmailTest extends AbstractEmailTest {
         testContentType = null;
 
         email.setContent(testObject, testContentType);
-        assertEquals(testObject, email.getContentObject());
+        assertEquals(testObject, email.getContent());
         assertEquals(testContentType, email.getContentType());
 
         // test (string object and invalid content type)
@@ -878,7 +878,7 @@ public class EmailTest extends AbstractEmailTest {
         testContentType = " something incorrect ";
 
         email.setContent(testObject, testContentType);
-        assertEquals(testObject, email.getContentObject());
+        assertEquals(testObject, email.getContent());
         assertEquals(testContentType, email.getContentType());
     }
 
@@ -992,7 +992,7 @@ public class EmailTest extends AbstractEmailTest {
         // retrieve and verify
         assertEquals(boolPopBeforeSmtp, email.isPopBeforeSmtp());
         assertEquals(strHost, email.getPopHost());
-        assertEquals(strUsername, email.getPopUsername());
+        assertEquals(strUsername, email.getPopUserName());
         assertEquals(strPassword, email.getPopPassword());
     }
 
diff --git a/src/test/java/org/apache/commons/mail/HtmlEmailTest.java b/src/test/java/org/apache/commons/mail/HtmlEmailTest.java
index 5032ef4..6b77111 100644
--- a/src/test/java/org/apache/commons/mail/HtmlEmailTest.java
+++ b/src/test/java/org/apache/commons/mail/HtmlEmailTest.java
@@ -108,12 +108,12 @@ public class HtmlEmailTest extends AbstractEmailTest {
         fakeMailServer.stop();
 
         // validate html message
-        validateSend(fakeMailServer, strSubject, email.getHtmlMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getHtml(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), false);
 
         // make sure that no double dots show up
-        assertTrue(email.getHtmlMsg().contains("3DTZC268X93337.zip"));
-        assertFalse(email.getHtmlMsg().contains("3DTZC268X93337..zip"));
+        assertTrue(email.getHtml().contains("3DTZC268X93337.zip"));
+        assertFalse(email.getHtml().contains("3DTZC268X93337..zip"));
     }
 
     /**
@@ -291,7 +291,7 @@ public class HtmlEmailTest extends AbstractEmailTest {
         // Test Success
         for (final String validChar : testCharsValid) {
             email.setHtmlMsg(validChar);
-            assertEquals(validChar, email.getHtmlMsg());
+            assertEquals(validChar, email.getHtml());
         }
         // Test Exception
         for (final String invalidChar : testCharsNotValid) {
@@ -310,9 +310,9 @@ public class HtmlEmailTest extends AbstractEmailTest {
         // Test Success
         for (final String validChar : testCharsValid) {
             email.setMsg(validChar);
-            assertEquals(validChar, email.getTextMsg());
+            assertEquals(validChar, email.getText());
 
-            assertTrue(email.getHtmlMsg().contains(validChar));
+            assertTrue(email.getHtml().contains(validChar));
         }
         // Test Exception
         for (final String invalidChar : testCharsNotValid) {
@@ -331,7 +331,7 @@ public class HtmlEmailTest extends AbstractEmailTest {
         // Test Success
         for (final String validChar : testCharsValid) {
             email.setTextMsg(validChar);
-            assertEquals(validChar, email.getTextMsg());
+            assertEquals(validChar, email.getText());
         }
         // Test Exception
         for (final String invalidChar : testCharsNotValid) {
@@ -396,11 +396,11 @@ public class HtmlEmailTest extends AbstractEmailTest {
         email.send();
         fakeMailServer.stop();
         // validate txt message
-        validateSend(fakeMailServer, strSubject, email.getTextMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getText(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
 
         // validate html message
-        validateSend(fakeMailServer, strSubject, email.getHtmlMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getHtml(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), false);
 
         // validate attachment
@@ -426,7 +426,7 @@ public class HtmlEmailTest extends AbstractEmailTest {
         email.send();
         fakeMailServer.stop();
         // validate txt message
-        validateSend(fakeMailServer, strSubject, email.getTextMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getText(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
     }
 
@@ -453,11 +453,11 @@ public class HtmlEmailTest extends AbstractEmailTest {
         email.send();
         fakeMailServer.stop();
         // validate txt message
-        validateSend(fakeMailServer, strSubject, email.getTextMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getText(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
 
         // validate html message
-        validateSend(fakeMailServer, strSubject, email.getHtmlMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getHtml(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), false);
 
         getMailServer();
@@ -480,11 +480,11 @@ public class HtmlEmailTest extends AbstractEmailTest {
         email.send();
         fakeMailServer.stop();
         // validate txt message
-        validateSend(fakeMailServer, strSubject, email.getTextMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getText(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
 
         // validate html message
-        validateSend(fakeMailServer, strSubject, email.getHtmlMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getHtml(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), false);
 
     }
@@ -550,7 +550,7 @@ public class HtmlEmailTest extends AbstractEmailTest {
         fakeMailServer.stop();
 
         // validate text message
-        validateSend(fakeMailServer, strSubject, email.getTextMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getText(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
     }
 }
diff --git a/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java b/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java
index 65e0156..4e67e5c 100644
--- a/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java
+++ b/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java
@@ -116,7 +116,7 @@ public class ImageHtmlEmailTest extends HtmlEmailTest {
 
         fakeMailServer.stop();
         // validate txt message
-        validateSend(fakeMailServer, strSubject, email.getHtmlMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getHtml(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
     }
 
@@ -335,7 +335,7 @@ public class ImageHtmlEmailTest extends HtmlEmailTest {
 
         fakeMailServer.stop();
         // validate txt message
-        validateSend(fakeMailServer, strSubject, email.getHtmlMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getHtml(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
     }
 
@@ -488,7 +488,7 @@ public class ImageHtmlEmailTest extends HtmlEmailTest {
 
         fakeMailServer.stop();
         // validate txt message
-        validateSend(fakeMailServer, strSubject, email.getHtmlMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getHtml(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
     }
 }
diff --git a/src/test/java/org/apache/commons/mail/SendWithAttachmentsTest.java b/src/test/java/org/apache/commons/mail/SendWithAttachmentsTest.java
index d5a4837..fb7a950 100644
--- a/src/test/java/org/apache/commons/mail/SendWithAttachmentsTest.java
+++ b/src/test/java/org/apache/commons/mail/SendWithAttachmentsTest.java
@@ -74,11 +74,11 @@ public class SendWithAttachmentsTest extends AbstractEmailTest {
         fakeMailServer.stop();
 
         // validate txt message
-        validateSend(fakeMailServer, strSubject, email.getTextMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getText(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
 
         // validate html message
-        validateSend(fakeMailServer, strSubject, email.getHtmlMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getHtml(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), false);
     }
 
@@ -124,11 +124,11 @@ public class SendWithAttachmentsTest extends AbstractEmailTest {
         email.send();
         fakeMailServer.stop();
         // validate txt message
-        validateSend(fakeMailServer, strSubject, email.getTextMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getText(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
 
         // validate html message
-        validateSend(fakeMailServer, strSubject, email.getHtmlMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getHtml(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), false);
 
         // validate attachment
diff --git a/src/test/java/org/apache/commons/mail/SimpleEmailTest.java b/src/test/java/org/apache/commons/mail/SimpleEmailTest.java
index e1a8852..2720a7c 100644
--- a/src/test/java/org/apache/commons/mail/SimpleEmailTest.java
+++ b/src/test/java/org/apache/commons/mail/SimpleEmailTest.java
@@ -73,7 +73,7 @@ public class SimpleEmailTest extends AbstractEmailTest {
 
         fakeMailServer.stop();
 
-        validateSend(fakeMailServer, strSubject, email.getMsg().substring(0, 13), // only check the start, the ä will be encoded
+        validateSend(fakeMailServer, strSubject, email.getContentAsString().substring(0, 13), // only check the start, the ä will be encoded
                 email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(), email.getBccAddresses(), true);
 
         final String message = getMessageAsString(0);
@@ -88,7 +88,7 @@ public class SimpleEmailTest extends AbstractEmailTest {
         // Test Success
         for (final String validChar : testCharsValid) {
             email.setMsg(validChar);
-            assertEquals(validChar, email.getMsg());
+            assertEquals(validChar, email.getContentAsString());
         }
         // Test Exception
         for (final String invalidChar : testCharsNotValid) {
@@ -132,7 +132,7 @@ public class SimpleEmailTest extends AbstractEmailTest {
         email.send();
 
         fakeMailServer.stop();
-        validateSend(fakeMailServer, strSubject, email.getMsg(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
+        validateSend(fakeMailServer, strSubject, email.getContentAsString(), email.getFromAddress(), email.getToAddresses(), email.getCcAddresses(),
                 email.getBccAddresses(), true);
     }
 }
diff --git a/src/test/java/org/apache/commons/mail/mocks/MockEmailConcrete.java b/src/test/java/org/apache/commons/mail/mocks/MockEmailConcrete.java
index 138c80c..7626894 100644
--- a/src/test/java/org/apache/commons/mail/mocks/MockEmailConcrete.java
+++ b/src/test/java/org/apache/commons/mail/mocks/MockEmailConcrete.java
@@ -16,13 +16,7 @@
  */
 package org.apache.commons.mail.mocks;
 
-import javax.mail.Authenticator;
-import javax.mail.Session;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMultipart;
-
 import org.apache.commons.mail.Email;
-import org.apache.commons.mail.EmailException;
 
 /**
  * Concrete Implementation on the Abstract Email Class (used to allow testing only). Supplies getters for methods that normally only have setters.
@@ -32,120 +26,16 @@ import org.apache.commons.mail.EmailException;
 public class MockEmailConcrete extends Email {
 
     /**
-     * Retrieve the current authentication setting
-     *
-     * @return Authenticator Authenticator
-     */
-    public Authenticator getAuthenticator() {
-        return authenticator;
-    }
-
-    /**
-     * @return charset
-     */
-    public String getCharset() {
-        return charset;
-    }
-
-    /**
-     * @return content
-     */
-    public MimeMultipart getContentMimeMultipart() {
-        return emailBody;
-    }
-
-    /**
-     * @return content
-     */
-    public Object getContentObject() {
-        return content;
-    }
-
-    /**
-     * @return contentType
-     */
-    public String getContentType() {
-        return contentType;
-    }
-
-    /**
-     * @return emailBody
-     */
-    public MimeMultipart getEmailBody() {
-        return emailBody;
-    }
-
-    /**
-     * @return hostName
-     */
-    @Override
-    public String getHostName() {
-        return hostName;
-    }
-
-    /**
-     * @return message
-     */
-    public MimeMessage getMessage() {
-        return message;
-    }
-
-    /**
-     * @return popHost
-     */
-    public String getPopHost() {
-        return popHost;
-    }
-
-    /**
-     * @return popPassword
-     */
-    public String getPopPassword() {
-        return popPassword;
-    }
-
-    /**
-     * @return popUsername
-     */
-    public String getPopUsername() {
-        return popUsername;
-    }
-
-    /**
-     * @return Session
-     * @throws EmailException EmailException
-     */
-    public Session getSession() throws EmailException {
-        return getMailSession();
-    }
-
-    /**
-     * Retrieve the current debug setting
-     *
-     * @return debug
-     */
-    public boolean isDebug() {
-        return debug;
-    }
-
-    /**
-     * @return popBeforeSmtp
-     */
-    public boolean isPopBeforeSmtp() {
-        return popBeforeSmtp;
-    }
-
-    /**
-     * Not Implemented, should be implemented in subclasses of Email
+     * No-op for testing.
      *
-     * @param msg The email message
+     * @param msg The email message.
      * @return Email msg.
      */
     @Override
     public Email setMsg(final String msg) {
         // This abstract method should be tested in the concrete
         // implementation classes only.
-        return null;
+        return this;
     }
 
 }
diff --git a/src/test/java/org/apache/commons/mail/mocks/MockHtmlEmailConcrete.java b/src/test/java/org/apache/commons/mail/mocks/MockHtmlEmailConcrete.java
index 40afc4e..9d61abd 100644
--- a/src/test/java/org/apache/commons/mail/mocks/MockHtmlEmailConcrete.java
+++ b/src/test/java/org/apache/commons/mail/mocks/MockHtmlEmailConcrete.java
@@ -19,7 +19,6 @@ package org.apache.commons.mail.mocks;
 import java.io.IOException;
 
 import javax.mail.MessagingException;
-import javax.mail.internet.InternetAddress;
 
 import org.apache.commons.mail.HtmlEmail;
 
@@ -30,23 +29,6 @@ import org.apache.commons.mail.HtmlEmail;
  */
 public class MockHtmlEmailConcrete extends HtmlEmail {
 
-    /**
-     * @return fromAddress
-     */
-    @Override
-    public InternetAddress getFromAddress() {
-        return fromAddress;
-    }
-
-    /**
-     * Retrieve the html msg
-     *
-     * @return Message Content
-     */
-    public String getHtmlMsg() {
-        return html;
-    }
-
     /**
      * Retrieve the message content
      *
@@ -60,13 +42,4 @@ public class MockHtmlEmailConcrete extends HtmlEmail {
         }
     }
 
-    /**
-     * Retrieve the text msg
-     *
-     * @return Message Content
-     */
-    public String getTextMsg() {
-        return text;
-    }
-
 }
diff --git a/src/test/java/org/apache/commons/mail/mocks/MockImageHtmlEmailConcrete.java b/src/test/java/org/apache/commons/mail/mocks/MockImageHtmlEmailConcrete.java
index 2a9d260..e263aae 100644
--- a/src/test/java/org/apache/commons/mail/mocks/MockImageHtmlEmailConcrete.java
+++ b/src/test/java/org/apache/commons/mail/mocks/MockImageHtmlEmailConcrete.java
@@ -26,14 +26,6 @@ import org.apache.commons.mail.ImageHtmlEmail;
  * Extension of the ImageHtmlEmail Class (used to allow testing only)
  */
 public class MockImageHtmlEmailConcrete extends ImageHtmlEmail {
-    /**
-     * Retrieve the html msg
-     *
-     * @return Message Content
-     */
-    public String getHtmlMsg() {
-        return html;
-    }
 
     /**
      * Retrieve the message content
diff --git a/src/test/java/org/apache/commons/mail/mocks/MockMultiPartEmailConcrete.java b/src/test/java/org/apache/commons/mail/mocks/MockMultiPartEmailConcrete.java
index f1676f5..22820ed 100644
--- a/src/test/java/org/apache/commons/mail/mocks/MockMultiPartEmailConcrete.java
+++ b/src/test/java/org/apache/commons/mail/mocks/MockMultiPartEmailConcrete.java
@@ -19,8 +19,6 @@ package org.apache.commons.mail.mocks;
 import java.io.IOException;
 
 import javax.mail.MessagingException;
-import javax.mail.internet.InternetAddress;
-
 import org.apache.commons.mail.MultiPartEmail;
 
 /**
@@ -30,14 +28,6 @@ import org.apache.commons.mail.MultiPartEmail;
  */
 public class MockMultiPartEmailConcrete extends MultiPartEmail {
 
-    /**
-     * @return fromAddress
-     */
-    @Override
-    public InternetAddress getFromAddress() {
-        return fromAddress;
-    }
-
     /**
      * Retrieve the message content
      *
diff --git a/src/test/java/org/apache/commons/mail/mocks/MockSimpleEmail.java b/src/test/java/org/apache/commons/mail/mocks/MockSimpleEmail.java
index a5b5476..dfce043 100644
--- a/src/test/java/org/apache/commons/mail/mocks/MockSimpleEmail.java
+++ b/src/test/java/org/apache/commons/mail/mocks/MockSimpleEmail.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.mail.mocks;
 
-import javax.mail.internet.InternetAddress;
-
 import org.apache.commons.mail.SimpleEmail;
 
 /**
@@ -26,20 +24,13 @@ import org.apache.commons.mail.SimpleEmail;
  * @since 1.0
  */
 public class MockSimpleEmail extends SimpleEmail {
-    /**
-     * @return fromAddress
-     */
-    @Override
-    public InternetAddress getFromAddress() {
-        return fromAddress;
-    }
 
     /**
      * Retrieve the message content
      *
      * @return Message Content
      */
-    public String getMsg() {
+    public String getContentAsString() {
         return (String) content;
     }