I need to test whether the predicate object matches the exchange for various expression languages. I need to know what exchange value I need to set in exchange to validate the predicate.
public void test() {
String expression="//orders/value>10"';
CamelContext context = new DefaultCamelContext();
Predicate predicate=new JXpathExpression(expression,boolean.class);
Exchange exchange = new DefaultExchange(context);
Message in = exchange.getIn();
in.setBody(""); // how i need to set the message in exchange in order to evaluate it against predicate
exchange.setIn(in);
boolean check=predicate.matches(exchange);
}
For JXPath the predicate object contains JXpath[//orders/value>10] when I print it using predicate.toString().
How do I set the exchange so that this expression can be validated?
JXPath works on java objects. So you have to set a suitable object in the message body.
If the object you set there has o.getOrders().getValue() and returns a numeric value > 10 then the predicate should evaluate to true.