commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Day (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (JEXL-159) Difference in handling between Jexl expression evaluation and LazyDynaMap
Date Fri, 26 Jun 2015 11:20:04 GMT

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

Mike Day updated JEXL-159:
--------------------------
    Description: 

LazyDynaMap seems to support a full stop in the attribute name, but the Jexl expression evaluation
expects this to signify a nested object.
The second test below fails, even though the first assertion is correct. Please can you take
a look?

{code}
public class JexlTest {

	@Test
	public void testUnderscoreInName() {
        JexlEngine jexl = new JexlEngine();
        String jexlExp = "(x.length_mm * x.width)";
        Expression e = jexl.createExpression( jexlExp );
        JexlContext jc = new MapContext();

        LazyDynaMap object = new LazyDynaMap();
        object.set("length_mm", "10.0"); 
        object.set("width", "5.0");

        jc.set("x", object );

	    assertEquals(null, ((Double)e.evaluate(jc)).doubleValue(), 50d, 0d);
   }

	@Test
	public void testFullStopInName() {
        JexlEngine jexl = new JexlEngine();
        String jexlExp = "(x.length.mm * x.width)";
        Expression e = jexl.createExpression( jexlExp );
        JexlContext jc = new MapContext();

        LazyDynaMap object = new LazyDynaMap();
        object.set("length.mm", "10.0"); 
        object.set("width", "5.0");
        
        assertEquals(null, object.get("length.mm"), "10.0");

        jc.set("x", object );

	    assertEquals(null, ((Double)e.evaluate(jc)).doubleValue(), 50d, 0d);
	}
	
	@Test
	public void testFullStopInNameMakingSubObject() {
        JexlEngine jexl = new JexlEngine();
        String jexlExp = "(x.length.mm * x.width)";
        Expression e = jexl.createExpression( jexlExp );
        JexlContext jc = new MapContext();

        LazyDynaMap object = new LazyDynaMap();
        LazyDynaMap subObject = new LazyDynaMap();
        object.set("length", subObject);
        subObject.set("mm", "10.0");
        object.set("width", "5.0");
        
        jc.set("x", object );

	    assertEquals(null, ((Double)e.evaluate(jc)).doubleValue(), 50d, 0d);
	}

}
{code}

  was:
{code}
public class JexlTest {

	@Test
	public void testUnderscoreInName() {
        JexlEngine jexl = new JexlEngine();
        String jexlExp = "(x.length_mm * x.width)";
        Expression e = jexl.createExpression( jexlExp );
        JexlContext jc = new MapContext();

        LazyDynaMap object = new LazyDynaMap();
        object.set("length_mm", "10.0"); 
        object.set("width", "5.0");

        jc.set("x", object );

	    assertEquals(null, ((Double)e.evaluate(jc)).doubleValue(), 50d, 0d);
   }

	@Test
	public void testFullStopInName() {
        JexlEngine jexl = new JexlEngine();
        String jexlExp = "(x.length.mm * x.width)";
        Expression e = jexl.createExpression( jexlExp );
        JexlContext jc = new MapContext();

        LazyDynaMap object = new LazyDynaMap();
        object.set("length.mm", "10.0"); 
        object.set("width", "5.0");
        
        assertEquals(null, object.get("length.mm"), "10.0");

        jc.set("x", object );

	    assertEquals(null, ((Double)e.evaluate(jc)).doubleValue(), 50d, 0d);
	}
	
	@Test
	public void testFullStopInNameMakingSubObject() {
        JexlEngine jexl = new JexlEngine();
        String jexlExp = "(x.length.mm * x.width)";
        Expression e = jexl.createExpression( jexlExp );
        JexlContext jc = new MapContext();

        LazyDynaMap object = new LazyDynaMap();
        LazyDynaMap subObject = new LazyDynaMap();
        object.set("length", subObject);
        subObject.set("mm", "10.0");
        object.set("width", "5.0");
        
        jc.set("x", object );

	    assertEquals(null, ((Double)e.evaluate(jc)).doubleValue(), 50d, 0d);
	}

}
{code}


> Difference in handling between Jexl expression evaluation and LazyDynaMap
> -------------------------------------------------------------------------
>
>                 Key: JEXL-159
>                 URL: https://issues.apache.org/jira/browse/JEXL-159
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 2.1.1
>            Reporter: Mike Day
>
> LazyDynaMap seems to support a full stop in the attribute name, but the Jexl expression
evaluation expects this to signify a nested object.
> The second test below fails, even though the first assertion is correct. Please can you
take a look?
> {code}
> public class JexlTest {
> 	@Test
> 	public void testUnderscoreInName() {
>         JexlEngine jexl = new JexlEngine();
>         String jexlExp = "(x.length_mm * x.width)";
>         Expression e = jexl.createExpression( jexlExp );
>         JexlContext jc = new MapContext();
>         LazyDynaMap object = new LazyDynaMap();
>         object.set("length_mm", "10.0"); 
>         object.set("width", "5.0");
>         jc.set("x", object );
> 	    assertEquals(null, ((Double)e.evaluate(jc)).doubleValue(), 50d, 0d);
>    }
> 	@Test
> 	public void testFullStopInName() {
>         JexlEngine jexl = new JexlEngine();
>         String jexlExp = "(x.length.mm * x.width)";
>         Expression e = jexl.createExpression( jexlExp );
>         JexlContext jc = new MapContext();
>         LazyDynaMap object = new LazyDynaMap();
>         object.set("length.mm", "10.0"); 
>         object.set("width", "5.0");
>         
>         assertEquals(null, object.get("length.mm"), "10.0");
>         jc.set("x", object );
> 	    assertEquals(null, ((Double)e.evaluate(jc)).doubleValue(), 50d, 0d);
> 	}
> 	
> 	@Test
> 	public void testFullStopInNameMakingSubObject() {
>         JexlEngine jexl = new JexlEngine();
>         String jexlExp = "(x.length.mm * x.width)";
>         Expression e = jexl.createExpression( jexlExp );
>         JexlContext jc = new MapContext();
>         LazyDynaMap object = new LazyDynaMap();
>         LazyDynaMap subObject = new LazyDynaMap();
>         object.set("length", subObject);
>         subObject.set("mm", "10.0");
>         object.set("width", "5.0");
>         
>         jc.set("x", object );
> 	    assertEquals(null, ((Double)e.evaluate(jc)).doubleValue(), 50d, 0d);
> 	}
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message