You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2025/01/24 12:07:25 UTC

(maven-shared-utils) branch escape created (now 6982cf9)

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

elharo pushed a change to branch escape
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git


      at 6982cf9  Display Unicode unescaped

This branch includes the following new commits:

     new 6982cf9  Display Unicode unescaped

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(maven-shared-utils) 01/01: Display Unicode unescaped

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch escape
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git

commit 6982cf940ac9a5c1187bc0c943e5b8992810ad35
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Fri Jan 24 07:07:15 2025 -0500

    Display Unicode unescaped
---
 pom.xml                                            |  6 ---
 .../org/apache/maven/shared/utils/CaseTest.java    | 46 +++++-----------------
 2 files changed, 10 insertions(+), 42 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2ae3240..6b924ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,12 +108,6 @@
       <version>4.13.2</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-text</artifactId>
-      <version>1.11.0</version>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>com.google.code.findbugs</groupId>
       <artifactId>jsr305</artifactId>
diff --git a/src/test/java/org/apache/maven/shared/utils/CaseTest.java b/src/test/java/org/apache/maven/shared/utils/CaseTest.java
index 113c441..67250a7 100644
--- a/src/test/java/org/apache/maven/shared/utils/CaseTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/CaseTest.java
@@ -20,10 +20,8 @@ package org.apache.maven.shared.utils;
 
 import java.util.Locale;
 
-import org.apache.commons.text.StringEscapeUtils;
 import org.junit.AfterClass;
 import org.junit.Assert;
-import org.junit.ComparisonFailure;
 import org.junit.Test;
 
 /**
@@ -72,28 +70,19 @@ public class CaseTest extends Assert {
 
         final String iIıİ = "iIıİ";
 
-        // check source encoding doesn't wreck havoc */
-        assertUnicodeEquals(
-                "misc i directly in (UTF-8) source", iIıİ, "" + DOTTED_i + DOTLESS_I + DOTLESS_i + DOTTED_I);
+        // check source encoding doesn't wreak havoc */
+        assertEquals( "misc i directly in (UTF-8) source", iIıİ, "" + DOTTED_i + DOTLESS_I + DOTLESS_i + DOTTED_I );
 
         // check toUpperCase and toLowerCase difference with turkish and english locales
-        assertUnicodeEquals(
-                "'iIıİ'.toUpperCase('tr')=='İIIİ'",
-                "" + DOTTED_I + DOTLESS_I + DOTLESS_I + DOTTED_I,
-                iIıİ.toUpperCase(LOCALE_TURKISH));
-        assertUnicodeEquals(
-                "'iIıİ'.toLowerCase('tr')=='iııi'",
-                "" + DOTTED_i + DOTLESS_i + DOTLESS_i + DOTTED_i,
-                iIıİ.toLowerCase(LOCALE_TURKISH));
-        assertUnicodeEquals(
-                "'iIıİ'.toUpperCase('en')=='IIIİ'",
-                "" + DOTLESS_I + DOTLESS_I + DOTLESS_I + DOTTED_I,
-                iIıİ.toUpperCase(Locale.ENGLISH));
+        assertEquals( "'iIıİ'.toUpperCase('tr')=='İIIİ'", "" + DOTTED_I + DOTLESS_I + DOTLESS_I + DOTTED_I,
+                iIıİ.toUpperCase(LOCALE_TURKISH) );
+        assertEquals( "'iIıİ'.toLowerCase('tr')=='iııi'", "" + DOTTED_i + DOTLESS_i + DOTLESS_i + DOTTED_i,
+                iIıİ.toLowerCase(LOCALE_TURKISH) );
+        assertEquals( "'iIıİ'.toUpperCase('en')=='IIIİ'", "" + DOTLESS_I + DOTLESS_I + DOTLESS_I + DOTTED_I,
+                iIıİ.toUpperCase(Locale.ENGLISH) );
         String lower = iIıİ.toLowerCase(Locale.ENGLISH); // on some platforms, ends with extra COMBINED DOT ABOVE
-        assertUnicodeEquals(
-                "'iIıİ'.toLowerCase('en')=='iiıi'",
-                "" + DOTTED_i + DOTTED_i + DOTLESS_i + DOTTED_i + (lower.length() > 4 ? COMBINING_DOT_ABOVE : ""),
-                lower);
+        String expected = "" + DOTTED_i + DOTTED_i + DOTLESS_i + DOTTED_i + (lower.length() > 4 ? COMBINING_DOT_ABOVE : "");
+        assertEquals( "'iIıİ'.toLowerCase('en')=='iiıi'", expected, lower );
 
         // check equalsIgnoreCase() , which has no locale
         for (int i = 0; i < iIıİ.length(); i++) {
@@ -109,21 +98,6 @@ public class CaseTest extends Assert {
         }
     }
 
-    /**
-     * Assert equals, and in case the result isn't as expected, display content unicode-escaped.
-     * @param message
-     * @param expected
-     * @param actual
-     */
-    private void assertUnicodeEquals(String message, String expected, String actual) {
-        if (expected.equals(actual)) {
-            return;
-        }
-
-        throw new ComparisonFailure(
-                message, StringEscapeUtils.escapeJava(expected), StringEscapeUtils.escapeJava(actual));
-    }
-
     /**
      * Test case change on all ascii characters with every available locale, to check that turkish i is the only
      * exception on these characters.