use of org.apache.camel.Predicate in project camel by apache.
the class SimpleParserPredicateTest method testSimpleExpressionPredicate.
public void testSimpleExpressionPredicate() throws Exception {
exchange.getIn().setBody("Hello");
exchange.getIn().setHeader("number", "1234");
SimplePredicateParser parser = new SimplePredicateParser("${in.header.number} regex '\\d{4}'", true);
Predicate pre = parser.parsePredicate();
assertTrue("Should match", pre.matches(exchange));
}
use of org.apache.camel.Predicate in project camel by apache.
the class SimpleParserPredicateTest method testSimpleEqFunctionFunction.
public void testSimpleEqFunctionFunction() throws Exception {
exchange.getIn().setBody(122);
exchange.getIn().setHeader("val", 122);
SimplePredicateParser parser = new SimplePredicateParser("${body} == ${header.val}", true);
Predicate pre = parser.parsePredicate();
assertTrue("Should match", pre.matches(exchange));
}
use of org.apache.camel.Predicate in project camel by apache.
the class SimpleParserPredicateTest method testSimpleEqFunctionNumeric.
public void testSimpleEqFunctionNumeric() throws Exception {
exchange.getIn().setBody(122);
SimplePredicateParser parser = new SimplePredicateParser("${body} == 122", true);
Predicate pre = parser.parsePredicate();
assertTrue("Should match", pre.matches(exchange));
}
use of org.apache.camel.Predicate in project camel by apache.
the class SimpleParserPredicateTest method testSimpleEqFunctionBooleanSpaces.
public void testSimpleEqFunctionBooleanSpaces() throws Exception {
exchange.getIn().setBody("Hello");
exchange.getIn().setHeader("high", true);
SimplePredicateParser parser = new SimplePredicateParser("${header.high} == true", true);
Predicate pre = parser.parsePredicate();
assertTrue("Should match", pre.matches(exchange));
}
use of org.apache.camel.Predicate in project camel by apache.
the class SimpleParserPredicateTest method testSimpleBooleanValue.
public void testSimpleBooleanValue() throws Exception {
exchange.getIn().setBody("foo");
SimplePredicateParser parser = new SimplePredicateParser("true", true);
Predicate pre = parser.parsePredicate();
assertTrue(pre.matches(exchange));
parser = new SimplePredicateParser("false", true);
pre = parser.parsePredicate();
assertFalse(pre.matches(exchange));
}
Aggregations