You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2009/08/05 12:00:05 UTC
svn commit: r801118 - in /commons/proper/jexl/branches/2.0/src:
main/java/org/apache/commons/jexl/junit/ test/java/org/apache/commons/jexl/
test/java/org/apache/commons/jexl/junit/
Author: sebb
Date: Wed Aug 5 10:00:05 2009
New Revision: 801118
URL: http://svn.apache.org/viewvc?rev=801118&view=rev
Log:
JEXL-68 Change Asserter to use provided JexlEngine
Modified:
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/junit/Asserter.java
commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java
commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArrayAccessTest.java
commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/MethodTest.java
commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/junit/AsserterTest.java
Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/junit/Asserter.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/junit/Asserter.java?rev=801118&r1=801117&r2=801118&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/junit/Asserter.java (original)
+++ commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/junit/Asserter.java Wed Aug 5 10:00:05 2009
@@ -37,32 +37,22 @@
* @version $Revision$
*/
public class Asserter extends Assert {
-
/** variables used during asserts. */
private final Map<String, Object> variables = new HashMap<String, Object>();
/** context to use during asserts. */
private final JexlContext context = JexlHelper.createContext();
/** Jexl engine to use during Asserts. */
- private static final JexlEngine engine = new JexlEngine();
+ private final JexlEngine engine;
/**
*
* Create an asserter.
*/
- public Asserter() {
-
+ public Asserter(JexlEngine jexl) {
+ engine = jexl;
}
- /**
- * This constructor will register the given variableValue as the
- * "this" variable.
- *
- * @param variableValue 'this'.
- */
- public Asserter(Object variableValue) {
- setVariable("this", variableValue);
- }
/**
* Performs an assertion that the value of the given Jexl expression
@@ -75,7 +65,6 @@
*/
public void assertExpression(String expression, Object expected) throws Exception {
Expression exp = engine.createExpression(expression);
-
context.setVars(variables);
Object value = exp.evaluate(context);
Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java?rev=801118&r1=801117&r2=801118&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java Wed Aug 5 10:00:05 2009
@@ -28,7 +28,7 @@
@Override
public void setUp() {
- asserter = new Asserter();
+ asserter = new Asserter(JEXL);
}
public void testBigDecimal() throws Exception {
Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArrayAccessTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArrayAccessTest.java?rev=801118&r1=801117&r2=801118&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArrayAccessTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArrayAccessTest.java Wed Aug 5 10:00:05 2009
@@ -42,7 +42,7 @@
@Override
public void setUp() {
- asserter = new Asserter();
+ asserter = new Asserter(JEXL);
}
/**
Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/MethodTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/MethodTest.java?rev=801118&r1=801117&r2=801118&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/MethodTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/MethodTest.java Wed Aug 5 10:00:05 2009
@@ -52,7 +52,7 @@
@Override
public void setUp() {
- asserter = new Asserter();
+ asserter = new Asserter(JEXL);
}
public void testCallVarArgMethod() throws Exception {
Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/junit/AsserterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/junit/AsserterTest.java?rev=801118&r1=801117&r2=801118&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/junit/AsserterTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/junit/AsserterTest.java Wed Aug 5 10:00:05 2009
@@ -18,10 +18,11 @@
import junit.framework.AssertionFailedError;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+import org.apache.commons.jexl.JexlEngine;
+import org.apache.commons.jexl.JexlTestCase;
import org.apache.commons.jexl.Foo;
/**
@@ -31,7 +32,7 @@
* @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
* @version $Id$
*/
-public class AsserterTest extends TestCase {
+public class AsserterTest extends JexlTestCase {
public static Test suite() {
return new TestSuite(AsserterTest.class);
@@ -46,7 +47,8 @@
}
public void testThis() throws Exception {
- Asserter asserter = new Asserter(new Foo());
+ Asserter asserter = new Asserter(JEXL);
+ asserter.setVariable("this", new Foo());
asserter.assertExpression("this.get('abc')", "Repeat : abc");
@@ -60,7 +62,9 @@
}
public void testVariable() throws Exception {
- Asserter asserter = new Asserter();
+ JexlEngine jexl = new JexlEngine();
+ jexl.setSilent(true);
+ Asserter asserter = new Asserter(jexl);
asserter.setVariable("foo", new Foo());
asserter.setVariable("person", "James");