Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/jdk/sun/util/resources/TimeZone/Bug8139107.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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 @@ -27,11 +27,12 @@
* @summary Test that date parsing with DateTimeFormatter pattern
* that contains timezone field doesn't trigger NPE. All supported
* locales are tested.
* @run testng Bug8139107
* @run junit Bug8139107
*/
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.testng.annotations.Test;

import org.junit.jupiter.api.Test;

public class Bug8139107 {

Expand Down
25 changes: 12 additions & 13 deletions test/jdk/sun/util/resources/TimeZone/ChineseTimeZoneNameTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2026, 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 All @@ -26,7 +26,7 @@
* @bug 8275721 8174269
* @modules jdk.localedata
* @summary Checks Chinese time zone names for `UTC` using CLDR are consistent
* @run testng ChineseTimeZoneNameTest
* @run junit ChineseTimeZoneNameTest
*/

import java.time.Instant;
Expand All @@ -35,20 +35,18 @@
import java.time.format.DateTimeFormatter;
import java.util.Locale;

import static org.testng.Assert.assertEquals;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import static org.junit.jupiter.api.Assertions.assertEquals;

@Test
public class ChineseTimeZoneNameTest {

private static final Locale SIMPLIFIED_CHINESE = Locale.forLanguageTag("zh-Hans");
private static final Locale TRADITIONAL_CHINESE = Locale.forLanguageTag("zh-Hant");
private static final ZonedDateTime EPOCH_UTC =
ZonedDateTime.ofInstant(Instant.ofEpochSecond (0), ZoneId.of ("UTC"));

@DataProvider(name="locales")
Object[][] data() {
private static Object[][] data() {
return new Object[][] {
{Locale.CHINESE, SIMPLIFIED_CHINESE},
{Locale.SIMPLIFIED_CHINESE, SIMPLIFIED_CHINESE},
Expand All @@ -61,11 +59,12 @@ Object[][] data() {
};
}

@Test(dataProvider="locales")
@ParameterizedTest
@MethodSource("data")
public void test_ChineseTimeZoneNames(Locale testLoc, Locale resourceLoc) {
assertEquals(DateTimeFormatter.ofPattern("z", testLoc).format(EPOCH_UTC),
DateTimeFormatter.ofPattern("z", resourceLoc).format(EPOCH_UTC));
assertEquals(DateTimeFormatter.ofPattern("zzzz", testLoc).format(EPOCH_UTC),
DateTimeFormatter.ofPattern("zzzz", resourceLoc).format(EPOCH_UTC));
assertEquals(DateTimeFormatter.ofPattern("z", resourceLoc).format(EPOCH_UTC),
DateTimeFormatter.ofPattern("z", testLoc).format(EPOCH_UTC));
assertEquals(DateTimeFormatter.ofPattern("zzzz", resourceLoc).format(EPOCH_UTC),
DateTimeFormatter.ofPattern("zzzz", testLoc).format(EPOCH_UTC));
}
}
21 changes: 10 additions & 11 deletions test/jdk/sun/util/resources/cldr/Bug8202764.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, 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,11 +28,9 @@
* @summary Checks time zone names are consistent with aliased ids,
* between DateFormatSymbols.getZoneStrings() and getDisplayName()
* of TimeZone/ZoneId classes
* @run testng/othervm Bug8202764
* @run junit/othervm Bug8202764
*/

import static org.testng.Assert.assertEquals;

import java.time.ZoneId;
import java.time.format.TextStyle;
import java.text.DateFormatSymbols;
Expand All @@ -41,7 +39,8 @@
import java.util.Set;
import java.util.TimeZone;

import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class Bug8202764 {

Expand All @@ -53,15 +52,15 @@ public void testAliasedTZs() {
.forEach(zone -> {
System.out.println(zone[0]);
TimeZone tz = TimeZone.getTimeZone(zone[0]);
assertEquals(zone[1], tz.getDisplayName(false, TimeZone.LONG, Locale.US));
assertEquals(zone[2], tz.getDisplayName(false, TimeZone.SHORT, Locale.US));
assertEquals(zone[3], tz.getDisplayName(true, TimeZone.LONG, Locale.US));
assertEquals(zone[4], tz.getDisplayName(true, TimeZone.SHORT, Locale.US));
assertEquals(tz.getDisplayName(false, TimeZone.LONG, Locale.US), zone[1]);
assertEquals(tz.getDisplayName(false, TimeZone.SHORT, Locale.US), zone[2]);
assertEquals(tz.getDisplayName(true, TimeZone.LONG, Locale.US), zone[3]);
assertEquals(tz.getDisplayName(true, TimeZone.SHORT, Locale.US), zone[4]);
if (zoneIds.contains(zone[0])) {
// Some of the ids, e.g. three-letter ids are not supported in ZoneId
ZoneId zi = tz.toZoneId();
assertEquals(zone[5], zi.getDisplayName(TextStyle.FULL, Locale.US));
assertEquals(zone[6], zi.getDisplayName(TextStyle.SHORT, Locale.US));
assertEquals(zi.getDisplayName(TextStyle.FULL, Locale.US), zone[5]);
assertEquals(zi.getDisplayName(TextStyle.SHORT, Locale.US), zone[6]);
}
});
}
Expand Down
32 changes: 16 additions & 16 deletions test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, 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,7 +28,7 @@
* @modules jdk.localedata
* @summary Checks CLDR time zone names are generated correctly at
* either build or runtime
* @run testng TimeZoneNamesTest
* @run junit TimeZoneNamesTest
*/

import java.text.DateFormatSymbols;
Expand All @@ -39,16 +39,15 @@
import java.util.Objects;
import java.util.TimeZone;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

@Test
public class TimeZoneNamesTest {

@DataProvider
Object[][] sampleTZs() {
private static Object[][] sampleTZs() {
return new Object[][] {
// tzid, locale, style, expected

Expand Down Expand Up @@ -265,19 +264,20 @@ Object[][] sampleTZs() {
}


@Test(dataProvider="sampleTZs")
@ParameterizedTest
@MethodSource("sampleTZs")
public void test_tzNames(String tzid, Locale locale, String lstd, String sstd, String ldst, String sdst, String lgen, String sgen) {
// Standard time
assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(false, TimeZone.LONG, locale), lstd);
assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(false, TimeZone.SHORT, locale), sstd);
assertEquals(lstd, TimeZone.getTimeZone(tzid).getDisplayName(false, TimeZone.LONG, locale));
assertEquals(sstd, TimeZone.getTimeZone(tzid).getDisplayName(false, TimeZone.SHORT, locale));

// daylight saving time
assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(true, TimeZone.LONG, locale), ldst);
assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(true, TimeZone.SHORT, locale), sdst);
assertEquals(ldst, TimeZone.getTimeZone(tzid).getDisplayName(true, TimeZone.LONG, locale));
assertEquals(sdst, TimeZone.getTimeZone(tzid).getDisplayName(true, TimeZone.SHORT, locale));

// generic name
assertEquals(ZoneId.of(tzid).getDisplayName(TextStyle.FULL, locale), lgen);
assertEquals(ZoneId.of(tzid).getDisplayName(TextStyle.SHORT, locale), sgen);
assertEquals(lgen, ZoneId.of(tzid).getDisplayName(TextStyle.FULL, locale));
assertEquals(sgen, ZoneId.of(tzid).getDisplayName(TextStyle.SHORT, locale));
}

// Make sure getZoneStrings() returns non-empty string array
Expand Down