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 40dad2c commit 81566f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class DicomUtilsTest {

@BeforeAll
public void setUpAll() {
System.setProperty("user.language", "fr");
System.setProperty("user.country", "FR");
System.setProperty("user.language", "en");
System.setProperty("user.country", "US");
// Clear the Locale cache
Locale.setDefault(Locale.FRANCE);
Locale.setDefault(Locale.US);
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,23 @@
@TestInstance(
TestInstance.Lifecycle.PER_CLASS) // To enable BeforeAll and AfterAll for Locale.setDefault()
class AnatomicBuilderTest {
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.FRENCH); // Force Locale for testing translation
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 81566f2

Please sign in to comment.