Search in sources :

Example 11 with MethodExpression

use of javax.el.MethodExpression in project tomcat by apache.

the class TestMethodExpressionImpl method testBug53792a.

@Test
public void testBug53792a() {
    MethodExpression me = factory.createMethodExpression(context, "${beanA.setBean(beanB)}", null, new Class<?>[] { TesterBeanB.class });
    me.invoke(context, null);
    me = factory.createMethodExpression(context, "${beanB.setName('" + BUG53792 + "')}", null, new Class<?>[] { TesterBeanB.class });
    me.invoke(context, null);
    ValueExpression ve = factory.createValueExpression(context, "#{beanA.getBean().name}", java.lang.String.class);
    String actual = (String) ve.getValue(context);
    assertEquals(BUG53792, actual);
}
Also used : ValueExpression(javax.el.ValueExpression) MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 12 with MethodExpression

use of javax.el.MethodExpression in project tomcat by apache.

the class TestMethodExpressionImpl method testIsParametersProvided.

@Test
public void testIsParametersProvided() {
    MethodExpression me1 = factory.createMethodExpression(context, "${beanB.getName}", String.class, new Class<?>[] {});
    MethodExpression me2 = factory.createMethodExpression(context, "${beanB.sayHello('JUnit')}", String.class, new Class<?>[] { String.class });
    assertFalse(me1.isParametersProvided());
    assertTrue(me2.isParametersProvided());
}
Also used : MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 13 with MethodExpression

use of javax.el.MethodExpression in project tomcat by apache.

the class TestMethodExpressionImpl method testInvokeWithSuperABReturnTypeParamTypes.

@Test
public void testInvokeWithSuperABReturnTypeParamTypes() {
    MethodExpression me5 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanB)}", String.class, new Class<?>[] { TesterBeanA.class, TesterBeanB.class });
    Object r5 = me5.invoke(context, null);
    assertEquals("AB: Hello A from B", r5.toString());
}
Also used : MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 14 with MethodExpression

use of javax.el.MethodExpression in project tomcat by apache.

the class TestMethodExpressionImpl method testInvokeWithSuperAAB.

@Test
public void testInvokeWithSuperAAB() {
    MethodExpression me8 = factory.createMethodExpression(context, "${beanC.sayHello(beanAA,beanB)}", null, null);
    Object r8 = me8.invoke(context, null);
    assertEquals("AAB: Hello AA from B", r8.toString());
}
Also used : MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 15 with MethodExpression

use of javax.el.MethodExpression in project tomcat by apache.

the class TestMethodExpressionImpl method testInvokeWithSuperAABB.

@Test
public void testInvokeWithSuperAABB() {
    MethodExpression me9 = factory.createMethodExpression(context, "${beanC.sayHello(beanAA,beanBB)}", null, null);
    Exception e = null;
    try {
        me9.invoke(context, null);
    } catch (Exception e1) {
        e = e1;
    }
    // Expected to fail
    assertNotNull(e);
}
Also used : MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Aggregations

MethodExpression (javax.el.MethodExpression)42 Test (org.junit.Test)41 ValueExpression (javax.el.ValueExpression)7 ELException (javax.el.ELException)1 MethodNotFoundException (javax.el.MethodNotFoundException)1 VariableMapper (javax.el.VariableMapper)1