This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new ab0fe0f160 Add test case for bug 70249
ab0fe0f160 is described below
commit ab0fe0f16004fd01e318bf9bf04cf313bf75a417
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Sep 28 13:29:58 2026 +0100
Add test case for bug 70249
---
test/org/apache/el/TestELInJsp.java | 12 ++++++
test/org/apache/el/lang/TestELSupport.java | 66 ++++++++++++------------------
test/webapp/bug7nnnn/bug70249.jsp | 19 +++++++++
3 files changed, 57 insertions(+), 40 deletions(-)
diff --git a/test/org/apache/el/TestELInJsp.java
b/test/org/apache/el/TestELInJsp.java
index 10fa44ba3f..3055bf47b8 100644
--- a/test/org/apache/el/TestELInJsp.java
+++ b/test/org/apache/el/TestELInJsp.java
@@ -518,6 +518,18 @@ public class TestELInJsp extends TomcatBaseTest {
}
+ @Test
+ public void testBug70246() throws Exception {
+ getTomcatInstanceTestWebapp(true, true);
+
+ ByteChunk res = getUrl("http://localhost:" + getPort() +
"/test/bug7nnnn/bug70249.jsp");
+ String result = res.toString();
+ assertEcho(result, "01-[1, 2, 11]");
+ assertEcho(result, "02-[1, 2, 11]");
+ assertEcho(result, "03-[1, 11, 2]");
+ }
+
+
// Assertion for text contained with <p></p>, e.g. printed by tags:echo
private static void assertEcho(String result, String expected) {
Assert.assertTrue(result, result.indexOf("<p>" + expected + "</p>") >
0);
diff --git a/test/org/apache/el/lang/TestELSupport.java
b/test/org/apache/el/lang/TestELSupport.java
index 87d4f4e224..58dd776b68 100644
--- a/test/org/apache/el/lang/TestELSupport.java
+++ b/test/org/apache/el/lang/TestELSupport.java
@@ -38,14 +38,12 @@ public class TestELSupport {
@Test
public void testBigDecimal() {
- testIsSame(new BigDecimal(
-
"0.123456789012345678901234567890123456789012345678901234567890123456789"));
+ testIsSame(new
BigDecimal("0.123456789012345678901234567890123456789012345678901234567890123456789"));
}
@Test
public void testBigInteger() {
- testIsSame(new BigInteger(
-
"1234567890123456789012345678901234567890123456789012345678901234567890"));
+ testIsSame(new
BigInteger("1234567890123456789012345678901234567890123456789012345678901234567890"));
}
@Test
@@ -125,116 +123,100 @@ public class TestELSupport {
@Test
public void testCoerceToType01() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- null, Integer.class);
+ Object result = ELManager.getExpressionFactory().coerceToType(null,
Integer.class);
Assert.assertNull("Result: " + result, result);
}
@Test
public void testCoerceToType02() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- null, int.class);
+ Object result = ELManager.getExpressionFactory().coerceToType(null,
int.class);
Assert.assertEquals(Integer.valueOf(0), result);
}
@Test
public void testCoerceToType03() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- null, boolean.class);
+ Object result = ELManager.getExpressionFactory().coerceToType(null,
boolean.class);
Assert.assertEquals(Boolean.valueOf(null), result);
}
@Test
public void testCoerceToType04() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- null, String.class);
+ Object result = ELManager.getExpressionFactory().coerceToType(null,
String.class);
Assert.assertEquals("", result);
}
@Test
public void testCoerceToType05() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- null, Character.class);
+ Object result = ELManager.getExpressionFactory().coerceToType(null,
Character.class);
Assert.assertNull("Result: " + result, result);
}
@Test
public void testCoerceToType06() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- "", Character.class);
+ Object result = ELManager.getExpressionFactory().coerceToType("",
Character.class);
Assert.assertEquals(Character.valueOf((char) 0), result);
}
@Test
public void testCoerceToType07() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- null, char.class);
+ Object result = ELManager.getExpressionFactory().coerceToType(null,
char.class);
Assert.assertEquals(Character.valueOf((char) 0), result);
}
@Test
public void testCoerceToType08() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- "", char.class);
+ Object result = ELManager.getExpressionFactory().coerceToType("",
char.class);
Assert.assertEquals(Character.valueOf((char) 0), result);
}
@Test
public void testCoerceToType09() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- null, Boolean.class);
+ Object result = ELManager.getExpressionFactory().coerceToType(null,
Boolean.class);
Assert.assertNull("Result: " + result, result);
}
@Test
public void testCoerceToType10() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- "", Boolean.class);
+ Object result = ELManager.getExpressionFactory().coerceToType("",
Boolean.class);
Assert.assertEquals(Boolean.FALSE, result);
}
@Test
public void testCoerceToType11() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- null, boolean.class);
+ Object result = ELManager.getExpressionFactory().coerceToType(null,
boolean.class);
Assert.assertEquals(Boolean.FALSE, result);
}
@Test
public void testCoerceToType12() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- "", boolean.class);
+ Object result = ELManager.getExpressionFactory().coerceToType("",
boolean.class);
Assert.assertEquals(Boolean.FALSE, result);
}
@Test
public void testCoerceToType13() {
- Object result = ELManager.getExpressionFactory().coerceToType(
- "", TesterType.class);
+ Object result = ELManager.getExpressionFactory().coerceToType("",
TesterType.class);
Assert.assertNull(result);
}
@Test
public void testCoerceToType14() {
PropertyEditorManager.registerEditor(TesterType.class,
TesterTypeEditorNoError.class);
- Object result = ELManager.getExpressionFactory().coerceToType(
- "Foo", TesterType.class);
+ Object result = ELManager.getExpressionFactory().coerceToType("Foo",
TesterType.class);
Assert.assertEquals("Foo", ((TesterType) result).getValue());
}
- @Test(expected=ELException.class)
+ @Test(expected = ELException.class)
public void testCoerceToType15() {
PropertyEditorManager.registerEditor(TesterType.class,
TesterTypeEditorError.class);
- Object result = ELManager.getExpressionFactory().coerceToType(
- "Foo", TesterType.class);
+ Object result = ELManager.getExpressionFactory().coerceToType("Foo",
TesterType.class);
Assert.assertEquals("Foo", ((TesterType) result).getValue());
}
@Test
public void testCoerceToType16() {
PropertyEditorManager.registerEditor(TesterType.class,
TesterTypeEditorError.class);
- Object result = ELManager.getExpressionFactory().coerceToType(
- "", TesterType.class);
+ Object result = ELManager.getExpressionFactory().coerceToType("",
TesterType.class);
Assert.assertNull(result);
}
@@ -270,10 +252,12 @@ public class TestELSupport {
VALA1,
VALA2
}
+
private enum TestEnumB {
VALB1,
VALB2
}
+
private enum TestEnumC {
VALA1,
VALA2,
@@ -336,9 +320,9 @@ public class TestELSupport {
/*
- * Note: The following tests use compareTo(). When the target object (Long
or String) is examined by reflection
- * both compareTo(Object) and compareTo(Long)/compareTo(String) methods
will be found as potential matches. The
- * method matching rules (see section 1.2.1.2 of the specification)
require that overload resolution has a higher
+ * Note: The following tests use compareTo(). When the target object (Long
or String) is examined by reflection both
+ * compareTo(Object) and compareTo(Long)/compareTo(String) methods will be
found as potential matches. The method
+ * matching rules (see section 1.2.1.2 of the specification) require that
overload resolution has a higher
* precedence than coercion resolution so it is always the
compareTo(Object) method that will be used for the
* following tests resulting in a ClassCastException (which is wrapped in
an ELException).
*/
@@ -488,8 +472,10 @@ public class TestELSupport {
private interface FunctionalD<T> extends Predicate<T> {
@Override
String toString();
+
@Override
int hashCode();
+
@Override
boolean equals(Object o);
}
diff --git a/test/webapp/bug7nnnn/bug70249.jsp
b/test/webapp/bug7nnnn/bug70249.jsp
new file mode 100644
index 0000000000..992b2f5777
--- /dev/null
+++ b/test/webapp/bug7nnnn/bug70249.jsp
@@ -0,0 +1,19 @@
+<%--
+ 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.
+--%>
+<p>01-${ ["11", "2", "1"].stream().sorted( (a,b) ->
Long.valueOf(a).compareTo(Long.valueOf(b))).toList() }</p>
+<p>02-${ ["11", "2", "1"].stream().sorted( (a,b) -> Integer.parseInt(a) -
Integer.parseInt(b)).toList() }</p>
+<p>03-${ ["11", "2", "1"].stream().sorted( (a,b) -> a.compareTo(b)).toList()
}</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]