Search in sources :

Example 1 with TesterELContext

use of jakarta.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(jakarta.el.ELContext) TesterELContext(jakarta.el.TesterELContext) ExpressionFactory(jakarta.el.ExpressionFactory) VariableMapper(jakarta.el.VariableMapper) ValueExpression(jakarta.el.ValueExpression) TesterELContext(jakarta.el.TesterELContext) Test(org.junit.Test)

Aggregations

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