Author: remy.maucherat(a)jboss.com
Date: 2011-12-06 10:29:27 -0500 (Tue, 06 Dec 2011)
New Revision: 1883
Added:
trunk/test/java/org/apache/el/
trunk/test/java/org/apache/el/TestELEvaluation.java
trunk/test/java/org/apache/el/TestMethodExpressionImpl.java
trunk/test/java/org/apache/el/TestValueExpressionImpl.java
trunk/test/java/org/apache/el/TesterBeanA.java
trunk/test/java/org/apache/el/TesterBeanAA.java
trunk/test/java/org/apache/el/TesterBeanAAA.java
trunk/test/java/org/apache/el/TesterBeanB.java
trunk/test/java/org/apache/el/TesterBeanBB.java
trunk/test/java/org/apache/el/TesterBeanBBB.java
trunk/test/java/org/apache/el/TesterBeanC.java
trunk/test/java/org/apache/el/TesterEnum.java
trunk/test/java/org/apache/el/TesterFunctions.java
trunk/test/java/org/apache/el/lang/
trunk/test/java/org/apache/el/lang/TestELArithmetic.java
trunk/test/java/org/apache/el/lang/TestELSupport.java
trunk/test/java/org/apache/el/parser/
trunk/test/java/org/apache/el/parser/TestELParser.java
trunk/test/java/org/apache/el/parser/TesterBeanA.java
Removed:
trunk/test/java/org/apache/catalina/startup/TestTomcatSSL.java
trunk/test/java/org/apache/catalina/startup/TomcatBaseTest.java
trunk/test/java/org/apache/catalina/startup/test.keystore
Modified:
trunk/test/build.properties.default
trunk/test/build.xml
trunk/webapps/docs/changelog.xml
Log:
Add EL tests from Tomcat, which cover things well. Two failures due to the BeanELResolver
which
could use more tweaks.
Modified: trunk/test/build.properties.default
===================================================================
--- trunk/test/build.properties.default 2011-12-06 15:27:15 UTC (rev 1882)
+++ trunk/test/build.properties.default 2011-12-06 15:29:27 UTC (rev 1883)
@@ -1,5 +1,5 @@
# junit stuff
-junit.version=4.5
+junit.version=4.10
junit.jar.loc=http://kent.dl.sourceforge.net/sourceforge/junit/junit-${ju...
junit.jar=${base.path}/junit-${junit.version}/junit-${junit.version}.jar
base-junit.home=${base.path}/junit-${junit.version}
Modified: trunk/test/build.xml
===================================================================
--- trunk/test/build.xml 2011-12-06 15:27:15 UTC (rev 1882)
+++ trunk/test/build.xml 2011-12-06 15:29:27 UTC (rev 1883)
@@ -77,11 +77,42 @@
<!-- Run the tests -->
<target name="all" depends="compile">
+ <!--
<java dir="${test.classes}" classname="${test.runner}"
fork="yes">
<arg value="org.jboss.web.cookies.CookiesTestCase"/>
<jvmarg line="-Dcluster=${cluster}"/>
<classpath refid="jbossweb.test.classpath"/>
- </java>
+ </java>-->
+ <mkdir dir="${basedir}/output/logs" />
+ <junit printsummary="yes" fork="yes" dir="."
showoutput="yes"
+ errorproperty="test.result.error"
+ failureproperty="test.result.failure"
+ haltonfailure="false" >
+
+ <classpath refid="jbossweb.test.classpath" />
+
+ <formatter type="plain"/>
+
+ <!-- If test.entry is defined, run a single test, otherwise run all valid tests
-->
+ <test todir="${basedir}/output/logs" />
+ <batchtest todir="${basedir}/output/logs">
+ <fileset dir="java" >
+ <!-- Include all by default -->
+ <include name="**/Test*.java" />
+ <!-- Exclude helper classes -->
+ <exclude name="**/Tester*.java" />
+ </fileset>
+ </batchtest>
+ </junit>
+
+ <java dir="${test.classes}" classname="${test.runner}"
fork="yes">
+ <arg value="org.apache.el.TestValueExpressionImpl"/>
+ <classpath refid="jbossweb.test.classpath"/>
+ </java>
+ <java dir="${test.classes}" classname="${test.runner}"
fork="yes">
+ <arg value="org.apache.el.TestMethodExpressionImpl"/>
+ <classpath refid="jbossweb.test.classpath"/>
+ </java>
</target>
<target name="ssl" depends="compile">
Deleted: trunk/test/java/org/apache/catalina/startup/TestTomcatSSL.java
===================================================================
--- trunk/test/java/org/apache/catalina/startup/TestTomcatSSL.java 2011-12-06 15:27:15 UTC
(rev 1882)
+++ trunk/test/java/org/apache/catalina/startup/TestTomcatSSL.java 2011-12-06 15:29:27 UTC
(rev 1883)
@@ -1,251 +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.catalina.startup;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.HandshakeCompletedEvent;
-import javax.net.ssl.HandshakeCompletedListener;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.apache.catalina.connector.Connector;
-import org.apache.tomcat.util.buf.ByteChunk;
-
-/**
- * Requires test.keystore (checked in), generated with:
- * keytool -genkey -alias tomcat -keyalg RSA
- * pass: changeit
- * CN: localhost ( for hostname validation )
- */
-public class TestTomcatSSL extends TomcatBaseTest {
- static TrustManager[] trustAllCerts = new TrustManager[] {
- new X509TrustManager() {
- public X509Certificate[] getAcceptedIssuers() {
- return null;
- }
- public void checkClientTrusted(X509Certificate[] certs,
- String authType) {
- // NOOP - Trust everything
- }
- public void checkServerTrusted(X509Certificate[] certs,
- String authType) {
- // NOOP - Trust everything
- }
- }
- };
-
- private void initSsl(Tomcat tomcat, boolean nio) throws Exception {
- if (nio) {
- Connector connector =
- new Connector("org.apache.coyote.http11.Http11NioProtocol");
- connector.setPort(getPort());
- tomcat.getService().addConnector(connector);
- tomcat.setConnector(connector);
- tomcat.getConnector().setSecure(true);
- } else {
- tomcat.getConnector().setSecure(true);
- }
- tomcat.getConnector().setProperty("SSLEnabled", "true");
- tomcat.getConnector().setProperty("sslProtocol",
- "tls");
- // test runs in output/tmp
- tomcat.getConnector().setAttribute("keystore",
- "../test.keystore");
- }
-
- public void testSimpleSsl() throws Exception {
- simpleSsl(false);
- }
-
- // No Nio in jbossweb
- // public void testSimpleSslNio() throws Exception {
- // simpleSsl(true);
- // }
-
- public void simpleSsl(boolean nio) throws Exception {
- // Install the all-trusting trust manager so https:// works
- // with unsigned certs.
-
- try {
- SSLContext sc = SSLContext.getInstance("SSL");
- sc.init(null, trustAllCerts, new java.security.SecureRandom());
- javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(
- sc.getSocketFactory());
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- Tomcat tomcat = getTomcatInstance();
-
- File appDir =
- new File("output/build/webapps/examples");
- tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
-
- initSsl(tomcat, nio);
-
- tomcat.start();
- ByteChunk res = getUrl("https://localhost:" + getPort() +
- "/examples/");
- assertTrue(res.toString().indexOf("Hello World!") > 0);
- }
-
- boolean handshakeDone = false;
-
- public void testRenegotiateFail() throws Exception {
- renegotiateFail(false);
- }
-
- public void renegotiateFail(boolean nio) throws Exception {
- Tomcat tomcat = getTomcatInstance();
-
- File appDir =
- new File("output/build/webapps/examples");
- // app dir is relative to server home
- tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
-
- initSsl(tomcat, nio);
- // Default - MITM not enabled
-
- tomcat.start();
- SSLContext sslCtx = SSLContext.getInstance("TLS");
- sslCtx.init(null, trustAllCerts, new java.security.SecureRandom());
- SSLSocketFactory socketFactory = sslCtx.getSocketFactory();
- SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost",
getPort());
-
- socket.addHandshakeCompletedListener(new HandshakeCompletedListener() {
- @Override
- public void handshakeCompleted(HandshakeCompletedEvent event) {
- handshakeDone = true;
- }
- });
-
- OutputStream os = socket.getOutputStream();
- os.write("GET /examples/ HTTP/1.1\n".getBytes());
- os.flush();
-
- InputStream is = socket.getInputStream();
-
- socket.startHandshake();
- handshakeDone = false;
- byte[] b = new byte[0];
- int maxTries = 5; // 5 sec should be enough - in NIO we'll timeout
- socket.setSoTimeout(1000);
- for (int i = 0; i < maxTries; i++) {
- try {
- is.read(b);
- } catch (IOException e) {
- // timeout
- }
- if (handshakeDone) {
- break;
- }
- }
- os = socket.getOutputStream();
- if (!handshakeDone) {
- // success - we timedout without handshake
- return;
- }
- try {
- os.write("Host: localhost\n\n".getBytes());
- } catch (IOException ex) {
- // success - connection closed
- return;
- }
-
- fail("Re-negotiation worked");
-
- }
-
- public void testRenegotiateWorks() throws Exception {
- renegotiateWorks(false);
- }
-
-
- // Re-negotiation not implemented in NIO
- // public void testRenegotiateWorksNio() throws Exception {
- // renegotiateWorks(true);
- // }
-
- // public void testRenegotiateFailNio() throws Exception {
- // renegotiateFail(true);
- // }
-
-
- public void renegotiateWorks(boolean nio) throws Exception {
- Tomcat tomcat = getTomcatInstance();
-
- File appDir =
- new File("output/build/webapps/examples");
- // app dir is relative to server home
- tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
-
- initSsl(tomcat, nio);
- // Enable MITM attack
- tomcat.getConnector().setAttribute("allowUnsafeLegacyRenegotiation",
"true");
-
- tomcat.start();
- SSLContext sslCtx = SSLContext.getInstance("TLS");
- sslCtx.init(null, trustAllCerts, new java.security.SecureRandom());
- SSLSocketFactory socketFactory = sslCtx.getSocketFactory();
- SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost",
getPort());
-
- socket.addHandshakeCompletedListener(new HandshakeCompletedListener() {
- @Override
- public void handshakeCompleted(HandshakeCompletedEvent event) {
- handshakeDone = true;
- }
- });
-
- OutputStream os = socket.getOutputStream();
- os.write("GET /examples/ HTTP/1.1\n".getBytes());
- os.flush();
-
- InputStream is = socket.getInputStream();
-
- socket.startHandshake();
- handshakeDone = false;
- byte[] b = new byte[0];
- int maxTries = 5;
- socket.setSoTimeout(1000);
- for (int i = 0; i < maxTries; i++) {
- try {
- is.read(b);
- } catch (IOException e) {
- // timeout
- }
- if (handshakeDone) {
- break;
- }
- }
- os = socket.getOutputStream();
-
- try {
- os.write("Host: localhost\n\n".getBytes());
- } catch (IOException ex) {
- fail("Re-negotiation failed");
- }
-
- }
-}
Deleted: trunk/test/java/org/apache/catalina/startup/TomcatBaseTest.java
===================================================================
--- trunk/test/java/org/apache/catalina/startup/TomcatBaseTest.java 2011-12-06 15:27:15
UTC (rev 1882)
+++ trunk/test/java/org/apache/catalina/startup/TomcatBaseTest.java 2011-12-06 15:29:27
UTC (rev 1883)
@@ -1,137 +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.catalina.startup;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.tomcat.util.buf.ByteChunk;
-
-import junit.framework.TestCase;
-
-/**
- * Base test case that provides a Tomcat instance for each test - mainly so we
- * don't have to keep writing the cleanup code.
- */
-public abstract class TomcatBaseTest extends TestCase {
- private Tomcat tomcat;
- private File tempDir;
- private static int port = 8001;
-
- /**
- * Make Tomcat instance accessible to sub-classes.
- */
- public Tomcat getTomcatInstance() {
- return tomcat;
- }
-
- /**
- * Sub-classes need to know port so they can connect
- */
- public int getPort() {
- return port;
- }
-
- /**
- * Sub-classes may want to add connectors on a new port
- */
- public int getNextPort() {
- port++;
- return getPort();
- }
-
- @Override
- public void setUp() throws Exception {
- tempDir = new File("output/tmp");
- tempDir.mkdir();
-
- tomcat = new Tomcat();
- tomcat.setBaseDir(tempDir.getAbsolutePath());
- tomcat.getHost().setAppBase(tempDir.getAbsolutePath() + "/webapps");
-
- // If each test is running on same port - they
- // may interfere with each other (on unix at least)
- port++;
- tomcat.setPort(port);
- }
-
- @Override
- public void tearDown() throws Exception {
- tomcat.stop();
- ExpandWar.delete(tempDir);
- }
-
- /**
- * Simple Hello World servlet for use by test cases
- */
- public static final class HelloWorldServlet extends HttpServlet {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- PrintWriter out = resp.getWriter();
- out.print("<html><body><p>Hello
World</p></body></html>");
- }
- }
-
-
- /**
- * Wrapper for getting the response.
- */
- public static ByteChunk getUrl(String path) throws IOException {
- ByteChunk out = new ByteChunk();
- getUrl(path, out, null);
- return out;
- }
-
- public static int getUrl(String path,
- ByteChunk out,
- Map<String, List<String>> resHead) throws
IOException {
- URL url = new URL(path);
- HttpURLConnection connection =
- (HttpURLConnection) url.openConnection();
- connection.setReadTimeout(100000);
- connection.connect();
- int rc = connection.getResponseCode();
- if (resHead != null) {
- Map<String, List<String>> head = connection.getHeaderFields();
- resHead.putAll(head);
- }
- InputStream is = connection.getInputStream();
- BufferedInputStream bis = new BufferedInputStream(is);
- byte[] buf = new byte[2048];
- int rd = 0;
- while((rd = bis.read(buf)) > 0) {
- out.append(buf, 0, rd);
- }
- return rc;
- }
-}
Deleted: trunk/test/java/org/apache/catalina/startup/test.keystore
===================================================================
(Binary files differ)
Added: trunk/test/java/org/apache/el/TestELEvaluation.java
===================================================================
--- trunk/test/java/org/apache/el/TestELEvaluation.java (rev 0)
+++ trunk/test/java/org/apache/el/TestELEvaluation.java 2011-12-06 15:29:27 UTC (rev
1883)
@@ -0,0 +1,228 @@
+/*
+ * 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 java.io.File;
+import java.lang.reflect.Method;
+import java.util.Date;
+
+import javax.el.ELException;
+import javax.el.FunctionMapper;
+import javax.el.ValueExpression;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
+import org.apache.el.lang.ELSupport;
+import org.apache.jasper.el.ELContextImpl;
+
+/**
+ * Tests the EL engine directly. Similar tests may be found in
+ * {@link org.apache.jasper.compiler.TestAttributeParser} and
+ * {@link TestELInJsp}.
+ */
+public class TestELEvaluation {
+
+ /**
+ * Test use of spaces in ternary expressions. This was primarily an EL
+ * parser bug.
+ */
+ @Test
+ public void testBug42565() {
+ assertEquals("false",
evaluateExpression("${false?true:false}"));
+ assertEquals("false", evaluateExpression("${false?true:
false}"));
+ assertEquals("false", evaluateExpression("${false?true
:false}"));
+ assertEquals("false", evaluateExpression("${false?true :
false}"));
+ assertEquals("false", evaluateExpression("${false?
true:false}"));
+ assertEquals("false", evaluateExpression("${false? true:
false}"));
+ assertEquals("false", evaluateExpression("${false? true
:false}"));
+ assertEquals("false", evaluateExpression("${false? true :
false}"));
+ assertEquals("false", evaluateExpression("${false
?true:false}"));
+ assertEquals("false", evaluateExpression("${false ?true:
false}"));
+ assertEquals("false", evaluateExpression("${false ?true
:false}"));
+ assertEquals("false", evaluateExpression("${false ?true :
false}"));
+ assertEquals("false", evaluateExpression("${false ?
true:false}"));
+ assertEquals("false", evaluateExpression("${false ? true:
false}"));
+ assertEquals("false", evaluateExpression("${false ? true
:false}"));
+ assertEquals("false", evaluateExpression("${false ? true :
false}"));
+ }
+
+
+ /**
+ * Test use nested ternary expressions. This was primarily an EL parser bug.
+ */
+ @Test
+ public void testBug44994() {
+ assertEquals("none", evaluateExpression(
+ "${0 lt 0 ? 1 lt 0 ? 'many': 'one':
'none'}"));
+ assertEquals("one", evaluateExpression(
+ "${0 lt 1 ? 1 lt 1 ? 'many': 'one':
'none'}"));
+ assertEquals("many", evaluateExpression(
+ "${0 lt 2 ? 1 lt 2 ? 'many': 'one':
'none'}"));
+ }
+
+ @Test
+ 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)}"));
+ }
+
+ @Test
+ public void testBug48112() {
+ // bug 48112
+ assertEquals("{world}",
evaluateExpression("${fn:trim('{world}')}"));
+ }
+
+ @Test
+ public void testParserLiteralExpression() {
+ // Inspired by work on bug 45451, comments from kkolinko on the dev
+ // list and looking at the spec to find some edge cases
+
+ // '\' is only an escape character inside a StringLiteral
+ assertEquals("\\\\", evaluateExpression("\\\\"));
+
+ /*
+ * LiteralExpresions can only contain ${ or #{ if escaped with \
+ * \ is not an escape character in any other circumstances including \\
+ */
+ assertEquals("\\", evaluateExpression("\\"));
+ assertEquals("$", evaluateExpression("$"));
+ assertEquals("#", evaluateExpression("#"));
+ assertEquals("\\$", evaluateExpression("\\$"));
+ assertEquals("\\#", evaluateExpression("\\#"));
+ assertEquals("\\\\$", evaluateExpression("\\\\$"));
+ assertEquals("\\\\#", evaluateExpression("\\\\#"));
+ assertEquals("${", evaluateExpression("\\${"));
+ assertEquals("#{", evaluateExpression("\\#{"));
+ assertEquals("\\${", evaluateExpression("\\\\${"));
+ assertEquals("\\#{", evaluateExpression("\\\\#{"));
+ }
+
+ @Test
+ public void testParserStringLiteral() {
+ // Inspired by work on bug 45451, comments from kkolinko on the dev
+ // list and looking at the spec to find some edge cases
+
+ // The only characters that can be escaped inside a String literal
+ // are \ " and '. # and $ are not escaped inside a String literal.
+ assertEquals("\\", evaluateExpression("${'\\\\'}"));
+ assertEquals("\\",
evaluateExpression("${\"\\\\\"}"));
+ assertEquals("\\\"'$#",
evaluateExpression("${'\\\\\\\"\\'$#'}"));
+ assertEquals("\\\"'$#",
evaluateExpression("${\"\\\\\\\"\\'$#\"}"));
+
+ // Trying to quote # or $ should throw an error
+ Exception e = null;
+ try {
+ evaluateExpression("${'\\$'}");
+ } catch (ELException el) {
+ e = el;
+ }
+ assertNotNull(e);
+
+ assertEquals("\\$",
evaluateExpression("${'\\\\$'}"));
+ assertEquals("\\\\$",
evaluateExpression("${'\\\\\\\\$'}"));
+
+
+ // Can use ''' inside '"' when quoting with
'"' and vice versa without
+ // escaping
+ assertEquals("\\\"",
evaluateExpression("${'\\\\\"'}"));
+ assertEquals("\"\\",
evaluateExpression("${'\"\\\\'}"));
+ assertEquals("\\'",
evaluateExpression("${'\\\\\\''}"));
+ assertEquals("'\\",
evaluateExpression("${'\\'\\\\'}"));
+ assertEquals("\\'",
evaluateExpression("${\"\\\\'\"}"));
+ assertEquals("'\\",
evaluateExpression("${\"'\\\\\"}"));
+ assertEquals("\\\"",
evaluateExpression("${\"\\\\\\\"\"}"));
+ assertEquals("\"\\",
evaluateExpression("${\"\\\"\\\\\"}"));
+ }
+
+ private void compareBoth(String msg, int expected, Object o1, Object o2){
+ int i1 = ELSupport.compare(o1, o2);
+ int i2 = ELSupport.compare(o2, o1);
+ assertEquals(msg,expected, i1);
+ assertEquals(msg,expected, -i2);
+ }
+
+ @Test
+ public void testElSupportCompare(){
+ compareBoth("Nulls should compare equal", 0, null, null);
+ compareBoth("Null should compare equal to \"\"", 0,
"", null);
+ compareBoth("Null should be less than File()",-1, null, new
File(""));
+ compareBoth("Null should be less than Date()",-1, null, new Date());
+ compareBoth("Date(0) should be less than Date(1)",-1, new Date(0), new
Date(1));
+ try {
+ compareBoth("Should not compare",0, new Date(), new
File(""));
+ fail("Expecting ClassCastException");
+ } catch (ClassCastException expected) {
+ // Expected
+ }
+ assertTrue(null == null);
+ }
+
+ /**
+ * Test mixing ${...} and #{...} in the same expression.
+ */
+ @Test
+ public void testMixedTypes() {
+ // Mixing types should throw an error
+ Exception e = null;
+ try {
+ evaluateExpression("${1+1}#{1+1}");
+ } catch (ELException el) {
+ e = el;
+ }
+ assertNotNull(e);
+ }
+
+
+ // ************************************************************************
+
+ private String evaluateExpression(String expression) {
+ ELContextImpl ctx = new ELContextImpl();
+ ctx.setFunctionMapper(new FMapper());
+ ExpressionFactoryImpl exprFactory = new ExpressionFactoryImpl();
+ ValueExpression ve = exprFactory.createValueExpression(ctx, expression,
+ String.class);
+ return (String) ve.getValue(ctx);
+ }
+
+ public static class FMapper extends FunctionMapper {
+
+ @Override
+ public Method resolveFunction(String prefix, String localName) {
+ if ("trim".equals(localName)) {
+ Method m;
+ try {
+ m = TesterFunctions.class.getMethod("trim", String.class);
+ return m;
+ } catch (SecurityException e) {
+ // Ignore
+ } catch (NoSuchMethodException e) {
+ // Ignore
+ }
+ }
+ return null;
+ }
+ }
+}
Added: trunk/test/java/org/apache/el/TestMethodExpressionImpl.java
===================================================================
--- trunk/test/java/org/apache/el/TestMethodExpressionImpl.java
(rev 0)
+++ trunk/test/java/org/apache/el/TestMethodExpressionImpl.java 2011-12-06 15:29:27 UTC
(rev 1883)
@@ -0,0 +1,402 @@
+/*
+ * 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.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.jasper.el.ELContextImpl;
+
+public class TestMethodExpressionImpl {
+
+ private ExpressionFactory factory;
+ private ELContext context;
+
+ @Before
+ public void setUp() {
+ factory = ExpressionFactory.newInstance();
+ context = new ELContextImpl();
+
+ TesterBeanA beanA = new TesterBeanA();
+ beanA.setName("A");
+ context.getVariableMapper().setVariable("beanA",
+ factory.createValueExpression(beanA, TesterBeanA.class));
+
+ TesterBeanAA beanAA = new TesterBeanAA();
+ beanAA.setName("AA");
+ context.getVariableMapper().setVariable("beanAA",
+ factory.createValueExpression(beanAA, TesterBeanAA.class));
+
+ TesterBeanAAA beanAAA = new TesterBeanAAA();
+ beanAAA.setName("AAA");
+ context.getVariableMapper().setVariable("beanAAA",
+ factory.createValueExpression(beanAAA, TesterBeanAAA.class));
+
+ TesterBeanB beanB = new TesterBeanB();
+ beanB.setName("B");
+ context.getVariableMapper().setVariable("beanB",
+ factory.createValueExpression(beanB, TesterBeanB.class));
+
+ TesterBeanBB beanBB = new TesterBeanBB();
+ beanBB.setName("BB");
+ context.getVariableMapper().setVariable("beanBB",
+ factory.createValueExpression(beanBB, TesterBeanBB.class));
+
+ TesterBeanBBB beanBBB = new TesterBeanBBB();
+ beanBBB.setName("BBB");
+ context.getVariableMapper().setVariable("beanBBB",
+ factory.createValueExpression(beanBBB, TesterBeanBBB.class));
+
+ TesterBeanC beanC = new TesterBeanC();
+ context.getVariableMapper().setVariable("beanC",
+ factory.createValueExpression(beanC, TesterBeanC.class));
+ }
+
+ @Test
+ public void testIsParametersProvided() {
+ TesterBeanB beanB = new TesterBeanB();
+ beanB.setName("Tomcat");
+ ValueExpression var =
+ factory.createValueExpression(beanB, TesterBeanB.class);
+ context.getVariableMapper().setVariable("beanB", var);
+
+ MethodExpression me1 = factory.createMethodExpression(
+ context, "${beanB.getName}", String.class, new Class<?>[]
{});
+ MethodExpression me2 = factory.createMethodExpression(
+ context, "${beanB.sayHello('JUnit')}", String.class,
+ new Class<?>[] { String.class });
+
+ assertFalse(me1.isParmetersProvided());
+ assertTrue(me2.isParmetersProvided());
+ }
+
+ @Test
+ public void testInvoke() {
+ TesterBeanB beanB = new TesterBeanB();
+ beanB.setName("B");
+
+ context.getVariableMapper().setVariable("beanB",
+ factory.createValueExpression(beanB, TesterBeanB.class));
+
+ MethodExpression me1 = factory.createMethodExpression(
+ context, "${beanB.getName()}", String.class, new
Class<?>[] {});
+ MethodExpression me2 = factory.createMethodExpression(
+ context, "${beanB.sayHello('JUnit')}", String.class,
+ new Class<?>[] { String.class });
+ MethodExpression me3 = factory.createMethodExpression(
+ context, "${beanB.sayHello}", String.class,
+ new Class<?>[] { String.class });
+
+ assertEquals("B", me1.invoke(context, null));
+ assertEquals("Hello JUnit from B", me2.invoke(context, null));
+ assertEquals("Hello JUnit from B",
+ me2.invoke(context, new Object[] { "JUnit2" }));
+ assertEquals("Hello JUnit2 from B",
+ me3.invoke(context, new Object[] { "JUnit2" }));
+ assertEquals("Hello JUnit from B",
+ me2.invoke(context, new Object[] { null }));
+ assertEquals("Hello null from B",
+ me3.invoke(context, new Object[] { null }));
+ }
+
+ @Test
+ public void testInvokeWithSuper() {
+ MethodExpression me = factory.createMethodExpression(context,
+ "${beanA.setBean(beanBB)}", null ,
+ new Class<?>[] { TesterBeanB.class });
+ me.invoke(context, null);
+ ValueExpression ve = factory.createValueExpression(context,
+ "${beanA.bean.name}", String.class);
+ Object r = ve.getValue(context);
+ assertEquals("BB", r);
+ }
+
+ @Test
+ public void testInvokeWithSuperABNoReturnTypeNoParamTypes() {
+ MethodExpression me2 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanA,beanB)}", null , null);
+ Object r2 = me2.invoke(context, null);
+ assertEquals("AB: Hello A from B", r2.toString());
+ }
+
+ @Test
+ public void testInvokeWithSuperABReturnTypeNoParamTypes() {
+ MethodExpression me3 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanA,beanB)}", String.class , null);
+ Object r3 = me3.invoke(context, null);
+ assertEquals("AB: Hello A from B", r3.toString());
+ }
+
+ @Test
+ public void testInvokeWithSuperABNoReturnTypeParamTypes() {
+ MethodExpression me4 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanA,beanB)}", null ,
+ new Class<?>[] {TesterBeanA.class, TesterBeanB.class});
+ Object r4 = me4.invoke(context, null);
+ assertEquals("AB: Hello A from B", r4.toString());
+ }
+
+ @Test
+ public void testInvokeWithSuperABReturnTypeParamTypes() {
+ MethodExpression me5 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanA,beanB)}", String.class ,
+ new Class<?>[] {TesterBeanA.class, TesterBeanB.class});
+ Object r5 = me5.invoke(context, null);
+ assertEquals("AB: Hello A from B", r5.toString());
+ }
+
+ @Test
+ public void testInvokeWithSuperABB() {
+ MethodExpression me6 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanA,beanBB)}", null , null);
+ Object r6 = me6.invoke(context, null);
+ assertEquals("ABB: Hello A from BB", r6.toString());
+ }
+
+ @Test
+ public void testInvokeWithSuperABBB() {
+ MethodExpression me7 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanA,beanBBB)}", null , null);
+ Object r7 = me7.invoke(context, null);
+ assertEquals("ABB: Hello A from BBB", r7.toString());
+ }
+
+ @Test
+ public void testInvokeWithSuperAAB() {
+ MethodExpression me8 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAA,beanB)}", null , null);
+ Object r8 = me8.invoke(context, null);
+ assertEquals("AAB: Hello AA from B", r8.toString());
+ }
+
+ @Test
+ public void testInvokeWithSuperAABB() {
+ MethodExpression me9 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAA,beanBB)}", null , null);
+ Exception e = null;
+ try {
+ me9.invoke(context, null);
+ } catch (Exception e1) {
+ e = e1;
+ }
+ // Expected to fail
+ assertNotNull(e);
+ }
+
+ @Test
+ public void testInvokeWithSuperAABBB() {
+ // The Java compiler reports this as ambiguous. Using the parameter that
+ // matches exactly seems reasonable to limit the scope of the method
+ // search so the EL will find a match.
+ MethodExpression me10 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAA,beanBBB)}", null , null);
+ Object r10 = me10.invoke(context, null);
+ assertEquals("AAB: Hello AA from BBB", r10.toString());
+ }
+
+ @Test
+ public void testInvokeWithSuperAAAB() {
+ MethodExpression me11 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAAA,beanB)}", null , null);
+ Object r11 = me11.invoke(context, null);
+ assertEquals("AAB: Hello AAA from B", r11.toString());
+ }
+
+ @Test
+ public void testInvokeWithSuperAAABB() {
+ // The Java compiler reports this as ambiguous. Using the parameter that
+ // matches exactly seems reasonable to limit the scope of the method
+ // search so the EL will find a match.
+ MethodExpression me12 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAAA,beanBB)}", null , null);
+ Object r12 = me12.invoke(context, null);
+ assertEquals("ABB: Hello AAA from BB", r12.toString());
+ }
+
+ @Test
+ public void testInvokeWithSuperAAABBB() {
+ MethodExpression me13 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAAA,beanBBB)}", null , null);
+ Exception e = null;
+ try {
+ me13.invoke(context, null);
+ } catch (Exception e1) {
+ e = e1;
+ }
+ // Expected to fail
+ assertNotNull(e);
+ }
+
+ @Test
+ public void testInvokeWithVarArgsAB() throws Exception {
+ MethodExpression me1 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanA,beanB,beanB)}", null , null);
+ Exception e = null;
+ try {
+ me1.invoke(context, null);
+ } catch (Exception e1) {
+ e = e1;
+ }
+ // Expected to fail
+ assertNotNull(e);
+ }
+
+ @Test
+ public void testInvokeWithVarArgsABB() throws Exception {
+ MethodExpression me2 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanA,beanBB,beanBB)}", null , null);
+ Object r2 = me2.invoke(context, null);
+ assertEquals("ABB[]: Hello A from BB, BB", r2.toString());
+ }
+
+ @Test
+ public void testInvokeWithVarArgsABBB() throws Exception {
+ MethodExpression me3 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanA,beanBBB,beanBBB)}", null , null);
+ Object r3 = me3.invoke(context, null);
+ assertEquals("ABB[]: Hello A from BBB, BBB", r3.toString());
+ }
+
+ @Test
+ public void testInvokeWithVarArgsAAB() throws Exception {
+ MethodExpression me4 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAA,beanB,beanB)}", null , null);
+ Exception e = null;
+ try {
+ me4.invoke(context, null);
+ } catch (Exception e1) {
+ e = e1;
+ }
+ // Expected to fail
+ assertNotNull(e);
+ }
+
+ @Test
+ public void testInvokeWithVarArgsAABB() throws Exception {
+ MethodExpression me5 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAA,beanBB,beanBB)}", null , null);
+ Object r5 = me5.invoke(context, null);
+ assertEquals("ABB[]: Hello AA from BB, BB", r5.toString());
+ }
+
+ @Test
+ public void testInvokeWithVarArgsAABBB() throws Exception {
+ MethodExpression me6 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAA,beanBBB,beanBBB)}", null , null);
+ Object r6 = me6.invoke(context, null);
+ assertEquals("ABB[]: Hello AA from BBB, BBB", r6.toString());
+ }
+
+ @Test
+ public void testInvokeWithVarArgsAAAB() throws Exception {
+ MethodExpression me7 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAAA,beanB,beanB)}", null , null);
+ Exception e = null;
+ try {
+ me7.invoke(context, null);
+ } catch (Exception e1) {
+ e = e1;
+ }
+ // Expected to fail
+ assertNotNull(e);
+ }
+
+ @Test
+ public void testInvokeWithVarArgsAAABB() throws Exception {
+ MethodExpression me8 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAAA,beanBB,beanBB)}", null , null);
+ Object r8 = me8.invoke(context, null);
+ assertEquals("ABB[]: Hello AAA from BB, BB", r8.toString());
+ }
+
+ @Test
+ public void testInvokeWithVarArgsAAABBB() throws Exception {
+ MethodExpression me9 = factory.createMethodExpression(context,
+ "${beanC.sayHello(beanAAA,beanBBB,beanBBB)}", null , null);
+ Object r9 = me9.invoke(context, null);
+ assertEquals("ABB[]: Hello AAA from BBB, BBB", r9.toString());
+ }
+
+ /*
+ * This is also tested implicitly in numerous places elsewhere in this
+ * class.
+ */
+ @Test
+ public void testBug49655() throws Exception {
+ // This is the call the failed
+ MethodExpression me = factory.createMethodExpression(context,
+ "#{beanA.setName('New value')}", null, null);
+ // The rest is to check it worked correctly
+ me.invoke(context, null);
+ ValueExpression ve = factory.createValueExpression(context,
+ "#{beanA.name}", java.lang.String.class);
+ assertEquals("New value", ve.getValue(context));
+ }
+
+ @Test
+ public void testBugPrimitives() throws Exception {
+ MethodExpression me = factory.createMethodExpression(context,
+ "${beanA.setValLong(5)}", null, null);
+ me.invoke(context, null);
+ ValueExpression ve = factory.createValueExpression(context,
+ "#{beanA.valLong}", java.lang.String.class);
+ assertEquals("5", ve.getValue(context));
+ }
+
+ @Test
+ public void testBug50449a() throws Exception {
+ MethodExpression me1 = factory.createMethodExpression(context,
+ "${beanB.sayHello()}", null, null);
+ String actual = (String) me1.invoke(context, null);
+ assertEquals("Hello from B", actual);
+ }
+
+ @Test
+ public void testBug50449b() throws Exception {
+ MethodExpression me1 = factory.createMethodExpression(context,
+ "${beanB.sayHello('Tomcat')}", null, null);
+ String actual = (String) me1.invoke(context, null);
+ assertEquals("Hello Tomcat from B", actual);
+ }
+
+ @Test
+ public void testBug50790a() throws Exception {
+ ValueExpression ve = factory.createValueExpression(context,
+ "#{beanAA.name.contains(beanA.name)}",
java.lang.Boolean.class);
+ Boolean actual = (Boolean) ve.getValue(context);
+ assertEquals(Boolean.TRUE, actual);
+ }
+
+ @Test
+ public void testBug50790b() throws Exception {
+ ValueExpression ve = factory.createValueExpression(context,
+ "#{beanA.name.contains(beanAA.name)}",
java.lang.Boolean.class);
+ Boolean actual = (Boolean) ve.getValue(context);
+ assertEquals(Boolean.FALSE, actual);
+ }
+}
Added: trunk/test/java/org/apache/el/TestValueExpressionImpl.java
===================================================================
--- trunk/test/java/org/apache/el/TestValueExpressionImpl.java
(rev 0)
+++ trunk/test/java/org/apache/el/TestValueExpressionImpl.java 2011-12-06 15:29:27 UTC
(rev 1883)
@@ -0,0 +1,216 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.el.ValueReference;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+import org.apache.jasper.el.ELContextImpl;
+
+public class TestValueExpressionImpl {
+
+ @Test
+ public void testGetValueReference() {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ TesterBeanB beanB = new TesterBeanB();
+ beanB.setName("Tomcat");
+ ValueExpression var =
+ factory.createValueExpression(beanB, TesterBeanB.class);
+ context.getVariableMapper().setVariable("beanB", var);
+
+ ValueExpression ve = factory.createValueExpression(
+ context, "${beanB.name}", String.class);
+
+ // First check the basics work
+ String result = (String) ve.getValue(context);
+ assertEquals("Tomcat", result);
+
+ // Now check the value reference
+ ValueReference vr = ve.getValueReference(context);
+ assertNotNull(vr);
+
+ assertEquals(beanB, vr.getBase());
+ assertEquals("name", vr.getProperty());
+ }
+
+ @Test
+ public void testBug49345() {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ TesterBeanA beanA = new TesterBeanA();
+ TesterBeanB beanB = new TesterBeanB();
+ beanB.setName("Tomcat");
+ beanA.setBean(beanB);
+
+ ValueExpression var =
+ factory.createValueExpression(beanA, TesterBeanA.class);
+ context.getVariableMapper().setVariable("beanA", var);
+
+ ValueExpression ve = factory.createValueExpression(
+ context, "${beanA.bean.name}", String.class);
+
+ // First check the basics work
+ String result = (String) ve.getValue(context);
+ assertEquals("Tomcat", result);
+
+ // Now check the value reference
+ ValueReference vr = ve.getValueReference(context);
+ assertNotNull(vr);
+
+ assertEquals(beanB, vr.getBase());
+ assertEquals("name", vr.getProperty());
+ }
+
+ @Test
+ public void testBug50105() {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ TesterEnum testEnum = TesterEnum.APPLE;
+
+ ValueExpression var =
+ factory.createValueExpression(testEnum, TesterEnum.class);
+ context.getVariableMapper().setVariable("testEnum", var);
+
+ // When coercing an Enum to a String, name() should always be used.
+ ValueExpression ve1 = factory.createValueExpression(
+ context, "${testEnum}", String.class);
+ String result1 = (String) ve1.getValue(context);
+ assertEquals("APPLE", result1);
+
+ ValueExpression ve2 = factory.createValueExpression(
+ context, "foo${testEnum}bar", String.class);
+ String result2 = (String) ve2.getValue(context);
+ assertEquals("fooAPPLEbar", result2);
+ }
+
+ @Test
+ public void testBug51177ObjectMap() {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ Object o1 = "String value";
+ Object o2 = Integer.valueOf(32);
+
+ Map<Object,Object> map = new HashMap<Object,Object>();
+ map.put("key1", o1);
+ map.put("key2", o2);
+
+ ValueExpression var =
+ factory.createValueExpression(map, Map.class);
+ context.getVariableMapper().setVariable("map", var);
+
+ ValueExpression ve1 = factory.createValueExpression(
+ context, "${map.key1}", Object.class);
+ ve1.setValue(context, o2);
+ assertEquals(o2, ve1.getValue(context));
+
+ ValueExpression ve2 = factory.createValueExpression(
+ context, "${map.key2}", Object.class);
+ ve2.setValue(context, o1);
+ assertEquals(o1, ve2.getValue(context));
+ }
+
+ @Test
+ public void testBug51177ObjectList() {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ Object o1 = "String value";
+ Object o2 = Integer.valueOf(32);
+
+ List<Object> list = new ArrayList<Object>();
+ list.add(0, o1);
+ list.add(1, o2);
+
+ ValueExpression var =
+ factory.createValueExpression(list, List.class);
+ context.getVariableMapper().setVariable("list", var);
+
+ ValueExpression ve1 = factory.createValueExpression(
+ context, "${list[0]}", Object.class);
+ ve1.setValue(context, o2);
+ assertEquals(o2, ve1.getValue(context));
+
+ ValueExpression ve2 = factory.createValueExpression(
+ context, "${list[1]}", Object.class);
+ ve2.setValue(context, o1);
+ assertEquals(o1, ve2.getValue(context));
+ }
+
+
+ /**
+ * Test returning an empty list as a bean property.
+ */
+ @Test
+ public void testBug51544Bean() throws Exception {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ TesterBeanA beanA = new TesterBeanA();
+ beanA.setValList(Collections.emptyList());
+
+ ValueExpression var =
+ factory.createValueExpression(beanA, TesterBeanA.class);
+ context.getVariableMapper().setVariable("beanA", var);
+
+ ValueExpression ve = factory.createValueExpression(
+ context, "${beanA.valList.size()}", Integer.class);
+
+ Integer result = (Integer) ve.getValue(context);
+ assertEquals(Integer.valueOf(0), result);
+ }
+
+
+ /**
+ * Test using list directly as variable.
+ */
+ @Test
+ public void testBug51544Direct() throws Exception {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ List<?> list = Collections.emptyList();
+
+ ValueExpression var =
+ factory.createValueExpression(list, List.class);
+ context.getVariableMapper().setVariable("list", var);
+
+ ValueExpression ve = factory.createValueExpression(
+ context, "${list.size()}", Integer.class);
+
+ Integer result = (Integer) ve.getValue(context);
+ assertEquals(Integer.valueOf(0), result);
+ }
+}
Added: trunk/test/java/org/apache/el/TesterBeanA.java
===================================================================
--- trunk/test/java/org/apache/el/TesterBeanA.java (rev 0)
+++ trunk/test/java/org/apache/el/TesterBeanA.java 2011-12-06 15:29:27 UTC (rev 1883)
@@ -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 java.util.List;
+
+public class TesterBeanA {
+ private TesterBeanB bean;
+ private String name;
+ private long valLong;
+ private List<?> valList;
+
+ public TesterBeanB getBean() {
+ return bean;
+ }
+
+ public void setBean(TesterBeanB bean) {
+ this.bean = bean;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public long getValLong() {
+ return valLong;
+ }
+
+ public void setValLong(long valLong) {
+ this.valLong = valLong;
+ }
+
+ public List<?> getValList() {
+ return valList;
+ }
+
+ public void setValList(List<?> valList) {
+ this.valList = valList;
+ }
+}
Added: trunk/test/java/org/apache/el/TesterBeanAA.java
===================================================================
--- trunk/test/java/org/apache/el/TesterBeanAA.java (rev 0)
+++ trunk/test/java/org/apache/el/TesterBeanAA.java 2011-12-06 15:29:27 UTC (rev 1883)
@@ -0,0 +1,23 @@
+/*
+ * 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 TesterBeanAA extends TesterBeanA {
+ // No additional implementation - just need a class that extends A for
+ // testing EL methods calls
+}
Added: trunk/test/java/org/apache/el/TesterBeanAAA.java
===================================================================
--- trunk/test/java/org/apache/el/TesterBeanAAA.java (rev 0)
+++ trunk/test/java/org/apache/el/TesterBeanAAA.java 2011-12-06 15:29:27 UTC (rev 1883)
@@ -0,0 +1,23 @@
+/*
+ * 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 TesterBeanAAA extends TesterBeanAA {
+ // No additional implementation - just need a class that extends AA for
+ // testing EL methods calls
+}
Added: trunk/test/java/org/apache/el/TesterBeanB.java
===================================================================
--- trunk/test/java/org/apache/el/TesterBeanB.java (rev 0)
+++ trunk/test/java/org/apache/el/TesterBeanB.java 2011-12-06 15:29:27 UTC (rev 1883)
@@ -0,0 +1,38 @@
+/*
+ * 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() {
+ return "Hello from " + name;
+ }
+
+ public String sayHello(String to) {
+ return "Hello " + to + " from " + name;
+ }
+}
Added: trunk/test/java/org/apache/el/TesterBeanBB.java
===================================================================
--- trunk/test/java/org/apache/el/TesterBeanBB.java (rev 0)
+++ trunk/test/java/org/apache/el/TesterBeanBB.java 2011-12-06 15:29:27 UTC (rev 1883)
@@ -0,0 +1,31 @@
+/*
+ * 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 TesterBeanBB extends TesterBeanB {
+
+ private String extra;
+
+ public String getExtra() {
+ return extra;
+ }
+
+ public void setExtra(String extra) {
+ this.extra = extra;
+ }
+}
Added: trunk/test/java/org/apache/el/TesterBeanBBB.java
===================================================================
--- trunk/test/java/org/apache/el/TesterBeanBBB.java (rev 0)
+++ trunk/test/java/org/apache/el/TesterBeanBBB.java 2011-12-06 15:29:27 UTC (rev 1883)
@@ -0,0 +1,23 @@
+/*
+ * 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 TesterBeanBBB extends TesterBeanBB {
+ // No additional implementation - just need a class that extends BB for
+ // testing EL methods calls
+}
Added: trunk/test/java/org/apache/el/TesterBeanC.java
===================================================================
--- trunk/test/java/org/apache/el/TesterBeanC.java (rev 0)
+++ trunk/test/java/org/apache/el/TesterBeanC.java 2011-12-06 15:29:27 UTC (rev 1883)
@@ -0,0 +1,41 @@
+/*
+ * 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 TesterBeanC {
+ public String sayHello(TesterBeanA a, TesterBeanB b) {
+ return "AB: Hello " + a.getName() + " from " + b.getName();
+ }
+ public String sayHello(TesterBeanAA a, TesterBeanB b) {
+ return "AAB: Hello " + a.getName() + " from " + b.getName();
+ }
+ public String sayHello(TesterBeanA a, TesterBeanBB b) {
+ return "ABB: Hello " + a.getName() + " from " + b.getName();
+ }
+ public String sayHello(TesterBeanA a, TesterBeanBB... b) {
+ StringBuilder result =
+ new StringBuilder("ABB[]: Hello " + a.getName() + " from
");
+ for (int i = 0; i < b.length; i++) {
+ if (i > 0) {
+ result.append(", ");
+ }
+ result.append(b[i].getName());
+ }
+ return result.toString();
+ }
+}
Added: trunk/test/java/org/apache/el/TesterEnum.java
===================================================================
--- trunk/test/java/org/apache/el/TesterEnum.java (rev 0)
+++ trunk/test/java/org/apache/el/TesterEnum.java 2011-12-06 15:29:27 UTC (rev 1883)
@@ -0,0 +1,26 @@
+/*
+ * 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 enum TesterEnum {
+ APPLE, ORANGE;
+
+ @Override
+ public String toString() {
+ return "This is a " + this.name();
+ }
+}
Added: trunk/test/java/org/apache/el/TesterFunctions.java
===================================================================
--- trunk/test/java/org/apache/el/TesterFunctions.java (rev 0)
+++ trunk/test/java/org/apache/el/TesterFunctions.java 2011-12-06 15:29:27 UTC (rev 1883)
@@ -0,0 +1,32 @@
+/*
+ * 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 TesterFunctions {
+ public static String trim(String input) {
+ return input.trim();
+ }
+
+ public static class Inner$Class {
+
+ public static final String RETVAL = "Return from bug49555";
+ public static String bug49555() {
+ return RETVAL;
+ }
+ }
+}
Added: trunk/test/java/org/apache/el/lang/TestELArithmetic.java
===================================================================
--- trunk/test/java/org/apache/el/lang/TestELArithmetic.java (rev
0)
+++ trunk/test/java/org/apache/el/lang/TestELArithmetic.java 2011-12-06 15:29:27 UTC (rev
1883)
@@ -0,0 +1,98 @@
+/*
+ * 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.lang;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class TestELArithmetic {
+ private static final String a = "1.1";
+ private static final BigInteger b =
+ new BigInteger("1000000000000000000000");
+
+ @Test
+ public void testAdd() throws Exception {
+ assertEquals("1000000000000000000001.1",
+ String.valueOf(ELArithmetic.add(a, b)));
+ }
+
+ @Test
+ public void testSubtract() throws Exception {
+ assertEquals("-999999999999999999998.9",
+ String.valueOf(ELArithmetic.subtract(a, b)));
+ }
+
+ @Test
+ public void testMultiply() throws Exception {
+ assertEquals("1100000000000000000000.0",
+ String.valueOf(ELArithmetic.multiply(a, b)));
+ }
+
+ @Test
+ public void testDivide() throws Exception {
+ assertEquals("0.0",
+ String.valueOf(ELArithmetic.divide(a, b)));
+ }
+
+ @Test
+ public void testMod() throws Exception {
+ assertEquals("1.1",
+ String.valueOf(ELArithmetic.mod(a, b)));
+ }
+
+ @Test
+ public void testBug47371bigDecimal() throws Exception {
+ assertEquals(BigDecimal.valueOf(1),
+ ELArithmetic.add("", BigDecimal.valueOf(1)));
+ }
+
+ @Test
+ public void testBug47371double() throws Exception {
+ assertEquals(Double.valueOf(7), ELArithmetic.add("",
Double.valueOf(7)));
+ }
+
+ @Test
+ public void testBug47371doubleString() throws Exception {
+ assertEquals(Double.valueOf(2), ELArithmetic.add("", "2."));
+ }
+
+ @Test
+ public void testBug47371bigInteger() throws Exception {
+ assertEquals(BigInteger.valueOf(0),
+ ELArithmetic.multiply("", BigInteger.valueOf(1)));
+ }
+
+ @Test
+ public void testBug47371long() throws Exception {
+ assertEquals(Long.valueOf(1), ELArithmetic.add("",
Integer.valueOf(1)));
+ }
+
+ @Test
+ public void testBug47371long2() throws Exception {
+ assertEquals(Long.valueOf(-3), ELArithmetic.subtract("1",
"4"));
+ }
+
+ @Test
+ public void testBug47371doubleString2() throws Exception {
+ assertEquals(Double.valueOf(2), ELArithmetic.add("1.",
"1"));
+ }
+
+}
Added: trunk/test/java/org/apache/el/lang/TestELSupport.java
===================================================================
--- trunk/test/java/org/apache/el/lang/TestELSupport.java (rev 0)
+++ trunk/test/java/org/apache/el/lang/TestELSupport.java 2011-12-06 15:29:27 UTC (rev
1883)
@@ -0,0 +1,135 @@
+/*
+ * 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.lang;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import javax.el.ELException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+public class TestELSupport {
+ @Test
+ public void testBigDecimal() {
+ testIsSame(new BigDecimal(
+
"0.123456789012345678901234567890123456789012345678901234567890123456789"));
+ }
+
+ @Test
+ public void testBigInteger() {
+ testIsSame(new BigInteger(
+
"1234567890123456789012345678901234567890123456789012345678901234567890"));
+ }
+
+ @Test
+ public void testLong() {
+ testIsSame(Long.valueOf(0x0102030405060708L));
+ }
+
+ @Test
+ public void testInteger() {
+ testIsSame(Integer.valueOf(0x01020304));
+ }
+
+ @Test
+ public void testShort() {
+ testIsSame(Short.valueOf((short) 0x0102));
+ }
+
+ @Test
+ public void testByte() {
+ testIsSame(Byte.valueOf((byte) 0xEF));
+ }
+
+ @Test
+ public void testDouble() {
+ testIsSame(Double.valueOf(0.123456789012345678901234));
+ }
+
+ @Test
+ public void testFloat() {
+ testIsSame(Float.valueOf(0.123456F));
+ }
+
+ @Test
+ public void testCoerceIntegerToNumber() {
+ Integer input = Integer.valueOf(4390241);
+ Object output = ELSupport.coerceToType(input, Number.class);
+ assertEquals(input, output);
+ }
+
+ @Test
+ public void testCoerceNullToNumber() {
+ Object output = ELSupport.coerceToType(null, Number.class);
+ assertEquals(Long.valueOf(0), output);
+ }
+
+ @Test
+ public void testCoerceEnumAToEnumA() {
+ Object output = null;
+ try {
+ output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumA.class);
+ } finally {
+ assertEquals(TestEnumA.VALA1, output);
+ }
+ }
+
+ @Test
+ public void testCoerceEnumAToEnumB() {
+ Object output = null;
+ try {
+ output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumB.class);
+ } catch (ELException ele) {
+ // Ignore
+ }
+ assertNull(output);
+ }
+
+ @Test
+ public void testCoerceEnumAToEnumC() {
+ Object output = null;
+ try {
+ output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumC.class);
+ } catch (ELException ele) {
+ // Ignore
+ }
+ assertNull(output);
+ }
+
+ private static void testIsSame(Object value) {
+ assertEquals(value, ELSupport.coerceToNumber(value, value.getClass()));
+ }
+
+ private static enum TestEnumA {
+ VALA1,
+ VALA2
+ }
+ private static enum TestEnumB {
+ VALB1,
+ VALB2
+ }
+ private static enum TestEnumC {
+ VALA1,
+ VALA2,
+ VALB1,
+ VALB2
+ }
+}
Added: trunk/test/java/org/apache/el/parser/TestELParser.java
===================================================================
--- trunk/test/java/org/apache/el/parser/TestELParser.java (rev
0)
+++ trunk/test/java/org/apache/el/parser/TestELParser.java 2011-12-06 15:29:27 UTC (rev
1883)
@@ -0,0 +1,117 @@
+/*
+ * 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.ELContext;
+import javax.el.ELException;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+import org.apache.jasper.el.ELContextImpl;
+
+public class TestELParser {
+
+ @Test
+ public void testBug49081() {
+ // OP's report
+ testExpression("#${1+1}", "#2");
+
+ // Variations on a theme
+ testExpression("#", "#");
+ testExpression("##", "##");
+ testExpression("###", "###");
+ testExpression("$", "$");
+ testExpression("$$", "$$");
+ testExpression("$$$", "$$$");
+ testExpression("#$", "#$");
+ testExpression("#$#", "#$#");
+ testExpression("$#", "$#");
+ testExpression("$#$", "$#$");
+
+ testExpression("#{1+1}", "2");
+ testExpression("##{1+1}", "#2");
+ testExpression("###{1+1}", "##2");
+ testExpression("${1+1}", "2");
+ testExpression("$${1+1}", "$2");
+ testExpression("$$${1+1}", "$$2");
+ testExpression("#${1+1}", "#2");
+ testExpression("#$#{1+1}", "#$2");
+ testExpression("$#{1+1}", "$2");
+ testExpression("$#${1+1}", "$#2");
+ }
+
+ @Test
+ public void testJavaKeyWordSuffix() {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ TesterBeanA beanA = new TesterBeanA();
+ beanA.setInt("five");
+ ValueExpression var =
+ factory.createValueExpression(beanA, TesterBeanA.class);
+ context.getVariableMapper().setVariable("beanA", var);
+
+ // Should fail
+ Exception e = null;
+ try {
+ factory.createValueExpression(context, "${beanA.int}",
+ String.class);
+ } catch (ELException ele) {
+ e = ele;
+ }
+ assertNotNull(e);
+ }
+
+ @Test
+ public void testJavaKeyWordIdentifier() {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ TesterBeanA beanA = new TesterBeanA();
+ beanA.setInt("five");
+ ValueExpression var =
+ factory.createValueExpression(beanA, TesterBeanA.class);
+ context.getVariableMapper().setVariable("this", var);
+
+ // Should fail
+ Exception e = null;
+ try {
+ factory.createValueExpression(context, "${this}", String.class);
+ } catch (ELException ele) {
+ e = ele;
+ }
+ assertNotNull(e);
+ }
+
+
+ private void testExpression(String expression, String expected) {
+ ExpressionFactory factory = ExpressionFactory.newInstance();
+ ELContext context = new ELContextImpl();
+
+ ValueExpression ve = factory.createValueExpression(
+ context, expression, String.class);
+
+ String result = (String) ve.getValue(context);
+ assertEquals(expected, result);
+ }
+}
Added: trunk/test/java/org/apache/el/parser/TesterBeanA.java
===================================================================
--- trunk/test/java/org/apache/el/parser/TesterBeanA.java (rev 0)
+++ trunk/test/java/org/apache/el/parser/TesterBeanA.java 2011-12-06 15:29:27 UTC (rev
1883)
@@ -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.parser;
+
+public class TesterBeanA {
+ private String keywordInt;
+
+ public String getInt() {
+ return keywordInt;
+ }
+
+ public void setInt(String keywordInt) {
+ this.keywordInt = keywordInt;
+ }
+}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2011-12-06 15:27:15 UTC (rev 1882)
+++ trunk/webapps/docs/changelog.xml 2011-12-06 15:29:27 UTC (rev 1883)
@@ -16,6 +16,24 @@
<body>
+<section name="JBoss Web 7.0.5.Final (remm)">
+ <subsection name="Catalina">
+ <changelog>
+ <update>
+ <jira>AS7-2844</jira>: Error pages are suppose to complete or
dispatch an async operation,
+ but the check was not in the right location. (remm)
+ </update>
+ </changelog>
+ </subsection>
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ Rebase on Tomcat EL. (remm)
+ </fix>
+ </changelog>
+ </subsection>
+</section>
+
<section name="JBoss Web 7.0.4.Final (remm)">
<subsection name="Catalina">
<changelog>