commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1692733 - in /commons/proper/email/trunk/src: changes/changes.xml main/java/org/apache/commons/mail/Email.java test/java/org/apache/commons/mail/EmailTest.java
Date Sun, 26 Jul 2015 17:42:48 GMT
Author: ggregory
Date: Sun Jul 26 17:42:48 2015
New Revision: 1692733

URL: http://svn.apache.org/r1692733
Log:
[EMAIL-154] Add Email#getHeader(String) and Email#getHeaders() methods.

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=1692733&r1=1692732&r2=1692733&view=diff
==============================================================================
--- commons/proper/email/trunk/src/changes/changes.xml (original)
+++ commons/proper/email/trunk/src/changes/changes.xml Sun Jul 26 17:42:48 2015
@@ -22,6 +22,11 @@
   </properties>
 
   <body>
+    <release version="1.5" date="2015-MM-DD">
+      <action dev="ggregory" type="add" issue="EMAIL-154" date="2015-07-26" due-to="Ken
Geis, Balachandran Sivakumar">
+        Add Email#getHeader(String) and Email#getHeaders() methods
+      </action>
+    </release>
     <release version="1.4" date="2015-05-23">
       <action dev="tn" type="fix" issue="EMAIL-149" date="2015-03-10" due-to="Richard
DiCroce">
         "Email" threw an "EmailException" when trying to send the email if neither a from

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=1692733&r1=1692732&r2=1692733&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 Sun Jul 26
17:42:48 2015
@@ -1202,6 +1202,27 @@ public abstract class Email
     }
 
     /**
+     * Gets the specified header.
+     *
+     * @param header A string with the header. 
+     * @return The value of the header, or null if no such header.
+     */
+    public String getHeader(final String header)
+    {
+        return headers.get(header);
+    }
+
+    /**
+     * Gets all headers on an Email.
+     *
+     * @return a Map of all headers.
+     */
+    public Map<String, String> getHeaders()
+    {
+        return this.headers;
+    }
+    
+    /**
      * Set the email subject.
      *
      * @param aSubject A String.

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=1692733&r1=1692732&r2=1692733&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 Sun Jul
26 17:42:48 2015
@@ -890,6 +890,31 @@ public class EmailTest extends AbstractE
     }
 
     @Test
+    public void testGetHeader()
+    {
+        final Map<String, String> ht = new Hashtable<String, String>();
+        ht.put("X-Foo", "Bar");
+        ht.put("X-Int", "1");
+
+        email.setHeaders(ht);
+
+        assertEquals("Bar", email.getHeader("X-Foo"));
+        assertEquals("1", email.getHeader("X-Int"));
+    }
+
+    @Test
+    public void testGetHeaders()
+    {
+        final Map<String, String> ht = new Hashtable<String, String>();
+        ht.put("X-Foo", "Bar");
+        ht.put("X-Int", "1");
+
+        email.setHeaders(ht);
+
+        assertEquals(ht.size(), email.getHeaders().size());
+    }
+    
+    @Test
     public void testFoldingHeaders() throws Exception
     {
         email.setHostName(strTestMailServer);



Mime
View raw message