Search in sources :

Example 1 with TesterELContext

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

the class TesterVariableMapperImpl method testSetVariable01.

@Test
public void testSetVariable01() {
    ExpressionFactory factory = ELManager.getExpressionFactory();
    ELContext context = new TesterELContext();
    ValueExpression ve1 = factory.createValueExpression(context, "${1}", int.class);
    ValueExpression ve2 = factory.createValueExpression(context, "${2}", int.class);
    ValueExpression ve3 = factory.createValueExpression(context, "${3}", int.class);
    VariableMapper mapper = new VariableMapperImpl();
    mapper.setVariable("var1", ve1);
    mapper.setVariable("var2", ve2);
    mapper.setVariable("var3", ve3);
    mapper.setVariable("var2", null);
    Assert.assertEquals(ve1, mapper.resolveVariable("var1"));
    Assert.assertNull(mapper.resolveVariable("var2"));
    Assert.assertEquals(ve3, mapper.resolveVariable("var3"));
}
Also used : ELContext(javax.el.ELContext) TesterELContext(javax.el.TesterELContext) ExpressionFactory(javax.el.ExpressionFactory) VariableMapper(javax.el.VariableMapper) ValueExpression(javax.el.ValueExpression) TesterELContext(javax.el.TesterELContext) Test(org.junit.Test)

Aggregations

ELContext (javax.el.ELContext)1 ExpressionFactory (javax.el.ExpressionFactory)1 TesterELContext (javax.el.TesterELContext)1 ValueExpression (javax.el.ValueExpression)1 VariableMapper (javax.el.VariableMapper)1 Test (org.junit.Test)1