Apache camel 使用ApacheCamel JXPath表达式语言时如何设置Exchange正文
我需要测试谓词对象是否匹配各种表达式语言的交换。我需要知道我需要在exchange中设置什么交换值来验证谓词Apache camel 使用ApacheCamel JXPath表达式语言时如何设置Exchange正文,apache-camel,Apache Camel,我需要测试谓词对象是否匹配各种表达式语言的交换。我需要知道我需要在exchange中设置什么交换值来验证谓词 public void test() { String expression="//orders/value>10"'; CamelContext context = new DefaultCamelContext(); Predicate predicate=new JXpathExpression(expression,boolean.class);
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);
}
对于JXPath,当我使用predicate.toString打印它时,谓词对象包含JXPath[//orders/value>10]
如何设置交换以验证此表达式?JXPath适用于java对象。因此,必须在消息体中设置合适的对象。
如果在那里设置的对象具有o.getOrders.getValue并返回一个大于10的数值,则谓词的计算结果应为true。也发布在Camel用户邮件列表上: