Dietrich Schulten created CAMEL-16485:
-----------------------------------------

             Summary: Allow XML namespaces for xpath mock expectations
                 Key: CAMEL-16485
                 URL: https://issues.apache.org/jira/browse/CAMEL-16485
             Project: Camel
          Issue Type: Improvement
          Components: camel-test
    Affects Versions: 3.9.0
            Reporter: Dietrich Schulten


It is possible to write an xpath expectation for a mock endpoint:
{code:java}
 mockendpoint.message(0).body().matches().xpath("/ns2:myElement"){code}
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:
{code:java}
Namespaces namespaces = new Namespaces("ns2", "http://xpsw.domap.de/xpsw174";);
mockendpoint.message(0).body().matches().xpath("/ns2:myElement", namespaces) 
{code}
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to