Search in sources :

Example 11 with MethodExpression

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

the class TestMethodExpressionImpl method testBug57855a.

@Test(expected = MethodNotFoundException.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(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 12 with MethodExpression

use of jakarta.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 });
    Assert.assertFalse(me1.isParametersProvided());
    Assert.assertTrue(me2.isParametersProvided());
}
Also used : MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 13 with MethodExpression

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

the class TestMethodExpressionImpl method testGetMethodInfo02.

@Test
public void testGetMethodInfo02() throws Exception {
    MethodExpression me = factory.createMethodExpression(context, "#{beanA.setName}", null, new Class[] { String.class });
    // 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)

Example 14 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithVarArgsAAABBB.

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

Example 15 with MethodExpression

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

the class TestMethodExpressionImpl method testBug49655.

/*
     * This is also tested implicitly in numerous places elsewhere in this
     * class.
     */
@Test
public void testBug49655() throws Exception {
    // This is the call the failed
    MethodExpression me = factory.createMethodExpression(context, "#{beanA.setName('New value')}", null, null);
    // The rest is to check it worked correctly
    me.invoke(context, null);
    ValueExpression ve = factory.createValueExpression(context, "#{beanA.name}", java.lang.String.class);
    Assert.assertEquals("New value", ve.getValue(context));
}
Also used : ValueExpression(jakarta.el.ValueExpression) 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