Search in sources :

Example 41 with MethodExpression

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

the class TestMethodExpressionImpl method testBug52445a.

@Test
public void testBug52445a() {
    MethodExpression me = factory.createMethodExpression(context, "${beanA.setBean(beanBB)}", null, new Class<?>[] { TesterBeanB.class });
    me.invoke(context, null);
    MethodExpression me1 = factory.createMethodExpression(context, "${beanA.bean.sayHello()}", null, null);
    String actual = (String) me1.invoke(context, null);
    Assert.assertEquals("Hello from BB", actual);
}
Also used : MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 42 with MethodExpression

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

the class TestMethodExpressionImpl method testBugPrimitives.

@Test
public void testBugPrimitives() throws Exception {
    MethodExpression me = factory.createMethodExpression(context, "${beanA.setValLong(5)}", null, null);
    me.invoke(context, null);
    ValueExpression ve = factory.createValueExpression(context, "#{beanA.valLong}", java.lang.String.class);
    Assert.assertEquals("5", ve.getValue(context));
}
Also used : ValueExpression(jakarta.el.ValueExpression) MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 43 with MethodExpression

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

the class TestMethodExpressionImpl method testBug57855d.

@Test
public void testBug57855d() {
    MethodExpression me = factory.createMethodExpression(context, "${beanB.echo}", null, new Class[] { String.class });
    Object r = me.invoke(context, new String[] { "aaa" });
    Assert.assertEquals("aaa", r.toString());
}
Also used : MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 44 with MethodExpression

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

the class TestMethodExpressionImpl method testBug57855e.

@Test(expected = MethodNotFoundException.class)
public void testBug57855e() {
    MethodExpression me = factory.createMethodExpression(context, "${beanB.echo}", null, new Class[] { String.class });
    Object r = me.invoke(context, new String[] { "aaa", "bbb" });
    Assert.assertEquals("aaa, bbb", r.toString());
}
Also used : MethodExpression(jakarta.el.MethodExpression) Test(org.junit.Test)

Example 45 with MethodExpression

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

the class TestMethodExpressionImpl method testInvokeWithSuperABNoReturnTypeNoParamTypes.

@Test
public void testInvokeWithSuperABNoReturnTypeNoParamTypes() {
    MethodExpression me2 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanB)}", null, null);
    Object r2 = me2.invoke(context, null);
    Assert.assertEquals("AB: Hello A from B", r2.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