Author: markt
Date: Fri Jul 12 12:23:25 2013
New Revision: 1502528

URL: http://svn.apache.org/r1502528
Log:
Add initial unit test for ELProcessor and handle the fact that expressions are 
defined without brackets.

Added:
    tomcat/trunk/test/javax/el/TestELProcessor.java   (with props)
Modified:
    tomcat/trunk/java/javax/el/ELProcessor.java

Modified: tomcat/trunk/java/javax/el/ELProcessor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ELProcessor.java?rev=1502528&r1=1502527&r2=1502528&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/ELProcessor.java (original)
+++ tomcat/trunk/java/javax/el/ELProcessor.java Fri Jul 12 12:23:25 2013
@@ -41,14 +41,14 @@ public class ELProcessor {
 
     public Object getValue(String expression, Class<?> expectedType) {
         ValueExpression ve = factory.createValueExpression(
-                context, expression, expectedType);
+                context, bracket(expression), expectedType);
         return ve.getValue(context);
     }
 
 
     public void setValue(String expression, Object value) {
         ValueExpression ve = factory.createValueExpression(
-                context, expression, Object.class);
+                context, bracket(expression), Object.class);
         ve.setValue(context, value);
     }
 
@@ -58,7 +58,7 @@ public class ELProcessor {
             manager.setVariable(variable, null);
         } else {
             ValueExpression ve = factory.createValueExpression(
-                    context, expression, Object.class);
+                    context, bracket(expression), Object.class);
             manager.setVariable(variable, ve);
         }
     }
@@ -150,6 +150,10 @@ public class ELProcessor {
     }
 
 
+    private static String bracket(String expression) {
+        return "${" + expression + "}";
+    }
+
     private static class MethodSignature {
 
         private final String name;

Added: tomcat/trunk/test/javax/el/TestELProcessor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TestELProcessor.java?rev=1502528&view=auto
==============================================================================
--- tomcat/trunk/test/javax/el/TestELProcessor.java (added)
+++ tomcat/trunk/test/javax/el/TestELProcessor.java Fri Jul 12 12:23:25 2013
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package javax.el;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestELProcessor {
+
+    @Test
+    public void testDefineBean01() {
+        ELProcessor elp = new ELProcessor();
+        elp.defineBean("bean01", new TesterBean("name01"));
+        Assert.assertEquals("name01", elp.eval("bean01.name"));
+    }
+}

Propchange: tomcat/trunk/test/javax/el/TestELProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native



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

Reply via email to