This is an automated email from the ASF dual-hosted git repository. garydgregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-text.git
commit fcf5a757883e702be5d93b4d25bb0a6c7add3829 Author: Gary Gregory <[email protected]> AuthorDate: Sat Jul 18 10:04:38 2026 -0700 Sort members. --- .../commons/text/ExtendedMessageFormatTest.java | 30 +++++++++++----------- ...ubstitutorWithInterpolatorStringLookupTest.java | 26 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java index 5af24ee5..9d7d7be8 100644 --- a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java +++ b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java @@ -236,21 +236,6 @@ class ExtendedMessageFormatTest { assertThrowsExactly(IllegalArgumentException.class, () -> new ExtendedMessageFormat("{0 ", new HashMap<>())); } - @Test - void testTruncatedFormatElementWithRegistry() { - // Sanity check to match JRE - assertThrowsExactly(IllegalArgumentException.class, () -> new MessageFormat("{")); - assertThrowsExactly(IllegalArgumentException.class, () -> new MessageFormat("{0,")); - assertThrowsExactly(IllegalArgumentException.class, () -> new MessageFormat("{0}extra{")); - // A format element left unterminated at the end of the pattern used to make the - // registry-based constructor seek one past the buffer and throw - // ArrayIndexOutOfBoundsException; it should report the documented - // IllegalArgumentException, as the plain constructor already does. - assertThrowsExactly(IllegalArgumentException.class, () -> new ExtendedMessageFormat("{", new HashMap<>())); - assertThrowsExactly(IllegalArgumentException.class, () -> new ExtendedMessageFormat("{0,", new HashMap<>())); - assertThrowsExactly(IllegalArgumentException.class, () -> new ExtendedMessageFormat("{0}extra{", new HashMap<>())); - } - /** * Test the built in choice format. */ @@ -542,4 +527,19 @@ class ExtendedMessageFormatTest { () -> new ExtendedMessageFormat("").setFormats(new Format[] { new LowerCaseFormat(), new UpperCaseFormat() })); } + @Test + void testTruncatedFormatElementWithRegistry() { + // Sanity check to match JRE + assertThrowsExactly(IllegalArgumentException.class, () -> new MessageFormat("{")); + assertThrowsExactly(IllegalArgumentException.class, () -> new MessageFormat("{0,")); + assertThrowsExactly(IllegalArgumentException.class, () -> new MessageFormat("{0}extra{")); + // A format element left unterminated at the end of the pattern used to make the + // registry-based constructor seek one past the buffer and throw + // ArrayIndexOutOfBoundsException; it should report the documented + // IllegalArgumentException, as the plain constructor already does. + assertThrowsExactly(IllegalArgumentException.class, () -> new ExtendedMessageFormat("{", new HashMap<>())); + assertThrowsExactly(IllegalArgumentException.class, () -> new ExtendedMessageFormat("{0,", new HashMap<>())); + assertThrowsExactly(IllegalArgumentException.class, () -> new ExtendedMessageFormat("{0}extra{", new HashMap<>())); + } + } diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java index e312e645..90c729c2 100644 --- a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java +++ b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java @@ -256,19 +256,6 @@ class StringSubstitutorWithInterpolatorStringLookupTest { assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" + spKey + "}")); } - /** - * In our POM. the module {@code java.base} must open "opens java.lang" for the {@link SetEnvironmentVariable} annotation to work. Otherwise, the test will - * fail with an IllegalAccessException. - */ - @Disabled("Needs java.base to open 'opens java.lang' for SetEnvironmentVariable.") - @Test - @SetEnvironmentVariable(key = "testSystemPropertyDefaultDefault", value = "123456789") - void testSystemPropertyDefaultDefaultEnv() { - final StringSubstitutor strSubst = StringSubstitutor.createInterpolator(); - assertEquals("123456789", strSubst - .replace("${env:testSystemPropertyDefaultDefault:-${sys:unknownkey1:-${sys:unknownkey2:-${sys:unknownkey3:-${sys:unknownkey4:-foo}}}}}")); - } - @Test void testSystemPropertyDefaultDefault() { final StringSubstitutor strSubst = StringSubstitutor.createInterpolator(); @@ -288,6 +275,19 @@ class StringSubstitutorWithInterpolatorStringLookupTest { assertEquals(actual, strSubst.replace("${sys:unknownkey1:-${sys:unknownkey2:-" + spLookupStr + "}}")); } + /** + * In our POM. the module {@code java.base} must open "opens java.lang" for the {@link SetEnvironmentVariable} annotation to work. Otherwise, the test will + * fail with an IllegalAccessException. + */ + @Disabled("Needs java.base to open 'opens java.lang' for SetEnvironmentVariable.") + @Test + @SetEnvironmentVariable(key = "testSystemPropertyDefaultDefault", value = "123456789") + void testSystemPropertyDefaultDefaultEnv() { + final StringSubstitutor strSubst = StringSubstitutor.createInterpolator(); + assertEquals("123456789", strSubst + .replace("${env:testSystemPropertyDefaultDefault:-${sys:unknownkey1:-${sys:unknownkey2:-${sys:unknownkey3:-${sys:unknownkey4:-foo}}}}}")); + } + @Test void testSystemPropertyDefaultStringLookup() { final StringSubstitutor strSubst = new StringSubstitutor(
