Skip to content
Permalink
Browse files
8264952: [TestBug] Controls unit tests - ControlTest and SpinnerTest …
…fail for non US Locale

Reviewed-by: kcr
  • Loading branch information
aghaisas committed Apr 23, 2021
1 parent 27e57d3 commit b50ce94cd0a41bb616a37c104f7daedd35b0f65d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
@@ -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
@@ -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.*;
@@ -62,6 +64,7 @@
public class DatePickerTest {
private DatePicker datePicker;
private final LocalDate today = LocalDate.now();
private static Locale defaultLocale;


/*********************************************************************
@@ -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();
}

/*********************************************************************
* *
@@ -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
@@ -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;
@@ -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;

1 comment on commit b50ce94

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on b50ce94 Apr 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.