Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Information Provided
-
3.9.0
-
None
-
None
-
Unknown
Description
It is possible to write an xpath expectation for a mock endpoint:
mockendpoint.message(0).body().matches().xpath("/ns2:myElement")
However, this does not seem to work with namespaced elements (ns2 in the example above).
The Camel XPath documentation says that the Namespaces class can be used to define namespaces for e.g. xpath filters (btw. the code snippet that was formerly presented to show the usage got lost in the current manual).
Also, the XPathBuilder already has a namespace() method to set namespaces. But it appears that the MockExpressionClause.getExpressionValue }}does not support that, it uses {{XPathLanguage.createPredicate to create the XPath expression with a plain XPathBuilder without defining namespaces.
Is it possible to add namespaces to mock expectations somehow? If not I would like to suggest such support as an improvement. If it were built like the filter DSL, it should be possible to say sth like:
Namespaces namespaces = new Namespaces("ns2", "http://xpsw.domap.de/xpsw174"); mockendpoint.message(0).body().matches().xpath("/ns2:myElement", namespaces)