Search in sources :

Example 6 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithVarArgsAAAB.

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

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

the class TestMethodExpressionImpl method testBug53792b.

@Test
public void testBug53792b() {
    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.length()}", java.lang.Integer.class);
    Integer actual = (Integer) ve.getValue(context);
    Assert.assertEquals(Integer.valueOf(BUG53792.length()), actual);
}
Also used : ValueExpression(jakarta.el.ValueExpression) MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 8 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithVarArgsAB.

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

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

the class TestMethodExpressionImpl method testInvokeWithSuperAAABB.

@Test
public void testInvokeWithSuperAAABB() {
    // 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 me12 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanBB)}", null, null);
    Object r12 = me12.invoke(context, null);
    Assert.assertEquals("ABB: Hello AAA from BB", r12.toString());
}
Also used : MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 10 with MethodExpression

use of jakarta.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);
    Assert.assertEquals("ABB[]: Hello A from BBB, BBB", r3.toString());
}
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