From: kkolinko Date: Thu, 23 Jul 2009 13:15:41 +0000 (+0000) Subject: Moved and renamed TestELParser class. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=27cba0db7e6a8c6dc1d80218e8cb0de7a42a1cb5;p=tomcat7.0 Moved and renamed TestELParser class. Some more EL tests to be added later. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@797058 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/org/apache/TestAll.java b/test/org/apache/TestAll.java index 78a070bd3..1a6bfc850 100644 --- a/test/org/apache/TestAll.java +++ b/test/org/apache/TestAll.java @@ -4,7 +4,7 @@ import org.apache.catalina.ha.session.TestSerializablePrincipal; import org.apache.catalina.startup.TestTomcat; import org.apache.catalina.tribes.test.TribesTestSuite; import org.apache.el.lang.TestELSupport; -import org.apache.el.parser.TestELParser; +import org.apache.el.TestELEvaluation; import org.apache.tomcat.util.http.TestCookies; import org.apache.tomcat.util.res.TestStringManager; @@ -25,7 +25,7 @@ public class TestAll { // suite.addTest(TribesTestSuite.suite()); // o.a.el suite.addTestSuite(TestELSupport.class); - suite.addTestSuite(TestELParser.class); + suite.addTestSuite(TestELEvaluation.class); // o.a.tomcat.util suite.addTestSuite(TestStringManager.class); diff --git a/test/org/apache/el/TestELEvaluation.java b/test/org/apache/el/TestELEvaluation.java new file mode 100644 index 000000000..c441be793 --- /dev/null +++ b/test/org/apache/el/TestELEvaluation.java @@ -0,0 +1,59 @@ +/* + * 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; + +import javax.el.ValueExpression; + +import org.apache.el.ExpressionFactoryImpl; +import org.apache.jasper.el.ELContextImpl; + +import junit.framework.TestCase; + +/** + * Tests for EL parsing and evaluation. + */ +public class TestELEvaluation extends TestCase { + + public void testParserBug45511() { + // 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 testParserBug42565() { + // 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); + } +} diff --git a/test/org/apache/el/parser/TestELParser.java b/test/org/apache/el/parser/TestELParser.java deleted file mode 100644 index 2cce2098b..000000000 --- a/test/org/apache/el/parser/TestELParser.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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); - } -}