use of org.apache.camel.Expression in project camel by apache.
the class SimpleParserExpressionTest method testSimpleParserEol.
public void testSimpleParserEol() throws Exception {
SimpleExpressionParser parser = new SimpleExpressionParser("Hello", true);
Expression exp = parser.parseExpression();
assertEquals("Hello", exp.evaluate(exchange, String.class));
}
use of org.apache.camel.Expression in project camel by apache.
the class SimpleParserExpressionTest method testThreeNestedFunctions.
public void testThreeNestedFunctions() throws Exception {
exchange.getIn().setBody("123");
exchange.getIn().setHeader("foo", "Int");
exchange.getIn().setHeader("bar", "e");
exchange.getIn().setHeader("baz", "ger");
SimpleExpressionParser parser = new SimpleExpressionParser("${bodyAs(${header.foo}${header.bar}${header.baz})}", true);
Expression exp = parser.parseExpression();
Object obj = exp.evaluate(exchange, Object.class);
assertNotNull(obj);
Integer num = assertIsInstanceOf(Integer.class, obj);
assertEquals(123, num.intValue());
}
use of org.apache.camel.Expression in project camel by apache.
the class SimpleParserExpressionTest method testSimpleUnaryInc.
public void testSimpleUnaryInc() throws Exception {
exchange.getIn().setBody("122");
SimpleExpressionParser parser = new SimpleExpressionParser("${body}++", true);
Expression exp = parser.parseExpression();
assertEquals("123", exp.evaluate(exchange, String.class));
}
use of org.apache.camel.Expression in project camel by apache.
the class SimpleParserExpressionTest method testHeaderNestedFunction.
public void testHeaderNestedFunction() throws Exception {
exchange.getIn().setBody("foo");
exchange.getIn().setHeader("foo", "abc");
SimpleExpressionParser parser = new SimpleExpressionParser("${header.${body}}", true);
Expression exp = parser.parseExpression();
Object obj = exp.evaluate(exchange, Object.class);
assertNotNull(obj);
assertEquals("abc", obj);
}
use of org.apache.camel.Expression in project camel by apache.
the class SimpleParserExpressionTest method testBodyAsNestedFunction.
public void testBodyAsNestedFunction() throws Exception {
exchange.getIn().setBody("123");
exchange.getIn().setHeader("foo", "Integer");
SimpleExpressionParser parser = new SimpleExpressionParser("${bodyAs(${header.foo})}", true);
Expression exp = parser.parseExpression();
Object obj = exp.evaluate(exchange, Object.class);
assertNotNull(obj);
Integer num = assertIsInstanceOf(Integer.class, obj);
assertEquals(123, num.intValue());
}
Aggregations