Skip to content

Commit

Permalink
8264952: [TestBug] Controls unit tests - ControlTest and SpinnerTest …
Browse files Browse the repository at this point in the history
…fail for non US Locale

Reviewed-by: kcr
  • Loading branch information
aghaisas committed Apr 23, 2021
1 parent 27e57d3 commit b50ce94
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -53,7 +53,9 @@

import javafx.scene.control.skin.DatePickerSkin;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

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


/*********************************************************************
Expand All @@ -82,12 +85,18 @@ public Node getDisplayNode() {
* *
********************************************************************/

@Before public void setup() {
@BeforeClass public static void setupOnce() {
defaultLocale = Locale.getDefault();
Locale.setDefault(Locale.forLanguageTag("en-US"));
datePicker = new DatePicker();
}

@AfterClass public static void tearDownOnce() {
Locale.setDefault(defaultLocale);
}

@Before public void setup() {
datePicker = new DatePicker();
}

/*********************************************************************
* *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,13 +28,18 @@

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;

import java.util.Locale;

import javafx.scene.control.Button;
import javafx.scene.control.skin.SpinnerSkin;
import javafx.scene.control.Spinner;
Expand Down Expand Up @@ -82,6 +87,16 @@ public class SpinnerTest {
// used in tests for counting events, reset to zero in setup()
private int eventCount;

private static Locale defaultLocale;

@BeforeClass public static void setupOnce() {
defaultLocale = Locale.getDefault();
Locale.setDefault(Locale.US);
}

@AfterClass public static void tearDownOnce() {
Locale.setDefault(defaultLocale);
}

@Before public void setup() {
eventCount = 0;
Expand Down

0 comments on commit b50ce94

Please sign in to comment.