use of javax.el.ValueExpression in project tomee by apache.
the class StatefulConversationScopedTOMEE1138Test method el.
@Test
public void el() {
final BeanELResolver elResolver = new BeanELResolver();
assertEquals("John", elResolver.getValue(new ELContext() {
@Override
public ELResolver getELResolver() {
return elResolver;
}
@Override
public FunctionMapper getFunctionMapper() {
return new FunctionMapper() {
@Override
public Method resolveFunction(final String prefix, final String localName) {
return null;
}
};
}
@Override
public VariableMapper getVariableMapper() {
return new VariableMapper() {
@Override
public ValueExpression resolveVariable(final String variable) {
return null;
}
@Override
public ValueExpression setVariable(final String variable, final ValueExpression expression) {
return null;
}
};
}
}, conversationByName, "name"));
}
use of javax.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);
assertEquals(Boolean.TRUE, actual);
}
use of javax.el.ValueExpression 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);
assertNotNull(vr);
assertEquals(beanB, vr.getBase());
assertEquals("name", vr.getProperty());
}
use of javax.el.ValueExpression in project tomcat by apache.
the class TestValueExpressionImpl method testBug51177ObjectList.
@Test
public void testBug51177ObjectList() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
Object o1 = "String value";
Object o2 = Integer.valueOf(32);
List<Object> list = new ArrayList<>();
list.add(0, o1);
list.add(1, o2);
ValueExpression var = factory.createValueExpression(list, List.class);
context.getVariableMapper().setVariable("list", var);
ValueExpression ve1 = factory.createValueExpression(context, "${list[0]}", Object.class);
ve1.setValue(context, o2);
assertEquals(o2, ve1.getValue(context));
ValueExpression ve2 = factory.createValueExpression(context, "${list[1]}", Object.class);
ve2.setValue(context, o1);
assertEquals(o1, ve2.getValue(context));
}
use of javax.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);
assertEquals("Tomcat", result);
// Now set the value to null
ve.setValue(context, null);
assertEquals("", beanB.getName());
}
Aggregations