Search in sources :

Example 71 with ELProcessor

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

the class TestELSupport method testCoercetoFunctionalInterface02.

@Test
public void testCoercetoFunctionalInterface02() throws Exception {
    final ELProcessor elp = new ELProcessor();
    elp.defineFunction("", "", "org.apache.el.lang.TestELSupport", "testPredicateA");
    Object result = elp.eval("testPredicateA(x -> !x.equals('data'))");
    Assert.assertEquals("BLOCK", result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 72 with ELProcessor

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

the class TestELSupport method testCoercetoFunctionalInterface05.

@Test(expected = ELException.class)
public void testCoercetoFunctionalInterface05() throws Exception {
    final ELProcessor elp = new ELProcessor();
    elp.defineFunction("", "", "org.apache.el.lang.TestELSupport", "testPredicateC");
    elp.eval("testPredicateC(x -> x > 50)");
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 73 with ELProcessor

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

the class TestELSupport method testCoercetoFunctionalInterface06.

@Test
public void testCoercetoFunctionalInterface06() throws Exception {
    final ELProcessor elp = new ELProcessor();
    elp.defineFunction("", "", "org.apache.el.lang.TestELSupport", "testBiPredicateA");
    Object result = elp.eval("testBiPredicateA((x,y) -> x.name().equals('VALA1') && y)");
    Assert.assertEquals("PASS", result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 74 with ELProcessor

use of jakarta.el.ELProcessor in project appslandia-common by haducloc.

the class CDIUtils method getELProcessor.

public static ELProcessor getELProcessor(BeanManager beanManager) {
    ELProcessor elProcessor = new ELProcessor();
    elProcessor.getELManager().addELResolver(beanManager.getELResolver());
    return elProcessor;
}
Also used : ELProcessor(jakarta.el.ELProcessor)

Example 75 with ELProcessor

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

the class TestMethodExpressionImpl method doTestVarArgsBeanG.

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

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