use of org.apache.camel.Expression in project camel by apache.
the class SimpleTest method testListRemoveByInstance.
public void testListRemoveByInstance() throws Exception {
List<Object> data = new ArrayList<Object>();
data.add("A");
data.add("B");
exchange.getIn().setBody(data);
assertEquals(2, data.size());
Expression expression = SimpleLanguage.simple("${body.remove('A')}");
expression.evaluate(exchange, Object.class);
assertEquals(1, data.size());
assertEquals("B", data.get(0));
}
use of org.apache.camel.Expression in project camel by apache.
the class ExpressionListComparator method compare.
public int compare(Exchange e1, Exchange e2) {
for (Expression expression : expressions) {
Object o1 = expression.evaluate(e1, Object.class);
Object o2 = expression.evaluate(e2, Object.class);
int answer = ObjectHelper.compare(o1, o2);
if (answer != 0) {
return answer;
}
}
return 0;
}
use of org.apache.camel.Expression in project camel by apache.
the class BeanTest method testBeanTypeAndMethodExpression.
public void testBeanTypeAndMethodExpression() throws Exception {
Expression exp = BeanLanguage.bean(MyUser.class, "hello");
Exchange exchange = createExchangeWithBody("Claus");
Object result = exp.evaluate(exchange, Object.class);
assertEquals("Hello Claus", result);
}
use of org.apache.camel.Expression in project camel by apache.
the class BeanTest method testBeanTypeExpression.
public void testBeanTypeExpression() throws Exception {
Expression exp = BeanLanguage.bean(MyUser.class, null);
Exchange exchange = createExchangeWithBody("Claus");
Object result = exp.evaluate(exchange, Object.class);
assertEquals("Hello Claus", result);
}
use of org.apache.camel.Expression in project camel by apache.
the class BeanTest method testNoMethodBeanLookup.
public void testNoMethodBeanLookup() throws Exception {
Expression exp = BeanLanguage.bean("foo.cake");
Exchange exchange = createExchangeWithBody("Claus");
Object result = exp.evaluate(exchange, Object.class);
assertNull(result);
assertNotNull(exchange.getException());
MethodNotFoundException e = assertIsInstanceOf(MethodNotFoundException.class, exchange.getException());
assertSame(context.getRegistry().lookupByName("foo"), e.getBean());
assertEquals("cake", e.getMethodName());
}
Aggregations