You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2024/12/20 11:28:35 UTC

(maven) branch master updated: [MNG-8454] Force the FileSizeFormat UT to US Locale (#2003)

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

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 575ad3719c [MNG-8454] Force the FileSizeFormat UT to US Locale (#2003)
575ad3719c is described below

commit 575ad3719c79b061c78d531ec9d29793f159c2ec
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Fri Dec 20 12:28:29 2024 +0100

    [MNG-8454] Force the FileSizeFormat UT to US Locale (#2003)
    
    As it uses now String.format that produces different
    decimal separator based on local, most notable DE
    
    ---
    
    https://issues.apache.org/jira/browse/MNG-8454
---
 .../maven/cling/transfer/FileSizeFormatTest.java       | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/transfer/FileSizeFormatTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/transfer/FileSizeFormatTest.java
index aec45fd4ca..d642450178 100644
--- a/impl/maven-cli/src/test/java/org/apache/maven/cling/transfer/FileSizeFormatTest.java
+++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/transfer/FileSizeFormatTest.java
@@ -18,15 +18,33 @@
  */
 package org.apache.maven.cling.transfer;
 
+import java.util.Locale;
+
 import org.apache.maven.api.services.MessageBuilder;
 import org.apache.maven.cling.transfer.FileSizeFormat.ScaleUnit;
 import org.apache.maven.internal.impl.DefaultMessageBuilder;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
 class FileSizeFormatTest {
+    // Locale like DE uses "," and not "."
+    // For simplicity’s sake let test in US
+    static Locale original;
+
+    @BeforeAll
+    static void beforeAll() {
+        original = Locale.getDefault();
+        Locale.setDefault(Locale.US);
+    }
+
+    @AfterAll
+    static void afterAll() {
+        Locale.setDefault(original);
+    }
 
     @Test
     void testNegativeSize() {