mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8372844: Improve usage of test/jdk/java/text/testlib/TestUtils.java locale methods
Reviewed-by: naoto
This commit is contained in:
parent
c55287d197
commit
c7aa10339a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2025, 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
|
||||
@ -27,29 +27,31 @@
|
||||
* @summary Make sure that cloned SimpleDateFormat objects work
|
||||
* independently in multiple threads.
|
||||
* @library /java/text/testlib
|
||||
* @run main Bug4407042 10
|
||||
* @run junit Bug4407042
|
||||
*/
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
// Usage: java Bug4407042 [duration]
|
||||
public class Bug4407042 {
|
||||
|
||||
static final String TIME_STRING = "2000/11/18 00:01:00";
|
||||
static final long UTC_LONG = 974534460000L;
|
||||
static SimpleDateFormat masterFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
static boolean runrun = true;
|
||||
static int duration = 100;
|
||||
static int duration = 10;
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesAsciiDigits(locale)
|
||||
|| !TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesAsciiDigits(locale),
|
||||
locale + " does not use ASCII digits");
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
masterFormat.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
|
||||
DateParseThread d1 = new DateParseThread();
|
||||
@ -124,11 +126,4 @@ public class Bug4407042 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main (String[] args) {
|
||||
if (args.length == 1) {
|
||||
duration = Math.max(10, Integer.parseInt(args[0]));
|
||||
}
|
||||
new Bug4407042().test();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2025, 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,19 +28,22 @@
|
||||
* the same time zone abbreviation for standard and daylight saving
|
||||
* time.
|
||||
* @library /java/text/testlib
|
||||
* @run main Bug4845901
|
||||
* @run junit/othervm Bug4845901
|
||||
*/
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
public class Bug4845901 {
|
||||
public static void main (String args[]) {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
TimeZone savedTZ = TimeZone.getDefault();
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("Australia/Sydney"));
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2025, 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
|
||||
@ -25,93 +25,73 @@
|
||||
* @test
|
||||
* @bug 6530336 6537997 8008577 8174269 8333582
|
||||
* @library /java/text/testlib
|
||||
* @run main Bug6530336
|
||||
* @run junit/othervm Bug6530336
|
||||
*/
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.FieldSource;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class Bug6530336 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
TimeZone defaultTimeZone = TimeZone.getDefault();
|
||||
private static final Locale[] locales = Locale.getAvailableLocales();
|
||||
private static final TimeZone[] timezones = {
|
||||
TimeZone.getTimeZone("America/New_York"),
|
||||
TimeZone.getTimeZone("America/Denver"),
|
||||
};
|
||||
private static final TimeZone timezone_LA = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
private static final String[] expected = {
|
||||
"Sun Jul 15 12:00:00 PDT 2007",
|
||||
"Sun Jul 15 14:00:00 PDT 2007",
|
||||
};
|
||||
private static final Date[] dates = new Date[2];
|
||||
|
||||
boolean err = false;
|
||||
|
||||
try {
|
||||
Locale locales[] = Locale.getAvailableLocales();
|
||||
TimeZone timezone_LA = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
TimeZone.setDefault(timezone_LA);
|
||||
|
||||
TimeZone timezones[] = {
|
||||
TimeZone.getTimeZone("America/New_York"),
|
||||
TimeZone.getTimeZone("America/Denver"),
|
||||
};
|
||||
|
||||
String[] expected = {
|
||||
"Sun Jul 15 12:00:00 PDT 2007",
|
||||
"Sun Jul 15 14:00:00 PDT 2007",
|
||||
};
|
||||
|
||||
Date[] dates = new Date[2];
|
||||
|
||||
for (int i = 0; i < locales.length; i++) {
|
||||
Locale locale = locales[i];
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Locale.setDefault(locale);
|
||||
|
||||
for (int j = 0; j < timezones.length; j++) {
|
||||
Calendar cal = Calendar.getInstance(timezones[j]);
|
||||
cal.set(2007, 6, 15, 15, 0, 0);
|
||||
dates[j] = cal.getTime();
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
|
||||
|
||||
for (int j = 0; j < timezones.length; j++) {
|
||||
sdf.setTimeZone(timezones[j]);
|
||||
String date = sdf.format(dates[j]);
|
||||
// CLDR localizes GMT format into for some locales. Ignore those cases
|
||||
if (date.matches(".*GMT[\\s+-]\\D.*") ||
|
||||
date.contains("UTC") ||
|
||||
date.contains("TMG") || // Interlingue
|
||||
date.contains("\u07dc\u07ed\u07d5\u07d6") || // N’Ko
|
||||
date.contains("\ua2e7\ua0c5\ua395\ua3e6\ua12e\ua209") || // Sichuan Yi, Nuosu
|
||||
date.contains("\u06af\u0631\u06cc\u0646\u06cc\u0686")) { // Central Kurdish
|
||||
continue;
|
||||
}
|
||||
sdf.setTimeZone(timezone_LA);
|
||||
String date_LA = sdf.parse(date).toString();
|
||||
|
||||
if (!expected[j].equals(date_LA)) {
|
||||
System.err.println("Got wrong Pacific time (" +
|
||||
date_LA + ") for (" + date + ") in " + locale +
|
||||
" in " + timezones[j] +
|
||||
".\nExpected=" + expected[j]);
|
||||
err = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
err = true;
|
||||
}
|
||||
finally {
|
||||
Locale.setDefault(defaultLocale);
|
||||
TimeZone.setDefault(defaultTimeZone);
|
||||
|
||||
if (err) {
|
||||
throw new RuntimeException("Failed.");
|
||||
}
|
||||
}
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
TimeZone.setDefault(timezone_LA);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@FieldSource("locales")
|
||||
void test(Locale locale) {
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
Locale.setDefault(locale);
|
||||
|
||||
for (int j = 0; j < timezones.length; j++) {
|
||||
Calendar cal = Calendar.getInstance(timezones[j]);
|
||||
cal.set(2007, 6, 15, 15, 0, 0);
|
||||
dates[j] = cal.getTime();
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
|
||||
|
||||
for (int j = 0; j < timezones.length; j++) {
|
||||
sdf.setTimeZone(timezones[j]);
|
||||
String date = sdf.format(dates[j]);
|
||||
// CLDR localizes GMT format into for some locales. Ignore those cases
|
||||
if (date.matches(".*GMT[\\s+-]\\D.*") ||
|
||||
date.contains("UTC") ||
|
||||
date.contains("TMG") || // Interlingue
|
||||
date.contains("ߜ߭ߕߖ") || // N’Ko
|
||||
date.contains("ꋧꃅꎕꏦꄮꈉ") || // Sichuan Yi, Nuosu
|
||||
date.contains("گرینیچ")) { // Central Kurdish
|
||||
continue;
|
||||
}
|
||||
sdf.setTimeZone(timezone_LA);
|
||||
String date_LA = assertDoesNotThrow(() -> sdf.parse(date).toString());
|
||||
assertEquals(expected[j], date_LA,
|
||||
"Got wrong Pacific time (%s) for (%s) in %s in %s.".formatted(date_LA, date, locale, timezones[j]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
@ -170,10 +171,8 @@ public class DateFormatRegression {
|
||||
@Test
|
||||
public void Test4059917() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesAsciiDigits(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesAsciiDigits(locale),
|
||||
locale + " does not use ASCII digits");
|
||||
|
||||
SimpleDateFormat fmt;
|
||||
String myDate;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2025, 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,6 +53,7 @@ import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
@ -126,10 +127,8 @@ public class MessageRegression {
|
||||
@Test
|
||||
public void Test4031438() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesAsciiDigits(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesAsciiDigits(locale),
|
||||
locale + " does not use ASCII digits");
|
||||
|
||||
String pattern1 = "Impossible {1} has occurred -- status code is {0} and message is {2}.";
|
||||
String pattern2 = "Double '' Quotes {0} test and quoted '{1}' test plus 'other {2} stuff'.";
|
||||
|
||||
@ -58,6 +58,7 @@ import java.math.BigDecimal;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import sun.util.resources.LocaleData;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -109,10 +110,8 @@ public class NumberRegression {
|
||||
@Test
|
||||
public void Test4088161 (){
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesAsciiDigits(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesAsciiDigits(locale),
|
||||
locale + " does not use ASCII digits");
|
||||
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
double d = 100;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2025, 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
|
||||
@ -32,6 +32,7 @@
|
||||
import java.util.*;
|
||||
import java.text.*;
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
@ -130,10 +131,8 @@ public class CalendarLimitTest
|
||||
public void TestCalendarLimit()
|
||||
{
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
ORIGIN = julianDayToMillis(JAN_1_1_JULIAN_DAY);
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
@ -55,6 +55,7 @@ import java.util.function.Predicate;
|
||||
|
||||
import static java.util.Calendar.*;
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
@ -575,10 +576,8 @@ public class CalendarRegression {
|
||||
@Test
|
||||
public void Test4100311() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
|
||||
cal.set(YEAR, 1997);
|
||||
@ -593,10 +592,8 @@ public class CalendarRegression {
|
||||
@Test
|
||||
public void Test4103271() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
int numYears = 40, startYear = 1997, numDays = 15;
|
||||
@ -833,10 +830,8 @@ public class CalendarRegression {
|
||||
@Test
|
||||
public void Test4114578() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
int ONE_HOUR = 60 * 60 * 1000;
|
||||
TimeZone saveZone = TimeZone.getDefault();
|
||||
@ -921,10 +916,8 @@ public class CalendarRegression {
|
||||
@Test
|
||||
public void Test4125881() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
|
||||
DateFormat fmt = new SimpleDateFormat("MMMM d, yyyy G");
|
||||
@ -947,10 +940,8 @@ public class CalendarRegression {
|
||||
@Test
|
||||
public void Test4125892() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
|
||||
DateFormat fmt = new SimpleDateFormat("MMMM d, yyyy G");
|
||||
@ -1373,10 +1364,8 @@ public class CalendarRegression {
|
||||
@Test
|
||||
public void Test4173516() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
int[][] fieldsList = {
|
||||
{1997, FEBRUARY, 1, 10, 45, 15, 900},
|
||||
@ -1852,11 +1841,10 @@ public class CalendarRegression {
|
||||
@Test
|
||||
public void Test4685354() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesAsciiDigits(locale)
|
||||
|| !TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesAsciiDigits(locale),
|
||||
locale + " does not use ASCII digits");
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
Calendar calendar = Calendar.getInstance(Locale.US);
|
||||
DateFormat df = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
|
||||
@ -1961,10 +1949,8 @@ public class CalendarRegression {
|
||||
@Test
|
||||
public void Test4655637() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Date(1029814211523L));
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2025, 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
|
||||
@ -48,6 +48,7 @@ import java.util.TimeZone;
|
||||
|
||||
import static java.util.Calendar.*;
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
@ -223,10 +224,8 @@ public class CalendarTest {
|
||||
@Test
|
||||
public void TestGenericAPI() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
String str;
|
||||
Date when = new Date(90, APRIL, 15);
|
||||
@ -625,10 +624,8 @@ public class CalendarTest {
|
||||
@Test
|
||||
public void TestGMTvsLocal4064654() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
// Sample output 1:
|
||||
// % /usr/local/java/jdk1.1.3/solaris/bin/java test 1997 1 1 12 0 0
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2025, 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
|
||||
@ -32,6 +32,7 @@
|
||||
import java.util.*;
|
||||
import static java.util.Calendar.*;
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
@ -44,10 +45,8 @@ public class bug4409072 {
|
||||
@Test
|
||||
public void Test4409072() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
Locale savedLocale = Locale.getDefault();
|
||||
TimeZone savedTZ = TimeZone.getDefault();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2025, 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
|
||||
@ -29,14 +29,17 @@
|
||||
* @library /java/text/testlib
|
||||
* @build TestUtils LocaleCategory
|
||||
* @comment test user.xxx.display user.xxx.format properties
|
||||
* @run main/othervm -Duser.language.display=ja
|
||||
* @run junit/othervm -Duser.language.display=ja
|
||||
* -Duser.language.format=zh LocaleCategory
|
||||
* @comment test user.xxx properties overriding user.xxx.display/format
|
||||
* @run main/othervm -Duser.language=en
|
||||
* @run junit/othervm -Duser.language=en
|
||||
* -Duser.language.display=ja
|
||||
* -Duser.language.format=zh LocaleCategory
|
||||
*/
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class LocaleCategory {
|
||||
@ -44,12 +47,11 @@ public class LocaleCategory {
|
||||
private static Locale disp = null;
|
||||
private static Locale fmt = null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
@Test
|
||||
void test() {
|
||||
Locale reservedLocale = Locale.getDefault();
|
||||
if (TestUtils.hasSpecialVariant(reservedLocale)) {
|
||||
System.out.println("Skipping this test because locale is " + reservedLocale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeFalse(TestUtils.hasSpecialVariant(reservedLocale),
|
||||
reservedLocale + " has special variant");
|
||||
|
||||
try {
|
||||
Locale.Builder builder = new Locale.Builder();
|
||||
|
||||
@ -34,6 +34,7 @@ import java.util.*;
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
@ -164,10 +165,8 @@ public class TimeZoneRegression {
|
||||
@Test
|
||||
public void Test4109314() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
// test both SimpleTimeZone and ZoneInfo objects.
|
||||
// @since 1.4
|
||||
@ -292,10 +291,8 @@ public class TimeZoneRegression {
|
||||
@Test
|
||||
public void Test4126678() {
|
||||
Locale locale = Locale.getDefault();
|
||||
if (!TestUtils.usesGregorianCalendar(locale)) {
|
||||
System.out.println("Skipping this test because locale is " + locale);
|
||||
return;
|
||||
}
|
||||
Assumptions.assumeTrue(TestUtils.usesGregorianCalendar(locale),
|
||||
locale + " does not use a Gregorian calendar");
|
||||
|
||||
// Note: this test depends on the PST time zone.
|
||||
TimeZone initialZone = TimeZone.getDefault();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user