Author: markt
Date: Fri Jul 12 13:25:04 2013
New Revision: 1502552
URL: http://svn.apache.org/r1502552
Log:
Add some more unit tests for the EL processor and make sure it uses the import
information it has to hand to resolve class names.
Modified:
tomcat/trunk/java/javax/el/ELProcessor.java
tomcat/trunk/test/javax/el/TestELProcessor.java
Modified: tomcat/trunk/java/javax/el/ELProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ELProcessor.java?rev=1502552&r1=1502551&r2=1502552&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/ELProcessor.java (original)
+++ tomcat/trunk/java/javax/el/ELProcessor.java Fri Jul 12 13:25:04 2013
@@ -74,7 +74,12 @@ public class ELProcessor {
context, "elProcessor.defineFunctionNullParams"));
}
- Class<?> clazz = Class.forName(className);
+ // Check the imports
+ Class<?> clazz = context.getImportHandler().resolveClass(className);
+
+ if (clazz == null) {
+ clazz = Class.forName(className);
+ }
if (!Modifier.isPublic(clazz.getModifiers())) {
throw new ClassNotFoundException(Util.message(context,
Modified: tomcat/trunk/test/javax/el/TestELProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TestELProcessor.java?rev=1502552&r1=1502551&r2=1502552&view=diff
==============================================================================
--- tomcat/trunk/test/javax/el/TestELProcessor.java (original)
+++ tomcat/trunk/test/javax/el/TestELProcessor.java Fri Jul 12 13:25:04 2013
@@ -27,4 +27,37 @@ public class TestELProcessor {
elp.defineBean("bean01", new TesterBean("name01"));
Assert.assertEquals("name01", elp.eval("bean01.name"));
}
+
+
+ @Test(expected=ELException.class)
+ public void testEval01() {
+ ELProcessor elp = new ELProcessor();
+ elp.eval("${1+1}");
+ }
+
+
+ @Test(expected=ELException.class)
+ public void testEval02() {
+ ELProcessor elp = new ELProcessor();
+ elp.eval("#{1+1}");
+ }
+
+
+ @Test
+ public void testDefineFunctionMethod01() throws Exception {
+ ELProcessor elp = new ELProcessor();
+ elp.defineFunction("fn", "toInt",
+ Integer.class.getMethod("valueOf", String.class));
+ Assert.assertEquals(Integer.valueOf(1), elp.eval("fn:toInt(1)"));
+ }
+
+
+ @Test
+ public void testDefineFunctionName01() throws Exception {
+ ELProcessor elp = new ELProcessor();
+ // java.lang should be automatically imported so no need for full class
+ // name
+ elp.defineFunction("fn", "toInt", "Integer", "valueOf");
+ Assert.assertEquals(Integer.valueOf(1), elp.eval("fn:toInt(1)"));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]