camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Camel-Mail: Subject cannot handle unicode chars?
Date Fri, 28 May 2010 03:42:01 GMT
Hi,

In camel you can get the Charset information from exchange, I just 
created a JIRA[1] for it, it should be easy to fix.

[1]https://issues.apache.org/activemq/browse/CAMEL-2763

Willem


tide08 wrote:
> It looks like camel-mail cannot handle unicode chars in subject header? I
> have something like below and subject does not appear correctly in mail
> client -
> 
>     @Test
>     public void testMailSubjectWithUnicode() throws Exception {
>         Mailbox.clearAll();
> 
>         String body = "Hello Camel Riders!";
>         String subject = "My Camel \u2122";     
> 
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedMessageCount(1);
>         //mock.expectedHeaderReceived("subject", "My_Camel_=AA");
>         mock.expectedBodiesReceived(body);
> 
>         template.sendBodyAndHeader("direct:a", body, "subject", subject);
> 
>         mock.assertIsSatisfied();
> 
>         assertFalse("Should not have attachements",
> mock.getExchanges().get(0).getIn().hasAttachments());
>     }
> 
> I tried looking into fix but I am exactly not sure if I have the right fix.
> It looks like in MailBinding class subject is not added using correct method
> -
> 
> mimeMessage.setHeader(headerName, asString(exchange, headerValue));
> 
> but should instead be? 
> 
> mimeMessage.setSubject(asString(exchange, headerValue));
> 
> Looking at JavaDoc and source it looks like setSubject() method will
> actually find right encoder and do the encoding for subject. I made changes
> to mailBinding and it indeed fixed it but looks like it uses platform
> specific encoding so was confused if that is right approach, any ideas?
> 
> Also, platform specific encoding may make unit testing difficult?
> 
> 
> Thanks!
> 
> 
> 
> 
> 
> 


Mime
View raw message