use of jakarta.el.ELContext 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);
Assert.assertEquals("true", result);
}
use of jakarta.el.ELContext in project tomcat by apache.
the class TestAstMapData method testGetType.
@Test
public void testGetType() {
ELProcessor processor = new ELProcessor();
ELContext context = processor.getELManager().getELContext();
ExpressionFactory factory = ELManager.getExpressionFactory();
ValueExpression ve = factory.createValueExpression(context, "${{'a':'1','b':'2','c':'3'}}", Map.class);
Assert.assertEquals(Map.class, ve.getType(context));
Assert.assertEquals(simpleMap, ve.getValue(context));
}
use of jakarta.el.ELContext in project tomcat by apache.
the class TestAstAssign method testGetType02.
@Test
public void testGetType02() {
ELProcessor processor = new ELProcessor();
ELContext context = processor.getELManager().getELContext();
ExpressionFactory factory = ELManager.getExpressionFactory();
processor.defineBean("bean01", new TesterBeanB());
ValueExpression ve = factory.createValueExpression(context, "${bean01.text = 'hello'; bean01.text}", String.class);
Assert.assertEquals(String.class, ve.getType(context));
Assert.assertEquals("hello", ve.getValue(context));
}
use of jakarta.el.ELContext in project tomcat by apache.
the class TestAstConcatenation method testGetType.
@Test
public void testGetType() {
ELProcessor processor = new ELProcessor();
ELContext context = processor.getELManager().getELContext();
ExpressionFactory factory = ELManager.getExpressionFactory();
ValueExpression ve = factory.createValueExpression(context, "${'a' += 3}", String.class);
Assert.assertEquals(String.class, ve.getType(context));
Assert.assertEquals("a3", ve.getValue(context));
}
use of jakarta.el.ELContext in project tomcat by apache.
the class TestAstListData method testGetType.
@Test
public void testGetType() {
ELProcessor processor = new ELProcessor();
ELContext context = processor.getELManager().getELContext();
ExpressionFactory factory = ELManager.getExpressionFactory();
ValueExpression ve = factory.createValueExpression(context, "${['a','b','c','b','c']}", List.class);
Assert.assertEquals(List.class, ve.getType(context));
Assert.assertEquals(simpleList, ve.getValue(context));
}
Aggregations