Author: kkolinko
Date: Tue Feb 25 16:34:59 2014
New Revision: 1571731
URL: http://svn.apache.org/r1571731
Log:
Add tests for
https://issues.apache.org/bugzilla/show_bug.cgi?id=56179
https://issues.apache.org/bugzilla/show_bug.cgi?id=56185
(Backport of r1571245, r1571725)
Added:
tomcat/tc7.0.x/trunk/test/org/apache/el/parser/TesterBeanC.java
- copied unchanged from r1571725,
tomcat/trunk/test/org/apache/el/parser/TesterBeanC.java
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/test/org/apache/el/parser/TestELParser.java
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1571725
Modified: tomcat/tc7.0.x/trunk/test/org/apache/el/parser/TestELParser.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/el/parser/TestELParser.java?rev=1571731&r1=1571730&r2=1571731&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/el/parser/TestELParser.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/el/parser/TestELParser.java Tue Feb 25
16:34:59 2014
@@ -104,6 +104,121 @@ public class TestELParser {
}
+ @Test
+ public void bug56179a() {
+ doTestBug56179(0, "test == true");
+ }
+
+ @Test
+ public void bug56179b() {
+ doTestBug56179(1, "test == true");
+ }
+
+ @Test
+ public void bug56179c() {
+ doTestBug56179(2, "test == true");
+ }
+
+ @Test
+ public void bug56179d() {
+ doTestBug56179(3, "test == true");
+ }
+
+ @Test
+ public void bug56179e() {
+ doTestBug56179(4, "test == true");
+ }
+
+ @Test
+ public void bug56179f() {
+ doTestBug56179(5, "test == true");
+ }
+
+ @Test
+ public void bug56179g() {
+ doTestBug56179(0, "(test) == true");
+ }
+
+ @Test
+ public void bug56179h() {
+ doTestBug56179(1, "(test) == true");
+ }
+
+ @Test
+ public void bug56179i() {
+ doTestBug56179(2, "(test) == true");
+ }
+
+ @Test
+ public void bug56179j() {
+ doTestBug56179(3, "(test) == true");
+ }
+
+ @Test
+ public void bug56179k() {
+ doTestBug56179(4, "(test) == true");
+ }
+
+ @Test
+ public void bug56179l() {
+ doTestBug56179(5, "(test) == true");
+ }
+
+ @Test
+ public void bug56179m() {
+ doTestBug56179(5, "((test)) == true");
+ }
+
+ @Test
+ public void bug56179n() {
+ doTestBug56179(5, "(((test))) == true");
+ }
+
+ private void doTestBug56179(int parenthesesCount, String innerExpr) {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ ValueExpression var =
+ factory.createValueExpression(Boolean.TRUE, Boolean.class);
+ context.getVariableMapper().setVariable("test", var);
+
+ StringBuilder expr = new StringBuilder();
+ expr.append("${");
+ for (int i = 0; i < parenthesesCount; i++) {
+ expr.append("(");
+ }
+ expr.append(innerExpr);
+ for (int i = 0; i < parenthesesCount; i++) {
+ expr.append(")");
+ }
+ expr.append("}");
+ ValueExpression ve = factory.createValueExpression(
+ context, expr.toString(), String.class);
+
+ String result = (String) ve.getValue(context);
+ assertEquals("true", result);
+ }
+
+ @Test
+ public void bug56185() {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ TesterBeanC beanC = new TesterBeanC();
+ ValueExpression var =
+ factory.createValueExpression(beanC, TesterBeanC.class);
+ context.getVariableMapper().setVariable("myBean", var);
+
+ ValueExpression ve = factory.createValueExpression(context,
+ "${(myBean.int1 > 1 and myBean.myBool) or "+
+ "((myBean.myBool or myBean.myBool1) and myBean.int1 > 1)}",
+ Boolean.class);
+ assertEquals(Boolean.FALSE, ve.getValue(context));
+ beanC.setInt1(2);
+ beanC.setMyBool1(true);
+ assertEquals(Boolean.TRUE, ve.getValue(context));
+ }
+
private void testExpression(String expression, String expected) {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]