Java Code Examples for javax.el.MethodExpression#invoke()

The following examples show how to use javax.el.MethodExpression#invoke() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Test
public void testBug53792a() {
    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}", java.lang.String.class);
    String actual = (String) ve.getValue(context);
    Assert.assertEquals(BUG53792, actual);
}
 
Example 2
Source File: TestMethodExpressionImpl.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@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);
    assertEquals(Integer.valueOf(BUG53792.length()), actual);
}
 
Example 3
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@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);
}
 
Example 4
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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());
}
 
Example 5
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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);
}
 
Example 6
Source File: TestMethodExpressionImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@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
    assertNotNull(e);
}
 
Example 7
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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());
}
 
Example 8
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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);
}
 
Example 9
Source File: TestMethodExpressionImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testBug57855e() {
    MethodExpression me = factory.createMethodExpression(context,
            "${beanB.echo}", null , new Class[]{String.class});
    Object r = me.invoke(context, new String[] { "aaa", "bbb" });
    assertEquals("aaa, bbb", r.toString());
}
 
Example 10
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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());
}
 
Example 11
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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);
}
 
Example 12
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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);
}
 
Example 13
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Test
public void testInvokeWithSuper() {
    MethodExpression me = factory.createMethodExpression(context,
            "${beanA.setBean(beanBB)}", null ,
            new Class<?>[] { TesterBeanB.class });
    me.invoke(context, null);
    ValueExpression ve = factory.createValueExpression(context,
            "${beanA.bean.name}", String.class);
    Object r = ve.getValue(context);
    Assert.assertEquals("BB", r);
}
 
Example 14
Source File: TestMethodExpressionImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeWithSuper() {
    MethodExpression me = factory.createMethodExpression(context,
            "${beanA.setBean(beanBB)}", null ,
            new Class<?>[] { TesterBeanB.class });
    me.invoke(context, null);
    ValueExpression ve = factory.createValueExpression(context,
            "${beanA.bean.name}", String.class);
    Object r = ve.getValue(context);
    assertEquals("BB", r);
}
 
Example 15
Source File: TestMethodExpressionImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeWithSuperAAB() {
    MethodExpression me8 = factory.createMethodExpression(context,
            "${beanC.sayHello(beanAA,beanB)}", null , null);
    Object r8 = me8.invoke(context, null);
    assertEquals("AAB: Hello AA from B", r8.toString());
}
 
Example 16
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@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());
}
 
Example 17
Source File: TestMethodExpressionImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeWithVarArgsABB() throws Exception {
    MethodExpression me2 = factory.createMethodExpression(context,
            "${beanC.sayHello(beanA,beanBB,beanBB)}", null , null);
    Object r2 = me2.invoke(context, null);
    assertEquals("ABB[]: Hello A from BB, BB", r2.toString());
}
 
Example 18
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Test
public void testBug57855c() {
    MethodExpression me = factory.createMethodExpression(context,
            "${beanB.echo}", null , new Class[]{String.class});
    me.invoke(context, null);
}
 
Example 19
Source File: TestMethodExpressionImpl.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Test
public void testBug57855c() {
    MethodExpression me = factory.createMethodExpression(context,
            "${beanB.echo}", null , new Class[]{String.class});
    me.invoke(context, null);
}
 
Example 20
Source File: TestMethodExpressionImpl.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Test(expected=IllegalArgumentException.class)
public void testBug60844() {
    MethodExpression me2 = factory.createMethodExpression(context,
            "${beanC.sayHello}", null , new Class[]{ TesterBeanA.class, TesterBeanB.class});
    me2.invoke(context, new Object[] { new Object() });
}