Author: markt
Date: Sat Jan 16 10:49:25 2010
New Revision: 899918

URL: http://svn.apache.org/viewvc?rev=899918&view=rev
Log:
Add some test cases for Enum to Enum coercion

Modified:
    tomcat/trunk/test/org/apache/el/lang/TestELSupport.java

Modified: tomcat/trunk/test/org/apache/el/lang/TestELSupport.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/lang/TestELSupport.java?rev=899918&r1=899917&r2=899918&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/lang/TestELSupport.java (original)
+++ tomcat/trunk/test/org/apache/el/lang/TestELSupport.java Sat Jan 16 10:49:25 
2010
@@ -19,6 +19,8 @@
 import java.math.BigDecimal;
 import java.math.BigInteger;
 
+import javax.el.ELException;
+
 import junit.framework.TestCase;
 
 public class TestELSupport extends TestCase {
@@ -66,8 +68,51 @@
         Object output = ELSupport.coerceToType(null, Number.class);
         assertEquals(Long.valueOf(0), output);
     }
+    
+    public void testCoerceEnumAToEnumA() {
+        Object output = null;
+        try {
+            output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumA.class);
+        } finally {
+            assertEquals(TestEnumA.VALA1, output);
+        }
+    }
+    
+    public void testCoerceEnumAToEnumB() {
+        Object output = null;
+        try {
+            output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumB.class);
+        } catch (ELException ele) {
+            // Ignore
+        }
+        assertNull(output);
+    }
+
+    public void testCoerceEnumAToEnumC() {
+        Object output = null;
+        try {
+            output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumC.class);
+        } finally {
+            assertEquals(TestEnumC.VALA1, output);
+        }
+    }
 
     private static void testIsSame(Object value) {
         assertEquals(value, ELSupport.coerceToNumber(value, value.getClass()));
     }
+    
+    private static enum TestEnumA {
+        VALA1,
+        VALA2
+    }
+    private static enum TestEnumB {
+        VALB1,
+        VALB2
+    }
+    private static enum TestEnumC {
+        VALA1,
+        VALA2,
+        VALB1,
+        VALB2
+    }
 }



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

Reply via email to