Search in sources :

Example 31 with ELProcessor

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

the class TestCollectionOperations method testSorted01.

@Test
public void testSorted01() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("['c', 'd', 'b', 'a'].stream().sorted().toList()", List.class);
    List<String> expected = new ArrayList<>(4);
    expected.add("a");
    expected.add("b");
    expected.add("c");
    expected.add("d");
    Assert.assertEquals(expected, result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 32 with ELProcessor

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

the class TestCollectionOperations method testAverage03.

@Test(expected = ELException.class)
public void testAverage03() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("[].stream().average()", Object.class);
    ((Optional) result).get();
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 33 with ELProcessor

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

the class TestMethodExpressionImpl method testPreferNoVarArgs.

@Test
public void testPreferNoVarArgs() {
    ELProcessor elp = new ELProcessor();
    TesterBeanAAA bean = new TesterBeanAAA();
    bean.setName("xyz");
    elp.defineBean("bean2", bean);
    elp.defineBean("bean1", new TesterBeanI());
    String elResult = elp.eval("bean1.echo(bean2)");
    Assert.assertEquals("No varargs: xyz", elResult);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 34 with ELProcessor

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

the class TestAstNot method test03.

@Test
public void test03() {
    ELProcessor processor = new ELProcessor();
    Boolean result = processor.eval("!false");
    Assert.assertEquals(Boolean.TRUE, result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 35 with ELProcessor

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

the class TestAstSemicolon method testGetValue02.

@Test
public void testGetValue02() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("1;2", Integer.class);
    Assert.assertEquals(Integer.valueOf(2), 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