Search in sources :

Example 1 with ExpressionFactory

use of javax.el.ExpressionFactory 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);
}
Also used : ExpressionFactory(javax.el.ExpressionFactory) ValueExpression(javax.el.ValueExpression) Test(org.junit.Test)

Example 2 with ExpressionFactory

use of javax.el.ExpressionFactory 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);
}
Also used : ExpressionFactory(javax.el.ExpressionFactory) ValueExpression(javax.el.ValueExpression) Test(org.junit.Test)

Example 3 with ExpressionFactory

use of javax.el.ExpressionFactory 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);
}
Also used : ExpressionFactory(javax.el.ExpressionFactory) ValueExpression(javax.el.ValueExpression) Test(org.junit.Test)

Example 4 with ExpressionFactory

use of javax.el.ExpressionFactory in project jersey by jersey.

the class LinkELContextTest method testExpressionFactory.

@Test
public void testExpressionFactory() {
    System.out.println("Create expression factory");
    ExpressionFactory factory = ExpressionFactory.newInstance();
    assertNotNull(factory);
}
Also used : ExpressionFactory(javax.el.ExpressionFactory) Test(org.junit.Test)

Example 5 with ExpressionFactory

use of javax.el.ExpressionFactory in project jersey by jersey.

the class LinkELContextTest method testNestedExpression.

@Test
public void testNestedExpression() {
    System.out.println("Nested expression");
    ExpressionFactory factory = ExpressionFactory.newInstance();
    LinkELContext context = new LinkELContext(new OuterEntityBean(), null);
    ValueExpression expr = factory.createValueExpression(context, "${entity.inner.id}", String.class);
    Object value = expr.getValue(context);
    assertEquals(ID, value);
}
Also used : ExpressionFactory(javax.el.ExpressionFactory) ValueExpression(javax.el.ValueExpression) Test(org.junit.Test)

Aggregations

ExpressionFactory (javax.el.ExpressionFactory)39 ValueExpression (javax.el.ValueExpression)28 Test (org.junit.Test)24 ELContext (javax.el.ELContext)22 ELContextImpl (org.apache.jasper.el.ELContextImpl)15 ELException (javax.el.ELException)4 ValueReference (javax.el.ValueReference)3 IOException (java.io.IOException)2 StringTokenizer (java.util.StringTokenizer)2 BeanManager (javax.enterprise.inject.spi.BeanManager)2 FacesException (javax.faces.FacesException)2 FacesContext (javax.faces.context.FacesContext)2 ExpressionFactoryImpl (de.odysseus.el.ExpressionFactoryImpl)1 SimpleContext (de.odysseus.el.util.SimpleContext)1 PrivilegedActionException (java.security.PrivilegedActionException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ELResolver (javax.el.ELResolver)1 ServletContextEvent (javax.servlet.ServletContextEvent)1