Skip to content

Commit

Permalink
Fix locale for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nroduit committed Jul 26, 2024
1 parent ca8fab9 commit 40dad2c
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,24 @@
@TestInstance(
TestInstance.Lifecycle.PER_CLASS) // To enable BeforeAll and AfterAll for Locale.setDefault()
class DicomUtilsTest {
private Locale defaultLocale;

private static final String ORIGINAL_LANGUAGE = System.getProperty("user.language");
private static final String ORIGINAL_COUNTRY = System.getProperty("user.country");

@BeforeAll
void setUp() {
defaultLocale = Locale.getDefault();
Locale.setDefault(Locale.US); // Force Locale for testing date format
public void setUpAll() {
System.setProperty("user.language", "fr");
System.setProperty("user.country", "FR");
// Clear the Locale cache
Locale.setDefault(Locale.FRANCE);
}

@AfterAll
void tearDown() {
Locale.setDefault(defaultLocale);
public void tearDownAll() {
System.setProperty("user.language", ORIGINAL_LANGUAGE);
System.setProperty("user.country", ORIGINAL_COUNTRY);
// Clear the Locale cache
Locale.setDefault(new Locale(ORIGINAL_LANGUAGE, ORIGINAL_COUNTRY));
}

@Test
Expand Down

0 comments on commit 40dad2c

Please sign in to comment.