You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/06/18 07:53:28 UTC

svn commit: r785916 - in /camel/branches/camel-1.x/components/camel-mail/src: main/java/org/apache/camel/component/mail/ test/java/org/apache/camel/component/mail/

Author: davsclaus
Date: Thu Jun 18 05:53:28 2009
New Revision: 785916

URL: http://svn.apache.org/viewvc?rev=785916&view=rev
Log:
CAMEL-1727: alternative body header should not be included in mime mail as header also.

Modified:
    camel/branches/camel-1.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
    camel/branches/camel-1.x/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeResolverTest.java
    camel/branches/camel-1.x/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeTest.java

Modified: camel/branches/camel-1.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java?rev=785916&r1=785915&r2=785916&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java (original)
+++ camel/branches/camel-1.x/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java Thu Jun 18 05:53:28 2009
@@ -41,7 +41,6 @@
 import org.apache.camel.impl.DefaultHeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.CollectionHelper;
-import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -87,7 +86,7 @@
         }
 
         // append the rest of the headers (no recipients) that could be subject, reply-to etc.
-        appendHeadersFromCamelMessage(mimeMessage, exchange, exchange.getIn());
+        appendHeadersFromCamelMessage(mimeMessage, endpoint.getConfiguration(), exchange, exchange.getIn());
 
         if (empty(mimeMessage.getFrom())) {
             // lets default the address to the endpoint destination
@@ -137,7 +136,7 @@
     /**
      * Appends the Mail headers from the Camel {@link MailMessage}
      */
-    protected void appendHeadersFromCamelMessage(MimeMessage mimeMessage, Exchange exchange,
+    protected void appendHeadersFromCamelMessage(MimeMessage mimeMessage, MailConfiguration configuration, Exchange exchange,
                                                  org.apache.camel.Message camelMessage)
         throws MessagingException {
 
@@ -153,6 +152,12 @@
                         continue;
                     }
 
+                    // alternative body should also be skipped
+                    if (headerName.equalsIgnoreCase(configuration.getAlternateBodyHeader())) {
+                        // skip alternative body
+                        continue;
+                    }
+
                     // Mail messages can repeat the same header...
                     if (ObjectConverter.isCollection(headerValue)) {
                         Iterator iter = ObjectConverter.iterator(headerValue);

Modified: camel/branches/camel-1.x/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeResolverTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeResolverTest.java?rev=785916&r1=785915&r2=785916&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeResolverTest.java (original)
+++ camel/branches/camel-1.x/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailContentTypeResolverTest.java Thu Jun 18 05:53:28 2009
@@ -51,7 +51,7 @@
         producer.process(exchange);
 
         // need some time for the mail to arrive on the inbox (consumed and sent to the mock)
-        Thread.sleep(1000);
+        Thread.sleep(4000);
 
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);

Modified: camel/branches/camel-1.x/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeTest.java?rev=785916&r1=785915&r2=785916&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeTest.java (original)
+++ camel/branches/camel-1.x/components/camel-mail/src/test/java/org/apache/camel/component/mail/MimeMultipartAlternativeTest.java Thu Jun 18 05:53:28 2009
@@ -36,7 +36,7 @@
     private String htmlBody = "<html><body><h1>Hello</h1>World<img src=\"cid:0001\"></body></html>";
 
     private void sendMultipartEmail(boolean useInlineattachments) throws Exception {
-     // create an exchange with a normal body and attachment to be produced as email
+        // create an exchange with a normal body and attachment to be produced as email
         MailEndpoint endpoint = context.getEndpoint("smtp://ryan@mymailserver.com?password=secret", MailEndpoint.class);
         endpoint.getConfiguration().setUseInlineAttachments(useInlineattachments);
         endpoint.getConfiguration().setAlternateBodyHeader(MailConfiguration.DEFAULT_ALTERNATE_BODY_HEADER);
@@ -56,7 +56,6 @@
         producer.process(exchange); 
         
         producer.stop();
-
     }
     
     private void verifyTheRecivedEmail(String expectString) throws Exception {
@@ -65,6 +64,8 @@
 
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
+        // this header should be removed
+        mock.message(0).header(MailConfiguration.DEFAULT_ALTERNATE_BODY_HEADER).isNull();
         Exchange out = mock.assertExchangeReceived(0);
         mock.assertIsSatisfied();
 
@@ -84,9 +85,8 @@
         assertNotNull("Should not have null attachments", attachments);
         assertEquals(1, attachments.size());
         assertEquals("multipart body should have 2 parts", 2, out.getIn().getBody(MimeMultipart.class).getCount());
-
-        
     }
+
     public void testMultipartEmailWithInlineAttachments() throws Exception {
         sendMultipartEmail(true);
         verifyTheRecivedEmail("Content-Disposition: inline; filename=\"cid:0001\"");