You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2013/11/25 14:35:57 UTC
svn commit: r1545274 [3/3] - in /commons/proper/jexl/trunk/src:
main/java/org/apache/commons/jexl3/
main/java/org/apache/commons/jexl3/internal/
main/java/org/apache/commons/jexl3/internal/introspection/
main/java/org/apache/commons/jexl3/introspection...
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ForEachTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ForEachTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ForEachTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ForEachTest.java Mon Nov 25 13:35:55 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,102 +36,102 @@ public class ForEachTest extends JexlTes
}
public void testForEachWithEmptyStatement() throws Exception {
- JexlExpression e = JEXL.createExpression("for(item : list) ;");
+ JexlScript e = JEXL.createScript("for(item : list) ;");
JexlContext jc = new MapContext();
jc.set("list", Collections.emptyList());
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertNull("Result is not null", o);
}
public void testForEachWithEmptyList() throws Exception {
- JexlExpression e = JEXL.createExpression("for(item : list) 1+1");
+ JexlScript e = JEXL.createScript("for(item : list) 1+1");
JexlContext jc = new MapContext();
jc.set("list", Collections.emptyList());
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertNull("Result is not null", o);
}
public void testForEachWithArray() throws Exception {
- JexlExpression e = JEXL.createExpression("for(item : list) item");
+ JexlScript e = JEXL.createScript("for(item : list) item");
JexlContext jc = new MapContext();
jc.set("list", new Object[] {"Hello", "World"});
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not last evaluated expression", "World", o);
}
public void testForEachWithCollection() throws Exception {
- JexlExpression e = JEXL.createExpression("for(item : list) item");
+ JexlScript e = JEXL.createScript("for(item : list) item");
JexlContext jc = new MapContext();
jc.set("list", Arrays.asList(new Object[] {"Hello", "World"}));
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not last evaluated expression", "World", o);
}
public void testForEachWithEnumeration() throws Exception {
- JexlExpression e = JEXL.createExpression("for(item : list) item");
+ JexlScript e = JEXL.createScript("for(item : list) item");
JexlContext jc = new MapContext();
jc.set("list", new StringTokenizer("Hello,World", ","));
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not last evaluated expression", "World", o);
}
public void testForEachWithIterator() throws Exception {
- JexlExpression e = JEXL.createExpression("for(item : list) item");
+ JexlScript e = JEXL.createScript("for(item : list) item");
JexlContext jc = new MapContext();
jc.set("list", Arrays.asList(new Object[] {"Hello", "World"}).iterator());
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not last evaluated expression", "World", o);
}
public void testForEachWithMap() throws Exception {
- JexlExpression e = JEXL.createExpression("for(item : list) item");
+ JexlScript e = JEXL.createScript("for(item : list) item");
JexlContext jc = new MapContext();
Map<?, ?> map = System.getProperties();
String lastProperty = (String) new ArrayList<Object>(map.values()).get(System.getProperties().size() - 1);
jc.set("list", map);
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not last evaluated expression", lastProperty, o);
}
public void testForEachWithBlock() throws Exception {
- JexlExpression exs0 = JEXL.createExpression("for(in : list) { x = x + in; }");
- JexlExpression exs1 = JEXL.createExpression("foreach(item in list) { x = x + item; }");
- JexlExpression []exs = { exs0, exs1 };
+ JexlScript exs0 = JEXL.createScript("for(in : list) { x = x + in; }");
+ JexlScript exs1 = JEXL.createScript("foreach(item in list) { x = x + item; }");
+ JexlScript []exs = { exs0, exs1 };
JexlContext jc = new MapContext();
jc.set("list", new Object[] {"2", "3"});
for(int ex = 0; ex < exs.length; ++ex) {
jc.set("x", new Integer(1));
- Object o = exs[ex].evaluate(jc);
+ Object o = exs[ex].execute(jc);
assertEquals("Result is wrong", new Integer(6), o);
assertEquals("x is wrong", new Integer(6), jc.get("x"));
}
}
public void testForEachWithListExpression() throws Exception {
- JexlExpression e = JEXL.createExpression("for(item : list.keySet()) item");
+ JexlScript e = JEXL.createScript("for(item : list.keySet()) item");
JexlContext jc = new MapContext();
Map<?, ?> map = System.getProperties();
String lastKey = (String) new ArrayList<Object>(map.keySet()).get(System.getProperties().size() - 1);
jc.set("list", map);
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not last evaluated expression", lastKey, o);
}
-
+
public void testForEachWithProperty() throws Exception {
- JexlExpression e = JEXL.createExpression("for(item : list.cheeseList) item");
+ JexlScript e = JEXL.createScript("for(item : list.cheeseList) item");
JexlContext jc = new MapContext();
jc.set("list", new Foo());
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not last evaluated expression", "brie", o);
}
-
+
public void testForEachWithIteratorMethod() throws Exception {
- JexlExpression e = JEXL.createExpression("for(item : list.cheezy) item");
+ JexlScript e = JEXL.createScript("for(item : list.cheezy) item");
JexlContext jc = new MapContext();
jc.set("list", new Foo());
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not last evaluated expression", "brie", o);
}
}
\ No newline at end of file
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java Mon Nov 25 13:35:55 2013
@@ -32,10 +32,10 @@ public class IfTest extends JexlTestCase
* @throws Exception on any error
*/
public void testSimpleIfTrue() throws Exception {
- JexlExpression e = JEXL.createExpression("if (true) 1");
+ JexlScript e = JEXL.createScript("if (true) 1");
JexlContext jc = new MapContext();
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not 1", new Integer(1), o);
}
@@ -45,10 +45,10 @@ public class IfTest extends JexlTestCase
* @throws Exception on any error
*/
public void testSimpleIfFalse() throws Exception {
- JexlExpression e = JEXL.createExpression("if (false) 1");
+ JexlScript e = JEXL.createScript("if (false) 1");
JexlContext jc = new MapContext();
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertNull("Return value is not empty", o);
}
@@ -58,10 +58,10 @@ public class IfTest extends JexlTestCase
* @throws Exception on any error
*/
public void testSimpleElse() throws Exception {
- JexlExpression e = JEXL.createExpression("if (false) 1 else 2;");
+ JexlScript e = JEXL.createScript("if (false) 1 else 2;");
JexlContext jc = new MapContext();
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not 2", new Integer(2), o);
}
@@ -71,10 +71,10 @@ public class IfTest extends JexlTestCase
* @throws Exception on any error
*/
public void testBlockIfTrue() throws Exception {
- JexlExpression e = JEXL.createExpression("if (true) { 'hello'; }");
+ JexlScript e = JEXL.createScript("if (true) { 'hello'; }");
JexlContext jc = new MapContext();
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is wrong", "hello", o);
}
@@ -84,10 +84,10 @@ public class IfTest extends JexlTestCase
* @throws Exception on any error
*/
public void testBlockElse() throws Exception {
- JexlExpression e = JEXL.createExpression("if (false) {1} else {2 ; 3}");
+ JexlScript e = JEXL.createScript("if (false) {1} else {2 ; 3}");
JexlContext jc = new MapContext();
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is wrong", new Integer(3), o);
}
@@ -97,11 +97,11 @@ public class IfTest extends JexlTestCase
* @throws Exception on any error
*/
public void testIfWithSimpleExpression() throws Exception {
- JexlExpression e = JEXL.createExpression("if (x == 1) true;");
+ JexlScript e = JEXL.createScript("if (x == 1) true;");
JexlContext jc = new MapContext();
jc.set("x", new Integer(1));
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not true", Boolean.TRUE, o);
}
@@ -111,11 +111,11 @@ public class IfTest extends JexlTestCase
* @throws Exception on any error
*/
public void testIfWithArithmeticExpression() throws Exception {
- JexlExpression e = JEXL.createExpression("if ((x * 2) + 1 == 5) true;");
+ JexlScript e = JEXL.createScript("if ((x * 2) + 1 == 5) true;");
JexlContext jc = new MapContext();
jc.set("x", new Integer(2));
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not true", Boolean.TRUE, o);
}
@@ -125,11 +125,11 @@ public class IfTest extends JexlTestCase
* @throws Exception on any error
*/
public void testIfWithDecimalArithmeticExpression() throws Exception {
- JexlExpression e = JEXL.createExpression("if ((x * 2) == 5) true");
+ JexlScript e = JEXL.createScript("if ((x * 2) == 5) true");
JexlContext jc = new MapContext();
jc.set("x", new Float(2.5f));
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is not true", Boolean.TRUE, o);
}
@@ -139,11 +139,11 @@ public class IfTest extends JexlTestCase
* @throws Exception on any error
*/
public void testIfWithAssignment() throws Exception {
- JexlExpression e = JEXL.createExpression("if ((x * 2) == 5) {y = 1} else {y = 2;}");
+ JexlScript e = JEXL.createScript("if ((x * 2) == 5) {y = 1} else {y = 2;}");
JexlContext jc = new MapContext();
jc.set("x", new Float(2.5f));
- e.evaluate(jc);
+ e.execute(jc);
Object result = jc.get("y");
assertEquals("y has the wrong value", new Integer(1), result);
}
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java Mon Nov 25 13:35:55 2013
@@ -23,10 +23,15 @@ import java.math.MathContext;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.jexl3.internal.introspection.Uberspect;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import org.junit.Assert;
import org.junit.Test;
/**
- * Test cases for reported issues
+ * Test cases for reported issue .
*/
@SuppressWarnings("boxing")
public class IssuesTest extends JexlTestCase {
@@ -196,11 +201,11 @@ public class IssuesTest extends JexlTest
ctxt.set("a", null);
String[] exprs = {
- "10 + null",
- "a - 10",
- "b * 10",
- "a % b",
- "1000 / a"
+ //"10 + null",
+ //"a - 10",
+ //"b * 10",
+ "a % b"//,
+ //"1000 / a"
};
for (int e = 0; e < exprs.length; ++e) {
try {
@@ -501,35 +506,35 @@ public class IssuesTest extends JexlTest
}
public void test108() throws Exception {
- JexlExpression expr;
+ JexlScript expr;
Object value;
JexlEngine jexl = new Engine();
- expr = jexl.createExpression("size([])");
- value = expr.evaluate(null);
+ expr = jexl.createScript("size([])");
+ value = expr.execute(null);
assertEquals(0, value);
- expr = jexl.createExpression(expr.getParsedText());
- value = expr.evaluate(null);
+ expr = jexl.createScript(expr.getParsedText());
+ value = expr.execute(null);
assertEquals(0, value);
- expr = jexl.createExpression("if (true) { [] } else { {:} }");
- value = expr.evaluate(null);
+ expr = jexl.createScript("if (true) { [] } else { {:} }");
+ value = expr.execute(null);
assertTrue(value.getClass().isArray());
- expr = jexl.createExpression(expr.getParsedText());
- value = expr.evaluate(null);
+ expr = jexl.createScript(expr.getParsedText());
+ value = expr.execute(null);
assertTrue(value.getClass().isArray());
- expr = jexl.createExpression("size({:})");
- value = expr.evaluate(null);
+ expr = jexl.createScript("size({:})");
+ value = expr.execute(null);
assertEquals(0, value);
- expr = jexl.createExpression(expr.getParsedText());
- value = expr.evaluate(null);
+ expr = jexl.createScript(expr.getParsedText());
+ value = expr.execute(null);
assertEquals(0, value);
- expr = jexl.createExpression("if (false) { [] } else { {:} }");
- value = expr.evaluate(null);
+ expr = jexl.createScript("if (false) { [] } else { {:} }");
+ value = expr.execute(null);
assertTrue(value instanceof Map<?, ?>);
- expr = jexl.createExpression(expr.getParsedText());
- value = expr.evaluate(null);
+ expr = jexl.createScript(expr.getParsedText());
+ value = expr.execute(null);
assertTrue(value instanceof Map<?, ?>);
}
@@ -660,6 +665,10 @@ public class IssuesTest extends JexlTest
public String method() {
return "OK";
}
+
+ public String total(String tt) {
+ return "total " + tt;
+ }
}
public static class Foo125Context extends ObjectContext<Foo125> {
@@ -892,4 +901,172 @@ public class IssuesTest extends JexlTest
result = expr.evaluate(jc);
assertEquals("EXPR01 result", 22, result);
}
+
+ public void test137() throws Exception {
+ JexlEngine jexl = new Engine();
+ JexlContext jc = new MapContext();
+ JexlScript script;
+ JexlExpression expr;
+ Object result;
+
+ script = jexl.createScript("(x)->{ x }");
+ Assert.assertArrayEquals(new String[]{"x"}, script.getParameters());
+ result = script.execute(null, 42);
+ Assert.assertEquals(42, result);
+ }
+
+// public void test138() throws Exception {
+// MapContext ctxt = new MapContext();
+// ctxt.set("tz", java.util.TimeZone.class);
+// String source = ""
+// + "var currentDate = new('java.util.Date');"
+// + "var gmt = tz.getTimeZone('GMT');"
+// + "var cet = tz.getTimeZone('CET');"
+// + "var calendarGMT = new('java.util.GregorianCalendar' , gmt);"
+// + "var calendarCET = new('java.util.GregorianCalendar', cet);"
+// + "var diff = calendarCET.getTime() - calendarGMT.getTime();"
+// + "return diff";
+//
+// JexlEngine jexl = new Engine();
+// JexlScript script = jexl.createScript(source);
+// Object result = script.execute(ctxt);
+// Assert.assertNotNull(result);
+// }
+ public void test142() throws Exception {
+ JexlEngine jexl = new Engine();
+ JexlContext jc = new MapContext();
+ JexlScript script;
+ Object result;
+
+ script = jexl.createScript("map['']", "map");
+ result = script.execute(jc, Collections.singletonMap("", 42));
+ Assert.assertEquals(42, result);
+ }
+
+ public void test143() throws Exception {
+ JexlEngine jexl = new Engine();
+ JexlContext jc = new MapContext();
+ JexlScript script;
+ Object result;
+
+ script = jexl.createScript("var total = 10; total = (total - ((x < 3)? y : z)) / (total / 10); total", "x", "y", "z");
+ result = script.execute(jc, 2, 2, 1);
+ Assert.assertEquals(8, result);
+ script = jexl.createScript("var total = 10; total = (total - ((x < 3)? y : 1)) / (total / 10); total", "x", "y", "z");
+ result = script.execute(jc, 2, 2, 1);
+ Assert.assertEquals(8, result);
+ }
+
+ public void test144() throws Exception {
+ JexlEngine jexl = new Engine();
+ JexlContext jc = new MapContext();//ObjectContext<Foo125>(jexl, new Foo125());
+ JexlScript script;
+ Object result;
+ script = jexl.createScript("var total = 10; total('tt')");
+ try {
+ result = script.execute(jc);
+ Assert.fail("total() is not solvable");
+ } catch (JexlException.Method ambiguous) {
+ Assert.assertEquals("total", ambiguous.getMethod());
+ }
+ jc = new ObjectContext<Foo125>(jexl, new Foo125());
+ try {
+ result = script.execute(jc);
+ } catch (JexlException.Method ambiguous) {
+ Assert.fail("total() is solvable");
+ }
+ }
+
+ public void test145() throws Exception {
+ JexlEngine jexl = new Engine();
+ JexlContext jc = new MapContext();
+ JexlScript script = jexl.createScript("sum(TOTAL) - partial.sum() + partial['sub'].avg() - sum(partial.sub)");
+ Set<List<String>> vars = script.getVariables();
+
+ Assert.assertTrue(vars.size() == 3);
+ }
+
+ public void test143apache() throws Exception {
+ JexlEngine jexl = new Engine();
+ JexlExpression e = jexl.createExpression("9223372036854775806.5B");
+ JexlContext context = new MapContext();
+ String res = String.valueOf(e.evaluate(context));
+ Assert.assertEquals("9223372036854775806.5", res);
+ }
+
+ /**
+ * Test cases for empty array assignment.
+ */
+ public static class Quux144 {
+ String[] arr;
+ String[] arr2;
+
+ public Quux144() {
+ }
+
+ public String[] getArr() {
+ return arr;
+ }
+
+ public String[] getArr2() {
+ return arr2;
+ }
+
+ public void setArr(String[] arr) {
+ this.arr = arr;
+ }
+
+ public void setArr2(String[] arr2) {
+ this.arr2 = arr2;
+ }
+
+ // Overloaded setter with different argument type.
+ public void setArr2(Integer[] arr2) {
+ }
+ }
+
+ public void test144apache() throws Exception {
+ JexlEngine JEXL = new Engine();
+ JexlContext jc = new MapContext();
+ jc.set("quuxClass", Quux144.class);
+ JexlExpression create = JEXL.createExpression("quux = new(quuxClass)");
+ JexlExpression assignArray = JEXL.createExpression("quux.arr = [ 'hello', 'world' ]");
+ JexlExpression checkArray = JEXL.createExpression("quux.arr");
+
+ // test with a string
+ Quux144 quux = (Quux144) create.evaluate(jc);
+ assertNotNull("quux is null", quux);
+
+ // test with a nonempty string array
+ Object o = assignArray.evaluate(jc);
+ assertEquals("Result is not a string array", String[].class, o.getClass());
+ o = checkArray.evaluate(jc);
+ assertEquals("The array elements are equal", Arrays.asList("hello", "world"), Arrays.asList((String[]) o));
+
+ // test with a null array
+ assignArray = JEXL.createExpression("quux.arr = null");
+ o = assignArray.evaluate(jc);
+ assertNull("Result is not null", o);
+ o = checkArray.evaluate(jc);
+ assertNull("Result is not null", o);
+
+ // test with an empty array
+ assignArray = JEXL.createExpression("quux.arr = [ ]");
+ o = assignArray.evaluate(jc);
+ assertNotNull("Result is null", o);
+ o = checkArray.evaluate(jc);
+ assertEquals("The array elements are not equal", Arrays.asList(new String[0]), Arrays.asList((String[]) o));
+ assertEquals("The array size is not zero", 0, ((String[]) o).length);
+
+ // test with an empty array on the overloaded setter for different types.
+ // so, the assignment should fail with logging 'The ambiguous property, arr2, should have failed.'
+ try {
+ assignArray = JEXL.createExpression("quux.arr2 = [ ]");
+ o = assignArray.evaluate(jc);
+ fail("The arr2 property shouldn't be set due to its ambiguity (overloaded setters with different types).");
+ } catch (JexlException.Property e) {
+ //System.out.println("Expected ambiguous property setting exception: " + e);
+ }
+ assertNull("The arr2 property value should remain as null, not an empty array.", quux.arr2);
+ }
}
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JXLTTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JXLTTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JXLTTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JXLTTest.java Mon Nov 25 13:35:55 2013
@@ -16,8 +16,8 @@
*/
package org.apache.commons.jexl3;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.Logger;
+import org.apache.log4j.LogManager;
import java.io.PrintWriter;
import java.io.StringReader;
@@ -34,7 +34,7 @@ import java.util.Set;
public class JXLTTest extends JexlTestCase {
private static final JexlEngine ENGINE = new JexlBuilder().silent(false).cache(128).strict(true).create();
private static final JxltEngine JXLT = ENGINE.createJxltEngine();
- private static final Log LOG = LogFactory.getLog(JxltEngine.class);
+ private static final Logger LOG = LogManager.getLogger(JxltEngine.class);
private MapContext vars = new MapContext();
private JexlEvalContext context = null;
@@ -94,12 +94,14 @@ public class JXLTTest extends JexlTestCa
}
public void testStatement() throws Exception {
- context.set("froboz", new Froboz(123));
- JxltEngine.Expression check = JXLT.createExpression("${froboz.value = 32; froboz.plus10(); froboz.value}");
+ Froboz froboz = new Froboz(32);
+ context.set("froboz", froboz);
+ JxltEngine.Expression check = JXLT.createExpression("${ froboz.plus10() }");
Object o = check.evaluate(context);
- assertEquals("Result is not 42", new Integer(42), o);
+ assertEquals("Result is not 32", new Integer(32), o);
+ assertEquals("Result is not 42", 42, froboz.getValue());
Set<List<String>> evars = check.getVariables();
- assertEquals(2, evars.size());
+ assertEquals(1, evars.size());
}
public void testAssign() throws Exception {
@@ -269,6 +271,21 @@ public class JXLTTest extends JexlTestCa
}
}
+ public void testMalformedNested2() throws Exception {
+ try {
+ JxltEngine.Expression expr = JXLT.createExpression("#{${hi} world}");
+ JexlContext ctxt = new MapContext();
+ ctxt.set("hi", "hello");
+ expr.evaluate(ctxt);
+ fail("should be malformed");
+ } catch (JxltEngine.Exception xjexl) {
+ // expected
+ String xmsg = xjexl.getMessage();
+ LOG.warn(xmsg);
+ }
+ }
+
+
public void testBadContextNested() throws Exception {
try {
JxltEngine.Expression expr = JXLT.createExpression("#{${hi}+'.world'}");
@@ -353,6 +370,8 @@ public class JXLTTest extends JexlTestCa
JxltEngine.Template tl10n = JXLT.createTemplate(source, "list");
String dstr = tl10n.asString();
assertNotNull(dstr);
+ Set<List<String>> vars = tl10n.getVariables();
+ assertFalse(vars.isEmpty());
context.set("l10n", "valeur");
JxltEngine.Template tpFR = tl10n.prepare(context);
context.set("l10n", "value");
@@ -439,7 +458,44 @@ public class JXLTTest extends JexlTestCa
StringWriter strw = new StringWriter();
t.evaluate(context, strw);
String output = strw.toString();
- String ctl = "<report>\n\n\n 11</report>";
+ String ctl = "<report>\n\n\n 11\n</report>\n";
assertEquals(ctl, output);
}
+
+
+ public void testOneLiner() throws Exception {
+ JxltEngine.Template t = JXLT.createTemplate("$$", new StringReader("fourty-two"));
+ StringWriter strw = new StringWriter();
+ t.evaluate(context, strw);
+ String output = strw.toString();
+ assertEquals("fourty-two", output);
+ }
+
+ public void testOneLinerVar() throws Exception {
+ JxltEngine.Template t = JXLT.createTemplate("$$", new StringReader("fourty-${x}"));
+ StringWriter strw = new StringWriter();
+ context.set("x", "two");
+ t.evaluate(context, strw);
+ String output = strw.toString();
+ assertEquals("fourty-two", output);
+ }
+//
+// public void testDeferredTemplate() throws Exception {
+// JxltEngine.Template t = JXLT.createTemplate("$$", new StringReader(
+// "select * from \n"+
+// "##for(var c : tables) {\n"+
+// "#{c} \n"+
+// "##}\n"+
+// "where $(w}\n"
+// ));
+// StringWriter strw = new StringWriter();
+// context.set("tables", new String[]{"table1", "table2"});
+// t = t.prepare(context);
+// vars.clear();
+// context.set("w" ,"x=1");
+// t.evaluate(context, strw);
+// String output = strw.toString();
+// assertEquals("fourty-two", output);
+//
+// }
}
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/Jexl.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/Jexl.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/Jexl.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/Jexl.java Mon Nov 25 13:35:55 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTest.java Mon Nov 25 13:35:55 2013
@@ -649,7 +649,7 @@ public class JexlTest extends JexlTestCa
Foo foo = new Foo();
jc.set("foo", foo);
Parser parser = new Parser(new StringReader(";"));
- parser.parse(null, "aString = 'World';", null, false);
+ parser.parse(null, "aString = 'World';", null, false, false);
assertExpression(jc, "hello = 'world'", "world");
assertEquals("hello variable not changed", "world", jc.get("hello"));
@@ -677,7 +677,7 @@ public class JexlTest extends JexlTestCa
public void testUnicodeSupport() throws Exception {
JexlContext jc = new MapContext();
- assertExpression(jc, "'x' == 'U?ytkownik'", Boolean.FALSE);
+ assertExpression(jc, "'x' == '\\u0032?ytkownik'", Boolean.FALSE);
assertExpression(jc, "'c:\\some\\windows\\path'", "c:\\some\\windows\\path");
assertExpression(jc, "'foo\\u0020bar'", "foo\u0020bar");
assertExpression(jc, "'foo\\u0020\\u0020bar'", "foo\u0020\u0020bar");
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTestCase.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTestCase.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTestCase.java Mon Nov 25 13:35:55 2013
@@ -41,7 +41,7 @@ public class JexlTestCase extends TestCa
public JexlTestCase(String name) {
this(name, new JexlBuilder().strict(true).silent(false).cache(32).create());
}
-
+
protected JexlTestCase(String name, JexlEngine jexl) {
super(name);
JEXL = jexl;
@@ -55,7 +55,7 @@ public class JexlTestCase extends TestCa
public static JexlEngine createEngine(boolean lenient) {
return new JexlBuilder().arithmetic(new JexlArithmetic(!lenient)).cache(512).create();
}
-
+
/**
* Will force testing the debugger for each derived test class by
* recreating each expression from the JexlNode in the JexlEngine cache &
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/LambdaTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/LambdaTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/LambdaTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/LambdaTest.java Mon Nov 25 13:35:55 2013
@@ -38,16 +38,15 @@ public class LambdaTest extends JexlTest
public void testScriptContext() throws Exception {
JexlEngine jexl = new Engine();
JexlScript s = jexl.createScript("function(x) { x + x }");
- JexlScript fs = (JexlScript) s.execute(null);
- String fsstr = fs.toString();
+ String fsstr = s.getParsedText();
assertEquals("(x)->{ x + x; }", fsstr);
- assertEquals(42, fs.execute(null, 21));
+ assertEquals(42, s.execute(null, 21));
JexlScript s42 = jexl.createScript("s(21)");
JexlEvalContext ctxt = new JexlEvalContext();
- ctxt.set("s", fs);
+ ctxt.set("s", s);
Object result = s42.execute(ctxt);
assertEquals(42, result);
- result = s42.evaluate(ctxt);
+ result = s42.execute(ctxt);
assertEquals(42, result);
}
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/MethodTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/MethodTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/MethodTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/MethodTest.java Mon Nov 25 13:35:55 2013
@@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.commons.jexl3.introspection.JexlMethod;
import org.apache.commons.jexl3.junit.Asserter;
+import java.util.Arrays;
/**
* Tests for calling methods on objects
@@ -35,6 +36,11 @@ public class MethodTest extends JexlTest
}
public static class VarArgs {
+ public String callInts() {
+ int result = -5000;
+ return "Varargs:" + result;
+ }
+
public String callInts(Integer... args) {
int result = 0;
if (args != null) {
@@ -85,28 +91,6 @@ public class MethodTest extends JexlTest
}
}
- public static class Functor {
- public int ten() {
- return 10;
- }
-
- public int plus10(int num) {
- return num + 10;
- }
-
- public static int TWENTY() {
- return 20;
- }
-
- public static int PLUS20(int num) {
- return num + 20;
- }
-
- public static Class<?> NPEIfNull(Object x) {
- return x.getClass();
- }
- }
-
public static class EnhancedContext extends JexlEvalContext {
int factor = 6;
final Map<String, Object> funcs;
@@ -143,11 +127,11 @@ public class MethodTest extends JexlTest
public void testCallVarArgMethod() throws Exception {
VarArgs test = new VarArgs();
asserter.setVariable("test", test);
- asserter.assertExpression("test.callInts()", "Varargs:0");
- asserter.assertExpression("test.callInts(1)", "Varargs:1");
- asserter.assertExpression("test.callInts(1,2,3,4,5)", "Varargs:15");
- asserter.assertExpression("test.concat(['1', '2', '3'])", "1, 2, 3");
- asserter.assertExpression("test.concat('1', '2', '3')", "1, 2, 3");
+ asserter.assertExpression("test.callInts()", test.callInts());
+ asserter.assertExpression("test.callInts(1)", test.callInts(1));
+ asserter.assertExpression("test.callInts(1,2,3,4,5)", test.callInts(1,2,3,4,5));
+ asserter.assertExpression("test.concat(['1', '2', '3'])", test.concat(new String[]{"1", "2", "3"}));
+ asserter.assertExpression("test.concat('1', '2', '3')", test.concat("1", "2", "3"));
}
@@ -155,14 +139,14 @@ public class MethodTest extends JexlTest
VarArgs test = new VarArgs();
asserter.setVariable("test", test);
assertEquals("Mixed:1", test.callMixed(Integer.valueOf(1)));
- asserter.assertExpression("test.callMixed(1)", "Mixed:1");
+ asserter.assertExpression("test.callMixed(1)", test.callMixed(1));
// Java and JEXL equivalent behavior: 'Mixed:-999' expected
//{
assertEquals("Mixed:-999", test.callMixed(Integer.valueOf(1), (Integer[]) null));
asserter.assertExpression("test.callMixed(1, null)", "Mixed:-999");
//}
- asserter.assertExpression("test.callMixed(1,2)", "Mixed:3");
- asserter.assertExpression("test.callMixed(1,2,3,4,5)", "Mixed:15");
+ asserter.assertExpression("test.callMixed(1,2)", test.callMixed(1,2));
+ asserter.assertExpression("test.callMixed(1,2,3,4,5)", test.callMixed(1,2,3,4,5));
}
public void testCallJexlVarArgMethod() throws Exception {
@@ -175,8 +159,30 @@ public class MethodTest extends JexlTest
assertEquals("jexl:-1000", test.callMixed("jexl", (Integer[]) null));
asserter.assertExpression("test.callMixed('jexl', null)", "jexl:-1000");
//}
- asserter.assertExpression("test.callMixed('jexl', 2)", "jexl:2");
- asserter.assertExpression("test.callMixed('jexl',2,3,4,5)", "jexl:14");
+ asserter.assertExpression("test.callMixed('jexl', 2)", test.callMixed("jexl", 2));
+ asserter.assertExpression("test.callMixed('jexl',2,3,4,5)", test.callMixed("jexl",2,3,4,5));
+ }
+
+ public static class Functor {
+ public int ten() {
+ return 10;
+ }
+
+ public int plus10(int num) {
+ return num + 10;
+ }
+
+ public static int TWENTY() {
+ return 20;
+ }
+
+ public static int PLUS20(int num) {
+ return num + 20;
+ }
+
+ public static Class<?> NPEIfNull(Object x) {
+ return x.getClass();
+ }
}
public void testInvoke() throws Exception {
@@ -300,6 +306,139 @@ public class MethodTest extends JexlTest
assertEquals("Result is not 40", new Integer(40), o);
}
+ public static class Edge {
+ private Edge() {}
+
+ public int exec(int arg) {
+ return 1;
+ }
+
+ public int exec(int[] arg) {
+ return 20;
+ }
+
+ public int exec(String arg) {
+ return 2;
+ }
+
+ public int exec(String... arg) {
+ return 200;
+ }
+
+ public int exec(Object args) {
+ return 3;
+ }
+
+ public int exec(Object... args) {
+ return 4;
+ }
+
+ public int exec(Boolean x, int arg) {
+ return 1;
+ }
+
+ public int exec(Boolean x, int[] arg) {
+ return 20;
+ }
+
+ public int exec(Boolean x, String arg) {
+ return 2;
+ }
+
+ public int exec(Boolean x, Object args) {
+ return 3;
+ }
+
+ public int exec(Boolean x, Object... args) {
+ return 4;
+ }
+
+ public Class<?>[] execute(Object... args) {
+ Class<?>[] clazz = new Class<?>[args.length];
+ for(int a = 0; a < args.length; ++a) {
+ clazz[a] = args[a] != null? args[a].getClass() : Void.class;
+ }
+ return clazz;
+ }
+ }
+
+ private boolean eqExecute(Object lhs, Object rhs) {
+ if (lhs instanceof Class<?>[] && rhs instanceof Class<?>[]) {
+ Class<?>[] lhsa = (Class<?>[]) lhs;
+ Class<?>[] rhsa = (Class<?>[]) rhs;
+ return Arrays.deepEquals(lhsa, rhsa);
+ }
+ return false;
+ }
+
+
+ public void testNamespaceCallEdge() throws Exception {
+ java.util.Map<String, Object> funcs = new java.util.HashMap<String, Object>();
+ Edge func = new Edge();
+ funcs.put("func", func);
+
+ Object o;
+ Object c;
+ JexlExpression e;
+ JexlEvalContext jc = new EnhancedContext(funcs);
+ try {
+ for (int i = 0; i < 2; ++i) {
+ e = JEXL.createExpression("func:exec([1, 2])");
+ o = e.evaluate(jc);
+ assertEquals("exec(int[] arg): " + i, 20, o);
+
+ e = JEXL.createExpression("func:exec(1, 2)");
+ o = e.evaluate(jc);
+ assertEquals("exec(Object... args): " + i, 4, o);
+
+ e = JEXL.createExpression("func:exec([10.0, 20.0])");
+ o = e.evaluate(jc);
+ assertEquals("exec(Object args): " + i, 3, o);
+
+ e = JEXL.createExpression("func:exec('1', 2)");
+ o = e.evaluate(jc);
+ assertEquals("exec(Object... args): " + i, 4, o);
+
+ // no way to differentiate between a single arg call with an array and a vararg call with same args
+ assertEquals("exec(String... args): " + i, func.exec("1", "2"), func.exec(new String[]{"1", "2"}));
+ e = JEXL.createExpression("func:exec(['1', '2'])");
+ o = e.evaluate(jc);
+ assertEquals("exec(String... args): " + i, func.exec(new String[]{"1", "2"}), o);
+ e = JEXL.createExpression("func:exec('1', '2')");
+ o = e.evaluate(jc);
+ assertEquals("exec(String... args): " + i, func.exec("1", "2"), o);
+
+ e = JEXL.createExpression("func:exec(true, [1, 2])");
+ o = e.evaluate(jc);
+ assertEquals("exec(int[] arg): " + i, 20, o);
+
+ e = JEXL.createExpression("func:exec(true, 1, 2)");
+ o = e.evaluate(jc);
+ assertEquals("exec(Object... args): " + i, 4, o);
+
+ e = JEXL.createExpression("func:exec(true, ['1', '2'])");
+ o = e.evaluate(jc);
+ assertEquals("exec(Object args): " + i, 3, o);
+
+ e = JEXL.createExpression("func:exec(true, '1', '2')");
+ o = e.evaluate(jc);
+ assertEquals("exec(Object... args): " + i, 4, o);
+
+ e = JEXL.createExpression("func:execute(true, '1', '2')");
+ o = e.evaluate(jc);
+ c = func.execute(Boolean.TRUE, "1", "2");
+ assertTrue("execute(Object... args): " + i, eqExecute(o, c));
+
+ e = JEXL.createExpression("func:execute([true])");
+ o = e.evaluate(jc);
+ c = func.execute(new boolean[]{true});
+ assertTrue("execute(Object... args): " + i, eqExecute(o, c));
+ }
+ } catch (JexlException xjexl) {
+ fail(xjexl.toString());
+ }
+ }
+
public static class ScriptContext extends MapContext implements JexlContext.NamespaceResolver {
Map<String, Object> nsScript;
@@ -315,6 +454,20 @@ public class MethodTest extends JexlTest
if ("script".equals(name)) {
return nsScript;
}
+ if ("functor".equals(name)) {
+ return new JexlContext.NamespaceFunctor() {
+ @Override
+ public Object createFunctor(JexlContext context) {
+ Map<String, Object> values = new HashMap<String, Object>();
+ if ("gin".equals(context.get("base"))) {
+ values.put("drink", "gin fizz");
+ } else {
+ values.put("drink", "champaign");
+ }
+ return values;
+ }
+ };
+ }
return null;
}
}
@@ -389,4 +542,23 @@ public class MethodTest extends JexlTest
o = forty2.execute(context);
assertEquals("Result is not 42", new Integer(42), o);
}
+
+
+ public void testFizzCall() throws Exception {
+ ScriptContext context = new ScriptContext(new HashMap<String, Object>());
+
+ JexlScript bar = JEXL.createScript("functor:get('drink')");
+ Object o;
+ o = bar.execute(context);
+ assertEquals("Wrong choice", "champaign", o);
+ context.set("base", "gin");
+ o = bar.execute(context);
+ assertEquals("Wrong choice", "gin fizz", o);
+
+ // despite being called twice, the functor is created only once.
+ context.set("base", "wine");
+ bar = JEXL.createScript("var glass = functor:get('drink'); base = 'gin'; functor:get('drink')");
+ o = bar.execute(context);
+ assertEquals("Wrong choice", "champaign", o);
+ }
}
\ No newline at end of file
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ParseFailuresTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ParseFailuresTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ParseFailuresTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ParseFailuresTest.java Mon Nov 25 13:35:55 2013
@@ -16,8 +16,8 @@
*/
package org.apache.commons.jexl3;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.Logger;
+import org.apache.log4j.LogManager;
/**
* Tests for malformed expressions and scripts.
@@ -29,7 +29,7 @@ import org.apache.commons.logging.LogFac
*/
public class ParseFailuresTest extends JexlTestCase {
- static final Log LOGGER = LogFactory.getLog(ParseFailuresTest.class.getName());
+ static final Logger LOGGER = LogManager.getLogger(ParseFailuresTest.class.getName());
/**
* Create the test.
*
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ReadonlyContext.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ReadonlyContext.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ReadonlyContext.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ReadonlyContext.java Mon Nov 25 13:35:55 2013
@@ -18,8 +18,6 @@ package org.apache.commons.jexl3;
import java.math.MathContext;
import java.nio.charset.Charset;
-import org.apache.commons.jexl3.JexlContext;
-import org.apache.commons.jexl3.JexlEngine;
/**
* A readonly context wrapper.
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/SandboxTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/SandboxTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/SandboxTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/SandboxTest.java Mon Nov 25 13:35:55 2013
@@ -18,15 +18,15 @@ package org.apache.commons.jexl3;
import org.apache.commons.jexl3.annotations.NoJexl;
import org.apache.commons.jexl3.introspection.JexlSandbox;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* Tests sandbox features.
*/
public class SandboxTest extends JexlTestCase {
- static final Log LOGGER = LogFactory.getLog(SandboxTest.class.getName());
+ static final Logger LOGGER = LogManager.getLogger(SandboxTest.class.getName());
public SandboxTest() {
super("SandboxTest");
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java Mon Nov 25 13:35:55 2013
@@ -69,7 +69,6 @@ public class ScriptCallableTest extends
public void testCallableClosure() throws Exception {
JexlScript e = JEXL.createScript("function(t) {while(t);}");
- e = (JexlScript) e.execute(null);
Callable<Object> c = e.callable(null, Boolean.TRUE);
ExecutorService executor = Executors.newFixedThreadPool(1);
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java Mon Nov 25 13:35:55 2013
@@ -22,14 +22,14 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.Logger;
+import org.apache.log4j.LogManager;
/**
* Tests local variables.
*/
public class VarTest extends JexlTestCase {
- static final Log LOGGER = LogFactory.getLog(VarTest.class.getName());
+ static final Logger LOGGER = LogManager.getLogger(VarTest.class.getName());
public VarTest(String testName) {
super(testName);
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/WhileTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/WhileTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/WhileTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/WhileTest.java Mon Nov 25 13:35:55 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,29 +28,29 @@ public class WhileTest extends JexlTestC
}
public void testSimpleWhileFalse() throws Exception {
- JexlExpression e = JEXL.createExpression("while (false) ;");
+ JexlScript e = JEXL.createScript("while (false) ;");
JexlContext jc = new MapContext();
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertNull("Result is not null", o);
}
-
+
public void testWhileExecutesExpressionWhenLooping() throws Exception {
- JexlExpression e = JEXL.createExpression("while (x < 10) x = x + 1;");
+ JexlScript e = JEXL.createScript("while (x < 10) x = x + 1;");
JexlContext jc = new MapContext();
jc.set("x", new Integer(1));
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is wrong", new Integer(10), o);
}
public void testWhileWithBlock() throws Exception {
- JexlExpression e = JEXL.createExpression("while (x < 10) { x = x + 1; y = y * 2; }");
+ JexlScript e = JEXL.createScript("while (x < 10) { x = x + 1; y = y * 2; }");
JexlContext jc = new MapContext();
jc.set("x", new Integer(1));
jc.set("y", new Integer(1));
- Object o = e.evaluate(jc);
+ Object o = e.execute(jc);
assertEquals("Result is wrong", new Integer(512), o);
assertEquals("x is wrong", new Integer(10), jc.get("x"));
assertEquals("y is wrong", new Integer(512), jc.get("y"));
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/examples/ArrayTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/examples/ArrayTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/examples/ArrayTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/examples/ArrayTest.java Mon Nov 25 13:35:55 2013
@@ -71,10 +71,10 @@ public class ArrayTest extends TestCase
example(Output.JUNIT);
}
- /**
+ /**
* Command line entry point.
* @param args command line arguments
- * @throws Exception cos jexl does.
+ * @throws Exception cos jexl does.
*/
public static void main(String[] args) throws Exception {
example(Output.SYSTEM);
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/examples/Output.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/examples/Output.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/examples/Output.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/examples/Output.java Mon Nov 25 13:35:55 2013
@@ -47,7 +47,7 @@ public abstract class Output {
}
};
-
+
/**
* The output instance for the general outputing to System.out.
*/
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/internal/introspection/DiscoveryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/internal/introspection/DiscoveryTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/internal/introspection/DiscoveryTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/internal/introspection/DiscoveryTest.java Mon Nov 25 13:35:55 2013
@@ -29,7 +29,7 @@ import java.util.Map;
/**
* Tests for checking introspection discovery.
- *
+ *
* @since 2.0
*/
public class DiscoveryTest extends JexlTestCase {
Added: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java?rev=1545274&view=auto
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java (added)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java Mon Nov 25 13:35:55 2013
@@ -0,0 +1,320 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.jexl3.introspection;
+
+import org.apache.commons.jexl3.JexlBuilder;
+import org.apache.commons.jexl3.JexlContext;
+import org.apache.commons.jexl3.JexlEngine;
+import org.apache.commons.jexl3.JexlException;
+import org.apache.commons.jexl3.JexlScript;
+import org.apache.commons.jexl3.JexlTestCase;
+import org.apache.commons.jexl3.MapContext;
+import org.apache.commons.jexl3.annotations.NoJexl;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.LogManager;
+
+/**
+ * Tests sandbox features.
+ */
+public class SandboxTest extends JexlTestCase {
+ static final Logger LOGGER = LogManager.getLogger(SandboxTest.class.getName());
+
+ public SandboxTest() {
+ super("SandboxTest");
+ JEXL.setClassLoader(getClass().getClassLoader());
+ }
+
+ @NoJexl
+ public interface CantCallMe {
+ void tryMe();
+ }
+
+ public interface TryCallMe {
+ @NoJexl
+ void tryMeARiver();
+ }
+
+ public static abstract class CallMeNot {
+ public @NoJexl
+ String NONO = "should not be accessible!";
+
+ @NoJexl
+ public void callMeNot() {
+ throw new RuntimeException("should not be callable!");
+ }
+ }
+
+ public static class Foo extends CallMeNot implements CantCallMe, TryCallMe {
+ String name;
+ public String alias;
+
+ public @NoJexl Foo(String name, String notcallable) {
+ throw new RuntimeException("should not be callable!");
+ }
+
+ public Foo(String name) {
+ this.name = name;
+ this.alias = name + "-alias";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String Quux() {
+ return name + "-quux";
+ }
+
+ @NoJexl
+ public String cantCallMe() {
+ throw new RuntimeException("should not be callable!");
+ }
+
+ @Override
+ public void tryMe() {
+ throw new RuntimeException("should not be callable!");
+ }
+
+ @Override
+ public void tryMeARiver() {
+ throw new RuntimeException("should not be callable!");
+ }
+ }
+
+ public void testCtorBlack() throws Exception {
+ String expr = "new('" + Foo.class.getName() + "', '42')";
+ JexlScript script = JEXL.createScript(expr);
+ Object result;
+ result = script.execute(null);
+ assertEquals("42", ((Foo) result).getName());
+
+ JexlSandbox sandbox = new JexlSandbox();
+ sandbox.black(Foo.class.getName()).execute("");
+ JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).create();
+
+ script = sjexl.createScript(expr);
+ try {
+ result = script.execute(null);
+ fail("ctor should not be accessible");
+ } catch (JexlException.Method xmethod) {
+ // ok, ctor should not have been accessible
+ LOGGER.info(xmethod.toString());
+ }
+ }
+
+ public void testMethodBlack() throws Exception {
+ String expr = "foo.Quux()";
+ JexlScript script = JEXL.createScript(expr, "foo");
+ Foo foo = new Foo("42");
+ Object result;
+ result = script.execute(null, foo);
+ assertEquals(foo.Quux(), result);
+
+ JexlSandbox sandbox = new JexlSandbox();
+ sandbox.black(Foo.class.getName()).execute("Quux");
+ JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).create();
+
+ script = sjexl.createScript(expr, "foo");
+ try {
+ result = script.execute(null, foo);
+ fail("Quux should not be accessible");
+ } catch (JexlException.Method xmethod) {
+ // ok, Quux should not have been accessible
+ LOGGER.info(xmethod.toString());
+ }
+ }
+
+ public void testGetBlack() throws Exception {
+ String expr = "foo.alias";
+ JexlScript script = JEXL.createScript(expr, "foo");
+ Foo foo = new Foo("42");
+ Object result;
+ result = script.execute(null, foo);
+ assertEquals(foo.alias, result);
+
+ JexlSandbox sandbox = new JexlSandbox();
+ sandbox.black(Foo.class.getName()).read("alias");
+ JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).create();
+
+ script = sjexl.createScript(expr, "foo");
+ try {
+ result = script.execute(null, foo);
+ fail("alias should not be accessible");
+ } catch (JexlException.Property xvar) {
+ // ok, alias should not have been accessible
+ LOGGER.info(xvar.toString());
+ }
+ }
+
+ public void testSetBlack() throws Exception {
+ String expr = "foo.alias = $0";
+ JexlScript script = JEXL.createScript(expr, "foo", "$0");
+ Foo foo = new Foo("42");
+ Object result;
+ result = script.execute(null, foo, "43");
+ assertEquals("43", result);
+
+ JexlSandbox sandbox = new JexlSandbox();
+ sandbox.black(Foo.class.getName()).write("alias");
+ JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).create();
+
+ script = sjexl.createScript(expr, "foo", "$0");
+ try {
+ result = script.execute(null, foo, "43");
+ fail("alias should not be accessible");
+ } catch (JexlException.Property xvar) {
+ // ok, alias should not have been accessible
+ LOGGER.info(xvar.toString());
+ }
+ }
+
+ public void testCtorWhite() throws Exception {
+ String expr = "new('" + Foo.class.getName() + "', '42')";
+ JexlScript script;
+ Object result;
+
+ JexlSandbox sandbox = new JexlSandbox();
+ sandbox.white(Foo.class.getName()).execute("");
+ JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).create();
+
+ script = sjexl.createScript(expr);
+ result = script.execute(null);
+ assertEquals("42", ((Foo) result).getName());
+ }
+
+ public void testMethodWhite() throws Exception {
+ Foo foo = new Foo("42");
+ String expr = "foo.Quux()";
+ JexlScript script;
+ Object result;
+
+ JexlSandbox sandbox = new JexlSandbox();
+ sandbox.white(Foo.class.getName()).execute("Quux");
+ JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).create();
+
+ script = sjexl.createScript(expr, "foo");
+ result = script.execute(null, foo);
+ assertEquals(foo.Quux(), result);
+ }
+
+ public void testMethodNoJexl() throws Exception {
+ Foo foo = new Foo("42");
+ String[] exprs = {
+ "foo.cantCallMe()",
+ "foo.tryMe()",
+ "foo.tryMeARiver()",
+ "foo.callMeNot()",
+ "foo.NONO",
+ "new('org.apache.commons.jexl3.SandboxTest$Foo', 'one', 'two')"
+ };
+ JexlScript script;
+ Object result;
+
+ JexlEngine sjexl = new JexlBuilder().strict(true).create();
+ for (String expr : exprs) {
+ script = sjexl.createScript(expr, "foo");
+ try {
+ result = script.execute(null, foo);
+ fail("should have not been possible");
+ } catch (JexlException.Method xjm) {
+ // ok
+ LOGGER.info(xjm.toString());
+ } catch (JexlException.Property xjm) {
+ // ok
+ LOGGER.info(xjm.toString());
+ }
+ }
+ }
+
+ public void testGetWhite() throws Exception {
+ Foo foo = new Foo("42");
+ String expr = "foo.alias";
+ JexlScript script;
+ Object result;
+
+ JexlSandbox sandbox = new JexlSandbox();
+ sandbox.white(Foo.class.getName()).read("alias");
+ sandbox.get(Foo.class.getName()).read().alias("alias", "ALIAS");
+ JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).create();
+
+ script = sjexl.createScript(expr, "foo");
+ result = script.execute(null, foo);
+ assertEquals(foo.alias, result);
+
+ script = sjexl.createScript("foo.ALIAS", "foo");
+ result = script.execute(null, foo);
+ assertEquals(foo.alias, result);
+ }
+
+ public void testSetWhite() throws Exception {
+ Foo foo = new Foo("42");
+ String expr = "foo.alias = $0";
+ JexlScript script;
+ Object result;
+
+ JexlSandbox sandbox = new JexlSandbox();
+ sandbox.white(Foo.class.getName()).write("alias");
+ JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).create();
+
+ script = sjexl.createScript(expr, "foo", "$0");
+ result = script.execute(null, foo, "43");
+ assertEquals("43", result);
+ assertEquals("43", foo.alias);
+ }
+
+ public void testRestrict() throws Exception {
+ JexlContext context = new MapContext();
+ context.set("System", System.class);
+ JexlSandbox sandbox = new JexlSandbox();
+ // only allow call to currentTimeMillis (avoid exit, gc, loadLibrary, etc)
+ sandbox.white(System.class.getName()).execute("currentTimeMillis");
+ // can not create a new file
+ sandbox.black(java.io.File.class.getName()).execute("");
+
+ JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).create();
+
+ String expr;
+ JexlScript script;
+ Object result;
+
+ script = sjexl.createScript("System.exit()");
+ try {
+ result = script.execute(context);
+ fail("should not allow calling exit!");
+ } catch (JexlException xjexl) {
+ LOGGER.info(xjexl.toString());
+ }
+
+ script = sjexl.createScript("new('java.io.File', '/tmp/should-not-be-created')");
+ try {
+ result = script.execute(context);
+ fail("should not allow creating a file");
+ } catch (JexlException xjexl) {
+ LOGGER.info(xjexl.toString());
+ }
+
+ expr = "System.currentTimeMillis()";
+ script = sjexl.createScript("System.currentTimeMillis()");
+ result = script.execute(context);
+ assertNotNull(result);
+ }
+}
Propchange: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/Asserter.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/Asserter.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/Asserter.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/Asserter.java Mon Nov 25 13:35:55 2013
@@ -23,11 +23,11 @@ import java.util.Map;
import junit.framework.Assert;
import org.apache.commons.jexl3.JexlEvalContext;
-import org.apache.commons.jexl3.JexlExpression;
import org.apache.commons.jexl3.JexlArithmetic;
import org.apache.commons.jexl3.JexlContext;
import org.apache.commons.jexl3.JexlEngine;
import org.apache.commons.jexl3.JexlException;
+import org.apache.commons.jexl3.JexlScript;
/**
* A utility class for performing JUnit based assertions using Jexl
@@ -95,8 +95,8 @@ public class Asserter extends Assert {
* fails
*/
public void assertExpression(String expression, Object expected) throws Exception {
- JexlExpression exp = engine.createScript(expression);
- Object value = exp.evaluate(context);
+ JexlScript exp = engine.createScript(expression);
+ Object value = exp.execute(context);
if (expected instanceof BigDecimal) {
JexlArithmetic jexla = engine.getArithmetic();
assertTrue("expression: " + expression, ((BigDecimal) expected).compareTo(jexla.toBigDecimal(value)) == 0);
@@ -122,8 +122,8 @@ public class Asserter extends Assert {
*/
public void failExpression(String expression, String matchException) throws Exception {
try {
- JexlExpression exp = engine.createScript(expression);
- exp.evaluate(context);
+ JexlScript exp = engine.createScript(expression);
+ exp.execute(context);
fail("expression: " + expression);
} catch (JexlException xjexl) {
if (matchException != null && !xjexl.getMessage().matches(matchException)) {
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/AsserterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/AsserterTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/AsserterTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/AsserterTest.java Mon Nov 25 13:35:55 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,9 +35,9 @@ public class AsserterTest extends JexlTe
public void testThis() throws Exception {
Asserter asserter = new Asserter(JEXL);
asserter.setVariable("this", new Foo());
-
+
asserter.assertExpression("this.get('abc')", "Repeat : abc");
-
+
try {
asserter.assertExpression("this.count", "Wrong Value");
fail("This method should have thrown an assertion exception");
@@ -55,10 +55,10 @@ public class AsserterTest extends JexlTe
asserter.assertExpression("person", "James");
asserter.assertExpression("size(person)", new Integer(5));
-
+
asserter.assertExpression("foo.getCount()", new Integer(5));
asserter.assertExpression("foo.count", new Integer(5));
-
+
try {
asserter.assertExpression("bar.count", new Integer(5));
fail("This method should have thrown an assertion exception");
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/parser/ParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/parser/ParserTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/parser/ParserTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/parser/ParserTest.java Mon Nov 25 13:35:55 2013
@@ -37,20 +37,20 @@ public class ParserTest extends TestCase
Parser parser = new Parser(new StringReader(";"));
JexlNode sn;
- sn = parser.parse(null, "foo = 1;", null, false);
+ sn = parser.parse(null, "foo = 1;", null, false, false);
assertNotNull("parsed node is null", sn);
- sn = parser.parse(null, "foo = \"bar\";", null, false);
+ sn = parser.parse(null, "foo = \"bar\";", null, false, false);
assertNotNull("parsed node is null", sn);
- sn = parser.parse(null, "foo = 'bar';", null, false);
+ sn = parser.parse(null, "foo = 'bar';", null, false, false);
assertNotNull("parsed node is null", sn);
}
public void testErrorAssign() throws Exception {
Parser parser = new Parser(new StringReader(";"));
try {
- JexlNode sn = parser.parse(null, "foo() = 1;", null, false);
+ JexlNode sn = parser.parse(null, "foo() = 1;", null, false, false);
fail("should have failed on invalid assignment");
} catch (JexlException.Parsing xparse) {
// ok
@@ -60,7 +60,7 @@ public class ParserTest extends TestCase
public void testErrorAmbiguous() throws Exception {
Parser parser = new Parser(new StringReader(";"));
try {
- JexlNode sn = parser.parse(null, "x = 1 y = 5", null, false);
+ JexlNode sn = parser.parse(null, "x = 1 y = 5", null, false, false);
fail("should have failed on ambiguous statement");
} catch (JexlException.Ambiguous xambiguous) {
// ok
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/scripting/JexlScriptEngineOptionalTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/scripting/JexlScriptEngineOptionalTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/scripting/JexlScriptEngineOptionalTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/scripting/JexlScriptEngineOptionalTest.java Mon Nov 25 13:35:55 2013
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.commons.jexl3.scripting;
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/scripting/JexlScriptEngineTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/scripting/JexlScriptEngineTest.java?rev=1545274&r1=1545273&r2=1545274&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/scripting/JexlScriptEngineTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/scripting/JexlScriptEngineTest.java Mon Nov 25 13:35:55 2013
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.commons.jexl3.scripting;
@@ -94,7 +94,7 @@ public class JexlScriptEngineTest extend
assertEquals(engine.getContext().getErrorWriter(),engine.eval("JEXL.err"));
assertEquals(System.class,engine.eval("JEXL.System"));
}
-
+
public void testNulls() throws Exception {
ScriptEngineManager manager = new ScriptEngineManager();
assertNotNull("Manager should not be null", manager);
Added: commons/proper/jexl/trunk/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/resources/log4j.xml?rev=1545274&view=auto
==============================================================================
--- commons/proper/jexl/trunk/src/test/resources/log4j.xml (added)
+++ commons/proper/jexl/trunk/src/test/resources/log4j.xml Mon Nov 25 13:35:55 2013
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
+<log4j:configuration>
+ <appender name="Console" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
+ </layout>
+ </appender>
+
+ <logger name="org.apache.commons.jexl3" additivity="false">
+ <level value="error"/>
+ <appender-ref ref="Console"/>
+ </logger>
+
+ <root>
+ <priority value="error"></priority>
+ <appender-ref ref="Console"/>
+ </root>
+</log4j:configuration>
\ No newline at end of file
Propchange: commons/proper/jexl/trunk/src/test/resources/log4j.xml
------------------------------------------------------------------------------
svn:eol-style = native