Search in sources :

Example 76 with ELProcessor

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

the class TestAstAssign method testGetType01.

@Test
public void testGetType01() {
    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'}", String.class);
    Assert.assertEquals(String.class, ve.getType(context));
    Assert.assertEquals("hello", 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 77 with ELProcessor

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

the class TestAstAssign method testGetValue02.

@Test
public void testGetValue02() {
    ELProcessor processor = new ELProcessor();
    processor.defineBean("bean01", new TesterBeanB());
    Object result = processor.getValue("bean01.text = 'hello'; bean01.text", String.class);
    Assert.assertEquals("hello", result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 78 with ELProcessor

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

the class TestAstConcatenation method testPrecedence01.

/**
 * Test operator precedence (+ before +=).
 */
@Test
public void testPrecedence01() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("1 + 2 += 3", String.class);
    Assert.assertEquals("33", result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 79 with ELProcessor

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

the class TestAstConcatenation method testConcatenation01.

/**
 * Test string concatenation.
 */
@Test
public void testConcatenation01() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("'a' += 'b'", String.class);
    Assert.assertEquals("ab", result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 80 with ELProcessor

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

the class TestAstConcatenation method testPrecedence03.

/**
 * Test operator precedence (+= before >).
 */
@Test
public void testPrecedence03() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("10 > 2 += 3", String.class);
    Assert.assertEquals("false", 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