Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-129

Inner type attributes cannot be resolved in expressions

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.1.1
    • Labels:
      None
    • Environment:

      JDK 6

      Description

      When using inner types e.g. for unit tests, it is impossible to resolve bean attributes from beans that are otherwise available in the JexlContext. I don't know about the implications for real world systems, but in testing this can be a pain.

      Junit Example:

      package test;

      import org.apache.commons.jexl2.Expression;
      import org.apache.commons.jexl2.JexlContext;
      import org.apache.commons.jexl2.JexlEngine;
      import org.apache.commons.jexl2.MapContext;
      import org.junit.Test;

      import static junit.framework.Assert.assertEquals;

      public class TestJEXL {
      @Test
      public void test()

      { JexlEngine jexl = new JexlEngine(); Expression exp = jexl.createExpression("b.i + b.i"); FakeBean b = new FakeBean(); JexlContext jc = new MapContext(); jc.set("b", b); Object results = exp.evaluate(jc); System.out.println(results); assertEquals(20,results); }

      private static class FakeBean {
      private int i = 10;
      private String key = "myval";

      public int getI()

      { return i; }

      public void setI(int i)

      { this.i = i; }

      public String getKey()

      { return key; }

      public void setKey(String key)

      { this.key = key; }

      }
      }

        Attachments

          Activity

            People

            • Assignee:
              henrib Henri Biestro
              Reporter:
              aagudo Antonio Agudo
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: