camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1215233 - /camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeTest.java
Date Fri, 16 Dec 2011 17:57:44 GMT
Author: cmueller
Date: Fri Dec 16 17:57:44 2011
New Revision: 1215233

URL: http://svn.apache.org/viewvc?rev=1215233&view=rev
Log:
added unit test for sending multipart mail messages

Modified:
    camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeTest.java

Modified: camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeTest.java?rev=1215233&r1=1215232&r2=1215233&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeTest.java
(original)
+++ camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeTest.java
Fri Dec 16 17:57:44 2011
@@ -16,7 +16,11 @@
  */
 package org.apache.camel.component.mail;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.mail.Message;
+import javax.mail.internet.MimeMultipart;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit4.CamelTestSupport;
@@ -52,12 +56,28 @@ public class MailContentTypeTest extends
         assertTrue(msg.getContentType().startsWith("text/plain"));
         assertEquals("Hello World", msg.getContent());
     }
+    
+    @Test
+    public void testSendMultipartMail() throws Exception {
+        Mailbox.clearAll();
+
+        Map<String, Object> headers = new HashMap<String, Object>();
+        headers.put(MailConstants.MAIL_ALTERNATIVE_BODY, "Hello World");
+        sendBody("direct:c", "<html><body><h1>Hello</h1>World</body></html>",
headers);
+
+        Mailbox box = Mailbox.get("claus@localhost");
+        Message msg = box.get(0);
+        assertTrue(msg.getContentType().startsWith("multipart/alternative"));
+        assertEquals("Hello World", ((MimeMultipart) msg.getContent()).getBodyPart(0).getContent());
+        assertEquals("<html><body><h1>Hello</h1>World</body></html>",
((MimeMultipart) msg.getContent()).getBodyPart(1).getContent());
+    }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
                 from("direct:a").to("smtp://claus@localhost?contentType=text/html");
                 from("direct:b").to("smtp://claus@localhost?contentType=text/plain");
+                from("direct:c").to("smtp://claus@localhost");
             }
         };
     }



Mime
View raw message