use of javax.el.ELContext 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);
assertEquals("Tomcat", result);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
assertNotNull(vr);
assertEquals(beanB, vr.getBase());
assertEquals("name", vr.getProperty());
}
use of javax.el.ELContext in project tomcat by apache.
the class TestAstListData 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','b','c']}", List.class);
Assert.assertEquals(List.class, ve.getType(context));
Assert.assertEquals(simpleList, ve.getValue(context));
}
use of javax.el.ELContext in project tomcat by apache.
the class TestAstMapData 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':'1','b':'2','c':'3'}}", Map.class);
Assert.assertEquals(Map.class, ve.getType(context));
Assert.assertEquals(simpleMap, ve.getValue(context));
}
use of javax.el.ELContext in project tomcat by apache.
the class TestAstSemicolon method testGetType.
@Test
public void testGetType() {
ELProcessor processor = new ELProcessor();
ELContext context = processor.getELManager().getELContext();
ExpressionFactory factory = ELManager.getExpressionFactory();
ValueExpression ve = factory.createValueExpression(context, "${1+1;2+2}", Integer.class);
Assert.assertEquals(Number.class, ve.getType(context));
Assert.assertEquals(Integer.valueOf(4), ve.getValue(context));
}
use of javax.el.ELContext 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));
}
Aggregations