use of jakarta.el.ValueExpression in project tomcat by apache.
the class TestMethodExpressionImpl method testBug50790a.
@Test
public void testBug50790a() throws Exception {
ValueExpression ve = factory.createValueExpression(context, "#{beanAA.name.contains(beanA.name)}", java.lang.Boolean.class);
Boolean actual = (Boolean) ve.getValue(context);
Assert.assertEquals(Boolean.TRUE, actual);
}
use of jakarta.el.ValueExpression in project tomcat by apache.
the class TesterVariableMapperImpl method testSetVariable01.
@Test
public void testSetVariable01() {
ExpressionFactory factory = ELManager.getExpressionFactory();
ELContext context = new TesterELContext();
ValueExpression ve1 = factory.createValueExpression(context, "${1}", int.class);
ValueExpression ve2 = factory.createValueExpression(context, "${2}", int.class);
ValueExpression ve3 = factory.createValueExpression(context, "${3}", int.class);
VariableMapper mapper = new VariableMapperImpl();
mapper.setVariable("var1", ve1);
mapper.setVariable("var2", ve2);
mapper.setVariable("var3", ve3);
mapper.setVariable("var2", null);
Assert.assertEquals(ve1, mapper.resolveVariable("var1"));
Assert.assertNull(mapper.resolveVariable("var2"));
Assert.assertEquals(ve3, mapper.resolveVariable("var3"));
}
use of jakarta.el.ValueExpression 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));
}
use of jakarta.el.ValueExpression in project tomcat by apache.
the class TestAstSetData 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','b','c'}}", Set.class);
Assert.assertEquals(Set.class, ve.getType(context));
Assert.assertEquals(simpleSet, ve.getValue(context));
}
use of jakarta.el.ValueExpression in project tomcat by apache.
the class TestValueExpressionImpl method testBug56522SetNullValue.
@Test
public void testBug56522SetNullValue() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
ValueExpression var = factory.createValueExpression(beanB, TesterBeanB.class);
context.getVariableMapper().setVariable("beanB", var);
ValueExpression ve = factory.createValueExpression(context, "${beanB.name}", String.class);
// First check the basics work
String result = (String) ve.getValue(context);
Assert.assertEquals("Tomcat", result);
// Now set the value to null
ve.setValue(context, null);
Assert.assertEquals("", beanB.getName());
}
Aggregations