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 1d2f3d3a JEXL-461 : add specific test that illustrates namespace
identifier feature usage
1d2f3d3a is described below
commit 1d2f3d3ab099f1dac50299fa51f0062a3505e21f
Author: Henrib <[email protected]>
AuthorDate: Fri May 29 09:43:02 2026 +0200
JEXL-461 : add specific test that illustrates namespace identifier feature
usage
---
.../org/apache/commons/jexl3/Issues400Test.java | 29 ++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java
b/src/test/java/org/apache/commons/jexl3/Issues400Test.java
index 9f1977c1..9da5fa64 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java
@@ -1209,5 +1209,34 @@ public class Issues400Test {
}
}
+ public static class Namespace461 {
+ public static int func(int i) {
+ return i * 42;
+ }
+ }
+
+ @Test
+ void test461() {
+ JexlFeatures f =
JexlFeatures.createDefault().namespaceIdentifier(true);
+ final JexlEngine jexl = new JexlBuilder()
+ .namespaces(Collections.singletonMap("z", Namespace461.class))
+ .features(f)
+ .create();
+
+ final JexlContext jc = new MapContext();
+ jc.set("x", 1);
+ jc.set("y", 2);
+ jc.set("my_function", jexl.createScript("(a) -> { a * 1000 }"));
+
+ JexlScript script = jexl.createScript("x != null ? x :
my_function(y)");
+ Object result = script.execute(jc);
+ assertEquals(1, result, "Result is not x");
+ script = jexl.createScript("x != null ? z:func(x) : my_function(y)");
+ result = script.execute(jc);
+ assertEquals(42, result);
+ script = jexl.createScript("y == 1 ? my_function(x) : z:func(x)");
+ result = script.execute(jc);
+ assertEquals(42, result);
+ }
}