Search in sources :

Example 16 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithSuperAAAB.

@Test
public void testInvokeWithSuperAAAB() {
    MethodExpression me11 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanB)}", null, null);
    Object r11 = me11.invoke(context, null);
    Assert.assertEquals("AAB: Hello AAA from B", r11.toString());
}
Also used : MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 17 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithVarArgsAABB.

@Test
public void testInvokeWithVarArgsAABB() throws Exception {
    MethodExpression me5 = factory.createMethodExpression(context, "${beanC.sayHello(beanAA,beanBB,beanBB)}", null, null);
    Object r5 = me5.invoke(context, null);
    Assert.assertEquals("ABB[]: Hello AA from BB, BB", r5.toString());
}
Also used : MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 18 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithSuperAAABBB.

@Test
public void testInvokeWithSuperAAABBB() {
    MethodExpression me13 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanBBB)}", null, null);
    Exception e = null;
    try {
        me13.invoke(context, null);
    } catch (Exception e1) {
        e = e1;
    }
    // Expected to fail
    Assert.assertNotNull(e);
}
Also used : MethodExpression(jakarta.el.MethodExpression) MethodNotFoundException(jakarta.el.MethodNotFoundException) Test(org.junit.Test)

Example 19 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithVarArgsAAABB.

@Test
public void testInvokeWithVarArgsAAABB() throws Exception {
    MethodExpression me8 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanBB,beanBB)}", null, null);
    Object r8 = me8.invoke(context, null);
    Assert.assertEquals("ABB[]: Hello AAA from BB, BB", r8.toString());
}
Also used : MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 20 with MethodExpression

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

the class TestMethodExpressionImpl method testGetMethodInfo01.

@Test
public void testGetMethodInfo01() throws Exception {
    MethodExpression me = factory.createMethodExpression(context, "#{beanA.setName('New value')}", null, null);
    // This is the call that failed
    MethodInfo mi = me.getMethodInfo(context);
    // The rest is to check it worked correctly
    Assert.assertEquals(void.class, mi.getReturnType());
    Assert.assertEquals(1, mi.getParamTypes().length);
    Assert.assertEquals(String.class, mi.getParamTypes()[0]);
}
Also used : MethodInfo(jakarta.el.MethodInfo) MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Aggregations

MethodExpression (jakarta.el.MethodExpression)45 Test (org.junit.Test)44 ValueExpression (jakarta.el.ValueExpression)7 MethodNotFoundException (jakarta.el.MethodNotFoundException)6 MethodInfo (jakarta.el.MethodInfo)2 ELException (jakarta.el.ELException)1 VariableMapper (jakarta.el.VariableMapper)1