Skip to main content

[el-spec commits] [el-spec~source-code:84] Fix isParametersProvided()

  • From: kchung@...
  • To: commits@...
  • Subject: [el-spec commits] [el-spec~source-code:84] Fix isParametersProvided()
  • Date: Thu, 26 Apr 2012 01:01:53 +0000

Project:    el-spec
Repository: source-code
Revision:   84
Author:     kchung
Date:       2012-04-26 01:01:52 UTC
Link:       

Log Message:
------------
Fix isParametersProvided()




Revisions:
----------
84


Modified Paths:
---------------
trunk/impl/src/main/java/com/sun/el/parser/AstValue.java
trunk/impl/src/main/java/com/sun/el/MethodExpressionImpl.java
trunk/impl/src/test/java/org/glassfish/el/test/ELProcessorTest.java
trunk/impl/src/main/java/com/sun/el/ExpressionFactoryImpl.java


Diffs:
------
Index: trunk/impl/src/test/java/org/glassfish/el/test/ELProcessorTest.java
===================================================================
--- trunk/impl/src/test/java/org/glassfish/el/test/ELProcessorTest.java 
(revision 83)
+++ trunk/impl/src/test/java/org/glassfish/el/test/ELProcessorTest.java 
(revision 84)
@@ -7,14 +7,22 @@
 import static org.junit.Assert.assertTrue;
 
 import javax.el.ELProcessor;
+import javax.el.ELManager;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ELContext;
 
 public class ELProcessorTest {
 
     static ELProcessor elp;
+    static ELManager elm;
+    static ExpressionFactory factory;
     
     @BeforeClass
     public static void setUpClass() throws Exception {
         elp = new ELProcessor();
+        elm = elp.getELManager();
+        factory = elm.getExpressionFactory();
     }
     
     @Before
@@ -22,6 +30,24 @@
     }
 
     @Test
+    public void testMethExpr() {
+        MethodExpression meth = null;
+        ELContext ctxt = elm.getELContext();
+        try {
+            meth = factory.createMethodExpression(
+                ctxt, "#{str.length}", Object.class, null);
+        } catch (NullPointerException ex){
+            // Do nothing
+        }
+        assertTrue(meth == null);
+        meth = factory.createMethodExpression(
+                ctxt, "#{'abc'.length()}", Object.class, null);
+        Object result = meth.invoke(ctxt, new Object[] {"abcde"});
+        System.out.println("'abc'.length() called, equals " + result);
+        assertEquals(result, new Integer(3));
+    }
+
+    @Test
     public void testGetValue() {
         Object result = elp.eval("10 + 1");
         assertEquals(result.toString(), "11");
Index: trunk/impl/src/main/java/com/sun/el/MethodExpressionImpl.java
===================================================================
--- trunk/impl/src/main/java/com/sun/el/MethodExpressionImpl.java       
(revision 83)
+++ trunk/impl/src/main/java/com/sun/el/MethodExpressionImpl.java       
(revision 84)
@@ -339,7 +339,7 @@
     }
 
     @Override
-    public boolean isParmetersProvided() {
+    public boolean isParametersProvided() {
         return this.getNode().isParametersProvided();
     }
 }
Index: trunk/impl/src/main/java/com/sun/el/ExpressionFactoryImpl.java
===================================================================
--- trunk/impl/src/main/java/com/sun/el/ExpressionFactoryImpl.java      
(revision 83)
+++ trunk/impl/src/main/java/com/sun/el/ExpressionFactoryImpl.java      
(revision 84)
@@ -83,7 +83,7 @@
         ExpressionBuilder builder = new ExpressionBuilder(expression, 
context);
         MethodExpression me = 
builder.createMethodExpression(expectedReturnType,
                 expectedParamTypes);
-        if (expectedParamTypes == null && !me.isParmetersProvided()) {
+        if (expectedParamTypes == null && !me.isParametersProvided()) {
             throw new NullPointerException(MessageFactory
                     .get("error.method.nullParms"));
         }
Index: trunk/impl/src/main/java/com/sun/el/parser/AstValue.java
===================================================================
--- trunk/impl/src/main/java/com/sun/el/parser/AstValue.java    (revision 83)
+++ trunk/impl/src/main/java/com/sun/el/parser/AstValue.java    (revision 84)
@@ -262,7 +262,6 @@
 
     @Override
     public boolean isParametersProvided() {
-        // XXX
-        return true;
+        return getArguments(this.children[this.jjtGetNumChildren()-1]) != 
null;
     }
 }





[el-spec commits] [el-spec~source-code:84] Fix isParametersProvided()

kchung 04/26/2012
 
 
Close
loading
Please Confirm
Close