[mule-scm] [mule][25298] branches/mule-3.2.x: Merged revisions 25294 via svnmerge from

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[mule-scm] [mule][25298] branches/mule-3.2.x: Merged revisions 25294 via svnmerge from

damian.bakarcic
[mule][25298] branches/mule-3.2.x: Merged revisions 25294 via svnmerge from
Revision
25298
Author
damian.bakarcic
Date
2013-02-22 06:12:30 -0600 (Fri, 22 Feb 2013)

Log Message

Merged revisions 25294 via svnmerge from 
https://svn.codehaus.org/mule/branches/mule-3.1.x

........
  r25294 | damian.bakarcic | 2013-02-21 16:17:15 -0300 (Thu, 21 Feb 2013) | 5 lines
  
  MULE-6690: StringToEmailMessage doesn't encode subject correctly
  
  - Added the transformer output encoding to the message subject when the MimeMessage is being constructed inside the StringToEmailMessage transformer. 
........

Modified Paths

Property Changed

Diff

Property changes: branches/mule-3.2.x


Modified: svnmerge-integrated

+ /branches/mule-3.1.x:1-22948,22951-22954,22958-22985,22989-22992,23002,23005,23009-23013,23016,23021,23023,23032,23037,23042-23043,23046,23050,23076,23079,23085,23089,23100-23101,23106,23109-23114,23121,23127-23128,23134,23143,23163-23314,23316-23322,23324-23403,23405-23422,23424-23426,23428-23429,23431-23582,23584-23586,23588-23589,23591-23619,23627-23638,23640-23650,23653-23654,23659-23661,23672,23674,23679-23680,23684,23693,23700,23709-23710,23713,23734-23735,23749,23753,23758,23761,23777,23787,23800,23818,23826,23841-23842,23859-23860,23864,23872,23884,23899,23907,23935,24072,24097,24118,24202,24301,24318,24349,24354,24362,24370,24388,24414,24466,24470,24482,24486,24525,24529,24533,24537-24538,24547,24570,24577,24581,24586,24595,24599,24609,24619,24623-24624,24634,24665,24677-24679,24705,24709-24711,24739,24742,24749-24751,24851,24874,24891,24914,24956,24959,24969,24980,24988-24989,25042,25063,25095,25154,25195,25198,25225,25232,25294

Modified: svn:mergeinfo

/branches/mule-3.1.x:23002,23163,23431,23435-23436,23454-23455,23459,23471,23475,23499,23506,23509,23516,23530,23550,23596,23610,23616,23618-23619,23627-23631,23634,23644,23647-23648,23653-23654,23659-23661,23672,23674,23679-23680,23684,23693,23700,23709-23710,23713,23734-23735,23749,23753,23761,23777,23800,23818,23859-23860,23864,23872,23884,23899,23907,23935,24072,24097,24118,24202,24301,24318,24349,24354,24362,24370,24388,24414,24466,24470,24482,24486,24525,24529,24533,24537-24538,24547,24570,24577,24586,24595,24599,24609,24619,24623-24624,24634,24665,24677-24679,24705,24709-24711,24739,24742,24749-24751,24851,24874,24891,24914,24956,24959,24969,24980,24988-24989,25042,25063,25095,25195,25198,25225,25232 + /branches/mule-2.2.x:23434 /branches/mule-3.1.x:23002,23163,23431,23435-23436,23454-23455,23459,23471,23475,23499,23506,23509,23516,23530,23550,23596,23610,23616,23618-23619,23627-23631,23634,23644,23647-23648,23653-23654,23659-23661,23672,23674,23679-23680,23684,23693,23700,23709-23710,23713,23734-23735,23749,23753,23761,23777,23800,23818,23859-23860,23864,23872,23884,23899,23907,23935,24072,24097,24118,24202,24301,24318,24349,24354,24362,24370,24388,24414,24466,24470,24482,24486,24525,24529,24533,24537-24538,24547,24570,24577,24586,24595,24599,24609,24619,24623-24624,24634,24665,24677-24679,24705,24709-24711,24739,24742,24749-24751,24851,24874,24891,24914,24956,24959,24969,24980,24988-24989,25042,25063,25095,25195,25198,25225,25232,25294

Modified: branches/mule-3.2.x/transports/email/src/main/java/org/mule/transport/email/transformers/StringToEmailMessage.java (25297 => 25298)


--- branches/mule-3.2.x/transports/email/src/main/java/org/mule/transport/email/transformers/StringToEmailMessage.java	2013-02-21 20:59:41 UTC (rev 25297)
+++ branches/mule-3.2.x/transports/email/src/main/java/org/mule/transport/email/transformers/StringToEmailMessage.java	2013-02-22 12:12:30 UTC (rev 25298)
@@ -112,7 +112,7 @@
 
         try
         {
-            Message email = new MimeMessage(((SmtpConnector) endpoint.getConnector()).getSessionDetails(endpoint).getSession());
+            MimeMessage email = new MimeMessage(((SmtpConnector) endpoint.getConnector()).getSessionDetails(endpoint).getSession());
 
             email.setRecipients(Message.RecipientType.TO, MailUtils.stringToInternetAddresses(to));
 
@@ -139,7 +139,7 @@
                 email.setReplyTo(MailUtils.stringToInternetAddresses(replyTo));
             }
 
-            email.setSubject(subject);
+            email.setSubject(subject, outputEncoding);
 
             for (Iterator iterator = headers.entrySet().iterator(); iterator.hasNext();)
             {

Modified: branches/mule-3.2.x/transports/email/src/test/java/org/mule/transport/email/transformers/MailMessageTransformersNonAsciiTestCase.java (25297 => 25298)


--- branches/mule-3.2.x/transports/email/src/test/java/org/mule/transport/email/transformers/MailMessageTransformersNonAsciiTestCase.java	2013-02-21 20:59:41 UTC (rev 25297)
+++ branches/mule-3.2.x/transports/email/src/test/java/org/mule/transport/email/transformers/MailMessageTransformersNonAsciiTestCase.java	2013-02-22 12:12:30 UTC (rev 25298)
@@ -10,12 +10,27 @@
 
 package org.mule.transport.email.transformers;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.mule.DefaultMuleMessage;
+import org.mule.api.MuleMessage;
+import org.mule.api.transformer.Transformer;
 import org.mule.config.i18n.LocaleMessageHandler;
+import org.mule.transport.email.MailProperties;
 
+import java.util.HashMap;
 import java.util.Locale;
+import java.util.Map;
 
+import javax.mail.internet.MimeMessage;
+
+import org.junit.Test;
+
 public class MailMessageTransformersNonAsciiTestCase extends MailMessageTransformersTestCase
 {
+
     @Override
     protected String getContentType() 
     {
@@ -28,4 +43,27 @@
         return LocaleMessageHandler.getString("test-data", Locale.JAPAN,
             "MailMessageTransformersNonAsciiTestCase.getResultData", new Object[] {});
     }
+
+    @Test
+    public void testNonAsciiSubjectEncodingInRoundtripTransformation() throws Exception
+    {
+        Transformer roundTripTransformer = super.getRoundTripTransformer();
+
+        // Build message setting the non-ascii message subject as a property for the transformer.
+        Map<String, Object> outboundProperties = new HashMap<String, Object>();
+        String testSubject = (String) getResultData();
+        outboundProperties.put(MailProperties.SUBJECT_PROPERTY, testSubject);
+        MuleMessage message = new DefaultMuleMessage(testSubject, outboundProperties, muleContext);
+
+        // Hack to set the default charset used by the javax.mail API to perform the mail subject encoding as iso-8859-1.
+        System.setProperty("mail.mime.charset", "iso-8859-1");
+
+        // Transform.
+        Object result = roundTripTransformer.transform(message, "iso-2022-jp");
+
+        assertNotNull("The result of the roundtrip transform shouldn't be null", result);
+        assertTrue(result instanceof MimeMessage);
+        // Assert that the mail subject has been correctly encoded in iso-2022-jp.
+        assertEquals(((MimeMessage) result).getSubject(), testSubject);
+    }
 }

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email