From c9b1e755ccd421b197265a57869392a45c127b9b Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 13 Jan 2010 18:01:26 +0000 Subject: [PATCH] Add a test for method invocation with parameters git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@898863 13f79535-47bb-0310-9956-ffa450edef68 --- test/org/apache/el/TestELInJsp.java | 18 +++++++++++++++++- test/org/apache/el/TesterBeanA.java | 30 ++++++++++++++++++++++++++++++ test/org/apache/el/TesterBeanB.java | 34 ++++++++++++++++++++++++++++++++++ test/webapp/el-method.jsp | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 test/org/apache/el/TesterBeanA.java create mode 100644 test/org/apache/el/TesterBeanB.java create mode 100644 test/webapp/el-method.jsp diff --git a/test/org/apache/el/TestELInJsp.java b/test/org/apache/el/TestELInJsp.java index b28ba5fc8..0bfd53696 100644 --- a/test/org/apache/el/TestELInJsp.java +++ b/test/org/apache/el/TestELInJsp.java @@ -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 index 000000000..b5d4b8d9a --- /dev/null +++ b/test/org/apache/el/TesterBeanA.java @@ -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 index 000000000..e92926b72 --- /dev/null +++ b/test/org/apache/el/TesterBeanB.java @@ -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 index 000000000..a7c9d62c0 --- /dev/null +++ b/test/webapp/el-method.jsp @@ -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. +--%> + + EL method test cases + + <% + TesterBeanA beanA = new TesterBeanA(); + TesterBeanB beanB = new TesterBeanB(); + beanB.setName("Tomcat"); + beanA.setBean(beanB); + pageContext.setAttribute("testBeanA", beanA); + pageContext.setAttribute("testBeanB", beanB); + %> + + + + + \ No newline at end of file -- 2.11.0