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 2015/06/10 18:30:17 UTC

svn commit: r1684706 [2/5] - in /commons/proper/jexl/trunk: ./ src/main/java/org/apache/commons/jexl3/ src/main/java/org/apache/commons/jexl3/annotations/ src/main/java/org/apache/commons/jexl3/internal/ src/main/java/org/apache/commons/jexl3/internal/...

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArrayLiteralTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArrayLiteralTest.java?rev=1684706&r1=1684705&r2=1684706&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArrayLiteralTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArrayLiteralTest.java Wed Jun 10 16:30:16 2015
@@ -17,45 +17,52 @@
 package org.apache.commons.jexl3;
 
 import java.util.Arrays;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests for array literals
  * @since 2.0
  */
+@SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class ArrayLiteralTest extends JexlTestCase {
 
     public ArrayLiteralTest() {
         super("ArrayLiteralTest");
     }
 
+    @Test
     public void testLiteralWithStrings() throws Exception {
         JexlExpression e = JEXL.createExpression( "[ 'foo' , 'bar' ]" );
         JexlContext jc = new MapContext();
 
         Object o = e.evaluate( jc );
         Object[] check = { "foo", "bar" };
-        assertTrue( Arrays.equals(check, (Object[])o) );
+        Assert.assertTrue( Arrays.equals(check, (Object[])o) );
     }
 
+    @Test
     public void testLiteralWithOneEntry() throws Exception {
         JexlExpression e = JEXL.createExpression( "[ 'foo' ]" );
         JexlContext jc = new MapContext();
 
         Object o = e.evaluate( jc );
         Object[] check = { "foo" };
-        assertTrue( Arrays.equals(check, (Object[])o) );
+        Assert.assertTrue( Arrays.equals(check, (Object[])o) );
     }
 
+    @Test
     public void testLiteralWithNumbers() throws Exception {
         JexlExpression e = JEXL.createExpression( "[ 5.0 , 10 ]" );
         JexlContext jc = new MapContext();
 
         Object o = e.evaluate( jc );
         Object[] check = { new Double(5), new Integer(10) };
-        assertTrue( Arrays.equals(check, (Object[])o) );
-        assertTrue (o.getClass().isArray() && o.getClass().getComponentType().equals(Number.class));
+        Assert.assertTrue( Arrays.equals(check, (Object[])o) );
+        Assert.assertTrue (o.getClass().isArray() && o.getClass().getComponentType().equals(Number.class));
     }
 
+    @Test
     public void testLiteralWithNulls() throws Exception {
         String []exprs = {
             "[ null , 10 ]",
@@ -75,42 +82,63 @@ public class ArrayLiteralTest extends Je
         for(int t = 0; t < exprs.length; ++t) {
             JexlExpression e = JEXL.createExpression( exprs[t] );
             Object o = e.evaluate( jc );
-            assertTrue(exprs[t], Arrays.equals(checks[t], (Object[])o) );
+            Assert.assertTrue(exprs[t], Arrays.equals(checks[t], (Object[])o) );
         }
 
     }
 
+    @Test
     public void testLiteralWithIntegers() throws Exception {
         JexlExpression e = JEXL.createExpression( "[ 5 , 10 ]" );
         JexlContext jc = new MapContext();
 
         Object o = e.evaluate( jc );
         int[] check = { 5, 10 };
-        assertTrue( Arrays.equals(check, (int[])o) );
+        Assert.assertTrue( Arrays.equals(check, (int[])o) );
     }
 
+    @Test
     public void testSizeOfSimpleArrayLiteral() throws Exception {
         JexlExpression e = JEXL.createExpression( "size([ 'foo' , 'bar' ])" );
         JexlContext jc = new MapContext();
 
         Object o = e.evaluate( jc );
-        assertEquals( new Integer( 2 ), o );
+        Assert.assertEquals( new Integer( 2 ), o );
     }
 
+    @Test
     public void notestCallingMethodsOnNewMapLiteral() throws Exception {
         JexlExpression e = JEXL.createExpression( "size({ 'foo' : 'bar' }.values())" );
         JexlContext jc = new MapContext();
 
         Object o = e.evaluate( jc );
-        assertEquals( new Integer( 1 ), o );
+        Assert.assertEquals( new Integer( 1 ), o );
     }
 
+    @Test
     public void testNotEmptySimpleArrayLiteral() throws Exception {
         JexlExpression e = JEXL.createExpression( "empty([ 'foo' , 'bar' ])" );
         JexlContext jc = new MapContext();
 
         Object o = e.evaluate( jc );
-        assertFalse( ( (Boolean) o ).booleanValue() );
+        Assert.assertFalse( (Boolean) o );
     }
 
+    @Test
+    public void testChangeThroughVariables() throws Exception {
+        JexlContext jc = new MapContext();
+        JexlExpression e147 = JEXL.createExpression("quux = [one, two]");
+
+        jc.set("one", 1);
+        jc.set("two", 2);
+        int[] o1 = (int[]) e147.evaluate(jc);
+        Assert.assertEquals(1, o1[0]);
+        Assert.assertEquals(2, o1[1]);
+
+        jc.set("one", 10);
+        jc.set("two", 20);
+        int[] o2 = (int[]) e147.evaluate(jc);
+        Assert.assertEquals(10, o2[0]);
+        Assert.assertEquals(20, o2[1]);
+    }
 }

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AssignTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AssignTest.java?rev=1684706&r1=1684705&r2=1684706&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AssignTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AssignTest.java Wed Jun 10 16:30:16 2015
@@ -16,11 +16,15 @@
  */
 package org.apache.commons.jexl3;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 /**
  * Test cases for assignment.
  *
  * @since 1.1
  */
+@SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class AssignTest extends JexlTestCase {
 
     public static class Froboz {
@@ -61,8 +65,8 @@ public class AssignTest extends JexlTest
         }
     }
 
-    public AssignTest(String testName) {
-        super(testName, new JexlBuilder().cache(512).strict(true).silent(false).create());
+    public AssignTest() {
+        super("AssignTest", new JexlBuilder().cache(512).strict(true).silent(false).create());
     }
 
     /**
@@ -70,26 +74,29 @@ public class AssignTest extends JexlTest
      *
      * @throws Exception on any error
      */
+    @Test
     public void testAntish() throws Exception {
         JexlExpression assign = JEXL.createExpression("froboz.value = 10");
         JexlExpression check = JEXL.createExpression("froboz.value");
         JexlContext jc = new MapContext();
         Object o = assign.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
         o = check.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
     }
 
+    @Test
     public void testAntishInteger() throws Exception {
         JexlExpression assign = JEXL.createExpression("froboz.0 = 10");
         JexlExpression check = JEXL.createExpression("froboz.0");
         JexlContext jc = new MapContext();
         Object o = assign.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
         o = check.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
     }
 
+    @Test
     public void testBeanish() throws Exception {
         JexlExpression assign = JEXL.createExpression("froboz.value = 10");
         JexlExpression check = JEXL.createExpression("froboz.value");
@@ -97,9 +104,9 @@ public class AssignTest extends JexlTest
         Froboz froboz = new Froboz(-169);
         jc.set("froboz", froboz);
         Object o = assign.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
         o = check.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
     }
 
     public void testAmbiguous() throws Exception {
@@ -113,13 +120,14 @@ public class AssignTest extends JexlTest
         }
         catch(RuntimeException xrt) {
             String str = xrt.toString();
-            assertTrue(str.contains("nosuchbean"));
+            Assert.assertTrue(str.contains("nosuchbean"));
         }
         finally {
-            assertEquals("Should have failed", null, o);
+            Assert.assertEquals("Should have failed", null, o);
         }
     }
 
+    @Test
     public void testArray() throws Exception {
         JexlExpression assign = JEXL.createExpression("froboz[\"value\"] = 10");
         JexlExpression check = JEXL.createExpression("froboz[\"value\"]");
@@ -127,18 +135,21 @@ public class AssignTest extends JexlTest
         Froboz froboz = new Froboz(0);
         jc.set("froboz", froboz);
         Object o = assign.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
         o = check.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
     }
 
+    @Test
     public void testMini() throws Exception {
         JexlContext jc = new MapContext();
         JexlExpression assign = JEXL.createExpression("quux = 10");
         Object o = assign.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
 
     }
+
+    @Test
     public void testMore() throws Exception {
         JexlContext jc = new MapContext();
         jc.set("quuxClass", Quux.class);
@@ -147,30 +158,32 @@ public class AssignTest extends JexlTest
         JexlExpression check = JEXL.createExpression("quux[\"froboz\"].value");
 
         Quux quux = (Quux) create.evaluate(jc);
-        assertNotNull("quux is null", quux);
+        Assert.assertNotNull("quux is null", quux);
         Object o = assign.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
         o = check.evaluate(jc);
-        assertEquals("Result is not 10", new Integer(10), o);
+        Assert.assertEquals("Result is not 10", new Integer(10), o);
     }
 
+    @Test
     public void testUtil() throws Exception {
         Quux quux = JEXL.newInstance(Quux.class, "xuuq", Integer.valueOf(100));
-        assertNotNull(quux);
+        Assert.assertNotNull(quux);
         JEXL.setProperty(quux, "froboz.value", Integer.valueOf(100));
         Object o = JEXL.getProperty(quux, "froboz.value");
-        assertEquals("Result is not 100", new Integer(100), o);
+        Assert.assertEquals("Result is not 100", new Integer(100), o);
         JEXL.setProperty(quux, "['froboz'].value", Integer.valueOf(1000));
         o = JEXL.getProperty(quux, "['froboz']['value']");
-        assertEquals("Result is not 1000", new Integer(1000), o);
+        Assert.assertEquals("Result is not 1000", new Integer(1000), o);
     }
 
+    @Test
     public void testRejectLocal() throws Exception {
         JexlContext jc = new MapContext();
         JexlScript assign = JEXL.createScript("var quux = null; quux.froboz.value = 10");
         try {
             Object o = assign.execute(jc);
-            fail("quux is local and null, should fail");
+            Assert.fail("quux is local and null, should fail");
         } catch (JexlException xjexl) {
             String x = xjexl.toString();
             String y = x;
@@ -178,6 +191,6 @@ public class AssignTest extends JexlTest
         // quux is a global antish var
         assign = JEXL.createScript("quux.froboz.value = 10");
         Object o = assign.execute(jc);
-        assertEquals(10, o);
+        Assert.assertEquals(10, o);
     }
 }
\ No newline at end of file

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/BitwiseOperatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/BitwiseOperatorTest.java?rev=1684706&r1=1684705&r2=1684706&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/BitwiseOperatorTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/BitwiseOperatorTest.java Wed Jun 10 16:30:16 2015
@@ -14,18 +14,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.commons.jexl3;
+
 import org.apache.commons.jexl3.junit.Asserter;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Tests for the bitwise operators.
  * @since 1.1
  */
+@SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class BitwiseOperatorTest extends JexlTestCase {
     private Asserter asserter;
 
     @Override
+    @Before
     public void setUp() {
         asserter = new Asserter(JEXL);
         asserter.setStrict(false);
@@ -35,116 +39,139 @@ public class BitwiseOperatorTest extends
      * Create the named test.
      * @param name test name
      */
-    public BitwiseOperatorTest(String name) {
-        super(name);
+    public BitwiseOperatorTest() {
+        super("BitwiseOperatorTest");
     }
 
+    @Test
     public void testAndWithTwoNulls() throws Exception {
         asserter.assertExpression("null & null", new Long(0));
     }
 
+    @Test
     public void testAndWithLeftNull() throws Exception {
         asserter.assertExpression("null & 1", new Long(0));
     }
 
+    @Test
     public void testAndWithRightNull() throws Exception {
         asserter.assertExpression("1 & null", new Long(0));
     }
 
+    @Test
     public void testAndSimple() throws Exception {
         asserter.assertExpression("15 & 3", new Long(15 & 3));
     }
 
+    @Test
     public void testAndVariableNumberCoercion() throws Exception {
         asserter.setVariable("x", new Integer(15));
-        asserter.setVariable("y", new Short((short)7));
+        asserter.setVariable("y", new Short((short) 7));
         asserter.assertExpression("x & y", new Long(15 & 7));
     }
 
+    @Test
     public void testAndVariableStringCoercion() throws Exception {
         asserter.setVariable("x", new Integer(15));
         asserter.setVariable("y", "7");
         asserter.assertExpression("x & y", new Long(15 & 7));
     }
 
+    @Test
     public void testComplementWithNull() throws Exception {
         asserter.assertExpression("~null", new Long(-1));
     }
 
+    @Test
     public void testComplementSimple() throws Exception {
         asserter.assertExpression("~128", new Long(-129));
     }
 
+    @Test
     public void testComplementVariableNumberCoercion() throws Exception {
         asserter.setVariable("x", new Integer(15));
         asserter.assertExpression("~x", new Long(~15));
     }
 
+    @Test
     public void testComplementVariableStringCoercion() throws Exception {
         asserter.setVariable("x", "15");
         asserter.assertExpression("~x", new Long(~15));
     }
 
+    @Test
     public void testOrWithTwoNulls() throws Exception {
         asserter.assertExpression("null | null", new Long(0));
     }
 
+    @Test
     public void testOrWithLeftNull() throws Exception {
         asserter.assertExpression("null | 1", new Long(1));
     }
 
+    @Test
     public void testOrWithRightNull() throws Exception {
         asserter.assertExpression("1 | null", new Long(1));
     }
 
+    @Test
     public void testOrSimple() throws Exception {
         asserter.assertExpression("12 | 3", new Long(15));
     }
 
+    @Test
     public void testOrVariableNumberCoercion() throws Exception {
         asserter.setVariable("x", new Integer(12));
         asserter.setVariable("y", new Short((short) 3));
         asserter.assertExpression("x | y", new Long(15));
     }
 
+    @Test
     public void testOrVariableStringCoercion() throws Exception {
         asserter.setVariable("x", new Integer(12));
         asserter.setVariable("y", "3");
         asserter.assertExpression("x | y", new Long(15));
     }
 
+    @Test
     public void testXorWithTwoNulls() throws Exception {
         asserter.assertExpression("null ^ null", new Long(0));
     }
 
+    @Test
     public void testXorWithLeftNull() throws Exception {
         asserter.assertExpression("null ^ 1", new Long(1));
     }
 
+    @Test
     public void testXorWithRightNull() throws Exception {
         asserter.assertExpression("1 ^ null", new Long(1));
     }
 
+    @Test
     public void testXorSimple() throws Exception {
         asserter.assertExpression("1 ^ 3", new Long(1 ^ 3));
     }
 
+    @Test
     public void testXorVariableNumberCoercion() throws Exception {
         asserter.setVariable("x", new Integer(1));
         asserter.setVariable("y", new Short((short) 3));
         asserter.assertExpression("x ^ y", new Long(1 ^ 3));
     }
 
+    @Test
     public void testXorVariableStringCoercion() throws Exception {
         asserter.setVariable("x", new Integer(1));
         asserter.setVariable("y", "3");
         asserter.assertExpression("x ^ y", new Long(1 ^ 3));
     }
 
+    @Test
     public void testParenthesized() throws Exception {
         asserter.assertExpression("(2 | 1) & 3", Long.valueOf(3L));
         asserter.assertExpression("(2 & 1) | 3", Long.valueOf(3L));
-        asserter.assertExpression("~(120 | 42)", new Long( ~(120 | 42) ));
+        asserter.assertExpression("~(120 | 42)", new Long(~(120 | 42)));
     }
 
 }

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/BlockTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/BlockTest.java?rev=1684706&r1=1684705&r2=1684706&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/BlockTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/BlockTest.java Wed Jun 10 16:30:16 2015
@@ -16,62 +16,70 @@
  */
 package org.apache.commons.jexl3;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 /**
  * Tests for blocks
  * @since 1.1
  */
+@SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class BlockTest extends JexlTestCase {
 
     /**
      * Create the test
-     *
-     * @param testName name of the test
      */
-    public BlockTest(String testName) {
-        super(testName);
+    public BlockTest() {
+        super("BlockTest");
     }
 
+    @Test
     public void testBlockSimple() throws Exception {
         JexlScript e = JEXL.createScript("if (true) { 'hello'; }");
         JexlContext jc = new MapContext();
         Object o = e.execute(jc);
-        assertEquals("Result is wrong", "hello", o);
+        Assert.assertEquals("Result is wrong", "hello", o);
     }
 
+    @Test
     public void testBlockExecutesAll() throws Exception {
         JexlScript e = JEXL.createScript("if (true) { x = 'Hello'; y = 'World';}");
         JexlContext jc = new MapContext();
         Object o = e.execute(jc);
-        assertEquals("First result is wrong", "Hello", jc.get("x"));
-        assertEquals("Second result is wrong", "World", jc.get("y"));
-        assertEquals("Block result is wrong", "World", o);
+        Assert.assertEquals("First result is wrong", "Hello", jc.get("x"));
+        Assert.assertEquals("Second result is wrong", "World", jc.get("y"));
+        Assert.assertEquals("Block result is wrong", "World", o);
     }
 
+    @Test
     public void testEmptyBlock() throws Exception {
         JexlScript e = JEXL.createScript("if (true) { }");
         JexlContext jc = new MapContext();
         Object o = e.execute(jc);
-        assertNull("Result is wrong", o);
+        Assert.assertNull("Result is wrong", o);
     }
 
+    @Test
     public void testBlockLastExecuted01() throws Exception {
         JexlScript e = JEXL.createScript("if (true) { x = 1; } else { x = 2; }");
         JexlContext jc = new MapContext();
         Object o = e.execute(jc);
-        assertEquals("Block result is wrong", new Integer(1), o);
+        Assert.assertEquals("Block result is wrong", new Integer(1), o);
     }
 
+    @Test
     public void testBlockLastExecuted02() throws Exception {
         JexlScript e = JEXL.createScript("if (false) { x = 1; } else { x = 2; }");
         JexlContext jc = new MapContext();
         Object o = e.execute(jc);
-        assertEquals("Block result is wrong", new Integer(2), o);
+        Assert.assertEquals("Block result is wrong", new Integer(2), o);
     }
 
+    @Test
     public void testNestedBlock() throws Exception {
         JexlScript e = JEXL.createScript("if (true) { x = 'hello'; y = 'world';" + " if (true) { x; } y; }");
         JexlContext jc = new MapContext();
         Object o = e.execute(jc);
-        assertEquals("Block result is wrong", "world", o);
+        Assert.assertEquals("Block result is wrong", "world", o);
     }
 }

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/CacheTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/CacheTest.java?rev=1684706&r1=1684705&r2=1684706&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/CacheTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/CacheTest.java Wed Jun 10 16:30:16 2015
@@ -23,11 +23,25 @@ import java.util.HashMap;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Verifies cache & tryExecute
  */
+@SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class CacheTest extends JexlTestCase {
+    // LOOPS & THREADS
+    private static final int LOOPS = 4096;
+    private static final int NTHREADS = 4;
+    // A pseudo random mix of accessors
+    private static final int[] MIX = {
+        0, 0, 3, 3, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 1, 2, 2, 2,
+        3, 3, 3, 4, 4, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 3, 3, 0
+    };
+    
     public CacheTest() {
         super("CacheTest", null);
     }
@@ -35,23 +49,17 @@ public class CacheTest extends JexlTestC
     private static final JexlEngine jexlNoCache = new JexlBuilder().cache(0).debug(true).strict(true).create();
     private static JexlEngine jexl = jexlCache;
 
+    @Before
     @Override
     public void setUp() throws Exception {
         // ensure jul logging is only error to avoid warning in silent mode
         java.util.logging.Logger.getLogger(JexlEngine.class.getName()).setLevel(java.util.logging.Level.SEVERE);
     }
 
-    // LOOPS & THREADS
-    private static final int LOOPS = 4096;
-    private static final int NTHREADS = 4;
-    // A pseudo random mix of accessors
-    private static final int[] MIX = {
-        0, 0, 3, 3, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 1, 2, 2, 2,
-        3, 3, 3, 4, 4, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 3, 3, 0
-    };
 
+    @After
     @Override
-    protected void tearDown() throws Exception {
+    public void tearDown() throws Exception {
         debuggerCheck(jexl);
     }
 
@@ -286,14 +294,14 @@ public class CacheTest extends JexlTestC
         }
         java.util.concurrent.ExecutorService execs = java.util.concurrent.Executors.newFixedThreadPool(NTHREADS);
         List<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>(NTHREADS);
-        for(int t = 0; t < NTHREADS; ++t) {
+        for (int t = 0; t < NTHREADS; ++t) {
             tasks.add(jexl.newInstance(ctask, loops));
         }
         // let's not wait for more than a minute
         List<Future<Integer>> futures = execs.invokeAll(tasks, 60, TimeUnit.SECONDS);
         // check that all returned loops
-        for(Future<Integer> future : futures) {
-            assertEquals(Integer.valueOf(loops), future.get());
+        for (Future<Integer> future : futures) {
+            Assert.assertEquals(Integer.valueOf(loops), future.get());
         }
     }
 
@@ -315,7 +323,8 @@ public class CacheTest extends JexlTestC
 
         /**
          * The actual test function; assigns and checks.
-         * <p>The expression will be evaluated against different classes in parallel.
+         * <p>
+         * The expression will be evaluated against different classes in parallel.
          * This verifies that neither the volatile cache in the AST nor the expression cache in the JEXL engine
          * induce errors.</p>
          * <p>
@@ -341,16 +350,16 @@ public class CacheTest extends JexlTestC
                 vars.put("value", args.value[0]);
                 result = cacheSetValue.evaluate(jc);
                 if (args.value[0] == null) {
-                    assertNull(cacheSetValue.toString(), result);
+                    Assert.assertNull(cacheSetValue.toString(), result);
                 } else {
-                    assertEquals(cacheSetValue.toString(), args.value[0], result);
+                    Assert.assertEquals(cacheSetValue.toString(), args.value[0], result);
                 }
 
                 result = cacheGetValue.evaluate(jc);
                 if (args.value[0] == null) {
-                    assertEquals(cacheGetValue.toString(), "Cached" + mix + ":na", result);
+                    Assert.assertEquals(cacheGetValue.toString(), "Cached" + mix + ":na", result);
                 } else {
-                    assertEquals(cacheGetValue.toString(), "Cached" + mix + ":" + args.value[0], result);
+                    Assert.assertEquals(cacheGetValue.toString(), "Cached" + mix + ":" + args.value[0], result);
                 }
 
             }
@@ -366,6 +375,7 @@ public class CacheTest extends JexlTestC
         public AssignTask(int loops) {
             super(loops);
         }
+
         @Override
         public Integer call() throws Exception {
             return runAssign("foo");
@@ -379,6 +389,7 @@ public class CacheTest extends JexlTestC
         public AssignNullTask(int loops) {
             super(loops);
         }
+
         @Override
         public Integer call() throws Exception {
             return runAssign(null);
@@ -392,6 +403,7 @@ public class CacheTest extends JexlTestC
         public AssignBooleanTask(int loops) {
             super(loops);
         }
+
         @Override
         public Integer call() throws Exception {
             return runAssignBoolean(Boolean.TRUE);
@@ -411,10 +423,10 @@ public class CacheTest extends JexlTestC
                 vars.put("cache", args.ca[mix]);
                 vars.put("value", args.value[0]);
                 result = cacheSetValue.evaluate(jc);
-                assertEquals(cacheSetValue.toString(), args.value[0], result);
+                Assert.assertEquals(cacheSetValue.toString(), args.value[0], result);
 
                 result = cacheGetValue.evaluate(jc);
-                assertEquals(cacheGetValue.toString(), args.value[0], result);
+                Assert.assertEquals(cacheGetValue.toString(), args.value[0], result);
 
             }
 
@@ -434,6 +446,7 @@ public class CacheTest extends JexlTestC
         public Integer call() throws Exception {
             return runAssignList();
         }
+
         /** The actual test function. */
         private Integer runAssignList() {
             args.value = new Object[]{"foo"};
@@ -441,9 +454,9 @@ public class CacheTest extends JexlTestC
             c1.add("foo");
             c1.add("bar");
             args.ca = new Object[]{
-                        new String[]{"one", "two"},
-                        c1
-                    };
+                new String[]{"one", "two"},
+                c1
+            };
 
             JexlExpression cacheGetValue = jexl.createExpression("cache.0");
             JexlExpression cacheSetValue = jexl.createExpression("cache[0] = value");
@@ -456,45 +469,52 @@ public class CacheTest extends JexlTestC
                 vars.put("cache", args.ca[mix]);
                 vars.put("value", args.value[0]);
                 result = cacheSetValue.evaluate(jc);
-                assertEquals(cacheSetValue.toString(), args.value[0], result);
+                Assert.assertEquals(cacheSetValue.toString(), args.value[0], result);
 
                 result = cacheGetValue.evaluate(jc);
-                assertEquals(cacheGetValue.toString(), args.value[0], result);
+                Assert.assertEquals(cacheGetValue.toString(), args.value[0], result);
             }
 
             return Integer.valueOf(loops);
         }
     }
 
-
+    @Test
     public void testNullAssignNoCache() throws Exception {
         runThreaded(AssignNullTask.class, LOOPS, false);
     }
 
+    @Test
     public void testNullAssignCache() throws Exception {
         runThreaded(AssignNullTask.class, LOOPS, true);
     }
 
+    @Test
     public void testAssignNoCache() throws Exception {
         runThreaded(AssignTask.class, LOOPS, false);
     }
 
+    @Test
     public void testAssignCache() throws Exception {
         runThreaded(AssignTask.class, LOOPS, true);
     }
 
+    @Test
     public void testAssignBooleanNoCache() throws Exception {
         runThreaded(AssignBooleanTask.class, LOOPS, false);
     }
 
+    @Test
     public void testAssignBooleanCache() throws Exception {
         runThreaded(AssignBooleanTask.class, LOOPS, true);
     }
 
+    @Test
     public void testAssignListNoCache() throws Exception {
         runThreaded(AssignListTask.class, LOOPS, false);
     }
 
+    @Test
     public void testAssignListCache() throws Exception {
         runThreaded(AssignListTask.class, LOOPS, true);
     }
@@ -534,17 +554,17 @@ public class CacheTest extends JexlTestC
                     vars.put("a1", Integer.valueOf(9));
                     expected = "Cached" + mix + "@i#7,i#9";
                 } else {
-                    fail("unexpected value type");
+                    Assert.fail("unexpected value type");
                 }
                 result = compute2.evaluate(jc);
-                assertEquals(compute2.toString(), expected, result);
+                Assert.assertEquals(compute2.toString(), expected, result);
 
                 if (value instanceof Integer) {
                     try {
                         vars.put("a0", Short.valueOf((short) 17));
                         vars.put("a1", Short.valueOf((short) 19));
                         result = ambiguous.evaluate(jc);
-                        fail("should have thrown an exception");
+                        Assert.fail("should have thrown an exception");
                     } catch (JexlException xany) {
                         // throws due to ambiguous exception
                     }
@@ -557,21 +577,21 @@ public class CacheTest extends JexlTestC
                     vars.put("a0", Integer.valueOf(5));
                     expected = "Cached" + mix + "@i#5";
                 } else {
-                    fail("unexpected value type");
+                    Assert.fail("unexpected value type");
                 }
                 result = compute1.evaluate(jc);
-                assertEquals(compute1.toString(), expected, result);
+                Assert.assertEquals(compute1.toString(), expected, result);
 
                 try {
                     vars.put("a0", null);
                     result = compute1null.evaluate(jc);
-                    fail("should have thrown an exception");
+                    Assert.fail("should have thrown an exception");
                 } catch (JexlException xany) {
                     // throws due to ambiguous exception
                     String sany = xany.getMessage();
                     String tname = getClass().getName();
                     if (!sany.startsWith(tname)) {
-                        fail("debug mode should carry caller information, "
+                        Assert.fail("debug mode should carry caller information, "
                                 + sany + ", "
                                 + tname);
                     }
@@ -581,20 +601,24 @@ public class CacheTest extends JexlTestC
         }
     }
 
+    @Test
     public void testComputeNoCache() throws Exception {
-            runThreaded(ComputeTask.class, LOOPS, false);
+        runThreaded(ComputeTask.class, LOOPS, false);
     }
 
+    @Test
     public void testComputeCache() throws Exception {
-            runThreaded(ComputeTask.class, LOOPS, true);
+        runThreaded(ComputeTask.class, LOOPS, true);
     }
 
     public static class JexlContextNS extends JexlEvalContext {
         final Map<String, Object> funcs;
+
         JexlContextNS(Map<String, Object> vars, Map<String, Object> funcs) {
             super(vars);
             this.funcs = funcs;
         }
+
         @Override
         public Object resolveNamespace(String name) {
             return funcs.get(name);
@@ -637,10 +661,10 @@ public class CacheTest extends JexlTestC
                 vars.put("a1", Integer.valueOf(9));
                 expected = "CACHED@i#7,i#9";
             } else {
-                fail("unexpected value type");
+                Assert.fail("unexpected value type");
             }
             result = compute2.evaluate(jc);
-            assertEquals(compute2.toString(), expected, result);
+            Assert.assertEquals(compute2.toString(), expected, result);
 
             if (value instanceof String) {
                 vars.put("a0", "X0");
@@ -649,27 +673,29 @@ public class CacheTest extends JexlTestC
                 vars.put("a0", Integer.valueOf(5));
                 expected = "CACHED@i#5";
             } else {
-                fail("unexpected value type");
+                Assert.fail("unexpected value type");
             }
             result = compute1.evaluate(jc);
-            assertEquals(compute1.toString(), expected, result);
+            Assert.assertEquals(compute1.toString(), expected, result);
         }
     }
 
+    @Test
     public void testCOMPUTENoCache() throws Exception {
         TestCacheArguments args = new TestCacheArguments();
         args.ca = new Object[]{
-                    Cached.class, Cached1.class, Cached2.class
-                };
+            Cached.class, Cached1.class, Cached2.class
+        };
         args.value = new Object[]{new Integer(2), "quux"};
         doCOMPUTE(args, LOOPS, false);
     }
 
+    @Test
     public void testCOMPUTECache() throws Exception {
         TestCacheArguments args = new TestCacheArguments();
         args.ca = new Object[]{
-                    Cached.class, Cached1.class, Cached2.class
-                };
+            Cached.class, Cached1.class, Cached2.class
+        };
         args.value = new Object[]{new Integer(2), "quux"};
         doCOMPUTE(args, LOOPS, true);
     }

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java?rev=1684706&r1=1684705&r2=1684706&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java Wed Jun 10 16:30:16 2015
@@ -26,10 +26,15 @@ import java.util.List;
 
 import org.apache.log4j.Logger;
 import org.apache.log4j.LogManager;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Basic check on automated class creation
  */
+@SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class ClassCreatorTest extends JexlTestCase {
     static final Logger logger = LogManager.getLogger(JexlTestCase.class);
     static final int LOOPS = 8;
@@ -40,6 +45,7 @@ public class ClassCreatorTest extends Je
         super("ClassCreatorTest");
     }
 
+    @Before
     @Override
     public void setUp() throws Exception {
         base = new File(System.getProperty("java.io.tmpdir") + File.pathSeparator + "jexl" + System.currentTimeMillis());
@@ -47,6 +53,7 @@ public class ClassCreatorTest extends Je
 
     }
 
+    @After
     @Override
     public void tearDown() throws Exception {
         deleteDirectory(base);
@@ -65,6 +72,7 @@ public class ClassCreatorTest extends Je
 
     // A space hog class
     static final int MEGA = 1024 * 1024;
+
     public class BigObject {
         @SuppressWarnings("unused")
         private final byte[] space = new byte[MEGA];
@@ -85,6 +93,7 @@ public class ClassCreatorTest extends Je
             super(clazz, queue);
         }
     }
+
     // A soft reference on instance
     static final class InstanceReference extends SoftReference<Object> {
         InstanceReference(Object obj, ReferenceQueue<Object> queue) {
@@ -92,6 +101,7 @@ public class ClassCreatorTest extends Je
         }
     }
 
+    @Test
     public void testOne() throws Exception {
         // abort test if class creator can not run
         if (!ClassCreator.canRun) {
@@ -100,10 +110,11 @@ public class ClassCreatorTest extends Je
         ClassCreator cctor = new ClassCreator(jexl, base);
         cctor.setSeed(1);
         Class<?> foo1 = cctor.createClass();
-        assertEquals("foo1", foo1.getSimpleName());
+        Assert.assertEquals("foo1", foo1.getSimpleName());
         cctor.clear();
     }
 
+    @Test
     public void testMany() throws Exception {
         // abort test if class creator can not run
         if (!ClassCreator.canRun) {
@@ -130,7 +141,7 @@ public class ClassCreatorTest extends Je
             } else {
                 clazz = cctor.getClassInstance();
                 if (clazz == null) {
-                    assertEquals(i, gced);
+                    Assert.assertEquals(i, gced);
                     break;
                 }
             }
@@ -142,17 +153,17 @@ public class ClassCreatorTest extends Je
             context.set("clazz", cctor.getClassName());
             context.set("foo", null);
             Object z = newx.evaluate(context);
-            assertNull(z);
+            Assert.assertNull(z);
             // check with the class itself
             context.set("clazz", clazz);
             z = newx.evaluate(context);
-            assertNotNull(clazz + ": class " + i + " could not be instantiated on pass " + pass, z);
-            assertEquals(new Integer(i), expr.evaluate(context));
+            Assert.assertNotNull(clazz + ": class " + i + " could not be instantiated on pass " + pass, z);
+            Assert.assertEquals(new Integer(i), expr.evaluate(context));
             // with the proper class loader, attempt to create an instance from the class name
             jexl.setClassLoader(cctor.getClassLoader());
             z = newx.evaluate(context);
-            assertTrue(z.getClass().equals(clazz));
-            assertEquals(new Integer(i), expr.evaluate(context));
+            Assert.assertTrue(z.getClass().equals(clazz));
+            Assert.assertEquals(new Integer(i), expr.evaluate(context));
             cctor.clear();
             jexl.setClassLoader(null);
 
@@ -190,7 +201,7 @@ public class ClassCreatorTest extends Je
 
         if (gced < 0) {
             logger.warn("unable to force GC");
-            //assertTrue(gced > 0);
+            //Assert.assertTrue(gced > 0);
         }
     }
 
@@ -210,15 +221,16 @@ public class ClassCreatorTest extends Je
         }
     }
 
+    @Test
     public void testBasicCtor() throws Exception {
         JexlScript s = jexl.createScript("(c, v)->{ var ct2 = new(c, v); ct2.value; }");
         Object r = s.execute(null, TwoCtors.class, 10);
-        assertEquals(10, r);
+        Assert.assertEquals(10, r);
         r = s.execute(null, TwoCtors.class, 5 + 5);
-        assertEquals(10, r);
+        Assert.assertEquals(10, r);
         r = s.execute(null, TwoCtors.class, 10d);
-        assertEquals(-10, r);
+        Assert.assertEquals(-10, r);
         r = s.execute(null, TwoCtors.class, 100f);
-        assertEquals(-100, r);
+        Assert.assertEquals(-100, r);
     }
 }

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java?rev=1684706&r1=1684705&r2=1684706&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java Wed Jun 10 16:30:16 2015
@@ -17,13 +17,17 @@
 package org.apache.commons.jexl3;
 
 import org.apache.commons.jexl3.internal.Engine;
+import org.junit.Assert;
+import org.junit.Test;
+
 /**
  * Tests JexlContext (advanced) features.
  */
+@SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class ContextNamespaceTest extends JexlTestCase {
 
-    public ContextNamespaceTest(String testName) {
-        super(testName);
+    public ContextNamespaceTest() {
+        super("ContextNamespaceTest");
     }
 
     /*
@@ -42,25 +46,29 @@ public class ContextNamespaceTest extend
     public static class TaxesContext extends MapContext implements JexlContext.ThreadLocal, JexlContext.NamespaceResolver {
         private final Taxes taxes = new Taxes();
         private final double vat;
+
         TaxesContext(double vat) {
             this.vat = vat;
         }
+
         @Override
         public Object resolveNamespace(String name) {
-           return "taxes".equals(name)? taxes : null;
+            return "taxes".equals(name) ? taxes : null;
         }
+
         public double getVAT() {
             return vat;
         }
     }
 
+    @Test
     public void testThreadedContext() throws Exception {
         JexlEngine jexl = new Engine();
         TaxesContext context = new TaxesContext(18.6);
         String strs = "taxes:vat(1000)";
         JexlScript staxes = jexl.createScript(strs);
         Object result = staxes.execute(context);
-        assertEquals(186., result);
+        Assert.assertEquals(186., result);
     }
 
 }

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ExceptionTest.java?rev=1684706&r1=1684705&r2=1684706&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ExceptionTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ExceptionTest.java Wed Jun 10 16:30:16 2015
@@ -17,14 +17,17 @@
 package org.apache.commons.jexl3;
 
 import org.apache.commons.jexl3.internal.Engine;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Checks various exception handling cases.
  */
+@SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class ExceptionTest extends JexlTestCase {
     /** create a named test */
-    public ExceptionTest(String name) {
-        super(name);
+    public ExceptionTest() {
+        super("ExceptionTest");
     }
 
     public static class ThrowNPE {
@@ -33,20 +36,22 @@ public class ExceptionTest extends JexlT
         }
     }
 
+    @Test
     public void testWrappedEx() throws Exception {
         JexlEngine jexl = new Engine();
         JexlExpression e = jexl.createExpression("method()");
         JexlContext jc = new ObjectContext<ThrowNPE>(jexl, new ThrowNPE());
         try {
             e.evaluate(jc);
-            fail("Should have thrown NPE");
+            Assert.fail("Should have thrown NPE");
         } catch (JexlException xany) {
             Throwable xth = xany.getCause();
-            assertEquals(NullPointerException.class, xth.getClass());
+            Assert.assertEquals(NullPointerException.class, xth.getClass());
         }
     }
 
     // Unknown vars and properties versus null operands
+    @Test
     public void testEx() throws Exception {
         JexlEngine jexl = createEngine(false);
         JexlExpression e = jexl.createExpression("c.e * 6");
@@ -58,10 +63,10 @@ public class ExceptionTest extends JexlT
         // empty cotext
         try {
             /* Object o = */ e.evaluate(ctxt);
-            fail("c.e not defined as variable should throw");
+            Assert.fail("c.e not defined as variable should throw");
         } catch (JexlException.Variable xjexl) {
             String msg = xjexl.getMessage();
-            assertTrue(msg.indexOf("c.e") > 0);
+            Assert.assertTrue(msg.indexOf("c.e") > 0);
         }
 
         // disallow null operands
@@ -69,10 +74,10 @@ public class ExceptionTest extends JexlT
         ctxt.set("c.e", null);
         try {
             /* Object o = */ e.evaluate(ctxt);
-            fail("c.e as null operand should throw");
+            Assert.fail("c.e as null operand should throw");
         } catch (JexlException.Variable xjexl) {
             String msg = xjexl.getMessage();
-            assertTrue(msg.indexOf("c.e") > 0);
+            Assert.assertTrue(msg.indexOf("c.e") > 0);
         }
 
         // allow null operands
@@ -81,7 +86,7 @@ public class ExceptionTest extends JexlT
             /* Object o = */ e.evaluate(ctxt);
 
         } catch (JexlException xjexl) {
-            fail("c.e in expr should not throw");
+            Assert.fail("c.e in expr should not throw");
         }
 
         // ensure c.e is not a defined property
@@ -89,14 +94,15 @@ public class ExceptionTest extends JexlT
         ctxt.set("e", Integer.valueOf(2));
         try {
             /* Object o = */ e.evaluate(ctxt);
-            fail("c.e not accessible as property should throw");
+            Assert.fail("c.e not accessible as property should throw");
         } catch (JexlException.Property xjexl) {
             String msg = xjexl.getMessage();
-            assertTrue(msg.indexOf("e") > 0);
+            Assert.assertTrue(msg.indexOf("e") > 0);
         }
     }
 
     // null local vars and strict arithmetic effects
+    @Test
     public void testExVar() throws Exception {
         JexlEngine jexl = createEngine(false);
         JexlScript e = jexl.createScript("(x)->{ x * 6 }");
@@ -109,10 +115,10 @@ public class ExceptionTest extends JexlT
         // empty cotext
         try {
             /* Object o = */ e.execute(ctxt);
-            fail("x is null, should throw");
+            Assert.fail("x is null, should throw");
         } catch (JexlException xjexl) {
             String msg = xjexl.getMessage();
-            assertTrue(msg.indexOf("null") > 0);
+            Assert.assertTrue(msg.indexOf("null") > 0);
         }
 
         // allow null operands
@@ -120,11 +126,12 @@ public class ExceptionTest extends JexlT
         try {
             Object o = e.execute(ctxt);
         } catch (JexlException.Variable xjexl) {
-            fail("arithmetic allows null operands, should not throw");
+            Assert.fail("arithmetic allows null operands, should not throw");
         }
     }
 
     // Unknown vars and properties versus null operands
+    @Test
     public void testExMethod() throws Exception {
         JexlEngine jexl = createEngine(false);
         JexlExpression e = jexl.createExpression("c.e.foo()");
@@ -136,10 +143,10 @@ public class ExceptionTest extends JexlT
         // empty cotext
         try {
             /* Object o = */ e.evaluate(ctxt);
-            fail("c.e not declared as variable should throw");
+            Assert.fail("c.e not declared as variable should throw");
         } catch (JexlException.Variable xjexl) {
             String msg = xjexl.getMessage();
-            assertTrue(msg.indexOf("c.e") > 0);
+            Assert.assertTrue(msg.indexOf("c.e") > 0);
         }
 
         // disallow null operands
@@ -147,10 +154,10 @@ public class ExceptionTest extends JexlT
         ctxt.set("c.e", null);
         try {
             /* Object o = */ e.evaluate(ctxt);
-            fail("c.e as null operand should throw");
+            Assert.fail("c.e as null operand should throw");
         } catch (JexlException xjexl) {
             String msg = xjexl.getMessage();
-            assertTrue(msg.indexOf("c.e") > 0);
+            Assert.assertTrue(msg.indexOf("c.e") > 0);
         }
     }
 }

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=1684706&r1=1684705&r2=1684706&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 Wed Jun 10 16:30:16 2015
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.commons.jexl3;
 
 import java.util.ArrayList;
@@ -22,69 +21,78 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Map;
 import java.util.StringTokenizer;
-
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests for the foreach statement
  * @since 1.1
  */
+@SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class ForEachTest extends JexlTestCase {
 
     /** create a named test */
-    public ForEachTest(String name) {
-        super(name);
+    public ForEachTest() {
+        super("ForEachTest");
     }
 
+    @Test
     public void testForEachWithEmptyStatement() throws Exception {
         JexlScript e = JEXL.createScript("for(item : list) ;");
         JexlContext jc = new MapContext();
         jc.set("list", Collections.emptyList());
 
         Object o = e.execute(jc);
-        assertNull("Result is not null", o);
+        Assert.assertNull("Result is not null", o);
     }
 
+    @Test
     public void testForEachWithEmptyList() throws Exception {
         JexlScript e = JEXL.createScript("for(item : list) 1+1");
         JexlContext jc = new MapContext();
         jc.set("list", Collections.emptyList());
 
         Object o = e.execute(jc);
-        assertNull("Result is not null", o);
+        Assert.assertNull("Result is not null", o);
     }
 
+    @Test
     public void testForEachWithArray() throws Exception {
         JexlScript e = JEXL.createScript("for(item : list) item");
         JexlContext jc = new MapContext();
-        jc.set("list", new Object[] {"Hello", "World"});
+        jc.set("list", new Object[]{"Hello", "World"});
         Object o = e.execute(jc);
-        assertEquals("Result is not last evaluated expression", "World", o);
+        Assert.assertEquals("Result is not last evaluated expression", "World", o);
     }
 
+    @Test
     public void testForEachWithCollection() throws Exception {
         JexlScript e = JEXL.createScript("for(item : list) item");
         JexlContext jc = new MapContext();
-        jc.set("list", Arrays.asList(new Object[] {"Hello", "World"}));
+        jc.set("list", Arrays.asList(new Object[]{"Hello", "World"}));
         Object o = e.execute(jc);
-        assertEquals("Result is not last evaluated expression", "World", o);
+        Assert.assertEquals("Result is not last evaluated expression", "World", o);
     }
 
+    @Test
     public void testForEachWithEnumeration() throws Exception {
         JexlScript e = JEXL.createScript("for(item : list) item");
         JexlContext jc = new MapContext();
         jc.set("list", new StringTokenizer("Hello,World", ","));
         Object o = e.execute(jc);
-        assertEquals("Result is not last evaluated expression", "World", o);
+        Assert.assertEquals("Result is not last evaluated expression", "World", o);
     }
 
+    @Test
     public void testForEachWithIterator() throws Exception {
         JexlScript e = JEXL.createScript("for(item : list) item");
         JexlContext jc = new MapContext();
-        jc.set("list", Arrays.asList(new Object[] {"Hello", "World"}).iterator());
+        jc.set("list", Arrays.asList(new Object[]{"Hello", "World"}).iterator());
         Object o = e.execute(jc);
-        assertEquals("Result is not last evaluated expression", "World", o);
+        Assert.assertEquals("Result is not last evaluated expression", "World", o);
     }
 
+    @Test
     public void testForEachWithMap() throws Exception {
         JexlScript e = JEXL.createScript("for(item : list) item");
         JexlContext jc = new MapContext();
@@ -92,23 +100,25 @@ public class ForEachTest extends JexlTes
         String lastProperty = (String) new ArrayList<Object>(map.values()).get(System.getProperties().size() - 1);
         jc.set("list", map);
         Object o = e.execute(jc);
-        assertEquals("Result is not last evaluated expression", lastProperty, o);
+        Assert.assertEquals("Result is not last evaluated expression", lastProperty, o);
     }
 
+    @Test
     public void testForEachWithBlock() throws Exception {
         JexlScript exs0 = JEXL.createScript("for(var in : list) { x = x + in; }");
         JexlScript exs1 = JEXL.createScript("foreach(item in list) { x = x + item; }");
-        JexlScript []exs = { exs0, exs1 };
+        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("list", new Object[]{"2", "3"});
+        for (int ex = 0; ex < exs.length; ++ex) {
             jc.set("x", new Integer(1));
             Object o = exs[ex].execute(jc);
-            assertEquals("Result is wrong", new Integer(6), o);
-            assertEquals("x is wrong", new Integer(6), jc.get("x"));
+            Assert.assertEquals("Result is wrong", new Integer(6), o);
+            Assert.assertEquals("x is wrong", new Integer(6), jc.get("x"));
         }
     }
 
+    @Test
     public void testForEachWithListExpression() throws Exception {
         JexlScript e = JEXL.createScript("for(var item : list.keySet()) item");
         JexlContext jc = new MapContext();
@@ -116,25 +126,28 @@ public class ForEachTest extends JexlTes
         String lastKey = (String) new ArrayList<Object>(map.keySet()).get(System.getProperties().size() - 1);
         jc.set("list", map);
         Object o = e.execute(jc);
-        assertEquals("Result is not last evaluated expression", lastKey, o);
+        Assert.assertEquals("Result is not last evaluated expression", lastKey, o);
     }
 
+    @Test
     public void testForEachWithProperty() throws Exception {
         JexlScript e = JEXL.createScript("for(var item : list.cheeseList) item");
         JexlContext jc = new MapContext();
         jc.set("list", new Foo());
         Object o = e.execute(jc);
-        assertEquals("Result is not last evaluated expression", "brie", o);
+        Assert.assertEquals("Result is not last evaluated expression", "brie", o);
     }
 
+    @Test
     public void testForEachWithIteratorMethod() throws Exception {
         JexlScript e = JEXL.createScript("for(var item : list.cheezy) item");
         JexlContext jc = new MapContext();
         jc.set("list", new Foo());
         Object o = e.execute(jc);
-        assertEquals("Result is not last evaluated expression", "brie", o);
+        Assert.assertEquals("Result is not last evaluated expression", "brie", o);
     }
 
+    @Test
     public void testForEachBreakMethod() throws Exception {
         JexlScript e = JEXL.createScript(
                 "var rr = -1; for(var item : [1, 2, 3 ,4 ,5, 6]) { if (item == 3) { rr = item; break; }} rr"
@@ -142,9 +155,10 @@ public class ForEachTest extends JexlTes
         JexlContext jc = new MapContext();
         jc.set("list", new Foo());
         Object o = e.execute(jc);
-        assertEquals("Result is not last evaluated expression", 3, o);
+        Assert.assertEquals("Result is not last evaluated expression", 3, o);
     }
 
+    @Test
     public void testForEachContinueMethod() throws Exception {
         JexlScript e = JEXL.createScript(
                 "var rr = 0; for(var item : [1, 2, 3 ,4 ,5, 6]) { if (item <= 3) continue; rr = rr + item;}"
@@ -152,26 +166,28 @@ public class ForEachTest extends JexlTes
         JexlContext jc = new MapContext();
         jc.set("list", new Foo());
         Object o = e.execute(jc);
-        assertEquals("Result is not last evaluated expression", 15, o);
+        Assert.assertEquals("Result is not last evaluated expression", 15, o);
     }
 
+    @Test
     public void testForEachContinueBroken() throws Exception {
         try {
             JexlScript e = JEXL.createScript("var rr = 0; continue;");
-            fail("continue is out of loop!");
+            Assert.fail("continue is out of loop!");
         } catch (JexlException.Parsing xparse) {
             String str = xparse.detailedMessage();
-            assertTrue(str.contains("continue"));
+            Assert.assertTrue(str.contains("continue"));
         }
     }
 
+    @Test
     public void testForEachBreakBroken() throws Exception {
         try {
             JexlScript e = JEXL.createScript("if (true) { break; }");
-            fail("break is out of loop!");
+            Assert.fail("break is out of loop!");
         } catch (JexlException.Parsing xparse) {
             String str = xparse.detailedMessage();
-            assertTrue(str.contains("break"));
+            Assert.assertTrue(str.contains("break"));
         }
     }
-}
\ 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=1684706&r1=1684705&r2=1684706&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 Wed Jun 10 16:30:16 2015
@@ -16,11 +16,15 @@
  */
 package org.apache.commons.jexl3;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 /**
  * Test cases for the if statement.
  *
  * @since 1.1
  */
+@SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class IfTest extends JexlTestCase {
     public IfTest() {
         super("IfTest");
@@ -31,12 +35,13 @@ public class IfTest extends JexlTestCase
      *
      * @throws Exception on any error
      */
+    @Test
     public void testSimpleIfTrue() throws Exception {
         JexlScript e = JEXL.createScript("if (true) 1");
         JexlContext jc = new MapContext();
 
         Object o = e.execute(jc);
-        assertEquals("Result is not 1", new Integer(1), o);
+        Assert.assertEquals("Result is not 1", new Integer(1), o);
     }
 
     /**
@@ -44,12 +49,13 @@ public class IfTest extends JexlTestCase
      *
      * @throws Exception on any error
      */
+    @Test
     public void testSimpleIfFalse() throws Exception {
         JexlScript e = JEXL.createScript("if (false) 1");
         JexlContext jc = new MapContext();
 
         Object o = e.execute(jc);
-        assertNull("Return value is not empty", o);
+        Assert.assertNull("Return value is not empty", o);
     }
 
     /**
@@ -57,12 +63,13 @@ public class IfTest extends JexlTestCase
      *
      * @throws Exception on any error
      */
+    @Test
     public void testSimpleElse() throws Exception {
         JexlScript e = JEXL.createScript("if (false) 1 else 2;");
         JexlContext jc = new MapContext();
 
         Object o = e.execute(jc);
-        assertEquals("Result is not 2", new Integer(2), o);
+        Assert.assertEquals("Result is not 2", new Integer(2), o);
     }
 
     /**
@@ -70,12 +77,13 @@ public class IfTest extends JexlTestCase
      *
      * @throws Exception on any error
      */
+    @Test
     public void testBlockIfTrue() throws Exception {
         JexlScript e = JEXL.createScript("if (true) { 'hello'; }");
         JexlContext jc = new MapContext();
 
         Object o = e.execute(jc);
-        assertEquals("Result is wrong", "hello", o);
+        Assert.assertEquals("Result is wrong", "hello", o);
     }
 
     /**
@@ -83,12 +91,13 @@ public class IfTest extends JexlTestCase
      *
      * @throws Exception on any error
      */
+    @Test
     public void testBlockElse() throws Exception {
         JexlScript e = JEXL.createScript("if (false) {1} else {2 ; 3}");
         JexlContext jc = new MapContext();
 
         Object o = e.execute(jc);
-        assertEquals("Result is wrong", new Integer(3), o);
+        Assert.assertEquals("Result is wrong", new Integer(3), o);
     }
 
     /**
@@ -96,13 +105,14 @@ public class IfTest extends JexlTestCase
      *
      * @throws Exception on any error
      */
+    @Test
     public void testIfWithSimpleExpression() throws Exception {
         JexlScript e = JEXL.createScript("if (x == 1) true;");
         JexlContext jc = new MapContext();
         jc.set("x", new Integer(1));
 
         Object o = e.execute(jc);
-        assertEquals("Result is not true", Boolean.TRUE, o);
+        Assert.assertEquals("Result is not true", Boolean.TRUE, o);
     }
 
     /**
@@ -110,13 +120,14 @@ public class IfTest extends JexlTestCase
      *
      * @throws Exception on any error
      */
+    @Test
     public void testIfWithArithmeticExpression() throws Exception {
         JexlScript e = JEXL.createScript("if ((x * 2) + 1 == 5) true;");
         JexlContext jc = new MapContext();
         jc.set("x", new Integer(2));
 
         Object o = e.execute(jc);
-        assertEquals("Result is not true", Boolean.TRUE, o);
+        Assert.assertEquals("Result is not true", Boolean.TRUE, o);
     }
 
     /**
@@ -124,13 +135,14 @@ public class IfTest extends JexlTestCase
      *
      * @throws Exception on any error
      */
+    @Test
     public void testIfWithDecimalArithmeticExpression() throws Exception {
         JexlScript e = JEXL.createScript("if ((x * 2) == 5) true");
         JexlContext jc = new MapContext();
         jc.set("x", new Float(2.5f));
 
         Object o = e.execute(jc);
-        assertEquals("Result is not true", Boolean.TRUE, o);
+        Assert.assertEquals("Result is not true", Boolean.TRUE, o);
     }
 
     /**
@@ -138,6 +150,7 @@ public class IfTest extends JexlTestCase
      *
      * @throws Exception on any error
      */
+    @Test
     public void testIfWithAssignment() throws Exception {
         JexlScript e = JEXL.createScript("if ((x * 2) == 5) {y = 1} else {y = 2;}");
         JexlContext jc = new MapContext();
@@ -145,7 +158,7 @@ public class IfTest extends JexlTestCase
 
         e.execute(jc);
         Object result = jc.get("y");
-        assertEquals("y has the wrong value", new Integer(1), result);
+        Assert.assertEquals("y has the wrong value", new Integer(1), result);
     }
 
     /**
@@ -153,6 +166,7 @@ public class IfTest extends JexlTestCase
      * independantly of engine flags.
      * @throws Exception
      */
+    @Test
     public void testTernary() throws Exception {
         JexlEngine jexl = JEXL;
 
@@ -161,14 +175,13 @@ public class IfTest extends JexlTestCase
         Object o;
 
         // undefined foo
-
         for (int l = 0; l < 4; ++l) {
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
         jc.set("foo", null);
@@ -177,9 +190,9 @@ public class IfTest extends JexlTestCase
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
         jc.set("foo", Boolean.FALSE);
@@ -188,9 +201,9 @@ public class IfTest extends JexlTestCase
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
         jc.set("foo", Boolean.TRUE);
@@ -199,9 +212,9 @@ public class IfTest extends JexlTestCase
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be bar", "bar", o);
+            Assert.assertEquals("Should be bar", "bar", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be bar", "bar", o);
+            Assert.assertEquals("Should be bar", "bar", o);
         }
 
         debuggerCheck(jexl);
@@ -212,20 +225,20 @@ public class IfTest extends JexlTestCase
      * independantly of engine flags.
      * @throws Exception
      */
+    @Test
     public void testTernaryShorthand() throws Exception {
         JexlEvalContext jc = new JexlEvalContext();
         JexlExpression e = JEXL.createExpression("x.y.z = foo?:'quux'");
         Object o;
 
         // undefined foo
-
         for (int l = 0; l < 4; ++l) {
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
         jc.set("foo", null);
@@ -234,9 +247,9 @@ public class IfTest extends JexlTestCase
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
         jc.set("foo", Boolean.FALSE);
@@ -245,9 +258,9 @@ public class IfTest extends JexlTestCase
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
         jc.set("foo", Double.NaN);
@@ -256,9 +269,9 @@ public class IfTest extends JexlTestCase
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
         jc.set("foo", "");
@@ -267,9 +280,9 @@ public class IfTest extends JexlTestCase
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
         jc.set("foo", "false");
@@ -278,9 +291,9 @@ public class IfTest extends JexlTestCase
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
         jc.set("foo", 0d);
@@ -289,9 +302,9 @@ public class IfTest extends JexlTestCase
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
         jc.set("foo", 0);
@@ -300,21 +313,20 @@ public class IfTest extends JexlTestCase
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be quux", "quux", o);
+            Assert.assertEquals("Should be quux", "quux", o);
         }
 
-
         jc.set("foo", "bar");
 
         for (int l = 0; l < 4; ++l) {
             jc.setStrict((l & 1) == 0);
             jc.setSilent((l & 2) != 0);
             o = e.evaluate(jc);
-            assertEquals("Should be bar", "bar", o);
+            Assert.assertEquals("Should be bar", "bar", o);
             o = jc.get("x.y.z");
-            assertEquals("Should be bar", "bar", o);
+            Assert.assertEquals("Should be bar", "bar", o);
         }
 
         debuggerCheck(JEXL);