[ 
https://issues.apache.org/jira/browse/CAMEL-12062?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16277761#comment-16277761
 ] 

ASF GitHub Bot commented on CAMEL-12062:
----------------------------------------

GitHub user IIlllII opened a pull request:

    https://github.com/apache/camel/pull/2130

    CAMEL-12062:  Propagate encoding in charset property from jaxb component

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/IIlllII/camel master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/camel/pull/2130.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2130
    
----
commit 64169aed7e0c8f07853565fac4e9822f26c83647
Author: Jonas Waage <[email protected]>
Date:   2017-12-04T23:34:55Z

    CAMEL-12062 Propagate encoding in property

----


> Jaxb component does not communicate charset when explicitly set
> ---------------------------------------------------------------
>
>                 Key: CAMEL-12062
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12062
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jaxb
>    Affects Versions: 2.20.1
>            Reporter: Jonas Waage
>            Priority: Minor
>
> This test will cause a UnmappableCharacterException, since jaxb does not 
> communicate the encoding of the bytes it outputs causing the file endpoint to 
> assume it is UTF-8.
> This can be mitigated by adding an explicit reader in the route, but it would 
> be nice if it worked OOTB.
> {code:java}
> /**
>  * @version 
>  */
> public class ExplicitFileEncodingTest extends CamelTestSupport {
>     @Override
>     public void setUp() throws Exception {
>         deleteDirectory("target/charset");
>         super.setUp();
>     }
>     @Test
>     public void testISOFileEncoding() throws Exception {
>         PurchaseOrder order = new PurchaseOrder();
>         //Data containing characters ÆØÅæøå that differ in utf-8 and iso
>         String name = "\u00c6\u00d8\u00C5\u00e6\u00f8\u00e5";
>         order.setName(name);
>         order.setAmount(123.45);
>         order.setPrice(2.22);
>         MockEndpoint result = getMockEndpoint("mock:file");
>         result.expectedFileExists("target/charset/output.txt");
>         template.sendBody("direct:start", order);
>         assertMockEndpointsSatisfied();
>         JAXBContext jaxbContext = 
> JAXBContext.newInstance("org.apache.camel.example");
>         Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
>         PurchaseOrder obj = (PurchaseOrder)unmarshaller.unmarshal(new 
> File("target/charset/output.txt"));
>         assertEquals(obj.getName(), name);
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 JaxbDataFormat jaxb = new 
> JaxbDataFormat("org.apache.camel.example");
>                 jaxb.setEncoding("iso-8859-1");
>                 from("direct:start")
>                         .marshal(jaxb)
>                         
> .to("file:target/charset/?fileName=output.txt&charset=iso-8859-1");
>             }
>         };
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to