Search in sources :

Example 31 with MethodExpression

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

the class TestMethodExpressionImpl method testBug50449a.

@Test
public void testBug50449a() throws Exception {
    MethodExpression me1 = factory.createMethodExpression(context, "${beanB.sayHello()}", null, null);
    String actual = (String) me1.invoke(context, null);
    Assert.assertEquals("Hello from B", actual);
}
Also used : MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 32 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithVarArgsABB.

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

Example 33 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithVarArgsAAB.

@Test
public void testInvokeWithVarArgsAAB() throws Exception {
    MethodExpression me4 = factory.createMethodExpression(context, "${beanC.sayHello(beanAA,beanB,beanB)}", null, null);
    Exception e = null;
    try {
        me4.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 34 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithSuperAABBB.

@Test
public void testInvokeWithSuperAABBB() {
    // The Java compiler reports this as ambiguous. Using the parameter that
    // matches exactly seems reasonable to limit the scope of the method
    // search so the EL will find a match.
    MethodExpression me10 = factory.createMethodExpression(context, "${beanC.sayHello(beanAA,beanBBB)}", null, null);
    Object r10 = me10.invoke(context, null);
    Assert.assertEquals("AAB: Hello AA from BBB", r10.toString());
}
Also used : MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 35 with MethodExpression

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

the class TestMethodExpressionImpl method testBug57855c.

@Test
public void testBug57855c() {
    MethodExpression me = factory.createMethodExpression(context, "${beanB.echo}", null, new Class[] { String.class });
    me.invoke(context, null);
}
Also used : 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