Search in sources :

Example 21 with MethodExpression

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

the class TestMethodExpressionImpl method testBug53792d.

@Test
public void testBug53792d() {
    MethodExpression me = factory.createMethodExpression(context, "#{beanB.sayHello().length()}", null, new Class<?>[] {});
    Integer result = (Integer) me.invoke(context, new Object[] { "foo" });
    assertEquals(beanB.sayHello().length(), result.intValue());
}
Also used : MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 22 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithVarArgsABBB.

@Test
public void testInvokeWithVarArgsABBB() throws Exception {
    MethodExpression me3 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanBBB,beanBBB)}", null, null);
    Object r3 = me3.invoke(context, null);
    assertEquals("ABB[]: Hello A from BBB, BBB", r3.toString());
}
Also used : MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 23 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithSuperABB.

@Test
public void testInvokeWithSuperABB() {
    MethodExpression me6 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanBB)}", null, null);
    Object r6 = me6.invoke(context, null);
    assertEquals("ABB: Hello A from BB", r6.toString());
}
Also used : MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 24 with MethodExpression

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

the class TestMethodExpressionImpl method testBug57855a.

@Test(expected = IllegalArgumentException.class)
public void testBug57855a() {
    MethodExpression me = factory.createMethodExpression(context, "${beanAA.echo2}", null, new Class[] { String.class });
    me.invoke(context, new Object[0]);
}
Also used : MethodExpression(javax.el.MethodExpression) Test(org.junit.Test)

Example 25 with MethodExpression

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

the class TestMethodExpressionImpl method testInvoke.

@Test
public void testInvoke() {
    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 });
    MethodExpression me3 = factory.createMethodExpression(context, "${beanB.sayHello}", String.class, new Class<?>[] { String.class });
    assertEquals("B", me1.invoke(context, null));
    assertEquals("Hello JUnit from B", me2.invoke(context, null));
    assertEquals("Hello JUnit from B", me2.invoke(context, new Object[] { "JUnit2" }));
    assertEquals("Hello JUnit2 from B", me3.invoke(context, new Object[] { "JUnit2" }));
    assertEquals("Hello JUnit from B", me2.invoke(context, new Object[] { null }));
    assertEquals("Hello  from B", me3.invoke(context, new Object[] { null }));
}
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