Volodymyr Sobotovych created CAMEL-8283:
-------------------------------------------
Summary: Fix documentation for File2 component
Key: CAMEL-8283
URL: https://issues.apache.org/jira/browse/CAMEL-8283
Project: Camel
Issue Type: Bug
Reporter: Volodymyr Sobotovych
Priority: Minor
There is some incorrectness in description of "charset" option in documentation
(http://camel.apache.org/file2.html):
Camel 2.9.3: this option is used to specify the encoding of the file, _and
camel will set the Exchange property with Exchange.CHARSET_NAME with the value
of this option_. You can use this on the consumer, to specify the encodings of
the files, which allow Camel to know the charset it should load the file
content in case the file content is being accessed. Likewise when writing a
file, you can use this option to specify which charset to write the file as
well. See further below for a examples and more important details.
The incorrectness is highlighted in _italic_ above. No endpoint (file, ftp,
sftp) sets Exchange.CHARSET_NAME as illustrated by the output of this test:
{code}
public class FileEncodingTest extends CamelTestSupport {
@Test
public void testFileEncoding() {
template.sendBody("direct:in", "Hi there");
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:in")
.log("Charset name header (1):
${header.CamelCharsetName}")
.to("file://output.txt?charset=iso-8859-1")
.log("Charset name header (2):
${header.CamelCharsetName}")
.setHeader(Exchange.CHARSET_NAME,
constant("iso-8859-1"))
.log("Charset name header (3):
${header.CamelCharsetName}");
}
};
}
}
{code}
{code}
[ main] route1 INFO Charset
name header (1):
[ main] SendProcessor DEBUG >>>>
Endpoint[file://output.txt?charset=iso-8859-1] Exchange[Message: Hi there]
[ main] FileOperations DEBUG Using
Reader to write file: output.txt/ID-wheleph-Lenovo-G570-42931-1422203242220-0-1
with charset: iso-8859-1
[ main] GenericFileProducer DEBUG Wrote
[output.txt/ID-wheleph-Lenovo-G570-42931-1422203242220-0-1] to
[Endpoint[file://output.txt?charset=iso-8859-1]]
[ main] route1 INFO Charset
name header (2):
[ main] route1 INFO Charset
name header (3): iso-8859-1
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)