[
https://issues.apache.org/jira/browse/CAMEL-4143?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Kulp updated CAMEL-4143:
-------------------------------
Fix Version/s: 2.7.3
> CxfPayload to Node conversion is not working properly
> ------------------------------------------------------
>
> Key: CAMEL-4143
> URL: https://issues.apache.org/jira/browse/CAMEL-4143
> Project: Camel
> Issue Type: Bug
> Components: camel-cxf
> Affects Versions: 2.8.0
> Reporter: Alexey Venderov
> Assignee: Willem Jiang
> Priority: Minor
> Fix For: 2.7.3, 2.8.0
>
> Attachments: CxfPayloadConverter.patch
>
>
> We are using {{camel-cxf}} component and building it from the sources. Also
> we have slightly modified {{CxfPayloadConverterTest.testCxfPayloadToNode}}
> test, added some additional checks. Here are the changes that were made to
> the test:
> {code:borderStyle=solid}
> Index: CxfPayloadConverterTest.java
> ===================================================================
> --- CxfPayloadConverterTest.java (revision 6644)
> +++ CxfPayloadConverterTest.java (revision 6686)
> @@ -49,6 +49,7 @@
> DocumentBuilderFactory documentBuilderFactory =
> DocumentBuilderFactory.newInstance();
> + documentBuilderFactory.setNamespaceAware(true);
> DocumentBuilder documentBuilder =
> documentBuilderFactory.newDocumentBuilder();
> document = documentBuilder.parse(file);
> document.getDocumentElement().normalize();
> @@ -118,5 +119,13 @@
> exchange.getIn().setBody(payload);
> node = exchange.getIn().getBody(Node.class);
> assertNotNull(node);
> + Element root = (Element) node;
> + assertEquals("root element name", "root", root.getNodeName());
> + assertEquals("root element namespace", "http://www.test.org/foo",
> + root.getNamespaceURI());
> + Element bar = (Element) root.getElementsByTagName("bar").item(0);
> + assertEquals("child element name", "bar", bar.getNodeName());
> + assertEquals("child element namespace", "http://www.test.org/foo",
> + bar.getNamespaceURI());
> }
> }
> {code}
> Since there is no explicit converter from {{CxfPayload}} to {{Node}} the
> fallback converter from {{CxfPayloadConverter}} is used for this conversion.
> Fallback converter from {{CxfPayloadConverter}} under the hood uses
> converters from {{XmlConverter}}. There are two suitable converters in
> {{XmlConverter}} class which are randomly selected. Some times {{public
> Element toDOMElement(Node node)}} converter is used and some times {{public
> Document toDOMDocument(final Node node)}} converter is used. If {{public
> Document toDOMDocument(final Node node)}} converter is used then test fails
> with {{ClassCastException}}. To avoid this, explicit converter from
> {{CxfPayload}} to {{Node}} should be added. Patch that adds {{CxfPayload}} to
> {{Node}} converter is provided.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira