This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 08e24d9a19 Add test case for bug 70249
08e24d9a19 is described below

commit 08e24d9a196fd962b9b3bf9d54bca4ab3a067a6c
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 9042e6cb02..dfe6ba1ad1 100644
--- a/test/org/apache/el/lang/TestELSupport.java
+++ b/test/org/apache/el/lang/TestELSupport.java
@@ -41,14 +41,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
@@ -128,116 +126,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);
     }
 
@@ -295,10 +277,12 @@ public class TestELSupport {
         VALA1,
         VALA2
     }
+
     private enum TestEnumB {
         VALB1,
         VALB2
     }
+
     private enum TestEnumC {
         VALA1,
         VALA2,
@@ -361,9 +345,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).
      */
@@ -513,8 +497,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]

Reply via email to