Search in sources :

Example 6 with ValueExpression

use of javax.el.ValueExpression in project tomcat by apache.

the class TestELEvaluation method evaluateExpression.

// ************************************************************************
private String evaluateExpression(String expression) {
    ExpressionFactoryImpl exprFactory = new ExpressionFactoryImpl();
    ELContextImpl ctx = new ELContextImpl(exprFactory);
    ctx.setFunctionMapper(new TesterFunctions.FMapper());
    ValueExpression ve = exprFactory.createValueExpression(ctx, expression, String.class);
    return (String) ve.getValue(ctx);
}
Also used : ValueExpression(javax.el.ValueExpression) ELContextImpl(org.apache.jasper.el.ELContextImpl)

Example 7 with ValueExpression

use of javax.el.ValueExpression in project tomcat by apache.

the class TestMethodExpressionImpl method testBug52970.

@Test
public void testBug52970() {
    MethodExpression me = factory.createMethodExpression(context, "${beanEnum.submit('APPLE')}", null, new Class<?>[] { TesterBeanEnum.class });
    me.invoke(context, null);
    ValueExpression ve = factory.createValueExpression(context, "#{beanEnum.lastSubmitted}", TesterEnum.class);
    TesterEnum actual = (TesterEnum) ve.getValue(context);
    assertEquals(TesterEnum.APPLE, actual);
}
Also used : ValueExpression(javax.el.ValueExpression) MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 8 with ValueExpression

use of javax.el.ValueExpression in project tomcat by apache.

the class TestMethodExpressionImpl method testBug49655.

/*
     * This is also tested implicitly in numerous places elsewhere in this
     * class.
     */
@Test
public void testBug49655() throws Exception {
    // This is the call the failed
    MethodExpression me = factory.createMethodExpression(context, "#{beanA.setName('New value')}", null, null);
    // The rest is to check it worked correctly
    me.invoke(context, null);
    ValueExpression ve = factory.createValueExpression(context, "#{beanA.name}", java.lang.String.class);
    assertEquals("New value", ve.getValue(context));
}
Also used : ValueExpression(javax.el.ValueExpression) MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 9 with ValueExpression

use of javax.el.ValueExpression in project tomcat by apache.

the class TestMethodExpressionImpl method testBug53792b.

@Test
public void testBug53792b() {
    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.length()}", java.lang.Integer.class);
    Integer actual = (Integer) ve.getValue(context);
    assertEquals(Integer.valueOf(BUG53792.length()), actual);
}
Also used : ValueExpression(javax.el.ValueExpression) MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 10 with ValueExpression

use of javax.el.ValueExpression in project tomcat by apache.

the class TestMethodExpressionImpl method testBug50790b.

@Test
public void testBug50790b() throws Exception {
    ValueExpression ve = factory.createValueExpression(context, "#{beanA.name.contains(beanAA.name)}", java.lang.Boolean.class);
    Boolean actual = (Boolean) ve.getValue(context);
    assertEquals(Boolean.FALSE, actual);
}
Also used : ValueExpression(javax.el.ValueExpression) Test(org.junit.Test)

Aggregations

ValueExpression (javax.el.ValueExpression)59 Test (org.junit.Test)36 ExpressionFactory (javax.el.ExpressionFactory)33 ELContext (javax.el.ELContext)27 ELContextImpl (org.apache.jasper.el.ELContextImpl)17 VariableMapper (javax.el.VariableMapper)9 ELException (javax.el.ELException)7 ELProcessor (javax.el.ELProcessor)7 MethodExpression (javax.el.MethodExpression)7 PropertyNotFoundException (javax.el.PropertyNotFoundException)4 ValueReference (javax.el.ValueReference)4 SimpleContext (de.odysseus.el.util.SimpleContext)2 HashMap (java.util.HashMap)2 ELClass (javax.el.ELClass)2 FunctionMapper (javax.el.FunctionMapper)2 ELParseException (javax.servlet.jsp.el.ELParseException)2 ExpressionFactoryImpl (de.odysseus.el.ExpressionFactoryImpl)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1