Search in sources :

Example 36 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestAstSemicolon method testGetType.

@Test
public void testGetType() {
    ELProcessor processor = new ELProcessor();
    ELContext context = processor.getELManager().getELContext();
    ExpressionFactory factory = ELManager.getExpressionFactory();
    ValueExpression ve = factory.createValueExpression(context, "${1+1;2+2}", Integer.class);
    Assert.assertEquals(Number.class, ve.getType(context));
    Assert.assertEquals(Integer.valueOf(4), ve.getValue(context));
}
Also used : ELContext(jakarta.el.ELContext) ExpressionFactory(jakarta.el.ExpressionFactory) ValueExpression(jakarta.el.ValueExpression) ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 37 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestAstSemicolon method testGetValue03.

@Test
public void testGetValue03() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("1;2 + 3", Integer.class);
    Assert.assertEquals(Integer.valueOf(5), result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 38 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestMethodExpressionImpl method doTestVarArgsBeanH.

private void doTestVarArgsBeanH(String expression, Function<TesterBeanH, String> func) {
    ELProcessor elp = new ELProcessor();
    elp.defineBean("apple", TesterEnum.APPLE);
    elp.defineBean("beanH", new TesterBeanH());
    String elResult = elp.eval(expression);
    String javaResult = func.apply(new TesterBeanH());
    Assert.assertEquals(javaResult, elResult);
}
Also used : ELProcessor(jakarta.el.ELProcessor)

Example 39 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestAstLambdaExpression method testNested02.

@Test
public void testNested02() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("(()->y->()->2-y)()(1)()", Integer.class);
    Assert.assertEquals(Integer.valueOf(1), result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 40 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestAstLambdaExpression method testLambdaAsFunction07.

@Test
public void testLambdaAsFunction07() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("v = (()->y->()->()->x->x-y); v()(1)()(3)(2)", Integer.class);
    Assert.assertEquals(Integer.valueOf(1), result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Aggregations

ELProcessor (jakarta.el.ELProcessor)138 Test (org.junit.Test)133 ArrayList (java.util.ArrayList)13 ELContext (jakarta.el.ELContext)8 ValueExpression (jakarta.el.ValueExpression)8 ExpressionFactory (jakarta.el.ExpressionFactory)7 TesterBeanA (org.apache.el.TesterBeanA)5 List (java.util.List)1