This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 11.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit b27657e78d57166eb84b1a6c6004503e8a9b6b20 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Jan 17 18:06:17 2025 +0000 Improve EL Identifier tests Test valid and non-valid characters. Tests can only run on versions of Java that have the same definition of identifier as Java 17 (Java 17 to Java 18). --- test/org/apache/el/parser/TestAstIdentifier.java | 34 +++++++++++++++++++++- .../el/parser/TesterGenerateIdentifierRanges.java | 5 ++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/test/org/apache/el/parser/TestAstIdentifier.java b/test/org/apache/el/parser/TestAstIdentifier.java index 584325d4b6..48f1621f30 100644 --- a/test/org/apache/el/parser/TestAstIdentifier.java +++ b/test/org/apache/el/parser/TestAstIdentifier.java @@ -17,14 +17,17 @@ package org.apache.el.parser; import jakarta.el.ELContext; +import jakarta.el.ELException; import jakarta.el.ELProcessor; import jakarta.el.ExpressionFactory; import jakarta.el.ValueExpression; import org.junit.Assert; +import org.junit.Assume; import org.junit.Test; import org.apache.jasper.el.ELContextImpl; +import org.apache.tomcat.util.compat.JreCompat; public class TestAstIdentifier { @@ -52,9 +55,24 @@ public class TestAstIdentifier { @Test public void testIdentifierStart() { + /* + * This test only works on Java 17 to Java 18. + * + * Java 17 is the minimum Java version for Tomcat 11. + * + * In Java 19, the definition of Java Letter and/or Java Digit has changed. + */ + Assume.assumeFalse(JreCompat.isJre19Available()); for (int i = 0; i < 0xFFFF; i++) { if (Character.isJavaIdentifierStart(i)) { testIdentifier((char) i, 'b'); + } else { + try { + testIdentifier((char) i, 'b'); + } catch (ELException e) { + continue; + } + Assert.fail("Expected EL exception for [" + i + "], [" + (char) i + "]"); } } } @@ -62,9 +80,24 @@ public class TestAstIdentifier { @Test public void testIdentifierPart() { + /* + * This test only works on Java 17 to Java 18. + * + * Java 17 is the minimum Java version for Tomcat 11. + * + * In Java 19, the definition of Java Letter and/or Java Digit has changed. + */ + Assume.assumeFalse(JreCompat.isJre19Available()); for (int i = 0; i < 0xFFFF; i++) { if (Character.isJavaIdentifierPart(i)) { testIdentifier('b', (char) i); + } else { + try { + testIdentifier((char) i, 'b'); + } catch (ELException e) { + continue; + } + Assert.fail("Expected EL exception for [" + i + "], [" + (char) i + "]"); } } } @@ -84,7 +117,6 @@ public class TestAstIdentifier { try { ve = factory.createValueExpression(context, "${" + identifier + "}", String.class); } catch (Exception e) { - System.out.println("" + (int) one + " " + (int) two); throw e; } diff --git a/test/org/apache/el/parser/TesterGenerateIdentifierRanges.java b/test/org/apache/el/parser/TesterGenerateIdentifierRanges.java index f692344e3f..97f463a8b1 100644 --- a/test/org/apache/el/parser/TesterGenerateIdentifierRanges.java +++ b/test/org/apache/el/parser/TesterGenerateIdentifierRanges.java @@ -21,6 +21,11 @@ import org.junit.Test; /* * The purpose of this class is to generate the ranges used in the JavaCC grammar for EL parsing. * + * The ranges for Tomcat 11 were generated with Java 17. + * + * The generated ranges are unchanged from Java 17 to 18. + * + * The generated ranges change in Java 19. */ public class TesterGenerateIdentifierRanges { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org