You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2008/12/24 16:11:08 UTC

svn commit: r729318 - in /tomcat/trunk/test/org/apache/el/parser: ./ TestELParser.java

Author: markt
Date: Wed Dec 24 07:11:07 2008
New Revision: 729318

URL: http://svn.apache.org/viewvc?rev=729318&view=rev
Log:
Add some unit tests for the EL parser based on some recent bugs

Added:
    tomcat/trunk/test/org/apache/el/parser/
    tomcat/trunk/test/org/apache/el/parser/TestELParser.java

Added: tomcat/trunk/test/org/apache/el/parser/TestELParser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/parser/TestELParser.java?rev=729318&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/el/parser/TestELParser.java (added)
+++ tomcat/trunk/test/org/apache/el/parser/TestELParser.java Wed Dec 24 07:11:07 2008
@@ -0,0 +1,57 @@
+/*
+ * 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 org.apache.el.parser;
+
+import javax.el.ValueExpression;
+
+import org.apache.el.ExpressionFactoryImpl;
+import org.apache.jasper.el.ELContextImpl;
+
+import junit.framework.TestCase;
+
+public class TestELParser extends TestCase {
+    
+    public void testBug45511() {
+        // Test cases provided by OP
+        assertEquals("true", evaluateExpression("${empty ('')}"));
+        assertEquals("true", evaluateExpression("${empty('')}"));
+        assertEquals("false", evaluateExpression("${(true) and (false)}"));
+        assertEquals("false", evaluateExpression("${(true)and(false)}"));
+    }
+    
+
+    public void testBug42565() {
+        // Test cases provided by OP
+        assertEquals("false", evaluateExpression("${false?true:false}"));
+    }
+
+
+    public void testMisc() {
+        // From bug 45451 - not a parser bug
+        assertEquals("\\", evaluateExpression("\\\\"));
+    }
+    
+
+    private String evaluateExpression(String expression) {
+        ELContextImpl ctx = new ELContextImpl();
+        ExpressionFactoryImpl exprFactory = new ExpressionFactoryImpl();
+        ValueExpression ve =
+            exprFactory.createValueExpression(ctx, expression, String.class );
+        return (String) ve.getValue(ctx);
+    }
+}



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