From 48e7dd820e9aa313b9616600fd5603007bab6115 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 26 Dec 2024 10:26:09 -0500 Subject: [PATCH] Use JUnit Pioneer instead of direct global variables access --- .../routines/CurrencyValidatorTest.java | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java b/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java index e549bf8e6..1f495c5af 100644 --- a/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java +++ b/src/test/java/org/apache/commons/validator/routines/CurrencyValidatorTest.java @@ -25,9 +25,9 @@ import java.text.NumberFormat; import java.util.Locale; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.DefaultLocale; /** * Test Case for CurrencyValidator. @@ -39,20 +39,12 @@ public class CurrencyValidatorTest { private String usDollar; private String ukPound; - private Locale originalLocale; - @BeforeEach protected void setUp() { - originalLocale = Locale.getDefault(); usDollar = new DecimalFormatSymbols(Locale.US).getCurrencySymbol(); ukPound = new DecimalFormatSymbols(Locale.UK).getCurrencySymbol(); } - @AfterEach - protected void tearDown() { - Locale.setDefault(originalLocale); - } - /** * Test Format Type */ @@ -82,10 +74,8 @@ public void testIntegerInvalid() { * Test Valid integer (non-decimal) currency values */ @Test + @DefaultLocale("en-GB") public void testIntegerValid() { - // Set the default Locale - Locale.setDefault(Locale.UK); - final CurrencyValidator validator = new CurrencyValidator(); final BigDecimal expected = new BigDecimal("1234.00"); final BigDecimal negative = new BigDecimal("-1234.00"); @@ -143,10 +133,8 @@ public void testInvalid() { * Test currency values with a pattern */ @Test + @DefaultLocale("en-GB") public void testPattern() { - // Set the default Locale - Locale.setDefault(Locale.UK); - final BigDecimalValidator validator = CurrencyValidator.getInstance(); final String basicPattern = CURRENCY_SYMBOL + "#,##0.000"; final String pattern = basicPattern + ";[" + basicPattern + "]"; @@ -174,10 +162,8 @@ public void testPattern() { * Test Valid currency values */ @Test + @DefaultLocale("en-GB") public void testValid() { - // Set the default Locale - Locale.setDefault(Locale.UK); - final BigDecimalValidator validator = CurrencyValidator.getInstance(); final BigDecimal expected = new BigDecimal("1234.56"); final BigDecimal negative = new BigDecimal("-1234.56");