use of javax.el.ValueExpression 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));
}
use of javax.el.ValueExpression in project tomcat by apache.
the class TestAstConcatenation 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' += 3}", String.class);
Assert.assertEquals(String.class, ve.getType(context));
Assert.assertEquals("a3", ve.getValue(context));
}
use of javax.el.ValueExpression in project jersey by jersey.
the class LinkELContextTest method testLiteralExpression.
@Test
public void testLiteralExpression() {
System.out.println("Literal expression");
ExpressionFactory factory = ExpressionFactory.newInstance();
LinkELContext context = new LinkELContext(new BooleanBean(), null);
ValueExpression expr = factory.createValueExpression(context, "${1+2}", int.class);
Object value = expr.getValue(context);
assertEquals(3, value);
}
use of javax.el.ValueExpression in project jersey by jersey.
the class LinkELContextTest method testBooleanExpression.
@Test
public void testBooleanExpression() {
System.out.println("Boolean expression");
ExpressionFactory factory = ExpressionFactory.newInstance();
LinkELContext context = new LinkELContext(new BooleanBean(), null);
ValueExpression expr = factory.createValueExpression(context, "${entity.enabled}", boolean.class);
Object value = expr.getValue(context);
assertEquals(true, value);
expr = factory.createValueExpression(context, "${entity.getValue(true)}", boolean.class);
value = expr.getValue(context);
assertEquals(true, value);
expr = factory.createValueExpression(context, "${entity.getValue(false)}", boolean.class);
value = expr.getValue(context);
assertEquals(false, value);
}
use of javax.el.ValueExpression in project jersey by jersey.
the class LinkELContextTest method testExpression.
@Test
public void testExpression() {
System.out.println("Raw expression");
ExpressionFactory factory = ExpressionFactory.newInstance();
LinkELContext context = new LinkELContext(new EntityBean(), null);
ValueExpression expr = factory.createValueExpression(context, "${entity.id}", String.class);
Object value = expr.getValue(context);
assertEquals(ID, value);
}
Aggregations