use of jakarta.el.ValueReference in project tomcat by apache.
the class TestValueExpressionImpl method testGetValueReference.
@Test
public void testGetValueReference() {
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 check the value reference
ValueReference vr = ve.getValueReference(context);
Assert.assertNotNull(vr);
Assert.assertEquals(beanB, vr.getBase());
Assert.assertEquals("name", vr.getProperty());
}
use of jakarta.el.ValueReference in project tomcat by apache.
the class TestValueExpressionImpl method testBug49345.
@Test
public void testBug49345() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
TesterBeanA beanA = new TesterBeanA();
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
beanA.setBean(beanB);
ValueExpression var = factory.createValueExpression(beanA, TesterBeanA.class);
context.getVariableMapper().setVariable("beanA", var);
ValueExpression ve = factory.createValueExpression(context, "${beanA.bean.name}", String.class);
// First check the basics work
String result = (String) ve.getValue(context);
Assert.assertEquals("Tomcat", result);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
Assert.assertNotNull(vr);
Assert.assertEquals(beanB, vr.getBase());
Assert.assertEquals("name", vr.getProperty());
}
use of jakarta.el.ValueReference in project tomcat by apache.
the class ValueExpressionImpl method getValueReference.
/**
* @since EL 2.2
*/
@Override
public ValueReference getValueReference(ELContext context) {
EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper);
context.notifyBeforeEvaluation(getExpressionString());
ValueReference result = this.getNode().getValueReference(ctx);
context.notifyAfterEvaluation(getExpressionString());
return result;
}
use of jakarta.el.ValueReference in project tomcat by apache.
the class TestValueExpressionImpl method testGetValueReferenceVariable.
@Test
public void testGetValueReferenceVariable() {
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 var2 = factory.createValueExpression(context, "${beanB.name}", String.class);
context.getVariableMapper().setVariable("foo", var2);
ValueExpression ve = factory.createValueExpression(context, "${foo}", ValueExpression.class);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
Assert.assertNotNull(vr);
Assert.assertEquals(beanB, vr.getBase());
Assert.assertEquals("name", vr.getProperty());
}
Aggregations