use of javax.el.ValueExpression in project tomcat by apache.
the class TestValueExpressionImpl method testBug51544Bean.
/*
* Test returning an empty list as a bean property.
*/
@Test
public void testBug51544Bean() throws Exception {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
TesterBeanA beanA = new TesterBeanA();
beanA.setValList(Collections.emptyList());
ValueExpression var = factory.createValueExpression(beanA, TesterBeanA.class);
context.getVariableMapper().setVariable("beanA", var);
ValueExpression ve = factory.createValueExpression(context, "${beanA.valList.size()}", Integer.class);
Integer result = (Integer) ve.getValue(context);
assertEquals(Integer.valueOf(0), result);
}
use of javax.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 javax.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 javax.el.ValueExpression in project tomcat by apache.
the class TestMethodExpressionImpl method testInvokeWithSuper.
@Test
public void testInvokeWithSuper() {
MethodExpression me = factory.createMethodExpression(context, "${beanA.setBean(beanBB)}", null, new Class<?>[] { TesterBeanB.class });
me.invoke(context, null);
ValueExpression ve = factory.createValueExpression(context, "${beanA.bean.name}", String.class);
Object r = ve.getValue(context);
assertEquals("BB", r);
}
use of javax.el.ValueExpression in project tomcat by apache.
the class TestMethodExpressionImpl method testBugPrimitives.
@Test
public void testBugPrimitives() throws Exception {
MethodExpression me = factory.createMethodExpression(context, "${beanA.setValLong(5)}", null, null);
me.invoke(context, null);
ValueExpression ve = factory.createValueExpression(context, "#{beanA.valLong}", java.lang.String.class);
assertEquals("5", ve.getValue(context));
}
Aggregations