This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-validator.git
The following commit(s) were added to refs/heads/master by this push:
new 48e7dd82 Use JUnit Pioneer instead of direct global variables access
48e7dd82 is described below
commit 48e7dd820e9aa313b9616600fd5603007bab6115
Author: Gary D. Gregory <[email protected]>
AuthorDate: Thu Dec 26 10:26:09 2024 -0500
Use JUnit Pioneer instead of direct global variables access
---
.../validator/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 e549bf8e..1f495c5a 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.DecimalFormatSymbols;
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 class CurrencyValidatorTest {
* 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 class CurrencyValidatorTest {
* 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 class CurrencyValidatorTest {
* 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");