use of javax.el.ValueExpression in project tomcat by apache.
the class TestMethodExpressionImpl method testBug53792a.
@Test
public void testBug53792a() {
MethodExpression me = factory.createMethodExpression(context, "${beanA.setBean(beanB)}", null, new Class<?>[] { TesterBeanB.class });
me.invoke(context, null);
me = factory.createMethodExpression(context, "${beanB.setName('" + BUG53792 + "')}", null, new Class<?>[] { TesterBeanB.class });
me.invoke(context, null);
ValueExpression ve = factory.createValueExpression(context, "#{beanA.getBean().name}", java.lang.String.class);
String actual = (String) ve.getValue(context);
assertEquals(BUG53792, actual);
}
use of javax.el.ValueExpression in project tomcat by apache.
the class ExpressionEvaluatorImpl method parseExpression.
@Override
public Expression parseExpression(String expression, @SuppressWarnings("rawtypes") Class expectedType, FunctionMapper fMapper) throws ELException {
try {
ELContextImpl ctx = new ELContextImpl(ELContextImpl.getDefaultResolver(factory));
if (fMapper != null) {
ctx.setFunctionMapper(new FunctionMapperImpl(fMapper));
}
ValueExpression ve = this.factory.createValueExpression(ctx, expression, expectedType);
return new ExpressionImpl(ve, factory);
} catch (javax.el.ELException e) {
throw new ELParseException(e.getMessage());
}
}
use of javax.el.ValueExpression in project tomcat by apache.
the class TestELParser method doTestBug56179.
private void doTestBug56179(int parenthesesCount, String innerExpr) {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
ValueExpression var = factory.createValueExpression(Boolean.TRUE, Boolean.class);
context.getVariableMapper().setVariable("test", var);
StringBuilder expr = new StringBuilder();
expr.append("${");
for (int i = 0; i < parenthesesCount; i++) {
expr.append("(");
}
expr.append(innerExpr);
for (int i = 0; i < parenthesesCount; i++) {
expr.append(")");
}
expr.append("}");
ValueExpression ve = factory.createValueExpression(context, expr.toString(), String.class);
String result = (String) ve.getValue(context);
assertEquals("true", result);
}
use of javax.el.ValueExpression in project tomcat by apache.
the class TestELParser method bug56185.
@Test
public void bug56185() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
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);
assertEquals(Boolean.FALSE, ve.getValue(context));
beanC.setInt1(2);
beanC.setMyBool1(true);
assertEquals(Boolean.TRUE, ve.getValue(context));
}
use of javax.el.ValueExpression in project tomcat by apache.
the class TestELParser method testExpression.
private void testExpression(String expression, String expected) {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
ValueExpression ve = factory.createValueExpression(context, expression, String.class);
String result = (String) ve.getValue(context);
assertEquals(expected, result);
}
Aggregations