This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 7923e11532 Improve EL Identifier tests 7923e11532 is described below commit 7923e115320983e10aca6e50f0f4256f81b5560b Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Jan 17 19:06:24 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 8 (only Java 8). --- test/org/apache/el/parser/TestAstIdentifier.java | 34 +++++++++++++++++++++- .../el/parser/TesterGenerateIdentifierRanges.java | 3 ++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/test/org/apache/el/parser/TestAstIdentifier.java b/test/org/apache/el/parser/TestAstIdentifier.java index c42cc66100..1c69c84306 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 javax.el.ELContext; +import javax.el.ELException; import javax.el.ELProcessor; import javax.el.ExpressionFactory; import javax.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 8. + * + * Java 8 is the minimum Java version for Tomcat 9. + * + * In Java 9, the definition of Java Letter and/or Java Digit has changed. + */ + Assume.assumeFalse(JreCompat.isJre9Available()); 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 8. + * + * Java 8 is the minimum Java version for Tomcat 9. + * + * In Java 9, the definition of Java Letter and/or Java Digit has changed. + */ + Assume.assumeFalse(JreCompat.isJre9Available()); 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..2171f78bc2 100644 --- a/test/org/apache/el/parser/TesterGenerateIdentifierRanges.java +++ b/test/org/apache/el/parser/TesterGenerateIdentifierRanges.java @@ -21,6 +21,9 @@ 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 9 were generated with Java 8. + * + * The generated ranges changed in Java 9. */ public class TesterGenerateIdentifierRanges { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org