citrusframework / citrusframework/citrus
Citrus ignores XML encoding
- Dominant language
- Java
- Stars
- 485
- Forks
- 155
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 6
Description
**Citrus Version**
2.8.0
**Expected behavior**
When validating XML payloads using the "payload()" method, I expect Citrus to respect the encoding set in the XML declaration.
**Actual behavior**
Citrus ignores the encoding and uses the default encoding. My current workaround is therefore to manually set the encoding via the citrus-application.properties file. This is dangerous, as the XML file might not always have that specific encoding. Tests that should fail might therefore pass.
**Test case sample**
In the following example, I merge two XMLs using an XSLT in a Camel route. The XML file loaded by Citrus ignores the UTF-8 encoding, the one read by Camel honors it. When validating the response, some of the values merged from the file loaded by Camel are seen as faulty with Errors like this:
` Node value not equal for element 'vorname', expected 'Véréna' but was 'Véréna'`
```
context.addRouteDefinition(new RouteDefinition()
.from("direct:testXsltMerge")
.enrich("language:constant:resource:classpath:data/file1.xml",
xsltMergeStrategy));
send("camel:sync:direct:testXsltMerge")
.payload(new ClassPathResource("data/file2.xml"));
receive("camel:sync:direct:testXsltMerge")
.payload(new ClassPathResource("data/expectedResult.xml"));
```
Contributor guide
Assessment
This issue has not been assessed yet.