Skip to content

Commit b50ce94

Browse files
committed
8264952: [TestBug] Controls unit tests - ControlTest and SpinnerTest fail for non US Locale
Reviewed-by: kcr
1 parent 27e57d3 commit b50ce94

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

modules/javafx.controls/src/test/java/test/javafx/scene/control/DatePickerTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,9 @@
5353

5454
import javafx.scene.control.skin.DatePickerSkin;
5555

56+
import org.junit.AfterClass;
5657
import org.junit.Before;
58+
import org.junit.BeforeClass;
5759
import org.junit.Test;
5860

5961
import static org.junit.Assert.*;
@@ -62,6 +64,7 @@
6264
public class DatePickerTest {
6365
private DatePicker datePicker;
6466
private final LocalDate today = LocalDate.now();
67+
private static Locale defaultLocale;
6568

6669

6770
/*********************************************************************
@@ -82,12 +85,18 @@ public Node getDisplayNode() {
8285
* *
8386
********************************************************************/
8487

85-
@Before public void setup() {
88+
@BeforeClass public static void setupOnce() {
89+
defaultLocale = Locale.getDefault();
8690
Locale.setDefault(Locale.forLanguageTag("en-US"));
87-
datePicker = new DatePicker();
8891
}
8992

93+
@AfterClass public static void tearDownOnce() {
94+
Locale.setDefault(defaultLocale);
95+
}
9096

97+
@Before public void setup() {
98+
datePicker = new DatePicker();
99+
}
91100

92101
/*********************************************************************
93102
* *

modules/javafx.controls/src/test/java/test/javafx/scene/control/SpinnerTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,13 +28,18 @@
2828

2929
import javafx.collections.FXCollections;
3030
import javafx.collections.ObservableList;
31+
import org.junit.AfterClass;
3132
import org.junit.Before;
33+
import org.junit.BeforeClass;
3234
import org.junit.Ignore;
3335
import org.junit.Test;
3436

3537
import java.time.LocalDate;
3638
import java.time.LocalTime;
3739
import java.time.temporal.ChronoUnit;
40+
41+
import java.util.Locale;
42+
3843
import javafx.scene.control.Button;
3944
import javafx.scene.control.skin.SpinnerSkin;
4045
import javafx.scene.control.Spinner;
@@ -82,6 +87,16 @@ public class SpinnerTest {
8287
// used in tests for counting events, reset to zero in setup()
8388
private int eventCount;
8489

90+
private static Locale defaultLocale;
91+
92+
@BeforeClass public static void setupOnce() {
93+
defaultLocale = Locale.getDefault();
94+
Locale.setDefault(Locale.US);
95+
}
96+
97+
@AfterClass public static void tearDownOnce() {
98+
Locale.setDefault(defaultLocale);
99+
}
85100

86101
@Before public void setup() {
87102
eventCount = 0;

0 commit comments

Comments
 (0)