You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Samruben <ra...@gmail.com> on 2012/04/11 18:41:09 UTC
Expression Language exchange test
Hi
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 pre
exchange.setIn(in);
boolean check=predicate.matches(exchange);
}
for Jxpath : the predicate object contains JXpath[//orders/value>10], how i
need to set the exchange in order to evaluate this expression.
Thank you
--
View this message in context: http://camel.465427.n5.nabble.com/Expression-Language-exchange-test-tp5633420p5633420.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Expression Language exchange test
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
A good idea is always to check the test source code of the Camel
component you work with.
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jxpath/src/test/
See for example this test
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathTest.java
On Wed, Apr 11, 2012 at 6:41 PM, Samruben <ra...@gmail.com> wrote:
> Hi
>
> 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 pre
> exchange.setIn(in);
> boolean check=predicate.matches(exchange);
> }
>
> for Jxpath : the predicate object contains JXpath[//orders/value>10], how i
> need to set the exchange in order to evaluate this expression.
>
> Thank you
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Expression-Language-exchange-test-tp5633420p5633420.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/