Author: kkolinko
Date: Sat Nov  7 14:35:52 2015
New Revision: 1713133

URL: http://svn.apache.org/viewvc?rev=1713133&view=rev
Log:
Convert test classes to JUnit 4, copy some additional tests from Tomcat 7.

Modified:
    tomcat/tc6.0.x/trunk/test/org/apache/el/TestELEvaluation.java
    tomcat/tc6.0.x/trunk/test/org/apache/el/lang/TestELArithmetic.java
    tomcat/tc6.0.x/trunk/test/org/apache/el/lang/TestELSupport.java

Modified: tomcat/tc6.0.x/trunk/test/org/apache/el/TestELEvaluation.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/test/org/apache/el/TestELEvaluation.java?rev=1713133&r1=1713132&r2=1713133&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/test/org/apache/el/TestELEvaluation.java (original)
+++ tomcat/tc6.0.x/trunk/test/org/apache/el/TestELEvaluation.java Sat Nov  7 
14:35:52 2015
@@ -22,26 +22,31 @@ import java.lang.reflect.Method;
 import java.util.Date;
 
 import javax.el.ELException;
-import javax.el.ValueExpression;
 import javax.el.FunctionMapper;
+import javax.el.ValueExpression;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
 
-import org.apache.el.ExpressionFactoryImpl;
 import org.apache.el.lang.ELSupport;
-import org.apache.jasper.compiler.TestAttributeParser;
 import org.apache.jasper.el.ELContextImpl;
 
-import junit.framework.TestCase;
-
 /**
  * Tests the EL engine directly. Similar tests may be found in
- * {@link TestAttributeParser} and {@link TestELInJsp}.
+ * {@link org.apache.jasper.compiler.TestAttributeParser} and
+ * {@link TestELInJsp}.
  */
-public class TestELEvaluation extends TestCase {
+public class TestELEvaluation {
 
     /**
      * Test use of spaces in ternary expressions. This was primarily an EL
      * parser bug.
      */
+    @Test
     public void testBug42565() {
         assertEquals("false", evaluateExpression("${false?true:false}"));
         assertEquals("false", evaluateExpression("${false?true: false}"));
@@ -63,8 +68,9 @@ public class TestELEvaluation extends Te
 
 
     /**
-     * Test use nested ternary expressions. This was primarily an EL parser 
bug. 
+     * Test use nested ternary expressions. This was primarily an EL parser 
bug.
      */
+    @Test
     public void testBug44994() {
         assertEquals("none", evaluateExpression(
                 "${0 lt 0 ? 1 lt 0 ? 'many': 'one': 'none'}"));
@@ -74,7 +80,7 @@ public class TestELEvaluation extends Te
                 "${0 lt 2 ? 1 lt 2 ? 'many': 'one': 'none'}"));
     }
 
-
+    @Test
     public void testParserBug45511() {
         // Test cases provided by OP
         assertEquals("true", evaluateExpression("${empty ('')}"));
@@ -83,18 +89,20 @@ public class TestELEvaluation extends Te
         assertEquals("false", evaluateExpression("${(true)and(false)}"));
     }
 
+    @Test
     public void testBug48112() {
         // bug 48112
         assertEquals("{world}", evaluateExpression("${fn:trim('{world}')}"));
     }
 
+    @Test
     public void testParserLiteralExpression() {
         // Inspired by work on bug 45451, comments from kkolinko on the dev
         // list and looking at the spec to find some edge cases
 
         // '\' is only an escape character inside a StringLiteral
         assertEquals("\\\\", evaluateExpression("\\\\"));
-        
+
         /*
          * LiteralExpresions can only contain ${ or #{ if escaped with \
          * \ is not an escape character in any other circumstances including \\
@@ -119,10 +127,11 @@ public class TestELEvaluation extends Te
         assertEquals("\\\\", evaluateExpression("\\\\"));
     }
 
+    @Test
     public void testParserStringLiteral() {
         // Inspired by work on bug 45451, comments from kkolinko on the dev
         // list and looking at the spec to find some edge cases
-        
+
         // The only characters that can be escaped inside a String literal
         // are \ " and '. # and $ are not escaped inside a String literal.
         assertEquals("\\", evaluateExpression("${'\\\\'}"));
@@ -141,9 +150,8 @@ public class TestELEvaluation extends Te
 
         assertEquals("\\$", evaluateExpression("${'\\\\$'}"));
         assertEquals("\\\\$", evaluateExpression("${'\\\\\\\\$'}"));
-        
-        
-        
+
+
         // Can use ''' inside '"' when quoting with '"' and vice versa without
         // escaping
         assertEquals("\\\"", evaluateExpression("${'\\\\\"'}"));
@@ -163,12 +171,13 @@ public class TestELEvaluation extends Te
         assertEquals(msg,expected, -i2);
     }
 
+    @Test
     public void testElSupportCompare(){
         compareBoth("Nulls should compare equal", 0, null, null);
         compareBoth("Null should compare equal to \"\"", 0, "", null);
         compareBoth("Null should be less than File()",-1, null, new File(""));
         compareBoth("Null should be less than Date()",-1, null, new Date());
-        compareBoth("Date(0) should be less than Date(1)",-1, new Date(0), new 
Date(1));        
+        compareBoth("Date(0) should be less than Date(1)",-1, new Date(0), new 
Date(1));
         try {
             compareBoth("Should not compare",0, new Date(), new File(""));
             fail("Expecting ClassCastException");
@@ -181,6 +190,7 @@ public class TestELEvaluation extends Te
     /**
      * Test mixing ${...} and #{...} in the same expression.
      */
+    @Test
     public void testMixedTypes() {
         // Mixing types should throw an error
         Exception e = null;
@@ -202,7 +212,7 @@ public class TestELEvaluation extends Te
                 String.class);
         return (String) ve.getValue(ctx);
     }
-    
+
     public static class FMapper extends FunctionMapper {
 
         @Override
@@ -216,7 +226,7 @@ public class TestELEvaluation extends Te
                     // Ignore
                 } catch (NoSuchMethodException e) {
                     // Ignore
-                } 
+                }
             }
             return null;
         }

Modified: tomcat/tc6.0.x/trunk/test/org/apache/el/lang/TestELArithmetic.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/test/org/apache/el/lang/TestELArithmetic.java?rev=1713133&r1=1713132&r2=1713133&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/test/org/apache/el/lang/TestELArithmetic.java 
(original)
+++ tomcat/tc6.0.x/trunk/test/org/apache/el/lang/TestELArithmetic.java Sat Nov  
7 14:35:52 2015
@@ -16,41 +16,83 @@
  */
 package org.apache.el.lang;
 
+import java.math.BigDecimal;
 import java.math.BigInteger;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
 
-public class TestELArithmetic extends TestCase {
-    private final String a = "1.1";
-    private final BigInteger b = new BigInteger("1000000000000000000000");
+import org.junit.Test;
 
+public class TestELArithmetic {
+    private static final String a = "1.1";
+    private static final BigInteger b =
+        new BigInteger("1000000000000000000000");
+
+    @Test
     public void testAdd() throws Exception {
         assertEquals("1000000000000000000001.1",
                 String.valueOf(ELArithmetic.add(a, b)));
     }
 
+    @Test
     public void testSubtract() throws Exception {
         assertEquals("-999999999999999999998.9",
                 String.valueOf(ELArithmetic.subtract(a, b)));
     }
 
+    @Test
     public void testMultiply() throws Exception {
         assertEquals("1100000000000000000000.0",
                 String.valueOf(ELArithmetic.multiply(a, b)));
     }
 
+    @Test
     public void testDivide() throws Exception {
         assertEquals("0.0",
                 String.valueOf(ELArithmetic.divide(a, b)));
     }
 
+    @Test
     public void testMod() throws Exception {
         assertEquals("1.1",
                 String.valueOf(ELArithmetic.mod(a, b)));
     }
 
-    public void testBug47371() throws Exception {
-        assertEquals("1",
-                String.valueOf(ELArithmetic.add("", Integer.valueOf(1))));
+    @Test
+    public void testBug47371bigDecimal() throws Exception {
+        assertEquals(BigDecimal.valueOf(1),
+                ELArithmetic.add("", BigDecimal.valueOf(1)));
+    }
+
+    @Test
+    public void testBug47371double() throws Exception {
+        assertEquals(Double.valueOf(7), ELArithmetic.add("", 
Double.valueOf(7)));
+    }
+
+    @Test
+    public void testBug47371doubleString() throws Exception {
+        assertEquals(Double.valueOf(2), ELArithmetic.add("", "2."));
+    }
+
+    @Test
+    public void testBug47371bigInteger() throws Exception {
+        assertEquals(BigInteger.valueOf(0),
+                ELArithmetic.multiply("", BigInteger.valueOf(1)));
     }
+
+    @Test
+    public void testBug47371long() throws Exception {
+        assertEquals(Long.valueOf(1), ELArithmetic.add("", 
Integer.valueOf(1)));
+    }
+
+    @Test
+    public void testBug47371long2() throws Exception {
+        assertEquals(Long.valueOf(-3), ELArithmetic.subtract("1", "4"));
+    }
+
+    @Test
+    public void testBug47371doubleString2() throws Exception {
+        assertEquals(Double.valueOf(2), ELArithmetic.add("1.", "1"));
+    }
+
 }

Modified: tomcat/tc6.0.x/trunk/test/org/apache/el/lang/TestELSupport.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/test/org/apache/el/lang/TestELSupport.java?rev=1713133&r1=1713132&r2=1713133&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/test/org/apache/el/lang/TestELSupport.java (original)
+++ tomcat/tc6.0.x/trunk/test/org/apache/el/lang/TestELSupport.java Sat Nov  7 
14:35:52 2015
@@ -21,58 +21,74 @@ import java.math.BigInteger;
 
 import javax.el.ELException;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
-public class TestELSupport extends TestCase {
+import org.junit.Test;
+
+public class TestELSupport {
+    @Test
     public void testEquals() {
         assertTrue(ELSupport.equals("01", Long.valueOf(1)));
     }
 
+    @Test
     public void testBigDecimal() {
         testIsSame(new BigDecimal(
                 
"0.123456789012345678901234567890123456789012345678901234567890123456789"));
     }
 
+    @Test
     public void testBigInteger() {
         testIsSame(new BigInteger(
                 
"1234567890123456789012345678901234567890123456789012345678901234567890"));
     }
 
+    @Test
     public void testLong() {
         testIsSame(Long.valueOf(0x0102030405060708L));
     }
 
+    @Test
     public void testInteger() {
         testIsSame(Integer.valueOf(0x01020304));
     }
 
+    @Test
     public void testShort() {
         testIsSame(Short.valueOf((short) 0x0102));
     }
 
+    @Test
     public void testByte() {
         testIsSame(Byte.valueOf((byte) 0xEF));
     }
 
+    @Test
     public void testDouble() {
         testIsSame(Double.valueOf(0.123456789012345678901234));
     }
 
+    @Test
     public void testFloat() {
         testIsSame(Float.valueOf(0.123456F));
     }
 
+    @Test
     public void testCoerceIntegerToNumber() {
-        Integer input = 4390241;
+        Integer input = Integer.valueOf(4390241);
         Object output = ELSupport.coerceToType(input, Number.class);
         assertEquals(input, output);
     }
 
+    @Test
     public void testCoerceNullToNumber() {
         Object output = ELSupport.coerceToType(null, Number.class);
         assertEquals(Long.valueOf(0), output);
     }
-    
+
+    @Test
     public void testCoerceEnumAToEnumA() {
         Object output = null;
         try {
@@ -81,7 +97,8 @@ public class TestELSupport extends TestC
             assertEquals(TestEnumA.VALA1, output);
         }
     }
-    
+
+    @Test
     public void testCoerceEnumAToEnumB() {
         Object output = null;
         try {
@@ -92,6 +109,7 @@ public class TestELSupport extends TestC
         assertNull(output);
     }
 
+    @Test
     public void testCoerceEnumAToEnumC() {
         Object output = null;
         try {
@@ -105,7 +123,7 @@ public class TestELSupport extends TestC
     private static void testIsSame(Object value) {
         assertEquals(value, ELSupport.coerceToNumber(value, value.getClass()));
     }
-    
+
     private static enum TestEnumA {
         VALA1,
         VALA2



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to