camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephan Siano (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-6854) Type conversion between DOMSource and InputStream breaks on Windows
Date Fri, 11 Oct 2013 11:47:42 GMT

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

Stephan Siano commented on CAMEL-6854:
--------------------------------------

Wouldn't changing lines 834 and 848 of XMLConverter class to
        return new ByteArrayInputStream(s.getBytes("UTF-8"));

fix this issue? (hardcoded UTF-8 no matter what the default encoding is)

Or would this have side effects?

> Type conversion between DOMSource and InputStream breaks on Windows
> -------------------------------------------------------------------
>
>                 Key: CAMEL-6854
>                 URL: https://issues.apache.org/jira/browse/CAMEL-6854
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.10.7, 2.11.2, 2.12.1
>         Environment: Windows
>            Reporter: Stephan Siano
>         Attachments: XMLTypeConverterTest.txt
>
>
> The type conversion between DomSource and InputStream will destroy non-ascii characters
if the default charset is not UTF-8.
> Therefore the following test will work on Linux (and in my Eclipse on Windows) where
the default charset is UTF-8, but it will not work if invoked from the command line (maven)
when the default charset is not UTF-8.
> I will also get similar issues if the type converter are implicitly called by endpoints
(the real use case was to read the output of a camel-cxf endpoint as an InputStream).
> import java.io.InputStream;
> import javax.xml.transform.dom.DOMSource;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.test.junit4.CamelTestSupport;
> import org.junit.Test;
> public class XMLTypeConverterTest extends CamelTestSupport {
>     @Test
>     public void testBase64Marshal() throws InterruptedException {
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.expectedMessageCount(1);
>         template.sendBody("direct:source", "<colors><color>grün</color></colors>");
>         assertMockEndpointsSatisfied();
>         String body = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
>         assertStringContains(body, "<colors><color>grün</color></colors>");
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from("direct:source").convertBodyTo(DOMSource.class).convertBodyTo(InputStream.class).convertBodyTo(DOMSource.class)
>                         .convertBodyTo(String.class).to("mock:result");
>             }
>         };
>     }
> }



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message