This is an automated email from the ASF dual-hosted git repository. henrib pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
The following commit(s) were added to refs/heads/master by this push: new 0028d9a JEXL-348: unit test, same as JEXL-346 0028d9a is described below commit 0028d9a5ae54046de8edcecd6aa11fc43e61f558 Author: henrib <hen...@apache.org> AuthorDate: Wed Jun 2 08:52:35 2021 +0200 JEXL-348: unit test, same as JEXL-346 --- .../org/apache/commons/jexl3/ContextNamespaceTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java b/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java index fb928cb..cc397a8 100644 --- a/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java +++ b/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java @@ -134,6 +134,24 @@ public class ContextNamespaceTest extends JexlTestCase { Assert.assertEquals(169, result); } + public static class Ns348 { + public static int func(int y) { return 42 * y;} + } + + @Test + public void testNamespace348() throws Exception { + JexlContext ctxt = new MapContext(); + Map<String, Object> ns = new HashMap<String, Object>(); + ns.put("ns", Ns348.class); + String src = "empty(x) ? ns:func(y) : z"; + final JexlEngine jexl = new JexlBuilder().safe(false).namespaces(ns).create(); + final JexlScript script = jexl.createScript(src, "x", "y", "z"); + Object result = script.execute(ctxt, null, 1, 169); + Assert.assertEquals(42, result); + result = script.execute(ctxt, "42", 1, 169); + Assert.assertEquals(169, result); + } + @Test public void testNamespacePragmaString() throws Exception { final JexlEngine jexl = new JexlBuilder().create();