use of javax.el.ExpressionFactory in project tomcat70 by apache.
the class TestELParser method bug56185.
@Test
public void bug56185() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
TesterBeanC beanC = new TesterBeanC();
ValueExpression var = factory.createValueExpression(beanC, TesterBeanC.class);
context.getVariableMapper().setVariable("myBean", var);
ValueExpression ve = factory.createValueExpression(context, "${(myBean.int1 > 1 and myBean.myBool) or " + "((myBean.myBool or myBean.myBool1) and myBean.int1 > 1)}", Boolean.class);
Assert.assertEquals(Boolean.FALSE, ve.getValue(context));
beanC.setInt1(2);
beanC.setMyBool1(true);
Assert.assertEquals(Boolean.TRUE, ve.getValue(context));
}
use of javax.el.ExpressionFactory in project tomcat70 by apache.
the class TestELParser method testJavaKeyWordIdentifier.
@Test
public void testJavaKeyWordIdentifier() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
TesterBeanA beanA = new TesterBeanA();
beanA.setInt("five");
ValueExpression var = factory.createValueExpression(beanA, TesterBeanA.class);
context.getVariableMapper().setVariable("this", var);
// Should fail
Exception e = null;
try {
factory.createValueExpression(context, "${this}", String.class);
} catch (ELException ele) {
e = ele;
}
Assert.assertNotNull(e);
}
use of javax.el.ExpressionFactory in project jersey by jersey.
the class LinkELContextTest method testEmbeddedExpression.
@Test
public void testEmbeddedExpression() {
System.out.println("Embedded expression");
ExpressionFactory factory = ExpressionFactory.newInstance();
LinkELContext context = new LinkELContext(new EntityBean(), null);
ValueExpression expr = factory.createValueExpression(context, "foo/${entity.id}/bar", String.class);
Object value = expr.getValue(context);
assertEquals("foo/" + ID + "/bar", value);
}
use of javax.el.ExpressionFactory in project jersey by jersey.
the class LinkELContextTest method testMultipleExpressions.
@Test
public void testMultipleExpressions() {
System.out.println("Multiple expressions");
ExpressionFactory factory = ExpressionFactory.newInstance();
LinkELContext context = new LinkELContext(new EntityBean(), null);
ValueExpression expr = factory.createValueExpression(context, "foo/${entity.id}/bar/${entity.name}", String.class);
Object value = expr.getValue(context);
assertEquals("foo/" + ID + "/bar/" + NAME, value);
}
use of javax.el.ExpressionFactory in project camel by apache.
the class JuelExpression method evaluate.
public <T> T evaluate(Exchange exchange, Class<T> tClass) {
// Create (if needed) the ExpressionFactory first from the CamelContext using FactoryFinder
ExpressionFactory factory = getExpressionFactory(exchange.getContext());
ELContext context = populateContext(createContext(), exchange);
ValueExpression valueExpression = factory.createValueExpression(context, expression, type);
Object value = valueExpression.getValue(context);
LOG.trace("Value returned {}", value);
return exchange.getContext().getTypeConverter().convertTo(tClass, value);
}
Aggregations