Add a test for method invocation with parameters
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 13 Jan 2010 18:01:26 +0000 (18:01 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 13 Jan 2010 18:01:26 +0000 (18:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@898863 13f79535-47bb-0310-9956-ffa450edef68

test/org/apache/el/TestELInJsp.java
test/org/apache/el/TesterBeanA.java [new file with mode: 0644]
test/org/apache/el/TesterBeanB.java [new file with mode: 0644]
test/webapp/el-method.jsp [new file with mode: 0644]

index b28ba5f..0bfd536 100644 (file)
@@ -312,7 +312,6 @@ public class TestELInJsp extends TomcatBaseTest {
         ByteChunk res = getUrl("http://localhost:" + getPort() +
                 "/test/script-expr.jsp");
         String result = res.toString();
-        System.out.println(result);
         assertTrue(result.indexOf("00-hello world") > 0);
         assertTrue(result.indexOf("01-hello \"world") > 0);
         assertTrue(result.indexOf("02-hello \\\"world") > 0);
@@ -327,4 +326,21 @@ public class TestELInJsp extends TomcatBaseTest {
         assertTrue(result.indexOf("11-hello %> world") > 0);
     }
 
+    public void testELMethod() throws Exception {
+        Tomcat tomcat = getTomcatInstance();
+
+        File appDir = 
+            new File("test/webapp");
+        // app dir is relative to server home
+        tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
+        
+        tomcat.start();
+
+        ByteChunk res = getUrl("http://localhost:" + getPort() +
+                "/test/el-method.jsp");
+        String result = res.toString();
+        assertTrue(result.indexOf("00-Hello JUnit from Tomcat") > 0);
+        assertTrue(result.indexOf("01-Hello JUnit from Tomcat") > 0);
+        assertTrue(result.indexOf("02-Hello JUnit from Tomcat") > 0);
+    }
 }
diff --git a/test/org/apache/el/TesterBeanA.java b/test/org/apache/el/TesterBeanA.java
new file mode 100644 (file)
index 0000000..b5d4b8d
--- /dev/null
@@ -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 org.apache.el;
+
+public class TesterBeanA {
+    private TesterBeanB bean;
+
+    public TesterBeanB getBean() {
+        return bean;
+    }
+
+    public void setBean(TesterBeanB bean) {
+        this.bean = bean;
+    }
+}
diff --git a/test/org/apache/el/TesterBeanB.java b/test/org/apache/el/TesterBeanB.java
new file mode 100644 (file)
index 0000000..e92926b
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+public class TesterBeanB {
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    public String sayHello(String to) {
+        return "Hello " + to + " from " + name;
+    }
+}
diff --git a/test/webapp/el-method.jsp b/test/webapp/el-method.jsp
new file mode 100644 (file)
index 0000000..a7c9d62
--- /dev/null
@@ -0,0 +1,35 @@
+<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
+<%@ page import="org.apache.el.TesterBeanA" %>
+<%@ page import="org.apache.el.TesterBeanB" %>
+<%--
+ 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.
+--%>
+<html>
+  <head><title>EL method test cases</title></head>
+  <body>
+    <%
+    TesterBeanA beanA = new TesterBeanA();
+    TesterBeanB beanB = new TesterBeanB();
+    beanB.setName("Tomcat");
+    beanA.setBean(beanB);
+    pageContext.setAttribute("testBeanA", beanA);
+    pageContext.setAttribute("testBeanB", beanB);
+    %>
+    <tags:echo echo="00-${testBeanA[\"bean\"].sayHello('JUnit')}" />
+    <tags:echo echo="01-${testBeanA.bean.sayHello('JUnit')}" />
+    <tags:echo echo="02-${testBeanB.sayHello('JUnit')}" />
+  </body>
+</html>
\ No newline at end of file