[ 
https://issues.apache.org/jira/browse/JEXL-356?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Osipov updated JEXL-356:
--------------------------------
    Description: 
this test case fails after upgrading to 3.2 . also fails on 3.2.1

{code:java} 
 @Test
    public void testJexlActionExecutionWithFailureWhenMethodIsNotFound() {
        JexlEngine jexlEngine = new 
JexlBuilder().silent(false).strict(true).create();
    
        // given
        JexlScript action = jexlEngine.createScript("person.setBlah(true);")
        MapContext mc = new MapContext();
        Person foo = new Person("foo", 20);
        mc.put("person", foo);

        // when
        Assertions.assertThatThrownBy(() -> action.execute(mc))
                .isInstanceOf(JexlException.Method.class)
                .hasMessage("org.jeasy.rules.jexl.JexlRuleAction.<init>@1:7 
unsolvable function/method 'setBlah'");

        // then
        // excepted exception
    }
    
    public class Person {

    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    
        public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

}
{code}

  was:
this test case fails after upgrading to 3.2 . also fails on 3.2.1

 

 @Test
    public void testJexlActionExecutionWithFailureWhenMethodIsNotFound() {
        JexlEngine jexlEngine = new 
JexlBuilder().silent(false).strict(true).create();
    
        // given
        JexlScript action = jexlEngine.createScript("person.setBlah(true);")
        MapContext mc = new MapContext();
        Person foo = new Person("foo", 20);
        mc.put("person", foo);

        // when
        Assertions.assertThatThrownBy(() -> action.execute(mc))
                .isInstanceOf(JexlException.Method.class)
                .hasMessage("org.jeasy.rules.jexl.JexlRuleAction.<init>@1:7 
unsolvable function/method 'setBlah'");

        // then
        // excepted exception
    }
    
    public class Person {

    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    
        public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

}


> no exception thrown when a method does not exist
> ------------------------------------------------
>
>                 Key: JEXL-356
>                 URL: https://issues.apache.org/jira/browse/JEXL-356
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.2, 3.2.1
>            Reporter: ai
>            Priority: Major
>
> this test case fails after upgrading to 3.2 . also fails on 3.2.1
> {code:java} 
>  @Test
>     public void testJexlActionExecutionWithFailureWhenMethodIsNotFound() {
>         JexlEngine jexlEngine = new 
> JexlBuilder().silent(false).strict(true).create();
>     
>         // given
>         JexlScript action = jexlEngine.createScript("person.setBlah(true);")
>         MapContext mc = new MapContext();
>         Person foo = new Person("foo", 20);
>         mc.put("person", foo);
>         // when
>         Assertions.assertThatThrownBy(() -> action.execute(mc))
>                 .isInstanceOf(JexlException.Method.class)
>                 .hasMessage("org.jeasy.rules.jexl.JexlRuleAction.<init>@1:7 
> unsolvable function/method 'setBlah'");
>         // then
>         // excepted exception
>     }
>     
>     public class Person {
>     private String name;
>     private int age;
>     public Person(String name, int age) {
>         this.name = name;
>         this.age = age;
>     }
>     
>         public String getName() {
>         return name;
>     }
>     public void setName(String name) {
>         this.name = name;
>     }
>     public int getAge() {
>         return age;
>     }
>     public void setAge(int age) {
>         this.age = age;
>     }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to