use of jakarta.el.ELProcessor in project tomcat by apache.
the class TestAstAssign method testGetValue01.
@Test
public void testGetValue01() {
ELProcessor processor = new ELProcessor();
processor.defineBean("bean01", new TesterBeanB());
Object result = processor.getValue("bean01.text = 'hello'", String.class);
Assert.assertEquals("hello", result);
}
use of jakarta.el.ELProcessor 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.ELProcessor in project tomcat by apache.
the class TestAstConcatenation method testConcatenation02.
/**
* Test coercion to string then concatenation.
*/
@Test
public void testConcatenation02() {
ELProcessor processor = new ELProcessor();
Object result = processor.getValue("1 += 2", String.class);
Assert.assertEquals("12", result);
}
use of jakarta.el.ELProcessor 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.ELProcessor in project tomcat by apache.
the class TestAstConcatenation method testConcatenation04.
/**
* Test string concatenation with mixed types.
*/
@Test
public void testConcatenation04() {
ELProcessor processor = new ELProcessor();
Object result = processor.getValue("'a' += 3", String.class);
Assert.assertEquals("a3", result);
}
Aggregations