diff --git a/.github/workflows/build-alpine-linux.yml b/.github/workflows/build-alpine-linux.yml index ce97f3c1092..c356a8a0f2a 100644 --- a/.github/workflows/build-alpine-linux.yml +++ b/.github/workflows/build-alpine-linux.yml @@ -96,6 +96,7 @@ jobs: --with-boot-jdk=${{ steps.bootjdk.outputs.path }} --with-zlib=system --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 27ae0a6cb63..c2ed63aa439 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -179,6 +179,7 @@ jobs: --openjdk-target=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} --with-sysroot=sysroot --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-${{ inputs.gcc-major-version }} CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-${{ inputs.gcc-major-version }} ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 33e09585bf3..a668cb5a0f9 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -143,6 +143,7 @@ jobs: --with-gtest=${{ steps.gtest.outputs.path }} --with-zlib=system --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index dba47194c6d..4535d0dd760 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -110,6 +110,7 @@ jobs: --with-gtest=${{ steps.gtest.outputs.path }} --with-zlib=system --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 6bcccf627ab..4dafc016a99 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -134,6 +134,7 @@ jobs: --with-gtest=${{ steps.gtest.outputs.path }} --with-msvc-toolset-version=${{ inputs.msvc-toolset-version }} --with-jmod-compress=zip-1 + --with-external-symbols-in-bundles=none ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && diff --git a/make/modules/jdk.jdwp.agent/Lib.gmk b/make/modules/jdk.jdwp.agent/Lib.gmk index 6ae053d4bec..ce58e145f59 100644 --- a/make/modules/jdk.jdwp.agent/Lib.gmk +++ b/make/modules/jdk.jdwp.agent/Lib.gmk @@ -54,21 +54,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJDWP, \ NAME := jdwp, \ OPTIMIZATION := LOW, \ CFLAGS := -DJDWP_LOGGING $(ICONV_CFLAGS), \ - DISABLED_WARNINGS_gcc_eventFilter.c := unused-variable, \ - DISABLED_WARNINGS_gcc_SDE.c := unused-function, \ - DISABLED_WARNINGS_gcc_threadControl.c := unused-but-set-variable \ - unused-variable, \ - DISABLED_WARNINGS_gcc_utf_util.c := unused-but-set-variable, \ - DISABLED_WARNINGS_clang_error_messages.c := format-nonliteral, \ - DISABLED_WARNINGS_clang_eventFilter.c := unused-variable, \ - DISABLED_WARNINGS_clang_EventRequestImpl.c := self-assign, \ - DISABLED_WARNINGS_clang_inStream.c := sometimes-uninitialized, \ - DISABLED_WARNINGS_clang_log_messages.c := format-nonliteral, \ - DISABLED_WARNINGS_clang_SDE.c := unused-function, \ - DISABLED_WARNINGS_clang_threadControl.c := unused-but-set-variable \ - unused-variable, \ - DISABLED_WARNINGS_clang_utf_util.c := unused-but-set-variable, \ - DISABLED_WARNINGS_microsoft_debugInit.c := 5287, \ LDFLAGS := $(ICONV_LDFLAGS), \ EXTRA_HEADER_DIRS := \ include \ diff --git a/src/demo/share/java2d/J2DBench/Makefile b/src/demo/share/java2d/J2DBench/Makefile index f8949845b4f..b5996ae4d6d 100644 --- a/src/demo/share/java2d/J2DBench/Makefile +++ b/src/demo/share/java2d/J2DBench/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/src/demo/share/java2d/J2DBench/build.xml b/src/demo/share/java2d/J2DBench/build.xml index d48b446d0f3..748673b5fed 100644 --- a/src/demo/share/java2d/J2DBench/build.xml +++ b/src/demo/share/java2d/J2DBench/build.xml @@ -1,5 +1,5 @@ " + dowDate); + assertEquals(dowExpected, dowResult, "Localized DayOfWeek not correct; " + day + " -->" + dowDate); int weekExpected = day.get(wowbyField) + 1; ValueRange range = day.range(wowbyField); weekExpected = ((weekExpected - 1) % (int)range.getMaximum()) + 1; LocalDate weekDate = day.with(wowbyField, weekExpected); int weekResult = weekDate.get(wowbyField); - assertEquals(weekResult, weekExpected, "Localized WeekOfWeekBasedYear not correct; " + day + " -->" + weekDate); + assertEquals(weekExpected, weekResult, "Localized WeekOfWeekBasedYear not correct; " + day + " -->" + weekDate); int yearExpected = day.get(yowbyField) + 1; LocalDate yearDate = day.with(yowbyField, yearExpected); int yearResult = yearDate.get(yowbyField); - assertEquals(yearResult, yearExpected, "Localized WeekBasedYear not correct; " + day + " --> " + yearDate); + assertEquals(yearExpected, yearResult, "Localized WeekBasedYear not correct; " + day + " --> " + yearDate); range = yearDate.range(wowbyField); weekExpected = Math.min(day.get(wowbyField), (int)range.getMaximum()); int weekActual = yearDate.get(wowbyField); - assertEquals(weekActual, weekExpected, "Localized WeekOfWeekBasedYear week should not change; " + day + " --> " + yearDate + ", actual: " + weekActual + ", weekExpected: " + weekExpected); + assertEquals(weekExpected, weekActual, "Localized WeekOfWeekBasedYear week should not change; " + day + " --> " + yearDate + ", actual: " + weekActual + ", weekExpected: " + weekExpected); } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWom(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -388,13 +403,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.getYear() + ":" + date.getMonthValue() + ":" + date.get(womField) + ":" + date.get(DAY_OF_WEEK); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " ::" + str + "::" + i); + assertEquals(date, parsed, " ::" + str + "::" + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWom_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -411,14 +427,15 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = wom - 10; j < wom + 10; j++) { String str = date.getYear() + ":" + date.getMonthValue() + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - wom), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - wom), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWom_strict(DayOfWeek firstDayOfWeek, int minDays) { WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField womField = week.weekOfMonth(); @@ -430,17 +447,18 @@ public class TCKWeekFields extends AbstractTCKTest { String str = "2012:1:0:1"; try { LocalDate date = LocalDate.parse(str, f); - assertEquals(date.getYear(), 2012); - assertEquals(date.getMonthValue(), 1); - assertEquals(date.get(womField), 0); - assertEquals(date.get(DAY_OF_WEEK), 1); + assertEquals(2012, date.getYear()); + assertEquals(1, date.getMonthValue()); + assertEquals(0, date.get(womField)); + assertEquals(1, date.get(DAY_OF_WEEK)); } catch (DateTimeException ex) { // expected } } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWomDow(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -456,13 +474,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.getYear() + ":" + date.getMonthValue() + ":" + date.get(womField) + ":" + date.get(dowField); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " :: " + str + " " + i); + assertEquals(date, parsed, " :: " + str + " " + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWomDow_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -480,7 +499,7 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = wom - 10; j < wom + 10; j++) { String str = date.getYear() + ":" + date.getMonthValue() + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - wom), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - wom), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); @@ -488,7 +507,8 @@ public class TCKWeekFields extends AbstractTCKTest { } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoy(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -502,13 +522,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.getYear() + ":" + date.get(woyField) + ":" + date.get(DAY_OF_WEEK); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " :: " + str + " " + i); + assertEquals(date, parsed, " :: " + str + " " + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoy_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -524,14 +545,15 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = woy - 60; j < woy + 60; j++) { String str = date.getYear() + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - woy), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - woy), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoy_strict(DayOfWeek firstDayOfWeek, int minDays) { WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField woyField = week.weekOfYear(); @@ -542,16 +564,17 @@ public class TCKWeekFields extends AbstractTCKTest { String str = "2012:0:1"; try { LocalDate date = LocalDate.parse(str, f); - assertEquals(date.getYear(), 2012); - assertEquals(date.get(woyField), 0); - assertEquals(date.get(DAY_OF_WEEK), 1); + assertEquals(2012, date.getYear()); + assertEquals(0, date.get(woyField)); + assertEquals(1, date.get(DAY_OF_WEEK)); } catch (DateTimeException ex) { // expected } } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoyDow(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -567,13 +590,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.getYear() + ":" + date.getMonthValue() + ":" + date.get(woyField) + ":" + date.get(dowField); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " :: " + str + " " + i); + assertEquals(date, parsed, " :: " + str + " " + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoyDow_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -590,7 +614,7 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = woy - 60; j < woy + 60; j++) { String str = date.getYear() + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - woy), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - woy), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); @@ -598,7 +622,8 @@ public class TCKWeekFields extends AbstractTCKTest { } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoWBY(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 31); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -613,13 +638,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.get(yowbyField) + ":" + date.get(wowbyField) + ":" + date.get(DAY_OF_WEEK); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " :: " + str + " " + i); + assertEquals(date, parsed, " :: " + str + " " + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoWBY_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 31); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -636,14 +662,15 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = wowby - 60; j < wowby + 60; j++) { String str = date.get(yowbyField) + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - wowby), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - wowby), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoWBY_strict(DayOfWeek firstDayOfWeek, int minDays) { WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField wowbyField = week.weekOfWeekBasedYear(); @@ -655,16 +682,17 @@ public class TCKWeekFields extends AbstractTCKTest { String str = "2012:0:1"; try { LocalDate date = LocalDate.parse(str, f); - assertEquals(date.get(yowbyField), 2012); - assertEquals(date.get(wowbyField), 0); - assertEquals(date.get(DAY_OF_WEEK), 1); + assertEquals(2012, date.get(yowbyField)); + assertEquals(0, date.get(wowbyField)); + assertEquals(1, date.get(DAY_OF_WEEK)); } catch (DateTimeException ex) { // expected } } //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoWBYDow(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 31); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -680,13 +708,14 @@ public class TCKWeekFields extends AbstractTCKTest { String str = date.get(yowbyField) + ":" + date.get(wowbyField) + ":" + date.get(dowField); LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date, " :: " + str + " " + i); + assertEquals(date, parsed, " :: " + str + " " + i); date = date.plusDays(1); } } - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_parse_resolve_localizedWoWBYDow_lenient(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 31); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); @@ -704,7 +733,7 @@ public class TCKWeekFields extends AbstractTCKTest { for (int j = wowby - 60; j < wowby + 60; j++) { String str = date.get(yowbyField) + ":" + j + ":" + dow; LocalDate parsed = LocalDate.parse(str, f); - assertEquals(parsed, date.plusWeeks(j - wowby), " ::" + str + ": :" + i + "::" + j); + assertEquals(date.plusWeeks(j - wowby), parsed, " ::" + str + ": :" + i + "::" + j); } date = date.plusDays(1); @@ -713,7 +742,6 @@ public class TCKWeekFields extends AbstractTCKTest { //----------------------------------------------------------------------- - @DataProvider(name="weekFields") Object[][] data_weekFields() { Object[][] objects = new Object[49][]; int i = 0; @@ -726,7 +754,6 @@ public class TCKWeekFields extends AbstractTCKTest { } //----------------------------------------------------------------------- - @DataProvider(name="WeekBasedYearData") Object[][] provider_WeekBasedYearData() { return new Object[][] { {WeekFields.of(DayOfWeek.SUNDAY, 1), 2008, 52, 7, LocalDate.of(2008, 12, 27)}, @@ -741,20 +768,20 @@ public class TCKWeekFields extends AbstractTCKTest { }; } - @Test(dataProvider="WeekBasedYearData") + @ParameterizedTest + @MethodSource("provider_WeekBasedYearData") public void test_weekBasedYears(WeekFields weekDef, int weekBasedYear, int weekOfWeekBasedYear, int dayOfWeek, LocalDate date) { TemporalField dowField = weekDef.dayOfWeek(); TemporalField wowbyField = weekDef.weekOfWeekBasedYear(); TemporalField yowbyField = weekDef.weekBasedYear(); - assertEquals(date.get(dowField), dayOfWeek, "DayOfWeek mismatch"); - assertEquals(date.get(wowbyField), weekOfWeekBasedYear, "Week of WeekBasedYear mismatch"); - assertEquals(date.get(yowbyField), weekBasedYear, "Year of WeekBasedYear mismatch"); + assertEquals(dayOfWeek, date.get(dowField), "DayOfWeek mismatch"); + assertEquals(weekOfWeekBasedYear, date.get(wowbyField), "Week of WeekBasedYear mismatch"); + assertEquals(weekBasedYear, date.get(yowbyField), "Year of WeekBasedYear mismatch"); } //----------------------------------------------------------------------- - @DataProvider(name="IsoWeekData") Object[][] data_week() { return new Object[][] { {LocalDate.of(1969, 12, 29), DayOfWeek.MONDAY, 1, 1970}, @@ -776,16 +803,17 @@ public class TCKWeekFields extends AbstractTCKTest { // WEEK_OF_WEEK_BASED_YEAR // Validate with the same data used by IsoFields. //----------------------------------------------------------------------- - @Test(dataProvider="IsoWeekData") + @ParameterizedTest + @MethodSource("data_week") public void test_WOWBY(LocalDate date, DayOfWeek dow, int week, int wby) { WeekFields weekDef = WeekFields.ISO; TemporalField dowField = weekDef.dayOfWeek(); TemporalField wowbyField = weekDef.weekOfWeekBasedYear(); TemporalField yowbyField = weekDef.weekBasedYear(); - assertEquals(date.get(dowField), dow.getValue()); - assertEquals(date.get(wowbyField), week); - assertEquals(date.get(yowbyField), wby); + assertEquals(dow.getValue(), date.get(dowField)); + assertEquals(week, date.get(wowbyField)); + assertEquals(wby, date.get(yowbyField)); } //----------------------------------------------------------------------- @@ -798,11 +826,11 @@ public class TCKWeekFields extends AbstractTCKTest { assertTrue(weekDef_iso.equals(WeekFields.of(DayOfWeek.MONDAY, 4))); assertTrue(weekDef_sundayStart.equals(WeekFields.of(DayOfWeek.SUNDAY, 1))); - assertEquals(weekDef_iso.hashCode(), WeekFields.of(DayOfWeek.MONDAY, 4).hashCode()); - assertEquals(weekDef_sundayStart.hashCode(), WeekFields.of(DayOfWeek.SUNDAY, 1).hashCode()); + assertEquals(WeekFields.of(DayOfWeek.MONDAY, 4).hashCode(), weekDef_iso.hashCode()); + assertEquals(WeekFields.of(DayOfWeek.SUNDAY, 1).hashCode(), weekDef_sundayStart.hashCode()); assertFalse(weekDef_iso.equals(weekDef_sundayStart)); - assertNotEquals(weekDef_iso.hashCode(), weekDef_sundayStart.hashCode()); + assertNotEquals(weekDef_sundayStart.hashCode(), weekDef_iso.hashCode()); } } diff --git a/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoFieldSerialization.java b/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoFieldSerialization.java index bb8c5c566a5..b82a278cb34 100644 --- a/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoFieldSerialization.java +++ b/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoFieldSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -86,21 +86,21 @@ import static java.time.temporal.ChronoField.ERA; import java.io.IOException; import java.time.temporal.ChronoField; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import tck.java.time.AbstractTCKTest; /** * Test serialization of ChronoField. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKChronoFieldSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- // List of Fields //----------------------------------------------------------------------- - @DataProvider(name="fieldBased") Object[][] data_fieldBased() { return new Object[][] { {DAY_OF_WEEK}, @@ -135,7 +135,8 @@ public class TCKChronoFieldSerialization extends AbstractTCKTest { }; } - @Test(dataProvider = "fieldBased") + @ParameterizedTest + @MethodSource("data_fieldBased") public void test_fieldSerializable(ChronoField field) throws IOException, ClassNotFoundException { assertSerializableSame(field); } diff --git a/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoUnitSerialization.java b/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoUnitSerialization.java index e97e183d252..9714220b7be 100644 --- a/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoUnitSerialization.java +++ b/test/jdk/java/time/tck/java/time/temporal/serial/TCKChronoUnitSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -74,21 +74,21 @@ import static java.time.temporal.ChronoUnit.YEARS; import java.io.IOException; import java.time.temporal.ChronoUnit; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import tck.java.time.AbstractTCKTest; /** * Test. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKChronoUnitSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- // ChronoUnits //----------------------------------------------------------------------- - @DataProvider(name="chronoUnit") Object[][] data_chronoUnit() { return new Object[][] { {FOREVER}, @@ -112,7 +112,8 @@ public class TCKChronoUnitSerialization extends AbstractTCKTest { }; } - @Test(dataProvider = "chronoUnit") + @ParameterizedTest + @MethodSource("data_chronoUnit") public void test_unitType(ChronoUnit unit) throws IOException, ClassNotFoundException { assertSerializableSame(unit); } diff --git a/test/jdk/java/time/tck/java/time/temporal/serial/TCKJulianFieldsSerialization.java b/test/jdk/java/time/tck/java/time/temporal/serial/TCKJulianFieldsSerialization.java index 53047f8441a..a861290ac0e 100644 --- a/test/jdk/java/time/tck/java/time/temporal/serial/TCKJulianFieldsSerialization.java +++ b/test/jdk/java/time/tck/java/time/temporal/serial/TCKJulianFieldsSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -63,19 +63,19 @@ import java.io.IOException; import java.time.temporal.JulianFields; import java.time.temporal.TemporalField; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import tck.java.time.AbstractTCKTest; /** * Test serialization of JulianFields */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKJulianFieldsSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- - @DataProvider(name="julian_fields") Object[][] julian_samples() { return new Object[][] { {JulianFields.JULIAN_DAY}, @@ -86,7 +86,8 @@ public class TCKJulianFieldsSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- - @Test(dataProvider="julian_fields") + @ParameterizedTest + @MethodSource("julian_samples") public void test_serializable(TemporalField field) throws IOException, ClassNotFoundException { assertSerializable(field); } diff --git a/test/jdk/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java b/test/jdk/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java index d99efd03535..a3612e7f6a6 100644 --- a/test/jdk/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java +++ b/test/jdk/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,7 @@ */ package tck.java.time.temporal.serial; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -71,19 +70,20 @@ import java.io.ObjectOutputStream; import java.time.temporal.ValueRange; import java.util.Arrays; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tck.java.time.AbstractTCKTest; /** * Test serialization of ValueRange. */ -@Test public class TCKValueRangeSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- // Serialization //----------------------------------------------------------------------- + @Test public void test_serialization() throws Exception { ValueRange range = ValueRange.of(1, 2, 3, 4); assertSerializable(range); @@ -94,6 +94,7 @@ public class TCKValueRangeSerialization extends AbstractTCKTest { * Verify Serialized bytes of a ValueRange. * @throws IOException if thrown during serialization is an unexpected test tailure */ + @Test public void test_valueRangeSerialized() throws IOException { byte[] expected = { (byte)172, (byte)237, 0, 5, 115, 114, 0, 29, 106, 97, /* \u00ac \u00ed \u0000 \u0005 s r \u0000 \u001d j a */ @@ -118,7 +119,7 @@ public class TCKValueRangeSerialization extends AbstractTCKTest { oos.writeObject(range); byte[] actual = baos.toByteArray(); - assertEquals(actual, expected, "Serialized bytes incorrect"); + Assertions.assertArrayEquals(expected, actual, "Serialized bytes incorrect"); } } diff --git a/test/jdk/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java b/test/jdk/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java index 3523f05c88c..34171276cd1 100644 --- a/test/jdk/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java +++ b/test/jdk/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -54,13 +54,11 @@ */ package tck.java.time.temporal.serial; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import tck.java.time.AbstractTCKTest; import java.io.IOException; @@ -70,21 +68,26 @@ import java.time.DayOfWeek; import java.time.temporal.WeekFields; import java.util.Arrays; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + /** * Test serialization of WeekFields. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKWeekFieldsSerialization extends AbstractTCKTest { //----------------------------------------------------------------------- - @Test(dataProvider="weekFields") + @ParameterizedTest + @MethodSource("data_weekFields") public void test_serializable_singleton(DayOfWeek firstDayOfWeek, int minDays) throws IOException, ClassNotFoundException { WeekFields weekDef = WeekFields.of(firstDayOfWeek, minDays); assertSerializableSame(weekDef); // spec state singleton } //----------------------------------------------------------------------- - @DataProvider(name="weekFields") Object[][] data_weekFields() { Object[][] objects = new Object[49][]; int i = 0; @@ -110,7 +113,7 @@ public class TCKWeekFieldsSerialization extends AbstractTCKTest { System.arraycopy(good1, 0, val, 105, good1.length); try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(val))) { Object o = in.readObject(); - assertEquals(o, WeekFields.of(DayOfWeek.MONDAY, 5), "Should be MONDAY, min = 5"); + assertEquals(WeekFields.of(DayOfWeek.MONDAY, 5), o, "Should be MONDAY, min = 5"); } catch (Exception ioe) { fail("Unexpected exception " + ioe); } diff --git a/test/jdk/java/time/tck/java/time/zone/TCKFixedZoneRules.java b/test/jdk/java/time/tck/java/time/zone/TCKFixedZoneRules.java index 08df5433349..83d8af37306 100644 --- a/test/jdk/java/time/tck/java/time/zone/TCKFixedZoneRules.java +++ b/test/jdk/java/time/tck/java/time/zone/TCKFixedZoneRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,7 +59,7 @@ */ package tck.java.time.zone; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -76,13 +76,16 @@ import java.time.zone.ZoneOffsetTransitionRule; import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; import java.time.zone.ZoneRules; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test ZoneRules for fixed offset time-zones. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKFixedZoneRules { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); @@ -95,7 +98,6 @@ public class TCKFixedZoneRules { return offset.getRules(); } - @DataProvider(name="rules") Object[][] data_rules() { return new Object[][] { {make(OFFSET_PONE), OFFSET_PONE}, @@ -108,95 +110,111 @@ public class TCKFixedZoneRules { // Basics //----------------------------------------------------------------------- - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getOffset_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getOffset(INSTANT), expectedOffset); - assertEquals(test.getOffset((Instant) null), expectedOffset); + assertEquals(expectedOffset, test.getOffset(INSTANT)); + assertEquals(expectedOffset, test.getOffset((Instant) null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getOffset_LocalDateTime(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getOffset(LDT), expectedOffset); - assertEquals(test.getOffset((LocalDateTime) null), expectedOffset); + assertEquals(expectedOffset, test.getOffset(LDT)); + assertEquals(expectedOffset, test.getOffset((LocalDateTime) null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getValidOffsets_LDT(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getValidOffsets(LDT).size(), 1); - assertEquals(test.getValidOffsets(LDT).get(0), expectedOffset); - assertEquals(test.getValidOffsets(null).size(), 1); - assertEquals(test.getValidOffsets(null).get(0), expectedOffset); + assertEquals(1, test.getValidOffsets(LDT).size()); + assertEquals(expectedOffset, test.getValidOffsets(LDT).get(0)); + assertEquals(1, test.getValidOffsets(null).size()); + assertEquals(expectedOffset, test.getValidOffsets(null).get(0)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getTransition_LDT(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getTransition(LDT), null); - assertEquals(test.getTransition(null), null); + assertEquals(null, test.getTransition(LDT)); + assertEquals(null, test.getTransition(null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_isValidOffset_LDT_ZO(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.isValidOffset(LDT, expectedOffset), true); - assertEquals(test.isValidOffset(LDT, ZoneOffset.UTC), false); - assertEquals(test.isValidOffset(LDT, null), false); + assertEquals(true, test.isValidOffset(LDT, expectedOffset)); + assertEquals(false, test.isValidOffset(LDT, ZoneOffset.UTC)); + assertEquals(false, test.isValidOffset(LDT, null)); - assertEquals(test.isValidOffset(null, expectedOffset), true); - assertEquals(test.isValidOffset(null, ZoneOffset.UTC), false); - assertEquals(test.isValidOffset(null, null), false); + assertEquals(true, test.isValidOffset(null, expectedOffset)); + assertEquals(false, test.isValidOffset(null, ZoneOffset.UTC)); + assertEquals(false, test.isValidOffset(null, null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getStandardOffset_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getStandardOffset(INSTANT), expectedOffset); - assertEquals(test.getStandardOffset(null), expectedOffset); + assertEquals(expectedOffset, test.getStandardOffset(INSTANT)); + assertEquals(expectedOffset, test.getStandardOffset(null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getDaylightSavings_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getDaylightSavings(INSTANT), Duration.ZERO); - assertEquals(test.getDaylightSavings(null), Duration.ZERO); + assertEquals(Duration.ZERO, test.getDaylightSavings(INSTANT)); + assertEquals(Duration.ZERO, test.getDaylightSavings(null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_isDaylightSavings_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.isDaylightSavings(INSTANT), false); - assertEquals(test.isDaylightSavings(null), false); + assertEquals(false, test.isDaylightSavings(INSTANT)); + assertEquals(false, test.isDaylightSavings(null)); } //------------------------------------------------------------------------- - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_nextTransition_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.nextTransition(INSTANT), null); - assertEquals(test.nextTransition(null), null); + assertEquals(null, test.nextTransition(INSTANT)); + assertEquals(null, test.nextTransition(null)); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_previousTransition_Instant(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.previousTransition(INSTANT), null); - assertEquals(test.previousTransition(null), null); + assertEquals(null, test.previousTransition(INSTANT)); + assertEquals(null, test.previousTransition(null)); } //------------------------------------------------------------------------- - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getTransitions(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getTransitions().size(), 0); + assertEquals(0, test.getTransitions().size()); } - @Test(expectedExceptions=UnsupportedOperationException.class) + @Test public void test_getTransitions_immutable() { - ZoneRules test = make(OFFSET_PTWO); - test.getTransitions().add(ZoneOffsetTransition.of(LDT, OFFSET_PONE, OFFSET_PTWO)); + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + ZoneRules test = make(OFFSET_PTWO); + test.getTransitions().add(ZoneOffsetTransition.of(LDT, OFFSET_PONE, OFFSET_PTWO)); + }); } - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_getTransitionRules(ZoneRules test, ZoneOffset expectedOffset) { - assertEquals(test.getTransitionRules().size(), 0); + assertEquals(0, test.getTransitionRules().size()); } - @Test(expectedExceptions=UnsupportedOperationException.class) + @Test public void test_getTransitionRules_immutable() { - ZoneRules test = make(OFFSET_PTWO); - test.getTransitionRules().add(ZoneOffsetTransitionRule.of(Month.JULY, 2, null, LocalTime.of(12, 30), false, TimeDefinition.STANDARD, OFFSET_PONE, OFFSET_PTWO, OFFSET_PONE)); + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + ZoneRules test = make(OFFSET_PTWO); + test.getTransitionRules().add(ZoneOffsetTransitionRule.of(Month.JULY, 2, null, LocalTime.of(12, 30), false, TimeDefinition.STANDARD, OFFSET_PONE, OFFSET_PTWO, OFFSET_PONE)); + }); } //----------------------------------------------------------------------- @@ -207,16 +225,16 @@ public class TCKFixedZoneRules { ZoneRules a = make(OFFSET_PONE); ZoneRules b = make(OFFSET_PTWO); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); - assertEquals(a.equals("Rubbish"), false); - assertEquals(a.equals(null), false); + assertEquals(false, a.equals("Rubbish")); + assertEquals(false, a.equals(null)); - assertEquals(a.hashCode() == a.hashCode(), true); - assertEquals(b.hashCode() == b.hashCode(), true); + assertEquals(true, a.hashCode() == a.hashCode()); + assertEquals(true, b.hashCode() == b.hashCode()); } } diff --git a/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java b/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java index 9cd42624bfa..241da3d0519 100644 --- a/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java +++ b/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,7 +60,8 @@ package tck.java.time.zone; import static java.time.temporal.ChronoUnit.HOURS; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.Duration; import java.time.LocalDateTime; @@ -68,13 +69,14 @@ import java.time.Year; import java.time.ZoneOffset; import java.time.zone.ZoneOffsetTransition; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransition. */ -@Test public class TCKZoneOffsetTransition extends AbstractTCKTest { private static final ZoneOffset OFFSET_0100 = ZoneOffset.ofHours(1); @@ -86,29 +88,29 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { //----------------------------------------------------------------------- // factory //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullTransition() { - ZoneOffsetTransition.of(null, OFFSET_0100, OFFSET_0200); + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransition.of(null, OFFSET_0100, OFFSET_0200)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullOffsetBefore() { - ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), null, OFFSET_0200); + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), null, OFFSET_0200)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullOffsetAfter() { - ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, null); + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, null)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_sameOffset() { - ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, OFFSET_0200); + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, OFFSET_0200)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_noNanos() { - ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30, 0, 500), OFFSET_0200, OFFSET_0300); + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30, 0, 500), OFFSET_0200, OFFSET_0300)); } //----------------------------------------------------------------------- @@ -119,14 +121,14 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { LocalDateTime before = LocalDateTime.of(2010, 3, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 3, 31, 2, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0200, OFFSET_0300); - assertEquals(test.isGap(), true); - assertEquals(test.isOverlap(), false); - assertEquals(test.getDateTimeBefore(), before); - assertEquals(test.getDateTimeAfter(), after); - assertEquals(test.getInstant(), before.toInstant(OFFSET_0200)); - assertEquals(test.getOffsetBefore(), OFFSET_0200); - assertEquals(test.getOffsetAfter(), OFFSET_0300); - assertEquals(test.getDuration(), Duration.of(1, HOURS)); + assertEquals(true, test.isGap()); + assertEquals(false, test.isOverlap()); + assertEquals(before, test.getDateTimeBefore()); + assertEquals(after, test.getDateTimeAfter()); + assertEquals(before.toInstant(OFFSET_0200), test.getInstant()); + assertEquals(OFFSET_0200, test.getOffsetBefore()); + assertEquals(OFFSET_0300, test.getOffsetAfter()); + assertEquals(Duration.of(1, HOURS), test.getDuration()); } @Test @@ -134,14 +136,14 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { LocalDateTime before = LocalDateTime.of(2010, 10, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 10, 31, 0, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0300, OFFSET_0200); - assertEquals(test.isGap(), false); - assertEquals(test.isOverlap(), true); - assertEquals(test.getDateTimeBefore(), before); - assertEquals(test.getDateTimeAfter(), after); - assertEquals(test.getInstant(), before.toInstant(OFFSET_0300)); - assertEquals(test.getOffsetBefore(), OFFSET_0300); - assertEquals(test.getOffsetAfter(), OFFSET_0200); - assertEquals(test.getDuration(), Duration.of(-1, HOURS)); + assertEquals(false, test.isGap()); + assertEquals(true, test.isOverlap()); + assertEquals(before, test.getDateTimeBefore()); + assertEquals(after, test.getDateTimeAfter()); + assertEquals(before.toInstant(OFFSET_0300), test.getInstant()); + assertEquals(OFFSET_0300, test.getOffsetBefore()); + assertEquals(OFFSET_0200, test.getOffsetAfter()); + assertEquals(Duration.of(-1, HOURS), test.getDuration()); } @@ -152,22 +154,22 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { public void test_isValidOffset_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); - assertEquals(test.isValidOffset(OFFSET_0100), false); - assertEquals(test.isValidOffset(OFFSET_0200), false); - assertEquals(test.isValidOffset(OFFSET_0230), false); - assertEquals(test.isValidOffset(OFFSET_0300), false); - assertEquals(test.isValidOffset(OFFSET_0400), false); + assertEquals(false, test.isValidOffset(OFFSET_0100)); + assertEquals(false, test.isValidOffset(OFFSET_0200)); + assertEquals(false, test.isValidOffset(OFFSET_0230)); + assertEquals(false, test.isValidOffset(OFFSET_0300)); + assertEquals(false, test.isValidOffset(OFFSET_0400)); } @Test public void test_isValidOffset_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); - assertEquals(test.isValidOffset(OFFSET_0100), false); - assertEquals(test.isValidOffset(OFFSET_0200), true); - assertEquals(test.isValidOffset(OFFSET_0230), false); - assertEquals(test.isValidOffset(OFFSET_0300), true); - assertEquals(test.isValidOffset(OFFSET_0400), false); + assertEquals(false, test.isValidOffset(OFFSET_0100)); + assertEquals(true, test.isValidOffset(OFFSET_0200)); + assertEquals(false, test.isValidOffset(OFFSET_0230)); + assertEquals(true, test.isValidOffset(OFFSET_0300)); + assertEquals(false, test.isValidOffset(OFFSET_0400)); } //----------------------------------------------------------------------- @@ -182,17 +184,17 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { ZoneOffsetTransition c = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L + 1, 0, OFFSET_0100), OFFSET_0100,OFFSET_0400); - assertEquals(a.compareTo(a) == 0, true); - assertEquals(a.compareTo(b) < 0, true); - assertEquals(a.compareTo(c) < 0, true); + assertEquals(true, a.compareTo(a) == 0); + assertEquals(true, a.compareTo(b) < 0); + assertEquals(true, a.compareTo(c) < 0); - assertEquals(b.compareTo(a) > 0, true); - assertEquals(b.compareTo(b) == 0, true); - assertEquals(b.compareTo(c) < 0, true); + assertEquals(true, b.compareTo(a) > 0); + assertEquals(true, b.compareTo(b) == 0); + assertEquals(true, b.compareTo(c) < 0); - assertEquals(c.compareTo(a) > 0, true); - assertEquals(c.compareTo(b) > 0, true); - assertEquals(c.compareTo(c) == 0, true); + assertEquals(true, c.compareTo(a) > 0); + assertEquals(true, c.compareTo(b) > 0); + assertEquals(true, c.compareTo(c) == 0); } @Test @@ -204,17 +206,17 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { ZoneOffsetTransition c = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0100), OFFSET_0100, OFFSET_0400); - assertEquals(a.compareTo(a) == 0, true); - assertEquals(a.compareTo(b) == 0, true); - assertEquals(a.compareTo(c) == 0, true); + assertEquals(true, a.compareTo(a) == 0); + assertEquals(true, a.compareTo(b) == 0); + assertEquals(true, a.compareTo(c) == 0); - assertEquals(b.compareTo(a) == 0, true); - assertEquals(b.compareTo(b) == 0, true); - assertEquals(b.compareTo(c) == 0, true); + assertEquals(true, b.compareTo(a) == 0); + assertEquals(true, b.compareTo(b) == 0); + assertEquals(true, b.compareTo(c) == 0); - assertEquals(c.compareTo(a) == 0, true); - assertEquals(c.compareTo(b) == 0, true); - assertEquals(c.compareTo(c) == 0, true); + assertEquals(true, c.compareTo(a) == 0); + assertEquals(true, c.compareTo(b) == 0); + assertEquals(true, c.compareTo(c) == 0); } //----------------------------------------------------------------------- @@ -228,18 +230,18 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { LocalDateTime ldtB = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition b = ZoneOffsetTransition.of(ldtB, OFFSET_0300, OFFSET_0200); - assertEquals(a1.equals(a1), true); - assertEquals(a1.equals(a2), true); - assertEquals(a1.equals(b), false); - assertEquals(a2.equals(a1), true); - assertEquals(a2.equals(a2), true); - assertEquals(a2.equals(b), false); - assertEquals(b.equals(a1), false); - assertEquals(b.equals(a2), false); - assertEquals(b.equals(b), true); + assertEquals(true, a1.equals(a1)); + assertEquals(true, a1.equals(a2)); + assertEquals(false, a1.equals(b)); + assertEquals(true, a2.equals(a1)); + assertEquals(true, a2.equals(a2)); + assertEquals(false, a2.equals(b)); + assertEquals(false, b.equals(a1)); + assertEquals(false, b.equals(a2)); + assertEquals(true, b.equals(b)); - assertEquals(a1.equals(""), false); - assertEquals(a1.equals(null), false); + assertEquals(false, a1.equals("")); + assertEquals(false, a1.equals(null)); } //----------------------------------------------------------------------- @@ -254,7 +256,7 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { ZoneOffsetTransition b = ZoneOffsetTransition.of(ldtB, OFFSET_0300, OFFSET_0200); assertEquals(a1.hashCode(), a1.hashCode()); - assertEquals(a1.hashCode(), a2.hashCode()); + assertEquals(a2.hashCode(), a1.hashCode()); assertEquals(b.hashCode(), b.hashCode()); } @@ -265,14 +267,14 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { public void test_toString_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); - assertEquals(test.toString(), "Transition[Gap at 2010-03-31T01:00+02:00 to +03:00]"); + assertEquals("Transition[Gap at 2010-03-31T01:00+02:00 to +03:00]", test.toString()); } @Test public void test_toString_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); - assertEquals(test.toString(), "Transition[Overlap at 2010-10-31T01:00+03:00 to +02:00]"); + assertEquals("Transition[Overlap at 2010-10-31T01:00+03:00 to +02:00]", test.toString()); } } diff --git a/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java b/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java index 3c0c14c1ca6..e12251c6874 100644 --- a/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java +++ b/test/jdk/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,7 +59,7 @@ */ package tck.java.time.zone; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DayOfWeek; import java.time.LocalDateTime; @@ -70,13 +70,14 @@ import java.time.zone.ZoneOffsetTransition; import java.time.zone.ZoneOffsetTransitionRule; import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransitionRule. */ -@Test public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { private static final LocalTime TIME_0100 = LocalTime.of(1, 0); @@ -86,81 +87,81 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { //----------------------------------------------------------------------- // factory //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullMonth() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( null, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullTime() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, null, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullTimeDefinition() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, null, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullStandardOffset() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - null, OFFSET_0200, OFFSET_0300); + null, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullOffsetBefore() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, null, OFFSET_0300); + OFFSET_0200, null, OFFSET_0300)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_factory_nullOffsetAfter() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(NullPointerException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, null); + OFFSET_0200, OFFSET_0200, null)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_invalidDayOfMonthIndicator_tooSmall() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, -29, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_invalidDayOfMonthIndicator_zero() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 0, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_invalidDayOfMonthIndicator_tooLarge() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 32, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_invalidMidnightFlag() { - ZoneOffsetTransitionRule.of( + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, true, TimeDefinition.WALL, - OFFSET_0200, OFFSET_0200, OFFSET_0300); + OFFSET_0200, OFFSET_0200, OFFSET_0300)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_factory_nonZeroTimeNanos() { - ZoneOffsetTransitionRule.of( - Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.of(1, 2, 3, 400_000_000), - false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); + Assertions.assertThrows(IllegalArgumentException.class, () -> ZoneOffsetTransitionRule.of( + Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.of(1, 2, 3, 400_000_000), + false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300)); } //----------------------------------------------------------------------- @@ -171,15 +172,15 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.getMonth(), Month.MARCH); - assertEquals(test.getDayOfMonthIndicator(), 20); - assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY); - assertEquals(test.getLocalTime(), TIME_0100); - assertEquals(test.isMidnightEndOfDay(), false); - assertEquals(test.getTimeDefinition(), TimeDefinition.WALL); - assertEquals(test.getStandardOffset(), OFFSET_0200); - assertEquals(test.getOffsetBefore(), OFFSET_0200); - assertEquals(test.getOffsetAfter(), OFFSET_0300); + assertEquals(Month.MARCH, test.getMonth()); + assertEquals(20, test.getDayOfMonthIndicator()); + assertEquals(DayOfWeek.SUNDAY, test.getDayOfWeek()); + assertEquals(TIME_0100, test.getLocalTime()); + assertEquals(false, test.isMidnightEndOfDay()); + assertEquals(TimeDefinition.WALL, test.getTimeDefinition()); + assertEquals(OFFSET_0200, test.getStandardOffset()); + assertEquals(OFFSET_0200, test.getOffsetBefore()); + assertEquals(OFFSET_0300, test.getOffsetAfter()); } @Test @@ -187,15 +188,15 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.getMonth(), Month.MARCH); - assertEquals(test.getDayOfMonthIndicator(), -1); - assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY); - assertEquals(test.getLocalTime(), TIME_0100); - assertEquals(test.isMidnightEndOfDay(), false); - assertEquals(test.getTimeDefinition(), TimeDefinition.WALL); - assertEquals(test.getStandardOffset(), OFFSET_0200); - assertEquals(test.getOffsetBefore(), OFFSET_0200); - assertEquals(test.getOffsetAfter(), OFFSET_0300); + assertEquals(Month.MARCH, test.getMonth()); + assertEquals(-1, test.getDayOfMonthIndicator()); + assertEquals(DayOfWeek.SUNDAY, test.getDayOfWeek()); + assertEquals(TIME_0100, test.getLocalTime()); + assertEquals(false, test.isMidnightEndOfDay()); + assertEquals(TimeDefinition.WALL, test.getTimeDefinition()); + assertEquals(OFFSET_0200, test.getStandardOffset()); + assertEquals(OFFSET_0200, test.getOffsetBefore()); + assertEquals(OFFSET_0300, test.getOffsetAfter()); } @Test @@ -203,15 +204,15 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.getMonth(), Month.MARCH); - assertEquals(test.getDayOfMonthIndicator(), 20); - assertEquals(test.getDayOfWeek(), null); - assertEquals(test.getLocalTime(), TIME_0100); - assertEquals(test.isMidnightEndOfDay(), false); - assertEquals(test.getTimeDefinition(), TimeDefinition.WALL); - assertEquals(test.getStandardOffset(), OFFSET_0200); - assertEquals(test.getOffsetBefore(), OFFSET_0200); - assertEquals(test.getOffsetAfter(), OFFSET_0300); + assertEquals(Month.MARCH, test.getMonth()); + assertEquals(20, test.getDayOfMonthIndicator()); + assertEquals(null, test.getDayOfWeek()); + assertEquals(TIME_0100, test.getLocalTime()); + assertEquals(false, test.isMidnightEndOfDay()); + assertEquals(TimeDefinition.WALL, test.getTimeDefinition()); + assertEquals(OFFSET_0200, test.getStandardOffset()); + assertEquals(OFFSET_0200, test.getOffsetBefore()); + assertEquals(OFFSET_0300, test.getOffsetAfter()); } @@ -225,7 +226,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } @Test @@ -235,7 +236,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0300, OFFSET_0200); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 27, 0, 0), OFFSET_0300, OFFSET_0200); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } @Test @@ -245,7 +246,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } @Test @@ -255,7 +256,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 19, 1, 0), OFFSET_0200, OFFSET_0300); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } @Test @@ -265,7 +266,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } @Test @@ -275,7 +276,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 20, 1, 0), OFFSET_0200, OFFSET_0300); - assertEquals(test.createTransition(2000), trans); + assertEquals(trans, test.createTransition(2000)); } //----------------------------------------------------------------------- @@ -289,10 +290,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.APRIL, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -303,10 +304,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 21, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -317,10 +318,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SATURDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -331,10 +332,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -345,10 +346,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -359,10 +360,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -373,10 +374,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -387,10 +388,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0300, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -401,10 +402,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0300); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -415,10 +416,10 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0200); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), false); - assertEquals(b.equals(a), false); - assertEquals(b.equals(b), true); + assertEquals(true, a.equals(a)); + assertEquals(false, a.equals(b)); + assertEquals(false, b.equals(a)); + assertEquals(true, b.equals(b)); } @Test @@ -426,7 +427,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals("TZDB"), false); + assertEquals(false, a.equals("TZDB")); } @Test @@ -434,7 +435,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.equals(null), false); + assertEquals(false, a.equals(null)); } //----------------------------------------------------------------------- @@ -448,7 +449,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.hashCode(), b.hashCode()); + assertEquals(b.hashCode(), a.hashCode()); } @Test @@ -459,7 +460,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, null, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0200); - assertEquals(a.hashCode(), b.hashCode()); + assertEquals(b.hashCode(), a.hashCode()); } @Test @@ -470,7 +471,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.hashCode(), b.hashCode()); + assertEquals(b.hashCode(), a.hashCode()); } @Test @@ -481,7 +482,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(a.hashCode(), b.hashCode()); + assertEquals(b.hashCode(), a.hashCode()); } //----------------------------------------------------------------------- @@ -492,7 +493,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or after MARCH 20 at 01:00 WALL, standard offset +02:00]"); + assertEquals("TransitionRule[Gap +02:00 to +03:00, SUNDAY on or after MARCH 20 at 01:00 WALL, standard offset +02:00]", test.toString()); } @Test @@ -500,7 +501,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0200); - assertEquals(test.toString(), "TransitionRule[Overlap +03:00 to +02:00, SUNDAY on or after OCTOBER 20 at 24:00 WALL, standard offset +02:00]"); + assertEquals("TransitionRule[Overlap +03:00 to +02:00, SUNDAY on or after OCTOBER 20 at 24:00 WALL, standard offset +02:00]", test.toString()); } @Test @@ -508,7 +509,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day of MARCH at 01:00 WALL, standard offset +02:00]"); + assertEquals("TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day of MARCH at 01:00 WALL, standard offset +02:00]", test.toString()); } @Test @@ -516,7 +517,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day minus 1 of MARCH at 01:00 WALL, standard offset +02:00]"); + assertEquals("TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day minus 1 of MARCH at 01:00 WALL, standard offset +02:00]", test.toString()); } @Test @@ -524,7 +525,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); - assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, MARCH 20 at 01:00 STANDARD, standard offset +02:00]"); + assertEquals("TransitionRule[Gap +02:00 to +03:00, MARCH 20 at 01:00 STANDARD, standard offset +02:00]", test.toString()); } } diff --git a/test/jdk/java/time/tck/java/time/zone/TCKZoneRules.java b/test/jdk/java/time/tck/java/time/zone/TCKZoneRules.java index d44216b69b5..265555a1792 100644 --- a/test/jdk/java/time/tck/java/time/zone/TCKZoneRules.java +++ b/test/jdk/java/time/tck/java/time/zone/TCKZoneRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,10 +59,10 @@ */ package tck.java.time.zone; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -88,12 +88,12 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test ZoneRules. */ -@Test public class TCKZoneRules { private static final ZoneOffset OFFSET_ZERO = ZoneOffset.ofHours(0); @@ -115,7 +115,7 @@ public class TCKZoneRules { @Test public void test_London() { ZoneRules test = europeLondon(); - assertEquals(test.isFixedOffset(), false); + assertEquals(false, test.isFixedOffset()); } @Test @@ -124,60 +124,60 @@ public class TCKZoneRules { ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, -1, -15); - assertEquals(test.getOffset(instant), offset); + assertEquals(offset, test.getOffset(instant)); checkOffset(test, old.toLocalDateTime(), offset, 1); - assertEquals(test.getStandardOffset(instant), offset); - assertEquals(test.getDaylightSavings(instant), Duration.ZERO); - assertEquals(test.isDaylightSavings(instant), false); + assertEquals(offset, test.getStandardOffset(instant)); + assertEquals(Duration.ZERO, test.getDaylightSavings(instant)); + assertEquals(false, test.isDaylightSavings(instant)); } @Test public void test_London_getOffset() { ZoneRules test = europeLondon(); - assertEquals(test.getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC)), OFFSET_ZERO); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC))); } @Test public void test_London_getOffset_toDST() { ZoneRules test = europeLondon(); - assertEquals(test.getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC)), OFFSET_PONE); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_PONE); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC))); } @Test public void test_London_getOffset_fromDST() { ZoneRules test = europeLondon(); - assertEquals(test.getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC)), OFFSET_ZERO); - assertEquals(test.getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC)), OFFSET_ZERO); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_ZERO); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(OFFSET_ZERO, test.getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC))); } @Test @@ -234,17 +234,17 @@ public class TCKZoneRules { ZoneRules test = europeLondon(); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 30, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_ZERO, GAP); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.getOffsetBefore(), OFFSET_ZERO); - assertEquals(trans.getOffsetAfter(), OFFSET_PONE); - assertEquals(trans.getInstant(), createInstant(2008, 3, 30, 1, 0, ZoneOffset.UTC)); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2008, 3, 30, 1, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2008, 3, 30, 2, 0)); - assertEquals(trans.isValidOffset(OFFSET_ZERO), false); - assertEquals(trans.isValidOffset(OFFSET_PONE), false); - assertEquals(trans.isValidOffset(OFFSET_PTWO), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-30T01:00Z to +01:00]"); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(OFFSET_ZERO, trans.getOffsetBefore()); + assertEquals(OFFSET_PONE, trans.getOffsetAfter()); + assertEquals(createInstant(2008, 3, 30, 1, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(LocalDateTime.of(2008, 3, 30, 1, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(2008, 3, 30, 2, 0), trans.getDateTimeAfter()); + assertEquals(false, trans.isValidOffset(OFFSET_ZERO)); + assertEquals(false, trans.isValidOffset(OFFSET_PONE)); + assertEquals(false, trans.isValidOffset(OFFSET_PTWO)); + assertEquals("Transition[Gap at 2008-03-30T01:00Z to +01:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(OFFSET_ZERO)); @@ -252,7 +252,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -260,18 +260,18 @@ public class TCKZoneRules { ZoneRules test = europeLondon(); final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_PONE, OVERLAP); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.getOffsetBefore(), OFFSET_PONE); - assertEquals(trans.getOffsetAfter(), OFFSET_ZERO); - assertEquals(trans.getInstant(), createInstant(2008, 10, 26, 1, 0, ZoneOffset.UTC)); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2008, 10, 26, 2, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2008, 10, 26, 1, 0)); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false); - assertEquals(trans.isValidOffset(OFFSET_ZERO), true); - assertEquals(trans.isValidOffset(OFFSET_PONE), true); - assertEquals(trans.isValidOffset(OFFSET_PTWO), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T02:00+01:00 to Z]"); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(OFFSET_PONE, trans.getOffsetBefore()); + assertEquals(OFFSET_ZERO, trans.getOffsetAfter()); + assertEquals(createInstant(2008, 10, 26, 1, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(LocalDateTime.of(2008, 10, 26, 2, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(2008, 10, 26, 1, 0), trans.getDateTimeAfter()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-1))); + assertEquals(true, trans.isValidOffset(OFFSET_ZERO)); + assertEquals(true, trans.isValidOffset(OFFSET_PONE)); + assertEquals(false, trans.isValidOffset(OFFSET_PTWO)); + assertEquals("Transition[Overlap at 2008-10-26T02:00+01:00 to Z]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(OFFSET_PONE)); @@ -279,7 +279,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -289,11 +289,11 @@ public class TCKZoneRules { while (zdt.getYear() < 2010) { Instant instant = zdt.toInstant(); if (zdt.getYear() < 1848) { - assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15)); + assertEquals(ZoneOffset.ofHoursMinutesSeconds(0, -1, -15), test.getStandardOffset(instant)); } else if (zdt.getYear() >= 1969 && zdt.getYear() < 1972) { - assertEquals(test.getStandardOffset(instant), OFFSET_PONE); + assertEquals(OFFSET_PONE, test.getStandardOffset(instant)); } else { - assertEquals(test.getStandardOffset(instant), OFFSET_ZERO); + assertEquals(OFFSET_ZERO, test.getStandardOffset(instant)); } zdt = zdt.plusMonths(6); } @@ -305,19 +305,19 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition first = trans.get(0); - assertEquals(first.getDateTimeBefore(), LocalDateTime.of(1847, 12, 1, 0, 0)); - assertEquals(first.getOffsetBefore(), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15)); - assertEquals(first.getOffsetAfter(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1847, 12, 1, 0, 0), first.getDateTimeBefore()); + assertEquals(ZoneOffset.ofHoursMinutesSeconds(0, -1, -15), first.getOffsetBefore()); + assertEquals(OFFSET_ZERO, first.getOffsetAfter()); ZoneOffsetTransition spring1916 = trans.get(1); - assertEquals(spring1916.getDateTimeBefore(), LocalDateTime.of(1916, 5, 21, 2, 0)); - assertEquals(spring1916.getOffsetBefore(), OFFSET_ZERO); - assertEquals(spring1916.getOffsetAfter(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1916, 5, 21, 2, 0), spring1916.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, spring1916.getOffsetBefore()); + assertEquals(OFFSET_PONE, spring1916.getOffsetAfter()); ZoneOffsetTransition autumn1916 = trans.get(2); - assertEquals(autumn1916.getDateTimeBefore(), LocalDateTime.of(1916, 10, 1, 3, 0)); - assertEquals(autumn1916.getOffsetBefore(), OFFSET_PONE); - assertEquals(autumn1916.getOffsetAfter(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1916, 10, 1, 3, 0), autumn1916.getDateTimeBefore()); + assertEquals(OFFSET_PONE, autumn1916.getOffsetBefore()); + assertEquals(OFFSET_ZERO, autumn1916.getOffsetAfter()); ZoneOffsetTransition zot = null; Iterator it = trans.iterator(); @@ -327,81 +327,81 @@ public class TCKZoneRules { break; } } - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 3, 25, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1990, 3, 25, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 10, 28, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1990, 10, 28, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 3, 31, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1991, 3, 31, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 10, 27, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1991, 10, 27, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 3, 29, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1992, 3, 29, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 10, 25, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1992, 10, 25, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 3, 28, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1993, 3, 28, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 10, 24, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1993, 10, 24, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 3, 27, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1994, 3, 27, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 10, 23, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1994, 10, 23, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 3, 26, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1995, 3, 26, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 10, 22, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1995, 10, 22, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 3, 31, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1996, 3, 31, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 10, 27, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); + assertEquals(LocalDateTime.of(1996, 10, 27, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 3, 30, 1, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_ZERO); + assertEquals(LocalDateTime.of(1997, 3, 30, 1, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_ZERO, zot.getOffsetBefore()); zot = it.next(); - assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 10, 26, 2, 0)); - assertEquals(zot.getOffsetBefore(), OFFSET_PONE); - assertEquals(it.hasNext(), false); + assertEquals(LocalDateTime.of(1997, 10, 26, 2, 0), zot.getDateTimeBefore()); + assertEquals(OFFSET_PONE, zot.getOffsetBefore()); + assertEquals(false, it.hasNext()); } @Test public void test_London_getTransitionRules() { ZoneRules test = europeLondon(); List rules = test.getTransitionRules(); - assertEquals(rules.size(), 2); + assertEquals(2, rules.size()); ZoneOffsetTransitionRule in = rules.get(0); - assertEquals(in.getMonth(), Month.MARCH); - assertEquals(in.getDayOfMonthIndicator(), 25); // optimized from -1 - assertEquals(in.getDayOfWeek(), DayOfWeek.SUNDAY); - assertEquals(in.getLocalTime(), LocalTime.of(1, 0)); - assertEquals(in.getTimeDefinition(), TimeDefinition.UTC); - assertEquals(in.getStandardOffset(), OFFSET_ZERO); - assertEquals(in.getOffsetBefore(), OFFSET_ZERO); - assertEquals(in.getOffsetAfter(), OFFSET_PONE); + assertEquals(Month.MARCH, in.getMonth()); + assertEquals(25, in.getDayOfMonthIndicator()); // optimized from -1 + assertEquals(DayOfWeek.SUNDAY, in.getDayOfWeek()); + assertEquals(LocalTime.of(1, 0), in.getLocalTime()); + assertEquals(TimeDefinition.UTC, in.getTimeDefinition()); + assertEquals(OFFSET_ZERO, in.getStandardOffset()); + assertEquals(OFFSET_ZERO, in.getOffsetBefore()); + assertEquals(OFFSET_PONE, in.getOffsetAfter()); ZoneOffsetTransitionRule out = rules.get(1); - assertEquals(out.getMonth(), Month.OCTOBER); - assertEquals(out.getDayOfMonthIndicator(), 25); // optimized from -1 - assertEquals(out.getDayOfWeek(), DayOfWeek.SUNDAY); - assertEquals(out.getLocalTime(), LocalTime.of(1, 0)); - assertEquals(out.getTimeDefinition(), TimeDefinition.UTC); - assertEquals(out.getStandardOffset(), OFFSET_ZERO); - assertEquals(out.getOffsetBefore(), OFFSET_PONE); - assertEquals(out.getOffsetAfter(), OFFSET_ZERO); + assertEquals(Month.OCTOBER, out.getMonth()); + assertEquals(25, out.getDayOfMonthIndicator()); // optimized from -1 + assertEquals(DayOfWeek.SUNDAY, out.getDayOfWeek()); + assertEquals(LocalTime.of(1, 0), out.getLocalTime()); + assertEquals(TimeDefinition.UTC, out.getTimeDefinition()); + assertEquals(OFFSET_ZERO, out.getStandardOffset()); + assertEquals(OFFSET_PONE, out.getOffsetBefore()); + assertEquals(OFFSET_ZERO, out.getOffsetAfter()); } //----------------------------------------------------------------------- @@ -411,14 +411,14 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition first = trans.get(0); - assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first); + assertEquals(first, test.nextTransition(first.getInstant().minusNanos(1))); for (int i = 0; i < trans.size() - 1; i++) { ZoneOffsetTransition cur = trans.get(i); ZoneOffsetTransition next = trans.get(i + 1); - assertEquals(test.nextTransition(cur.getInstant()), next); - assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next); + assertEquals(next, test.nextTransition(cur.getInstant())); + assertEquals(next, test.nextTransition(next.getInstant().minusNanos(1))); } } @@ -429,18 +429,18 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition last = trans.get(trans.size() - 1); - assertEquals(test.nextTransition(last.getInstant()), rules.get(0).createTransition(1998)); + assertEquals(rules.get(0).createTransition(1998), test.nextTransition(last.getInstant())); for (int year = 1998; year < 2010; year++) { ZoneOffsetTransition a = rules.get(0).createTransition(year); ZoneOffsetTransition b = rules.get(1).createTransition(year); ZoneOffsetTransition c = rules.get(0).createTransition(year + 1); - assertEquals(test.nextTransition(a.getInstant()), b); - assertEquals(test.nextTransition(b.getInstant().minusNanos(1)), b); + assertEquals(b, test.nextTransition(a.getInstant())); + assertEquals(b, test.nextTransition(b.getInstant().minusNanos(1))); - assertEquals(test.nextTransition(b.getInstant()), c); - assertEquals(test.nextTransition(c.getInstant().minusNanos(1)), c); + assertEquals(c, test.nextTransition(b.getInstant())); + assertEquals(c, test.nextTransition(c.getInstant().minusNanos(1))); } } @@ -449,7 +449,7 @@ public class TCKZoneRules { ZoneRules test = europeLondon(); List rules = test.getTransitionRules(); ZoneOffsetTransition zot = rules.get(1).createTransition(Year.MAX_VALUE); - assertEquals(test.nextTransition(zot.getInstant()), null); + assertEquals(null, test.nextTransition(zot.getInstant())); } //----------------------------------------------------------------------- @@ -459,16 +459,16 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition first = trans.get(0); - assertEquals(test.previousTransition(first.getInstant()), null); - assertEquals(test.previousTransition(first.getInstant().minusNanos(1)), null); + assertEquals(null, test.previousTransition(first.getInstant())); + assertEquals(null, test.previousTransition(first.getInstant().minusNanos(1))); for (int i = 0; i < trans.size() - 1; i++) { ZoneOffsetTransition prev = trans.get(i); ZoneOffsetTransition cur = trans.get(i + 1); - assertEquals(test.previousTransition(cur.getInstant()), prev); - assertEquals(test.previousTransition(prev.getInstant().plusSeconds(1)), prev); - assertEquals(test.previousTransition(prev.getInstant().plusNanos(1)), prev); + assertEquals(prev, test.previousTransition(cur.getInstant())); + assertEquals(prev, test.previousTransition(prev.getInstant().plusSeconds(1))); + assertEquals(prev, test.previousTransition(prev.getInstant().plusNanos(1))); } } @@ -479,13 +479,13 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition last = trans.get(trans.size() - 1); - assertEquals(test.previousTransition(last.getInstant().plusSeconds(1)), last); - assertEquals(test.previousTransition(last.getInstant().plusNanos(1)), last); + assertEquals(last, test.previousTransition(last.getInstant().plusSeconds(1))); + assertEquals(last, test.previousTransition(last.getInstant().plusNanos(1))); // Jan 1st of year between transitions and rules ZonedDateTime odt = ZonedDateTime.ofInstant(last.getInstant(), last.getOffsetAfter()); odt = odt.withDayOfYear(1).plusYears(1).with(LocalTime.MIDNIGHT); - assertEquals(test.previousTransition(odt.toInstant()), last); + assertEquals(last, test.previousTransition(odt.toInstant())); // later years for (int year = 1998; year < 2010; year++) { @@ -493,13 +493,13 @@ public class TCKZoneRules { ZoneOffsetTransition b = rules.get(1).createTransition(year); ZoneOffsetTransition c = rules.get(0).createTransition(year + 1); - assertEquals(test.previousTransition(c.getInstant()), b); - assertEquals(test.previousTransition(b.getInstant().plusSeconds(1)), b); - assertEquals(test.previousTransition(b.getInstant().plusNanos(1)), b); + assertEquals(b, test.previousTransition(c.getInstant())); + assertEquals(b, test.previousTransition(b.getInstant().plusSeconds(1))); + assertEquals(b, test.previousTransition(b.getInstant().plusNanos(1))); - assertEquals(test.previousTransition(b.getInstant()), a); - assertEquals(test.previousTransition(a.getInstant().plusSeconds(1)), a); - assertEquals(test.previousTransition(a.getInstant().plusNanos(1)), a); + assertEquals(a, test.previousTransition(b.getInstant())); + assertEquals(a, test.previousTransition(a.getInstant().plusSeconds(1))); + assertEquals(a, test.previousTransition(a.getInstant().plusNanos(1))); } } @@ -513,7 +513,7 @@ public class TCKZoneRules { @Test public void test_Paris() { ZoneRules test = europeParis(); - assertEquals(test.isFixedOffset(), false); + assertEquals(false, test.isFixedOffset()); } @Test @@ -522,60 +522,60 @@ public class TCKZoneRules { ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, 9, 21); - assertEquals(test.getOffset(instant), offset); + assertEquals(offset, test.getOffset(instant)); checkOffset(test, old.toLocalDateTime(), offset, 1); - assertEquals(test.getStandardOffset(instant), offset); - assertEquals(test.getDaylightSavings(instant), Duration.ZERO); - assertEquals(test.isDaylightSavings(instant), false); + assertEquals(offset, test.getStandardOffset(instant)); + assertEquals(Duration.ZERO, test.getDaylightSavings(instant)); + assertEquals(false, test.isDaylightSavings(instant)); } @Test public void test_Paris_getOffset() { ZoneRules test = europeParis(); - assertEquals(test.getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC)), OFFSET_PONE); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC))); } @Test public void test_Paris_getOffset_toDST() { ZoneRules test = europeParis(); - assertEquals(test.getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC)), OFFSET_PTWO); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_PTWO); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC))); } @Test public void test_Paris_getOffset_fromDST() { ZoneRules test = europeParis(); - assertEquals(test.getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC)), OFFSET_PONE); - assertEquals(test.getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC)), OFFSET_PONE); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC))); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_PTWO); - assertEquals(test.getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_PONE); + assertEquals(OFFSET_PTWO, test.getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(OFFSET_PONE, test.getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC))); } @Test @@ -632,15 +632,15 @@ public class TCKZoneRules { ZoneRules test = europeParis(); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 30, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_PONE, GAP); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.getOffsetBefore(), OFFSET_PONE); - assertEquals(trans.getOffsetAfter(), OFFSET_PTWO); - assertEquals(trans.getInstant(), createInstant(2008, 3, 30, 1, 0, ZoneOffset.UTC)); - assertEquals(trans.isValidOffset(OFFSET_ZERO), false); - assertEquals(trans.isValidOffset(OFFSET_PONE), false); - assertEquals(trans.isValidOffset(OFFSET_PTWO), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-30T02:00+01:00 to +02:00]"); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(OFFSET_PONE, trans.getOffsetBefore()); + assertEquals(OFFSET_PTWO, trans.getOffsetAfter()); + assertEquals(createInstant(2008, 3, 30, 1, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(false, trans.isValidOffset(OFFSET_ZERO)); + assertEquals(false, trans.isValidOffset(OFFSET_PONE)); + assertEquals(false, trans.isValidOffset(OFFSET_PTWO)); + assertEquals("Transition[Gap at 2008-03-30T02:00+01:00 to +02:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(OFFSET_PONE)); @@ -648,7 +648,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -656,16 +656,16 @@ public class TCKZoneRules { ZoneRules test = europeParis(); final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_PTWO, OVERLAP); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.getOffsetBefore(), OFFSET_PTWO); - assertEquals(trans.getOffsetAfter(), OFFSET_PONE); - assertEquals(trans.getInstant(), createInstant(2008, 10, 26, 1, 0, ZoneOffset.UTC)); - assertEquals(trans.isValidOffset(OFFSET_ZERO), false); - assertEquals(trans.isValidOffset(OFFSET_PONE), true); - assertEquals(trans.isValidOffset(OFFSET_PTWO), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(3)), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T03:00+02:00 to +01:00]"); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(OFFSET_PTWO, trans.getOffsetBefore()); + assertEquals(OFFSET_PONE, trans.getOffsetAfter()); + assertEquals(createInstant(2008, 10, 26, 1, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(false, trans.isValidOffset(OFFSET_ZERO)); + assertEquals(true, trans.isValidOffset(OFFSET_PONE)); + assertEquals(true, trans.isValidOffset(OFFSET_PTWO)); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(3))); + assertEquals("Transition[Overlap at 2008-10-26T03:00+02:00 to +01:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(OFFSET_PTWO)); @@ -673,7 +673,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -683,15 +683,15 @@ public class TCKZoneRules { while (zdt.getYear() < 2010) { Instant instant = zdt.toInstant(); if (zdt.toLocalDate().isBefore(LocalDate.of(1911, 3, 11))) { - assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, 9, 21)); + assertEquals(ZoneOffset.ofHoursMinutesSeconds(0, 9, 21), test.getStandardOffset(instant)); } else if (zdt.toLocalDate().isBefore(LocalDate.of(1940, 6, 14))) { - assertEquals(test.getStandardOffset(instant), OFFSET_ZERO); + assertEquals(OFFSET_ZERO, test.getStandardOffset(instant)); } else if (zdt.toLocalDate().isBefore(LocalDate.of(1944, 8, 25))) { - assertEquals(test.getStandardOffset(instant), OFFSET_PONE); + assertEquals(OFFSET_PONE, test.getStandardOffset(instant)); } else if (zdt.toLocalDate().isBefore(LocalDate.of(1945, 9, 16))) { - assertEquals(test.getStandardOffset(instant), OFFSET_ZERO); + assertEquals(OFFSET_ZERO, test.getStandardOffset(instant)); } else { - assertEquals(test.getStandardOffset(instant), OFFSET_PONE); + assertEquals(OFFSET_PONE, test.getStandardOffset(instant)); } zdt = zdt.plusMonths(6); } @@ -707,7 +707,7 @@ public class TCKZoneRules { @Test public void test_NewYork() { ZoneRules test = americaNewYork(); - assertEquals(test.isFixedOffset(), false); + assertEquals(false, test.isFixedOffset()); } @Test @@ -716,73 +716,73 @@ public class TCKZoneRules { ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC); Instant instant = old.toInstant(); ZoneOffset offset = ZoneOffset.of("-04:56:02"); - assertEquals(test.getOffset(instant), offset); + assertEquals(offset, test.getOffset(instant)); checkOffset(test, old.toLocalDateTime(), offset, 1); - assertEquals(test.getStandardOffset(instant), offset); - assertEquals(test.getDaylightSavings(instant), Duration.ZERO); - assertEquals(test.isDaylightSavings(instant), false); + assertEquals(offset, test.getStandardOffset(instant)); + assertEquals(Duration.ZERO, test.getDaylightSavings(instant)); + assertEquals(false, test.isDaylightSavings(instant)); } @Test public void test_NewYork_getOffset() { ZoneRules test = americaNewYork(); ZoneOffset offset = ZoneOffset.ofHours(-5); - assertEquals(test.getOffset(createInstant(2008, 1, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 2, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 3, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 4, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 5, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 6, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 7, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 8, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 9, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 10, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 11, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 12, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 1, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 2, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 3, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 4, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 5, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 6, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 7, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 8, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 9, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 10, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 11, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 12, 28, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 1, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 2, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 3, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 4, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 5, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 6, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 7, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 8, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 9, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 10, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 11, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 12, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 1, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 2, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 4, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 5, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 6, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 7, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 8, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 9, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 10, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 12, 28, offset))); } @Test public void test_NewYork_getOffset_toDST() { ZoneRules test = americaNewYork(); ZoneOffset offset = ZoneOffset.ofHours(-5); - assertEquals(test.getOffset(createInstant(2008, 3, 8, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 3, 9, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 3, 10, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 3, 11, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 3, 12, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 3, 13, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 3, 14, offset)), ZoneOffset.ofHours(-4)); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 3, 8, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 3, 9, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 10, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 11, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 12, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 13, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 14, offset))); // cutover at 02:00 local - assertEquals(test.getOffset(createInstant(2008, 3, 9, 1, 59, 59, 999999999, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 3, 9, 2, 0, 0, 0, offset)), ZoneOffset.ofHours(-4)); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 3, 9, 1, 59, 59, 999999999, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 3, 9, 2, 0, 0, 0, offset))); } @Test public void test_NewYork_getOffset_fromDST() { ZoneRules test = americaNewYork(); ZoneOffset offset = ZoneOffset.ofHours(-4); - assertEquals(test.getOffset(createInstant(2008, 11, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 11, 2, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 11, 3, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 11, 4, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 11, 5, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 11, 6, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getOffset(createInstant(2008, 11, 7, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 11, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 11, 2, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 3, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 4, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 5, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 6, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 7, offset))); // cutover at 02:00 local - assertEquals(test.getOffset(createInstant(2008, 11, 2, 1, 59, 59, 999999999, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getOffset(createInstant(2008, 11, 2, 2, 0, 0, 0, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-4), test.getOffset(createInstant(2008, 11, 2, 1, 59, 59, 999999999, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getOffset(createInstant(2008, 11, 2, 2, 0, 0, 0, offset))); } @Test @@ -849,15 +849,15 @@ public class TCKZoneRules { ZoneRules test = americaNewYork(); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 9, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, ZoneOffset.ofHours(-5), GAP); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(-5)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(-4)); - assertEquals(trans.getInstant(), createInstant(2008, 3, 9, 2, 0, ZoneOffset.ofHours(-5))); - assertEquals(trans.isValidOffset(OFFSET_PTWO), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-5)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-4)), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-09T02:00-05:00 to -04:00]"); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(-5), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(-4), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 3, 9, 2, 0, ZoneOffset.ofHours(-5)), trans.getInstant()); + assertEquals(false, trans.isValidOffset(OFFSET_PTWO)); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-5))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-4))); + assertEquals("Transition[Gap at 2008-03-09T02:00-05:00 to -04:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(-5))); @@ -865,7 +865,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -873,16 +873,16 @@ public class TCKZoneRules { ZoneRules test = americaNewYork(); final LocalDateTime dateTime = LocalDateTime.of(2008, 11, 2, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test, dateTime, ZoneOffset.ofHours(-4), OVERLAP); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(-4)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(-5)); - assertEquals(trans.getInstant(), createInstant(2008, 11, 2, 2, 0, ZoneOffset.ofHours(-4))); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-5)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-4)), true); - assertEquals(trans.isValidOffset(OFFSET_PTWO), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-11-02T02:00-04:00 to -05:00]"); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(-4), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(-5), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 11, 2, 2, 0, ZoneOffset.ofHours(-4)), trans.getInstant()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-1))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(-5))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(-4))); + assertEquals(false, trans.isValidOffset(OFFSET_PTWO)); + assertEquals("Transition[Overlap at 2008-11-02T02:00-04:00 to -05:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(-4))); @@ -890,7 +890,7 @@ public class TCKZoneRules { final ZoneOffsetTransition otherTrans = test.getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } @Test @@ -900,9 +900,9 @@ public class TCKZoneRules { while (dateTime.getYear() < 2010) { Instant instant = dateTime.toInstant(); if (dateTime.toLocalDate().isBefore(LocalDate.of(1883, 11, 18))) { - assertEquals(test.getStandardOffset(instant), ZoneOffset.of("-04:56:02")); + assertEquals(ZoneOffset.of("-04:56:02"), test.getStandardOffset(instant)); } else { - assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-5), test.getStandardOffset(instant)); } dateTime = dateTime.plusMonths(6); } @@ -921,14 +921,14 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition first = trans.get(0); - assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first); + assertEquals(first, test.nextTransition(first.getInstant().minusNanos(1))); for (int i = 0; i < trans.size() - 1; i++) { ZoneOffsetTransition cur = trans.get(i); ZoneOffsetTransition next = trans.get(i + 1); - assertEquals(test.nextTransition(cur.getInstant()), next); - assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next); + assertEquals(next, test.nextTransition(cur.getInstant())); + assertEquals(next, test.nextTransition(next.getInstant().minusNanos(1))); } } @@ -938,7 +938,7 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition last = trans.get(trans.size() - 1); - assertEquals(test.nextTransition(last.getInstant()), null); + assertEquals(null, test.nextTransition(last.getInstant())); } //----------------------------------------------------------------------- @@ -954,14 +954,14 @@ public class TCKZoneRules { List trans = test.getTransitions(); ZoneOffsetTransition first = trans.get(0); - assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first); + assertEquals(first, test.nextTransition(first.getInstant().minusNanos(1))); for (int i = 0; i < trans.size() - 1; i++) { ZoneOffsetTransition cur = trans.get(i); ZoneOffsetTransition next = trans.get(i + 1); - assertEquals(test.nextTransition(cur.getInstant()), next); - assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next); + assertEquals(next, test.nextTransition(cur.getInstant())); + assertEquals(next, test.nextTransition(next.getInstant().minusNanos(1))); } } @@ -971,17 +971,17 @@ public class TCKZoneRules { ZoneRules test = pacificApia(); Instant instantBefore = LocalDate.of(2011, 12, 27).atStartOfDay(ZoneOffset.UTC).toInstant(); ZoneOffsetTransition trans = test.nextTransition(instantBefore); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2011, 12, 30, 0, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2011, 12, 31, 0, 0)); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-10)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(+14)), false); - assertEquals(trans.getDuration(), Duration.ofHours(24)); - assertEquals(trans.getInstant(), LocalDateTime.of(2011, 12, 31, 0, 0).toInstant(ZoneOffset.ofHours(+14))); + assertEquals(LocalDateTime.of(2011, 12, 30, 0, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(2011, 12, 31, 0, 0), trans.getDateTimeAfter()); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-10))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(+14))); + assertEquals(Duration.ofHours(24), trans.getDuration()); + assertEquals(LocalDateTime.of(2011, 12, 31, 0, 0).toInstant(ZoneOffset.ofHours(+14)), trans.getInstant()); ZonedDateTime zdt = ZonedDateTime.of(2011, 12, 29, 23, 0, 0, 0, ZoneId.of("Pacific/Apia")); - assertEquals(zdt.plusHours(2).toLocalDateTime(), LocalDateTime.of(2011, 12, 31, 1, 0)); + assertEquals(LocalDateTime.of(2011, 12, 31, 1, 0), zdt.plusHours(2).toLocalDateTime()); } @Test @@ -990,30 +990,34 @@ public class TCKZoneRules { ZoneRules test = pacificApia(); Instant instantBefore = LocalDate.of(1892, 7, 2).atStartOfDay(ZoneOffset.UTC).toInstant(); ZoneOffsetTransition trans = test.nextTransition(instantBefore); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(1892, 7, 5, 0, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(1892, 7, 4, 0, 0)); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHoursMinutesSeconds(+12, 33, 4)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHoursMinutesSeconds(-11, -26, -56)), true); - assertEquals(trans.getDuration(), Duration.ofHours(-24)); - assertEquals(trans.getInstant(), LocalDateTime.of(1892, 7, 4, 0, 0).toInstant(ZoneOffset.ofHoursMinutesSeconds(-11, -26, -56))); + assertEquals(LocalDateTime.of(1892, 7, 5, 0, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(1892, 7, 4, 0, 0), trans.getDateTimeAfter()); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHoursMinutesSeconds(+12, 33, 4))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHoursMinutesSeconds(-11, -26, -56))); + assertEquals(Duration.ofHours(-24), trans.getDuration()); + assertEquals(LocalDateTime.of(1892, 7, 4, 0, 0).toInstant(ZoneOffset.ofHoursMinutesSeconds(-11, -26, -56)), trans.getInstant()); ZonedDateTime zdt = ZonedDateTime.of(1892, 7, 4, 23, 0, 0, 0, ZoneId.of("Pacific/Apia")); - assertEquals(zdt.plusHours(2).toLocalDateTime(), LocalDateTime.of(1892, 7, 4, 1, 0, 0)); + assertEquals(LocalDateTime.of(1892, 7, 4, 1, 0, 0), zdt.plusHours(2).toLocalDateTime()); } //------------------------------------------------------------------------- - @Test(expectedExceptions=UnsupportedOperationException.class) + @Test public void test_getTransitions_immutable() { - ZoneRules test = europeParis(); - test.getTransitions().clear(); + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + ZoneRules test = europeParis(); + test.getTransitions().clear(); + }); } - @Test(expectedExceptions=UnsupportedOperationException.class) + @Test public void test_getTransitionRules_immutable() { - ZoneRules test = europeParis(); - test.getTransitionRules().clear(); + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + ZoneRules test = europeParis(); + test.getTransitionRules().clear(); + }); } //----------------------------------------------------------------------- @@ -1073,23 +1077,23 @@ public class TCKZoneRules { OffsetDateTime before_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).minusSeconds(1); OffsetDateTime after_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).plusSeconds(1); - assertEquals(zoneRule.getStandardOffset(before_time_of_stdOffsetTransition1.toInstant()), stdOffset1); - assertEquals(zoneRule.getStandardOffset(after_time_of_stdOffsetTransition1.toInstant()), stdOffset2); + assertEquals(stdOffset1, zoneRule.getStandardOffset(before_time_of_stdOffsetTransition1.toInstant())); + assertEquals(stdOffset2, zoneRule.getStandardOffset(after_time_of_stdOffsetTransition1.toInstant())); OffsetDateTime before_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).plusSeconds(1); - assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition1); - assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition2); + assertEquals(wallOffsetTransition1, zoneRule.nextTransition(before_time_of_wallOffsetTransition1.toInstant())); + assertEquals(wallOffsetTransition2, zoneRule.nextTransition(after_time_of_wallOffsetTransition1.toInstant())); OffsetDateTime before_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).plusSeconds(1); - assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition2); - assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition3); + assertEquals(wallOffsetTransition2, zoneRule.nextTransition(before_time_of_wallOffsetTransition2.toInstant())); + assertEquals(wallOffsetTransition3, zoneRule.nextTransition(after_time_of_wallOffsetTransition2.toInstant())); OffsetDateTime before_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).plusSeconds(1); - assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition3.toInstant()), wallOffsetTransition3); - assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition3.toInstant()), rule1.createTransition(2014)); + assertEquals(wallOffsetTransition3, zoneRule.nextTransition(before_time_of_wallOffsetTransition3.toInstant())); + assertEquals(rule1.createTransition(2014), zoneRule.nextTransition(after_time_of_wallOffsetTransition3.toInstant())); } //----------------------------------------------------------------------- @@ -1100,31 +1104,31 @@ public class TCKZoneRules { ZoneRules test1 = europeLondon(); ZoneRules test2 = europeParis(); ZoneRules test2b = europeParis(); - assertEquals(test1.equals(test2), false); - assertEquals(test2.equals(test1), false); + assertEquals(false, test1.equals(test2)); + assertEquals(false, test2.equals(test1)); - assertEquals(test1.equals(test1), true); - assertEquals(test2.equals(test2), true); - assertEquals(test2.equals(test2b), true); + assertEquals(true, test1.equals(test1)); + assertEquals(true, test2.equals(test2)); + assertEquals(true, test2.equals(test2b)); - assertEquals(test1.hashCode() == test1.hashCode(), true); - assertEquals(test2.hashCode() == test2.hashCode(), true); - assertEquals(test2.hashCode() == test2b.hashCode(), true); + assertEquals(true, test1.hashCode() == test1.hashCode()); + assertEquals(true, test2.hashCode() == test2.hashCode()); + assertEquals(true, test2.hashCode() == test2b.hashCode()); } @Test public void test_equals_null() { - assertEquals(europeLondon().equals(null), false); + assertEquals(false, europeLondon().equals(null)); } @Test public void test_equals_notZoneRules() { - assertEquals(europeLondon().equals("Europe/London"), false); + assertEquals(false, europeLondon().equals("Europe/London")); } @Test public void test_toString() { - assertEquals(europeLondon().toString().contains("ZoneRules"), true); + assertEquals(true, europeLondon().toString().contains("ZoneRules")); } //----------------------------------------------------------------------- @@ -1152,17 +1156,17 @@ public class TCKZoneRules { private ZoneOffsetTransition checkOffset(ZoneRules rules, LocalDateTime dateTime, ZoneOffset offset, int type) { List validOffsets = rules.getValidOffsets(dateTime); - assertEquals(validOffsets.size(), type); - assertEquals(rules.getOffset(dateTime), offset); + assertEquals(type, validOffsets.size()); + assertEquals(offset, rules.getOffset(dateTime)); if (type == 1) { - assertEquals(validOffsets.get(0), offset); + assertEquals(offset, validOffsets.get(0)); return null; } else { ZoneOffsetTransition zot = rules.getTransition(dateTime); assertNotNull(zot); - assertEquals(zot.isOverlap(), type == 2); - assertEquals(zot.isGap(), type == 0); - assertEquals(zot.isValidOffset(offset), type == 2); + assertEquals(type == 2, zot.isOverlap()); + assertEquals(type == 0, zot.isGap()); + assertEquals(type == 2, zot.isValidOffset(offset)); return zot; } } diff --git a/test/jdk/java/time/tck/java/time/zone/TCKZoneRulesProvider.java b/test/jdk/java/time/tck/java/time/zone/TCKZoneRulesProvider.java index f51bb396f50..32b1a688b54 100644 --- a/test/jdk/java/time/tck/java/time/zone/TCKZoneRulesProvider.java +++ b/test/jdk/java/time/tck/java/time/zone/TCKZoneRulesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,9 +59,9 @@ */ package tck.java.time.zone; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.ZoneId; import java.time.ZoneOffset; @@ -74,12 +74,12 @@ import java.util.NavigableMap; import java.util.Set; import java.util.TreeMap; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test ZoneRulesProvider. */ -@Test public class TCKZoneRulesProvider { private static String TZDB_VERSION = "2012i"; @@ -90,12 +90,12 @@ public class TCKZoneRulesProvider { @Test public void test_getAvailableGroupIds() { Set zoneIds = ZoneRulesProvider.getAvailableZoneIds(); - assertEquals(zoneIds.contains("Europe/London"), true); + assertEquals(true, zoneIds.contains("Europe/London")); } - @Test(expectedExceptions=UnsupportedOperationException.class) + @Test public void test_getAvailableGroupIds_modifyZoneId() { - ZoneRulesProvider.getAvailableZoneIds().clear(); + Assertions.assertThrows(UnsupportedOperationException.class, () -> ZoneRulesProvider.getAvailableZoneIds().clear()); } //----------------------------------------------------------------------- @@ -106,17 +106,17 @@ public class TCKZoneRulesProvider { ZoneRules rules = ZoneRulesProvider.getRules("Europe/London", false); assertNotNull(rules); ZoneRules rules2 = ZoneRulesProvider.getRules("Europe/London", false); - assertEquals(rules2, rules); + assertEquals(rules, rules2); } - @Test(expectedExceptions=ZoneRulesException.class) + @Test public void test_getRules_StringBoolean_unknownId() { - ZoneRulesProvider.getRules("Europe/Lon", false); + Assertions.assertThrows(ZoneRulesException.class, () -> ZoneRulesProvider.getRules("Europe/Lon", false)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_getRules_StringBoolean_null() { - ZoneRulesProvider.getRules(null, false); + Assertions.assertThrows(NullPointerException.class, () -> ZoneRulesProvider.getRules(null, false)); } @Test @@ -124,13 +124,13 @@ public class TCKZoneRulesProvider { MockDynamicProvider dynamicProvider = new MockDynamicProvider(); ZoneRulesProvider.registerProvider(dynamicProvider); - assertEquals(dynamicProvider.count, 0); + assertEquals(0, dynamicProvider.count); ZoneRules rules1 = ZoneId.of("DynamicLocation").getRules(); - assertEquals(dynamicProvider.count, 2); - assertEquals(rules1, dynamicProvider.BASE); + assertEquals(2, dynamicProvider.count); + assertEquals(dynamicProvider.BASE, rules1); ZoneRules rules2 = ZoneId.of("DynamicLocation").getRules(); - assertEquals(dynamicProvider.count, 4); - assertEquals(rules2, dynamicProvider.ALTERNATE); + assertEquals(4, dynamicProvider.count); + assertEquals(dynamicProvider.ALTERNATE, rules2); } //----------------------------------------------------------------------- @@ -141,23 +141,23 @@ public class TCKZoneRulesProvider { NavigableMap versions = ZoneRulesProvider.getVersions("Europe/London"); assertTrue(versions.size() >= 1); ZoneRules rules = ZoneRulesProvider.getRules("Europe/London", false); - assertEquals(versions.lastEntry().getValue(), rules); + assertEquals(rules, versions.lastEntry().getValue()); NavigableMap copy = new TreeMap<>(versions); versions.clear(); - assertEquals(versions.size(), 0); + assertEquals(0, versions.size()); NavigableMap versions2 = ZoneRulesProvider.getVersions("Europe/London"); - assertEquals(versions2, copy); + assertEquals(copy, versions2); } - @Test(expectedExceptions=ZoneRulesException.class) + @Test public void test_getVersions_String_unknownId() { - ZoneRulesProvider.getVersions("Europe/Lon"); + Assertions.assertThrows(ZoneRulesException.class, () -> ZoneRulesProvider.getVersions("Europe/Lon")); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_getVersions_String_null() { - ZoneRulesProvider.getVersions(null); + Assertions.assertThrows(NullPointerException.class, () -> ZoneRulesProvider.getVersions(null)); } //----------------------------------------------------------------------- @@ -165,7 +165,7 @@ public class TCKZoneRulesProvider { //----------------------------------------------------------------------- @Test public void test_refresh() { - assertEquals(ZoneRulesProvider.refresh(), false); + assertEquals(false, ZoneRulesProvider.refresh()); } //----------------------------------------------------------------------- @@ -174,12 +174,12 @@ public class TCKZoneRulesProvider { @Test public void test_registerProvider() { Set pre = ZoneRulesProvider.getAvailableZoneIds(); - assertEquals(pre.contains("FooLocation"), false); + assertEquals(false, pre.contains("FooLocation")); ZoneRulesProvider.registerProvider(new MockTempProvider()); - assertEquals(pre.contains("FooLocation"), false); + assertEquals(false, pre.contains("FooLocation")); Set post = ZoneRulesProvider.getAvailableZoneIds(); - assertEquals(post.contains("FooLocation"), true); - assertEquals(ZoneRulesProvider.getRules("FooLocation", false), ZoneOffset.of("+01:45").getRules()); + assertEquals(true, post.contains("FooLocation")); + assertEquals(ZoneOffset.of("+01:45").getRules(), ZoneRulesProvider.getRules("FooLocation", false)); } static class MockTempProvider extends ZoneRulesProvider { diff --git a/test/jdk/java/time/tck/java/time/zone/serial/TCKFixedZoneRulesSerialization.java b/test/jdk/java/time/tck/java/time/zone/serial/TCKFixedZoneRulesSerialization.java index 790e54fbb6d..719d5aab5f7 100644 --- a/test/jdk/java/time/tck/java/time/zone/serial/TCKFixedZoneRulesSerialization.java +++ b/test/jdk/java/time/tck/java/time/zone/serial/TCKFixedZoneRulesSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,6 @@ */ package tck.java.time.zone.serial; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -69,12 +67,15 @@ import java.io.ObjectOutputStream; import java.time.ZoneOffset; import java.time.zone.ZoneRules; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test serialization of ZoneRules for fixed offset time-zones. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TCKFixedZoneRulesSerialization { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); @@ -85,7 +86,6 @@ public class TCKFixedZoneRulesSerialization { return offset.getRules(); } - @DataProvider(name="rules") Object[][] data_rules() { return new Object[][] { {make(OFFSET_PONE), OFFSET_PONE}, @@ -97,7 +97,8 @@ public class TCKFixedZoneRulesSerialization { //----------------------------------------------------------------------- // Basics //----------------------------------------------------------------------- - @Test(dataProvider="rules") + @ParameterizedTest + @MethodSource("data_rules") public void test_serialization(ZoneRules test, ZoneOffset expectedOffset) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); @@ -109,8 +110,8 @@ public class TCKFixedZoneRulesSerialization { ObjectInputStream in = new ObjectInputStream(bais); ZoneRules result = (ZoneRules) in.readObject(); - assertEquals(result, test); - assertEquals(result.getClass(), test.getClass()); + assertEquals(test, result); + assertEquals(test.getClass(), result.getClass()); } diff --git a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java index 42796f66f8f..ded4772cd9f 100644 --- a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java +++ b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -66,13 +66,13 @@ import java.time.ZoneOffset; import java.time.zone.ZoneOffsetTransitionRule; import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; + import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransitionRule serialization. */ -@Test public class TCKZoneOffsetTransitionRuleSerialization extends AbstractTCKTest { private static final LocalTime TIME_0100 = LocalTime.of(1, 0); diff --git a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java index 01ffefe09df..b6ae7dae76b 100644 --- a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java +++ b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -62,7 +62,6 @@ package tck.java.time.zone.serial; import static java.time.temporal.ChronoUnit.HOURS; import java.time.Duration; -import org.testng.annotations.Test; import tck.java.time.AbstractTCKTest; import java.time.LocalDateTime; @@ -70,10 +69,11 @@ import java.time.Year; import java.time.ZoneOffset; import java.time.zone.ZoneOffsetTransition; +import org.junit.jupiter.api.Test; + /** * Test serialization of ZoneOffsetTransition. */ -@Test public class TCKZoneOffsetTransitionSerialization extends AbstractTCKTest { private static final ZoneOffset OFFSET_0200 = ZoneOffset.ofHours(2); diff --git a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java index 5262d68eea0..1ba549ba916 100644 --- a/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java +++ b/test/jdk/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,7 +59,6 @@ */ package tck.java.time.zone.serial; -import org.testng.annotations.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -68,16 +67,17 @@ import java.io.ObjectOutputStream; import java.time.ZoneId; import java.time.zone.ZoneRules; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import tck.java.time.AbstractTCKTest; /** * Test serialization of ZoneRules. */ -@Test public class TCKZoneRulesSerialization extends AbstractTCKTest{ + @Test public void test_serialization_loaded() throws Exception { assertSerialization(europeLondon()); assertSerialization(europeParis()); @@ -95,7 +95,7 @@ public class TCKZoneRulesSerialization extends AbstractTCKTest{ ObjectInputStream in = new ObjectInputStream(bais); ZoneRules result = (ZoneRules) in.readObject(); - assertEquals(result, test); + assertEquals(test, result); } //----------------------------------------------------------------------- diff --git a/test/jdk/java/time/test/TEST.properties b/test/jdk/java/time/test/TEST.properties index 4cc5775e862..e2ecb3e5dc3 100644 --- a/test/jdk/java/time/test/TEST.properties +++ b/test/jdk/java/time/test/TEST.properties @@ -1,5 +1,5 @@ -# java.time tests use TestNG -TestNG.dirs = .. +# java.time tests use JUnit +JUnit.dirs = .. othervm.dirs = java/time lib.dirs = /test/lib /test/jdk/tools/lib lib.build = jdk.test.lib.RandomFactory diff --git a/test/jdk/java/time/test/java/time/AbstractTest.java b/test/jdk/java/time/test/java/time/AbstractTest.java index 6e4734b8e4c..2a117011533 100644 --- a/test/jdk/java/time/test/java/time/AbstractTest.java +++ b/test/jdk/java/time/test/java/time/AbstractTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,9 +59,7 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Constructor; import java.lang.reflect.Field; diff --git a/test/jdk/java/time/test/java/time/TestClock_Fixed.java b/test/jdk/java/time/test/java/time/TestClock_Fixed.java index cf07ceea07b..1c82a092c6a 100644 --- a/test/jdk/java/time/test/java/time/TestClock_Fixed.java +++ b/test/jdk/java/time/test/java/time/TestClock_Fixed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,8 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.Clock; import java.time.Instant; @@ -68,18 +68,18 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test fixed clock. */ -@Test public class TestClock_Fixed { private static final ZoneId PARIS = ZoneId.of("Europe/Paris"); private static final Instant INSTANT = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500).atZone(ZoneOffset.ofHours(2)).toInstant(); //------------------------------------------------------------------------- + @Test public void test_withZone_same() { Clock test = Clock.fixed(INSTANT, PARIS); Clock changed = test.withZone(PARIS); @@ -87,9 +87,10 @@ public class TestClock_Fixed { } //----------------------------------------------------------------------- + @Test public void test_toString() { Clock test = Clock.fixed(INSTANT, PARIS); - assertEquals(test.toString(), "FixedClock[2008-06-30T09:30:10.000000500Z,Europe/Paris]"); + assertEquals("FixedClock[2008-06-30T09:30:10.000000500Z,Europe/Paris]", test.toString()); } } diff --git a/test/jdk/java/time/test/java/time/TestClock_Offset.java b/test/jdk/java/time/test/java/time/TestClock_Offset.java index ed62300e681..03fc2974955 100644 --- a/test/jdk/java/time/test/java/time/TestClock_Offset.java +++ b/test/jdk/java/time/test/java/time/TestClock_Offset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,25 +59,25 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.Clock; import java.time.Duration; import java.time.ZoneId; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test offset clock. */ -@Test public class TestClock_Offset { private static final ZoneId PARIS = ZoneId.of("Europe/Paris"); private static final Duration OFFSET = Duration.ofSeconds(2); //------------------------------------------------------------------------- + @Test public void test_withZone_same() { Clock test = Clock.offset(Clock.system(PARIS), OFFSET); Clock changed = test.withZone(PARIS); @@ -85,9 +85,10 @@ public class TestClock_Offset { } //----------------------------------------------------------------------- + @Test public void test_toString() { Clock test = Clock.offset(Clock.systemUTC(), OFFSET); - assertEquals(test.toString(), "OffsetClock[SystemClock[Z],PT2S]"); + assertEquals("OffsetClock[SystemClock[Z],PT2S]", test.toString()); } } diff --git a/test/jdk/java/time/test/java/time/TestClock_System.java b/test/jdk/java/time/test/java/time/TestClock_System.java index 05d235e3b3c..4d685e78cc1 100644 --- a/test/jdk/java/time/test/java/time/TestClock_System.java +++ b/test/jdk/java/time/test/java/time/TestClock_System.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,8 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.lang.reflect.Field; import java.time.Clock; @@ -68,18 +68,21 @@ import java.time.Instant; import java.time.ZoneId; import java.time.ZoneOffset; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test system clock. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestClock_System { private static final ZoneId PARIS = ZoneId.of("Europe/Paris"); private static final Clock systemUTC = Clock.systemUTC(); + @Test public void test_withZone_same() { Clock test = Clock.system(PARIS); Clock changed = test.withZone(PARIS); @@ -87,13 +90,13 @@ public class TestClock_System { } //----------------------------------------------------------------------- + @Test public void test_toString() { Clock test = Clock.system(PARIS); - assertEquals(test.toString(), "SystemClock[Europe/Paris]"); + assertEquals("SystemClock[Europe/Paris]", test.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="sampleSystemUTC") Object[][] provider_sampleSystemUTC() { return new Object[][] { {"Clock.systemUTC()#1", Clock.systemUTC()}, @@ -104,7 +107,8 @@ public class TestClock_System { } // Test for 8073394 - @Test(dataProvider="sampleSystemUTC") + @ParameterizedTest + @MethodSource("provider_sampleSystemUTC") public void test_systemUTC(String s, Clock clock) { if (clock != systemUTC) { throw new RuntimeException("Unexpected clock instance for " + s + ": " @@ -126,6 +130,7 @@ public class TestClock_System { + time.getNano(); } + @Test public void test_ClockResolution() { Clock highestUTC = Clock.systemUTC(); @@ -392,6 +397,7 @@ public class TestClock_System { } } + @Test public void test_OffsetRegular() throws IllegalAccessException { System.out.println("*** Testing regular cases ***"); SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000", @@ -402,6 +408,7 @@ public class TestClock_System { System.currentTimeMillis()/1000 + 1024); } + @Test public void test_OffsetLimits() throws IllegalAccessException { System.out.println("*** Testing limits ***"); SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET + 1", diff --git a/test/jdk/java/time/test/java/time/TestClock_Tick.java b/test/jdk/java/time/test/java/time/TestClock_Tick.java index 53e27541764..5e23ed74ca2 100644 --- a/test/jdk/java/time/test/java/time/TestClock_Tick.java +++ b/test/jdk/java/time/test/java/time/TestClock_Tick.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,8 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.Clock; import java.time.Duration; @@ -69,12 +69,11 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test tick clock. */ -@Test public class TestClock_Tick { private static final ZoneId MOSCOW = ZoneId.of("Europe/Moscow"); @@ -82,6 +81,7 @@ public class TestClock_Tick { private static final ZonedDateTime ZDT = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500).atZone(ZoneOffset.ofHours(2)); //------------------------------------------------------------------------- + @Test public void test_withZone_same() { Clock test = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500)); Clock changed = test.withZone(PARIS); @@ -89,14 +89,16 @@ public class TestClock_Tick { } //----------------------------------------------------------------------- + @Test public void test_toString() { Clock test = Clock.tick(Clock.systemUTC(), Duration.ofMillis(500)); - assertEquals(test.toString(), "TickClock[SystemClock[Z],PT0.5S]"); + assertEquals("TickClock[SystemClock[Z],PT0.5S]", test.toString()); } //----------------------------------------------------------------------- // Ensure divide-by-zero will not be thrown // @bug 8310232 + @Test public void test_millis() { var test = Clock.tick(Clock.systemUTC(), Duration.ofNanos(1000)); test.millis(); diff --git a/test/jdk/java/time/test/java/time/TestDuration.java b/test/jdk/java/time/test/java/time/TestDuration.java index 2b2043377f3..37147687511 100644 --- a/test/jdk/java/time/test/java/time/TestDuration.java +++ b/test/jdk/java/time/test/java/time/TestDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,18 +59,16 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.Duration; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test Duration. */ -@Test public class TestDuration extends AbstractTest { //----------------------------------------------------------------------- @@ -187,14 +185,14 @@ public class TestDuration extends AbstractTest { for (int j = 0; j < durations.length; j++) { Duration b = durations[j]; if (i < j) { - assertEquals(a.compareTo(b)< 0, true, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(true, a.compareTo(b)< 0, a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else if (i > j) { - assertEquals(a.compareTo(b) > 0, true, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(true, a.compareTo(b) > 0, a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else { - assertEquals(a.compareTo(b), 0, a + " <=> " + b); - assertEquals(a.equals(b), true, a + " <=> " + b); + assertEquals(0, a.compareTo(b), a + " <=> " + b); + assertEquals(true, a.equals(b), a + " <=> " + b); } } } diff --git a/test/jdk/java/time/test/java/time/TestInstant.java b/test/jdk/java/time/test/java/time/TestInstant.java index 8dbd951bde1..40f3138ac28 100644 --- a/test/jdk/java/time/test/java/time/TestInstant.java +++ b/test/jdk/java/time/test/java/time/TestInstant.java @@ -66,16 +66,18 @@ import java.time.ZoneOffset; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoUnit; -import org.testng.annotations.Test; -import org.testng.annotations.DataProvider; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test Instant. * @bug 8273369 8331202 8364752 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestInstant extends AbstractTest { @Test @@ -83,7 +85,6 @@ public class TestInstant extends AbstractTest { assertImmutable(Instant.class); } - @DataProvider(name="sampleEpochMillis") private Object[][] provider_sampleEpochMillis() { return new Object[][] { {"Long.MAX_VALUE", Long.MAX_VALUE}, @@ -96,11 +97,12 @@ public class TestInstant extends AbstractTest { }; } - @Test(dataProvider="sampleEpochMillis") + @ParameterizedTest + @MethodSource("provider_sampleEpochMillis") public void test_epochMillis(String name, long millis) { Instant t1 = Instant.ofEpochMilli(millis); long m = t1.toEpochMilli(); - assertEquals(millis, m, name); + assertEquals(m, millis, name); } /** @@ -113,7 +115,7 @@ public class TestInstant extends AbstractTest { var nanoMax = Instant.EPOCH.plusNanos(Long.MAX_VALUE); var totalMicros = Instant.EPOCH.until(nanoMax, ChronoUnit.MICROS); var plusOneMicro = Instant.EPOCH.until(nanoMax.plusNanos(1000), ChronoUnit.MICROS); - assertEquals(plusOneMicro - totalMicros, 1L); + assertEquals(1L, plusOneMicro - totalMicros); } /** @@ -122,11 +124,10 @@ public class TestInstant extends AbstractTest { */ @Test public void test_millisUntil() { - assertEquals(Instant.MIN.until(Instant.MIN.plusSeconds(1), ChronoUnit.MILLIS), 1000L); - assertEquals(Instant.MAX.plusSeconds(-1).until(Instant.MAX, ChronoUnit.MILLIS), 1000L); + assertEquals(1000L, Instant.MIN.until(Instant.MIN.plusSeconds(1), ChronoUnit.MILLIS)); + assertEquals(1000L, Instant.MAX.plusSeconds(-1).until(Instant.MAX, ChronoUnit.MILLIS)); } - @DataProvider private Object[][] provider_until_1arg() { Instant t1 = Instant.ofEpochSecond(0, 10); Instant t2 = Instant.ofEpochSecond(10, -20); @@ -138,24 +139,22 @@ public class TestInstant extends AbstractTest { }; } - @Test(dataProvider = "provider_until_1arg") + @ParameterizedTest + @MethodSource("provider_until_1arg") public void test_until_1arg(Instant start, Instant end) { Duration result = start.until(end); Duration expected = Duration.ofSeconds(end.getEpochSecond() - start.getEpochSecond(), end.getNano() - start.getNano()); - assertEquals(result, expected); + assertEquals(expected, result); expected = Duration.between(start, end); - assertEquals(result, expected); + assertEquals(expected, result); } @Test public void test_until_1arg_NPE() { - assertThrows(NullPointerException.class, () -> { - Instant.now().until(null); - }); + assertThrows(NullPointerException.class, () -> Instant.now().until(null)); } - @DataProvider private Object[][] valid_instants() { var I1 = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.of("+02")).toInstant(); var I2 = OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.of("+02:02")).toInstant(); @@ -178,12 +177,12 @@ public class TestInstant extends AbstractTest { }; } - @Test(dataProvider = "valid_instants") + @ParameterizedTest + @MethodSource("valid_instants") public void test_parse_valid(String instant, Instant expected) { - assertEquals(Instant.parse(instant), expected); + assertEquals(expected, Instant.parse(instant)); } - @DataProvider private Object[][] invalid_instants() { return new Object[][] { {"2017-01-01T00:00:00.000"}, @@ -204,7 +203,8 @@ public class TestInstant extends AbstractTest { }; } - @Test(dataProvider = "invalid_instants") + @ParameterizedTest + @MethodSource("invalid_instants") public void test_parse_invalid(String instant) { assertThrows(DateTimeParseException.class, () -> Instant.parse(instant)); } diff --git a/test/jdk/java/time/test/java/time/TestInstantSource.java b/test/jdk/java/time/test/java/time/TestInstantSource.java index 31fe7874e62..e0f70047718 100644 --- a/test/jdk/java/time/test/java/time/TestInstantSource.java +++ b/test/jdk/java/time/test/java/time/TestInstantSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -23,9 +23,10 @@ package test.java.time; import static java.time.temporal.ChronoUnit.SECONDS; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.Clock; import java.time.Duration; @@ -34,67 +35,70 @@ import java.time.InstantSource; import java.time.ZoneId; import java.time.ZoneOffset; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test instant source. */ -@Test public class TestInstantSource { private static final ZoneId PARIS = ZoneId.of("Europe/Paris"); + @Test public void test_system() { // main tests for Clock.currentInstant() are in TestClock_System var test = InstantSource.system(); assertSame(test.withZone(ZoneOffset.UTC), Clock.systemUTC()); - assertEquals(test.withZone(PARIS), Clock.system(PARIS)); + assertEquals(Clock.system(PARIS), test.withZone(PARIS)); var millis = System.currentTimeMillis(); var testMillis = test.millis(); var testInstantMillis = test.instant().toEpochMilli(); assertTrue(Math.abs(testMillis - millis) < 1000); assertTrue(Math.abs(testInstantMillis - millis) < 1000); assertSame(test, InstantSource.system()); - assertEquals(test.hashCode(), InstantSource.system().hashCode()); - assertEquals(test.toString(), "SystemInstantSource"); + assertEquals(InstantSource.system().hashCode(), test.hashCode()); + assertEquals("SystemInstantSource", test.toString()); } + @Test public void test_tick() { var millis = 257265861691L; var instant = Instant.ofEpochMilli(millis); var duration = Duration.ofSeconds(1); var test = InstantSource.tick(InstantSource.fixed(instant), duration); - assertEquals(test.withZone(ZoneOffset.UTC), Clock.tick(Clock.fixed(instant, ZoneOffset.UTC), duration)); - assertEquals(test.withZone(PARIS), Clock.tick(Clock.fixed(instant, PARIS), duration)); - assertEquals(test.millis(), (millis / 1000) * 1000); - assertEquals(test.instant(), instant.truncatedTo(SECONDS)); - assertEquals(test, InstantSource.tick(InstantSource.fixed(instant), duration)); - assertEquals(test.hashCode(), InstantSource.tick(InstantSource.fixed(instant), duration).hashCode()); + assertEquals(Clock.tick(Clock.fixed(instant, ZoneOffset.UTC), duration), test.withZone(ZoneOffset.UTC)); + assertEquals(Clock.tick(Clock.fixed(instant, PARIS), duration), test.withZone(PARIS)); + assertEquals((millis / 1000) * 1000, test.millis()); + assertEquals(instant.truncatedTo(SECONDS), test.instant()); + assertEquals(InstantSource.tick(InstantSource.fixed(instant), duration), test); + assertEquals(InstantSource.tick(InstantSource.fixed(instant), duration).hashCode(), test.hashCode()); } + @Test public void test_fixed() { var millis = 257265861691L; var instant = Instant.ofEpochMilli(millis); var test = InstantSource.fixed(instant); - assertEquals(test.withZone(ZoneOffset.UTC), Clock.fixed(instant, ZoneOffset.UTC)); - assertEquals(test.withZone(PARIS), Clock.fixed(instant, PARIS)); - assertEquals(test.millis(), millis); - assertEquals(test.instant(), instant); - assertEquals(test, InstantSource.fixed(instant)); - assertEquals(test.hashCode(), InstantSource.fixed(instant).hashCode()); + assertEquals(Clock.fixed(instant, ZoneOffset.UTC), test.withZone(ZoneOffset.UTC)); + assertEquals(Clock.fixed(instant, PARIS), test.withZone(PARIS)); + assertEquals(millis, test.millis()); + assertEquals(instant, test.instant()); + assertEquals(InstantSource.fixed(instant), test); + assertEquals(InstantSource.fixed(instant).hashCode(), test.hashCode()); } + @Test public void test_offset() { var millis = 257265861691L; var instant = Instant.ofEpochMilli(millis); var duration = Duration.ofSeconds(120); var test = InstantSource.offset(InstantSource.fixed(instant), duration); - assertEquals(test.withZone(ZoneOffset.UTC), Clock.offset(Clock.fixed(instant, ZoneOffset.UTC), duration)); - assertEquals(test.withZone(PARIS), Clock.offset(Clock.fixed(instant, PARIS), duration)); - assertEquals(test.millis(), millis + 120_000); - assertEquals(test.instant(), instant.plusSeconds(120)); - assertEquals(test, InstantSource.offset(InstantSource.fixed(instant), duration)); - assertEquals(test.hashCode(), InstantSource.offset(InstantSource.fixed(instant), duration).hashCode()); + assertEquals(Clock.offset(Clock.fixed(instant, ZoneOffset.UTC), duration), test.withZone(ZoneOffset.UTC)); + assertEquals(Clock.offset(Clock.fixed(instant, PARIS), duration), test.withZone(PARIS)); + assertEquals(millis + 120_000, test.millis()); + assertEquals(instant.plusSeconds(120), test.instant()); + assertEquals(InstantSource.offset(InstantSource.fixed(instant), duration), test); + assertEquals(InstantSource.offset(InstantSource.fixed(instant), duration).hashCode(), test.hashCode()); } static class MockInstantSource implements InstantSource { @@ -106,13 +110,14 @@ public class TestInstantSource { } } + @Test public void test_mock() { var test = new MockInstantSource(); - assertEquals(test.withZone(ZoneOffset.UTC).getZone(), ZoneOffset.UTC); - assertEquals(test.withZone(PARIS).getZone(), PARIS); - assertEquals(test.withZone(ZoneOffset.UTC).withZone(PARIS).getZone(), PARIS); - assertEquals(test.millis(), MockInstantSource.FIXED.toEpochMilli()); - assertEquals(test.instant(), MockInstantSource.FIXED); + assertEquals(ZoneOffset.UTC, test.withZone(ZoneOffset.UTC).getZone()); + assertEquals(PARIS, test.withZone(PARIS).getZone()); + assertEquals(PARIS, test.withZone(ZoneOffset.UTC).withZone(PARIS).getZone()); + assertEquals(MockInstantSource.FIXED.toEpochMilli(), test.millis()); + assertEquals(MockInstantSource.FIXED, test.instant()); assertEquals(test.withZone(ZoneOffset.UTC), test.withZone(ZoneOffset.UTC)); assertEquals(test.withZone(ZoneOffset.UTC).hashCode(), test.withZone(ZoneOffset.UTC).hashCode()); } diff --git a/test/jdk/java/time/test/java/time/TestLocalDate.java b/test/jdk/java/time/test/java/time/TestLocalDate.java index ef7a10ac687..b7f232665d0 100644 --- a/test/jdk/java/time/test/java/time/TestLocalDate.java +++ b/test/jdk/java/time/test/java/time/TestLocalDate.java @@ -60,10 +60,11 @@ package test.java.time; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ObjectStreamClass; import java.io.ObjectStreamField; @@ -74,19 +75,21 @@ import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.IsoFields; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test LocalDate. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestLocalDate extends AbstractTest { private LocalDate TEST_2007_07_15; - @BeforeMethod + @BeforeEach public void setUp() { TEST_2007_07_15 = LocalDate.of(2007, 7, 15); } @@ -180,7 +183,6 @@ public class TestLocalDate extends AbstractTest { //----------------------------------------------------------------------- // plusWeeks() //----------------------------------------------------------------------- - @DataProvider(name="samplePlusWeeksSymmetry") Object[][] provider_samplePlusWeeksSymmetry() { return new Object[][] { {LocalDate.of(-1, 1, 1)}, @@ -212,14 +214,15 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="samplePlusWeeksSymmetry") + @ParameterizedTest + @MethodSource("provider_samplePlusWeeksSymmetry") public void test_plusWeeks_symmetry(LocalDate reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDate t = reference.plusWeeks(weeks).plusWeeks(-weeks); - assertEquals(t, reference); + assertEquals(reference, t); t = reference.plusWeeks(-weeks).plusWeeks(weeks); - assertEquals(t, reference); + assertEquals(reference, t); } } @@ -232,7 +235,6 @@ public class TestLocalDate extends AbstractTest { //----------------------------------------------------------------------- // plusDays() //----------------------------------------------------------------------- - @DataProvider(name="samplePlusDaysSymmetry") Object[][] provider_samplePlusDaysSymmetry() { return new Object[][] { {LocalDate.of(-1, 1, 1)}, @@ -264,14 +266,15 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="samplePlusDaysSymmetry") + @ParameterizedTest + @MethodSource("provider_samplePlusDaysSymmetry") public void test_plusDays_symmetry(LocalDate reference) { for (int days = 0; days < 365 * 8; days++) { LocalDate t = reference.plusDays(days).plusDays(-days); - assertEquals(t, reference); + assertEquals(reference, t); t = reference.plusDays(-days).plusDays(days); - assertEquals(t, reference); + assertEquals(reference, t); } } @@ -308,7 +311,6 @@ public class TestLocalDate extends AbstractTest { //----------------------------------------------------------------------- // minusWeeks() //----------------------------------------------------------------------- - @DataProvider(name="sampleMinusWeeksSymmetry") Object[][] provider_sampleMinusWeeksSymmetry() { return new Object[][] { {LocalDate.of(-1, 1, 1)}, @@ -340,14 +342,15 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="sampleMinusWeeksSymmetry") + @ParameterizedTest + @MethodSource("provider_sampleMinusWeeksSymmetry") public void test_minusWeeks_symmetry(LocalDate reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDate t = reference.minusWeeks(weeks).minusWeeks(-weeks); - assertEquals(t, reference); + assertEquals(reference, t); t = reference.minusWeeks(-weeks).minusWeeks(weeks); - assertEquals(t, reference); + assertEquals(reference, t); } } @@ -360,7 +363,6 @@ public class TestLocalDate extends AbstractTest { //----------------------------------------------------------------------- // minusDays() //----------------------------------------------------------------------- - @DataProvider(name="sampleMinusDaysSymmetry") Object[][] provider_sampleMinusDaysSymmetry() { return new Object[][] { {LocalDate.of(-1, 1, 1)}, @@ -392,14 +394,15 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="sampleMinusDaysSymmetry") + @ParameterizedTest + @MethodSource("provider_sampleMinusDaysSymmetry") public void test_minusDays_symmetry(LocalDate reference) { for (int days = 0; days < 365 * 8; days++) { LocalDate t = reference.minusDays(days).minusDays(-days); - assertEquals(t, reference); + assertEquals(reference, t); t = reference.minusDays(-days).minusDays(days); - assertEquals(t, reference); + assertEquals(reference, t); } } @@ -415,12 +418,12 @@ public class TestLocalDate extends AbstractTest { LocalDate test = LocalDate.of(0, 1, 1); for (long i = date_0000_01_01; i < 700000; i++) { - assertEquals(LocalDate.ofEpochDay(test.toEpochDay()), test); + assertEquals(test, LocalDate.ofEpochDay(test.toEpochDay())); test = next(test); } test = LocalDate.of(0, 1, 1); for (long i = date_0000_01_01; i > -2000000; i--) { - assertEquals(LocalDate.ofEpochDay(test.toEpochDay()), test); + assertEquals(test, LocalDate.ofEpochDay(test.toEpochDay())); test = previous(test); } } @@ -434,11 +437,11 @@ public class TestLocalDate extends AbstractTest { int[] offsets = new int[] { 0, 1, 2, 3, 28, 29, 30, 31, 32, 363, 364, 365, 366, 367 }; for (int offset : offsets) { LocalDate minDate = LocalDate.ofEpochDay(minDay + offset); - assertEquals(minDate, LocalDate.MIN.plusDays(offset)); + assertEquals(LocalDate.MIN.plusDays(offset), minDate); assertTrue(ChronoField.YEAR.range().isValidValue(minDate.getYear())); LocalDate maxDate = LocalDate.ofEpochDay(maxDay - offset); - assertEquals(maxDate, LocalDate.MAX.minusDays(offset)); + assertEquals(LocalDate.MAX.minusDays(offset), maxDate); assertTrue(ChronoField.YEAR.range().isValidValue(maxDate.getYear())); try { @@ -463,25 +466,24 @@ public class TestLocalDate extends AbstractTest { LocalDate b = localDates[j]; if (i < j) { assertTrue(a.compareTo(b) < 0, a + " <=> " + b); - assertEquals(a.isBefore(b), true, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(true, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else if (i > j) { assertTrue(a.compareTo(b) > 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), true, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(true, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else { - assertEquals(a.compareTo(b), 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), true, a + " <=> " + b); + assertEquals(0, a.compareTo(b), a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(true, a.equals(b), a + " <=> " + b); } } } } - @DataProvider(name="quarterYearsToAdd") Object[][] provider_quarterYearsToAdd() { return new Object[][] { {Long.valueOf(-1000000000)}, @@ -496,7 +498,8 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="quarterYearsToAdd") + @ParameterizedTest + @MethodSource("provider_quarterYearsToAdd") public void test_plus_QuarterYears(long quarterYears) { LocalDate t0 = TEST_2007_07_15 .plus(quarterYears, IsoFields.QUARTER_YEARS); @@ -504,10 +507,11 @@ public class TestLocalDate extends AbstractTest { .plus(quarterYears, ChronoUnit.MONTHS) .plus(quarterYears, ChronoUnit.MONTHS) .plus(quarterYears, ChronoUnit.MONTHS); - assertEquals(t0, t1); + assertEquals(t1, t0); } - @Test(dataProvider="quarterYearsToAdd") + @ParameterizedTest + @MethodSource("provider_quarterYearsToAdd") public void test_minus_QuarterYears(long quarterYears) { LocalDate t0 = TEST_2007_07_15 .minus(quarterYears, IsoFields.QUARTER_YEARS); @@ -515,7 +519,7 @@ public class TestLocalDate extends AbstractTest { .minus(quarterYears, ChronoUnit.MONTHS) .minus(quarterYears, ChronoUnit.MONTHS) .minus(quarterYears, ChronoUnit.MONTHS); - assertEquals(t0, t1); + assertEquals(t1, t0); } // Verify serialized fields types are backward compatible @@ -524,9 +528,9 @@ public class TestLocalDate extends AbstractTest { var osc = ObjectStreamClass.lookup(LocalDate.class); for (ObjectStreamField f : osc.getFields()) { switch (f.getName()) { - case "year" -> assertEquals(f.getType(), int.class, f.getName()); + case "year" -> assertEquals(int.class, f.getType(), f.getName()); case "month", - "day" -> assertEquals(f.getType(), short.class); + "day" -> assertEquals(short.class, f.getType()); default -> fail("unknown field in LocalDate: " + f.getName()); } } diff --git a/test/jdk/java/time/test/java/time/TestLocalDateTime.java b/test/jdk/java/time/test/java/time/TestLocalDateTime.java index 80469ed0621..fb53ec70ede 100644 --- a/test/jdk/java/time/test/java/time/TestLocalDateTime.java +++ b/test/jdk/java/time/test/java/time/TestLocalDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,9 +59,9 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.LocalDate; import java.time.LocalDateTime; @@ -69,13 +69,15 @@ import java.time.LocalTime; import java.time.Period; import java.time.temporal.ChronoUnit; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test LocalDateTime. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestLocalDateTime extends AbstractTest { private LocalDateTime TEST_2007_07_15_12_30_40_987654321 = LocalDateTime.of(2007, 7, 15, 12, 30, 40, 987654321); @@ -87,7 +89,6 @@ public class TestLocalDateTime extends AbstractTest { } //----------------------------------------------------------------------- - @DataProvider(name="sampleDates") Object[][] provider_sampleDates() { return new Object[][] { {2008, 7, 5}, @@ -99,7 +100,6 @@ public class TestLocalDateTime extends AbstractTest { }; } - @DataProvider(name="sampleTimes") Object[][] provider_sampleTimes() { return new Object[][] { {0, 0, 0, 0}, @@ -444,7 +444,7 @@ public class TestLocalDateTime extends AbstractTest { @Test public void test_minusSeconds_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusSeconds(24 * 60 * 60); - assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1)); + assertEquals(TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1), t.toLocalDate()); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } @@ -469,7 +469,7 @@ public class TestLocalDateTime extends AbstractTest { @Test public void test_minusNanos_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusNanos(24 * 60 * 60 * 1000000000L); - assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1)); + assertEquals(TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1), t.toLocalDate()); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } @@ -488,7 +488,8 @@ public class TestLocalDateTime extends AbstractTest { //----------------------------------------------------------------------- // toLocalDate() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates") + @ParameterizedTest + @MethodSource("provider_sampleDates") public void test_getDate(int year, int month, int day) { LocalDate d = LocalDate.of(year, month, day); LocalDateTime dt = LocalDateTime.of(d, LocalTime.MIDNIGHT); @@ -498,7 +499,8 @@ public class TestLocalDateTime extends AbstractTest { //----------------------------------------------------------------------- // toLocalTime() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes") + @ParameterizedTest + @MethodSource("provider_sampleTimes") public void test_getTime(int h, int m, int s, int ns) { LocalTime t = LocalTime.of(h, m, s, ns); LocalDateTime dt = LocalDateTime.of(LocalDate.of(2011, 7, 30), t); @@ -549,19 +551,19 @@ public class TestLocalDateTime extends AbstractTest { LocalDateTime b = localDateTimes[j]; if (i < j) { assertTrue(a.compareTo(b) < 0, a + " <=> " + b); - assertEquals(a.isBefore(b), true, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(true, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else if (i > j) { assertTrue(a.compareTo(b) > 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), true, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(true, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else { - assertEquals(a.compareTo(b), 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), true, a + " <=> " + b); + assertEquals(0, a.compareTo(b), a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(true, a.equals(b), a + " <=> " + b); } } } diff --git a/test/jdk/java/time/test/java/time/TestLocalTime.java b/test/jdk/java/time/test/java/time/TestLocalTime.java index 8e25a85f198..24a456683fd 100644 --- a/test/jdk/java/time/test/java/time/TestLocalTime.java +++ b/test/jdk/java/time/test/java/time/TestLocalTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,19 +59,18 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.Clock; import java.time.LocalTime; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test LocalTime. */ -@Test public class TestLocalTime extends AbstractTest { static final long NANOS_PER_SECOND = 1_000_000_000L; static final long NANOS_PER_MINUTE = 60 * NANOS_PER_SECOND; @@ -85,10 +84,10 @@ public class TestLocalTime extends AbstractTest { //----------------------------------------------------------------------- private void check(LocalTime time, int h, int m, int s, int n) { - assertEquals(time.getHour(), h); - assertEquals(time.getMinute(), m); - assertEquals(time.getSecond(), s); - assertEquals(time.getNano(), n); + assertEquals(h, time.getHour()); + assertEquals(m, time.getMinute()); + assertEquals(s, time.getSecond()); + assertEquals(n, time.getNano()); } //----------------------------------------------------------------------- @@ -184,8 +183,8 @@ public class TestLocalTime extends AbstractTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test @SuppressWarnings("unused") + @Test public void now() { // Warmup the TimeZone data so the following test does not include // one-time initialization diff --git a/test/jdk/java/time/test/java/time/TestMonthDay.java b/test/jdk/java/time/test/java/time/TestMonthDay.java index 311a40030c1..a5195387d2b 100644 --- a/test/jdk/java/time/test/java/time/TestMonthDay.java +++ b/test/jdk/java/time/test/java/time/TestMonthDay.java @@ -59,10 +59,10 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ObjectStreamClass; import java.io.ObjectStreamField; @@ -70,18 +70,17 @@ import java.time.LocalDate; import java.time.Month; import java.time.MonthDay; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test MonthDay. */ -@Test public class TestMonthDay extends AbstractTest { private MonthDay TEST_07_15; - @BeforeMethod + @BeforeEach public void setUp() { TEST_07_15 = MonthDay.of(7, 15); } @@ -94,8 +93,8 @@ public class TestMonthDay extends AbstractTest { //----------------------------------------------------------------------- void check(MonthDay test, int m, int d) { - assertEquals(test.getMonth().getValue(), m); - assertEquals(test.getDayOfMonth(), d); + assertEquals(m, test.getMonth().getValue()); + assertEquals(d, test.getDayOfMonth()); } @Test @@ -129,19 +128,19 @@ public class TestMonthDay extends AbstractTest { MonthDay b = localDates[j]; if (i < j) { assertTrue(a.compareTo(b) < 0, a + " <=> " + b); - assertEquals(a.isBefore(b), true, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(true, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else if (i > j) { assertTrue(a.compareTo(b) > 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), true, a + " <=> " + b); - assertEquals(a.equals(b), false, a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(true, a.isAfter(b), a + " <=> " + b); + assertEquals(false, a.equals(b), a + " <=> " + b); } else { - assertEquals(a.compareTo(b), 0, a + " <=> " + b); - assertEquals(a.isBefore(b), false, a + " <=> " + b); - assertEquals(a.isAfter(b), false, a + " <=> " + b); - assertEquals(a.equals(b), true, a + " <=> " + b); + assertEquals(0, a.compareTo(b), a + " <=> " + b); + assertEquals(false, a.isBefore(b), a + " <=> " + b); + assertEquals(false, a.isAfter(b), a + " <=> " + b); + assertEquals(true, a.equals(b), a + " <=> " + b); } } } @@ -155,7 +154,7 @@ public class TestMonthDay extends AbstractTest { for (ObjectStreamField f : osc.getFields()) { switch (f.getName()) { case "month", - "day" -> assertEquals(f.getType(), int.class, f.getName()); + "day" -> assertEquals(int.class, f.getType(), f.getName()); default -> fail("unknown field in MonthDay: " + f.getName()); } } diff --git a/test/jdk/java/time/test/java/time/TestOffsetDateTime.java b/test/jdk/java/time/test/java/time/TestOffsetDateTime.java index bd145fa9663..3caf4d13c88 100644 --- a/test/jdk/java/time/test/java/time/TestOffsetDateTime.java +++ b/test/jdk/java/time/test/java/time/TestOffsetDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,8 +59,8 @@ */ package test.java.time; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.Duration; import java.time.LocalDate; @@ -69,23 +69,25 @@ import java.time.LocalTime; import java.time.OffsetDateTime; import java.time.ZoneOffset; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test OffsetDateTime. * * @bug 8211990 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestOffsetDateTime extends AbstractTest { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); private OffsetDateTime TEST_2008_6_30_11_30_59_000000500; - @BeforeMethod + @BeforeEach public void setUp() { TEST_2008_6_30_11_30_59_000000500 = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 500), OFFSET_PONE); } @@ -98,7 +100,6 @@ public class TestOffsetDateTime extends AbstractTest { //----------------------------------------------------------------------- // basics //----------------------------------------------------------------------- - @DataProvider(name="sampleTimes") Object[][] provider_sampleTimes() { return new Object[][] { {2008, 6, 30, 11, 30, 20, 500, OFFSET_PONE}, @@ -108,7 +109,8 @@ public class TestOffsetDateTime extends AbstractTest { }; } - @Test(dataProvider="sampleTimes") + @ParameterizedTest + @MethodSource("provider_sampleTimes") public void test_get_same(int y, int o, int d, int h, int m, int s, int n, ZoneOffset offset) { LocalDate localDate = LocalDate.of(y, o, d); LocalTime localTime = LocalTime.of(h, m, s, n); @@ -329,6 +331,6 @@ public class TestOffsetDateTime extends AbstractTest { OffsetDateTime start = OffsetDateTime.MAX .withOffsetSameLocal(ZoneOffset.ofHours(-17)); OffsetDateTime end = OffsetDateTime.MAX; - assertEquals(Duration.between(start, end), Duration.ofHours(1)); + assertEquals(Duration.ofHours(1), Duration.between(start, end)); } } diff --git a/test/jdk/java/time/test/java/time/TestOffsetDateTime_instants.java b/test/jdk/java/time/test/java/time/TestOffsetDateTime_instants.java index 28b32ba2811..9131a7b02b6 100644 --- a/test/jdk/java/time/test/java/time/TestOffsetDateTime_instants.java +++ b/test/jdk/java/time/test/java/time/TestOffsetDateTime_instants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,7 +59,7 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.Instant; @@ -70,12 +70,12 @@ import java.time.OffsetDateTime; import java.time.Year; import java.time.ZoneOffset; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test OffsetDateTime creation. */ -@Test public class TestOffsetDateTime_instants { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); @@ -83,148 +83,167 @@ public class TestOffsetDateTime_instants { private static final ZoneOffset OFFSET_MIN = ZoneOffset.ofHours(-18); //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class) + @Test public void factory_ofInstant_nullInstant() { - OffsetDateTime.ofInstant((Instant) null, OFFSET_PONE); + Assertions.assertThrows(NullPointerException.class, () -> OffsetDateTime.ofInstant((Instant) null, OFFSET_PONE)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void factory_ofInstant_nullOffset() { - Instant instant = Instant.ofEpochSecond(0L); - OffsetDateTime.ofInstant(instant, (ZoneOffset) null); + Assertions.assertThrows(NullPointerException.class, () -> { + Instant instant = Instant.ofEpochSecond(0L); + OffsetDateTime.ofInstant(instant, (ZoneOffset) null); + }); } + @Test public void factory_ofInstant_allSecsInDay() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_PONE); - assertEquals(test.getYear(), 1970); - assertEquals(test.getMonth(), Month.JANUARY); - assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0)); - assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24); - assertEquals(test.getMinute(), (i / 60) % 60); - assertEquals(test.getSecond(), i % 60); + assertEquals(1970, test.getYear()); + assertEquals(Month.JANUARY, test.getMonth()); + assertEquals(1 + (i >= 23 * 60 * 60 ? 1 : 0), test.getDayOfMonth()); + assertEquals(((i / (60 * 60)) + 1) % 24, test.getHour()); + assertEquals((i / 60) % 60, test.getMinute()); + assertEquals(i % 60, test.getSecond()); } } + @Test public void factory_ofInstant_allDaysInCycle() { // sanity check using different algorithm OffsetDateTime expected = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); for (long i = 0; i < 146097; i++) { Instant instant = Instant.ofEpochSecond(i * 24L * 60L * 60L); OffsetDateTime test = OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); - assertEquals(test, expected); + assertEquals(expected, test); expected = expected.plusDays(1); } } + @Test public void factory_ofInstant_history() { doTest_factory_ofInstant_all(-2820, 2820); } //----------------------------------------------------------------------- + @Test public void factory_ofInstant_minYear() { doTest_factory_ofInstant_all(Year.MIN_VALUE, Year.MIN_VALUE + 420); } - @Test(expectedExceptions=DateTimeException.class) + @Test public void factory_ofInstant_tooLow() { - long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); - int year = Year.MIN_VALUE - 1; - long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; - Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L); - OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); + Assertions.assertThrows(DateTimeException.class, () -> { + long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); + int year = Year.MIN_VALUE - 1; + long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; + Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L); + OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); + }); } + @Test public void factory_ofInstant_maxYear() { doTest_factory_ofInstant_all(Year.MAX_VALUE - 420, Year.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class) + @Test public void factory_ofInstant_tooBig() { - long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); - long year = Year.MAX_VALUE + 1L; - long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; - Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L); - OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); + Assertions.assertThrows(DateTimeException.class, () -> { + long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); + long year = Year.MAX_VALUE + 1L; + long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; + Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L); + OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); + }); } //----------------------------------------------------------------------- + @Test public void factory_ofInstant_minWithMinOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MIN_VALUE; long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L - OFFSET_MIN.getTotalSeconds()); OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MIN); - assertEquals(test.getYear(), Year.MIN_VALUE); - assertEquals(test.getMonth().getValue(), 1); - assertEquals(test.getDayOfMonth(), 1); - assertEquals(test.getOffset(), OFFSET_MIN); - assertEquals(test.getHour(), 0); - assertEquals(test.getMinute(), 0); - assertEquals(test.getSecond(), 0); - assertEquals(test.getNano(), 0); + assertEquals(Year.MIN_VALUE, test.getYear()); + assertEquals(1, test.getMonth().getValue()); + assertEquals(1, test.getDayOfMonth()); + assertEquals(OFFSET_MIN, test.getOffset()); + assertEquals(0, test.getHour()); + assertEquals(0, test.getMinute()); + assertEquals(0, test.getSecond()); + assertEquals(0, test.getNano()); } + @Test public void factory_ofInstant_minWithMaxOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MIN_VALUE; long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970; Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L - OFFSET_MAX.getTotalSeconds()); OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MAX); - assertEquals(test.getYear(), Year.MIN_VALUE); - assertEquals(test.getMonth().getValue(), 1); - assertEquals(test.getDayOfMonth(), 1); - assertEquals(test.getOffset(), OFFSET_MAX); - assertEquals(test.getHour(), 0); - assertEquals(test.getMinute(), 0); - assertEquals(test.getSecond(), 0); - assertEquals(test.getNano(), 0); + assertEquals(Year.MIN_VALUE, test.getYear()); + assertEquals(1, test.getMonth().getValue()); + assertEquals(1, test.getDayOfMonth()); + assertEquals(OFFSET_MAX, test.getOffset()); + assertEquals(0, test.getHour()); + assertEquals(0, test.getMinute()); + assertEquals(0, test.getSecond()); + assertEquals(0, test.getNano()); } + @Test public void factory_ofInstant_maxWithMinOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MAX_VALUE; long days = (year * 365L + (year / 4 - year / 100 + year / 400)) + 365 - days_0000_to_1970; Instant instant = Instant.ofEpochSecond((days + 1) * 24L * 60L * 60L - 1 - OFFSET_MIN.getTotalSeconds()); OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MIN); - assertEquals(test.getYear(), Year.MAX_VALUE); - assertEquals(test.getMonth().getValue(), 12); - assertEquals(test.getDayOfMonth(), 31); - assertEquals(test.getOffset(), OFFSET_MIN); - assertEquals(test.getHour(), 23); - assertEquals(test.getMinute(), 59); - assertEquals(test.getSecond(), 59); - assertEquals(test.getNano(), 0); + assertEquals(Year.MAX_VALUE, test.getYear()); + assertEquals(12, test.getMonth().getValue()); + assertEquals(31, test.getDayOfMonth()); + assertEquals(OFFSET_MIN, test.getOffset()); + assertEquals(23, test.getHour()); + assertEquals(59, test.getMinute()); + assertEquals(59, test.getSecond()); + assertEquals(0, test.getNano()); } + @Test public void factory_ofInstant_maxWithMaxOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MAX_VALUE; long days = (year * 365L + (year / 4 - year / 100 + year / 400)) + 365 - days_0000_to_1970; Instant instant = Instant.ofEpochSecond((days + 1) * 24L * 60L * 60L - 1 - OFFSET_MAX.getTotalSeconds()); OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MAX); - assertEquals(test.getYear(), Year.MAX_VALUE); - assertEquals(test.getMonth().getValue(), 12); - assertEquals(test.getDayOfMonth(), 31); - assertEquals(test.getOffset(), OFFSET_MAX); - assertEquals(test.getHour(), 23); - assertEquals(test.getMinute(), 59); - assertEquals(test.getSecond(), 59); - assertEquals(test.getNano(), 0); + assertEquals(Year.MAX_VALUE, test.getYear()); + assertEquals(12, test.getMonth().getValue()); + assertEquals(31, test.getDayOfMonth()); + assertEquals(OFFSET_MAX, test.getOffset()); + assertEquals(23, test.getHour()); + assertEquals(59, test.getMinute()); + assertEquals(59, test.getSecond()); + assertEquals(0, test.getNano()); } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void factory_ofInstant_maxInstantWithMaxOffset() { - Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); - OffsetDateTime.ofInstant(instant, OFFSET_MAX); + Assertions.assertThrows(DateTimeException.class, () -> { + Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); + OffsetDateTime.ofInstant(instant, OFFSET_MAX); + }); } - @Test(expectedExceptions=DateTimeException.class) + @Test public void factory_ofInstant_maxInstantWithMinOffset() { - Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); - OffsetDateTime.ofInstant(instant, OFFSET_MIN); + Assertions.assertThrows(DateTimeException.class, () -> { + Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); + OffsetDateTime.ofInstant(instant, OFFSET_MIN); + }); } //----------------------------------------------------------------------- @@ -241,7 +260,7 @@ public class TestOffsetDateTime_instants { Instant instant = Instant.ofEpochSecond(i * 24L * 60L * 60L); try { OffsetDateTime test = OffsetDateTime.ofInstant(instant, ZoneOffset.UTC); - assertEquals(test, expected); + assertEquals(expected, test); if (expected.toLocalDate().equals(maxDate) == false) { expected = expected.plusDays(1); } @@ -282,65 +301,75 @@ public class TestOffsetDateTime_instants { // } //----------------------------------------------------------------------- + @Test public void test_toInstant_19700101() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); Instant test = dt.toInstant(); - assertEquals(test.getEpochSecond(), 0); - assertEquals(test.getNano(), 0); + assertEquals(0, test.getEpochSecond()); + assertEquals(0, test.getNano()); } + @Test public void test_toInstant_19700101_oneNano() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 1), ZoneOffset.UTC); Instant test = dt.toInstant(); - assertEquals(test.getEpochSecond(), 0); - assertEquals(test.getNano(), 1); + assertEquals(0, test.getEpochSecond()); + assertEquals(1, test.getNano()); } + @Test public void test_toInstant_19700101_minusOneNano() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1969, 12, 31), LocalTime.of(23, 59, 59, 999999999), ZoneOffset.UTC); Instant test = dt.toInstant(); - assertEquals(test.getEpochSecond(), -1); - assertEquals(test.getNano(), 999999999); + assertEquals(-1, test.getEpochSecond()); + assertEquals(999999999, test.getNano()); } + @Test public void test_toInstant_19700102() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 2), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); Instant test = dt.toInstant(); - assertEquals(test.getEpochSecond(), 24L * 60L * 60L); - assertEquals(test.getNano(), 0); + assertEquals(24L * 60L * 60L, test.getEpochSecond()); + assertEquals(0, test.getNano()); } + @Test public void test_toInstant_19691231() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1969, 12, 31), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); Instant test = dt.toInstant(); - assertEquals(test.getEpochSecond(), -24L * 60L * 60L); - assertEquals(test.getNano(), 0); + assertEquals(-24L * 60L * 60L, test.getEpochSecond()); + assertEquals(0, test.getNano()); } //----------------------------------------------------------------------- + @Test public void test_toEpochSecond_19700101() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); - assertEquals(dt.toEpochSecond(), 0); + assertEquals(0, dt.toEpochSecond()); } + @Test public void test_toEpochSecond_19700101_oneNano() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of( 0, 0, 0, 1), ZoneOffset.UTC); - assertEquals(dt.toEpochSecond(), 0); + assertEquals(0, dt.toEpochSecond()); } + @Test public void test_toEpochSecond_19700101_minusOneNano() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1969, 12, 31), LocalTime.of(23, 59, 59, 999999999), ZoneOffset.UTC); - assertEquals(dt.toEpochSecond(), -1); + assertEquals(-1, dt.toEpochSecond()); } + @Test public void test_toEpochSecond_19700102() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 2), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); - assertEquals(dt.toEpochSecond(), 24L * 60L * 60L); + assertEquals(24L * 60L * 60L, dt.toEpochSecond()); } + @Test public void test_toEpochSecond_19691231() { OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1969, 12, 31), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC); - assertEquals(dt.toEpochSecond(), -24L * 60L * 60L); + assertEquals(-24L * 60L * 60L, dt.toEpochSecond()); } } diff --git a/test/jdk/java/time/test/java/time/TestOffsetTime.java b/test/jdk/java/time/test/java/time/TestOffsetTime.java index 41116a7c964..ce3a73aa987 100644 --- a/test/jdk/java/time/test/java/time/TestOffsetTime.java +++ b/test/jdk/java/time/test/java/time/TestOffsetTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -61,12 +61,11 @@ package test.java.time; import java.time.OffsetTime; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test OffsetTime. */ -@Test public class TestOffsetTime extends AbstractTest { @Test diff --git a/test/jdk/java/time/test/java/time/TestPeriod.java b/test/jdk/java/time/test/java/time/TestPeriod.java index 2c6d4030d84..a74fbf4c8d2 100644 --- a/test/jdk/java/time/test/java/time/TestPeriod.java +++ b/test/jdk/java/time/test/java/time/TestPeriod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,17 +59,16 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.Period; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test. */ -@Test public class TestPeriod extends AbstractTest { @Test @@ -98,10 +97,10 @@ public class TestPeriod extends AbstractTest { Period test6 = Period.ofDays(6); Period test5M = Period.ofMonths(5); Period test5Y = Period.ofYears(5); - assertEquals(test5.hashCode() == test5.hashCode(), true); - assertEquals(test5.hashCode() == test6.hashCode(), false); - assertEquals(test5.hashCode() == test5M.hashCode(), false); - assertEquals(test5.hashCode() == test5Y.hashCode(), false); + assertEquals(true, test5.hashCode() == test5.hashCode()); + assertEquals(false, test5.hashCode() == test6.hashCode()); + assertEquals(false, test5.hashCode() == test5M.hashCode()); + assertEquals(false, test5.hashCode() == test5Y.hashCode()); } } diff --git a/test/jdk/java/time/test/java/time/TestYear.java b/test/jdk/java/time/test/java/time/TestYear.java index 71791ab5fa7..ddb82d91b26 100644 --- a/test/jdk/java/time/test/java/time/TestYear.java +++ b/test/jdk/java/time/test/java/time/TestYear.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -61,12 +61,11 @@ package test.java.time; import java.time.Year; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test Year. */ -@Test public class TestYear extends AbstractTest { @Test diff --git a/test/jdk/java/time/test/java/time/TestYearMonth.java b/test/jdk/java/time/test/java/time/TestYearMonth.java index 0552994b8c2..51202c902f9 100644 --- a/test/jdk/java/time/test/java/time/TestYearMonth.java +++ b/test/jdk/java/time/test/java/time/TestYearMonth.java @@ -64,15 +64,13 @@ import java.io.ObjectStreamField; import java.time.LocalDate; import java.time.YearMonth; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; /** * Test YearMonth. */ -@Test public class TestYearMonth extends AbstractTest { //----------------------------------------------------------------------- @@ -87,8 +85,8 @@ public class TestYearMonth extends AbstractTest { var osc = ObjectStreamClass.lookup(YearMonth.class); for (ObjectStreamField f : osc.getFields()) { switch (f.getName()) { - case "year" -> assertEquals(f.getType(), int.class, f.getName()); - case "month" -> assertEquals(f.getType(), int.class, f.getName()); + case "year" -> assertEquals(int.class, f.getType(), f.getName()); + case "month" -> assertEquals(int.class, f.getType(), f.getName()); default -> fail("unknown field in YearMonth: " + f.getName()); } } diff --git a/test/jdk/java/time/test/java/time/TestZoneId.java b/test/jdk/java/time/test/java/time/TestZoneId.java index df2bbbc519e..fa8727560af 100644 --- a/test/jdk/java/time/test/java/time/TestZoneId.java +++ b/test/jdk/java/time/test/java/time/TestZoneId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,10 +59,10 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -81,12 +81,12 @@ import java.util.Locale; import java.util.SimpleTimeZone; import java.util.TimeZone; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test ZoneId. */ -@Test public class TestZoneId extends AbstractTest { private static final int OVERLAP = 2; @@ -95,6 +95,7 @@ public class TestZoneId extends AbstractTest { //----------------------------------------------------------------------- // Basics //----------------------------------------------------------------------- + @Test public void test_immutable() { // cannot use standard test as ZoneId is abstract Class cls = ZoneId.class; @@ -112,100 +113,111 @@ public class TestZoneId extends AbstractTest { //----------------------------------------------------------------------- // UTC //----------------------------------------------------------------------- + @Test public void test_constant_UTC() { ZoneId test = ZoneOffset.UTC; - assertEquals(test.getId(), "Z"); - assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), "Z"); - assertEquals(test.getRules().isFixedOffset(), true); - assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), ZoneOffset.UTC); + assertEquals("Z", test.getId()); + assertEquals("Z", test.getDisplayName(TextStyle.FULL, Locale.UK)); + assertEquals(true, test.getRules().isFixedOffset()); + assertEquals(ZoneOffset.UTC, test.getRules().getOffset(Instant.ofEpochSecond(0L))); checkOffset(test.getRules(), createLDT(2008, 6, 30), ZoneOffset.UTC, 1); } //----------------------------------------------------------------------- // system default //----------------------------------------------------------------------- + @Test public void test_systemDefault() { ZoneId test = ZoneId.systemDefault(); - assertEquals(test.getId(), TimeZone.getDefault().getID()); + assertEquals(TimeZone.getDefault().getID(), test.getId()); } - @Test(expectedExceptions = DateTimeException.class) + @Test public void test_systemDefault_unableToConvert_badFormat() { - TimeZone current = TimeZone.getDefault(); - try { - TimeZone.setDefault(new SimpleTimeZone(127, "Something Weird")); - ZoneId.systemDefault(); - } finally { - TimeZone.setDefault(current); - } + Assertions.assertThrows(DateTimeException.class, () -> { + TimeZone current = TimeZone.getDefault(); + try { + TimeZone.setDefault(new SimpleTimeZone(127, "Something Weird")); + ZoneId.systemDefault(); + } finally { + TimeZone.setDefault(current); + } + }); } - @Test(expectedExceptions = ZoneRulesException.class) + @Test public void test_systemDefault_unableToConvert_unknownId() { - TimeZone current = TimeZone.getDefault(); - try { - TimeZone.setDefault(new SimpleTimeZone(127, "SomethingWeird")); - ZoneId.systemDefault(); - } finally { - TimeZone.setDefault(current); - } + Assertions.assertThrows(ZoneRulesException.class, () -> { + TimeZone current = TimeZone.getDefault(); + try { + TimeZone.setDefault(new SimpleTimeZone(127, "SomethingWeird")); + ZoneId.systemDefault(); + } finally { + TimeZone.setDefault(current); + } + }); } //----------------------------------------------------------------------- // Europe/London //----------------------------------------------------------------------- + @Test public void test_London() { ZoneId test = ZoneId.of("Europe/London"); - assertEquals(test.getId(), "Europe/London"); - assertEquals(test.getRules().isFixedOffset(), false); + assertEquals("Europe/London", test.getId()); + assertEquals(false, test.getRules().isFixedOffset()); } + @Test public void test_London_getOffset() { ZoneId test = ZoneId.of("Europe/London"); - assertEquals(test.getRules().getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC))); } + @Test public void test_London_getOffset_toDST() { ZoneId test = ZoneId.of("Europe/London"); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC))); } + @Test public void test_London_getOffset_fromDST() { ZoneId test = ZoneId.of("Europe/London"); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)), ZoneOffset.ofHours(0)); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(0), test.getRules().getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC))); } + @Test public void test_London_getOffsetInfo() { ZoneId test = ZoneId.of("Europe/London"); checkOffset(test.getRules(), createLDT(2008, 1, 1), ZoneOffset.ofHours(0), 1); @@ -222,6 +234,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), createLDT(2008, 12, 1), ZoneOffset.ofHours(0), 1); } + @Test public void test_London_getOffsetInfo_toDST() { ZoneId test = ZoneId.of("Europe/London"); checkOffset(test.getRules(), createLDT(2008, 3, 24), ZoneOffset.ofHours(0), 1); @@ -238,6 +251,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 3, 30, 2, 0, 0, 0), ZoneOffset.ofHours(1), 1); } + @Test public void test_London_getOffsetInfo_fromDST() { ZoneId test = ZoneId.of("Europe/London"); checkOffset(test.getRules(), createLDT(2008, 10, 24), ZoneOffset.ofHours(1), 1); @@ -254,22 +268,23 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 10, 26, 2, 0, 0, 0), ZoneOffset.ofHours(0), 1); } + @Test public void test_London_getOffsetInfo_gap() { ZoneId test = ZoneId.of("Europe/London"); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 30, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(0), GAP); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(0)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(1)); - assertEquals(trans.getInstant(), dateTime.toInstant(ZoneOffset.UTC)); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2008, 3, 30, 1, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2008, 3, 30, 2, 0)); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(0)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-30T01:00Z to +01:00]"); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(0), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(1), trans.getOffsetAfter()); + assertEquals(dateTime.toInstant(ZoneOffset.UTC), trans.getInstant()); + assertEquals(LocalDateTime.of(2008, 3, 30, 1, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(2008, 3, 30, 2, 0), trans.getDateTimeAfter()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-1))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(0))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(1))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(2))); + assertEquals("Transition[Gap at 2008-03-30T01:00Z to +01:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(0))); @@ -277,25 +292,26 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherTrans = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } + @Test public void test_London_getOffsetInfo_overlap() { ZoneId test = ZoneId.of("Europe/London"); final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(1), OVERLAP); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(1)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(0)); - assertEquals(trans.getInstant(), dateTime.toInstant(ZoneOffset.UTC)); - assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2008, 10, 26, 2, 0)); - assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2008, 10, 26, 1, 0)); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(0)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(1)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T02:00+01:00 to Z]"); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(1), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(0), trans.getOffsetAfter()); + assertEquals(dateTime.toInstant(ZoneOffset.UTC), trans.getInstant()); + assertEquals(LocalDateTime.of(2008, 10, 26, 2, 0), trans.getDateTimeBefore()); + assertEquals(LocalDateTime.of(2008, 10, 26, 1, 0), trans.getDateTimeAfter()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-1))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(0))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(1))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(2))); + assertEquals("Transition[Overlap at 2008-10-26T02:00+01:00 to Z]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(1))); @@ -303,64 +319,69 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherTrans = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } //----------------------------------------------------------------------- // Europe/Paris //----------------------------------------------------------------------- + @Test public void test_Paris() { ZoneId test = ZoneId.of("Europe/Paris"); - assertEquals(test.getId(), "Europe/Paris"); - assertEquals(test.getRules().isFixedOffset(), false); + assertEquals("Europe/Paris", test.getId()); + assertEquals(false, test.getRules().isFixedOffset()); } + @Test public void test_Paris_getOffset() { ZoneId test = ZoneId.of("Europe/Paris"); - assertEquals(test.getRules().getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 1, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 2, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 4, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 5, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 6, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 7, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 8, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 9, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 10, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 11, 1, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 12, 1, ZoneOffset.UTC))); } + @Test public void test_Paris_getOffset_toDST() { ZoneId test = ZoneId.of("Europe/Paris"); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC))); } + @Test public void test_Paris_getOffset_fromDST() { ZoneId test = ZoneId.of("Europe/Paris"); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC))); // cutover at 01:00Z - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC)), ZoneOffset.ofHours(2)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)), ZoneOffset.ofHours(1)); + assertEquals(ZoneOffset.ofHours(2), test.getRules().getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC))); + assertEquals(ZoneOffset.ofHours(1), test.getRules().getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC))); } + @Test public void test_Paris_getOffsetInfo() { ZoneId test = ZoneId.of("Europe/Paris"); checkOffset(test.getRules(), createLDT(2008, 1, 1), ZoneOffset.ofHours(1), 1); @@ -377,6 +398,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), createLDT(2008, 12, 1), ZoneOffset.ofHours(1), 1); } + @Test public void test_Paris_getOffsetInfo_toDST() { ZoneId test = ZoneId.of("Europe/Paris"); checkOffset(test.getRules(), createLDT(2008, 3, 24), ZoneOffset.ofHours(1), 1); @@ -393,6 +415,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 3, 30, 3, 0, 0, 0), ZoneOffset.ofHours(2), 1); } + @Test public void test_Paris_getOffsetInfo_fromDST() { ZoneId test = ZoneId.of("Europe/Paris"); checkOffset(test.getRules(), createLDT(2008, 10, 24), ZoneOffset.ofHours(2), 1); @@ -409,20 +432,21 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 10, 26, 3, 0, 0, 0), ZoneOffset.ofHours(1), 1); } + @Test public void test_Paris_getOffsetInfo_gap() { ZoneId test = ZoneId.of("Europe/Paris"); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 30, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(1), GAP); - assertEquals(trans.isGap(), true); - assertEquals(trans.isOverlap(), false); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(1)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(2)); - assertEquals(trans.getInstant(), createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(0)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(3)), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-30T02:00+01:00 to +02:00]"); + assertEquals(true, trans.isGap()); + assertEquals(false, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(1), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(2), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(0))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(1))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(2))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(3))); + assertEquals("Transition[Gap at 2008-03-30T02:00+01:00 to +02:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(1))); @@ -430,23 +454,24 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherDis = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherDis)); - assertEquals(trans.hashCode(), otherDis.hashCode()); + assertEquals(otherDis.hashCode(), trans.hashCode()); } + @Test public void test_Paris_getOffsetInfo_overlap() { ZoneId test = ZoneId.of("Europe/Paris"); final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(2), OVERLAP); - assertEquals(trans.isGap(), false); - assertEquals(trans.isOverlap(), true); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(2)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(1)); - assertEquals(trans.getInstant(), createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(0)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(1)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(3)), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T03:00+02:00 to +01:00]"); + assertEquals(false, trans.isGap()); + assertEquals(true, trans.isOverlap()); + assertEquals(ZoneOffset.ofHours(2), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(1), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC), trans.getInstant()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(0))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(1))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(2))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(3))); + assertEquals("Transition[Overlap at 2008-10-26T03:00+02:00 to +01:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(2))); @@ -454,77 +479,82 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherDis = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherDis)); - assertEquals(trans.hashCode(), otherDis.hashCode()); + assertEquals(otherDis.hashCode(), trans.hashCode()); } //----------------------------------------------------------------------- // America/New_York //----------------------------------------------------------------------- + @Test public void test_NewYork() { ZoneId test = ZoneId.of("America/New_York"); - assertEquals(test.getId(), "America/New_York"); - assertEquals(test.getRules().isFixedOffset(), false); + assertEquals("America/New_York", test.getId()); + assertEquals(false, test.getRules().isFixedOffset()); } + @Test public void test_NewYork_getOffset() { ZoneId test = ZoneId.of("America/New_York"); ZoneOffset offset = ZoneOffset.ofHours(-5); - assertEquals(test.getRules().getOffset(createInstant(2008, 1, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 2, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 4, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 5, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 6, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 7, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 8, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 9, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 12, 1, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 1, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 2, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 4, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 5, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 6, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 7, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 8, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 9, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 10, 28, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 28, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 12, 28, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 1, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 2, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 3, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 4, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 5, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 6, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 7, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 8, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 9, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 10, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 11, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 12, 1, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 1, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 2, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 4, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 5, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 6, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 7, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 8, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 9, 28, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 10, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 28, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 12, 28, offset))); } + @Test public void test_NewYork_getOffset_toDST() { ZoneId test = ZoneId.of("America/New_York"); ZoneOffset offset = ZoneOffset.ofHours(-5); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 8, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 9, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 10, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 11, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 12, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 13, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 14, offset)), ZoneOffset.ofHours(-4)); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 3, 8, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 3, 9, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 10, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 11, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 12, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 13, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 14, offset))); // cutover at 02:00 local - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 9, 1, 59, 59, 999999999, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 3, 9, 2, 0, 0, 0, offset)), ZoneOffset.ofHours(-4)); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 3, 9, 1, 59, 59, 999999999, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 3, 9, 2, 0, 0, 0, offset))); } + @Test public void test_NewYork_getOffset_fromDST() { ZoneId test = ZoneId.of("America/New_York"); ZoneOffset offset = ZoneOffset.ofHours(-4); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 1, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 2, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 3, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 4, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 5, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 6, offset)), ZoneOffset.ofHours(-5)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 7, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 11, 1, offset))); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 11, 2, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 3, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 4, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 5, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 6, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 7, offset))); // cutover at 02:00 local - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 2, 1, 59, 59, 999999999, offset)), ZoneOffset.ofHours(-4)); - assertEquals(test.getRules().getOffset(createInstant(2008, 11, 2, 2, 0, 0, 0, offset)), ZoneOffset.ofHours(-5)); + assertEquals(ZoneOffset.ofHours(-4), test.getRules().getOffset(createInstant(2008, 11, 2, 1, 59, 59, 999999999, offset))); + assertEquals(ZoneOffset.ofHours(-5), test.getRules().getOffset(createInstant(2008, 11, 2, 2, 0, 0, 0, offset))); } + @Test public void test_NewYork_getOffsetInfo() { ZoneId test = ZoneId.of("America/New_York"); checkOffset(test.getRules(), createLDT(2008, 1, 1), ZoneOffset.ofHours(-5), 1); @@ -553,6 +583,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), createLDT(2008, 12, 28), ZoneOffset.ofHours(-5), 1); } + @Test public void test_NewYork_getOffsetInfo_toDST() { ZoneId test = ZoneId.of("America/New_York"); checkOffset(test.getRules(), createLDT(2008, 3, 8), ZoneOffset.ofHours(-5), 1); @@ -568,6 +599,7 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 3, 9, 3, 0, 0, 0), ZoneOffset.ofHours(-4), 1); } + @Test public void test_NewYork_getOffsetInfo_fromDST() { ZoneId test = ZoneId.of("America/New_York"); checkOffset(test.getRules(), createLDT(2008, 11, 1), ZoneOffset.ofHours(-4), 1); @@ -583,18 +615,19 @@ public class TestZoneId extends AbstractTest { checkOffset(test.getRules(), LocalDateTime.of(2008, 11, 2, 2, 0, 0, 0), ZoneOffset.ofHours(-5), 1); } + @Test public void test_NewYork_getOffsetInfo_gap() { ZoneId test = ZoneId.of("America/New_York"); final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 9, 2, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(-5), GAP); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(-5)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(-4)); - assertEquals(trans.getInstant(), createInstant(2008, 3, 9, 2, 0, 0, 0, ZoneOffset.ofHours(-5))); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-6)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-5)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-4)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-3)), false); - assertEquals(trans.toString(), "Transition[Gap at 2008-03-09T02:00-05:00 to -04:00]"); + assertEquals(ZoneOffset.ofHours(-5), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(-4), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 3, 9, 2, 0, 0, 0, ZoneOffset.ofHours(-5)), trans.getInstant()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-6))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-5))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-4))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-3))); + assertEquals("Transition[Gap at 2008-03-09T02:00-05:00 to -04:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(-5))); @@ -603,21 +636,22 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherTrans = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } + @Test public void test_NewYork_getOffsetInfo_overlap() { ZoneId test = ZoneId.of("America/New_York"); final LocalDateTime dateTime = LocalDateTime.of(2008, 11, 2, 1, 0, 0, 0); ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(-4), OVERLAP); - assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(-4)); - assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(-5)); - assertEquals(trans.getInstant(), createInstant(2008, 11, 2, 2, 0, 0, 0, ZoneOffset.ofHours(-4))); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-5)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-4)), true); - assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), false); - assertEquals(trans.toString(), "Transition[Overlap at 2008-11-02T02:00-04:00 to -05:00]"); + assertEquals(ZoneOffset.ofHours(-4), trans.getOffsetBefore()); + assertEquals(ZoneOffset.ofHours(-5), trans.getOffsetAfter()); + assertEquals(createInstant(2008, 11, 2, 2, 0, 0, 0, ZoneOffset.ofHours(-4)), trans.getInstant()); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(-1))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(-5))); + assertEquals(true, trans.isValidOffset(ZoneOffset.ofHours(-4))); + assertEquals(false, trans.isValidOffset(ZoneOffset.ofHours(2))); + assertEquals("Transition[Overlap at 2008-11-02T02:00-04:00 to -05:00]", trans.toString()); assertFalse(trans.equals(null)); assertFalse(trans.equals(ZoneOffset.ofHours(-4))); @@ -626,22 +660,24 @@ public class TestZoneId extends AbstractTest { final ZoneOffsetTransition otherTrans = test.getRules().getTransition(dateTime); assertTrue(trans.equals(otherTrans)); - assertEquals(trans.hashCode(), otherTrans.hashCode()); + assertEquals(otherTrans.hashCode(), trans.hashCode()); } //----------------------------------------------------------------------- // getXxx() isXxx() //----------------------------------------------------------------------- + @Test public void test_get_Tzdb() { ZoneId test = ZoneId.of("Europe/London"); - assertEquals(test.getId(), "Europe/London"); - assertEquals(test.getRules().isFixedOffset(), false); + assertEquals("Europe/London", test.getId()); + assertEquals(false, test.getRules().isFixedOffset()); } + @Test public void test_get_TzdbFixed() { ZoneId test = ZoneId.of("+01:30"); - assertEquals(test.getId(), "+01:30"); - assertEquals(test.getRules().isFixedOffset(), true); + assertEquals("+01:30", test.getId()); + assertEquals(true, test.getRules().isFixedOffset()); } //----------------------------------------------------------------------- @@ -665,17 +701,17 @@ public class TestZoneId extends AbstractTest { private ZoneOffsetTransition checkOffset(ZoneRules rules, LocalDateTime dateTime, ZoneOffset offset, int type) { List validOffsets = rules.getValidOffsets(dateTime); - assertEquals(validOffsets.size(), type); - assertEquals(rules.getOffset(dateTime), offset); + assertEquals(type, validOffsets.size()); + assertEquals(offset, rules.getOffset(dateTime)); if (type == 1) { - assertEquals(validOffsets.get(0), offset); + assertEquals(offset, validOffsets.get(0)); return null; } else { ZoneOffsetTransition zot = rules.getTransition(dateTime); assertNotNull(zot); - assertEquals(zot.isOverlap(), type == 2); - assertEquals(zot.isGap(), type == 0); - assertEquals(zot.isValidOffset(offset), type == 2); + assertEquals(type == 2, zot.isOverlap()); + assertEquals(type == 0, zot.isGap()); + assertEquals(type == 2, zot.isValidOffset(offset)); return zot; } } diff --git a/test/jdk/java/time/test/java/time/TestZoneOffset.java b/test/jdk/java/time/test/java/time/TestZoneOffset.java index b85a629aefc..8a42fe2a0ab 100644 --- a/test/jdk/java/time/test/java/time/TestZoneOffset.java +++ b/test/jdk/java/time/test/java/time/TestZoneOffset.java @@ -60,17 +60,16 @@ */ package test.java.time; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; import java.util.Set; import java.time.ZoneOffset; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test ZoneOffset. */ -@Test public class TestZoneOffset extends AbstractTest { @Test diff --git a/test/jdk/java/time/test/java/time/TestZonedDateTime.java b/test/jdk/java/time/test/java/time/TestZonedDateTime.java index 15a95d1f3bc..436187cf3d0 100644 --- a/test/jdk/java/time/test/java/time/TestZonedDateTime.java +++ b/test/jdk/java/time/test/java/time/TestZonedDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,21 +59,20 @@ */ package test.java.time; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.Duration; import java.time.LocalDateTime; import java.time.ZonedDateTime; import java.time.ZoneId; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test ZonedDateTime. * * @bug 8211990 */ -@Test public class TestZonedDateTime extends AbstractTest { @Test @@ -89,6 +88,6 @@ public class TestZonedDateTime extends AbstractTest { ZonedDateTime end = ZonedDateTime.of(LocalDateTime.MAX, sanJose); ZonedDateTime start = end.withZoneSameLocal(tokyo); - assertEquals(Duration.between(start, end), Duration.ofHours(17)); + assertEquals(Duration.ofHours(17), Duration.between(start, end)); } } diff --git a/test/jdk/java/time/test/java/time/chrono/TestChronoLocalDate.java b/test/jdk/java/time/test/java/time/chrono/TestChronoLocalDate.java index 79410941206..bb738feee05 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestChronoLocalDate.java +++ b/test/jdk/java/time/test/java/time/chrono/TestChronoLocalDate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -54,8 +54,8 @@ */ package test.java.time.chrono; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.LocalDate; import java.time.LocalDateTime; @@ -69,16 +69,16 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test chrono local date. */ -@Test public class TestChronoLocalDate { // this class primarily tests whether the generics work OK //----------------------------------------------------------------------- + @Test public void test_date_comparator_checkGenerics_ISO() { List dates = new ArrayList<>(); ChronoLocalDate date = LocalDate.of(2013, 1, 1); @@ -99,10 +99,11 @@ public class TestChronoLocalDate { List copy = new ArrayList<>(dates); Collections.shuffle(copy); Collections.sort(copy, ChronoLocalDate.timeLineOrder()); - assertEquals(copy, dates); + assertEquals(dates, copy); assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); } + @Test public void test_date_comparator_checkGenerics_LocalDate() { List dates = new ArrayList<>(); LocalDate date = LocalDate.of(2013, 1, 1); @@ -123,11 +124,12 @@ public class TestChronoLocalDate { List copy = new ArrayList<>(dates); Collections.shuffle(copy); Collections.sort(copy, ChronoLocalDate.timeLineOrder()); - assertEquals(copy, dates); + assertEquals(dates, copy); assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); } //----------------------------------------------------------------------- + @Test public void test_date_checkGenerics_genericsMethod() { Chronology chrono = ThaiBuddhistChronology.INSTANCE; ChronoLocalDate date = chrono.dateNow(); @@ -138,6 +140,7 @@ public class TestChronoLocalDate { date = processClassWeird(ThaiBuddhistDate.class); } + @Test public void test_date_checkGenerics_genericsMethod_concreteType() { ThaiBuddhistChronology chrono = ThaiBuddhistChronology.INSTANCE; ThaiBuddhistDate date = chrono.dateNow(); @@ -149,6 +152,7 @@ public class TestChronoLocalDate { // date = processClassWeird(ThaiBuddhistDate.class); // does not compile (correct) } + @Test public void test_date_checkGenerics_genericsMethod_withType() { Chronology chrono = ThaiBuddhistChronology.INSTANCE; @SuppressWarnings("unchecked") @@ -180,6 +184,7 @@ public class TestChronoLocalDate { return null; } + @Test public void test_date_checkGenerics_chronoLocalDateTime1() { LocalDateTime now = LocalDateTime.now(); Chronology chrono = ThaiBuddhistChronology.INSTANCE; @@ -187,6 +192,7 @@ public class TestChronoLocalDate { ldt = processCLDT(ldt); } + @Test public void test_date_checkGenerics_chronoLocalDateTime2() { LocalDateTime now = LocalDateTime.now(); Chronology chrono = ThaiBuddhistChronology.INSTANCE; diff --git a/test/jdk/java/time/test/java/time/chrono/TestChronologyPerf.java b/test/jdk/java/time/test/java/time/chrono/TestChronologyPerf.java index 5026ebf1700..ab6bdd7ee1d 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestChronologyPerf.java +++ b/test/jdk/java/time/test/java/time/chrono/TestChronologyPerf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,7 +29,7 @@ import java.time.chrono.HijrahDate; import java.time.temporal.ChronoUnit; import java.util.Set; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test the speed of initializing all calendars. diff --git a/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java b/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java index 4e20ceb5495..99cd7499adb 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java +++ b/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java @@ -30,10 +30,11 @@ import java.util.Arrays; import java.util.Locale; import java.util.stream.Stream; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests Era.getDisplayName() correctly returns the name based on each @@ -42,7 +43,7 @@ import static org.testng.Assert.assertFalse; * * @bug 8171049 8224105 8240626 8354548 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestEraDisplayName { private static final Locale THAI = Locale.forLanguageTag("th-TH"); private static final Locale EGYPT = Locale.forLanguageTag("ar-EG"); @@ -52,7 +53,6 @@ public class TestEraDisplayName { DateTimeFormatter.ofPattern("yyyy MM dd GGGG G GGGGG") .withChronology(JapaneseChronology.INSTANCE); - @DataProvider(name="eraDisplayName") Object[][] eraDisplayName() { return new Object[][] { // Era, text style, displyay locale, expected name @@ -141,7 +141,6 @@ public class TestEraDisplayName { }; } - @DataProvider Object[][] allLocales() { return Arrays.stream(Locale.getAvailableLocales()) .map(Stream::of) @@ -149,7 +148,6 @@ public class TestEraDisplayName { .toArray(Object[][]::new); } - @DataProvider Object[][] allEras() { return Stream.of(IsoEra.values(), JapaneseEra.values(), @@ -162,29 +160,28 @@ public class TestEraDisplayName { .toArray(Object[][]::new); } - @Test(dataProvider="eraDisplayName") + @ParameterizedTest + @MethodSource("eraDisplayName") public void test_eraDisplayName(Era era, TextStyle style, Locale locale, String expected) { - assertEquals(era.getDisplayName(style, locale), expected); + assertEquals(expected, era.getDisplayName(style, locale)); } - @Test(dataProvider="allLocales") + @ParameterizedTest + @MethodSource("allLocales") public void test_reiwaNames(Locale locale) throws DateTimeParseException { DateTimeFormatter f = JAPANESE_FORMATTER.withLocale(locale); - assertEquals(LocalDate.parse(REIWA_1ST.format(f), f), REIWA_1ST); + assertEquals(REIWA_1ST, LocalDate.parse(REIWA_1ST.format(f), f)); } // Make sure era display names aren't empty // @bug 8240626 - @Test(dataProvider="allEras") + @ParameterizedTest + @MethodSource("allEras") public void test_noEmptyEraNames(Era era) { Arrays.stream(Locale.getAvailableLocales()) - .forEach(l -> { - Arrays.stream(TextStyle.values()) - .forEach(s -> { - assertFalse(era.getDisplayName(s, l).isEmpty(), - "getDisplayName() returns empty display name for era: " + era - + ", style: " + s + ", locale: " + l); - }); - }); + .forEach(l -> Arrays.stream(TextStyle.values()) + .forEach(s -> assertFalse(era.getDisplayName(s, l).isEmpty(), + "getDisplayName() returns empty display name for era: " + era + + ", style: " + s + ", locale: " + l))); } } diff --git a/test/jdk/java/time/test/java/time/chrono/TestExampleCode.java b/test/jdk/java/time/test/java/time/chrono/TestExampleCode.java index 5258a0b8062..b4e3c41d5e3 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestExampleCode.java +++ b/test/jdk/java/time/test/java/time/chrono/TestExampleCode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -55,7 +55,7 @@ package test.java.time.chrono; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDate; import java.time.LocalTime; @@ -72,13 +72,16 @@ import java.time.temporal.ChronoUnit; import java.util.Locale; import java.util.Set; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test case verify that the example code in the package-info.java compiles * and runs. */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestExampleCode { @Test @@ -113,14 +116,14 @@ public class TestExampleCode { //----------------------------------------------------------------------- // Data provider for Hijrah Type names //----------------------------------------------------------------------- - @DataProvider(name = "HijrahTypeNames") Object[][] data_of_ummalqura() { return new Object[][]{ { "Hijrah-umalqura", "islamic-umalqura"}, }; } - @Test(dataProvider= "HijrahTypeNames") + @ParameterizedTest + @MethodSource("data_of_ummalqura") public void test_HijrahTypeViaLocale(String calendarId, String calendarType) { Locale.Builder builder = new Locale.Builder(); builder.setLanguage("en").setRegion("US"); @@ -130,7 +133,7 @@ public class TestExampleCode { System.out.printf(" Locale language tag: %s, Chronology ID: %s, type: %s%n", locale.toLanguageTag(), chrono, chrono.getCalendarType()); Chronology expected = Chronology.of(calendarId); - assertEquals(chrono, expected, "Expected chronology not found"); + assertEquals(expected, chrono, "Expected chronology not found"); } @Test diff --git a/test/jdk/java/time/test/java/time/chrono/TestIsoChronoImpl.java b/test/jdk/java/time/test/java/time/chrono/TestIsoChronoImpl.java index 59f5016a6fc..adc8949e61e 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestIsoChronoImpl.java +++ b/test/jdk/java/time/test/java/time/chrono/TestIsoChronoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -58,7 +58,8 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DayOfWeek; import java.time.LocalDate; @@ -69,16 +70,16 @@ import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestIsoChronoImpl { - @DataProvider(name = "RangeVersusCalendar") Object[][] provider_rangeVersusCalendar() { return new Object[][]{ {LocalDate.of(1583, 1, 1), LocalDate.of(2100, 1, 1)}, @@ -88,10 +89,11 @@ public class TestIsoChronoImpl { //----------------------------------------------------------------------- // Verify ISO Calendar matches java.util.Calendar for range //----------------------------------------------------------------------- - @Test(dataProvider = "RangeVersusCalendar") + @ParameterizedTest + @MethodSource("provider_rangeVersusCalendar") public void test_IsoChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { GregorianCalendar cal = new GregorianCalendar(); - assertEquals(cal.getCalendarType(), "gregory", "Unexpected calendar type"); + assertEquals("gregory", cal.getCalendarType(), "Unexpected calendar type"); LocalDate isoDate = IsoChronology.INSTANCE.date(isoStartDate); cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); @@ -100,9 +102,9 @@ public class TestIsoChronoImpl { cal.set(Calendar.DAY_OF_MONTH, isoDate.get(DAY_OF_MONTH)); while (isoDate.isBefore(isoEndDate)) { - assertEquals(isoDate.get(DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal); - assertEquals(isoDate.get(MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + isoDate); - assertEquals(isoDate.get(YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + isoDate); + assertEquals(cal.get(Calendar.DAY_OF_MONTH), isoDate.get(DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal); + assertEquals(cal.get(Calendar.MONTH) + 1, isoDate.get(MONTH_OF_YEAR), "Month mismatch in " + isoDate); + assertEquals(cal.get(Calendar.YEAR), isoDate.get(YEAR_OF_ERA), "Year mismatch in " + isoDate); isoDate = isoDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); @@ -113,10 +115,11 @@ public class TestIsoChronoImpl { // Verify ISO Calendar matches java.util.Calendar // DayOfWeek, WeekOfMonth, WeekOfYear for range //----------------------------------------------------------------------- - @Test(dataProvider = "RangeVersusCalendar") + @ParameterizedTest + @MethodSource("provider_rangeVersusCalendar") public void test_DayOfWeek_IsoChronology_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { GregorianCalendar cal = new GregorianCalendar(); - assertEquals(cal.getCalendarType(), "gregory", "Unexpected calendar type"); + assertEquals("gregory", cal.getCalendarType(), "Unexpected calendar type"); LocalDate isoDate = IsoChronology.INSTANCE.date(isoStartDate); for (DayOfWeek firstDayOfWeek : DayOfWeek.values()) { @@ -132,29 +135,29 @@ public class TestIsoChronoImpl { // For every date in the range while (isoDate.isBefore(isoEndDate)) { - assertEquals(isoDate.get(DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal); - assertEquals(isoDate.get(MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + isoDate); - assertEquals(isoDate.get(YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + isoDate); + assertEquals(cal.get(Calendar.DAY_OF_MONTH), isoDate.get(DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal); + assertEquals(cal.get(Calendar.MONTH) + 1, isoDate.get(MONTH_OF_YEAR), "Month mismatch in " + isoDate); + assertEquals(cal.get(Calendar.YEAR), isoDate.get(YEAR_OF_ERA), "Year mismatch in " + isoDate); int jdow = Math.floorMod(cal.get(Calendar.DAY_OF_WEEK) - 2, 7) + 1; int dow = isoDate.get(weekDef.dayOfWeek()); - assertEquals(jdow, dow, "Calendar DayOfWeek does not match ISO DayOfWeek"); + assertEquals(dow, jdow, "Calendar DayOfWeek does not match ISO DayOfWeek"); int jweekOfMonth = cal.get(Calendar.WEEK_OF_MONTH); int isoWeekOfMonth = isoDate.get(weekDef.weekOfMonth()); - assertEquals(jweekOfMonth, isoWeekOfMonth, "Calendar WeekOfMonth does not match ISO WeekOfMonth"); + assertEquals(isoWeekOfMonth, jweekOfMonth, "Calendar WeekOfMonth does not match ISO WeekOfMonth"); int jweekOfYear = cal.get(Calendar.WEEK_OF_YEAR); int weekOfYear = isoDate.get(weekDef.weekOfWeekBasedYear()); - assertEquals(jweekOfYear, weekOfYear, "GregorianCalendar WeekOfYear does not match WeekOfWeekBasedYear"); + assertEquals(weekOfYear, jweekOfYear, "GregorianCalendar WeekOfYear does not match WeekOfWeekBasedYear"); int jWeekYear = cal.getWeekYear(); int weekBasedYear = isoDate.get(weekDef.weekBasedYear()); - assertEquals(jWeekYear, weekBasedYear, "GregorianCalendar getWeekYear does not match YearOfWeekBasedYear"); + assertEquals(weekBasedYear, jWeekYear, "GregorianCalendar getWeekYear does not match YearOfWeekBasedYear"); int jweeksInWeekyear = cal.getWeeksInWeekYear(); int weeksInWeekBasedYear = (int)isoDate.range(weekDef.weekOfWeekBasedYear()).getMaximum(); - assertEquals(jweeksInWeekyear, weeksInWeekBasedYear, "length of weekBasedYear"); + assertEquals(weeksInWeekBasedYear, jweeksInWeekyear, "length of weekBasedYear"); isoDate = isoDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); diff --git a/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java b/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java index fc2fa9798af..6ed24d579dd 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java +++ b/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -54,7 +54,7 @@ */ package test.java.time.chrono; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDate; import java.time.LocalTime; @@ -71,19 +71,20 @@ import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestJapaneseChronoImpl { /** * Range of years to check consistency with java.util.Calendar */ - @DataProvider(name="RangeVersusCalendar") Object[][] provider_rangeVersusCalendar() { return new Object[][] { {LocalDate.of(1873, 1, 1), LocalDate.of(2100, 1, 1)}, @@ -93,13 +94,14 @@ public class TestJapaneseChronoImpl { //----------------------------------------------------------------------- // Verify Japanese Calendar matches java.util.Calendar for range //----------------------------------------------------------------------- - @Test(dataProvider="RangeVersusCalendar") + @ParameterizedTest + @MethodSource("provider_rangeVersusCalendar") public void test_JapaneseChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese"); - assertEquals(locale.toString(), "ja_JP_#u-ca-japanese", "Unexpected locale"); + assertEquals("ja_JP_#u-ca-japanese", locale.toString(), "Unexpected locale"); Calendar cal = java.util.Calendar.getInstance(locale); - assertEquals(cal.getCalendarType(), "japanese", "Unexpected calendar type"); + assertEquals("japanese", cal.getCalendarType(), "Unexpected calendar type"); JapaneseDate jDate = JapaneseChronology.INSTANCE.date(isoStartDate); @@ -110,9 +112,9 @@ public class TestJapaneseChronoImpl { cal.setTimeInMillis(millis); while (jDate.isBefore(isoEndDate)) { - assertEquals(jDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + jDate + "; cal: " + cal); - assertEquals(jDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + jDate); - assertEquals(jDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + jDate); + assertEquals(cal.get(Calendar.DAY_OF_MONTH), jDate.get(ChronoField.DAY_OF_MONTH), "Day mismatch in " + jDate + "; cal: " + cal); + assertEquals(cal.get(Calendar.MONTH) + 1, jDate.get(ChronoField.MONTH_OF_YEAR), "Month mismatch in " + jDate); + assertEquals(cal.get(Calendar.YEAR), jDate.get(ChronoField.YEAR_OF_ERA), "Year mismatch in " + jDate); jDate = jDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); @@ -136,11 +138,11 @@ public class TestJapaneseChronoImpl { cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); cal.setTimeInMillis(millis); - assertEquals(jd.get(ChronoField.DAY_OF_YEAR), cal.get(Calendar.DAY_OF_YEAR), + assertEquals(cal.get(Calendar.DAY_OF_YEAR), jd.get(ChronoField.DAY_OF_YEAR), "different DAY_OF_YEAR values in " + era + ", year: " + year); - assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMaximum(), cal.getActualMaximum(Calendar.DAY_OF_YEAR), + assertEquals(cal.getActualMaximum(Calendar.DAY_OF_YEAR), jd.range(ChronoField.DAY_OF_YEAR).getMaximum(), "different maximum for DAY_OF_YEAR in " + era + ", year: " + year); - assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMinimum(), cal.getActualMinimum(Calendar.DAY_OF_YEAR), + assertEquals(cal.getActualMinimum(Calendar.DAY_OF_YEAR), jd.range(ChronoField.DAY_OF_YEAR).getMinimum(), "different minimum for DAY_OF_YEAR in " + era + ", year: " + year); } } diff --git a/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java b/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java index 6e7df8638f9..85c33a964a3 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java +++ b/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,20 +29,22 @@ import java.time.temporal.*; import java.util.List; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests for the Japanese chronology */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestJapaneseChronology { private static final JapaneseChronology JAPANESE = JapaneseChronology.INSTANCE; private static final Locale jaJPJP = Locale.forLanguageTag("ja-JP-u-ca-japanese"); - @DataProvider(name="transitions") Object[][] transitionData() { return new Object[][] { // Japanese era, yearOfEra, month, dayOfMonth, gregorianYear @@ -62,7 +64,6 @@ public class TestJapaneseChronology { }; } - @DataProvider(name="day_year_data") Object[][] dayYearData() { return new Object[][] { // Japanese era, yearOfEra, dayOfYear, month, dayOfMonth @@ -80,7 +81,6 @@ public class TestJapaneseChronology { }; } - @DataProvider(name="range_data") Object[][] rangeData() { return new Object[][] { // field, minSmallest, minLargest, maxSmallest, maxLargest @@ -91,7 +91,6 @@ public class TestJapaneseChronology { }; } - @DataProvider(name="invalid_dates") Object[][] invalidDatesData() { return new Object[][] { // Japanese era, yearOfEra, month, dayOfMonth @@ -114,7 +113,6 @@ public class TestJapaneseChronology { }; } - @DataProvider(name="invalid_eraYear") Object[][] invalidEraYearData() { return new Object[][] { // Japanese era, yearOfEra @@ -136,7 +134,6 @@ public class TestJapaneseChronology { }; } - @DataProvider(name="invalid_day_year_data") Object[][] invalidDayYearData() { return new Object[][] { // Japanese era, yearOfEra, dayOfYear @@ -155,7 +152,6 @@ public class TestJapaneseChronology { }; } - @DataProvider Object[][] eraNameData() { return new Object[][] { // Japanese era, name, exception @@ -171,56 +167,69 @@ public class TestJapaneseChronology { @Test public void test_ofLocale() { // must be a singleton - assertEquals(Chronology.ofLocale(jaJPJP) == JAPANESE, true); + assertEquals(true, Chronology.ofLocale(jaJPJP) == JAPANESE); } - @Test(dataProvider="transitions") + @ParameterizedTest + @MethodSource("transitionData") public void test_transitions(JapaneseEra era, int yearOfEra, int month, int dayOfMonth, int gregorianYear) { - assertEquals(JAPANESE.prolepticYear(era, yearOfEra), gregorianYear); + assertEquals(gregorianYear, JAPANESE.prolepticYear(era, yearOfEra)); JapaneseDate jdate1 = JapaneseDate.of(era, yearOfEra, month, dayOfMonth); JapaneseDate jdate2 = JapaneseDate.of(gregorianYear, month, dayOfMonth); - assertEquals(jdate1, jdate2); + assertEquals(jdate2, jdate1); } - @Test(dataProvider="range_data") + @ParameterizedTest + @MethodSource("rangeData") public void test_range(ChronoField field, int minSmallest, int minLargest, int maxSmallest, int maxLargest) { ValueRange range = JAPANESE.range(field); - assertEquals(range.getMinimum(), minSmallest); - assertEquals(range.getLargestMinimum(), minLargest); - assertEquals(range.getSmallestMaximum(), maxSmallest); - assertEquals(range.getMaximum(), maxLargest); + assertEquals(minSmallest, range.getMinimum()); + assertEquals(minLargest, range.getLargestMinimum()); + assertEquals(maxSmallest, range.getSmallestMaximum()); + assertEquals(maxLargest, range.getMaximum()); } - @Test(dataProvider="day_year_data") + @ParameterizedTest + @MethodSource("dayYearData") public void test_firstDayOfEra(JapaneseEra era, int yearOfEra, int dayOfYear, int month, int dayOfMonth) { JapaneseDate date1 = JAPANESE.dateYearDay(era, yearOfEra, dayOfYear); JapaneseDate date2 = JAPANESE.date(era, yearOfEra, month, dayOfMonth); - assertEquals(date1, date2); + assertEquals(date2, date1); } - @Test(dataProvider="invalid_dates", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("invalidDatesData") public void test_invalidDate(JapaneseEra era, int yearOfEra, int month, int dayOfMonth) { - JapaneseDate jdate = JapaneseDate.of(era, yearOfEra, month, dayOfMonth); - System.out.printf("No DateTimeException with %s %d.%02d.%02d%n", era, yearOfEra, month, dayOfMonth); + Assertions.assertThrows(DateTimeException.class, () -> { + JapaneseDate jdate = JapaneseDate.of(era, yearOfEra, month, dayOfMonth); + System.out.printf("No DateTimeException with %s %d.%02d.%02d%n", era, yearOfEra, month, dayOfMonth); + }); } - @Test(dataProvider="invalid_eraYear", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("invalidEraYearData") public void test_invalidEraYear(JapaneseEra era, int yearOfEra) { - int year = JAPANESE.prolepticYear(era, yearOfEra); - System.out.printf("No DateTimeException with era=%s, year=%d%n", era, yearOfEra); + Assertions.assertThrows(DateTimeException.class, () -> { + int year = JAPANESE.prolepticYear(era, yearOfEra); + System.out.printf("No DateTimeException with era=%s, year=%d%n", era, yearOfEra); + }); } - @Test(dataProvider="invalid_day_year_data", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("invalidDayYearData") public void test_invalidDayYear(JapaneseEra era, int yearOfEra, int dayOfYear) { - JapaneseDate date = JAPANESE.dateYearDay(era, yearOfEra, dayOfYear); - System.out.printf("No DateTimeException with era=%s, year=%d, dayOfYear=%d%n", era, yearOfEra, dayOfYear); + Assertions.assertThrows(DateTimeException.class, () -> { + JapaneseDate date = JAPANESE.dateYearDay(era, yearOfEra, dayOfYear); + System.out.printf("No DateTimeException with era=%s, year=%d, dayOfYear=%d%n", era, yearOfEra, dayOfYear); + }); } - @Test(dataProvider="eraNameData") + @ParameterizedTest + @MethodSource("eraNameData") public void test_eraName(String eraName, JapaneseEra era, Class expectedEx) { try { - assertEquals(JapaneseEra.valueOf(eraName), era); + assertEquals(era, JapaneseEra.valueOf(eraName)); } catch (Exception ex) { assertTrue(expectedEx.isInstance(ex)); } diff --git a/test/jdk/java/time/test/java/time/chrono/TestServiceLoader.java b/test/jdk/java/time/test/java/time/chrono/TestServiceLoader.java index 3eaa4253681..93e00b48b7a 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestServiceLoader.java +++ b/test/jdk/java/time/test/java/time/chrono/TestServiceLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,21 +59,20 @@ */ package test.java.time.chrono; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.time.chrono.Chronology; import java.util.HashMap; import java.util.Map; import java.util.ServiceLoader; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Tests that a custom Chronology is available via the ServiceLoader. * The CopticChronology is configured via META-INF/services/java.time.chrono.Chronology. */ -@Test public class TestServiceLoader { @Test @@ -85,7 +84,7 @@ public class TestServiceLoader { } var coptic = chronos.get("Coptic"); assertNotNull(coptic, "CopticChronology not found"); - assertEquals(coptic.isIsoBased(), false); + assertEquals(false, coptic.isIsoBased()); } } diff --git a/test/jdk/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java b/test/jdk/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java index e878ac0dcb3..bb32a9e7d65 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java +++ b/test/jdk/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -54,7 +54,7 @@ */ package test.java.time.chrono; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDate; import java.time.chrono.ThaiBuddhistChronology; @@ -65,19 +65,19 @@ import java.util.Calendar; import java.util.Locale; import java.util.TimeZone; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestThaiBuddhistChronoImpl { /** * Range of years to check consistency with java.util.Calendar */ - @DataProvider(name="RangeVersusCalendar") Object[][] provider_rangeVersusCalendar() { return new Object[][] { {LocalDate.of(1583, 1, 1), LocalDate.of(2100, 1, 1)}, @@ -87,12 +87,13 @@ public class TestThaiBuddhistChronoImpl { //----------------------------------------------------------------------- // Verify ThaiBuddhist Calendar matches java.util.Calendar for range //----------------------------------------------------------------------- - @Test(dataProvider="RangeVersusCalendar") + @ParameterizedTest + @MethodSource("provider_rangeVersusCalendar") public void test_ThaiBuddhistChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { Locale locale = Locale.forLanguageTag("th-TH--u-ca-buddhist"); - assertEquals(locale.toString(), "th_TH", "Unexpected locale"); + assertEquals("th_TH", locale.toString(), "Unexpected locale"); Calendar cal = java.util.Calendar.getInstance(locale); - assertEquals(cal.getCalendarType(), "buddhist", "Unexpected calendar type"); + assertEquals("buddhist", cal.getCalendarType(), "Unexpected calendar type"); ThaiBuddhistDate thaiDate = ThaiBuddhistChronology.INSTANCE.date(isoStartDate); @@ -102,9 +103,9 @@ public class TestThaiBuddhistChronoImpl { cal.set(Calendar.DAY_OF_MONTH, thaiDate.get(ChronoField.DAY_OF_MONTH)); while (thaiDate.isBefore(isoEndDate)) { - assertEquals(thaiDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + thaiDate + "; cal: " + cal); - assertEquals(thaiDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + thaiDate); - assertEquals(thaiDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + thaiDate); + assertEquals(cal.get(Calendar.DAY_OF_MONTH), thaiDate.get(ChronoField.DAY_OF_MONTH), "Day mismatch in " + thaiDate + "; cal: " + cal); + assertEquals(cal.get(Calendar.MONTH) + 1, thaiDate.get(ChronoField.MONTH_OF_YEAR), "Month mismatch in " + thaiDate); + assertEquals(cal.get(Calendar.YEAR), thaiDate.get(ChronoField.YEAR_OF_ERA), "Year mismatch in " + thaiDate); thaiDate = thaiDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); diff --git a/test/jdk/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java b/test/jdk/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java index 8d68abfd227..2dfd112596b 100644 --- a/test/jdk/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java +++ b/test/jdk/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,10 +27,11 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.time.DateTimeException; import java.time.DayOfWeek; @@ -64,15 +65,18 @@ import java.time.temporal.ValueRange; import java.time.temporal.WeekFields; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests for the Umm alQura chronology and data. * Note: The dates used for testing are just a sample of calendar data. * @bug 8067800 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestUmmAlQuraChronology { private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); @@ -82,21 +86,22 @@ public class TestUmmAlQuraChronology { @Test public void test_aliases() { HijrahChronology hc = (HijrahChronology) Chronology.of("Hijrah"); - assertEquals(hc, HijrahChronology.INSTANCE, "Alias for Hijrah-umalqura"); + assertEquals(HijrahChronology.INSTANCE, hc, "Alias for Hijrah-umalqura"); hc = (HijrahChronology) Chronology.of("islamic"); - assertEquals(hc, HijrahChronology.INSTANCE, "Alias for Hijrah-umalqura"); + assertEquals(HijrahChronology.INSTANCE, hc, "Alias for Hijrah-umalqura"); } // Test to check if the exception is thrown for an incorrect chronology id - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_badChronology() { - Chronology test = Chronology.of("Hijrah-ummalqura"); + Assertions.assertThrows(DateTimeException.class, () -> { + Chronology test = Chronology.of("Hijrah-ummalqura"); + }); } //-------------------------------------------------------------------------- // regular data factory for Umm alQura dates and the corresponding ISO dates //-------------------------------------------------------------------------- - @DataProvider(name = "UmmAlQuraVsISODates") Object[][] data_UmmAlQuraVsISODates() { return new Object[][] { {HijrahDate.of(1318, 1, 1), LocalDate.of(1900, 04, 30)}, @@ -110,9 +115,10 @@ public class TestUmmAlQuraChronology { } // Test to verify the epoch days for given Hijrah & ISO date instances - @Test(dataProvider="UmmAlQuraVsISODates") + @ParameterizedTest + @MethodSource("data_UmmAlQuraVsISODates") public void Test_UmmAlQuraVsISODates(HijrahDate hd, LocalDate ld) { - assertEquals(hd.toEpochDay(), ld.toEpochDay(), "Umm alQura date and ISO date should have same epochDay"); + assertEquals(ld.toEpochDay(), hd.toEpochDay(), "Umm alQura date and ISO date should have same epochDay"); } // UmmAlQura chronology ranges for year, month and days for the HijrahChronology @@ -120,28 +126,27 @@ public class TestUmmAlQuraChronology { public void Test_UmmAlQuraChronoRange() { HijrahChronology chrono = HijrahChronology.INSTANCE; ValueRange year = chrono.range(YEAR); - assertEquals(year.getMinimum(), 1300, "Minimum year"); - assertEquals(year.getLargestMinimum(), 1300, "Largest minimum year"); - assertEquals(year.getMaximum(), 1600, "Largest year"); - assertEquals(year.getSmallestMaximum(), 1600, "Smallest Maximum year"); + assertEquals(1300, year.getMinimum(), "Minimum year"); + assertEquals(1300, year.getLargestMinimum(), "Largest minimum year"); + assertEquals(1600, year.getMaximum(), "Largest year"); + assertEquals(1600, year.getSmallestMaximum(), "Smallest Maximum year"); ValueRange month = chrono.range(MONTH_OF_YEAR); - assertEquals(month.getMinimum(), 1, "Minimum month"); - assertEquals(month.getLargestMinimum(), 1, "Largest minimum month"); - assertEquals(month.getMaximum(), 12, "Largest month"); - assertEquals(month.getSmallestMaximum(), 12, "Smallest Maximum month"); + assertEquals(1, month.getMinimum(), "Minimum month"); + assertEquals(1, month.getLargestMinimum(), "Largest minimum month"); + assertEquals(12, month.getMaximum(), "Largest month"); + assertEquals(12, month.getSmallestMaximum(), "Smallest Maximum month"); ValueRange day = chrono.range(DAY_OF_MONTH); - assertEquals(day.getMinimum(), 1, "Minimum day"); - assertEquals(day.getLargestMinimum(), 1, "Largest minimum day"); - assertEquals(day.getMaximum(), 30, "Largest day"); - assertEquals(day.getSmallestMaximum(), 29, "Smallest Maximum day"); + assertEquals(1, day.getMinimum(), "Minimum day"); + assertEquals(1, day.getLargestMinimum(), "Largest minimum day"); + assertEquals(30, day.getMaximum(), "Largest day"); + assertEquals(29, day.getSmallestMaximum(), "Smallest Maximum day"); } //----------------------------------------------------------------------- // regular data factory for dates and the corresponding range values //----------------------------------------------------------------------- - @DataProvider(name = "dates") Object[][] data_dates() { return new Object[][]{ {HijrahDate.of(1300, 5, 1), 1300, 1600, 1, 12, 1, 30, 30}, @@ -153,7 +158,8 @@ public class TestUmmAlQuraChronology { } // Test to verify the min/max field ranges for given dates - @Test(dataProvider="dates") + @ParameterizedTest + @MethodSource("data_dates") public void Test_UmmAlQuraRanges(HijrahDate date, int minYear, int maxYear, int minMonth, int maxMonth, @@ -161,33 +167,33 @@ public class TestUmmAlQuraChronology { // Check the chronology ranges HijrahChronology chrono = date.getChronology(); ValueRange yearRange = chrono.range(YEAR); - assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah chronology"); - assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah chronology"); - assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah chronology"); - assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest Maximum year for Hijrah chronology"); + assertEquals(minYear, yearRange.getMinimum(), "Minimum year for Hijrah chronology"); + assertEquals(minYear, yearRange.getLargestMinimum(), "Largest minimum year for Hijrah chronology"); + assertEquals(maxYear, yearRange.getMaximum(), "Maximum year for Hijrah chronology"); + assertEquals(maxYear, yearRange.getSmallestMaximum(), "Smallest Maximum year for Hijrah chronology"); ValueRange monthRange = chrono.range(MONTH_OF_YEAR); - assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for Hijrah chronology"); - assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for Hijrah chronology"); + assertEquals(minMonth, monthRange.getMinimum(), "Minimum month for Hijrah chronology"); + assertEquals(maxMonth, monthRange.getMaximum(), "Maximum month for Hijrah chronology"); ValueRange daysRange = chrono.range(DAY_OF_MONTH); - assertEquals(daysRange.getMinimum(), minDay, "Minimum day for chronology"); - assertEquals(daysRange.getMaximum(), maxChronoDay, "Maximum day for Hijrah chronology"); + assertEquals(minDay, daysRange.getMinimum(), "Minimum day for chronology"); + assertEquals(maxChronoDay, daysRange.getMaximum(), "Maximum day for Hijrah chronology"); // Check the date ranges yearRange = date.range(YEAR); - assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah date"); - assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah date"); - assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah date"); - assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest maximum year for Hijrah date"); + assertEquals(minYear, yearRange.getMinimum(), "Minimum year for Hijrah date"); + assertEquals(minYear, yearRange.getLargestMinimum(), "Largest minimum year for Hijrah date"); + assertEquals(maxYear, yearRange.getMaximum(), "Maximum year for Hijrah date"); + assertEquals(maxYear, yearRange.getSmallestMaximum(), "Smallest maximum year for Hijrah date"); monthRange = date.range(MONTH_OF_YEAR); - assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for HijrahDate"); - assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for HijrahDate"); + assertEquals(minMonth, monthRange.getMinimum(), "Minimum month for HijrahDate"); + assertEquals(maxMonth, monthRange.getMaximum(), "Maximum month for HijrahDate"); daysRange = date.range(DAY_OF_MONTH); - assertEquals(daysRange.getMinimum(), minDay, "Minimum day for HijrahDate"); - assertEquals(daysRange.getMaximum(), maxDay, "Maximum day for HijrahDate"); + assertEquals(minDay, daysRange.getMinimum(), "Minimum day for HijrahDate"); + assertEquals(maxDay, daysRange.getMaximum(), "Maximum day for HijrahDate"); } @@ -223,7 +229,6 @@ public class TestUmmAlQuraChronology { } // Data provider to verify the dateYearDay() method - @DataProvider(name="dateYearDay") Object[][] data_dateYearDay() { return new Object[][] { {HijrahChronology.INSTANCE.dateYearDay(1434, 42), HijrahChronology.INSTANCE.date(1434, 02, 13)}, @@ -236,9 +241,10 @@ public class TestUmmAlQuraChronology { } // Test to verify the dateYearDay() method - @Test(dataProvider="dateYearDay") + @ParameterizedTest + @MethodSource("data_dateYearDay") public void test_DateYearDay(ChronoLocalDate date1, ChronoLocalDate date2) { - assertEquals(date1, date2); + assertEquals(date2, date1); } //----------------------------------------------------------------------- @@ -250,7 +256,7 @@ public class TestUmmAlQuraChronology { for (int i = 1; i <= hd1.lengthOfYear(); i++) { HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, i); int doy = hd.get(DAY_OF_YEAR); - assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i); + assertEquals(i, doy, "get(DAY_OF_YEAR) incorrect for " + i); } } @@ -260,54 +266,57 @@ public class TestUmmAlQuraChronology { for (int i = 1; i <= hd.lengthOfYear(); i++) { HijrahDate hd2 = hd.with(DAY_OF_YEAR, i); int doy = hd2.get(DAY_OF_YEAR); - assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2); + assertEquals(i, doy, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2); } } - @Test(expectedExceptions=java.time.DateTimeException.class) + @Test public void test_withDayOfYearTooSmall() { - HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1); - HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0); + Assertions.assertThrows(DateTimeException.class, () -> { + HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1); + HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0); + }); } - @Test(expectedExceptions=java.time.DateTimeException.class) + @Test public void test_withDayOfYearTooLarge() { - HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1); - HijrahDate hd2 = hd.with(DAY_OF_YEAR, hd.lengthOfYear() + 1); + Assertions.assertThrows(DateTimeException.class, () -> { + HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1); + HijrahDate hd2 = hd.with(DAY_OF_YEAR, hd.lengthOfYear() + 1); + }); } // Test to verify the with() method with ChronoField is set to DAY_OF_WEEK @Test public void test_adjustWithDayOfWeek() { - assertEquals(HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_WEEK, 4), HijrahDate.of(1320, 1, 15)); - assertEquals(HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_WEEK, 1), HijrahDate.of(1421, 11, 11)); - assertEquals(HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_WEEK, 6), HijrahDate.of(1529, 7, 20)); - assertEquals(HijrahChronology.INSTANCE.date(1534, 2, 10).with(ChronoField.DAY_OF_WEEK, 5), HijrahDate.of(1534, 2, 12)); - assertEquals(HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_WEEK, 2), HijrahDate.of(1552, 3, 26)); + assertEquals(HijrahDate.of(1320, 1, 15), HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_WEEK, 4)); + assertEquals(HijrahDate.of(1421, 11, 11), HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_WEEK, 1)); + assertEquals(HijrahDate.of(1529, 7, 20), HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_WEEK, 6)); + assertEquals(HijrahDate.of(1534, 2, 12), HijrahChronology.INSTANCE.date(1534, 2, 10).with(ChronoField.DAY_OF_WEEK, 5)); + assertEquals(HijrahDate.of(1552, 3, 26), HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_WEEK, 2)); } // Test to verify the with() method with ChronoField is set to DAY_OF_MONTH @Test public void test_adjustWithDayOfMonth() { - assertEquals(HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_MONTH, 2), HijrahDate.of(1320, 1, 2)); - assertEquals(HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_MONTH, 9), HijrahDate.of(1421, 11, 9)); - assertEquals(HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_MONTH, 13), HijrahDate.of(1529, 7, 13)); - assertEquals(HijrahChronology.INSTANCE.date(1534, 12, 10).with(ChronoField.DAY_OF_MONTH, 29), HijrahDate.of(1534, 12, 29)); - assertEquals(HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_MONTH, 6), HijrahDate.of(1552, 4, 6)); + assertEquals(HijrahDate.of(1320, 1, 2), HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_MONTH, 2)); + assertEquals(HijrahDate.of(1421, 11, 9), HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_MONTH, 9)); + assertEquals(HijrahDate.of(1529, 7, 13), HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_MONTH, 13)); + assertEquals(HijrahDate.of(1534, 12, 29), HijrahChronology.INSTANCE.date(1534, 12, 10).with(ChronoField.DAY_OF_MONTH, 29)); + assertEquals(HijrahDate.of(1552, 4, 6), HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_MONTH, 6)); } // Test to verify the with() method with ChronoField is set to DAY_OF_YEAR @Test public void test_adjustWithDayOfYear() { - assertEquals(HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_YEAR, 24), HijrahDate.of(1320, 1, 24)); - assertEquals(HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_YEAR, 135), HijrahDate.of(1421, 5, 18)); - assertEquals(HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_YEAR, 64), HijrahDate.of(1529, 3, 5)); - assertEquals(HijrahChronology.INSTANCE.date(1534, 2, 10).with(ChronoField.DAY_OF_YEAR, 354), HijrahDate.of(1534, 12, 29)); - assertEquals(HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_YEAR, 291), HijrahDate.of(1552, 10, 26)); + assertEquals(HijrahDate.of(1320, 1, 24), HijrahChronology.INSTANCE.date(1320, 1, 15).with(ChronoField.DAY_OF_YEAR, 24)); + assertEquals(HijrahDate.of(1421, 5, 18), HijrahChronology.INSTANCE.date(1421, 11, 15).with(ChronoField.DAY_OF_YEAR, 135)); + assertEquals(HijrahDate.of(1529, 3, 5), HijrahChronology.INSTANCE.date(1529, 7, 18).with(ChronoField.DAY_OF_YEAR, 64)); + assertEquals(HijrahDate.of(1534, 12, 29), HijrahChronology.INSTANCE.date(1534, 2, 10).with(ChronoField.DAY_OF_YEAR, 354)); + assertEquals(HijrahDate.of(1552, 10, 26), HijrahChronology.INSTANCE.date(1552, 4, 1).with(ChronoField.DAY_OF_YEAR, 291)); } // Data provider to get the difference between two dates in terms of days, months and years - @DataProvider(name="datesForDiff") Object[][] data_datesForDiffs() { return new Object[][] { {HijrahDate.of(1350, 5, 15), HijrahDate.of(1351, 12, 29), 574, 19, 1}, @@ -319,15 +328,15 @@ public class TestUmmAlQuraChronology { } // Test to verify the difference between two given dates in terms of days, months and years - @Test(dataProvider="datesForDiff") + @ParameterizedTest + @MethodSource("data_datesForDiffs") public void test_diffBetweenDates(ChronoLocalDate from, ChronoLocalDate to, long days, long months, long years) { - assertEquals(from.until(to, ChronoUnit.DAYS), days); - assertEquals(from.until(to, ChronoUnit.MONTHS), months); - assertEquals(from.until(to, ChronoUnit.YEARS), years); + assertEquals(days, from.until(to, ChronoUnit.DAYS)); + assertEquals(months, from.until(to, ChronoUnit.MONTHS)); + assertEquals(years, from.until(to, ChronoUnit.YEARS)); } // Data provider to get the difference between two dates as a period - @DataProvider(name="datesForPeriod") Object[][] data_Period() { return new Object[][] { {HijrahDate.of(1350, 5, 15), HijrahDate.of(1434, 7, 20), HijrahChronology.INSTANCE.period(84, 2, 5)}, @@ -339,34 +348,35 @@ public class TestUmmAlQuraChronology { } // Test to get the Period between two given dates - @Test(dataProvider="datesForPeriod") + @ParameterizedTest + @MethodSource("data_Period") public void test_until(HijrahDate h1, HijrahDate h2, ChronoPeriod p) { ChronoPeriod period = h1.until(h2); - assertEquals(period, p); + assertEquals(p, period); } // Test to get the Period between dates in different chronologies - @Test(dataProvider="datesForPeriod") + @ParameterizedTest + @MethodSource("data_Period") public void test_periodUntilDiffChrono(HijrahDate h1, HijrahDate h2, ChronoPeriod p) { MinguoDate m = MinguoChronology.INSTANCE.date(h2); ChronoPeriod period = h1.until(m); - assertEquals(period, p); + assertEquals(p, period); } // Test to get the adjusted date from a given date using TemporalAdjuster methods @Test public void test_temporalDayAdjustments() { HijrahDate date = HijrahDate.of(1554, 7, 21); - assertEquals(date.with(TemporalAdjusters.firstDayOfMonth()), HijrahDate.of(1554, 7, 1)); - assertEquals(date.with(TemporalAdjusters.lastDayOfMonth()), HijrahDate.of(1554, 7, 29)); - assertEquals(date.with(TemporalAdjusters.firstDayOfNextMonth()), HijrahDate.of(1554, 8, 1)); - assertEquals(date.with(TemporalAdjusters.firstDayOfNextYear()), HijrahDate.of(1555, 1, 1)); - assertEquals(date.with(TemporalAdjusters.firstDayOfYear()), HijrahDate.of(1554, 1, 1)); - assertEquals(date.with(TemporalAdjusters.lastDayOfYear()), HijrahDate.of(1554, 12, 30)); + assertEquals(HijrahDate.of(1554, 7, 1), date.with(TemporalAdjusters.firstDayOfMonth())); + assertEquals(HijrahDate.of(1554, 7, 29), date.with(TemporalAdjusters.lastDayOfMonth())); + assertEquals(HijrahDate.of(1554, 8, 1), date.with(TemporalAdjusters.firstDayOfNextMonth())); + assertEquals(HijrahDate.of(1555, 1, 1), date.with(TemporalAdjusters.firstDayOfNextYear())); + assertEquals(HijrahDate.of(1554, 1, 1), date.with(TemporalAdjusters.firstDayOfYear())); + assertEquals(HijrahDate.of(1554, 12, 30), date.with(TemporalAdjusters.lastDayOfYear())); } // Data provider for string representation of the date instances - @DataProvider(name="toString") Object[][] data_toString() { return new Object[][] { {HijrahChronology.INSTANCE.date(1320, 1, 1), "Hijrah-umalqura AH 1320-01-01"}, @@ -378,13 +388,13 @@ public class TestUmmAlQuraChronology { } // Test to verify the returned string value of a given date instance - @Test(dataProvider="toString") + @ParameterizedTest + @MethodSource("data_toString") public void test_toString(ChronoLocalDate hijrahDate, String expected) { - assertEquals(hijrahDate.toString(), expected); + assertEquals(expected, hijrahDate.toString()); } // Data provider for maximum number of days - @DataProvider(name="monthDays") Object[][] data_monthDays() { return new Object[][] { {1432, 1, 29}, @@ -397,27 +407,28 @@ public class TestUmmAlQuraChronology { } // Test to verify the maximum number of days by adding one month to a given date - @Test (dataProvider="monthDays") + @ParameterizedTest + @MethodSource("data_monthDays") public void test_valueRange_monthDays(int year, int month, int maxlength) { ChronoLocalDate date = HijrahChronology.INSTANCE.date(year, month, 1); ValueRange range = null; for (int i=1; i<=12; i++) { range = date.range(ChronoField.DAY_OF_MONTH); date = date.plus(1, ChronoUnit.MONTHS); - assertEquals(range.getMaximum(), month, maxlength); + assertEquals(month, range.getMaximum(), maxlength); } } // Test to get the last day of the month by adjusting the date with lastDayOfMonth() method - @Test(dataProvider="monthDays") + @ParameterizedTest + @MethodSource("data_monthDays") public void test_lastDayOfMonth(int year, int month, int numDays) { HijrahDate hDate = HijrahChronology.INSTANCE.date(year, month, 1); hDate = hDate.with(TemporalAdjusters.lastDayOfMonth()); - assertEquals(hDate.get(ChronoField.DAY_OF_MONTH), numDays); + assertEquals(numDays, hDate.get(ChronoField.DAY_OF_MONTH)); } // Data provider for the 12 islamic month names in a formatted date - @DataProvider(name="patternMonthNames") Object[][] data_patternMonthNames() { return new Object[][] { {1434, 1, 1, "01 AH Thu Muharram 1434"}, @@ -436,15 +447,15 @@ public class TestUmmAlQuraChronology { } // Test to verify the formatted dates - @Test(dataProvider="patternMonthNames") + @ParameterizedTest + @MethodSource("data_patternMonthNames") public void test_ofPattern(int year, int month, int day, String expected) { DateTimeFormatter test = DateTimeFormatter.ofPattern("dd G E MMMM yyyy", Locale.US); - assertEquals(test.format(HijrahDate.of(year, month, day)), expected); + assertEquals(expected, test.format(HijrahDate.of(year, month, day))); } // Data provider for localized dates - @DataProvider(name="chronoDateTimes") - Object[][] data_chronodatetimes() { + Object[][] data_chronodatetimes() { return new Object[][] { {1432, 12, 29, "Safar 1, 1434 AH"}, {1433, 1, 30, "Safar 30, 1434 AH"}, @@ -453,7 +464,8 @@ public class TestUmmAlQuraChronology { } // Test to verify the localized dates using ofLocalizedDate() method - @Test(dataProvider="chronoDateTimes") + @ParameterizedTest + @MethodSource("data_chronodatetimes") public void test_formatterOfLocalizedDate(int year, int month, int day, String expected) { HijrahDate hd = HijrahChronology.INSTANCE.date(year, month, day); ChronoLocalDateTime hdt = hd.atTime(LocalTime.NOON); @@ -464,12 +476,11 @@ public class TestUmmAlQuraChronology { hdt = hdt.plus(1, ChronoUnit.MINUTES); hdt = hdt.plus(1, ChronoUnit.SECONDS); DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withChronology(Chronology.of("Hijrah-umalqura")).withLocale(Locale.US); - assertEquals(df.format(hdt), expected); + assertEquals(expected, df.format(hdt)); } // Data provider to get the day of the week in a given date // The day of the week varies if the week starts with a saturday or sunday - @DataProvider(name="dayOfWeek") Object[][] data_dayOfweek() { return new Object[][] { {HijrahDate.of(1434, 6, 24), 1, 7}, @@ -481,14 +492,14 @@ public class TestUmmAlQuraChronology { } // Test to get the day of the week based on a Saturday/Sunday as the first day of the week - @Test(dataProvider="dayOfWeek") + @ParameterizedTest + @MethodSource("data_dayOfweek") public void test_dayOfWeek(HijrahDate date, int satStart, int sunStart) { - assertEquals(date.get(WeekFields.of(DayOfWeek.SATURDAY, 7).dayOfWeek()), satStart); - assertEquals(date.get(WeekFields.of(DayOfWeek.SUNDAY, 7).dayOfWeek()), sunStart); + assertEquals(satStart, date.get(WeekFields.of(DayOfWeek.SATURDAY, 7).dayOfWeek())); + assertEquals(sunStart, date.get(WeekFields.of(DayOfWeek.SUNDAY, 7).dayOfWeek())); } // Data sample to get the epoch days of a date instance - @DataProvider(name="epochDays") Object[][] data_epochdays() { return new Object[][] { {1332, -20486}, @@ -502,14 +513,14 @@ public class TestUmmAlQuraChronology { } // Test to verify the number of epoch days of a date instance - @Test(dataProvider="epochDays") + @ParameterizedTest + @MethodSource("data_epochdays") public void test_epochDays(int y, long epoch) { HijrahDate date = HijrahDate.of(y, 1, 1); - assertEquals(date.toEpochDay(), epoch); + assertEquals(epoch, date.toEpochDay()); } // Data provider to verify whether a given hijrah year is a leap year or not - @DataProvider(name="leapYears") Object[][] data_leapyears() { return new Object[][] { {1302, true}, @@ -524,15 +535,15 @@ public class TestUmmAlQuraChronology { } // Test to verify whether a given hijrah year is a leap year or not - @Test(dataProvider="leapYears") + @ParameterizedTest + @MethodSource("data_leapyears") public void test_leapYears(int y, boolean leapyear) { HijrahDate date = HijrahDate.of(y, 1, 1); - assertEquals(date.isLeapYear(), leapyear); + assertEquals(leapyear, date.isLeapYear()); } // Data provider to verify that a given hijrah year is outside the range of supported years // The values are dependent on the currently configured UmmAlQura calendar data - @DataProvider(name="OutOfRangeLeapYears") Object[][] data_invalid_leapyears() { return new Object[][] { {1299}, @@ -542,14 +553,14 @@ public class TestUmmAlQuraChronology { }; } - @Test(dataProvider="OutOfRangeLeapYears") + @ParameterizedTest + @MethodSource("data_invalid_leapyears") public void test_notLeapYears(int y) { assertFalse(HijrahChronology.INSTANCE.isLeapYear(y), "Out of range leap year"); } // Date samples to convert HijrahDate to LocalDate and vice versa - @DataProvider(name="samples") Object[][] data_samples() { return new Object[][] { {HijrahChronology.INSTANCE.date(1319, 12, 30), LocalDate.of(1902, 4, 9)}, @@ -562,45 +573,50 @@ public class TestUmmAlQuraChronology { } // Test to get LocalDate instance from a given HijrahDate - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_toLocalDate(ChronoLocalDate hijrahDate, LocalDate iso) { - assertEquals(LocalDate.from(hijrahDate), iso); + assertEquals(iso, LocalDate.from(hijrahDate)); } // Test to adjust HijrahDate with a given LocalDate - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_adjust_toLocalDate(ChronoLocalDate hijrahDate, LocalDate iso) { - assertEquals(hijrahDate.with(iso), hijrahDate); + assertEquals(hijrahDate, hijrahDate.with(iso)); } // Test to get a HijrahDate from a calendrical - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_fromCalendrical(ChronoLocalDate hijrahDate, LocalDate iso) { - assertEquals(HijrahChronology.INSTANCE.date(iso), hijrahDate); + assertEquals(hijrahDate, HijrahChronology.INSTANCE.date(iso)); } // Test to verify the day of week of a given HijrahDate and LocalDate - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_dayOfWeekEqualIsoDayOfWeek(ChronoLocalDate hijrahDate, LocalDate iso) { - assertEquals(hijrahDate.get(ChronoField.DAY_OF_WEEK), iso.get(ChronoField.DAY_OF_WEEK), "Hijrah day of week should be same as ISO day of week"); + assertEquals(iso.get(ChronoField.DAY_OF_WEEK), hijrahDate.get(ChronoField.DAY_OF_WEEK), "Hijrah day of week should be same as ISO day of week"); } // Test to get the local date by applying the MIN adjustment with hijrah date - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_LocalDate_adjustToHijrahDate(ChronoLocalDate hijrahDate, LocalDate localDate) { LocalDate test = LocalDate.MIN.with(hijrahDate); - assertEquals(test, localDate); + assertEquals(localDate, test); } // Test to get the local date time by applying the MIN adjustment with hijrah date - @Test(dataProvider="samples") + @ParameterizedTest + @MethodSource("data_samples") public void test_LocalDateTime_adjustToHijrahDate(ChronoLocalDate hijrahDate, LocalDate localDate) { LocalDateTime test = LocalDateTime.MIN.with(hijrahDate); - assertEquals(test, LocalDateTime.of(localDate, LocalTime.MIDNIGHT)); + assertEquals(LocalDateTime.of(localDate, LocalTime.MIDNIGHT), test); } // Sample dates for comparison - @DataProvider(name="datesForComparison") Object[][] data_datesForComparison() { return new Object[][] { {HijrahChronology.INSTANCE.date(1434, 6, 26), LocalDate.of(2013, 5, 5), -1, 1}, @@ -612,42 +628,42 @@ public class TestUmmAlQuraChronology { } // Test to compare dates in both forward and reverse order - @Test(dataProvider="datesForComparison") + @ParameterizedTest + @MethodSource("data_datesForComparison") public void test_compareDates(HijrahDate hdate, LocalDate ldate, int result1, int result2) { - assertEquals(ldate.compareTo(hdate), result1); - assertEquals(hdate.compareTo(ldate), result2); + assertEquals(result1, ldate.compareTo(hdate)); + assertEquals(result2, hdate.compareTo(ldate)); } // Test to verify the values of various chrono fields for a given hijrah date instance @Test public void test_chronoFields() { ChronoLocalDate hdate = HijrahChronology.INSTANCE.date(1434, 6, 28); - assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH), 7); - assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR), 7); - assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_MONTH), 4); - assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_YEAR), 25); - assertEquals(hdate.get(ChronoField.ERA), 1); - assertEquals(hdate.get(ChronoField.YEAR_OF_ERA), 1434); - assertEquals(hdate.get(ChronoField.MONTH_OF_YEAR), 6); - assertEquals(hdate.get(ChronoField.DAY_OF_MONTH), 28); - assertEquals(hdate.get(ChronoField.DAY_OF_WEEK), 3); - assertEquals(hdate.get(ChronoField.DAY_OF_YEAR), 175); + assertEquals(7, hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH)); + assertEquals(7, hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR)); + assertEquals(4, hdate.get(ChronoField.ALIGNED_WEEK_OF_MONTH)); + assertEquals(25, hdate.get(ChronoField.ALIGNED_WEEK_OF_YEAR)); + assertEquals(1, hdate.get(ChronoField.ERA)); + assertEquals(1434, hdate.get(ChronoField.YEAR_OF_ERA)); + assertEquals(6, hdate.get(ChronoField.MONTH_OF_YEAR)); + assertEquals(28, hdate.get(ChronoField.DAY_OF_MONTH)); + assertEquals(3, hdate.get(ChronoField.DAY_OF_WEEK)); + assertEquals(175, hdate.get(ChronoField.DAY_OF_YEAR)); } // Test to verify the returned hijrah date after adjusting the day of week as Saturday @Test public void test_adjustInto() { - assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 6, 28)), HijrahDate.of(1434, 7, 1)); - assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1432, 4, 13)), HijrahDate.of(1432, 4, 14)); - assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1433, 11, 29)), HijrahDate.of(1433, 12, 4)); - assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 5, 10)), HijrahDate.of(1434, 5, 11)); - assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 9, 11)), HijrahDate.of(1434, 9, 12)); + assertEquals(HijrahDate.of(1434, 7, 1), DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 6, 28))); + assertEquals(HijrahDate.of(1432, 4, 14), DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1432, 4, 13))); + assertEquals(HijrahDate.of(1433, 12, 4), DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1433, 11, 29))); + assertEquals(HijrahDate.of(1434, 5, 11), DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 5, 10))); + assertEquals(HijrahDate.of(1434, 9, 12), DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 9, 11))); } //----------------------------------------------------------------------- // zonedDateTime(TemporalAccessor) //----------------------------------------------------------------------- - @DataProvider(name="zonedDateTime") Object[][] data_zonedDateTime() { return new Object[][] { {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null}, @@ -661,13 +677,14 @@ public class TestUmmAlQuraChronology { } // Test to check the zoned date times - @Test(dataProvider="zonedDateTime") + @ParameterizedTest + @MethodSource("data_zonedDateTime") public void test_zonedDateTime(TemporalAccessor accessor, HijrahDate expectedDate, LocalTime expectedTime, Class expectedEx) { if (expectedEx == null) { ChronoZonedDateTime result = HijrahChronology.INSTANCE.zonedDateTime(accessor); - assertEquals(result.toLocalDate(), expectedDate); - assertEquals(HijrahDate.from(accessor), expectedDate); - assertEquals(result.toLocalTime(), expectedTime); + assertEquals(expectedDate, result.toLocalDate()); + assertEquals(expectedDate, HijrahDate.from(accessor)); + assertEquals(expectedTime, result.toLocalTime()); } else { try { @@ -688,18 +705,17 @@ public class TestUmmAlQuraChronology { ZonedDateTime zonedDateTime = ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH); ChronoZonedDateTime result = HijrahChronology.INSTANCE.zonedDateTime(offsetDateTime.toInstant(), offsetDateTime.getOffset()); - assertEquals(result.toLocalDate(), HijrahChronology.INSTANCE.date(1433, 4, 7)); - assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1)); + assertEquals(HijrahChronology.INSTANCE.date(1433, 4, 7), result.toLocalDate()); + assertEquals(LocalTime.of(2, 7, 1, 1), result.toLocalTime()); result = HijrahChronology.INSTANCE.zonedDateTime(zonedDateTime.toInstant(), zonedDateTime.getOffset()); - assertEquals(result.toLocalDate(), HijrahChronology.INSTANCE.date(1433, 4, 7)); - assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1)); + assertEquals(HijrahChronology.INSTANCE.date(1433, 4, 7), result.toLocalDate()); + assertEquals(LocalTime.of(2, 7, 1, 1), result.toLocalTime()); } //----------------------------------------------------------------------- // localDateTime() //----------------------------------------------------------------------- - @DataProvider(name="localDateTime") Object[][] data_localDateTime() { return new Object[][] { {LocalDateTime.of(2012, 2, 29, 2, 7), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7), null}, @@ -713,13 +729,14 @@ public class TestUmmAlQuraChronology { } // Test to verify local date time values from various date instances defined in the localDateTime data provider - @Test(dataProvider="localDateTime") + @ParameterizedTest + @MethodSource("data_localDateTime") public void test_localDateTime(TemporalAccessor accessor, HijrahDate expectedDate, LocalTime expectedTime, Class expectedEx) { if (expectedEx == null) { ChronoLocalDateTime result = HijrahChronology.INSTANCE.localDateTime(accessor); - assertEquals(result.toLocalDate(), expectedDate); - assertEquals(HijrahDate.from(accessor), expectedDate); - assertEquals(result.toLocalTime(), expectedTime); + assertEquals(expectedDate, result.toLocalDate()); + assertEquals(expectedDate, HijrahDate.from(accessor)); + assertEquals(expectedTime, result.toLocalTime()); } else { try { ChronoLocalDateTime result = HijrahChronology.INSTANCE.localDateTime(accessor); @@ -731,7 +748,6 @@ public class TestUmmAlQuraChronology { } // Sample Hijrah & Minguo Dates - @DataProvider(name="hijrahToMinguo") Object[][] data_hijrahToMinguo() { return new Object[][] { {HijrahDate.of(1350,5,15), MinguoDate.of(20,9,28)}, @@ -743,13 +759,13 @@ public class TestUmmAlQuraChronology { } // Test to verify the date conversion from Hijrah to Minguo chronology - @Test(dataProvider="hijrahToMinguo") + @ParameterizedTest + @MethodSource("data_hijrahToMinguo") public void test_hijrahToMinguo(HijrahDate hijrah, MinguoDate minguo) { - assertEquals(MinguoChronology.INSTANCE.date(hijrah), minguo); + assertEquals(minguo, MinguoChronology.INSTANCE.date(hijrah)); } // Sample Hijrah & Thai Dates - @DataProvider(name="hijrahToThai") Object[][] data_hijrahToThai() { return new Object[][] { {HijrahDate.of(1350,5,15), ThaiBuddhistDate.of(2474,9,28)}, @@ -761,13 +777,13 @@ public class TestUmmAlQuraChronology { } // Test to verify the date conversion from Hijrah to Thai chronology - @Test(dataProvider="hijrahToThai") + @ParameterizedTest + @MethodSource("data_hijrahToThai") public void test_hijrahToThai(HijrahDate hijrah, ThaiBuddhistDate thai) { - assertEquals(ThaiBuddhistChronology.INSTANCE.date(hijrah), thai); + assertEquals(thai, ThaiBuddhistChronology.INSTANCE.date(hijrah)); } // Sample Hijrah & Japanese Dates - @DataProvider(name="hijrahToJapanese") Object[][] data_hijrahToJapanese() { return new Object[][] { {HijrahDate.of(1350,5,15), "Japanese Showa 6-09-28"}, @@ -781,12 +797,12 @@ public class TestUmmAlQuraChronology { } // Test to verify the date conversion from Hijrah to Japanese chronology - @Test(dataProvider="hijrahToJapanese") + @ParameterizedTest + @MethodSource("data_hijrahToJapanese") public void test_hijrahToJapanese(HijrahDate hijrah, String japanese) { - assertEquals(JapaneseChronology.INSTANCE.date(hijrah).toString(), japanese); + assertEquals(japanese, JapaneseChronology.INSTANCE.date(hijrah).toString()); } - @DataProvider(name="alignedDayOfWeekInMonthTestDates") Object[][] data_alignedDayOfWeekInMonth() { return new Object[][] { {1437, 9, 1, 1, 1}, @@ -799,18 +815,20 @@ public class TestUmmAlQuraChronology { //----------------------------------------------------------------------- // Test for aligned-week-of-month calculation based on the day-of-month //----------------------------------------------------------------------- - @Test(dataProvider="alignedDayOfWeekInMonthTestDates") + @ParameterizedTest + @MethodSource("data_alignedDayOfWeekInMonth") public void test_alignedWeekOfMonth(int year, int month, int dom, int wom, int dowm) { HijrahDate date = HijrahChronology.INSTANCE.date(year, month, dom); - assertEquals(date.getLong(ChronoField.ALIGNED_WEEK_OF_MONTH), wom); + assertEquals(wom, date.getLong(ChronoField.ALIGNED_WEEK_OF_MONTH)); } //----------------------------------------------------------------------- // Test for aligned-day-of-week calculation based on the day-of-month //----------------------------------------------------------------------- - @Test(dataProvider="alignedDayOfWeekInMonthTestDates") + @ParameterizedTest + @MethodSource("data_alignedDayOfWeekInMonth") public void test_alignedDayOfWeekInMonth(int year, int month, int dom, int wom, int dowm) { HijrahDate date = HijrahChronology.INSTANCE.date(year, month, dom); - assertEquals(date.getLong(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH), dowm); + assertEquals(dowm, date.getLong(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH)); } } diff --git a/test/jdk/java/time/test/java/time/format/AbstractTestPrinterParser.java b/test/jdk/java/time/test/java/time/format/AbstractTestPrinterParser.java index 023f5c190ad..b4e9590c23d 100644 --- a/test/jdk/java/time/test/java/time/format/AbstractTestPrinterParser.java +++ b/test/jdk/java/time/test/java/time/format/AbstractTestPrinterParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -72,13 +72,11 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; /** * Abstract PrinterParser test. */ -@Test public class AbstractTestPrinterParser { protected StringBuilder buf; @@ -88,7 +86,7 @@ public class AbstractTestPrinterParser { protected DecimalStyle decimalStyle; - @BeforeMethod + @BeforeEach public void setUp() { buf = new StringBuilder(); builder = new DateTimeFormatterBuilder(); diff --git a/test/jdk/java/time/test/java/time/format/TestCharLiteralParser.java b/test/jdk/java/time/test/java/time/format/TestCharLiteralParser.java index 696aab0f539..d1896c865e1 100644 --- a/test/jdk/java/time/test/java/time/format/TestCharLiteralParser.java +++ b/test/jdk/java/time/test/java/time/format/TestCharLiteralParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,24 +60,25 @@ package test.java.time.format; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.text.ParsePosition; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test CharLiteralPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestCharLiteralParser extends AbstractTestPrinterParser { - @DataProvider(name="success") Object[][] data_success() { return new Object[][] { // match @@ -100,24 +101,24 @@ public class TestCharLiteralParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="success") + @ParameterizedTest + @MethodSource("data_success") public void test_parse_success(char c, boolean caseSensitive, String text, int pos, int expectedPos) { setCaseSensitive(caseSensitive); ParsePosition ppos = new ParsePosition(pos); TemporalAccessor parsed = getFormatter(c).parseUnresolved(text, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getIndex(), expectedPos); + assertEquals(expectedPos, ppos.getIndex()); } else { - assertEquals(ppos.getIndex(), expectedPos); - assertEquals(parsed.isSupported(YEAR), false); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(expectedPos, ppos.getIndex()); + assertEquals(false, parsed.isSupported(YEAR)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {'a', "a", -1, IndexOutOfBoundsException.class}, @@ -125,7 +126,8 @@ public class TestCharLiteralParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(char c, String text, int pos, Class expected) { try { ParsePosition ppos = new ParsePosition(pos); diff --git a/test/jdk/java/time/test/java/time/format/TestCharLiteralPrinter.java b/test/jdk/java/time/test/java/time/format/TestCharLiteralPrinter.java index 6aaf6a5b97d..71b7c7bed53 100644 --- a/test/jdk/java/time/test/java/time/format/TestCharLiteralPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestCharLiteralPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,42 +59,45 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test CharLiteralPrinterParser. */ -@Test public class TestCharLiteralPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- + @Test public void test_print_emptyCalendrical() throws Exception { buf.append("EXISTING"); getFormatter('a').formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "EXISTINGa"); + assertEquals("EXISTINGa", buf.toString()); } + @Test public void test_print_dateTime() throws Exception { buf.append("EXISTING"); getFormatter('a').formatTo(dta, buf); - assertEquals(buf.toString(), "EXISTINGa"); + assertEquals("EXISTINGa", buf.toString()); } + @Test public void test_print_emptyAppendable() throws Exception { getFormatter('a').formatTo(dta, buf); - assertEquals(buf.toString(), "a"); + assertEquals("a", buf.toString()); } //----------------------------------------------------------------------- + @Test public void test_toString() throws Exception { - assertEquals(getFormatter('a').toString(), "'a'"); + assertEquals("'a'", getFormatter('a').toString()); } //----------------------------------------------------------------------- + @Test public void test_toString_apos() throws Exception { - assertEquals(getFormatter('\'').toString(), "''"); + assertEquals("''", getFormatter('\'').toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatter.java b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatter.java index f6c1b253573..2ccc0da8f58 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatter.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,11 +60,12 @@ package test.java.time.format; import static java.time.temporal.ChronoField.DAY_OF_MONTH; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.time.DateTimeException; import java.time.DayOfWeek; @@ -93,14 +94,16 @@ import java.time.temporal.TemporalAccessor; import java.util.Locale; import java.util.function.Function; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test DateTimeFormatter. * @bug 8085887 8293146 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeFormatter { @Test @@ -203,7 +206,6 @@ public class TestDateTimeFormatter { assertTrue(msg.contains("11:30:56"), msg); } - @DataProvider(name="nozone_exception_cases") Object[][] exceptionCases() { return new Object[][] { {LocalDateTime.of(2000, 1, 1, 1, 1), "z", "ZoneId"}, @@ -213,7 +215,8 @@ public class TestDateTimeFormatter { // Test cases that should throw an exception with a cogent message // containing the Type being queried and the Temporal being queried. - @Test(dataProvider="nozone_exception_cases") + @ParameterizedTest + @MethodSource("exceptionCases") public void test_throws_message(Temporal temporal, String pattern, String queryName) { DateTimeFormatter fmt = DateTimeFormatter.ofPattern(pattern); try { @@ -277,7 +280,6 @@ public class TestDateTimeFormatter { private static final DateTimeFormatter STRICT_WEEK = DateTimeFormatter.ofPattern("YYYY-'W'ww-e") .withResolverStyle(ResolverStyle.STRICT); private static final Locale EGYPT = Locale.forLanguageTag("en-EG"); - @DataProvider(name = "week53Dates") Object[][] data_week53Dates() { return new Object[][] { // WeekFields[SUNDAY,1] @@ -321,15 +323,14 @@ public class TestDateTimeFormatter { }; } - @Test (dataProvider = "week53Dates") + @ParameterizedTest + @MethodSource("data_week53Dates") public void test_week_53(String weekDate, Locale locale, LocalDate expected) { var f = STRICT_WEEK.withLocale(locale); if (expected != null) { - assertEquals(LocalDate.parse(weekDate, f), expected); + assertEquals(expected, LocalDate.parse(weekDate, f)); } else { - assertThrows(DateTimeException.class, () -> { - LocalDate.parse(weekDate, f); - }); + assertThrows(DateTimeException.class, () -> LocalDate.parse(weekDate, f)); } } } diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java index 6d62dfe1265..294d204a216 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java @@ -66,9 +66,10 @@ import static java.time.temporal.ChronoField.HOUR_OF_DAY; import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; import java.text.ParsePosition; import java.time.LocalDate; @@ -95,19 +96,22 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test DateTimeFormatterBuilder. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeFormatterBuilder { private DateTimeFormatterBuilder builder; - @BeforeMethod + @BeforeEach public void setUp() { builder = new DateTimeFormatterBuilder(); } @@ -116,7 +120,7 @@ public class TestDateTimeFormatterBuilder { @Test public void test_toFormatter_empty() throws Exception { DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), ""); + assertEquals("", f.toString()); } //----------------------------------------------------------------------- @@ -124,14 +128,14 @@ public class TestDateTimeFormatterBuilder { public void test_parseCaseSensitive() throws Exception { builder.parseCaseSensitive(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ParseCaseSensitive(true)"); + assertEquals("ParseCaseSensitive(true)", f.toString()); } @Test public void test_parseCaseInsensitive() throws Exception { builder.parseCaseInsensitive(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ParseCaseSensitive(false)"); + assertEquals("ParseCaseSensitive(false)", f.toString()); } //----------------------------------------------------------------------- @@ -139,14 +143,14 @@ public class TestDateTimeFormatterBuilder { public void test_parseStrict() throws Exception { builder.parseStrict(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ParseStrict(true)"); + assertEquals("ParseStrict(true)", f.toString()); } @Test public void test_parseLenient() throws Exception { builder.parseLenient(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ParseStrict(false)"); + assertEquals("ParseStrict(false)", f.toString()); } //----------------------------------------------------------------------- @@ -154,12 +158,12 @@ public class TestDateTimeFormatterBuilder { public void test_appendValue_1arg() throws Exception { builder.appendValue(DAY_OF_MONTH); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(DayOfMonth)"); + assertEquals("Value(DayOfMonth)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendValue_1arg_null() throws Exception { - builder.appendValue(null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendValue(null)); } //----------------------------------------------------------------------- @@ -167,22 +171,22 @@ public class TestDateTimeFormatterBuilder { public void test_appendValue_2arg() throws Exception { builder.appendValue(DAY_OF_MONTH, 3); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(DayOfMonth,3)"); + assertEquals("Value(DayOfMonth,3)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendValue_2arg_null() throws Exception { - builder.appendValue(null, 3); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendValue(null, 3)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_2arg_widthTooSmall() throws Exception { - builder.appendValue(DAY_OF_MONTH, 0); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 0)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_2arg_widthTooBig() throws Exception { - builder.appendValue(DAY_OF_MONTH, 20); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 20)); } //----------------------------------------------------------------------- @@ -190,42 +194,42 @@ public class TestDateTimeFormatterBuilder { public void test_appendValue_3arg() throws Exception { builder.appendValue(DAY_OF_MONTH, 2, 3, SignStyle.NORMAL); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(DayOfMonth,2,3,NORMAL)"); + assertEquals("Value(DayOfMonth,2,3,NORMAL)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendValue_3arg_nullField() throws Exception { - builder.appendValue(null, 2, 3, SignStyle.NORMAL); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendValue(null, 2, 3, SignStyle.NORMAL)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_3arg_minWidthTooSmall() throws Exception { - builder.appendValue(DAY_OF_MONTH, 0, 2, SignStyle.NORMAL); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 0, 2, SignStyle.NORMAL)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_3arg_minWidthTooBig() throws Exception { - builder.appendValue(DAY_OF_MONTH, 20, 2, SignStyle.NORMAL); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 20, 2, SignStyle.NORMAL)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_3arg_maxWidthTooSmall() throws Exception { - builder.appendValue(DAY_OF_MONTH, 2, 0, SignStyle.NORMAL); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 2, 0, SignStyle.NORMAL)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_3arg_maxWidthTooBig() throws Exception { - builder.appendValue(DAY_OF_MONTH, 2, 20, SignStyle.NORMAL); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 2, 20, SignStyle.NORMAL)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendValue_3arg_maxWidthMinWidth() throws Exception { - builder.appendValue(DAY_OF_MONTH, 4, 2, SignStyle.NORMAL); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendValue(DAY_OF_MONTH, 4, 2, SignStyle.NORMAL)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendValue_3arg_nullSignStyle() throws Exception { - builder.appendValue(DAY_OF_MONTH, 2, 3, null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendValue(DAY_OF_MONTH, 2, 3, null)); } //----------------------------------------------------------------------- @@ -233,30 +237,30 @@ public class TestDateTimeFormatterBuilder { public void test_appendValue_subsequent2_parse3() throws Exception { builder.appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NORMAL).appendValue(DAY_OF_MONTH, 2); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)"); + assertEquals("Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)", f.toString()); TemporalAccessor parsed = f.parseUnresolved("123", new ParsePosition(0)); - assertEquals(parsed.getLong(MONTH_OF_YEAR), 1L); - assertEquals(parsed.getLong(DAY_OF_MONTH), 23L); + assertEquals(1L, parsed.getLong(MONTH_OF_YEAR)); + assertEquals(23L, parsed.getLong(DAY_OF_MONTH)); } @Test public void test_appendValue_subsequent2_parse4() throws Exception { builder.appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NORMAL).appendValue(DAY_OF_MONTH, 2); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)"); + assertEquals("Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)", f.toString()); TemporalAccessor parsed = f.parseUnresolved("0123", new ParsePosition(0)); - assertEquals(parsed.getLong(MONTH_OF_YEAR), 1L); - assertEquals(parsed.getLong(DAY_OF_MONTH), 23L); + assertEquals(1L, parsed.getLong(MONTH_OF_YEAR)); + assertEquals(23L, parsed.getLong(DAY_OF_MONTH)); } @Test public void test_appendValue_subsequent2_parse5() throws Exception { builder.appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NORMAL).appendValue(DAY_OF_MONTH, 2).appendLiteral('4'); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)'4'"); + assertEquals("Value(MonthOfYear,1,2,NORMAL)Value(DayOfMonth,2)'4'", f.toString()); TemporalAccessor parsed = f.parseUnresolved("01234", new ParsePosition(0)); - assertEquals(parsed.getLong(MONTH_OF_YEAR), 1L); - assertEquals(parsed.getLong(DAY_OF_MONTH), 23L); + assertEquals(1L, parsed.getLong(MONTH_OF_YEAR)); + assertEquals(23L, parsed.getLong(DAY_OF_MONTH)); } @Test @@ -266,38 +270,38 @@ public class TestDateTimeFormatterBuilder { .appendValue(MONTH_OF_YEAR, 2) .appendValue(DAY_OF_MONTH, 2); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(Year,4,10,EXCEEDS_PAD)Value(MonthOfYear,2)Value(DayOfMonth,2)"); + assertEquals("Value(Year,4,10,EXCEEDS_PAD)Value(MonthOfYear,2)Value(DayOfMonth,2)", f.toString()); TemporalAccessor parsed = f.parseUnresolved("20090630", new ParsePosition(0)); - assertEquals(parsed.getLong(YEAR), 2009L); - assertEquals(parsed.getLong(MONTH_OF_YEAR), 6L); - assertEquals(parsed.getLong(DAY_OF_MONTH), 30L); + assertEquals(2009L, parsed.getLong(YEAR)); + assertEquals(6L, parsed.getLong(MONTH_OF_YEAR)); + assertEquals(30L, parsed.getLong(DAY_OF_MONTH)); } //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendValueReduced_null() throws Exception { - builder.appendValueReduced(null, 2, 2, 2000); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendValueReduced(null, 2, 2, 2000)); } @Test public void test_appendValueReduced() throws Exception { builder.appendValueReduced(YEAR, 2, 2, 2000); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ReducedValue(Year,2,2,2000)"); + assertEquals("ReducedValue(Year,2,2,2000)", f.toString()); TemporalAccessor parsed = f.parseUnresolved("12", new ParsePosition(0)); - assertEquals(parsed.getLong(YEAR), 2012L); + assertEquals(2012L, parsed.getLong(YEAR)); } @Test public void test_appendValueReduced_subsequent_parse() throws Exception { builder.appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NORMAL).appendValueReduced(YEAR, 2, 2, 2000); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear,1,2,NORMAL)ReducedValue(Year,2,2,2000)"); + assertEquals("Value(MonthOfYear,1,2,NORMAL)ReducedValue(Year,2,2,2000)", f.toString()); ParsePosition ppos = new ParsePosition(0); TemporalAccessor parsed = f.parseUnresolved("123", ppos); assertNotNull(parsed, "Parse failed: " + ppos.toString()); - assertEquals(parsed.getLong(MONTH_OF_YEAR), 1L); - assertEquals(parsed.getLong(YEAR), 2023L); + assertEquals(1L, parsed.getLong(MONTH_OF_YEAR)); + assertEquals(2023L, parsed.getLong(YEAR)); } //----------------------------------------------------------------------- @@ -307,42 +311,42 @@ public class TestDateTimeFormatterBuilder { public void test_appendFraction_4arg() throws Exception { builder.appendFraction(MINUTE_OF_HOUR, 1, 9, false); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Fraction(MinuteOfHour,1,9)"); + assertEquals("Fraction(MinuteOfHour,1,9)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendFraction_4arg_nullRule() throws Exception { - builder.appendFraction(null, 1, 9, false); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendFraction(null, 1, 9, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_invalidRuleNotFixedSet() throws Exception { - builder.appendFraction(DAY_OF_MONTH, 1, 9, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(DAY_OF_MONTH, 1, 9, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_minTooSmall() throws Exception { - builder.appendFraction(MINUTE_OF_HOUR, -1, 9, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(MINUTE_OF_HOUR, -1, 9, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_minTooBig() throws Exception { - builder.appendFraction(MINUTE_OF_HOUR, 10, 9, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(MINUTE_OF_HOUR, 10, 9, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_maxTooSmall() throws Exception { - builder.appendFraction(MINUTE_OF_HOUR, 0, -1, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(MINUTE_OF_HOUR, 0, -1, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_maxTooBig() throws Exception { - builder.appendFraction(MINUTE_OF_HOUR, 1, 10, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(MINUTE_OF_HOUR, 1, 10, false)); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_appendFraction_4arg_maxWidthMinWidth() throws Exception { - builder.appendFraction(MINUTE_OF_HOUR, 9, 3, false); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendFraction(MINUTE_OF_HOUR, 9, 3, false)); } //----------------------------------------------------------------------- @@ -352,12 +356,12 @@ public class TestDateTimeFormatterBuilder { public void test_appendText_1arg() throws Exception { builder.appendText(MONTH_OF_YEAR); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Text(MonthOfYear)"); + assertEquals("Text(MonthOfYear)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendText_1arg_null() throws Exception { - builder.appendText(null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendText(null)); } //----------------------------------------------------------------------- @@ -365,17 +369,17 @@ public class TestDateTimeFormatterBuilder { public void test_appendText_2arg() throws Exception { builder.appendText(MONTH_OF_YEAR, TextStyle.SHORT); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Text(MonthOfYear,SHORT)"); + assertEquals("Text(MonthOfYear,SHORT)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendText_2arg_nullRule() throws Exception { - builder.appendText(null, TextStyle.SHORT); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendText(null, TextStyle.SHORT)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendText_2arg_nullStyle() throws Exception { - builder.appendText(MONTH_OF_YEAR, (TextStyle) null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendText(MONTH_OF_YEAR, (TextStyle) null)); } //----------------------------------------------------------------------- @@ -396,17 +400,17 @@ public class TestDateTimeFormatterBuilder { map.put(12L, "DBR"); builder.appendText(MONTH_OF_YEAR, map); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Text(MonthOfYear)"); // TODO: toString should be different? + assertEquals("Text(MonthOfYear)", f.toString()); // TODO: toString should be different? } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendTextMap_nullRule() throws Exception { - builder.appendText(null, new HashMap()); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendText(null, new HashMap())); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendTextMap_nullStyle() throws Exception { - builder.appendText(MONTH_OF_YEAR, (Map) null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendText(MONTH_OF_YEAR, (Map) null)); } //----------------------------------------------------------------------- @@ -416,10 +420,9 @@ public class TestDateTimeFormatterBuilder { public void test_appendOffsetId() throws Exception { builder.appendOffsetId(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Offset(+HH:MM:ss,'Z')"); + assertEquals("Offset(+HH:MM:ss,'Z')", f.toString()); } - @DataProvider(name="offsetPatterns") Object[][] data_offsetPatterns() { return new Object[][] { {"+HH", 2, 0, 0, "+02"}, @@ -466,24 +469,25 @@ public class TestDateTimeFormatterBuilder { }; } - @Test(dataProvider="offsetPatterns") + @ParameterizedTest + @MethodSource("data_offsetPatterns") public void test_appendOffset_format(String pattern, int h, int m, int s, String expected) throws Exception { builder.appendOffset(pattern, "Z"); DateTimeFormatter f = builder.toFormatter(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(h, m, s); - assertEquals(f.format(offset), expected); + assertEquals(expected, f.format(offset)); } - @Test(dataProvider="offsetPatterns") + @ParameterizedTest + @MethodSource("data_offsetPatterns") public void test_appendOffset_parse(String pattern, int h, int m, int s, String expected) throws Exception { builder.appendOffset(pattern, "Z"); DateTimeFormatter f = builder.toFormatter(); ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(h, m, s); ZoneOffset parsed = f.parse(expected, ZoneOffset::from); - assertEquals(f.format(parsed), expected); + assertEquals(expected, f.format(parsed)); } - @DataProvider(name="badOffsetPatterns") Object[][] data_badOffsetPatterns() { return new Object[][] { {"HH"}, @@ -498,19 +502,20 @@ public class TestDateTimeFormatterBuilder { }; } - @Test(dataProvider="badOffsetPatterns", expectedExceptions=IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("data_badOffsetPatterns") public void test_appendOffset_badPattern(String pattern) throws Exception { - builder.appendOffset(pattern, "Z"); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.appendOffset(pattern, "Z")); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendOffset_3arg_nullText() throws Exception { - builder.appendOffset("+HH:MM", null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendOffset("+HH:MM", null)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendOffset_3arg_nullPattern() throws Exception { - builder.appendOffset(null, "Z"); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendOffset(null, "Z")); } //----------------------------------------------------------------------- @@ -520,19 +525,19 @@ public class TestDateTimeFormatterBuilder { public void test_appendZoneId() throws Exception { builder.appendZoneId(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ZoneId()"); + assertEquals("ZoneId()", f.toString()); } @Test public void test_appendZoneText_1arg() throws Exception { builder.appendZoneText(TextStyle.FULL); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "ZoneText(FULL)"); + assertEquals("ZoneText(FULL)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendZoneText_1arg_nullText() throws Exception { - builder.appendZoneText(null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendZoneText(null)); } //----------------------------------------------------------------------- @@ -542,15 +547,14 @@ public class TestDateTimeFormatterBuilder { public void test_appendDayPeriodText_1arg() throws Exception { builder.appendDayPeriodText(TextStyle.FULL); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "DayPeriod(FULL)"); + assertEquals("DayPeriod(FULL)", f.toString()); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_appendDayPeriodText_1arg_nullText() throws Exception { - builder.appendDayPeriodText(null); + Assertions.assertThrows(NullPointerException.class, () -> builder.appendDayPeriodText(null)); } - @DataProvider(name="dayPeriodFormat") Object[][] data_dayPeriodFormat() { return new Object[][] { {0, 0, TextStyle.FULL, Locale.US, "midnight"}, @@ -588,15 +592,15 @@ public class TestDateTimeFormatterBuilder { {23, 0, TextStyle.NARROW, Locale.JAPAN, "\u591c\u4e2d"}, }; } - @Test (dataProvider="dayPeriodFormat") + @ParameterizedTest + @MethodSource("data_dayPeriodFormat") public void test_dayPeriodFormat(int hod, int moh, TextStyle ts, Locale l, String expected) throws Exception { builder.appendDayPeriodText(ts); LocalTime t = LocalTime.of(hod, moh); DateTimeFormatter f = builder.toFormatter().withLocale(l); - assertEquals(f.format(t), expected); + assertEquals(expected, f.format(t)); } - @DataProvider(name="dayPeriodParse") Object[][] data_dayPeriodParse() { return new Object[][] { {TextStyle.FULL, Locale.US, 0, 0, "midnight"}, @@ -638,16 +642,16 @@ public class TestDateTimeFormatterBuilder { {TextStyle.NARROW, Locale.JAPAN, 21, 0, "\u591c"}, }; } - @Test (dataProvider="dayPeriodParse") + @ParameterizedTest + @MethodSource("data_dayPeriodParse") public void test_dayPeriodParse(TextStyle ts, Locale l, long hod, long moh, String dayPeriod) throws Exception { builder.appendDayPeriodText(ts); DateTimeFormatter f = builder.toFormatter().withLocale(l); var p = f.parse(dayPeriod); - assertEquals(p.getLong(HOUR_OF_DAY), hod); - assertEquals(p.getLong(MINUTE_OF_HOUR), moh); + assertEquals(hod, p.getLong(HOUR_OF_DAY)); + assertEquals(moh, p.getLong(MINUTE_OF_HOUR)); } - @DataProvider(name="dayPeriodParsePattern") Object[][] data_dayPeriodParsePattern() { return new Object[][] { {"H B", "23 at night", 23}, @@ -663,15 +667,15 @@ public class TestDateTimeFormatterBuilder { }; } - @Test (dataProvider="dayPeriodParsePattern") + @ParameterizedTest + @MethodSource("data_dayPeriodParsePattern") public void test_dayPeriodParsePattern(String pattern, String hourDayPeriod, long expected) throws Exception { builder.appendPattern(pattern); DateTimeFormatter f = builder.toFormatter().withLocale(Locale.US); var p = f.parse(hourDayPeriod); - assertEquals(p.getLong(HOUR_OF_DAY), expected); + assertEquals(expected, p.getLong(HOUR_OF_DAY)); } - @DataProvider(name="dayPeriodParseMidnight") Object[][] data_dayPeriodParseMidnight() { return new Object[][] { {"u-M-d H:m B", "2020-11-07 00:00 midnight", 7, 0}, @@ -679,16 +683,16 @@ public class TestDateTimeFormatterBuilder { }; } - @Test (dataProvider="dayPeriodParseMidnight") + @ParameterizedTest + @MethodSource("data_dayPeriodParseMidnight") public void test_dayPeriodParseMidnight(String pattern, String dateTime, long expectedDOM, long expectedHOD) throws Exception { builder.appendPattern(pattern); DateTimeFormatter f = builder.toFormatter().withLocale(Locale.US); var p = f.parse(dateTime); - assertEquals(p.getLong(DAY_OF_MONTH), expectedDOM); - assertEquals(p.getLong(HOUR_OF_DAY), expectedHOD); + assertEquals(expectedDOM, p.getLong(DAY_OF_MONTH)); + assertEquals(expectedHOD, p.getLong(HOUR_OF_DAY)); } - @DataProvider(name="dayPeriodParseInvalid") Object[][] data_dayPeriodParseInvalid() { return new Object[][] { {TextStyle.FULL, ResolverStyle.SMART, Locale.US, "00:01 midnight", "00:00"}, @@ -748,7 +752,8 @@ public class TestDateTimeFormatterBuilder { {TextStyle.NARROW, ResolverStyle.LENIENT, Locale.JAPAN, "23:00 \u591c", "19:00-23:00"}, }; } - @Test (dataProvider="dayPeriodParseInvalid") + @ParameterizedTest + @MethodSource("data_dayPeriodParseInvalid") public void test_dayPeriodParseInvalid(TextStyle ts, ResolverStyle rs, Locale l, String dayPeriod, String periodRange) throws Exception { try { builder.append(ISO_LOCAL_TIME).appendLiteral(' ').appendDayPeriodText(ts) @@ -759,13 +764,11 @@ public class TestDateTimeFormatterBuilder { throw new RuntimeException("DateTimeParseException should be thrown"); } } catch (DateTimeParseException e) { - assertEquals(e.getCause().getMessage(), - "Conflict found: Resolved time " + dayPeriod.substring(0, 5) + " conflicts with " + - "DayPeriod(" + periodRange + ")"); + assertEquals("Conflict found: Resolved time " + dayPeriod.substring(0, 5) + " conflicts with " + + "DayPeriod(" + periodRange + ")", e.getCause().getMessage()); } } - @DataProvider(name="dayPeriodParsePatternInvalid") Object[][] data_dayPeriodParsePatternInvalid() { return new Object[][] { {"H B", ResolverStyle.SMART, "47 at night", 23, null}, @@ -794,7 +797,8 @@ public class TestDateTimeFormatterBuilder { }; } - @Test (dataProvider="dayPeriodParsePatternInvalid") + @ParameterizedTest + @MethodSource("data_dayPeriodParsePatternInvalid") public void test_dayPeriodParsePatternInvalid(String pattern, ResolverStyle rs, String hourDayPeriod, long expected, Period expectedExcessDays) throws Exception { try { builder.appendPattern(pattern); @@ -803,18 +807,20 @@ public class TestDateTimeFormatterBuilder { if (rs != ResolverStyle.LENIENT) { throw new RuntimeException("DateTimeParseException should be thrown"); } - assertEquals(p.getLong(HOUR_OF_DAY), expected); - assertEquals(p.query(DateTimeFormatter.parsedExcessDays()), expectedExcessDays); + assertEquals(expected, p.getLong(HOUR_OF_DAY)); + assertEquals(expectedExcessDays, p.query(DateTimeFormatter.parsedExcessDays())); } catch (DateTimeParseException e) { // exception successfully thrown } } - @Test (expectedExceptions = DateTimeParseException.class) + @Test public void test_dayPeriodParseStrictNoTime() { - builder.appendPattern("B"); - DateTimeFormatter f = builder.toFormatter().withLocale(Locale.US).withResolverStyle(ResolverStyle.STRICT); - LocalTime.parse("at night", f); + Assertions.assertThrows(DateTimeParseException.class, () -> { + builder.appendPattern("B"); + DateTimeFormatter f = builder.toFormatter().withLocale(Locale.US).withResolverStyle(ResolverStyle.STRICT); + LocalTime.parse("at night", f); + }); } @Test @@ -880,7 +886,7 @@ public class TestDateTimeFormatterBuilder { .appendPattern(" B") .toFormatter() .withLocale(Locale.US); - assertEquals((long)dtf.parse("0 in the morning").getLong(ChronoField.HOUR_OF_DAY), 6L); + assertEquals(6L, (long)dtf.parse("0 in the morning").getLong(ChronoField.HOUR_OF_DAY)); try { dtf.parse("0 at night"); fail("DateTimeParseException should be thrown"); @@ -895,24 +901,24 @@ public class TestDateTimeFormatterBuilder { @Test public void test_padNext_1arg() { builder.appendValue(MONTH_OF_YEAR).appendLiteral(':').padNext(2).appendValue(DAY_OF_MONTH); - assertEquals(builder.toFormatter().format(LocalDate.of(2013, 2, 1)), "2: 1"); + assertEquals("2: 1", builder.toFormatter().format(LocalDate.of(2013, 2, 1))); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_padNext_1arg_invalidWidth() throws Exception { - builder.padNext(0); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.padNext(0)); } //----------------------------------------------------------------------- @Test public void test_padNext_2arg_dash() throws Exception { builder.appendValue(MONTH_OF_YEAR).appendLiteral(':').padNext(2, '-').appendValue(DAY_OF_MONTH); - assertEquals(builder.toFormatter().format(LocalDate.of(2013, 2, 1)), "2:-1"); + assertEquals("2:-1", builder.toFormatter().format(LocalDate.of(2013, 2, 1))); } - @Test(expectedExceptions=IllegalArgumentException.class) + @Test public void test_padNext_2arg_invalidWidth() throws Exception { - builder.padNext(0, '-'); + Assertions.assertThrows(IllegalArgumentException.class, () -> builder.padNext(0, '-')); } //----------------------------------------------------------------------- @@ -921,8 +927,8 @@ public class TestDateTimeFormatterBuilder { builder.appendValue(MONTH_OF_YEAR).appendLiteral(':') .padNext(5).optionalStart().appendValue(DAY_OF_MONTH).optionalEnd() .appendLiteral(':').appendValue(YEAR); - assertEquals(builder.toFormatter().format(LocalDate.of(2013, 2, 1)), "2: 1:2013"); - assertEquals(builder.toFormatter().format(YearMonth.of(2013, 2)), "2: :2013"); + assertEquals("2: 1:2013", builder.toFormatter().format(LocalDate.of(2013, 2, 1))); + assertEquals("2: :2013", builder.toFormatter().format(YearMonth.of(2013, 2))); } //----------------------------------------------------------------------- @@ -932,21 +938,21 @@ public class TestDateTimeFormatterBuilder { public void test_optionalStart_noEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().appendValue(DAY_OF_MONTH).appendValue(DAY_OF_WEEK); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[Value(DayOfMonth)Value(DayOfWeek)]"); + assertEquals("Value(MonthOfYear)[Value(DayOfMonth)Value(DayOfWeek)]", f.toString()); } @Test public void test_optionalStart2_noEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().appendValue(DAY_OF_MONTH).optionalStart().appendValue(DAY_OF_WEEK); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[Value(DayOfMonth)[Value(DayOfWeek)]]"); + assertEquals("Value(MonthOfYear)[Value(DayOfMonth)[Value(DayOfWeek)]]", f.toString()); } @Test public void test_optionalStart_doubleStart() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().optionalStart().appendValue(DAY_OF_MONTH); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[[Value(DayOfMonth)]]"); + assertEquals("Value(MonthOfYear)[[Value(DayOfMonth)]]", f.toString()); } //----------------------------------------------------------------------- @@ -954,7 +960,7 @@ public class TestDateTimeFormatterBuilder { public void test_optionalEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().appendValue(DAY_OF_MONTH).optionalEnd().appendValue(DAY_OF_WEEK); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[Value(DayOfMonth)]Value(DayOfWeek)"); + assertEquals("Value(MonthOfYear)[Value(DayOfMonth)]Value(DayOfWeek)", f.toString()); } @Test @@ -962,39 +968,38 @@ public class TestDateTimeFormatterBuilder { builder.appendValue(MONTH_OF_YEAR).optionalStart().appendValue(DAY_OF_MONTH) .optionalStart().appendValue(DAY_OF_WEEK).optionalEnd().appendValue(DAY_OF_MONTH).optionalEnd(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[Value(DayOfMonth)[Value(DayOfWeek)]Value(DayOfMonth)]"); + assertEquals("Value(MonthOfYear)[Value(DayOfMonth)[Value(DayOfWeek)]Value(DayOfMonth)]", f.toString()); } @Test public void test_optionalEnd_doubleStartSingleEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().optionalStart().appendValue(DAY_OF_MONTH).optionalEnd(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[[Value(DayOfMonth)]]"); + assertEquals("Value(MonthOfYear)[[Value(DayOfMonth)]]", f.toString()); } @Test public void test_optionalEnd_doubleStartDoubleEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().optionalStart().appendValue(DAY_OF_MONTH).optionalEnd().optionalEnd(); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)[[Value(DayOfMonth)]]"); + assertEquals("Value(MonthOfYear)[[Value(DayOfMonth)]]", f.toString()); } @Test public void test_optionalStartEnd_immediateStartEnd() throws Exception { builder.appendValue(MONTH_OF_YEAR).optionalStart().optionalEnd().appendValue(DAY_OF_MONTH); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), "Value(MonthOfYear)Value(DayOfMonth)"); + assertEquals("Value(MonthOfYear)Value(DayOfMonth)", f.toString()); } - @Test(expectedExceptions=IllegalStateException.class) + @Test public void test_optionalEnd_noStart() throws Exception { - builder.optionalEnd(); + Assertions.assertThrows(IllegalStateException.class, () -> builder.optionalEnd()); } //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @DataProvider(name="validPatterns") Object[][] dataValid() { return new Object[][] { {"'a'", "'a'"}, @@ -1162,15 +1167,15 @@ public class TestDateTimeFormatterBuilder { }; } - @Test(dataProvider="validPatterns") + @ParameterizedTest + @MethodSource("dataValid") public void test_appendPattern_valid(String input, String expected) throws Exception { builder.appendPattern(input); DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), expected); + assertEquals(expected, f.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="invalidPatterns") Object[][] dataInvalid() { return new Object[][] { {"'"}, @@ -1241,17 +1246,19 @@ public class TestDateTimeFormatterBuilder { }; } - @Test(dataProvider="invalidPatterns", expectedExceptions=IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("dataInvalid") public void test_appendPattern_invalid(String input) throws Exception { - try { - builder.appendPattern(input); - } catch (IllegalArgumentException ex) { - throw ex; - } + Assertions.assertThrows(IllegalArgumentException.class, () -> { + try { + builder.appendPattern(input); + } catch (IllegalArgumentException ex) { + throw ex; + } + }); } //----------------------------------------------------------------------- - @DataProvider(name="localePatterns") Object[][] localizedDateTimePatterns() { return new Object[][] { {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, y, h:mm:ss\u202fa zzzz"}, @@ -1269,26 +1276,27 @@ public class TestDateTimeFormatterBuilder { }; } - @Test(dataProvider="localePatterns") + @ParameterizedTest + @MethodSource("localizedDateTimePatterns") public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale, String expected) { String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale); - assertEquals(actual, expected, "Pattern " + convertNonAscii(actual)); + assertEquals(expected, actual, "Pattern " + convertNonAscii(actual)); } - @Test(expectedExceptions=java.lang.IllegalArgumentException.class) + @Test public void test_getLocalizedDateTimePatternIAE() { - DateTimeFormatterBuilder.getLocalizedDateTimePattern(null, null, IsoChronology.INSTANCE, Locale.US); + Assertions.assertThrows(IllegalArgumentException.class, () -> DateTimeFormatterBuilder.getLocalizedDateTimePattern(null, null, IsoChronology.INSTANCE, Locale.US)); } - @Test(expectedExceptions=java.lang.NullPointerException.class) + @Test public void test_getLocalizedChronoNPE() { - DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, null, Locale.US); + Assertions.assertThrows(NullPointerException.class, () -> DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, null, Locale.US)); } - @Test(expectedExceptions=java.lang.NullPointerException.class) + @Test public void test_getLocalizedLocaleNPE() { - DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, null); + Assertions.assertThrows(NullPointerException.class, () -> DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, null)); } /** diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java index a0981f0c4d8..ff44426dbe9 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -84,27 +84,26 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test DateTimeFormatterBuilder. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeFormatterBuilderWithLocale { private DateTimeFormatterBuilder builder; - @BeforeMethod + @BeforeEach public void setUp() { builder = new DateTimeFormatterBuilder(); } //----------------------------------------------------------------------- - @DataProvider(name="patternPrint") Object[][] data_patternPrint() { return new Object[][] { {"Q", date(2012, 2, 10), "1"}, @@ -115,15 +114,15 @@ public class TestDateTimeFormatterBuilderWithLocale { }; } - @Test(dataProvider="patternPrint") + @ParameterizedTest + @MethodSource("data_patternPrint") public void test_appendPattern_patternPrint(String input, Temporal temporal, String expected) throws Exception { DateTimeFormatter f = builder.appendPattern(input).toFormatter(Locale.UK); String test = f.format(temporal); - assertEquals(test, expected); + assertEquals(expected, test); } //----------------------------------------------------------------------- - @DataProvider(name="mapTextLookup") Object[][] data_mapTextLookup() { return new Object[][] { {IsoChronology.INSTANCE.date(1, 1, 1), Locale.ENGLISH}, @@ -133,7 +132,8 @@ public class TestDateTimeFormatterBuilderWithLocale { }; } - @Test(dataProvider="mapTextLookup") + @ParameterizedTest + @MethodSource("data_mapTextLookup") public void test_appendText_mapTextLookup(ChronoLocalDate date, Locale locale) { final String firstYear = "firstYear"; final String firstMonth = "firstMonth"; @@ -146,16 +146,15 @@ public class TestDateTimeFormatterBuilderWithLocale { .toFormatter(locale) .withResolverStyle(ResolverStyle.STRICT); - assertEquals(date.format(formatter), firstYearMonth); + assertEquals(firstYearMonth, date.format(formatter)); TemporalAccessor ta = formatter.parse(firstYearMonth); - assertEquals(ta.getLong(ChronoField.YEAR_OF_ERA), first); - assertEquals(ta.getLong(ChronoField.MONTH_OF_YEAR), first); + assertEquals(first, ta.getLong(ChronoField.YEAR_OF_ERA)); + assertEquals(first, ta.getLong(ChronoField.MONTH_OF_YEAR)); } //----------------------------------------------------------------------- - @DataProvider(name="localePatterns") Object[][] localizedDateTimePatterns() { return new Object[][] { // French Locale and ISO Chronology @@ -202,11 +201,12 @@ public class TestDateTimeFormatterBuilderWithLocale { }; } - @Test(dataProvider="localePatterns") + @ParameterizedTest + @MethodSource("localizedDateTimePatterns") public void test_getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale, String expected) { String actual = DateTimeFormatterBuilder.getLocalizedDateTimePattern(dateStyle, timeStyle, chrono, locale); - assertEquals(actual, expected, "Pattern " + convertNonAscii(actual)); + assertEquals(expected, actual, "Pattern " + convertNonAscii(actual)); } /** diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeParsing.java b/test/jdk/java/time/test/java/time/format/TestDateTimeParsing.java index 67c91e6ad7e..f50a99f8a0e 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeParsing.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeParsing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -71,8 +71,9 @@ import static java.time.temporal.ChronoField.NANO_OF_SECOND; import static java.time.temporal.ChronoField.OFFSET_SECONDS; import static java.time.temporal.ChronoField.SECOND_OF_DAY; import static java.util.Locale.US; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import java.text.ParsePosition; import java.time.DateTimeException; @@ -88,14 +89,18 @@ import java.time.format.SignStyle; import java.time.temporal.TemporalAccessor; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * @test * @summary Test parsing of edge cases. * @bug 8223773 8272473 8319640 */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeParsing { private static final ZoneId PARIS = ZoneId.of("Europe/Paris"); @@ -132,7 +137,6 @@ public class TestDateTimeParsing { private static final String DTPE_MESSAGE = "Invalid value for HourOfAmPm (valid values 0 - 11): 12"; - @DataProvider(name = "instantZones") Object[][] data_instantZones() { return new Object[][] { {LOCALFIELDS_ZONEID, "2014-06-30 01:02:03 Europe/Paris", ZonedDateTime.of(2014, 6, 30, 1, 2, 3, 0, PARIS)}, @@ -154,37 +158,40 @@ public class TestDateTimeParsing { }; } - @Test(dataProvider = "instantZones") + @ParameterizedTest + @MethodSource("data_instantZones") public void test_parse_instantZones_ZDT(DateTimeFormatter formatter, String text, ZonedDateTime expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(ZonedDateTime.from(actual), expected); + assertEquals(expected, ZonedDateTime.from(actual)); } - @Test(dataProvider = "instantZones") + @ParameterizedTest + @MethodSource("data_instantZones") public void test_parse_instantZones_LDT(DateTimeFormatter formatter, String text, ZonedDateTime expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(LocalDateTime.from(actual), expected.toLocalDateTime()); + assertEquals(expected.toLocalDateTime(), LocalDateTime.from(actual)); } - @Test(dataProvider = "instantZones") + @ParameterizedTest + @MethodSource("data_instantZones") public void test_parse_instantZones_Instant(DateTimeFormatter formatter, String text, ZonedDateTime expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(Instant.from(actual), expected.toInstant()); + assertEquals(expected.toInstant(), Instant.from(actual)); } - @Test(dataProvider = "instantZones") + @ParameterizedTest + @MethodSource("data_instantZones") public void test_parse_instantZones_supported(DateTimeFormatter formatter, String text, ZonedDateTime expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(actual.isSupported(INSTANT_SECONDS), true); - assertEquals(actual.isSupported(EPOCH_DAY), true); - assertEquals(actual.isSupported(SECOND_OF_DAY), true); - assertEquals(actual.isSupported(NANO_OF_SECOND), true); - assertEquals(actual.isSupported(MICRO_OF_SECOND), true); - assertEquals(actual.isSupported(MILLI_OF_SECOND), true); + assertEquals(true, actual.isSupported(INSTANT_SECONDS)); + assertEquals(true, actual.isSupported(EPOCH_DAY)); + assertEquals(true, actual.isSupported(SECOND_OF_DAY)); + assertEquals(true, actual.isSupported(NANO_OF_SECOND)); + assertEquals(true, actual.isSupported(MICRO_OF_SECOND)); + assertEquals(true, actual.isSupported(MILLI_OF_SECOND)); } //----------------------------------------------------------------------- - @DataProvider(name = "instantNoZone") Object[][] data_instantNoZone() { return new Object[][] { {INSTANT, "2014-06-30T01:02:03Z", ZonedDateTime.of(2014, 6, 30, 1, 2, 3, 0, ZoneOffset.UTC).toInstant()}, @@ -193,55 +200,65 @@ public class TestDateTimeParsing { }; } - @Test(dataProvider = "instantNoZone", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_instantNoZone") public void test_parse_instantNoZone_ZDT(DateTimeFormatter formatter, String text, Instant expected) { - TemporalAccessor actual = formatter.parse(text); - ZonedDateTime.from(actual); + Assertions.assertThrows(DateTimeException.class, () -> { + TemporalAccessor actual = formatter.parse(text); + ZonedDateTime.from(actual); + }); } - @Test(dataProvider = "instantNoZone", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_instantNoZone") public void test_parse_instantNoZone_LDT(DateTimeFormatter formatter, String text, Instant expected) { - TemporalAccessor actual = formatter.parse(text); - LocalDateTime.from(actual); + Assertions.assertThrows(DateTimeException.class, () -> { + TemporalAccessor actual = formatter.parse(text); + LocalDateTime.from(actual); + }); } - @Test(dataProvider = "instantNoZone") + @ParameterizedTest + @MethodSource("data_instantNoZone") public void test_parse_instantNoZone_Instant(DateTimeFormatter formatter, String text, Instant expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(Instant.from(actual), expected); + assertEquals(expected, Instant.from(actual)); } - @Test(dataProvider = "instantNoZone") + @ParameterizedTest + @MethodSource("data_instantNoZone") public void test_parse_instantNoZone_supported(DateTimeFormatter formatter, String text, Instant expected) { TemporalAccessor actual = formatter.parse(text); - assertEquals(actual.isSupported(INSTANT_SECONDS), true); - assertEquals(actual.isSupported(EPOCH_DAY), false); - assertEquals(actual.isSupported(SECOND_OF_DAY), false); - assertEquals(actual.isSupported(NANO_OF_SECOND), true); - assertEquals(actual.isSupported(MICRO_OF_SECOND), true); - assertEquals(actual.isSupported(MILLI_OF_SECOND), true); + assertEquals(true, actual.isSupported(INSTANT_SECONDS)); + assertEquals(false, actual.isSupported(EPOCH_DAY)); + assertEquals(false, actual.isSupported(SECOND_OF_DAY)); + assertEquals(true, actual.isSupported(NANO_OF_SECOND)); + assertEquals(true, actual.isSupported(MICRO_OF_SECOND)); + assertEquals(true, actual.isSupported(MILLI_OF_SECOND)); } // Bug 8223773: validation check for the range of HourOfAmPm in SMART mode. // Should throw a DateTimeParseException, as 12 is out of range for HourOfAmPm. - @Test(expectedExceptions = DateTimeParseException.class) + @Test public void test_validateHourOfAmPm() { - try { - new DateTimeFormatterBuilder() - .appendValue(HOUR_OF_AMPM,2) - .appendText(AMPM_OF_DAY) - .toFormatter(US) - .parse("12PM"); - } catch (DateTimeParseException e) { - Throwable cause = e.getCause(); - if (cause == null || - !DTPE_MESSAGE.equals(cause.getMessage())) { - throw new RuntimeException( - "DateTimeParseException was thrown with different reason: " + e); - } else { - throw e; + Assertions.assertThrows(DateTimeParseException.class, () -> { + try { + new DateTimeFormatterBuilder() + .appendValue(HOUR_OF_AMPM,2) + .appendText(AMPM_OF_DAY) + .toFormatter(US) + .parse("12PM"); + } catch (DateTimeParseException e) { + Throwable cause = e.getCause(); + if (cause == null || + !DTPE_MESSAGE.equals(cause.getMessage())) { + throw new RuntimeException( + "DateTimeParseException was thrown with different reason: " + e); + } else { + throw e; + } } - } + }); } // Checks ::toFormat().parseObject(text, pos) do not throw DateTimeException diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeTextProvider.java b/test/jdk/java/time/test/java/time/format/TestDateTimeTextProvider.java index f2a14374c49..80336b7b761 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeTextProvider.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeTextProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -62,7 +62,8 @@ package test.java.time.format; import static java.time.temporal.ChronoField.AMPM_OF_DAY; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -70,19 +71,19 @@ import java.time.format.TextStyle; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test SimpleDateTimeTextProvider. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeTextProvider extends AbstractTestPrinterParser { Locale enUS = Locale.US; //----------------------------------------------------------------------- - @DataProvider(name = "Text") Object[][] data_text() { return new Object[][] { {DAY_OF_WEEK, 1, TextStyle.SHORT, enUS, "Mon"}, @@ -133,10 +134,11 @@ public class TestDateTimeTextProvider extends AbstractTestPrinterParser { }; } - @Test(dataProvider = "Text") + @ParameterizedTest + @MethodSource("data_text") public void test_getText(TemporalField field, Number value, TextStyle style, Locale locale, String expected) { DateTimeFormatter fmt = getFormatter(field, style).withLocale(locale); - assertEquals(fmt.format(ZonedDateTime.now().with(field, value.longValue())), expected); + assertEquals(expected, fmt.format(ZonedDateTime.now().with(field, value.longValue()))); } } diff --git a/test/jdk/java/time/test/java/time/format/TestDateTimeTextProviderWithLocale.java b/test/jdk/java/time/test/java/time/format/TestDateTimeTextProviderWithLocale.java index 65d65251862..35b793bb769 100644 --- a/test/jdk/java/time/test/java/time/format/TestDateTimeTextProviderWithLocale.java +++ b/test/jdk/java/time/test/java/time/format/TestDateTimeTextProviderWithLocale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -69,7 +69,8 @@ package test.java.time.format; import static java.time.temporal.ChronoField.AMPM_OF_DAY; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -77,20 +78,20 @@ import java.time.format.TextStyle; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test SimpleDateTimeTextProviderWithLocale. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeTextProviderWithLocale extends AbstractTestPrinterParser { Locale enUS = Locale.US; Locale ptBR = Locale.of("pt", "BR"); //----------------------------------------------------------------------- - @DataProvider(name = "Text") Object[][] data_text() { return new Object[][] { {DAY_OF_WEEK, 1, TextStyle.SHORT, ptBR, "seg."}, @@ -138,10 +139,11 @@ public class TestDateTimeTextProviderWithLocale extends AbstractTestPrinterParse }; } - @Test(dataProvider = "Text") + @ParameterizedTest + @MethodSource("data_text") public void test_getText(TemporalField field, Number value, TextStyle style, Locale locale, String expected) { DateTimeFormatter fmt = getFormatter(field, style).withLocale(locale); - assertEquals(fmt.format(ZonedDateTime.now().with(field, value.longValue())), expected); + assertEquals(expected, fmt.format(ZonedDateTime.now().with(field, value.longValue()))); } } diff --git a/test/jdk/java/time/test/java/time/format/TestDecimalStyle.java b/test/jdk/java/time/test/java/time/format/TestDecimalStyle.java index b506d547ada..48f7da3e80c 100644 --- a/test/jdk/java/time/test/java/time/format/TestDecimalStyle.java +++ b/test/jdk/java/time/test/java/time/format/TestDecimalStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,17 +59,16 @@ */ package test.java.time.format; -import static org.testng.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; import java.time.format.DecimalStyle; import java.util.Locale; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test DecimalStyle. */ -@Test public class TestDecimalStyle { @Test diff --git a/test/jdk/java/time/test/java/time/format/TestFractionPrinterParser.java b/test/jdk/java/time/test/java/time/format/TestFractionPrinterParser.java index 4dbca06709d..0c079173d1f 100644 --- a/test/jdk/java/time/test/java/time/format/TestFractionPrinterParser.java +++ b/test/jdk/java/time/test/java/time/format/TestFractionPrinterParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,8 +60,9 @@ package test.java.time.format; import static java.time.temporal.ChronoField.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.text.ParsePosition; import java.time.DateTimeException; @@ -71,8 +72,12 @@ import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.temporal.MockFieldValue; /** @@ -80,7 +85,7 @@ import test.java.time.temporal.MockFieldValue; * * @bug 8230136 8276220 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestFractionPrinterParser extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter(TemporalField field, int minWidth, int maxWidth, boolean decimalPoint) { @@ -90,12 +95,11 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- // print //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_emptyCalendrical() throws Exception { - getFormatter(NANO_OF_SECOND, 0, 9, true).formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter(NANO_OF_SECOND, 0, 9, true).formatTo(EMPTY_DTA, buf)); } - @DataProvider(name="OOB_Nanos") Object[][] provider_oob_nanos() { return new Object[][]{ {-1}, @@ -108,12 +112,12 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="OOB_Nanos", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("provider_oob_nanos") public void test_print_oob_nanos(long value) throws Exception { - getFormatter(NANO_OF_SECOND, 0, 9, true).formatTo(new MockFieldValue(NANO_OF_SECOND, value), buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter(NANO_OF_SECOND, 0, 9, true).formatTo(new MockFieldValue(NANO_OF_SECOND, value), buf)); } - @DataProvider(name="OOB_Micros") Object[][] provider_oob_micros() { return new Object[][]{ {-1}, @@ -126,25 +130,27 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="OOB_Micros", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("provider_oob_micros") public void test_print_oob_micros(long value) throws Exception { - getFormatter(MICRO_OF_SECOND, 0, 9, true).formatTo(new MockFieldValue(MICRO_OF_SECOND, value), buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter(MICRO_OF_SECOND, 0, 9, true).formatTo(new MockFieldValue(MICRO_OF_SECOND, value), buf)); } + @Test public void test_print_append() throws Exception { buf.append("EXISTING"); getFormatter(NANO_OF_SECOND, 0, 9, true).formatTo(LocalTime.of(12, 30, 40, 3), buf); - assertEquals(buf.toString(), "EXISTING.000000003"); + assertEquals("EXISTING.000000003", buf.toString()); } + @Test public void test_print_append_micros() throws Exception { buf.append("EXISTING"); getFormatter(MICRO_OF_SECOND, 0, 6, true).formatTo(LocalTime.of(12, 30, 40, 3000), buf); - assertEquals(buf.toString(), "EXISTING.000003"); + assertEquals("EXISTING.000003", buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="Nanos") Object[][] provider_nanos() { return new Object[][] { {0, 9, 0, ""}, @@ -266,26 +272,27 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_print_nanos(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(NANO_OF_SECOND, minWidth, maxWidth, true).formatTo(new MockFieldValue(NANO_OF_SECOND, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_print_nanos_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(NANO_OF_SECOND, minWidth, maxWidth, false).formatTo(new MockFieldValue(NANO_OF_SECOND, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), (result.startsWith(".") ? result.substring(1) : result)); + assertEquals((result.startsWith(".") ? result.substring(1) : result), buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="Micros") Object[][] provider_micros() { return new Object[][] { {0, 6, 0, ""}, @@ -342,26 +349,27 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="Micros") + @ParameterizedTest + @MethodSource("provider_micros") public void test_print_micros(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(MICRO_OF_SECOND, minWidth, maxWidth, true).formatTo(new MockFieldValue(MICRO_OF_SECOND, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } - @Test(dataProvider="Micros") + @ParameterizedTest + @MethodSource("provider_micros") public void test_print_micros_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(MICRO_OF_SECOND, minWidth, maxWidth, false).formatTo(new MockFieldValue(MICRO_OF_SECOND, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), (result.startsWith(".") ? result.substring(1) : result)); + assertEquals((result.startsWith(".") ? result.substring(1) : result), buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="Seconds") Object[][] provider_seconds() { return new Object[][] { {0, 9, 0, ""}, @@ -384,51 +392,56 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="Seconds") + @ParameterizedTest + @MethodSource("provider_seconds") public void test_print_seconds(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(SECOND_OF_MINUTE, minWidth, maxWidth, true).formatTo(new MockFieldValue(SECOND_OF_MINUTE, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } - @Test(dataProvider="Seconds") + @ParameterizedTest + @MethodSource("provider_seconds") public void test_print_seconds_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception { getFormatter(SECOND_OF_MINUTE, minWidth, maxWidth, false).formatTo(new MockFieldValue(SECOND_OF_MINUTE, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), (result.startsWith(".") ? result.substring(1) : result)); + assertEquals((result.startsWith(".") ? result.substring(1) : result), buf.toString()); } //----------------------------------------------------------------------- // parse //----------------------------------------------------------------------- - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_reverseParse(int minWidth, int maxWidth, int value, String result) throws Exception { ParsePosition pos = new ParsePosition(0); int expectedValue = fixParsedValue(maxWidth, value); TemporalAccessor parsed = getFormatter(NANO_OF_SECOND, minWidth, maxWidth, true).parseUnresolved(result, pos); - assertEquals(pos.getIndex(), result.length()); + assertEquals(result.length(), pos.getIndex()); assertParsed(parsed, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue); } - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_reverseParse_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception { ParsePosition pos = new ParsePosition((result.startsWith(".") ? 1 : 0)); TemporalAccessor parsed = getFormatter(NANO_OF_SECOND, minWidth, maxWidth, false).parseUnresolved(result, pos); - assertEquals(pos.getIndex(), result.length()); + assertEquals(result.length(), pos.getIndex()); int expectedValue = fixParsedValue(maxWidth, value); assertParsed(parsed, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue); } - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_reverseParse_followedByNonDigit(int minWidth, int maxWidth, int value, String result) throws Exception { ParsePosition pos = new ParsePosition(0); int expectedValue = fixParsedValue(maxWidth, value); TemporalAccessor parsed = getFormatter(NANO_OF_SECOND, minWidth, maxWidth, true).parseUnresolved(result + " ", pos); - assertEquals(pos.getIndex(), result.length()); + assertEquals(result.length(), pos.getIndex()); assertParsed(parsed, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue); } @@ -441,12 +454,13 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { // assertParsed(parseContext, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue); // } - @Test(dataProvider="Nanos") + @ParameterizedTest + @MethodSource("provider_nanos") public void test_reverseParse_preceededByNonDigit(int minWidth, int maxWidth, int value, String result) throws Exception { ParsePosition pos = new ParsePosition(1); int expectedValue = fixParsedValue(maxWidth, value); TemporalAccessor parsed = getFormatter(NANO_OF_SECOND, minWidth, maxWidth, true).parseUnresolved(" " + result, pos); - assertEquals(pos.getIndex(), result.length() + 1); + assertEquals(result.length() + 1, pos.getIndex()); assertParsed(parsed, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue); } @@ -458,25 +472,25 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { return value; } - @Test(dataProvider="Seconds") + @ParameterizedTest + @MethodSource("provider_seconds") public void test_reverseParse_seconds(int minWidth, int maxWidth, int value, String result) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(SECOND_OF_MINUTE, minWidth, maxWidth, true).parseUnresolved(result, pos); - assertEquals(pos.getIndex(), result.length()); + assertEquals(result.length(), pos.getIndex()); assertParsed(parsed, SECOND_OF_MINUTE, value == 0 && minWidth == 0 ? null : (long) value); } private void assertParsed(TemporalAccessor parsed, TemporalField field, Long value) { if (value == null) { - assertEquals(parsed.isSupported(field), false); + assertEquals(false, parsed.isSupported(field)); } else { - assertEquals(parsed.isSupported(field), true); - assertEquals(parsed.getLong(field), (long) value); + assertEquals(true, parsed.isSupported(field)); + assertEquals((long) value, parsed.getLong(field)); } } //----------------------------------------------------------------------- - @DataProvider(name="ParseNothing") Object[][] provider_parseNothing() { return new Object[][] { {NANO_OF_SECOND, 3, 6, true, "", 0, 0}, @@ -489,15 +503,15 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider = "ParseNothing") + @ParameterizedTest + @MethodSource("provider_parseNothing") public void test_parse_nothing(TemporalField field, int min, int max, boolean decimalPoint, String text, int pos, int expected) { ParsePosition ppos = new ParsePosition(pos); TemporalAccessor parsed = getFormatter(field, min, max, decimalPoint).parseUnresolved(text, ppos); - assertEquals(ppos.getErrorIndex(), expected); - assertEquals(parsed, null); + assertEquals(expected, ppos.getErrorIndex()); + assertEquals(null, parsed); } - @DataProvider(name="ParseMinWidth") Object[][] provider_parseMinWidth() { return new Object[][] { {MILLI_OF_SECOND, 3, 3, true, ".1x"}, @@ -506,22 +520,26 @@ public class TestFractionPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="ParseMinWidth", expectedExceptions=DateTimeException.class) + @ParameterizedTest + @MethodSource("provider_parseMinWidth") public void test_parse_minWidth(TemporalField field, int min, int max, boolean decimalPoint, String text) throws Exception { - builder - .appendFraction(field, min, max, decimalPoint) - .appendLiteral("x") - .toFormatter(locale) - .parse(text); + Assertions + .assertThrows(DateTimeException.class, () -> builder + .appendFraction(field, min, max, decimalPoint) + .appendLiteral("x") + .toFormatter(locale) + .parse(text)); } //----------------------------------------------------------------------- + @Test public void test_toString() throws Exception { - assertEquals(getFormatter(NANO_OF_SECOND, 3, 6, true).toString(), "Fraction(NanoOfSecond,3,6,DecimalPoint)"); + assertEquals("Fraction(NanoOfSecond,3,6,DecimalPoint)", getFormatter(NANO_OF_SECOND, 3, 6, true).toString()); } + @Test public void test_toString_noDecimalPoint() throws Exception { - assertEquals(getFormatter(NANO_OF_SECOND, 3, 6, false).toString(), "Fraction(NanoOfSecond,3,6)"); + assertEquals("Fraction(NanoOfSecond,3,6)", getFormatter(NANO_OF_SECOND, 3, 6, false).toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestLocalizedOffsetPrinterParser.java b/test/jdk/java/time/test/java/time/format/TestLocalizedOffsetPrinterParser.java index d1b1c25ba98..36b491178a7 100644 --- a/test/jdk/java/time/test/java/time/format/TestLocalizedOffsetPrinterParser.java +++ b/test/jdk/java/time/test/java/time/format/TestLocalizedOffsetPrinterParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -35,7 +35,7 @@ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDateTime; import java.time.OffsetDateTime; @@ -47,20 +47,20 @@ import java.time.format.TextStyle; import java.util.Locale; import java.util.Objects; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test DateTimeFormatterBuilder.appendOffset(). */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestLocalizedOffsetPrinterParser { private static final LocalDateTime DT_2012_06_30_12_30_40 = LocalDateTime.of(2012, 6, 30, 12, 30, 40); private static final Locale LOCALE_GA = Locale.of("ga"); - @DataProvider(name="print_localized_custom_locale") Object[][] data_print_localized_custom_locale() { return new Object[][] { {TextStyle.FULL, DT_2012_06_30_12_30_40, ZoneOffset.UTC, LOCALE_GA, "MAG"}, @@ -69,7 +69,8 @@ public class TestLocalizedOffsetPrinterParser { }; } - @Test(dataProvider="print_localized_custom_locale") + @ParameterizedTest + @MethodSource("data_print_localized_custom_locale") public void test_print_localized_custom_locale(TextStyle style, LocalDateTime ldt, ZoneOffset offset, Locale locale, String expected) { Objects.requireNonNull(locale, "Locale must not be null"); @@ -78,27 +79,27 @@ public class TestLocalizedOffsetPrinterParser { ZonedDateTime zdt = ldt.atZone(offset); DateTimeFormatter f = new DateTimeFormatterBuilder().appendLocalizedOffset(style).toFormatter(locale); - assertEquals(f.format(odt), expected); - assertEquals(f.format(zdt), expected); - assertEquals(f.parse(expected, ZoneOffset::from), offset); + assertEquals(expected, f.format(odt)); + assertEquals(expected, f.format(zdt)); + assertEquals(offset, f.parse(expected, ZoneOffset::from)); if (style == TextStyle.FULL) { f = new DateTimeFormatterBuilder().appendPattern("ZZZZ").toFormatter(locale); - assertEquals(f.format(odt), expected); - assertEquals(f.format(zdt), expected); - assertEquals(f.parse(expected, ZoneOffset::from), offset); + assertEquals(expected, f.format(odt)); + assertEquals(expected, f.format(zdt)); + assertEquals(offset, f.parse(expected, ZoneOffset::from)); f = new DateTimeFormatterBuilder().appendPattern("OOOO").toFormatter(locale); - assertEquals(f.format(odt), expected); - assertEquals(f.format(zdt), expected); - assertEquals(f.parse(expected, ZoneOffset::from), offset); + assertEquals(expected, f.format(odt)); + assertEquals(expected, f.format(zdt)); + assertEquals(offset, f.parse(expected, ZoneOffset::from)); } if (style == TextStyle.SHORT) { f = new DateTimeFormatterBuilder().appendPattern("O").toFormatter(locale); - assertEquals(f.format(odt), expected); - assertEquals(f.format(zdt), expected); - assertEquals(f.parse(expected, ZoneOffset::from), offset); + assertEquals(expected, f.format(odt)); + assertEquals(expected, f.format(zdt)); + assertEquals(offset, f.parse(expected, ZoneOffset::from)); } } diff --git a/test/jdk/java/time/test/java/time/format/TestLocalizedPattern.java b/test/jdk/java/time/test/java/time/format/TestLocalizedPattern.java index aa8ff763aad..1be115bc0ed 100644 --- a/test/jdk/java/time/test/java/time/format/TestLocalizedPattern.java +++ b/test/jdk/java/time/test/java/time/format/TestLocalizedPattern.java @@ -22,7 +22,7 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.ZonedDateTime; @@ -34,14 +34,16 @@ import java.util.List; import java.util.Locale; import java.util.ResourceBundle; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test DateTimeFormatter.ofLocalizedPattern() related methods. * @bug 8176706 8284840 8354548 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestLocalizedPattern { private static final ZonedDateTime ZDT = @@ -52,7 +54,6 @@ public class TestLocalizedPattern { Locale.forLanguageTag("ja-JP-u-ca-japanese") ); - @DataProvider(name = "validSkeletons") Object[][] data_validSkeletons() { return SAMPLE_LOCALES.stream() .flatMap(l -> { @@ -63,43 +64,46 @@ public class TestLocalizedPattern { .toArray(new Object[0][0]); } - @DataProvider(name = "invalidSkeletons") Object[][] data_invalidSkeletons() { return new Object[][] { {"afo"}, {"hB"}, {"uMMM"}, {"MMMMMM"}, {"BhmsyMMM"}, }; } - @DataProvider(name = "unavailableSkeletons") Object[][] data_unavailableSkeletons() { return new Object[][] { {"yyyyyy"}, {"BBh"}, {"yMMMMEdBBh"}, }; } - @Test(dataProvider = "validSkeletons") + @ParameterizedTest + @MethodSource("data_validSkeletons") public void test_ofLocalizedPattern(String skeleton, String expected, Locale l) { var dtf = DateTimeFormatter.ofLocalizedPattern(skeleton).localizedBy(l); - assertEquals(dtf.format(ZDT), expected); + assertEquals(expected, dtf.format(ZDT)); } - @Test(dataProvider = "invalidSkeletons", expectedExceptions = IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("data_invalidSkeletons") public void test_ofLocalizedPattern_invalid(String skeleton) { - DateTimeFormatter.ofLocalizedPattern(skeleton); + Assertions.assertThrows(IllegalArgumentException.class, () -> DateTimeFormatter.ofLocalizedPattern(skeleton)); } - @Test(dataProvider = "invalidSkeletons", expectedExceptions = IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("data_invalidSkeletons") public void test_appendLocalized_invalid(String skeleton) { - new DateTimeFormatterBuilder().appendLocalized(skeleton); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DateTimeFormatterBuilder().appendLocalized(skeleton)); } - @Test(dataProvider = "unavailableSkeletons", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_unavailableSkeletons") public void test_ofLocalizedPattern_unavailable(String skeleton) { - DateTimeFormatter.ofLocalizedPattern(skeleton).format(ZDT); + Assertions.assertThrows(DateTimeException.class, () -> DateTimeFormatter.ofLocalizedPattern(skeleton).format(ZDT)); } - @Test(dataProvider = "unavailableSkeletons", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_unavailableSkeletons") public void test_getLocalizedDateTimePattern_unavailable(String skeleton) { - DateTimeFormatterBuilder.getLocalizedDateTimePattern(skeleton, IsoChronology.INSTANCE, Locale.US); + Assertions.assertThrows(DateTimeException.class, () -> DateTimeFormatterBuilder.getLocalizedDateTimePattern(skeleton, IsoChronology.INSTANCE, Locale.US)); } } diff --git a/test/jdk/java/time/test/java/time/format/TestNarrowMonthNamesAndDayNames.java b/test/jdk/java/time/test/java/time/format/TestNarrowMonthNamesAndDayNames.java index 3e105665d14..92b7d1366b6 100644 --- a/test/jdk/java/time/test/java/time/format/TestNarrowMonthNamesAndDayNames.java +++ b/test/jdk/java/time/test/java/time/format/TestNarrowMonthNamesAndDayNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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,7 +28,7 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DayOfWeek; import java.time.Month; @@ -37,9 +37,11 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestNarrowMonthNamesAndDayNames { static { @@ -59,7 +61,6 @@ public class TestNarrowMonthNamesAndDayNames { * Locale en_US, de_DE, fr_FR, no_NO will have same Narrow and * Narrow_Standalone month Names for COMPAT Provider. */ - @DataProvider(name = "MonthNarrows") public Object[][] monthNameData() { return new Object[][]{{new String[]{ "J", @@ -80,27 +81,23 @@ public class TestNarrowMonthNamesAndDayNames { //----------------------------------------------------------------------- // Check Narrow and Narrow_standalone month name values //----------------------------------------------------------------------- - @Test(dataProvider = "MonthNarrows") + @ParameterizedTest + @MethodSource("monthNameData") public void compareMonthNarrowValues(String[] monthNarrowExpected) { - LOCARR.forEach((loc) -> { - TEXTSTYLELIST.forEach((style) -> { - MONTHVALUES.forEach((value) -> { - String result = value.getDisplayName(style, loc); - int index = value.ordinal(); - assertEquals(result, monthNarrowExpected[index], "Test failed" - + " for COMPAT Provider for locale " - + loc + " for style " + style.name() - + " with Month value " + value.name()); - }); - }); - }); + LOCARR.forEach((loc) -> TEXTSTYLELIST.forEach((style) -> MONTHVALUES.forEach((value) -> { + String result = value.getDisplayName(style, loc); + int index = value.ordinal(); + assertEquals(monthNarrowExpected[index], result, "Test failed" + + " for COMPAT Provider for locale " + + loc + " for style " + style.name() + + " with Month value " + value.name()); + }))); } /** * Locale en_US, de_DE, fr_FR, no_NO will have different Narrow and * Narrow_Standalone Day Names for COMPAT Provider. */ - @DataProvider(name = "DayNarrows") public Object[][] dayNameData() { return new Object[][]{ {Locale.US, new String[]{"M", "T", "W", "T", "F", "S", "S"}}, @@ -112,17 +109,16 @@ public class TestNarrowMonthNamesAndDayNames { //----------------------------------------------------------------------- // Check Narrow and Narrow_standalone Day name values //----------------------------------------------------------------------- - @Test(dataProvider = "DayNarrows") + @ParameterizedTest + @MethodSource("dayNameData") public void compareDayNarrowValues(Locale locale, String[] dayNarrowExpected) { - TEXTSTYLELIST.forEach((style) -> { - DAYVALUES.forEach((value) -> { - String result = value.getDisplayName(style, locale); - int index = value.ordinal(); - assertEquals(result, dayNarrowExpected[index], "Test failed" - + " for COMPAT Provider for locale " - + locale + " for style " + style.name() - + " with Day value " + value.name()); - }); - }); + TEXTSTYLELIST.forEach((style) -> DAYVALUES.forEach((value) -> { + String result = value.getDisplayName(style, locale); + int index = value.ordinal(); + assertEquals(dayNarrowExpected[index], result, "Test failed" + + " for COMPAT Provider for locale " + + locale + " for style " + style.name() + + " with Day value " + value.name()); + })); } } diff --git a/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java b/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java index edca2ae8ceb..cb824e1ea7f 100644 --- a/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java +++ b/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -30,7 +30,7 @@ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDate; import java.time.chrono.ChronoLocalDate; @@ -51,9 +51,11 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; import java.util.Locale; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test DateTimeFormatter with non-ISO chronology. @@ -61,7 +63,7 @@ import org.testng.annotations.Test; * Strings in test data are all dependent on CLDR data which may change * in future CLDR releases. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestNonIsoFormatter { private static final Chronology ISO8601 = IsoChronology.INSTANCE; private static final Chronology JAPANESE = JapaneseChronology.INSTANCE; @@ -76,11 +78,10 @@ public class TestNonIsoFormatter { private static final Locale thTHTH = Locale.forLanguageTag("th-TH-u-nu-thai"); private static final Locale jaJPJP = Locale.forLanguageTag("ja-JP-u-ca-japanese"); - @BeforeMethod + @BeforeEach public void setUp() { } - @DataProvider(name="format_data") Object[][] formatData() { return new Object[][] { // Chronology, Format Locale, Numbering Locale, ChronoLocalDate, expected string @@ -102,7 +103,6 @@ public class TestNonIsoFormatter { }; } - @DataProvider(name="invalid_text") Object[][] invalidText() { return new Object[][] { // TODO: currently fixed Chronology and Locale. @@ -113,7 +113,6 @@ public class TestNonIsoFormatter { }; } - @DataProvider(name="chrono_names") Object[][] chronoNamesData() { return new Object[][] { // Chronology, Locale, Chronology Name @@ -137,7 +136,6 @@ public class TestNonIsoFormatter { }; } - @DataProvider(name="lenient_eraYear") Object[][] lenientEraYear() { return new Object[][] { // Chronology, lenient era/year, strict era/year @@ -147,17 +145,19 @@ public class TestNonIsoFormatter { }; } - @Test(dataProvider="format_data") + @ParameterizedTest + @MethodSource("formatData") public void test_formatLocalizedDate(Chronology chrono, Locale formatLocale, Locale numberingLocale, ChronoLocalDate date, String expected) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) .withChronology(chrono).withLocale(formatLocale) .withDecimalStyle(DecimalStyle.of(numberingLocale)); String text = dtf.format(date); - assertEquals(text, expected); + assertEquals(expected, text); } - @Test(dataProvider="format_data") + @ParameterizedTest + @MethodSource("formatData") public void test_parseLocalizedText(Chronology chrono, Locale formatLocale, Locale numberingLocale, ChronoLocalDate expected, String text) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) @@ -165,28 +165,33 @@ public class TestNonIsoFormatter { .withDecimalStyle(DecimalStyle.of(numberingLocale)); TemporalAccessor temporal = dtf.parse(text); ChronoLocalDate date = chrono.date(temporal); - assertEquals(date, expected); + assertEquals(expected, date); } - @Test(dataProvider="invalid_text", expectedExceptions=DateTimeParseException.class) + @ParameterizedTest + @MethodSource("invalidText") public void test_parseInvalidText(String text) { - DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) - .withChronology(JAPANESE).withLocale(Locale.JAPANESE); - dtf.parse(text); + Assertions.assertThrows(DateTimeParseException.class, () -> { + DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) + .withChronology(JAPANESE).withLocale(Locale.JAPANESE); + dtf.parse(text); + }); } - @Test(dataProvider="chrono_names") + @ParameterizedTest + @MethodSource("chronoNamesData") public void test_chronoNames(Chronology chrono, Locale locale, String expected) { DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendChronologyText(TextStyle.SHORT) .toFormatter(locale); String text = dtf.format(chrono.dateNow()); - assertEquals(text, expected); + assertEquals(expected, text); TemporalAccessor ta = dtf.parse(text); Chronology cal = ta.query(TemporalQueries.chronology()); - assertEquals(cal, chrono); + assertEquals(chrono, cal); } - @Test(dataProvider="lenient_eraYear") + @ParameterizedTest + @MethodSource("lenientEraYear") public void test_lenientEraYear(Chronology chrono, String lenient, String strict) { String mdStr = "-01-01"; DateTimeFormatter dtf = new DateTimeFormatterBuilder() @@ -194,6 +199,6 @@ public class TestNonIsoFormatter { .toFormatter(Locale.ROOT) .withChronology(chrono); DateTimeFormatter dtfLenient = dtf.withResolverStyle(ResolverStyle.LENIENT); - assertEquals(LocalDate.parse(lenient+mdStr, dtfLenient), LocalDate.parse(strict+mdStr, dtf)); + assertEquals(LocalDate.parse(strict+mdStr, dtf), LocalDate.parse(lenient+mdStr, dtfLenient)); } } diff --git a/test/jdk/java/time/test/java/time/format/TestNumberParser.java b/test/jdk/java/time/test/java/time/format/TestNumberParser.java index f3ac13b791d..ea92dfcaea5 100644 --- a/test/jdk/java/time/test/java/time/format/TestNumberParser.java +++ b/test/jdk/java/time/test/java/time/format/TestNumberParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -63,9 +63,10 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.text.ParsePosition; import java.time.format.DateTimeFormatter; @@ -74,17 +75,17 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQueries; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test NumberPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestNumberParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {DAY_OF_MONTH, 1, 2, SignStyle.NEVER, "12", -1, IndexOutOfBoundsException.class}, @@ -92,7 +93,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(TemporalField field, int min, int max, SignStyle style, String text, int pos, Class expected) { try { getFormatter(field, min, max, style).parseUnresolved(text, new ParsePosition(pos)); @@ -103,7 +105,6 @@ public class TestNumberParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- - @DataProvider(name="parseData") Object[][] provider_parseData() { return new Object[][] { // normal @@ -163,7 +164,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- - @Test(dataProvider="parseData") + @ParameterizedTest + @MethodSource("provider_parseData") public void test_parse_fresh(int minWidth, int maxWidth, SignStyle signStyle, int subsequentWidth, String text, int pos, int expectedPos, long expectedValue) { ParsePosition ppos = new ParsePosition(pos); DateTimeFormatter dtf = getFormatter(DAY_OF_MONTH, minWidth, maxWidth, signStyle); @@ -173,17 +175,18 @@ public class TestNumberParser extends AbstractTestPrinterParser { } TemporalAccessor parsed = dtf.parseUnresolved(text, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), expectedPos); + assertEquals(expectedPos, ppos.getErrorIndex()); } else { assertTrue(subsequentWidth >= 0); - assertEquals(ppos.getIndex(), expectedPos + subsequentWidth); - assertEquals(parsed.getLong(DAY_OF_MONTH), expectedValue); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(expectedPos + subsequentWidth, ppos.getIndex()); + assertEquals(expectedValue, parsed.getLong(DAY_OF_MONTH)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } - @Test(dataProvider="parseData") + @ParameterizedTest + @MethodSource("provider_parseData") public void test_parse_textField(int minWidth, int maxWidth, SignStyle signStyle, int subsequentWidth, String text, int pos, int expectedPos, long expectedValue) { ParsePosition ppos = new ParsePosition(pos); DateTimeFormatter dtf = getFormatter(DAY_OF_WEEK, minWidth, maxWidth, signStyle); @@ -193,18 +196,17 @@ public class TestNumberParser extends AbstractTestPrinterParser { } TemporalAccessor parsed = dtf.parseUnresolved(text, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), expectedPos); + assertEquals(expectedPos, ppos.getErrorIndex()); } else { assertTrue(subsequentWidth >= 0); - assertEquals(ppos.getIndex(), expectedPos + subsequentWidth); - assertEquals(parsed.getLong(DAY_OF_WEEK), expectedValue); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(expectedPos + subsequentWidth, ppos.getIndex()); + assertEquals(expectedValue, parsed.getLong(DAY_OF_WEEK)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="parseSignsStrict") Object[][] provider_parseSignsStrict() { return new Object[][] { // basics @@ -304,22 +306,22 @@ public class TestNumberParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseSignsStrict") + @ParameterizedTest + @MethodSource("provider_parseSignsStrict") public void test_parseSignsStrict(String input, int min, int max, SignStyle style, int parseLen, Integer parseVal) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(DAY_OF_MONTH, min, max, style).parseUnresolved(input, pos); if (pos.getErrorIndex() != -1) { - assertEquals(pos.getErrorIndex(), parseLen); + assertEquals(parseLen, pos.getErrorIndex()); } else { - assertEquals(pos.getIndex(), parseLen); - assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(parseLen, pos.getIndex()); + assertEquals((long)parseVal, parsed.getLong(DAY_OF_MONTH)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="parseSignsLenient") Object[][] provider_parseSignsLenient() { return new Object[][] { // never @@ -413,23 +415,23 @@ public class TestNumberParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseSignsLenient") + @ParameterizedTest + @MethodSource("provider_parseSignsLenient") public void test_parseSignsLenient(String input, int min, int max, SignStyle style, int parseLen, Integer parseVal) throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(DAY_OF_MONTH, min, max, style).parseUnresolved(input, pos); if (pos.getErrorIndex() != -1) { - assertEquals(pos.getErrorIndex(), parseLen); + assertEquals(parseLen, pos.getErrorIndex()); } else { - assertEquals(pos.getIndex(), parseLen); - assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(parseLen, pos.getIndex()); + assertEquals((long)parseVal, parsed.getLong(DAY_OF_MONTH)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="parseDigitsLenient") Object[][] provider_parseDigitsLenient() { return new Object[][] { // never @@ -504,23 +506,23 @@ public class TestNumberParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseDigitsLenient") + @ParameterizedTest + @MethodSource("provider_parseDigitsLenient") public void test_parseDigitsLenient(String input, int min, int max, SignStyle style, int parseLen, Integer parseVal) throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(DAY_OF_MONTH, min, max, style).parseUnresolved(input, pos); if (pos.getErrorIndex() != -1) { - assertEquals(pos.getErrorIndex(), parseLen); + assertEquals(parseLen, pos.getErrorIndex()); } else { - assertEquals(pos.getIndex(), parseLen); - assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(parseLen, pos.getIndex()); + assertEquals((long)parseVal, parsed.getLong(DAY_OF_MONTH)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="parseDigitsAdjacentLenient") Object[][] provider_parseDigitsAdjacentLenient() { return new Object[][] { // never @@ -538,7 +540,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseDigitsAdjacentLenient") + @ParameterizedTest + @MethodSource("provider_parseDigitsAdjacentLenient") public void test_parseDigitsAdjacentLenient(String input, int parseLen, Integer parseMonth, Integer parsedDay) throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); @@ -547,13 +550,13 @@ public class TestNumberParser extends AbstractTestPrinterParser { .appendValue(DAY_OF_MONTH, 2).toFormatter(locale).withDecimalStyle(decimalStyle); TemporalAccessor parsed = f.parseUnresolved(input, pos); if (pos.getErrorIndex() != -1) { - assertEquals(pos.getErrorIndex(), parseLen); + assertEquals(parseLen, pos.getErrorIndex()); } else { - assertEquals(pos.getIndex(), parseLen); - assertEquals(parsed.getLong(MONTH_OF_YEAR), (long) parseMonth); - assertEquals(parsed.getLong(DAY_OF_MONTH), (long) parsedDay); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(parseLen, pos.getIndex()); + assertEquals((long) parseMonth, parsed.getLong(MONTH_OF_YEAR)); + assertEquals((long) parsedDay, parsed.getLong(DAY_OF_MONTH)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } diff --git a/test/jdk/java/time/test/java/time/format/TestNumberPrinter.java b/test/jdk/java/time/test/java/time/format/TestNumberPrinter.java index dedcc37e2ce..59038df910f 100644 --- a/test/jdk/java/time/test/java/time/format/TestNumberPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestNumberPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -61,37 +61,42 @@ package test.java.time.format; import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.HOUR_OF_DAY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.time.DateTimeException; import java.time.LocalDate; import java.time.format.SignStyle; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.temporal.MockFieldValue; /** * Test SimpleNumberPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestNumberPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_emptyCalendrical() throws Exception { - getFormatter(DAY_OF_MONTH, 1, 2, SignStyle.NEVER).formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter(DAY_OF_MONTH, 1, 2, SignStyle.NEVER).formatTo(EMPTY_DTA, buf)); } + @Test public void test_print_append() throws Exception { buf.append("EXISTING"); getFormatter(DAY_OF_MONTH, 1, 2, SignStyle.NEVER).formatTo(LocalDate.of(2012, 1, 3), buf); - assertEquals(buf.toString(), "EXISTING3"); + assertEquals("EXISTING3", buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="Pad") Object[][] provider_pad() { return new Object[][] { {1, 1, -10, null}, @@ -181,72 +186,77 @@ public class TestNumberPrinter extends AbstractTestPrinterParser { }; } - @Test(dataProvider="Pad") + @ParameterizedTest + @MethodSource("provider_pad") public void test_pad_NOT_NEGATIVE(int minPad, int maxPad, long value, String result) throws Exception { try { getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NOT_NEGATIVE).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf); if (result == null || value < 0) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } catch (DateTimeException ex) { if (result == null || value < 0) { - assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); + assertEquals(true, ex.getMessage().contains(DAY_OF_MONTH.toString())); } else { throw ex; } } } - @Test(dataProvider="Pad") + @ParameterizedTest + @MethodSource("provider_pad") public void test_pad_NEVER(int minPad, int maxPad, long value, String result) throws Exception { try { getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NEVER).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } catch (DateTimeException ex) { if (result != null) { throw ex; } - assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); + assertEquals(true, ex.getMessage().contains(DAY_OF_MONTH.toString())); } } - @Test(dataProvider="Pad") + @ParameterizedTest + @MethodSource("provider_pad") public void test_pad_NORMAL(int minPad, int maxPad, long value, String result) throws Exception { try { getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NORMAL).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), (value < 0 ? "-" + result : result)); + assertEquals((value < 0 ? "-" + result : result), buf.toString()); } catch (DateTimeException ex) { if (result != null) { throw ex; } - assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); + assertEquals(true, ex.getMessage().contains(DAY_OF_MONTH.toString())); } } - @Test(dataProvider="Pad") + @ParameterizedTest + @MethodSource("provider_pad") public void test_pad_ALWAYS(int minPad, int maxPad, long value, String result) throws Exception { try { getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.ALWAYS).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), (value < 0 ? "-" + result : "+" + result)); + assertEquals((value < 0 ? "-" + result : "+" + result), buf.toString()); } catch (DateTimeException ex) { if (result != null) { throw ex; } - assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); + assertEquals(true, ex.getMessage().contains(DAY_OF_MONTH.toString())); } } - @Test(dataProvider="Pad") + @ParameterizedTest + @MethodSource("provider_pad") public void test_pad_EXCEEDS_PAD(int minPad, int maxPad, long value, String result) throws Exception { try { getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.EXCEEDS_PAD).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf); @@ -257,26 +267,29 @@ public class TestNumberPrinter extends AbstractTestPrinterParser { if (result.length() > minPad || value < 0) { result = (value < 0 ? "-" + result : "+" + result); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } catch (DateTimeException ex) { if (result != null) { throw ex; } - assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); + assertEquals(true, ex.getMessage().contains(DAY_OF_MONTH.toString())); } } //----------------------------------------------------------------------- + @Test public void test_toString1() throws Exception { - assertEquals(getFormatter(HOUR_OF_DAY, 1, 19, SignStyle.NORMAL).toString(), "Value(HourOfDay)"); + assertEquals("Value(HourOfDay)", getFormatter(HOUR_OF_DAY, 1, 19, SignStyle.NORMAL).toString()); } + @Test public void test_toString2() throws Exception { - assertEquals(getFormatter(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE).toString(), "Value(HourOfDay,2)"); + assertEquals("Value(HourOfDay,2)", getFormatter(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE).toString()); } + @Test public void test_toString3() throws Exception { - assertEquals(getFormatter(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE).toString(), "Value(HourOfDay,1,2,NOT_NEGATIVE)"); + assertEquals("Value(HourOfDay,1,2,NOT_NEGATIVE)", getFormatter(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE).toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestPadPrinterDecorator.java b/test/jdk/java/time/test/java/time/format/TestPadPrinterDecorator.java index adb7677556a..48721e470c3 100644 --- a/test/jdk/java/time/test/java/time/format/TestPadPrinterDecorator.java +++ b/test/jdk/java/time/test/java/time/format/TestPadPrinterDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,79 +59,90 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.LocalDate; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test PadPrinterDecorator. */ -@Test public class TestPadPrinterDecorator extends AbstractTestPrinterParser { //----------------------------------------------------------------------- + @Test public void test_print_emptyCalendrical() throws Exception { builder.padNext(3, '-').appendLiteral('Z'); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "--Z"); + assertEquals("--Z", buf.toString()); } + @Test public void test_print_fullDateTime() throws Exception { builder.padNext(3, '-').appendLiteral('Z'); getFormatter().formatTo(LocalDate.of(2008, 12, 3), buf); - assertEquals(buf.toString(), "--Z"); + assertEquals("--Z", buf.toString()); } + @Test public void test_print_append() throws Exception { buf.append("EXISTING"); builder.padNext(3, '-').appendLiteral('Z'); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "EXISTING--Z"); + assertEquals("EXISTING--Z", buf.toString()); } //----------------------------------------------------------------------- + @Test public void test_print_noPadRequiredSingle() throws Exception { builder.padNext(1, '-').appendLiteral('Z'); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "Z"); + assertEquals("Z", buf.toString()); } + @Test public void test_print_padRequiredSingle() throws Exception { builder.padNext(5, '-').appendLiteral('Z'); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "----Z"); + assertEquals("----Z", buf.toString()); } + @Test public void test_print_noPadRequiredMultiple() throws Exception { builder.padNext(4, '-').appendLiteral("WXYZ"); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "WXYZ"); + assertEquals("WXYZ", buf.toString()); } + @Test public void test_print_padRequiredMultiple() throws Exception { builder.padNext(5, '-').appendLiteral("WXYZ"); getFormatter().formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "-WXYZ"); + assertEquals("-WXYZ", buf.toString()); } - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_overPad() throws Exception { - builder.padNext(3, '-').appendLiteral("WXYZ"); - getFormatter().formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> { + builder.padNext(3, '-').appendLiteral("WXYZ"); + getFormatter().formatTo(EMPTY_DTA, buf); + }); } //----------------------------------------------------------------------- + @Test public void test_toString1() throws Exception { builder.padNext(5, ' ').appendLiteral('Y'); - assertEquals(getFormatter().toString(), "Pad('Y',5)"); + assertEquals("Pad('Y',5)", getFormatter().toString()); } + @Test public void test_toString2() throws Exception { builder.padNext(5, '-').appendLiteral('Y'); - assertEquals(getFormatter().toString(), "Pad('Y',5,'-')"); + assertEquals("Pad('Y',5,'-')", getFormatter().toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestReducedParser.java b/test/jdk/java/time/test/java/time/format/TestReducedParser.java index 3bf806563e8..2d9df7c11da 100644 --- a/test/jdk/java/time/test/java/time/format/TestReducedParser.java +++ b/test/jdk/java/time/test/java/time/format/TestReducedParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -65,9 +65,10 @@ import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; import static java.time.temporal.ChronoUnit.YEARS; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertNotNull; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.text.ParsePosition; import java.time.LocalDate; @@ -85,13 +86,15 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQueries; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test ReducedPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestReducedParser extends AbstractTestPrinterParser { private static final boolean STRICT = true; private static final boolean LENIENT = false; @@ -109,7 +112,6 @@ public class TestReducedParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {YEAR, 2, 2010, "12", -1, IndexOutOfBoundsException.class}, @@ -117,7 +119,8 @@ public class TestReducedParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(TemporalField field, int width, int baseValue, String text, int pos, Class expected) { try { getFormatter0(field, width, baseValue).parseUnresolved(text, new ParsePosition(pos)); @@ -127,10 +130,11 @@ public class TestReducedParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- + @Test public void test_parse_fieldRangeIgnored() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter0(DAY_OF_YEAR, 3, 10).parseUnresolved("456", pos); - assertEquals(pos.getIndex(), 3); + assertEquals(3, pos.getIndex()); assertParsed(parsed, DAY_OF_YEAR, 456L); // parsed dayOfYear=456 } @@ -138,7 +142,6 @@ public class TestReducedParser extends AbstractTestPrinterParser { // Parse data and values that are consistent whether strict or lenient // The data is the ChronoField, width, baseValue, text, startPos, endPos, value //----------------------------------------------------------------------- - @DataProvider(name="ParseAll") Object[][] provider_parseAll() { return new Object[][] { // negative zero @@ -182,30 +185,32 @@ public class TestReducedParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="ParseAll") + @ParameterizedTest + @MethodSource("provider_parseAll") public void test_parseAllStrict(TemporalField field, int width, int baseValue, String input, int pos, int parseLen, Integer parseVal) { ParsePosition ppos = new ParsePosition(pos); setStrict(true); TemporalAccessor parsed = getFormatter0(field, width, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), parseLen, "error case parse position"); - assertEquals(parsed, parseVal, "unexpected parse result"); + assertEquals(parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), parseLen, "parse position"); + assertEquals(parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, parseVal != null ? (long) parseVal : null); } } - @Test(dataProvider="ParseAll") + @ParameterizedTest + @MethodSource("provider_parseAll") public void test_parseAllLenient(TemporalField field, int width, int baseValue, String input, int pos, int parseLen, Integer parseVal) { ParsePosition ppos = new ParsePosition(pos); setStrict(false); TemporalAccessor parsed = getFormatter0(field, width, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), parseLen, "error case parse position"); - assertEquals(parsed, parseVal, "unexpected parse result"); + assertEquals(parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), parseLen, "parse position"); + assertEquals(parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, parseVal != null ? (long) parseVal : null); } } @@ -215,7 +220,6 @@ public class TestReducedParser extends AbstractTestPrinterParser { // The data is the ChronoField, minWidth, maxWidth, baseValue, text, startPos, // Strict Pair(endPos, value), Lenient Pair(endPos, value) //----------------------------------------------------------------------- - @DataProvider(name="ParseLenientSensitive") Object[][] provider_parseLenientSensitive() { return new Object[][] { // few digits supplied @@ -268,32 +272,34 @@ public class TestReducedParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- // Parsing tests for strict mode //----------------------------------------------------------------------- - @Test(dataProvider="ParseLenientSensitive") + @ParameterizedTest + @MethodSource("provider_parseLenientSensitive") public void test_parseStrict(TemporalField field, int minWidth, int maxWidth, int baseValue, String input, int pos, Pair strict, Pair lenient) { ParsePosition ppos = new ParsePosition(pos); setStrict(true); TemporalAccessor parsed = getFormatter0(field, minWidth, maxWidth, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), strict.parseLen, "error case parse position"); - assertEquals(parsed, strict.parseVal, "unexpected parse result"); + assertEquals(strict.parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(strict.parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), strict.parseLen, "parse position"); + assertEquals(strict.parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, strict.parseVal != null ? (long) strict.parseVal : null); } } - @Test(dataProvider="ParseLenientSensitive") + @ParameterizedTest + @MethodSource("provider_parseLenientSensitive") public void test_parseStrict_baseDate(TemporalField field, int minWidth, int maxWidth, int baseValue, String input, int pos, Pair strict, Pair lenient) { ParsePosition ppos = new ParsePosition(pos); setStrict(true); TemporalAccessor parsed = getFormatterBaseDate(field, minWidth, maxWidth, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), strict.parseLen, "error case parse position"); - assertEquals(parsed, strict.parseVal, "unexpected parse result"); + assertEquals(strict.parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(strict.parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), strict.parseLen, "parse position"); + assertEquals(strict.parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, strict.parseVal != null ? (long) strict.parseVal : null); } } @@ -301,42 +307,44 @@ public class TestReducedParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- // Parsing tests for lenient mode //----------------------------------------------------------------------- - @Test(dataProvider="ParseLenientSensitive") + @ParameterizedTest + @MethodSource("provider_parseLenientSensitive") public void test_parseLenient(TemporalField field, int minWidth, int maxWidth, int baseValue, String input, int pos, Pair strict, Pair lenient) { ParsePosition ppos = new ParsePosition(pos); setStrict(false); TemporalAccessor parsed = getFormatter0(field, minWidth, maxWidth, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), lenient.parseLen, "error case parse position"); - assertEquals(parsed, lenient.parseVal, "unexpected parse result"); + assertEquals(lenient.parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(lenient.parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), lenient.parseLen, "parse position"); + assertEquals(lenient.parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, lenient.parseVal != null ? (long) lenient.parseVal : null); } } - @Test(dataProvider="ParseLenientSensitive") + @ParameterizedTest + @MethodSource("provider_parseLenientSensitive") public void test_parseLenient_baseDate(TemporalField field, int minWidth, int maxWidth, int baseValue, String input, int pos, Pair strict, Pair lenient) { ParsePosition ppos = new ParsePosition(pos); setStrict(false); TemporalAccessor parsed = getFormatterBaseDate(field, minWidth, maxWidth, baseValue).parseUnresolved(input, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), lenient.parseLen, "error case parse position"); - assertEquals(parsed, lenient.parseVal, "unexpected parse result"); + assertEquals(lenient.parseLen, ppos.getErrorIndex(), "error case parse position"); + assertEquals(lenient.parseVal, parsed, "unexpected parse result"); } else { - assertEquals(ppos.getIndex(), lenient.parseLen, "parse position"); + assertEquals(lenient.parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR, lenient.parseVal != null ? (long) lenient.parseVal : null); } } private void assertParsed(TemporalAccessor parsed, TemporalField field, Long value) { if (value == null) { - assertEquals(parsed, null, "Parsed Value"); + assertEquals(null, parsed, "Parsed Value"); } else { - assertEquals(parsed.isSupported(field), true, "isSupported: " + field); - assertEquals(parsed.getLong(field), (long) value, "Temporal.getLong: " + field); + assertEquals(true, parsed.isSupported(field), "isSupported: " + field); + assertEquals((long) value, parsed.getLong(field), "Temporal.getLong: " + field); } } @@ -344,7 +352,6 @@ public class TestReducedParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- // Cases and values in adjacent parsing mode //----------------------------------------------------------------------- - @DataProvider(name="ParseAdjacent") Object[][] provider_parseAdjacent() { return new Object[][] { // general @@ -363,7 +370,8 @@ public class TestReducedParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="ParseAdjacent") + @ParameterizedTest + @MethodSource("provider_parseAdjacent") public void test_parseAdjacent(String pattern, String input, boolean strict, int pos, int parseLen, int year, int month, int day) { ParsePosition ppos = new ParsePosition(0); builder = new DateTimeFormatterBuilder(); @@ -374,9 +382,9 @@ public class TestReducedParser extends AbstractTestPrinterParser { TemporalAccessor parsed = dtf.parseUnresolved(input, ppos); assertNotNull(parsed, String.format("parse failed: ppos: %s, formatter: %s%n", ppos.toString(), dtf)); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getErrorIndex(), parseLen, "error case parse position"); + assertEquals(parseLen, ppos.getErrorIndex(), "error case parse position"); } else { - assertEquals(ppos.getIndex(), parseLen, "parse position"); + assertEquals(parseLen, ppos.getIndex(), "parse position"); assertParsed(parsed, YEAR_OF_ERA, Long.valueOf(year)); assertParsed(parsed, MONTH_OF_YEAR, Long.valueOf(month)); assertParsed(parsed, DAY_OF_MONTH, Long.valueOf(day)); @@ -386,7 +394,6 @@ public class TestReducedParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- // Cases and values in reduced value parsing mode //----------------------------------------------------------------------- - @DataProvider(name="ReducedWithChrono") Object[][] provider_reducedWithChrono() { LocalDate baseYear = LocalDate.of(2000, 1, 1); return new Object[][] { @@ -408,7 +415,8 @@ public class TestReducedParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="ReducedWithChrono") + @ParameterizedTest + @MethodSource("provider_reducedWithChrono") public void test_reducedWithChronoYear(ChronoLocalDate date) { Chronology chrono = date.getChronology(); DateTimeFormatter df @@ -421,12 +429,13 @@ public class TestReducedParser extends AbstractTestPrinterParser { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); int actual = parsed.get(YEAR); - assertEquals(actual, expected, + assertEquals(expected, actual, String.format("Wrong date parsed, chrono: %s, input: %s", chrono, input)); } - @Test(dataProvider="ReducedWithChrono") + @ParameterizedTest + @MethodSource("provider_reducedWithChrono") public void test_reducedWithChronoYearOfEra(ChronoLocalDate date) { Chronology chrono = date.getChronology(); DateTimeFormatter df @@ -439,7 +448,7 @@ public class TestReducedParser extends AbstractTestPrinterParser { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); int actual = parsed.get(YEAR_OF_ERA); - assertEquals(actual, expected, + assertEquals(expected, actual, String.format("Wrong date parsed, chrono: %s, input: %s", chrono, input)); @@ -459,10 +468,10 @@ public class TestReducedParser extends AbstractTestPrinterParser { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); - assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); - assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); + assertEquals(input.length(), pos.getIndex(), "Input not parsed completely"); + assertEquals(-1, pos.getErrorIndex(), "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); - assertEquals(actual, expected, + assertEquals(expected, actual, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); @@ -482,10 +491,10 @@ public class TestReducedParser extends AbstractTestPrinterParser { String input = "44 ThaiBuddhist ISO"; ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); - assertEquals(pos.getIndex(), input.length(), "Input not parsed completely: " + pos); - assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); + assertEquals(input.length(), pos.getIndex(), "Input not parsed completely: " + pos); + assertEquals(-1, pos.getErrorIndex(), "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); - assertEquals(actual, expected, + assertEquals(expected, actual, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); diff --git a/test/jdk/java/time/test/java/time/format/TestReducedPrinter.java b/test/jdk/java/time/test/java/time/format/TestReducedPrinter.java index c4b6cf4dc39..94c45662666 100644 --- a/test/jdk/java/time/test/java/time/format/TestReducedPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestReducedPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,8 +60,9 @@ package test.java.time.format; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.time.DateTimeException; import java.time.LocalDate; @@ -70,14 +71,18 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.TemporalField; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.temporal.MockFieldValue; /** * Test ReducedPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestReducedPrinter extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter0(TemporalField field, int width, int baseValue) { @@ -93,20 +98,20 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_emptyCalendrical() throws Exception { - getFormatter0(YEAR, 2, 2010).formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter0(YEAR, 2, 2010).formatTo(EMPTY_DTA, buf)); } //----------------------------------------------------------------------- + @Test public void test_print_append() throws Exception { buf.append("EXISTING"); getFormatter0(YEAR, 2, 2010).formatTo(LocalDate.of(2012, 1, 1), buf); - assertEquals(buf.toString(), "EXISTING12"); + assertEquals("EXISTING12", buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="Pivot") Object[][] provider_pivot() { return new Object[][] { {1, 1, 2010, 2010, "0"}, @@ -175,34 +180,36 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { }; } - @Test(dataProvider="Pivot") + @ParameterizedTest + @MethodSource("provider_pivot") public void test_pivot(int minWidth, int maxWidth, int baseValue, int value, String result) throws Exception { try { getFormatter0(YEAR, minWidth, maxWidth, baseValue).formatTo(new MockFieldValue(YEAR, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } catch (DateTimeException ex) { if (result == null || value < 0) { - assertEquals(ex.getMessage().contains(YEAR.toString()), true); + assertEquals(true, ex.getMessage().contains(YEAR.toString())); } else { throw ex; } } } - @Test(dataProvider="Pivot") + @ParameterizedTest + @MethodSource("provider_pivot") public void test_pivot_baseDate(int minWidth, int maxWidth, int baseValue, int value, String result) throws Exception { try { getFormatterBaseDate(YEAR, minWidth, maxWidth, baseValue).formatTo(new MockFieldValue(YEAR, value), buf); if (result == null) { fail("Expected exception"); } - assertEquals(buf.toString(), result); + assertEquals(result, buf.toString()); } catch (DateTimeException ex) { if (result == null || value < 0) { - assertEquals(ex.getMessage().contains(YEAR.toString()), true); + assertEquals(true, ex.getMessage().contains(YEAR.toString())); } else { throw ex; } @@ -210,49 +217,51 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- + @Test public void test_minguoChrono_fixedWidth() throws Exception { // ISO 2021 is Minguo 110 DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 2, 2021); MinguoDate date = MinguoDate.of(109, 6, 30); - assertEquals(f.format(date), "09"); + assertEquals("09", f.format(date)); date = MinguoDate.of(110, 6, 30); - assertEquals(f.format(date), "10"); + assertEquals("10", f.format(date)); date = MinguoDate.of(199, 6, 30); - assertEquals(f.format(date), "99"); + assertEquals("99", f.format(date)); date = MinguoDate.of(200, 6, 30); - assertEquals(f.format(date), "00"); + assertEquals("00", f.format(date)); date = MinguoDate.of(209, 6, 30); - assertEquals(f.format(date), "09"); + assertEquals("09", f.format(date)); date = MinguoDate.of(210, 6, 30); - assertEquals(f.format(date), "10"); + assertEquals("10", f.format(date)); } + @Test public void test_minguoChrono_extendedWidth() throws Exception { // ISO 2021 is Minguo 110 DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 4, 2021); MinguoDate date = MinguoDate.of(109, 6, 30); - assertEquals(f.format(date), "109"); + assertEquals("109", f.format(date)); date = MinguoDate.of(110, 6, 30); - assertEquals(f.format(date), "10"); + assertEquals("10", f.format(date)); date = MinguoDate.of(199, 6, 30); - assertEquals(f.format(date), "99"); + assertEquals("99", f.format(date)); date = MinguoDate.of(200, 6, 30); - assertEquals(f.format(date), "00"); + assertEquals("00", f.format(date)); date = MinguoDate.of(209, 6, 30); - assertEquals(f.format(date), "09"); + assertEquals("09", f.format(date)); date = MinguoDate.of(210, 6, 30); - assertEquals(f.format(date), "210"); + assertEquals("210", f.format(date)); } //----------------------------------------------------------------------- + @Test public void test_toString() throws Exception { - assertEquals(getFormatter0(YEAR, 2, 2, 2005).toString(), "ReducedValue(Year,2,2,2005)"); + assertEquals("ReducedValue(Year,2,2,2005)", getFormatter0(YEAR, 2, 2, 2005).toString()); } //----------------------------------------------------------------------- // Cases and values in adjacent parsing mode //----------------------------------------------------------------------- - @DataProvider(name="PrintAdjacent") Object[][] provider_printAdjacent() { return new Object[][] { // general @@ -265,7 +274,8 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { }; } - @Test(dataProvider="PrintAdjacent") + @ParameterizedTest + @MethodSource("provider_printAdjacent") public void test_printAdjacent(String pattern, String text, int year, int month, int day) { builder = new DateTimeFormatterBuilder(); builder.appendPattern(pattern); @@ -273,7 +283,7 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { LocalDate ld = LocalDate.of(year, month, day); String actual = dtf.format(ld); - assertEquals(actual, text, "formatter output: " + dtf); + assertEquals(text, actual, "formatter output: " + dtf); } } diff --git a/test/jdk/java/time/test/java/time/format/TestSettingsParser.java b/test/jdk/java/time/test/java/time/format/TestSettingsParser.java index ce7b2d7f187..1f71a37a007 100644 --- a/test/jdk/java/time/test/java/time/format/TestSettingsParser.java +++ b/test/jdk/java/time/test/java/time/format/TestSettingsParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,29 +59,30 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.text.ParsePosition; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test SettingsParser. */ -@Test public class TestSettingsParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- + @Test public void test_print_sensitive() throws Exception { setCaseSensitive(true); getFormatter().formatTo(dta, buf); - assertEquals(buf.toString(), ""); + assertEquals("", buf.toString()); } + @Test public void test_print_strict() throws Exception { setStrict(true); getFormatter().formatTo(dta, buf); - assertEquals(buf.toString(), ""); + assertEquals("", buf.toString()); } /* @@ -92,53 +93,61 @@ public class TestSettingsParser extends AbstractTestPrinterParser { */ //----------------------------------------------------------------------- + @Test public void test_parse_changeStyle_sensitive() throws Exception { setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); getFormatter().parseUnresolved("a", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); } + @Test public void test_parse_changeStyle_insensitive() throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); getFormatter().parseUnresolved("a", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); } + @Test public void test_parse_changeStyle_strict() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); getFormatter().parseUnresolved("a", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); } + @Test public void test_parse_changeStyle_lenient() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); getFormatter().parseUnresolved("a", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); } //----------------------------------------------------------------------- + @Test public void test_toString_sensitive() throws Exception { setCaseSensitive(true); - assertEquals(getFormatter().toString(), "ParseCaseSensitive(true)"); + assertEquals("ParseCaseSensitive(true)", getFormatter().toString()); } + @Test public void test_toString_insensitive() throws Exception { setCaseSensitive(false); - assertEquals(getFormatter().toString(), "ParseCaseSensitive(false)"); + assertEquals("ParseCaseSensitive(false)", getFormatter().toString()); } + @Test public void test_toString_strict() throws Exception { setStrict(true); - assertEquals(getFormatter().toString(), "ParseStrict(true)"); + assertEquals("ParseStrict(true)", getFormatter().toString()); } + @Test public void test_toString_lenient() throws Exception { setStrict(false); - assertEquals(getFormatter().toString(), "ParseStrict(false)"); + assertEquals("ParseStrict(false)", getFormatter().toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestStringLiteralParser.java b/test/jdk/java/time/test/java/time/format/TestStringLiteralParser.java index f8f5147f921..c442621ce34 100644 --- a/test/jdk/java/time/test/java/time/format/TestStringLiteralParser.java +++ b/test/jdk/java/time/test/java/time/format/TestStringLiteralParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,24 +60,25 @@ package test.java.time.format; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.text.ParsePosition; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test StringLiteralPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestStringLiteralParser extends AbstractTestPrinterParser { - @DataProvider(name="success") Object[][] data_success() { return new Object[][] { // match @@ -104,23 +105,23 @@ public class TestStringLiteralParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="success") + @ParameterizedTest + @MethodSource("data_success") public void test_parse_success(String s, boolean caseSensitive, String text, int pos, int expectedPos) { setCaseSensitive(caseSensitive); ParsePosition ppos = new ParsePosition(pos); TemporalAccessor parsed = getFormatter(s).parseUnresolved(text, ppos); if (ppos.getErrorIndex() != -1) { - assertEquals(ppos.getIndex(), expectedPos); + assertEquals(expectedPos, ppos.getIndex()); } else { - assertEquals(ppos.getIndex(), expectedPos); - assertEquals(parsed.isSupported(YEAR), false); - assertEquals(parsed.query(TemporalQueries.chronology()), null); - assertEquals(parsed.query(TemporalQueries.zoneId()), null); + assertEquals(expectedPos, ppos.getIndex()); + assertEquals(false, parsed.isSupported(YEAR)); + assertEquals(null, parsed.query(TemporalQueries.chronology())); + assertEquals(null, parsed.query(TemporalQueries.zoneId())); } } //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {"hello", "hello", -1, IndexOutOfBoundsException.class}, @@ -128,7 +129,8 @@ public class TestStringLiteralParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(String s, String text, int pos, Class expected) { try { ParsePosition ppos = new ParsePosition(pos); diff --git a/test/jdk/java/time/test/java/time/format/TestStringLiteralPrinter.java b/test/jdk/java/time/test/java/time/format/TestStringLiteralPrinter.java index 6733af164a4..ed8717d8bdb 100644 --- a/test/jdk/java/time/test/java/time/format/TestStringLiteralPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestStringLiteralPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,44 +59,47 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test StringLiteralPrinterParser. */ -@Test public class TestStringLiteralPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- + @Test public void test_print_emptyCalendrical() throws Exception { buf.append("EXISTING"); getFormatter("hello").formatTo(EMPTY_DTA, buf); - assertEquals(buf.toString(), "EXISTINGhello"); + assertEquals("EXISTINGhello", buf.toString()); } + @Test public void test_print_dateTime() throws Exception { buf.append("EXISTING"); getFormatter("hello").formatTo(dta, buf); - assertEquals(buf.toString(), "EXISTINGhello"); + assertEquals("EXISTINGhello", buf.toString()); } + @Test public void test_print_emptyAppendable() throws Exception { getFormatter("hello").formatTo(dta, buf); - assertEquals(buf.toString(), "hello"); + assertEquals("hello", buf.toString()); } //----------------------------------------------------------------------- + @Test public void test_toString() throws Exception { - assertEquals(getFormatter("hello").toString(), "'hello'"); + assertEquals("'hello'", getFormatter("hello").toString()); } + @Test public void test_toString_apos() throws Exception { - assertEquals(getFormatter("o'clock").toString(), "'o''clock'"); + assertEquals("'o''clock'", getFormatter("o'clock").toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestTextParser.java b/test/jdk/java/time/test/java/time/format/TestTextParser.java index b6126a6b407..2482cbc5a6e 100644 --- a/test/jdk/java/time/test/java/time/format/TestTextParser.java +++ b/test/jdk/java/time/test/java/time/format/TestTextParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -63,8 +63,9 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.text.ParsePosition; import java.time.DayOfWeek; @@ -77,17 +78,18 @@ import java.time.temporal.TemporalQueries; import java.time.temporal.ChronoField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test TextPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestTextParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {DAY_OF_WEEK, TextStyle.FULL, "Monday", -1, IndexOutOfBoundsException.class}, @@ -95,7 +97,8 @@ public class TestTextParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(TemporalField field, TextStyle style, String text, int pos, Class expected) { try { getFormatter(field, style).parseUnresolved(text, new ParsePosition(pos)); @@ -105,49 +108,53 @@ public class TestTextParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- + @Test public void test_parse_midStr() throws Exception { ParsePosition pos = new ParsePosition(3); - assertEquals(getFormatter(DAY_OF_WEEK, TextStyle.FULL) - .parseUnresolved("XxxMondayXxx", pos) - .getLong(DAY_OF_WEEK), 1L); - assertEquals(pos.getIndex(), 9); + assertEquals(1L, getFormatter(DAY_OF_WEEK, TextStyle.FULL) + .parseUnresolved("XxxMondayXxx", pos) + .getLong(DAY_OF_WEEK)); + assertEquals(9, pos.getIndex()); } + @Test public void test_parse_remainderIgnored() throws Exception { ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(DAY_OF_WEEK, TextStyle.SHORT) - .parseUnresolved("Wednesday", pos) - .getLong(DAY_OF_WEEK), 3L); - assertEquals(pos.getIndex(), 3); + assertEquals(3L, getFormatter(DAY_OF_WEEK, TextStyle.SHORT) + .parseUnresolved("Wednesday", pos) + .getLong(DAY_OF_WEEK)); + assertEquals(3, pos.getIndex()); } //----------------------------------------------------------------------- + @Test public void test_parse_noMatch1() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("Munday", pos); - assertEquals(pos.getErrorIndex(), 0); - assertEquals(parsed, null); + assertEquals(0, pos.getErrorIndex()); + assertEquals(null, parsed); } + @Test public void test_parse_noMatch2() throws Exception { ParsePosition pos = new ParsePosition(3); TemporalAccessor parsed = getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("Monday", pos); - assertEquals(pos.getErrorIndex(), 3); - assertEquals(parsed, null); + assertEquals(3, pos.getErrorIndex()); + assertEquals(null, parsed); } + @Test public void test_parse_noMatch_atEnd() throws Exception { ParsePosition pos = new ParsePosition(6); TemporalAccessor parsed = getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("Monday", pos); - assertEquals(pos.getErrorIndex(), 6); - assertEquals(parsed, null); + assertEquals(6, pos.getErrorIndex()); + assertEquals(null, parsed); } //----------------------------------------------------------------------- - @DataProvider(name="parseText") Object[][] provider_text() { return new Object[][] { {DAY_OF_WEEK, TextStyle.FULL, 1, "Monday"}, @@ -189,7 +196,6 @@ public class TestTextParser extends AbstractTestPrinterParser { }; } - @DataProvider(name="parseNumber") Object[][] provider_number() { return new Object[][] { {DAY_OF_MONTH, TextStyle.FULL, 1, "1"}, @@ -204,7 +210,6 @@ public class TestTextParser extends AbstractTestPrinterParser { }; } - @DataProvider(name="parseDayOfWeekText") Object[][] providerDayOfWeekData() { return new Object[][] { // Locale, pattern, input text, expected DayOfWeek @@ -215,30 +220,34 @@ public class TestTextParser extends AbstractTestPrinterParser { } - @Test(dataProvider="parseText") + @ParameterizedTest + @MethodSource("provider_text") public void test_parseText(TemporalField field, TextStyle style, int value, String input) throws Exception { ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input, pos).getLong(field), (long) value); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) value, getFormatter(field, style).parseUnresolved(input, pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } - @Test(dataProvider="parseNumber") + @ParameterizedTest + @MethodSource("provider_number") public void test_parseNumber(TemporalField field, TextStyle style, int value, String input) throws Exception { ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input, pos).getLong(field), (long) value); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) value, getFormatter(field, style).parseUnresolved(input, pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } - @Test(dataProvider="parseDayOfWeekText") + @ParameterizedTest + @MethodSource("providerDayOfWeekData") public void test_parseDayOfWeekText(Locale locale, String pattern, String input, DayOfWeek expected) { DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); ParsePosition pos = new ParsePosition(0); - assertEquals(DayOfWeek.from(formatter.parse(input, pos)), expected); - assertEquals(pos.getIndex(), input.length()); + assertEquals(expected, DayOfWeek.from(formatter.parse(input, pos))); + assertEquals(input.length(), pos.getIndex()); } //----------------------------------------------------------------------- - @Test(dataProvider="parseText") + @ParameterizedTest + @MethodSource("provider_text") public void test_parse_strict_caseSensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception { if (input.equals(input.toUpperCase(Locale.ROOT))) { // Skip if the given input is all upper case (e.g., "Q1") @@ -247,19 +256,21 @@ public class TestTextParser extends AbstractTestPrinterParser { setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } - @Test(dataProvider="parseText") + @ParameterizedTest + @MethodSource("provider_text") public void test_parse_strict_caseInsensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos).getLong(field), (long) value); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) value, getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } //----------------------------------------------------------------------- - @Test(dataProvider="parseText") + @ParameterizedTest + @MethodSource("provider_text") public void test_parse_strict_caseSensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception { if (input.equals(input.toLowerCase(Locale.ROOT))) { // Skip if the given input is all lower case (e.g., "1st quarter") @@ -268,105 +279,118 @@ public class TestTextParser extends AbstractTestPrinterParser { setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } - @Test(dataProvider="parseText") + @ParameterizedTest + @MethodSource("provider_text") public void test_parse_strict_caseInsensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos).getLong(field), (long) value); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) value, getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- + @Test public void test_parse_full_strict_full_match() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 7); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR)); + assertEquals(7, pos.getIndex()); } + @Test public void test_parse_full_strict_short_noMatch() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("Janua", pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } + @Test public void test_parse_full_strict_number_noMatch() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("1", pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } //----------------------------------------------------------------------- + @Test public void test_parse_short_strict_full_match() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 3); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR)); + assertEquals(3, pos.getIndex()); } + @Test public void test_parse_short_strict_short_match() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 3); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR)); + assertEquals(3, pos.getIndex()); } + @Test public void test_parse_short_strict_number_noMatch() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("1", pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } //----------------------------------------------------------------------- + @Test public void test_parse_full_lenient_full_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January.", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 7); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January.", pos).getLong(MONTH_OF_YEAR)); + assertEquals(7, pos.getIndex()); } + @Test public void test_parse_full_lenient_short_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 3); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR)); + assertEquals(3, pos.getIndex()); } + @Test public void test_parse_full_lenient_number_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 1); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR)); + assertEquals(1, pos.getIndex()); } //----------------------------------------------------------------------- + @Test public void test_parse_short_lenient_full_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 7); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR)); + assertEquals(7, pos.getIndex()); } + @Test public void test_parse_short_lenient_short_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 3); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR)); + assertEquals(3, pos.getIndex()); } + @Test public void test_parse_short_lenient_number_match() throws Exception { setStrict(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR), 1L); - assertEquals(pos.getIndex(), 1); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR)); + assertEquals(1, pos.getIndex()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestTextParserWithLocale.java b/test/jdk/java/time/test/java/time/format/TestTextParserWithLocale.java index 371c5180832..35d458d6b45 100644 --- a/test/jdk/java/time/test/java/time/format/TestTextParserWithLocale.java +++ b/test/jdk/java/time/test/java/time/format/TestTextParserWithLocale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -81,24 +81,26 @@ import java.time.temporal.ChronoField; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test TextPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestTextParserWithLocale extends AbstractTestPrinterParser { static final Locale RUSSIAN = Locale.of("ru"); static final Locale FINNISH = Locale.of("fi"); - @DataProvider(name="parseDayOfWeekText") Object[][] providerDayOfWeekData() { return new Object[][] { // Locale, pattern, input text, expected DayOfWeek @@ -112,17 +114,17 @@ public class TestTextParserWithLocale extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseDayOfWeekText") + @ParameterizedTest + @MethodSource("providerDayOfWeekData") public void test_parseDayOfWeekText(Locale locale, String pattern, String input, DayOfWeek expected) { DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); ParsePosition pos = new ParsePosition(0); - assertEquals(DayOfWeek.from(formatter.parse(input, pos)), expected); - assertEquals(pos.getIndex(), input.length()); + assertEquals(expected, DayOfWeek.from(formatter.parse(input, pos))); + assertEquals(input.length(), pos.getIndex()); } //-------------------------------------------------------------------- // Test data is dependent on localized resources. - @DataProvider(name="parseStandaloneText") Object[][] providerStandaloneText() { // Locale, TemporalField, TextStyle, expected value, input text return new Object[][] { @@ -136,7 +138,6 @@ public class TestTextParserWithLocale extends AbstractTestPrinterParser { } // Test data is dependent on localized resources. - @DataProvider(name="parseLenientText") Object[][] providerLenientText() { // Locale, TemporalField, expected value, input text return new Object[][] { @@ -147,47 +148,49 @@ public class TestTextParserWithLocale extends AbstractTestPrinterParser { }; } - @Test(dataProvider="parseStandaloneText") + @ParameterizedTest + @MethodSource("providerStandaloneText") public void test_parseStandaloneText(Locale locale, TemporalField field, TextStyle style, int expectedValue, String input) { DateTimeFormatter formatter = getFormatter(field, style).withLocale(locale); ParsePosition pos = new ParsePosition(0); - assertEquals(formatter.parseUnresolved(input, pos).getLong(field), (long) expectedValue); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) expectedValue, formatter.parseUnresolved(input, pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } //----------------------------------------------------------------------- + @Test public void test_parse_french_short_strict_full_noMatch() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH) .parseUnresolved("janvier", pos); - assertEquals(pos.getErrorIndex(), 0); + assertEquals(0, pos.getErrorIndex()); } + @Test public void test_parse_french_short_strict_short_match() throws Exception { setStrict(true); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH) - .parseUnresolved("janv.", pos) - .getLong(MONTH_OF_YEAR), - 1L); - assertEquals(pos.getIndex(), 5); + assertEquals(1L, getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH) + .parseUnresolved("janv.", pos) + .getLong(MONTH_OF_YEAR)); + assertEquals(5, pos.getIndex()); } //----------------------------------------------------------------------- - @Test(dataProvider="parseLenientText") + @ParameterizedTest + @MethodSource("providerLenientText") public void test_parseLenientText(Locale locale, TemporalField field, int expectedValue, String input) { setStrict(false); ParsePosition pos = new ParsePosition(0); DateTimeFormatter formatter = getFormatter(field).withLocale(locale); - assertEquals(formatter.parseUnresolved(input, pos).getLong(field), (long) expectedValue); - assertEquals(pos.getIndex(), input.length()); + assertEquals((long) expectedValue, formatter.parseUnresolved(input, pos).getLong(field)); + assertEquals(input.length(), pos.getIndex()); } //----------------------------------------------------------------------- - @DataProvider(name="parseChronoLocalDate") Object[][] provider_chronoLocalDate() { return new Object[][] { { HijrahDate.now() }, @@ -213,14 +216,15 @@ public class TestTextParserWithLocale extends AbstractTestPrinterParser { .appendValue(ChronoField.DAY_OF_MONTH, 1, 2, SignStyle.NEVER) .toFormatter(); - @Test(dataProvider="parseChronoLocalDate") + @ParameterizedTest + @MethodSource("provider_chronoLocalDate") public void test_chronoLocalDate(ChronoLocalDate date) throws Exception { System.out.printf(" %s, [fmt=%s]%n", date, fmt_chrono.format(date)); - assertEquals(date, fmt_chrono.parse(fmt_chrono.format(date), ChronoLocalDate::from)); + assertEquals(fmt_chrono.parse(fmt_chrono.format(date), ChronoLocalDate::from), date); DateTimeFormatter fmt = DateTimeFormatter.ofPattern("[GGG ]yyy-MM-dd") .withChronology(date.getChronology()); System.out.printf(" %s, [fmt=%s]%n", date.toString(), fmt.format(date)); - assertEquals(date, fmt.parse(fmt.format(date), ChronoLocalDate::from)); + assertEquals(fmt.parse(fmt.format(date), ChronoLocalDate::from), date); } } diff --git a/test/jdk/java/time/test/java/time/format/TestTextPrinter.java b/test/jdk/java/time/test/java/time/format/TestTextPrinter.java index 379d6a23bb0..f07c935b025 100644 --- a/test/jdk/java/time/test/java/time/format/TestTextPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestTextPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -64,7 +64,8 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.DayOfWeek; @@ -75,30 +76,34 @@ import java.time.format.TextStyle; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.temporal.MockFieldValue; /** * Test TextPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestTextPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_emptyCalendrical() throws Exception { - getFormatter(DAY_OF_WEEK, TextStyle.FULL).formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter(DAY_OF_WEEK, TextStyle.FULL).formatTo(EMPTY_DTA, buf)); } + @Test public void test_print_append() throws Exception { buf.append("EXISTING"); getFormatter(DAY_OF_WEEK, TextStyle.FULL).formatTo(LocalDate.of(2012, 4, 18), buf); - assertEquals(buf.toString(), "EXISTINGWednesday"); + assertEquals("EXISTINGWednesday", buf.toString()); } //----------------------------------------------------------------------- - @DataProvider(name="print") Object[][] provider_dow() { return new Object[][] { {DAY_OF_WEEK, TextStyle.FULL, 1, "Monday"}, @@ -204,7 +209,6 @@ public class TestTextPrinter extends AbstractTestPrinterParser { }; } - @DataProvider(name="print_DayOfWeekData") Object[][] providerDayOfWeekData() { return new Object[][] { // Locale, pattern, expected text, input DayOfWeek @@ -214,26 +218,30 @@ public class TestTextPrinter extends AbstractTestPrinterParser { }; } - @Test(dataProvider="print") + @ParameterizedTest + @MethodSource("provider_dow") public void test_format(TemporalField field, TextStyle style, int value, String expected) throws Exception { getFormatter(field, style).formatTo(new MockFieldValue(field, value), buf); - assertEquals(buf.toString(), expected); + assertEquals(expected, buf.toString()); } - @Test(dataProvider="print_DayOfWeekData") + @ParameterizedTest + @MethodSource("providerDayOfWeekData") public void test_formatDayOfWeek(Locale locale, String pattern, String expected, DayOfWeek dayOfWeek) { DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); String text = formatter.format(dayOfWeek); - assertEquals(text, expected); + assertEquals(expected, text); } //----------------------------------------------------------------------- + @Test public void test_toString1() throws Exception { - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).toString(), "Text(MonthOfYear)"); + assertEquals("Text(MonthOfYear)", getFormatter(MONTH_OF_YEAR, TextStyle.FULL).toString()); } + @Test public void test_toString2() throws Exception { - assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).toString(), "Text(MonthOfYear,SHORT)"); + assertEquals("Text(MonthOfYear,SHORT)", getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestTextPrinterWithLocale.java b/test/jdk/java/time/test/java/time/format/TestTextPrinterWithLocale.java index abbe4302f99..9b85de777b1 100644 --- a/test/jdk/java/time/test/java/time/format/TestTextPrinterWithLocale.java +++ b/test/jdk/java/time/test/java/time/format/TestTextPrinterWithLocale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -70,7 +70,8 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.DayOfWeek; @@ -81,20 +82,22 @@ import java.time.format.TextStyle; import java.time.temporal.TemporalField; import java.util.Locale; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.temporal.MockFieldValue; /** * Test TextPrinterParserWithLocale. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestTextPrinterWithLocale extends AbstractTestPrinterParser { static final Locale RUSSIAN = Locale.of("ru"); static final Locale FINNISH = Locale.of("fi"); //----------------------------------------------------------------------- - @DataProvider(name="print_DayOfWeekData") Object[][] providerDayOfWeekData() { return new Object[][] { // Locale, pattern, expected text, input DayOfWeek @@ -109,7 +112,6 @@ public class TestTextPrinterWithLocale extends AbstractTestPrinterParser { } // Test data is dependent on localized resources. - @DataProvider(name="print_standalone") Object[][] provider_StandaloneNames() { return new Object[][] { // standalone names for 2013-01-01 (Tue) @@ -121,31 +123,34 @@ public class TestTextPrinterWithLocale extends AbstractTestPrinterParser { }; } - @Test(dataProvider="print_DayOfWeekData") + @ParameterizedTest + @MethodSource("providerDayOfWeekData") public void test_formatDayOfWeek(Locale locale, String pattern, String expected, DayOfWeek dayOfWeek) { DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); String text = formatter.format(dayOfWeek); - assertEquals(text, expected); + assertEquals(expected, text); } - @Test(dataProvider="print_standalone") + @ParameterizedTest + @MethodSource("provider_StandaloneNames") public void test_standaloneNames(Locale locale, TemporalField field, TextStyle style, String expected) { getFormatter(field, style).withLocale(locale).formatTo(LocalDate.of(2013, 1, 1), buf); - assertEquals(buf.toString(), expected); + assertEquals(expected, buf.toString()); } //----------------------------------------------------------------------- + @Test public void test_print_french_long() throws Exception { getFormatter(MONTH_OF_YEAR, TextStyle.FULL).withLocale(Locale.FRENCH).formatTo(LocalDate.of(2012, 1, 1), buf); - assertEquals(buf.toString(), "janvier"); + assertEquals("janvier", buf.toString()); } + @Test public void test_print_french_short() throws Exception { getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH).formatTo(LocalDate.of(2012, 1, 1), buf); - assertEquals(buf.toString(), "janv."); + assertEquals("janv.", buf.toString()); } - @DataProvider(name="print_JapaneseChronology") Object[][] provider_japaneseEra() { return new Object[][] { {ERA, TextStyle.FULL, 2, "Heisei"}, // Note: CLDR doesn't define "wide" Japanese era names. @@ -154,10 +159,11 @@ public class TestTextPrinterWithLocale extends AbstractTestPrinterParser { }; }; - @Test(dataProvider="print_JapaneseChronology") + @ParameterizedTest + @MethodSource("provider_japaneseEra") public void test_formatJapaneseEra(TemporalField field, TextStyle style, int value, String expected) throws Exception { LocalDate ld = LocalDate.of(2013, 1, 31); getFormatter(field, style).withChronology(JapaneseChronology.INSTANCE).formatTo(ld, buf); - assertEquals(buf.toString(), expected); + assertEquals(expected, buf.toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestUTCParse.java b/test/jdk/java/time/test/java/time/format/TestUTCParse.java index 2c41af68281..551f660e368 100644 --- a/test/jdk/java/time/test/java/time/format/TestUTCParse.java +++ b/test/jdk/java/time/test/java/time/format/TestUTCParse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -33,13 +33,14 @@ import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.time.temporal.TemporalQueries; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestUTCParse { - @DataProvider public Object[][] utcZoneIdStrings() { return new Object[][] { {"UTC"}, @@ -48,12 +49,13 @@ public class TestUTCParse { }; } - @Test(dataProvider = "utcZoneIdStrings") + @ParameterizedTest + @MethodSource("utcZoneIdStrings") public void testUTCOffsetRoundTrip(String zidString) { var fmt = new DateTimeFormatterBuilder() .appendZoneText(TextStyle.NARROW) .toFormatter(); var zid = ZoneId.of(zidString); - assertEquals(fmt.parse(zidString).query(TemporalQueries.zoneId()), zid); + assertEquals(zid, fmt.parse(zidString).query(TemporalQueries.zoneId())); } } diff --git a/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java b/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java index 6b99fea5c7c..80460fad007 100644 --- a/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java +++ b/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java @@ -31,7 +31,7 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DayOfWeek; import java.time.ZonedDateTime; @@ -50,15 +50,16 @@ import java.util.Locale; import java.util.TimeZone; import java.util.stream.Stream; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test JavaTime with BCP47 U extensions */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestUnicodeExtension { private static TimeZone defaultTZ; @@ -87,18 +88,17 @@ public class TestUnicodeExtension { private static final String PATTERN = "GGGG MMMM-dd-uu HH:mm:ss zzzz"; - @BeforeTest + @BeforeAll public void beforeTest() { defaultTZ = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone(AMLA)); } - @AfterTest + @AfterAll public void afterTest() { TimeZone.setDefault(defaultTZ); } - @DataProvider(name="localizedBy") Object[][] localizedBy() { return new Object[][] { // Locale, Chrono override, Zone override, Expected Chrono, Expected Zone, @@ -188,7 +188,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="withLocale") Object[][] withLocale() { return new Object[][] { // Locale, Chrono override, Zone override, Expected Chrono, Expected Zone, @@ -277,7 +276,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="firstDayOfWeek") Object[][] firstDayOfWeek () { return new Object[][] { // Locale, Expected DayOfWeek, @@ -304,7 +302,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="minDaysInFirstWeek") Object[][] minDaysInFrstWeek () { return new Object[][] { // Locale, Expected minDay, @@ -316,7 +313,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="ofPattern") Object[][] ofPattern() { return new Object[][] { // Locale, Expected Chrono, Expected Zone, @@ -342,7 +338,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="shortTZID") Object[][] shortTZID() { return new Object[][] { // LDML's short ID, Expected Zone, @@ -817,7 +812,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="getLocalizedDateTimePattern") Object[][] getLocalizedDateTimePattern() { return new Object[][] { // Locale, Expected pattern, @@ -832,7 +826,6 @@ public class TestUnicodeExtension { }; } - @DataProvider(name="getDisplayName") Object[][] getDisplayName() { return new Object[][] { // Locale, field, Expected name, @@ -841,7 +834,8 @@ public class TestUnicodeExtension { }; } - @Test(dataProvider="localizedBy") + @ParameterizedTest + @MethodSource("localizedBy") public void test_localizedBy(Locale locale, Chronology chrono, ZoneId zone, Chronology chronoExpected, ZoneId zoneExpected, String formatExpected) { @@ -855,91 +849,94 @@ public class TestUnicodeExtension { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) .withChronology(chrono).withZone(zone).localizedBy(locale); - assertEquals(dtf.getChronology(), chronoExpected); - assertEquals(dtf.getZone(), zoneExpected); + assertEquals(chronoExpected, dtf.getChronology()); + assertEquals(zoneExpected, dtf.getZone()); String formatted = dtf.format(ZDT); - assertEquals(formatted, formatExpected); - assertEquals(dtf.parse(formatted, ZonedDateTime::from), - zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + assertEquals(formatExpected, formatted); + assertEquals(zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT, dtf.parse(formatted, ZonedDateTime::from)); }); } finally { Locale.setDefault(def); } } - @Test(dataProvider="withLocale") + @ParameterizedTest + @MethodSource("withLocale") public void test_withLocale(Locale locale, Chronology chrono, ZoneId zone, Chronology chronoExpected, ZoneId zoneExpected, String formatExpected) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) .withChronology(chrono).withZone(zone).withLocale(locale); - assertEquals(dtf.getChronology(), chronoExpected); - assertEquals(dtf.getZone(), zoneExpected); + assertEquals(chronoExpected, dtf.getChronology()); + assertEquals(zoneExpected, dtf.getZone()); String formatted = dtf.format(ZDT); - assertEquals(formatted, formatExpected); - assertEquals(dtf.parse(formatted, ZonedDateTime::from), - zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + assertEquals(formatExpected, formatted); + assertEquals(zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT, dtf.parse(formatted, ZonedDateTime::from)); } - @Test(dataProvider="firstDayOfWeek") + @ParameterizedTest + @MethodSource("firstDayOfWeek") public void test_firstDayOfWeek(Locale locale, DayOfWeek dowExpected) { DayOfWeek dow = WeekFields.of(locale).getFirstDayOfWeek(); - assertEquals(dow, dowExpected); + assertEquals(dowExpected, dow); } - @Test(dataProvider="minDaysInFirstWeek") + @ParameterizedTest + @MethodSource("minDaysInFrstWeek") public void test_minDaysInFirstWeek(Locale locale, int minDaysExpected) { int minDays = WeekFields.of(locale).getMinimalDaysInFirstWeek(); - assertEquals(minDays, minDaysExpected); + assertEquals(minDaysExpected, minDays); } - @Test(dataProvider="ofPattern") + @ParameterizedTest + @MethodSource("ofPattern") public void test_ofPattern(Locale locale, Chronology chronoExpected, ZoneId zoneExpected, String formatExpected) { DateTimeFormatter dtf = DateTimeFormatter.ofPattern(PATTERN, locale); - assertEquals(dtf.getChronology(), chronoExpected); - assertEquals(dtf.getZone(), zoneExpected); + assertEquals(chronoExpected, dtf.getChronology()); + assertEquals(zoneExpected, dtf.getZone()); String formatted = dtf.format(ZDT); - assertEquals(formatted, formatExpected); - assertEquals(dtf.parse(formatted, ZonedDateTime::from), - zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + assertEquals(formatExpected, formatted); + assertEquals(zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT, dtf.parse(formatted, ZonedDateTime::from)); } - @Test(dataProvider="ofPattern") + @ParameterizedTest + @MethodSource("ofPattern") public void test_toFormatter(Locale locale, Chronology chronoExpected, ZoneId zoneExpected, String formatExpected) { DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendPattern(PATTERN).toFormatter(locale); - assertEquals(dtf.getChronology(), chronoExpected); - assertEquals(dtf.getZone(), zoneExpected); + assertEquals(chronoExpected, dtf.getChronology()); + assertEquals(zoneExpected, dtf.getZone()); String formatted = dtf.format(ZDT); - assertEquals(formatted, formatExpected); - assertEquals(dtf.parse(formatted, ZonedDateTime::from), - zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + assertEquals(formatExpected, formatted); + assertEquals(zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT, dtf.parse(formatted, ZonedDateTime::from)); } - @Test(dataProvider="shortTZID") + @ParameterizedTest + @MethodSource("shortTZID") public void test_shortTZID(String shortID, String expectedZone) { Locale l = Locale.forLanguageTag("en-US-u-tz-" + shortID); DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) .localizedBy(l); - assertEquals(dtf.getZone(), ZoneId.of(expectedZone)); + assertEquals(ZoneId.of(expectedZone), dtf.getZone()); } - @Test(dataProvider="getLocalizedDateTimePattern") + @ParameterizedTest + @MethodSource("getLocalizedDateTimePattern") public void test_getLocalizedDateTimePattern(Locale l, FormatStyle s, String expectedPattern) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); - assertEquals(dtfb.getLocalizedDateTimePattern(s, s, IsoChronology.INSTANCE, l), - expectedPattern); + assertEquals(expectedPattern, dtfb.getLocalizedDateTimePattern(s, s, IsoChronology.INSTANCE, l)); } - @Test(dataProvider="getDisplayName") + @ParameterizedTest + @MethodSource("getDisplayName") public void test_getDisplayName(Locale l, TemporalField f, String expectedName) { - assertEquals(f.getDisplayName(l), expectedName); + assertEquals(expectedName, f.getDisplayName(l)); } } diff --git a/test/jdk/java/time/test/java/time/format/TestZoneOffsetParser.java b/test/jdk/java/time/test/java/time/format/TestZoneOffsetParser.java index 32425549834..b5807e3cb2d 100644 --- a/test/jdk/java/time/test/java/time/format/TestZoneOffsetParser.java +++ b/test/jdk/java/time/test/java/time/format/TestZoneOffsetParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -60,24 +60,26 @@ package test.java.time.format; import static java.time.temporal.ChronoField.OFFSET_SECONDS; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.text.ParsePosition; import java.time.ZoneOffset; import java.time.temporal.TemporalAccessor; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test ZoneOffsetPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestZoneOffsetParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- - @DataProvider(name="error") Object[][] data_error() { return new Object[][] { {"+HH:MM:ss", "Z", "hello", -1, IndexOutOfBoundsException.class}, @@ -85,7 +87,8 @@ public class TestZoneOffsetParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="error") + @ParameterizedTest + @MethodSource("data_error") public void test_parse_error(String pattern, String noOffsetText, String text, int pos, Class expected) { try { getFormatter(pattern, noOffsetText).parseUnresolved(text, new ParsePosition(pos)); @@ -95,65 +98,72 @@ public class TestZoneOffsetParser extends AbstractTestPrinterParser { } //----------------------------------------------------------------------- + @Test public void test_parse_exactMatch_UTC() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("Z", pos); - assertEquals(pos.getIndex(), 1); + assertEquals(1, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_startStringMatch_UTC() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("ZOTHER", pos); - assertEquals(pos.getIndex(), 1); + assertEquals(1, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_midStringMatch_UTC() throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("OTHERZOTHER", pos); - assertEquals(pos.getIndex(), 6); + assertEquals(6, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_endStringMatch_UTC() throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("OTHERZ", pos); - assertEquals(pos.getIndex(), 6); + assertEquals(6, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } //----------------------------------------------------------------------- + @Test public void test_parse_exactMatch_UTC_EmptyUTC() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "").parseUnresolved("", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_startStringMatch_UTC_EmptyUTC() throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "").parseUnresolved("OTHER", pos); - assertEquals(pos.getIndex(), 0); + assertEquals(0, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_midStringMatch_UTC_EmptyUTC() throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "").parseUnresolved("OTHEROTHER", pos); - assertEquals(pos.getIndex(), 5); + assertEquals(5, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_endStringMatch_UTC_EmptyUTC() throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "").parseUnresolved("OTHER", pos); - assertEquals(pos.getIndex(), 5); + assertEquals(5, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } //----------------------------------------------------------------------- - @DataProvider(name="offsets") Object[][] provider_offsets() { return new Object[][] { {"+HH", "+00", ZoneOffset.UTC}, @@ -228,72 +238,79 @@ public class TestZoneOffsetParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_exactMatch(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved(parse, pos); - assertEquals(pos.getIndex(), parse.length()); + assertEquals(parse.length(), pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_startStringMatch(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved(parse + ":OTHER", pos); - assertEquals(pos.getIndex(), parse.length()); + assertEquals(parse.length(), pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_midStringMatch(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved("OTHER" + parse + ":OTHER", pos); - assertEquals(pos.getIndex(), parse.length() + 5); + assertEquals(parse.length() + 5, pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_endStringMatch(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved("OTHER" + parse, pos); - assertEquals(pos.getIndex(), parse.length() + 5); + assertEquals(parse.length() + 5, pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_exactMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved(parse, pos); - assertEquals(pos.getIndex(), parse.length()); + assertEquals(parse.length(), pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_startStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved(parse + ":OTHER", pos); - assertEquals(pos.getIndex(), parse.length()); + assertEquals(parse.length(), pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_midStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse + ":OTHER", pos); - assertEquals(pos.getIndex(), parse.length() + 5); + assertEquals(parse.length() + 5, pos.getIndex()); assertParsed(parsed, expected); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_parse_endStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception { ParsePosition pos = new ParsePosition(5); TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse, pos); - assertEquals(pos.getIndex(), parse.length() + 5); + assertEquals(parse.length() + 5, pos.getIndex()); assertParsed(parsed, expected); } //----------------------------------------------------------------------- - @DataProvider(name="bigOffsets") Object[][] provider_bigOffsets() { return new Object[][] { {"+HH", "+19", 19 * 3600}, @@ -319,16 +336,16 @@ public class TestZoneOffsetParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="bigOffsets") + @ParameterizedTest + @MethodSource("provider_bigOffsets") public void test_parse_bigOffsets(String pattern, String parse, long offsetSecs) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved(parse, pos); - assertEquals(pos.getIndex(), parse.length()); - assertEquals(parsed.getLong(OFFSET_SECONDS), offsetSecs); + assertEquals(parse.length(), pos.getIndex()); + assertEquals(offsetSecs, parsed.getLong(OFFSET_SECONDS)); } //----------------------------------------------------------------------- - @DataProvider(name="badOffsets") Object[][] provider_badOffsets() { return new Object[][] { {"+HH", "+1", 0}, @@ -390,55 +407,60 @@ public class TestZoneOffsetParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="badOffsets") + @ParameterizedTest + @MethodSource("provider_badOffsets") public void test_parse_invalid(String pattern, String parse, int expectedPosition) throws Exception { ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved(parse, pos); - assertEquals(pos.getErrorIndex(), expectedPosition); - assertEquals(parsed, null); + assertEquals(expectedPosition, pos.getErrorIndex()); + assertEquals(null, parsed); } //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- + @Test public void test_parse_caseSensitiveUTC_matchedCase() throws Exception { setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("Z", pos); - assertEquals(pos.getIndex(), 1); + assertEquals(1, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_caseSensitiveUTC_unmatchedCase() throws Exception { setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("z", pos); - assertEquals(pos.getErrorIndex(), 0); - assertEquals(parsed, null); + assertEquals(0, pos.getErrorIndex()); + assertEquals(null, parsed); } + @Test public void test_parse_caseInsensitiveUTC_matchedCase() throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("Z", pos); - assertEquals(pos.getIndex(), 1); + assertEquals(1, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } + @Test public void test_parse_caseInsensitiveUTC_unmatchedCase() throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("z", pos); - assertEquals(pos.getIndex(), 1); + assertEquals(1, pos.getIndex()); assertParsed(parsed, ZoneOffset.UTC); } private void assertParsed(TemporalAccessor parsed, ZoneOffset expectedOffset) { if (expectedOffset == null) { - assertEquals(parsed, null); + assertEquals(null, parsed); } else { - assertEquals(parsed.isSupported(OFFSET_SECONDS), true); - assertEquals(parsed.getLong(OFFSET_SECONDS), (long) expectedOffset.getTotalSeconds()); + assertEquals(true, parsed.isSupported(OFFSET_SECONDS)); + assertEquals((long) expectedOffset.getTotalSeconds(), parsed.getLong(OFFSET_SECONDS)); } } diff --git a/test/jdk/java/time/test/java/time/format/TestZoneOffsetPrinter.java b/test/jdk/java/time/test/java/time/format/TestZoneOffsetPrinter.java index 4e1b7a402c7..12d54d12200 100644 --- a/test/jdk/java/time/test/java/time/format/TestZoneOffsetPrinter.java +++ b/test/jdk/java/time/test/java/time/format/TestZoneOffsetPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,24 +59,26 @@ */ package test.java.time.format; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.DateTimeException; import java.time.ZoneOffset; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test ZoneOffsetPrinterParser. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestZoneOffsetPrinter extends AbstractTestPrinterParser { private static final ZoneOffset OFFSET_0130 = ZoneOffset.of("+01:30"); //----------------------------------------------------------------------- - @DataProvider(name="offsets") Object[][] provider_offsets() { return new Object[][] { {"+HH", "NO-OFFSET", ZoneOffset.UTC}, @@ -147,27 +149,30 @@ public class TestZoneOffsetPrinter extends AbstractTestPrinterParser { }; } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_format(String pattern, String expected, ZoneOffset offset) throws Exception { buf.append("EXISTING"); getFormatter(pattern, "NO-OFFSET").formatTo(offset, buf); - assertEquals(buf.toString(), "EXISTING" + expected); + assertEquals("EXISTING" + expected, buf.toString()); } - @Test(dataProvider="offsets") + @ParameterizedTest + @MethodSource("provider_offsets") public void test_toString(String pattern, String expected, ZoneOffset offset) throws Exception { - assertEquals(getFormatter(pattern, "NO-OFFSET").toString(), "Offset(" + pattern + ",'NO-OFFSET')"); + assertEquals("Offset(" + pattern + ",'NO-OFFSET')", getFormatter(pattern, "NO-OFFSET").toString()); } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class) + @Test public void test_print_emptyCalendrical() throws Exception { - getFormatter("+HH:MM:ss", "Z").formatTo(EMPTY_DTA, buf); + Assertions.assertThrows(DateTimeException.class, () -> getFormatter("+HH:MM:ss", "Z").formatTo(EMPTY_DTA, buf)); } + @Test public void test_print_emptyAppendable() throws Exception { getFormatter("+HH:MM:ss", "Z").formatTo(OFFSET_0130, buf); - assertEquals(buf.toString(), "+01:30"); + assertEquals("+01:30", buf.toString()); } } diff --git a/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java b/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java index 20861f151e0..abe3cd6b154 100644 --- a/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java +++ b/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java @@ -23,8 +23,8 @@ package test.java.time.format; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.text.DateFormatSymbols; import java.time.ZoneId; @@ -46,8 +46,10 @@ import java.util.Set; import java.util.TimeZone; import jdk.test.lib.RandomFactory; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* * @test @@ -59,7 +61,7 @@ import org.testng.annotations.Test; /** * Test ZoneTextPrinterParser */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { private static final Locale[] SAMPLE_LOCALES = { @@ -73,6 +75,7 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { .withDecimalStyle(DecimalStyle.of(locale)); } + @Test public void test_printText() { Random r = RandomFactory.getRandom(); int N = 8; @@ -123,9 +126,10 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { System.out.printf("[%-5s, %5s] :[%s]%n", locale.toString(), style.toString(),result); System.out.printf(" %5s, %5s :[%s] %s%n", "", "", expected, zone); } - assertEquals(result, expected); + assertEquals(expected, result); } + @Test public void test_ParseText() { Set zids = ZoneRulesProvider.getAvailableZoneIds(); for (Locale locale : SAMPLE_LOCALES) { @@ -153,7 +157,6 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { private static Set none = new HashSet<>(); - @DataProvider(name="preferredZones") Object[][] data_preferredZones() { return new Object[][] { {"America/New_York", "Eastern Standard Time", none, Locale.ENGLISH, TextStyle.FULL}, @@ -178,7 +181,8 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="preferredZones") + @ParameterizedTest + @MethodSource("data_preferredZones") public void test_ParseText(String expected, String text, Set preferred, Locale locale, TextStyle style) { DateTimeFormatter fmt = new DateTimeFormatterBuilder().appendZoneText(style, preferred) .toFormatter(locale) @@ -191,7 +195,7 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { style == TextStyle.FULL ? " full" :"short", text, ret, expected); - assertEquals(ret, expected); + assertEquals(expected, ret); } @@ -246,7 +250,6 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { .withDecimalStyle(DecimalStyle.of(locale)); } - @DataProvider(name="roundTripAtOverlap") Object[][] data_roundTripAtOverlap() { return new Object[][] { {"yyyy-MM-dd HH:mm:ss.SSS z", "2021-10-31 02:30:00.000 CET"}, @@ -265,10 +268,11 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { }; } - @Test(dataProvider="roundTripAtOverlap") + @ParameterizedTest + @MethodSource("data_roundTripAtOverlap") public void test_roundTripAtOverlap(String pattern, String input) { var dtf = DateTimeFormatter.ofPattern(pattern, Locale.US); - assertEquals(dtf.format(ZonedDateTime.parse(input, dtf)), input); + assertEquals(input, dtf.format(ZonedDateTime.parse(input, dtf))); var lc = input.toLowerCase(Locale.ROOT); try { ZonedDateTime.parse(lc, dtf); @@ -276,7 +280,7 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { } catch (DateTimeParseException ignore) {} dtf = new DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern(pattern).toFormatter(Locale.US); - assertEquals(dtf.format(ZonedDateTime.parse(input, dtf)), input); - assertEquals(dtf.format(ZonedDateTime.parse(lc, dtf)), input); + assertEquals(input, dtf.format(ZonedDateTime.parse(input, dtf))); + assertEquals(input, dtf.format(ZonedDateTime.parse(lc, dtf))); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestChronoField.java b/test/jdk/java/time/test/java/time/temporal/TestChronoField.java index a353a6b247b..716f586ff79 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestChronoField.java +++ b/test/jdk/java/time/test/java/time/temporal/TestChronoField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -54,8 +54,7 @@ */ package test.java.time.temporal; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.temporal.ChronoField; import java.time.temporal.IsoFields; @@ -64,18 +63,18 @@ import java.time.temporal.WeekFields; import java.util.HashMap; import java.util.Locale; import java.util.Map; -import java.util.ResourceBundle; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestChronoField { Map fieldMap; - @BeforeClass + @BeforeAll public void initClass() { fieldMap = new HashMap<>(); fieldMap.put(ChronoField.ERA, "era"); @@ -91,7 +90,6 @@ public class TestChronoField { fieldMap.put(ChronoField.OFFSET_SECONDS, "zone"); } - @DataProvider(name = "localeList") Locale[] data_localeList() { return new Locale[] { Locale.US, @@ -101,7 +99,6 @@ public class TestChronoField { }; } //----------------------------------------------------------------------- - @DataProvider(name = "localeDisplayNames") Object[][] data_localeDisplayNames() { return new Object[][] { {ChronoField.ERA}, @@ -121,12 +118,14 @@ public class TestChronoField { public void test_IsoFields_week_based_year() { Locale locale = Locale.US; String name = IsoFields.WEEK_OF_WEEK_BASED_YEAR.getDisplayName(locale); - assertEquals(name, "week"); + assertEquals("week", name); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_nullIsoFields_week_based_year() { - String name = IsoFields.WEEK_OF_WEEK_BASED_YEAR.getDisplayName((Locale)null); + Assertions.assertThrows(NullPointerException.class, () -> { + String name = IsoFields.WEEK_OF_WEEK_BASED_YEAR.getDisplayName((Locale)null); + }); } @Test @@ -134,24 +133,28 @@ public class TestChronoField { Locale locale = Locale.US; TemporalField weekOfYearField = WeekFields.SUNDAY_START.weekOfYear(); String name = weekOfYearField.getDisplayName(locale); - assertEquals(name, "week"); + assertEquals("week", name); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_nullWeekFields_week_based_year() { - TemporalField weekOfYearField = WeekFields.SUNDAY_START.weekOfYear(); - String name = weekOfYearField.getDisplayName((Locale)null); + Assertions.assertThrows(NullPointerException.class, () -> { + TemporalField weekOfYearField = WeekFields.SUNDAY_START.weekOfYear(); + String name = weekOfYearField.getDisplayName((Locale)null); + }); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_nullLocaleChronoFieldDisplayName() { - ChronoField.YEAR.getDisplayName((Locale)null); + Assertions.assertThrows(NullPointerException.class, () -> ChronoField.YEAR.getDisplayName((Locale)null)); } - @Test(expectedExceptions=NullPointerException.class) + @Test public void test_nullLocaleTemporalFieldDisplayName() { - // Test the default method in TemporalField using the - // IsoFields.DAY_OF_QUARTER which does not override getDisplayName - IsoFields.DAY_OF_QUARTER.getDisplayName((Locale)null); + Assertions.assertThrows(NullPointerException.class, () -> { + // Test the default method in TemporalField using the + // IsoFields.DAY_OF_QUARTER which does not override getDisplayName + IsoFields.DAY_OF_QUARTER.getDisplayName((Locale)null); + }); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestChronoUnit.java b/test/jdk/java/time/test/java/time/temporal/TestChronoUnit.java index 95e5f6503ed..11ebcfd13bd 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestChronoUnit.java +++ b/test/jdk/java/time/test/java/time/temporal/TestChronoUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -65,23 +65,24 @@ import static java.time.temporal.ChronoUnit.DAYS; import static java.time.temporal.ChronoUnit.MONTHS; import static java.time.temporal.ChronoUnit.WEEKS; import static java.time.temporal.ChronoUnit.YEARS; -import static org.testng.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.LocalDate; import java.time.Month; import java.time.ZoneOffset; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestChronoUnit { //----------------------------------------------------------------------- - @DataProvider(name = "yearsBetween") Object[][] data_yearsBetween() { return new Object[][] { {date(1939, SEPTEMBER, 2), date(1939, SEPTEMBER, 1), 0}, @@ -102,47 +103,52 @@ public class TestChronoUnit { }; } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetween(LocalDate start, LocalDate end, long expected) { - assertEquals(YEARS.between(start, end), expected); + assertEquals(expected, YEARS.between(start, end)); } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetweenReversed(LocalDate start, LocalDate end, long expected) { - assertEquals(YEARS.between(end, start), -expected); + assertEquals(-expected, YEARS.between(end, start)); } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { - assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 30)), expected); + assertEquals(expected, YEARS.between(start.atTime(12, 30), end.atTime(12, 30))); } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { if (expected >= 0) { - assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + assertEquals(expected, YEARS.between(start.atTime(12, 30), end.atTime(12, 31))); } else { - assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + assertEquals(expected, YEARS.between(start.atTime(12, 30), end.atTime(12, 29))); } } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { - assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } - @Test(dataProvider = "yearsBetween") + @ParameterizedTest + @MethodSource("data_yearsBetween") public void test_yearsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 if (expected >= 0) { - assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + assertEquals(expected, YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1)))); } else { - assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } } //----------------------------------------------------------------------- - @DataProvider(name = "monthsBetween") Object[][] data_monthsBetween() { return new Object[][] { {date(2012, JULY, 2), date(2012, JULY, 1), 0}, @@ -175,47 +181,52 @@ public class TestChronoUnit { }; } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetween(LocalDate start, LocalDate end, long expected) { - assertEquals(MONTHS.between(start, end), expected); + assertEquals(expected, MONTHS.between(start, end)); } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetweenReversed(LocalDate start, LocalDate end, long expected) { - assertEquals(MONTHS.between(end, start), -expected); + assertEquals(-expected, MONTHS.between(end, start)); } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { - assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 30)), expected); + assertEquals(expected, MONTHS.between(start.atTime(12, 30), end.atTime(12, 30))); } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { if (expected >= 0) { - assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + assertEquals(expected, MONTHS.between(start.atTime(12, 30), end.atTime(12, 31))); } else { - assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + assertEquals(expected, MONTHS.between(start.atTime(12, 30), end.atTime(12, 29))); } } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { - assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } - @Test(dataProvider = "monthsBetween") + @ParameterizedTest + @MethodSource("data_monthsBetween") public void test_monthsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 if (expected >= 0) { - assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + assertEquals(expected, MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1)))); } else { - assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } } //----------------------------------------------------------------------- - @DataProvider(name = "weeksBetween") Object[][] data_weeksBetween() { return new Object[][] { {date(2012, JULY, 2), date(2012, JUNE, 25), -1}, @@ -242,18 +253,19 @@ public class TestChronoUnit { }; } - @Test(dataProvider = "weeksBetween") + @ParameterizedTest + @MethodSource("data_weeksBetween") public void test_weeksBetween(LocalDate start, LocalDate end, long expected) { - assertEquals(WEEKS.between(start, end), expected); + assertEquals(expected, WEEKS.between(start, end)); } - @Test(dataProvider = "weeksBetween") + @ParameterizedTest + @MethodSource("data_weeksBetween") public void test_weeksBetweenReversed(LocalDate start, LocalDate end, long expected) { - assertEquals(WEEKS.between(end, start), -expected); + assertEquals(-expected, WEEKS.between(end, start)); } //----------------------------------------------------------------------- - @DataProvider(name = "daysBetween") Object[][] data_daysBetween() { return new Object[][] { {date(2012, JULY, 2), date(2012, JULY, 1), -1}, @@ -285,42 +297,48 @@ public class TestChronoUnit { }; } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetween(LocalDate start, LocalDate end, long expected) { - assertEquals(DAYS.between(start, end), expected); + assertEquals(expected, DAYS.between(start, end)); } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetweenReversed(LocalDate start, LocalDate end, long expected) { - assertEquals(DAYS.between(end, start), -expected); + assertEquals(-expected, DAYS.between(end, start)); } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { - assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 30)), expected); + assertEquals(expected, DAYS.between(start.atTime(12, 30), end.atTime(12, 30))); } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { if (expected >= 0) { - assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + assertEquals(expected, DAYS.between(start.atTime(12, 30), end.atTime(12, 31))); } else { - assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + assertEquals(expected, DAYS.between(start.atTime(12, 30), end.atTime(12, 29))); } } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { - assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } - @Test(dataProvider = "daysBetween") + @ParameterizedTest + @MethodSource("data_daysBetween") public void test_daysBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 if (expected >= 0) { - assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + assertEquals(expected, DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1)))); } else { - assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + assertEquals(expected, DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2)))); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java b/test/jdk/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java index ffa9fc3c342..8a81da27458 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java +++ b/test/jdk/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -70,8 +70,9 @@ import static java.time.temporal.ChronoField.EPOCH_DAY; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.time.DateTimeException; import java.time.LocalDate; @@ -80,15 +81,16 @@ import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test. */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeBuilderCombinations { - @DataProvider(name = "combine") Object[][] data_combine() { return new Object[][] { {YEAR, 2012, MONTH_OF_YEAR, 6, DAY_OF_MONTH, 3, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, @@ -101,7 +103,8 @@ public class TestDateTimeBuilderCombinations { }; } - @Test(dataProvider = "combine") + @ParameterizedTest + @MethodSource("data_combine") public void test_derive(final TemporalField field1, final Number value1, final TemporalField field2, final Number value2, final TemporalField field3, final Number value3, @@ -149,7 +152,7 @@ public class TestDateTimeBuilderCombinations { TemporalAccessor parsed = dtfb.toFormatter().parse(str); if (query == LocalDate.class) { if (expectedVal != null) { - assertEquals(parsed.query(LocalDate::from), expectedVal); + assertEquals(expectedVal, parsed.query(LocalDate::from)); } else { try { parsed.query(LocalDate::from); @@ -164,7 +167,6 @@ public class TestDateTimeBuilderCombinations { } //----------------------------------------------------------------------- - @DataProvider(name = "normalized") Object[][] data_normalized() { return new Object[][] { {YEAR, 2127, YEAR, 2127}, @@ -182,7 +184,8 @@ public class TestDateTimeBuilderCombinations { }; } - @Test(dataProvider = "normalized") + @ParameterizedTest + @MethodSource("data_normalized") public void test_normalized(final TemporalField field1, final Number value1, TemporalField expectedField, Number expectedVal) { // mock for testing that does not fully comply with TemporalAccessor contract TemporalAccessor test = new TemporalAccessor() { @@ -202,9 +205,9 @@ public class TestDateTimeBuilderCombinations { String str = value1.toString(); TemporalAccessor temporal = f.parse(str); if (expectedVal != null) { - assertEquals(temporal.getLong(expectedField), expectedVal.longValue()); + assertEquals(expectedVal.longValue(), temporal.getLong(expectedField)); } else { - assertEquals(temporal.isSupported(expectedField), false); + assertEquals(false, temporal.isSupported(expectedField)); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestDateTimeValueRange.java b/test/jdk/java/time/test/java/time/temporal/TestDateTimeValueRange.java index 570e6634a8a..e3e2f1758b9 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestDateTimeValueRange.java +++ b/test/jdk/java/time/test/java/time/temporal/TestDateTimeValueRange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,7 +59,7 @@ */ package test.java.time.temporal; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -69,15 +69,19 @@ import java.time.DateTimeException; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import test.java.time.AbstractTest; /** * Test. * @bug 8239520 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestDateTimeValueRange extends AbstractTest { //----------------------------------------------------------------------- @@ -91,63 +95,65 @@ public class TestDateTimeValueRange extends AbstractTest { //----------------------------------------------------------------------- // of(long,long) //----------------------------------------------------------------------- + @Test public void test_of_longlong() { ValueRange test = ValueRange.of(1, 12); - assertEquals(test.getMinimum(), 1); - assertEquals(test.getLargestMinimum(), 1); - assertEquals(test.getSmallestMaximum(), 12); - assertEquals(test.getMaximum(), 12); - assertEquals(test.isFixed(), true); - assertEquals(test.isIntValue(), true); + assertEquals(1, test.getMinimum()); + assertEquals(1, test.getLargestMinimum()); + assertEquals(12, test.getSmallestMaximum()); + assertEquals(12, test.getMaximum()); + assertEquals(true, test.isFixed()); + assertEquals(true, test.isIntValue()); } + @Test public void test_of_longlong_big() { ValueRange test = ValueRange.of(1, 123456789012345L); - assertEquals(test.getMinimum(), 1); - assertEquals(test.getLargestMinimum(), 1); - assertEquals(test.getSmallestMaximum(), 123456789012345L); - assertEquals(test.getMaximum(), 123456789012345L); - assertEquals(test.isFixed(), true); - assertEquals(test.isIntValue(), false); + assertEquals(1, test.getMinimum()); + assertEquals(1, test.getLargestMinimum()); + assertEquals(123456789012345L, test.getSmallestMaximum()); + assertEquals(123456789012345L, test.getMaximum()); + assertEquals(true, test.isFixed()); + assertEquals(false, test.isIntValue()); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test_of_longlong_minGtMax() { - ValueRange.of(12, 1); + Assertions.assertThrows(IllegalArgumentException.class, () -> ValueRange.of(12, 1)); } //----------------------------------------------------------------------- // of(long,long,long) //----------------------------------------------------------------------- + @Test public void test_of_longlonglong() { ValueRange test = ValueRange.of(1, 28, 31); - assertEquals(test.getMinimum(), 1); - assertEquals(test.getLargestMinimum(), 1); - assertEquals(test.getSmallestMaximum(), 28); - assertEquals(test.getMaximum(), 31); - assertEquals(test.isFixed(), false); - assertEquals(test.isIntValue(), true); + assertEquals(1, test.getMinimum()); + assertEquals(1, test.getLargestMinimum()); + assertEquals(28, test.getSmallestMaximum()); + assertEquals(31, test.getMaximum()); + assertEquals(false, test.isFixed()); + assertEquals(true, test.isIntValue()); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test_of_longlonglong_minGtMax() { - ValueRange.of(12, 1, 2); + Assertions.assertThrows(IllegalArgumentException.class, () -> ValueRange.of(12, 1, 2)); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test_of_longlonglong_smallestmaxminGtMax() { - ValueRange.of(1, 31, 28); + Assertions.assertThrows(IllegalArgumentException.class, () -> ValueRange.of(1, 31, 28)); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test_of_longlonglong_minGtSmallestMax() { - ValueRange.of(5, 2, 10); + Assertions.assertThrows(IllegalArgumentException.class, () -> ValueRange.of(5, 2, 10)); } //----------------------------------------------------------------------- // of(long,long,long,long) //----------------------------------------------------------------------- - @DataProvider(name="valid") Object[][] data_valid() { return new Object[][] { {1, 1, 1, 1}, @@ -162,18 +168,18 @@ public class TestDateTimeValueRange extends AbstractTest { }; } - @Test(dataProvider="valid") + @ParameterizedTest + @MethodSource("data_valid") public void test_of_longlonglonglong(long sMin, long lMin, long sMax, long lMax) { ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); - assertEquals(test.getMinimum(), sMin); - assertEquals(test.getLargestMinimum(), lMin); - assertEquals(test.getSmallestMaximum(), sMax); - assertEquals(test.getMaximum(), lMax); - assertEquals(test.isFixed(), sMin == lMin && sMax == lMax); - assertEquals(test.isIntValue(), true); + assertEquals(sMin, test.getMinimum()); + assertEquals(lMin, test.getLargestMinimum()); + assertEquals(sMax, test.getSmallestMaximum()); + assertEquals(lMax, test.getMaximum()); + assertEquals(sMin == lMin && sMax == lMax, test.isFixed()); + assertEquals(true, test.isIntValue()); } - @DataProvider(name="invalid") Object[][] data_invalid() { return new Object[][] { {1, 2, 31, 28}, @@ -192,118 +198,138 @@ public class TestDateTimeValueRange extends AbstractTest { }; } - @Test(dataProvider="invalid", expectedExceptions=IllegalArgumentException.class) + @ParameterizedTest + @MethodSource("data_invalid") public void test_of_longlonglonglong_invalid(long sMin, long lMin, long sMax, long lMax) { - ValueRange.of(sMin, lMin, sMax, lMax); + Assertions.assertThrows(IllegalArgumentException.class, () -> ValueRange.of(sMin, lMin, sMax, lMax)); } //----------------------------------------------------------------------- // isValidValue(long) //----------------------------------------------------------------------- + @Test public void test_isValidValue_long() { ValueRange test = ValueRange.of(1, 28, 31); - assertEquals(test.isValidValue(0), false); - assertEquals(test.isValidValue(1), true); - assertEquals(test.isValidValue(2), true); - assertEquals(test.isValidValue(30), true); - assertEquals(test.isValidValue(31), true); - assertEquals(test.isValidValue(32), false); + assertEquals(false, test.isValidValue(0)); + assertEquals(true, test.isValidValue(1)); + assertEquals(true, test.isValidValue(2)); + assertEquals(true, test.isValidValue(30)); + assertEquals(true, test.isValidValue(31)); + assertEquals(false, test.isValidValue(32)); } //----------------------------------------------------------------------- // isValidIntValue(long) //----------------------------------------------------------------------- + @Test public void test_isValidValue_long_int() { ValueRange test = ValueRange.of(1, 28, 31); - assertEquals(test.isValidValue(0), false); - assertEquals(test.isValidValue(1), true); - assertEquals(test.isValidValue(31), true); - assertEquals(test.isValidValue(32), false); + assertEquals(false, test.isValidValue(0)); + assertEquals(true, test.isValidValue(1)); + assertEquals(true, test.isValidValue(31)); + assertEquals(false, test.isValidValue(32)); } + @Test public void test_isValidValue_long_long() { ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); - assertEquals(test.isValidIntValue(0), false); - assertEquals(test.isValidIntValue(1), false); - assertEquals(test.isValidIntValue(31), false); - assertEquals(test.isValidIntValue(32), false); + assertEquals(false, test.isValidIntValue(0)); + assertEquals(false, test.isValidIntValue(1)); + assertEquals(false, test.isValidIntValue(31)); + assertEquals(false, test.isValidIntValue(32)); } //----------------------------------------------------------------------- // checkValidValue //----------------------------------------------------------------------- - @Test(dataProvider="valid") + @ParameterizedTest + @MethodSource("data_valid") public void test_of_checkValidValue(long sMin, long lMin, long sMax, long lMax) { ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); - assertEquals(test.checkValidIntValue(sMin, null), sMin); - assertEquals(test.checkValidIntValue(lMin, null), lMin); - assertEquals(test.checkValidIntValue(sMax, null), sMax); - assertEquals(test.checkValidIntValue(lMax, null), lMax); + assertEquals(sMin, test.checkValidIntValue(sMin, null)); + assertEquals(lMin, test.checkValidIntValue(lMin, null)); + assertEquals(sMax, test.checkValidIntValue(sMax, null)); + assertEquals(lMax, test.checkValidIntValue(lMax, null)); } - @Test(dataProvider="valid", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_valid") public void test_of_checkValidValueMinException(long sMin, long lMin, long sMax, long lMax) { - ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); - test.checkValidIntValue(sMin-1, null); + Assertions.assertThrows(DateTimeException.class, () -> { + ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); + test.checkValidIntValue(sMin-1, null); + }); } - @Test(dataProvider="valid", expectedExceptions = DateTimeException.class) + @ParameterizedTest + @MethodSource("data_valid") public void test_of_checkValidValueMaxException(long sMin, long lMin, long sMax, long lMax) { - ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); - test.checkValidIntValue(lMax+1, null); + Assertions.assertThrows(DateTimeException.class, () -> { + ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); + test.checkValidIntValue(lMax+1, null); + }); } - @Test(expectedExceptions = DateTimeException.class) + @Test public void test_checkValidValueUnsupported_long_long() { - ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); - test.checkValidIntValue(0, (ChronoField)null); + Assertions.assertThrows(DateTimeException.class, () -> { + ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); + test.checkValidIntValue(0, (ChronoField)null); + }); } - @Test(expectedExceptions = DateTimeException.class) + @Test public void test_checkValidValueInvalid_long_long() { - ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); - test.checkValidIntValue(Integer.MAX_VALUE + 2L, (ChronoField)null); + Assertions.assertThrows(DateTimeException.class, () -> { + ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); + test.checkValidIntValue(Integer.MAX_VALUE + 2L, (ChronoField)null); + }); } //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- + @Test public void test_equals1() { ValueRange a = ValueRange.of(1, 2, 3, 4); ValueRange b = ValueRange.of(1, 2, 3, 4); - assertEquals(a.equals(a), true); - assertEquals(a.equals(b), true); - assertEquals(b.equals(a), true); - assertEquals(b.equals(b), true); - assertEquals(a.hashCode() == b.hashCode(), true); + assertEquals(true, a.equals(a)); + assertEquals(true, a.equals(b)); + assertEquals(true, b.equals(a)); + assertEquals(true, b.equals(b)); + assertEquals(true, a.hashCode() == b.hashCode()); } + @Test public void test_equals2() { ValueRange a = ValueRange.of(1, 2, 3, 4); - assertEquals(a.equals(ValueRange.of(0, 2, 3, 4)), false); - assertEquals(a.equals(ValueRange.of(1, 3, 3, 4)), false); - assertEquals(a.equals(ValueRange.of(1, 2, 4, 4)), false); - assertEquals(a.equals(ValueRange.of(1, 2, 3, 5)), false); + assertEquals(false, a.equals(ValueRange.of(0, 2, 3, 4))); + assertEquals(false, a.equals(ValueRange.of(1, 3, 3, 4))); + assertEquals(false, a.equals(ValueRange.of(1, 2, 4, 4))); + assertEquals(false, a.equals(ValueRange.of(1, 2, 3, 5))); } + @Test public void test_equals_otherType() { ValueRange a = ValueRange.of(1, 12); - assertEquals(a.equals("Rubbish"), false); + assertEquals(false, a.equals("Rubbish")); } + @Test public void test_equals_null() { ValueRange a = ValueRange.of(1, 12); - assertEquals(a.equals(null), false); + assertEquals(false, a.equals(null)); } //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- + @Test public void test_toString() { - assertEquals(ValueRange.of(1, 1, 4, 4).toString(), "1 - 4"); - assertEquals(ValueRange.of(1, 1, 3, 4).toString(), "1 - 3/4"); - assertEquals(ValueRange.of(1, 2, 3, 4).toString(), "1/2 - 3/4"); - assertEquals(ValueRange.of(1, 2, 4, 4).toString(), "1/2 - 4"); + assertEquals("1 - 4", ValueRange.of(1, 1, 4, 4).toString()); + assertEquals("1 - 3/4", ValueRange.of(1, 1, 3, 4).toString()); + assertEquals("1/2 - 3/4", ValueRange.of(1, 2, 3, 4).toString()); + assertEquals("1/2 - 4", ValueRange.of(1, 2, 4, 4).toString()); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestIsoFields.java b/test/jdk/java/time/test/java/time/temporal/TestIsoFields.java index 53cd721c0e5..8a74582d976 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestIsoFields.java +++ b/test/jdk/java/time/test/java/time/temporal/TestIsoFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -26,8 +26,9 @@ import static java.time.temporal.IsoFields.DAY_OF_QUARTER; import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; import static java.time.temporal.IsoFields.WEEK_BASED_YEAR; import static java.time.temporal.IsoFields.WEEK_OF_WEEK_BASED_YEAR; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.LocalDate; import java.time.chrono.ChronoLocalDate; @@ -38,15 +39,16 @@ import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; import java.util.List; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests fields in IsoFields class are supported in Japanese/Minguo/ThaiBuddhist * date classes * @bug 8279185 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestIsoFields { private static final LocalDate ld = LocalDate.of(2022, 2, 25); private static final ChronoLocalDate J_DATE = JapaneseDate.from(ld); @@ -54,7 +56,6 @@ public class TestIsoFields { private static final ChronoLocalDate TB_DATE = ThaiBuddhistDate.from(ld); private static final List CLDATES = List.of(J_DATE, M_DATE, TB_DATE); - @DataProvider(name = "isSupported") Object[][] data_isSupported() { return new Object[][]{ {DAY_OF_QUARTER}, @@ -64,7 +65,6 @@ public class TestIsoFields { }; } - @DataProvider(name = "range") Object[][] data_range() { return new Object[][]{ {J_DATE, DAY_OF_QUARTER, ValueRange.of(1, 90)}, @@ -82,7 +82,6 @@ public class TestIsoFields { }; } - @DataProvider(name = "with_getLong") Object[][] data_with_getLong() { return new Object[][]{ {DAY_OF_QUARTER, 45}, @@ -92,24 +91,27 @@ public class TestIsoFields { }; } - @Test(dataProvider = "isSupported") + @ParameterizedTest + @MethodSource("data_isSupported") public void test_isSupported(TemporalField f) { CLDATES.forEach(d -> assertTrue(d.isSupported(f))); } - @Test(dataProvider = "range") + @ParameterizedTest + @MethodSource("data_range") public void test_range(ChronoLocalDate cld, TemporalField f, ValueRange r) { - assertEquals(cld.range(f), r); + assertEquals(r, cld.range(f)); } - @Test(dataProvider = "with_getLong") + @ParameterizedTest + @MethodSource("data_with_getLong") public void test_with_getLong(TemporalField f, long val) { CLDATES.forEach(d -> { var min = d.range(f).getMinimum(); var max = d.range(f).getMaximum(); - assertEquals(d.with(f, min).getLong(f), min); - assertEquals(d.with(f, max).getLong(f), max); - assertEquals(d.with(f, val).getLong(f), val); + assertEquals(min, d.with(f, min).getLong(f)); + assertEquals(max, d.with(f, max).getLong(f)); + assertEquals(val, d.with(f, val).getLong(f)); }); } } diff --git a/test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java b/test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java index 4c40e7278ed..80caa3ffcc1 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java +++ b/test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -23,8 +23,9 @@ package test.java.time.temporal; import static java.time.temporal.ChronoField.DAY_OF_WEEK; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.DayOfWeek; import java.time.LocalDate; @@ -40,16 +41,17 @@ import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; import java.time.temporal.WeekFields; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Test. */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestIsoWeekFields { - @DataProvider(name = "fields") Object[][] data_Fields() { return new Object[][] { {IsoFields.WEEK_OF_WEEK_BASED_YEAR, IsoFields.WEEK_BASED_YEAR}, @@ -60,92 +62,101 @@ public class TestIsoWeekFields { //----------------------------------------------------------------------- // WEEK_OF_WEEK_BASED_YEAR //----------------------------------------------------------------------- - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WOWBY_basics(TemporalField weekField, TemporalField yearField) { - assertEquals(weekField.isDateBased(), true); - assertEquals(weekField.isTimeBased(), false); - assertEquals(weekField.getBaseUnit(), ChronoUnit.WEEKS); - assertEquals(weekField.getRangeUnit(), IsoFields.WEEK_BASED_YEARS); + assertEquals(true, weekField.isDateBased()); + assertEquals(false, weekField.isTimeBased()); + assertEquals(ChronoUnit.WEEKS, weekField.getBaseUnit()); + assertEquals(IsoFields.WEEK_BASED_YEARS, weekField.getRangeUnit()); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WOWBY_isSupportedBy(TemporalField weekField, TemporalField yearField) { - assertEquals(weekField.isSupportedBy(LocalTime.NOON), false); - assertEquals(weekField.isSupportedBy(MonthDay.of(2, 1)), false); - assertEquals(weekField.isSupportedBy(LocalDate.MIN), true); - assertEquals(weekField.isSupportedBy(OffsetDateTime.MAX), true); - assertEquals(weekField.isSupportedBy(ThaiBuddhistDate.now()), true); + assertEquals(false, weekField.isSupportedBy(LocalTime.NOON)); + assertEquals(false, weekField.isSupportedBy(MonthDay.of(2, 1))); + assertEquals(true, weekField.isSupportedBy(LocalDate.MIN)); + assertEquals(true, weekField.isSupportedBy(OffsetDateTime.MAX)); + assertEquals(true, weekField.isSupportedBy(ThaiBuddhistDate.now())); } @Test public void test_WOWBY_isSupportedBy_fieldsDiffer() { - assertEquals(IsoFields.WEEK_OF_WEEK_BASED_YEAR.isSupportedBy(HijrahDate.now()), false); - assertEquals(WeekFields.ISO.weekOfWeekBasedYear().isSupportedBy(HijrahDate.now()), true); + assertEquals(false, IsoFields.WEEK_OF_WEEK_BASED_YEAR.isSupportedBy(HijrahDate.now())); + assertEquals(true, WeekFields.ISO.weekOfWeekBasedYear().isSupportedBy(HijrahDate.now())); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WOWBY_range(TemporalField weekField, TemporalField yearField) { - assertEquals(weekField.range(), ValueRange.of(1, 52, 53)); + assertEquals(ValueRange.of(1, 52, 53), weekField.range()); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WOWBY_rangeRefinedBy(TemporalField weekField, TemporalField yearField) { - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2012, 12, 31)), ValueRange.of(1, 52)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2013, 12, 29)), ValueRange.of(1, 52)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2013, 12, 30)), ValueRange.of(1, 52)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2014, 12, 28)), ValueRange.of(1, 52)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2014, 12, 29)), ValueRange.of(1, 53)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2016, 1, 3)), ValueRange.of(1, 53)); - assertEquals(weekField.rangeRefinedBy(LocalDate.of(2016, 1, 4)), ValueRange.of(1, 52)); + assertEquals(ValueRange.of(1, 52), weekField.rangeRefinedBy(LocalDate.of(2012, 12, 31))); + assertEquals(ValueRange.of(1, 52), weekField.rangeRefinedBy(LocalDate.of(2013, 12, 29))); + assertEquals(ValueRange.of(1, 52), weekField.rangeRefinedBy(LocalDate.of(2013, 12, 30))); + assertEquals(ValueRange.of(1, 52), weekField.rangeRefinedBy(LocalDate.of(2014, 12, 28))); + assertEquals(ValueRange.of(1, 53), weekField.rangeRefinedBy(LocalDate.of(2014, 12, 29))); + assertEquals(ValueRange.of(1, 53), weekField.rangeRefinedBy(LocalDate.of(2016, 1, 3))); + assertEquals(ValueRange.of(1, 52), weekField.rangeRefinedBy(LocalDate.of(2016, 1, 4))); } //----------------------------------------------------------------------- // WEEK_BASED_YEAR //----------------------------------------------------------------------- - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WBY_basics(TemporalField weekField, TemporalField yearField) { - assertEquals(yearField.isDateBased(), true); - assertEquals(yearField.isTimeBased(), false); - assertEquals(yearField.getBaseUnit(), IsoFields.WEEK_BASED_YEARS); - assertEquals(yearField.getRangeUnit(), ChronoUnit.FOREVER); + assertEquals(true, yearField.isDateBased()); + assertEquals(false, yearField.isTimeBased()); + assertEquals(IsoFields.WEEK_BASED_YEARS, yearField.getBaseUnit()); + assertEquals(ChronoUnit.FOREVER, yearField.getRangeUnit()); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WBY_isSupportedBy(TemporalField weekField, TemporalField yearField) { - assertEquals(yearField.isSupportedBy(LocalTime.NOON), false); - assertEquals(yearField.isSupportedBy(MonthDay.of(2, 1)), false); - assertEquals(yearField.isSupportedBy(LocalDate.MIN), true); - assertEquals(yearField.isSupportedBy(OffsetDateTime.MAX), true); - assertEquals(yearField.isSupportedBy(ThaiBuddhistDate.now()), true); + assertEquals(false, yearField.isSupportedBy(LocalTime.NOON)); + assertEquals(false, yearField.isSupportedBy(MonthDay.of(2, 1))); + assertEquals(true, yearField.isSupportedBy(LocalDate.MIN)); + assertEquals(true, yearField.isSupportedBy(OffsetDateTime.MAX)); + assertEquals(true, yearField.isSupportedBy(ThaiBuddhistDate.now())); } @Test public void test_WBY_isSupportedBy_ISO() { - assertEquals(IsoFields.WEEK_BASED_YEAR.isSupportedBy(HijrahDate.now()), false); + assertEquals(false, IsoFields.WEEK_BASED_YEAR.isSupportedBy(HijrahDate.now())); } @Test public void test_Unit_isSupportedBy_ISO() { - assertEquals(IsoFields.WEEK_BASED_YEARS.isSupportedBy(LocalDate.now()), true); - assertEquals(IsoFields.WEEK_BASED_YEARS.isSupportedBy(ThaiBuddhistDate.now()), true); - assertEquals(IsoFields.WEEK_BASED_YEARS.isSupportedBy(HijrahDate.now()), false); - assertEquals(IsoFields.QUARTER_YEARS.isSupportedBy(LocalDate.now()), true); - assertEquals(IsoFields.QUARTER_YEARS.isSupportedBy(ThaiBuddhistDate.now()), true); - assertEquals(IsoFields.QUARTER_YEARS.isSupportedBy(HijrahDate.now()), false); + assertEquals(true, IsoFields.WEEK_BASED_YEARS.isSupportedBy(LocalDate.now())); + assertEquals(true, IsoFields.WEEK_BASED_YEARS.isSupportedBy(ThaiBuddhistDate.now())); + assertEquals(false, IsoFields.WEEK_BASED_YEARS.isSupportedBy(HijrahDate.now())); + assertEquals(true, IsoFields.QUARTER_YEARS.isSupportedBy(LocalDate.now())); + assertEquals(true, IsoFields.QUARTER_YEARS.isSupportedBy(ThaiBuddhistDate.now())); + assertEquals(false, IsoFields.QUARTER_YEARS.isSupportedBy(HijrahDate.now())); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WBY_range(TemporalField weekField, TemporalField yearField) { - assertEquals(yearField.range(), ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE)); + assertEquals(ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE), yearField.range()); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_WBY_rangeRefinedBy(TemporalField weekField, TemporalField yearField) { - assertEquals(yearField.rangeRefinedBy(LocalDate.of(2012, 12, 31)), ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE)); + assertEquals(ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE), yearField.rangeRefinedBy(LocalDate.of(2012, 12, 31))); } //----------------------------------------------------------------------- - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_getFrom(TemporalField weekField, TemporalField yearField) { // tests every day from 2011 to 2016 inclusive LocalDate date = LocalDate.of(2011, 1, 3); @@ -153,9 +164,9 @@ public class TestIsoWeekFields { int week = 1; int dow = 1; for (int i = 1; i <= ((52 + 52 + 52 + 52 + 53 + 52) * 7); i++) { - assertEquals(yearField.getFrom(date), wby); - assertEquals(weekField.getFrom(date), week); - assertEquals(DAY_OF_WEEK.getFrom(date), dow); + assertEquals(wby, yearField.getFrom(date)); + assertEquals(week, weekField.getFrom(date)); + assertEquals(dow, DAY_OF_WEEK.getFrom(date)); if (dow == 7) { dow = 1; week++; @@ -168,12 +179,13 @@ public class TestIsoWeekFields { } date = date.plusDays(1); } - assertEquals(yearField.getFrom(date), 2017); - assertEquals(weekField.getFrom(date), 1); - assertEquals(DAY_OF_WEEK.getFrom(date), 1); + assertEquals(2017, yearField.getFrom(date)); + assertEquals(1, weekField.getFrom(date)); + assertEquals(1, DAY_OF_WEEK.getFrom(date)); } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_adjustInto_dow(TemporalField weekField, TemporalField yearField) { // tests every day from 2012 to 2016 inclusive LocalDate date = LocalDate.of(2012, 1, 2); @@ -183,9 +195,9 @@ public class TestIsoWeekFields { for (int i = 1; i <= ((52 + 52 + 52 + 53 + 52) * 7); i++) { for (int j = 1; j <= 7; j++) { LocalDate adjusted = DAY_OF_WEEK.adjustInto(date, j); - assertEquals(adjusted.get(DAY_OF_WEEK), j); - assertEquals(adjusted.get(weekField), week); - assertEquals(adjusted.get(yearField), wby); + assertEquals(j, adjusted.get(DAY_OF_WEEK)); + assertEquals(week, adjusted.get(weekField)); + assertEquals(wby, adjusted.get(yearField)); } if (dow == 7) { dow = 1; @@ -201,7 +213,8 @@ public class TestIsoWeekFields { } } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_adjustInto_week(TemporalField weekField, TemporalField yearField) { // tests every day from 2012 to 2016 inclusive LocalDate date = LocalDate.of(2012, 1, 2); @@ -212,9 +225,9 @@ public class TestIsoWeekFields { int weeksInYear = (wby == 2015 ? 53 : 52); for (int j = 1; j <= weeksInYear; j++) { LocalDate adjusted = weekField.adjustInto(date, j); - assertEquals(adjusted.get(weekField), j); - assertEquals(adjusted.get(DAY_OF_WEEK), dow); - assertEquals(adjusted.get(yearField), wby); + assertEquals(j, adjusted.get(weekField)); + assertEquals(dow, adjusted.get(DAY_OF_WEEK)); + assertEquals(wby, adjusted.get(yearField)); } if (dow == 7) { dow = 1; @@ -230,7 +243,8 @@ public class TestIsoWeekFields { } } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_adjustInto_wby(TemporalField weekField, TemporalField yearField) { // tests every day from 2012 to 2016 inclusive LocalDate date = LocalDate.of(2012, 1, 2); @@ -240,9 +254,9 @@ public class TestIsoWeekFields { for (int i = 1; i <= ((52 + 52 + 52 + 53 + 52) * 7); i++) { for (int j = 2004; j <= 2015; j++) { LocalDate adjusted = yearField.adjustInto(date, j); - assertEquals(adjusted.get(yearField), j); - assertEquals(adjusted.get(DAY_OF_WEEK), dow); - assertEquals(adjusted.get(weekField), (week == 53 && wbyLen(j) == 52 ? 52 : week), "" + date + " " + adjusted); + assertEquals(j, adjusted.get(yearField)); + assertEquals(dow, adjusted.get(DAY_OF_WEEK)); + assertEquals((week == 53 && wbyLen(j) == 52 ? 52 : week), adjusted.get(weekField), "" + date + " " + adjusted); } if (dow == 7) { dow = 1; @@ -258,7 +272,8 @@ public class TestIsoWeekFields { } } - @Test(dataProvider = "fields") + @ParameterizedTest + @MethodSource("data_Fields") public void test_addTo_weekBasedYears(TemporalField weekField, TemporalField yearField) { // tests every day from 2012 to 2016 inclusive LocalDate date = LocalDate.of(2012, 1, 2); @@ -268,9 +283,9 @@ public class TestIsoWeekFields { for (int i = 1; i <= ((52 + 52 + 52 + 53 + 52) * 7); i++) { for (int j = -5; j <= 5; j++) { LocalDate adjusted = IsoFields.WEEK_BASED_YEARS.addTo(date, j); - assertEquals(adjusted.get(yearField), wby + j); - assertEquals(adjusted.get(DAY_OF_WEEK), dow); - assertEquals(adjusted.get(weekField), (week == 53 && wbyLen(wby + j) == 52 ? 52 : week), "" + date + " " + adjusted); + assertEquals(wby + j, adjusted.get(yearField)); + assertEquals(dow, adjusted.get(DAY_OF_WEEK)); + assertEquals((week == 53 && wbyLen(wby + j) == 52 ? 52 : week), adjusted.get(weekField), "" + date + " " + adjusted); } if (dow == 7) { dow = 1; diff --git a/test/jdk/java/time/test/java/time/temporal/TestJulianFields.java b/test/jdk/java/time/test/java/time/temporal/TestJulianFields.java index 0d9d79e3158..5ed393d1b87 100644 --- a/test/jdk/java/time/test/java/time/temporal/TestJulianFields.java +++ b/test/jdk/java/time/test/java/time/temporal/TestJulianFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -59,16 +59,15 @@ */ package test.java.time.temporal; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.temporal.JulianFields; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test. */ -@Test public class TestJulianFields { //----------------------------------------------------------------------- @@ -76,9 +75,9 @@ public class TestJulianFields { //----------------------------------------------------------------------- @Test public void test_toString() { - assertEquals(JulianFields.JULIAN_DAY.toString(), "JulianDay"); - assertEquals(JulianFields.MODIFIED_JULIAN_DAY.toString(), "ModifiedJulianDay"); - assertEquals(JulianFields.RATA_DIE.toString(), "RataDie"); + assertEquals("JulianDay", JulianFields.JULIAN_DAY.toString()); + assertEquals("ModifiedJulianDay", JulianFields.MODIFIED_JULIAN_DAY.toString()); + assertEquals("RataDie", JulianFields.RATA_DIE.toString()); } } diff --git a/test/jdk/java/time/test/java/time/zone/TestFixedZoneRules.java b/test/jdk/java/time/test/java/time/zone/TestFixedZoneRules.java index d479134c26e..8f52372ab01 100644 --- a/test/jdk/java/time/test/java/time/zone/TestFixedZoneRules.java +++ b/test/jdk/java/time/test/java/time/zone/TestFixedZoneRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -61,19 +61,18 @@ package test.java.time.zone; import java.time.zone.ZoneRules; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneOffset; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Test ZoneRules for fixed offset time-zones. */ -@Test public class TestFixedZoneRules { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); @@ -86,16 +85,16 @@ public class TestFixedZoneRules { @Test public void test_data_nullInput() { ZoneRules test = make(OFFSET_PONE); - assertEquals(test.getOffset((Instant) null), OFFSET_PONE); - assertEquals(test.getOffset((LocalDateTime) null), OFFSET_PONE); - assertEquals(test.getValidOffsets(null).size(), 1); - assertEquals(test.getValidOffsets(null).get(0), OFFSET_PONE); - assertEquals(test.getTransition(null), null); - assertEquals(test.getStandardOffset(null), OFFSET_PONE); - assertEquals(test.getDaylightSavings(null), Duration.ZERO); - assertEquals(test.isDaylightSavings(null), false); - assertEquals(test.nextTransition(null), null); - assertEquals(test.previousTransition(null), null); + assertEquals(OFFSET_PONE, test.getOffset((Instant) null)); + assertEquals(OFFSET_PONE, test.getOffset((LocalDateTime) null)); + assertEquals(1, test.getValidOffsets(null).size()); + assertEquals(OFFSET_PONE, test.getValidOffsets(null).get(0)); + assertEquals(null, test.getTransition(null)); + assertEquals(OFFSET_PONE, test.getStandardOffset(null)); + assertEquals(Duration.ZERO, test.getDaylightSavings(null)); + assertEquals(false, test.isDaylightSavings(null)); + assertEquals(null, test.nextTransition(null)); + assertEquals(null, test.previousTransition(null)); } } diff --git a/test/jdk/java/time/test/java/time/zone/TestMutableZoneRules.java b/test/jdk/java/time/test/java/time/zone/TestMutableZoneRules.java index 4474f70db05..a8d7f4746c7 100644 --- a/test/jdk/java/time/test/java/time/zone/TestMutableZoneRules.java +++ b/test/jdk/java/time/test/java/time/zone/TestMutableZoneRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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,16 +27,15 @@ import java.time.*; import java.time.zone.*; import java.util.*; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; /** * @summary ZoneRules invariants can be broken. * * @bug 8246788 */ -@Test public class TestMutableZoneRules { static final ZoneOffset offset = ZoneOffset.ofHoursMinutes(1, 30); @@ -48,16 +47,18 @@ public class TestMutableZoneRules { ZoneOffsetTransitionRule.of(Month.MARCH, 2, DayOfWeek.MONDAY, LocalTime.MIN, true, ZoneOffsetTransitionRule.TimeDefinition.UTC, offset, offset, offset); + @Test public void testMutation() { ZoneOffsetTransitionRule[] array = { rule1 }; ZoneRules zr1 = ZoneRules.of(offset, offset, List.of(), List.of(), List.of(rule1)); ZoneRules zr2 = ZoneRules.of(offset, offset, List.of(), List.of(), new TestList(array, array.length)); - assertEquals(zr2, zr1); + assertEquals(zr1, zr2); array[0] = rule2; - assertEquals(zr2, zr1); + assertEquals(zr1, zr2); } + @Test public void testLength() { ZoneOffsetTransitionRule[] array = new ZoneOffsetTransitionRule[17]; Arrays.setAll(array, i -> rule1); diff --git a/test/jdk/java/time/test/java/time/zone/TestZoneRules.java b/test/jdk/java/time/test/java/time/zone/TestZoneRules.java index 584ed2e56c7..7a1e656ee87 100644 --- a/test/jdk/java/time/test/java/time/zone/TestZoneRules.java +++ b/test/jdk/java/time/test/java/time/zone/TestZoneRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -40,17 +40,19 @@ import java.time.zone.ZoneRules; import java.util.Collections; import java.util.List; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * @summary Tests for ZoneRules class. * * @bug 8212970 8236903 8239836 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestZoneRules { private static final ZoneId DUBLIN = ZoneId.of("Europe/Dublin"); @@ -68,7 +70,6 @@ public class TestZoneRules { private static final ZoneOffsetTransition ZOT = ZoneId.of("America/Los_Angeles").getRules().getTransitions().get(0); private static final ZoneOffsetTransitionRule ZOTR = ZoneId.of("America/Los_Angeles").getRules().getTransitionRules().get(0); - @DataProvider private Object[][] negativeDST () { return new Object[][] { // ZoneId, localDate, offset, standard offset, isDaylightSavings @@ -102,7 +103,6 @@ public class TestZoneRules { }; } - @DataProvider private Object[][] transitionBeyondDay() { return new Object[][] { // ZoneId, LocalDateTime, beforeOffset, afterOffset @@ -117,7 +117,6 @@ public class TestZoneRules { }; } - @DataProvider private Object[][] emptyTransitionList() { return new Object[][] { // days, offset, std offset, savings, isDST @@ -126,7 +125,6 @@ public class TestZoneRules { }; } - @DataProvider private Object[][] isFixedOffset() { return new Object[][] { // ZoneRules, expected @@ -144,20 +142,22 @@ public class TestZoneRules { * negative savings in the source TZ files. * @bug 8212970 */ - @Test(dataProvider="negativeDST") + @ParameterizedTest + @MethodSource("negativeDST") public void test_NegativeDST(ZoneId zid, LocalDate ld, ZoneOffset offset, ZoneOffset stdOffset, boolean isDST) { Instant i = Instant.from(ZonedDateTime.of(ld, LocalTime.MIN, zid)); ZoneRules zr = zid.getRules(); - assertEquals(zr.getOffset(i), offset); - assertEquals(zr.getStandardOffset(i), stdOffset); - assertEquals(zr.isDaylightSavings(i), isDST); + assertEquals(offset, zr.getOffset(i)); + assertEquals(stdOffset, zr.getStandardOffset(i)); + assertEquals(isDST, zr.isDaylightSavings(i)); } /** * Check the transition cutover time beyond 24:00, which should translate into the next day. * @bug 8212970 */ - @Test(dataProvider="transitionBeyondDay") + @ParameterizedTest + @MethodSource("transitionBeyondDay") public void test_TransitionBeyondDay(ZoneId zid, LocalDateTime ldt, ZoneOffset before, ZoneOffset after) { ZoneOffsetTransition zot = ZoneOffsetTransition.of(ldt, before, after); ZoneRules zr = zid.getRules(); @@ -198,14 +198,15 @@ public class TestZoneRules { Collections.singletonList(transitionRule)); ZoneOffset offsetA = zoneRulesA.getOffset(maxLocalDateTime); ZoneOffset offsetB = zoneRulesB.getOffset(maxLocalDateTime); - assertEquals(offsetA, offsetB); + assertEquals(offsetB, offsetA); } /** * Tests whether empty "transitionList" is correctly interpreted. * @bug 8239836 */ - @Test(dataProvider="emptyTransitionList") + @ParameterizedTest + @MethodSource("emptyTransitionList") public void test_EmptyTransitionList(int days, int offset, int stdOffset, int savings, boolean isDST) { LocalDateTime transitionDay = LocalDateTime.of(2020, 1, 1, 2, 0); Instant testDay = transitionDay.plusDays(days).toInstant(ZoneOffset.UTC); @@ -217,18 +218,19 @@ public class TestZoneRules { Collections.singletonList(trans), Collections.emptyList(), Collections.emptyList()); - assertEquals(rules.getOffset(testDay), ZoneOffset.ofHours(offset)); - assertEquals(rules.getStandardOffset(testDay), ZoneOffset.ofHours(stdOffset)); - assertEquals(rules.getDaylightSavings(testDay), Duration.ofHours(savings)); - assertEquals(rules.isDaylightSavings(testDay), isDST); + assertEquals(ZoneOffset.ofHours(offset), rules.getOffset(testDay)); + assertEquals(ZoneOffset.ofHours(stdOffset), rules.getStandardOffset(testDay)); + assertEquals(Duration.ofHours(savings), rules.getDaylightSavings(testDay)); + assertEquals(isDST, rules.isDaylightSavings(testDay)); } /** * Tests whether isFixedOffset() is working correctly * @bug 8239836 */ - @Test(dataProvider="isFixedOffset") + @ParameterizedTest + @MethodSource("isFixedOffset") public void test_IsFixedOffset(ZoneRules zr, boolean expected) { - assertEquals(zr.isFixedOffset(), expected); + assertEquals(expected, zr.isFixedOffset()); } } diff --git a/test/jdk/java/time/test/java/time/zone/TestZoneRulesProvider.java b/test/jdk/java/time/test/java/time/zone/TestZoneRulesProvider.java index 3a20dc2b864..6b0463d1b26 100644 --- a/test/jdk/java/time/test/java/time/zone/TestZoneRulesProvider.java +++ b/test/jdk/java/time/test/java/time/zone/TestZoneRulesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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,17 +32,15 @@ import java.util.LinkedHashSet; import java.util.NavigableMap; import java.util.Set; -import org.testng.annotations.Test; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; /** * @summary Tests for ZoneRulesProvider class. * @bug 8299571 8302983 */ -@Test public class TestZoneRulesProvider { /** diff --git a/test/jdk/java/time/test/java/util/TestFormatter.java b/test/jdk/java/time/test/java/util/TestFormatter.java index 903e48ba96d..72b859e533e 100644 --- a/test/jdk/java/time/test/java/util/TestFormatter.java +++ b/test/jdk/java/time/test/java/util/TestFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -22,7 +22,7 @@ */ package test.java.util; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.Instant; import java.time.LocalTime; @@ -42,14 +42,15 @@ import java.time.temporal.UnsupportedTemporalTypeException; import java.util.*; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /* @test * @summary Unit test for j.u.Formatter threeten date/time support * @bug 8003680 8043387 8012638 */ -@Test +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestFormatter { // time @@ -71,7 +72,6 @@ public class TestFormatter { private int failure = 0; private boolean verbose = false; - @DataProvider(name = "calendarsByLocale") Object[][] data_calendars() { return new Object[][] { {"en_US"}, @@ -80,7 +80,8 @@ public class TestFormatter { }; } - @Test(dataProvider="calendarsByLocale") + @ParameterizedTest + @MethodSource("data_calendars") public void test (String calendarLocale) { failure = 0; int N = 12; @@ -128,7 +129,7 @@ public class TestFormatter { System.out.println("All tests (" + total + ") PASSED"); } } - assertEquals(failure, 0); + assertEquals(0, failure); } private String getClassName(Object o) { diff --git a/test/jdk/java/util/Locale/PreserveTagCase.java b/test/jdk/java/util/Locale/PreserveTagCase.java index c5535e3a89f..3721067e831 100644 --- a/test/jdk/java/util/Locale/PreserveTagCase.java +++ b/test/jdk/java/util/Locale/PreserveTagCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -53,7 +53,7 @@ public class PreserveTagCase { */ @ParameterizedTest @MethodSource("filterProvider") - public static void testFilterTags(String ranges, List tags, + public void testFilterTags(String ranges, List tags, List expected, FilteringMode mode) { List priorityList = LanguageRange.parse(ranges); List actual = Locale.filterTags(priorityList, tags, mode); @@ -67,7 +67,7 @@ public class PreserveTagCase { */ @ParameterizedTest @MethodSource("lookupProvider") - public static void testLookupTag(String ranges, List tags, + public void testLookupTag(String ranges, List tags, String expected) { List priorityList = LanguageRange.parse(ranges); String actual = Locale.lookupTag(priorityList, tags); diff --git a/test/jdk/java/util/TimeZone/TimeZoneData/VERSION b/test/jdk/java/util/TimeZone/TimeZoneData/VERSION index 750d9fae2b1..76d146afc71 100644 --- a/test/jdk/java/util/TimeZone/TimeZoneData/VERSION +++ b/test/jdk/java/util/TimeZone/TimeZoneData/VERSION @@ -1 +1 @@ -tzdata2025b +tzdata2025c diff --git a/test/jdk/javax/management/mxbean/MXBeanInteropTest1.java b/test/jdk/javax/management/mxbean/MXBeanInteropTest1.java index 011bdb144fb..61127a4ee10 100644 --- a/test/jdk/javax/management/mxbean/MXBeanInteropTest1.java +++ b/test/jdk/javax/management/mxbean/MXBeanInteropTest1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/jdk/javax/swing/DefaultTableCellRenderer/DefRendererSerialize.java b/test/jdk/javax/swing/DefaultTableCellRenderer/DefRendererSerialize.java new file mode 100644 index 00000000000..07e1b1d51c7 --- /dev/null +++ b/test/jdk/javax/swing/DefaultTableCellRenderer/DefRendererSerialize.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4337898 + * @key headful + * @summary Verifies Serializing DefaultTableCellRenderer doesn't change colors + * @run main DefRendererSerialize + */ + +import java.awt.Color; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.SwingUtilities; +import java.util.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +public class DefRendererSerialize { + + private static JFrame frame; + private static JTable table; + private static volatile DefaultTableCellRenderer tcr; + private static String[][] rowData = { {"1-1","1-2","1-3"}, + {"2-1","","2-3"}, + {"3-1","3-2","3-3"} }; + + private static String[] columnData = {"Column 1", "Column 2", "Column 3"}; + private static volatile Rectangle tableRect; + private static volatile Point tableOnScreen; + private static volatile Point p; + private static Color fg, bg; + + public static void main (String[] args) throws Exception { + try { + + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame(); + table = new JTable(rowData, columnData); + + DefaultTableCellRenderer tcr = new DefaultTableCellRenderer(); + table.setDefaultRenderer(table.getColumnClass(1), tcr); + + fg = tcr.getForeground(); + bg = tcr.getBackground(); + System.out.println("renderer fg " + fg + " bg " + bg); + tcr = (DefaultTableCellRenderer) table.getDefaultRenderer(table.getColumnClass(1)); + + // If this try block is removed, table text remains black on white. + byte[] serializedObject = null; + try { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + ObjectOutputStream ostream = new ObjectOutputStream(bytes); + ostream.writeObject(tcr); + ostream.flush(); + serializedObject = bytes.toByteArray(); + } catch (IOException ioex) { + throw new RuntimeException(ioex); + } + + if (serializedObject == null) { + throw new RuntimeException("FAILED: Serialized byte array in null"); + } + try { + DefaultTableCellRenderer destcr; + try (ObjectInputStream inputStream = + new ObjectInputStream(new ByteArrayInputStream(serializedObject))) { + destcr = (DefaultTableCellRenderer) inputStream.readObject(); + } + System.out.println("deserialized renderer fg " + fg + " bg " + bg); + if (!(fg == destcr.getForeground()) || !(bg == destcr.getBackground())) { + throw new RuntimeException("Deserialized foreground and background color not same"); + } + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + + frame.add(table); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + tableRect = table.getCellRect(1, 1, true); + tableOnScreen = table.getLocationOnScreen(); + + p = new Point(tableOnScreen.x + tableRect.x + tableRect.width / 2, + tableOnScreen.y + tableRect.y + tableRect.height / 2); + + }); + Color pixelColor = robot.getPixelColor(p.x, p.y); + System.out.println("pixelColor " + pixelColor); + if (!pixelColor.equals(Color.white)) { + throw new RuntimeException("Serializing DefaultTableCellRenderer changes colors"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} diff --git a/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug6197830.java b/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug6197830.java index afb1c7bb33f..5a30e202d9d 100644 --- a/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug6197830.java +++ b/test/jdk/javax/swing/JMenuItem/MenuItemTest/bug6197830.java @@ -49,6 +49,7 @@ public class bug6197830 { .columns(35) .testUI(bug6197830::createTestUI) .positionTestUIBottomRowCentered() + .logArea() .build() .awaitAndCheck(); } diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java index c33678bee1f..3ad6d6f320f 100644 --- a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java index 837febfe0ed..d64caa3424f 100644 --- a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java index 1dd979f44bf..f494e3d3ae8 100644 --- a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java index 43d180db0a5..da2961cd97b 100644 --- a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java index cb7b00d8ebf..a5872219f10 100644 --- a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Double128VectorTests.java b/test/jdk/jdk/incubator/vector/Double128VectorTests.java index 716d7b1f1f7..215edbb3a66 100644 --- a/test/jdk/jdk/incubator/vector/Double128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Double256VectorTests.java b/test/jdk/jdk/incubator/vector/Double256VectorTests.java index 298d5591b1c..14d52320ce8 100644 --- a/test/jdk/jdk/incubator/vector/Double256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Double512VectorTests.java b/test/jdk/jdk/incubator/vector/Double512VectorTests.java index 34723b27ec9..91a4669a1b1 100644 --- a/test/jdk/jdk/incubator/vector/Double512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Double64VectorTests.java b/test/jdk/jdk/incubator/vector/Double64VectorTests.java index f8ccd2ea8b4..659e18cd8af 100644 --- a/test/jdk/jdk/incubator/vector/Double64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java index 1992f80eb2d..ac85f0bd07b 100644 --- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Float128VectorTests.java b/test/jdk/jdk/incubator/vector/Float128VectorTests.java index d605fa7c61f..32b93293fb9 100644 --- a/test/jdk/jdk/incubator/vector/Float128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Float256VectorTests.java b/test/jdk/jdk/incubator/vector/Float256VectorTests.java index f72e81cd030..9847865eacb 100644 --- a/test/jdk/jdk/incubator/vector/Float256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Float512VectorTests.java b/test/jdk/jdk/incubator/vector/Float512VectorTests.java index 68e182a602a..0daa5310ff0 100644 --- a/test/jdk/jdk/incubator/vector/Float512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Float64VectorTests.java b/test/jdk/jdk/incubator/vector/Float64VectorTests.java index c5bc801bc03..921264fc4e2 100644 --- a/test/jdk/jdk/incubator/vector/Float64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java index 5fccb85dc40..07c9b7d0ef9 100644 --- a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Int128VectorTests.java b/test/jdk/jdk/incubator/vector/Int128VectorTests.java index c0834d7710f..93912243ecd 100644 --- a/test/jdk/jdk/incubator/vector/Int128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Int256VectorTests.java b/test/jdk/jdk/incubator/vector/Int256VectorTests.java index cb8d306156a..e8d6f3311ac 100644 --- a/test/jdk/jdk/incubator/vector/Int256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Int512VectorTests.java b/test/jdk/jdk/incubator/vector/Int512VectorTests.java index d35d680c0c8..932d9ee4487 100644 --- a/test/jdk/jdk/incubator/vector/Int512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Int64VectorTests.java b/test/jdk/jdk/incubator/vector/Int64VectorTests.java index 9c35785e298..3c00904a70e 100644 --- a/test/jdk/jdk/incubator/vector/Int64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java index 0f5e0d1cdc0..42659bfe44e 100644 --- a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Long128VectorTests.java b/test/jdk/jdk/incubator/vector/Long128VectorTests.java index 832329a0a8b..6c305a5c2b4 100644 --- a/test/jdk/jdk/incubator/vector/Long128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Long256VectorTests.java b/test/jdk/jdk/incubator/vector/Long256VectorTests.java index ff9d063ad0a..3b276391cb7 100644 --- a/test/jdk/jdk/incubator/vector/Long256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Long512VectorTests.java b/test/jdk/jdk/incubator/vector/Long512VectorTests.java index fac87be8e22..181116cf399 100644 --- a/test/jdk/jdk/incubator/vector/Long512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Long64VectorTests.java b/test/jdk/jdk/incubator/vector/Long64VectorTests.java index 7c283b972dc..cb052925778 100644 --- a/test/jdk/jdk/incubator/vector/Long64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java index c76a2a2affd..6fe189867c2 100644 --- a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Short128VectorTests.java b/test/jdk/jdk/incubator/vector/Short128VectorTests.java index 8300c64e574..be39a01a4e7 100644 --- a/test/jdk/jdk/incubator/vector/Short128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Short256VectorTests.java b/test/jdk/jdk/incubator/vector/Short256VectorTests.java index f208905b203..0b6ae53710e 100644 --- a/test/jdk/jdk/incubator/vector/Short256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Short512VectorTests.java b/test/jdk/jdk/incubator/vector/Short512VectorTests.java index 776ba2115b8..d4568068b6a 100644 --- a/test/jdk/jdk/incubator/vector/Short512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/Short64VectorTests.java b/test/jdk/jdk/incubator/vector/Short64VectorTests.java index 9903759f8f3..83d5cfd18e8 100644 --- a/test/jdk/jdk/incubator/vector/Short64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java index 2e5c37d8cc6..45ba8db51c1 100644 --- a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/internal/platform/docker/MetricsCpuTester.java b/test/jdk/jdk/internal/platform/docker/MetricsCpuTester.java index 62549e7b518..9ec9b2bbf0e 100644 --- a/test/jdk/jdk/internal/platform/docker/MetricsCpuTester.java +++ b/test/jdk/jdk/internal/platform/docker/MetricsCpuTester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/jdk/jdk/internal/vm/Continuation/OSRWithManyLocals.java b/test/jdk/jdk/internal/vm/Continuation/OSRWithManyLocals.java new file mode 100644 index 00000000000..2a8d4e91001 --- /dev/null +++ b/test/jdk/jdk/internal/vm/Continuation/OSRWithManyLocals.java @@ -0,0 +1,90 @@ +/* +* Copyright (c) 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 +* under the terms of the GNU General Public License version 2 only, as +* published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +* or visit www.oracle.com if you need additional information or have any +* questions. +*/ + +/** +* @test +* @bug 8372591 +* @summary Test freeze/thaw of OSR frame from method with many locals +* @requires vm.continuations +* @requires vm.compMode != "Xint" & vm.compMode != "Xcomp" +* @modules java.base/jdk.internal.vm +* @library /test/lib /test/hotspot/jtreg +* @build jdk.test.whitebox.WhiteBox +* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox +* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI OSRWithManyLocals +*/ + +import jdk.internal.vm.Continuation; +import jdk.internal.vm.ContinuationScope; + +import jdk.test.lib.Asserts; +import java.lang.reflect.Method; +import jdk.test.whitebox.WhiteBox; + +public class OSRWithManyLocals { + static final WhiteBox wb = WhiteBox.getWhiteBox(); + static final ContinuationScope FOO = new ContinuationScope() {}; + static final Method foo = getMethod("foo"); + + public static void main(String[] args) throws Exception { + runCont(new Continuation(FOO, () -> warmUp())); + runCont(new Continuation(FOO, () -> foo())); + } + + public static void runCont(Continuation cont) { + while (!cont.isDone()) { + cont.run(); + } + } + + public static void warmUp() { + // Trigger compilation of Continuation.yield/yield0 + for (int i = 0; i < 10_000; i++) { + Continuation.yield(FOO); + } + } + + public static void foo() { + // Declare lots of locals so that size of OSR foo + Continuation.yield/yield0 + // frames is less than (foo_sender.unextended_sp() - foo_sender.sp()). + double d1=1,d2=2,d3=3,d4=4,d5=5,d6=6,d7=7,d8=8,d9=9,d10=10,d11=11,d12=12,d13=13,d14=14,d15=15,d16=16,d17=17,d18=18; + double d19=19,d20=20,d21=21,d22=22,d23=23,d24=24,d25=25,d26=26,d27=27,d28=28,d29=29,d30=30,d31=31,d32=32,d33=33,d34=34; + double d35=35,d36=36,d37=37,d38=38,d39=39,d40=40,d41=41,d42=42,d43=43,d44=44,d45=45,d46=46,d47=47,d48=48,d49=49,d50=50; + double d51=51,d52=52,d53=53,d54=54,d55=55,d56=56,d57=57,d58=58,d59=59,d60=60,d61=61,d62=62,d63=63,d64=64,d65=65,d66=66; + double d67=67,d68=68,d69=69,d70=70,d71=71,d72=72,d73=73,d74=74,d75=75,d76=76,d77=77,d78=78,d79=79,d80=80,d81=81,d82=82; + + // Provoke OSR compilation. After we verified the method was compiled keep looping + // until we trigger the _backedge_counter overflow to actually trigger OSR. + for (int i = 0; !wb.isMethodCompiled(foo, true) || i++ < 2_000;) { + } + Continuation.yield(FOO); + } + + static Method getMethod(String method) { + try { + return OSRWithManyLocals.class.getMethod(method); + } catch (Exception e) { + throw new RuntimeException("Exception: couldn't found method " + method + ". " + e.getMessage()); + } + } +} diff --git a/test/jdk/jdk/jfr/event/profiling/BaseTestFullStackTrace.java b/test/jdk/jdk/jfr/event/profiling/BaseTestFullStackTrace.java index de211b8c454..aadd9dded7e 100644 --- a/test/jdk/jdk/jfr/event/profiling/BaseTestFullStackTrace.java +++ b/test/jdk/jdk/jfr/event/profiling/BaseTestFullStackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/test/jdk/jdk/jfr/event/profiling/TestCPUTimeSampleNative.java b/test/jdk/jdk/jfr/event/profiling/TestCPUTimeSampleNative.java index 1617bce4ba3..b79edfeac10 100644 --- a/test/jdk/jdk/jfr/event/profiling/TestCPUTimeSampleNative.java +++ b/test/jdk/jdk/jfr/event/profiling/TestCPUTimeSampleNative.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 diff --git a/test/jdk/jdk/jfr/event/profiling/TestCPUTimeSamplingLongPeriod.java b/test/jdk/jdk/jfr/event/profiling/TestCPUTimeSamplingLongPeriod.java index 69d32d48282..cbaf8d707e8 100644 --- a/test/jdk/jdk/jfr/event/profiling/TestCPUTimeSamplingLongPeriod.java +++ b/test/jdk/jdk/jfr/event/profiling/TestCPUTimeSamplingLongPeriod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 diff --git a/test/jdk/sun/security/util/Password/EmptyIn.java b/test/jdk/sun/security/util/Password/EmptyIn.java new file mode 100644 index 00000000000..b5692b9e7f9 --- /dev/null +++ b/test/jdk/sun/security/util/Password/EmptyIn.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.Asserts; +import sun.security.util.Password; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +/* + * @test + * @bug 8374555 + * @summary only print warning when reading from System.in + * @modules java.base/sun.security.util + * @library /test/lib + */ +public class EmptyIn { + public static void main(String[] args) throws Exception { + testSystemIn(); + testNotSystemIn(); + } + + static void testSystemIn() throws Exception { + var in = new ByteArrayInputStream(new byte[0]); + var err = new ByteArrayOutputStream(); + var oldErr = System.err; + var oldIn = System.in; + try { + System.setIn(in); + System.setErr(new PrintStream(err)); + Password.readPassword(System.in); + } finally { + System.setIn(oldIn); + System.setErr(oldErr); + } + // Read from System.in. Should warn. + Asserts.assertNotEquals(0, err.size()); + } + + static void testNotSystemIn() throws Exception { + var in = new ByteArrayInputStream(new byte[0]); + var err = new ByteArrayOutputStream(); + var oldErr = System.err; + try { + System.setErr(new PrintStream(err)); + Password.readPassword(in); + } finally { + System.setErr(oldErr); + } + // Not read from System.in. Should not warn. + Asserts.assertEQ(0, err.size()); + } +} diff --git a/test/jdk/tools/jpackage/share/ErrorTest.java b/test/jdk/tools/jpackage/share/ErrorTest.java index 955c17e6043..bc12577fa20 100644 --- a/test/jdk/tools/jpackage/share/ErrorTest.java +++ b/test/jdk/tools/jpackage/share/ErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -707,12 +707,6 @@ public final class ErrorTest { final List errorMessages = new ArrayList<>(); errorMessages.add(makeError(JPackageStringBundle.MAIN.cannedFormattedString( "error.cert.not.found", "Developer ID Application: " + signingId, ""))); - errorMessages.addAll(Stream.of( - Map.>entry("error.explicit-sign-no-cert", JPackageCommand::makeError), - Map.>entry("error.explicit-sign-no-cert.advice", JPackageCommand::makeAdvice) - ).map(e -> { - return e.getValue().apply(JPackageStringBundle.MAIN.cannedFormattedString(e.getKey())); - }).toList()); final var cmd = JPackageCommand.helloAppImage() .ignoreDefaultVerbose(true) diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index dbc7a916885..70e619f3d3d 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -146,6 +146,7 @@ public class VMProps implements Callable> { map.put("jdk.containerized", this::jdkContainerized); map.put("vm.flagless", this::isFlagless); map.put("jdk.foreign.linker", this::jdkForeignLinker); + map.put("jdk.explodedImage", this::explodedImage); map.put("jlink.packagedModules", this::packagedModules); map.put("jdk.static", this::isStatic); vmGC(map); // vm.gc.X = true/false @@ -751,6 +752,20 @@ public class VMProps implements Callable> { return "" + "true".equalsIgnoreCase(isEnabled); } + private String explodedImage() { + try { + Path jmodFile = Path.of(System.getProperty("java.home"), "jmods", "java.base.jmod"); + if (Files.exists(jmodFile)) { + return Boolean.FALSE.toString(); + } else { + return Boolean.TRUE.toString(); + } + } catch (Throwable t) { + t.printStackTrace(); + return errorWithMessage("Error in explodedImage " + t); + } + } + private String packagedModules() { // Some jlink tests require packaged modules being present (jmods). // For a runtime linkable image build packaged modules aren't present diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java b/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java index 784efa9767d..579fed9d355 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java index e9d7f7a795d..c8f79eb466c 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 diff --git a/test/langtools/jdk/javadoc/doclet/testMarkdown/TestMarkdownLinks.java b/test/langtools/jdk/javadoc/doclet/testMarkdown/TestMarkdownLinks.java index 76fa87f4fff..24e9a798e1b 100644 --- a/test/langtools/jdk/javadoc/doclet/testMarkdown/TestMarkdownLinks.java +++ b/test/langtools/jdk/javadoc/doclet/testMarkdown/TestMarkdownLinks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 diff --git a/test/langtools/jdk/javadoc/doclet/testRelativeLinks/pkg/C.java b/test/langtools/jdk/javadoc/doclet/testRelativeLinks/pkg/C.java index 79a09b4f240..5231fa6b072 100644 --- a/test/langtools/jdk/javadoc/doclet/testRelativeLinks/pkg/C.java +++ b/test/langtools/jdk/javadoc/doclet/testRelativeLinks/pkg/C.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTagWithModule.java b/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTagWithModule.java index 9c4c4da70e3..ded9a3a9d72 100644 --- a/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTagWithModule.java +++ b/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTagWithModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/test/langtools/jdk/javadoc/doclet/testTitleInHref/TestTitleInHref.java b/test/langtools/jdk/javadoc/doclet/testTitleInHref/TestTitleInHref.java index 70a77fad5a7..67cba82c6d8 100644 --- a/test/langtools/jdk/javadoc/doclet/testTitleInHref/TestTitleInHref.java +++ b/test/langtools/jdk/javadoc/doclet/testTitleInHref/TestTitleInHref.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/test/langtools/jdk/javadoc/tool/modules/Modules.java b/test/langtools/jdk/javadoc/tool/modules/Modules.java index c8028ba5c7e..ce317bdb015 100644 --- a/test/langtools/jdk/javadoc/tool/modules/Modules.java +++ b/test/langtools/jdk/javadoc/tool/modules/Modules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/test/langtools/jdk/jshell/Compiler.java b/test/langtools/jdk/jshell/Compiler.java index a255008b15d..f2ae98102c4 100644 --- a/test/langtools/jdk/jshell/Compiler.java +++ b/test/langtools/jdk/jshell/Compiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 diff --git a/test/langtools/jdk/jshell/HighlightUITest.java b/test/langtools/jdk/jshell/HighlightUITest.java index 22403d5ae7e..77fb07a1632 100644 --- a/test/langtools/jdk/jshell/HighlightUITest.java +++ b/test/langtools/jdk/jshell/HighlightUITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 diff --git a/test/langtools/jdk/jshell/Presets.java b/test/langtools/jdk/jshell/Presets.java index afe193ee5c3..1d8e277dbdd 100644 --- a/test/langtools/jdk/jshell/Presets.java +++ b/test/langtools/jdk/jshell/Presets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/langtools/tools/javac/6457284/T6457284.java b/test/langtools/tools/javac/6457284/T6457284.java index f40d569ad91..939f10013c0 100644 --- a/test/langtools/tools/javac/6457284/T6457284.java +++ b/test/langtools/tools/javac/6457284/T6457284.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/OverrideChecks/InterfaceImplements.java b/test/langtools/tools/javac/OverrideChecks/InterfaceImplements.java index bb248b13ea1..ea172364bf7 100644 --- a/test/langtools/tools/javac/OverrideChecks/InterfaceImplements.java +++ b/test/langtools/tools/javac/OverrideChecks/InterfaceImplements.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/OverrideChecks/InterfaceOverride.java b/test/langtools/tools/javac/OverrideChecks/InterfaceOverride.java index 0b7b9de6857..387449fc940 100644 --- a/test/langtools/tools/javac/OverrideChecks/InterfaceOverride.java +++ b/test/langtools/tools/javac/OverrideChecks/InterfaceOverride.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/OverrideChecks/T6326485.java b/test/langtools/tools/javac/OverrideChecks/T6326485.java index 76b3e64f954..6bd809e43bf 100644 --- a/test/langtools/tools/javac/OverrideChecks/T6326485.java +++ b/test/langtools/tools/javac/OverrideChecks/T6326485.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/T4093617/T4093617.java b/test/langtools/tools/javac/T4093617/T4093617.java index 35b6dcaadb8..2d999d9fa3c 100644 --- a/test/langtools/tools/javac/T4093617/T4093617.java +++ b/test/langtools/tools/javac/T4093617/T4093617.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/test/langtools/tools/javac/T5092545.java b/test/langtools/tools/javac/T5092545.java index 0191c789e6c..5b794682bc4 100644 --- a/test/langtools/tools/javac/T5092545.java +++ b/test/langtools/tools/javac/T5092545.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, 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 diff --git a/test/langtools/tools/javac/T5105890.java b/test/langtools/tools/javac/T5105890.java index 12e579a8349..534d598ac59 100644 --- a/test/langtools/tools/javac/T5105890.java +++ b/test/langtools/tools/javac/T5105890.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, 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 diff --git a/test/langtools/tools/javac/T6180021/AbstractSub.java b/test/langtools/tools/javac/T6180021/AbstractSub.java index 67334bdfc71..b909e3f8a3a 100644 --- a/test/langtools/tools/javac/T6180021/AbstractSub.java +++ b/test/langtools/tools/javac/T6180021/AbstractSub.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/T6180021/Sub.java b/test/langtools/tools/javac/T6180021/Sub.java index 3233b9a2bf0..6172e077c61 100644 --- a/test/langtools/tools/javac/T6180021/Sub.java +++ b/test/langtools/tools/javac/T6180021/Sub.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/T6231246/T6231246.java b/test/langtools/tools/javac/T6231246/T6231246.java index 34835d9e454..b067a2f494d 100644 --- a/test/langtools/tools/javac/T6231246/T6231246.java +++ b/test/langtools/tools/javac/T6231246/T6231246.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/T6266772.java b/test/langtools/tools/javac/T6266772.java index 79ae48a28fc..9a69f969d14 100644 --- a/test/langtools/tools/javac/T6266772.java +++ b/test/langtools/tools/javac/T6266772.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/T6358024.java b/test/langtools/tools/javac/T6358024.java index 7388ce55cef..6ccf2b332b8 100644 --- a/test/langtools/tools/javac/T6358024.java +++ b/test/langtools/tools/javac/T6358024.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/T6358166.java b/test/langtools/tools/javac/T6358166.java index d3d4b2ae162..20b83997c0e 100644 --- a/test/langtools/tools/javac/T6358166.java +++ b/test/langtools/tools/javac/T6358166.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/T6361619.java b/test/langtools/tools/javac/T6361619.java index 1f299a8f4c3..97c4e629bbe 100644 --- a/test/langtools/tools/javac/T6361619.java +++ b/test/langtools/tools/javac/T6361619.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/T6395974.java b/test/langtools/tools/javac/T6395974.java index 623a9563695..b88f775861d 100644 --- a/test/langtools/tools/javac/T6395974.java +++ b/test/langtools/tools/javac/T6395974.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/T6397286.java b/test/langtools/tools/javac/T6397286.java index 8e8ef882aa2..a7d4caa03dc 100644 --- a/test/langtools/tools/javac/T6397286.java +++ b/test/langtools/tools/javac/T6397286.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/T6458823/T6458823.java b/test/langtools/tools/javac/T6458823/T6458823.java index cd23066edc8..bb536928f5a 100644 --- a/test/langtools/tools/javac/T6458823/T6458823.java +++ b/test/langtools/tools/javac/T6458823/T6458823.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, 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 diff --git a/test/langtools/tools/javac/TryWithResources/InterruptedExceptionTest.java b/test/langtools/tools/javac/TryWithResources/InterruptedExceptionTest.java index 05317b00492..fd765b219d5 100644 --- a/test/langtools/tools/javac/TryWithResources/InterruptedExceptionTest.java +++ b/test/langtools/tools/javac/TryWithResources/InterruptedExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/test/langtools/tools/javac/TryWithResources/TwrAvoidNullCheck.java b/test/langtools/tools/javac/TryWithResources/TwrAvoidNullCheck.java index 045558374c7..07b664165ab 100644 --- a/test/langtools/tools/javac/TryWithResources/TwrAvoidNullCheck.java +++ b/test/langtools/tools/javac/TryWithResources/TwrAvoidNullCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/test/langtools/tools/javac/TryWithResources/TwrSimpleClose.java b/test/langtools/tools/javac/TryWithResources/TwrSimpleClose.java index 11691a43040..a28a9108478 100644 --- a/test/langtools/tools/javac/TryWithResources/TwrSimpleClose.java +++ b/test/langtools/tools/javac/TryWithResources/TwrSimpleClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/langtools/tools/javac/annotations/crash_empty_enum_const/CrashEmptyEnumConstructorTest.java b/test/langtools/tools/javac/annotations/crash_empty_enum_const/CrashEmptyEnumConstructorTest.java index 865c53a19c3..e21ad3d6221 100644 --- a/test/langtools/tools/javac/annotations/crash_empty_enum_const/CrashEmptyEnumConstructorTest.java +++ b/test/langtools/tools/javac/annotations/crash_empty_enum_const/CrashEmptyEnumConstructorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/langtools/tools/javac/annotations/pos/AnnotationMethods.java b/test/langtools/tools/javac/annotations/pos/AnnotationMethods.java index 129fe57b667..62ec14dff07 100644 --- a/test/langtools/tools/javac/annotations/pos/AnnotationMethods.java +++ b/test/langtools/tools/javac/annotations/pos/AnnotationMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6400303/T6400303.java b/test/langtools/tools/javac/api/6400303/T6400303.java index c3a01c007b3..c64bf6720c7 100644 --- a/test/langtools/tools/javac/api/6400303/T6400303.java +++ b/test/langtools/tools/javac/api/6400303/T6400303.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6406133/T6406133.java b/test/langtools/tools/javac/api/6406133/T6406133.java index 24ddba1e602..aee9588e68e 100644 --- a/test/langtools/tools/javac/api/6406133/T6406133.java +++ b/test/langtools/tools/javac/api/6406133/T6406133.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 diff --git a/test/langtools/tools/javac/api/6410643/T6410643.java b/test/langtools/tools/javac/api/6410643/T6410643.java index d8f5c798249..84728988c49 100644 --- a/test/langtools/tools/javac/api/6410643/T6410643.java +++ b/test/langtools/tools/javac/api/6410643/T6410643.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6411310/T6411310.java b/test/langtools/tools/javac/api/6411310/T6411310.java index 2714117962f..99747453283 100644 --- a/test/langtools/tools/javac/api/6411310/T6411310.java +++ b/test/langtools/tools/javac/api/6411310/T6411310.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6411333/T6411333.java b/test/langtools/tools/javac/api/6411333/T6411333.java index 83726143964..101375e5f7a 100644 --- a/test/langtools/tools/javac/api/6411333/T6411333.java +++ b/test/langtools/tools/javac/api/6411333/T6411333.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6412656/T6412656.java b/test/langtools/tools/javac/api/6412656/T6412656.java index cfea162ae98..72a9d42088b 100644 --- a/test/langtools/tools/javac/api/6412656/T6412656.java +++ b/test/langtools/tools/javac/api/6412656/T6412656.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6415780/T6415780.java b/test/langtools/tools/javac/api/6415780/T6415780.java index 99c0a476bee..6887e15410b 100644 --- a/test/langtools/tools/javac/api/6415780/T6415780.java +++ b/test/langtools/tools/javac/api/6415780/T6415780.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6418694/T6418694.java b/test/langtools/tools/javac/api/6418694/T6418694.java index 9e8ee8e850b..acb6c148e7b 100644 --- a/test/langtools/tools/javac/api/6418694/T6418694.java +++ b/test/langtools/tools/javac/api/6418694/T6418694.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6420409/T6420409.java b/test/langtools/tools/javac/api/6420409/T6420409.java index d12274f5f3b..9e1456560d0 100644 --- a/test/langtools/tools/javac/api/6420409/T6420409.java +++ b/test/langtools/tools/javac/api/6420409/T6420409.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6421111/T6421111.java b/test/langtools/tools/javac/api/6421111/T6421111.java index 9497e2ca22f..932f3ab3bdf 100644 --- a/test/langtools/tools/javac/api/6421111/T6421111.java +++ b/test/langtools/tools/javac/api/6421111/T6421111.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6421756/T6421756.java b/test/langtools/tools/javac/api/6421756/T6421756.java index 00efff6971c..f28253258fb 100644 --- a/test/langtools/tools/javac/api/6421756/T6421756.java +++ b/test/langtools/tools/javac/api/6421756/T6421756.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6422215/T6422215.java b/test/langtools/tools/javac/api/6422215/T6422215.java index 425d47616f0..f010ba8e91a 100644 --- a/test/langtools/tools/javac/api/6422215/T6422215.java +++ b/test/langtools/tools/javac/api/6422215/T6422215.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6422327/T6422327.java b/test/langtools/tools/javac/api/6422327/T6422327.java index 94a31101f16..13c90a06e4d 100644 --- a/test/langtools/tools/javac/api/6422327/T6422327.java +++ b/test/langtools/tools/javac/api/6422327/T6422327.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6423003/T6423003.java b/test/langtools/tools/javac/api/6423003/T6423003.java index 58d055e9685..6fb07a73ecf 100644 --- a/test/langtools/tools/javac/api/6423003/T6423003.java +++ b/test/langtools/tools/javac/api/6423003/T6423003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6431257/T6431257.java b/test/langtools/tools/javac/api/6431257/T6431257.java index c772a3c129c..23a45cd85fc 100644 --- a/test/langtools/tools/javac/api/6431257/T6431257.java +++ b/test/langtools/tools/javac/api/6431257/T6431257.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6437999/T6437999.java b/test/langtools/tools/javac/api/6437999/T6437999.java index 167c7feda11..0e669b681bf 100644 --- a/test/langtools/tools/javac/api/6437999/T6437999.java +++ b/test/langtools/tools/javac/api/6437999/T6437999.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6440333/T6440333.java b/test/langtools/tools/javac/api/6440333/T6440333.java index 5da878273b3..c7faca8d48f 100644 --- a/test/langtools/tools/javac/api/6440333/T6440333.java +++ b/test/langtools/tools/javac/api/6440333/T6440333.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6440528/T6440528.java b/test/langtools/tools/javac/api/6440528/T6440528.java index 3b72fd39255..3407f819e86 100644 --- a/test/langtools/tools/javac/api/6440528/T6440528.java +++ b/test/langtools/tools/javac/api/6440528/T6440528.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6452876/T6452876.java b/test/langtools/tools/javac/api/6452876/T6452876.java index 49a25a3bd32..47f9501e917 100644 --- a/test/langtools/tools/javac/api/6452876/T6452876.java +++ b/test/langtools/tools/javac/api/6452876/T6452876.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6468404/T6468404.java b/test/langtools/tools/javac/api/6468404/T6468404.java index c06e37e84b8..2e42d3d056f 100644 --- a/test/langtools/tools/javac/api/6468404/T6468404.java +++ b/test/langtools/tools/javac/api/6468404/T6468404.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6471599/Main.java b/test/langtools/tools/javac/api/6471599/Main.java index fa66ecc51d3..8d88514d64b 100644 --- a/test/langtools/tools/javac/api/6471599/Main.java +++ b/test/langtools/tools/javac/api/6471599/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/6731573/T6731573.java b/test/langtools/tools/javac/api/6731573/T6731573.java index 892b8e63ffb..b06ae9ce4d6 100644 --- a/test/langtools/tools/javac/api/6731573/T6731573.java +++ b/test/langtools/tools/javac/api/6731573/T6731573.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 diff --git a/test/langtools/tools/javac/api/7086261/T7086261.java b/test/langtools/tools/javac/api/7086261/T7086261.java index 391e71c94a7..364e9bf54a5 100644 --- a/test/langtools/tools/javac/api/7086261/T7086261.java +++ b/test/langtools/tools/javac/api/7086261/T7086261.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/test/langtools/tools/javac/api/8007344/Test.java b/test/langtools/tools/javac/api/8007344/Test.java index d230fb6086b..b8d4a8bb49f 100644 --- a/test/langtools/tools/javac/api/8007344/Test.java +++ b/test/langtools/tools/javac/api/8007344/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, 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 diff --git a/test/langtools/tools/javac/api/DiagSpans.java b/test/langtools/tools/javac/api/DiagSpans.java index 527fe1aad62..d6fbfa0b2fd 100644 --- a/test/langtools/tools/javac/api/DiagSpans.java +++ b/test/langtools/tools/javac/api/DiagSpans.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/test/langtools/tools/javac/api/Sibling.java b/test/langtools/tools/javac/api/Sibling.java index d70548caa63..d4007616e70 100644 --- a/test/langtools/tools/javac/api/Sibling.java +++ b/test/langtools/tools/javac/api/Sibling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/T6257235.java b/test/langtools/tools/javac/api/T6257235.java index 095d2e83d3b..08c6da7a972 100644 --- a/test/langtools/tools/javac/api/T6257235.java +++ b/test/langtools/tools/javac/api/T6257235.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/api/T6258271.java b/test/langtools/tools/javac/api/T6258271.java index 2092f5825a0..c1292aae35a 100644 --- a/test/langtools/tools/javac/api/T6258271.java +++ b/test/langtools/tools/javac/api/T6258271.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/api/T6265137.java b/test/langtools/tools/javac/api/T6265137.java index 2a8a1fcb9ad..47db903a65f 100644 --- a/test/langtools/tools/javac/api/T6265137.java +++ b/test/langtools/tools/javac/api/T6265137.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/api/T6306137.java b/test/langtools/tools/javac/api/T6306137.java index fe443950e52..b96a78c6d4c 100644 --- a/test/langtools/tools/javac/api/T6306137.java +++ b/test/langtools/tools/javac/api/T6306137.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/api/T6357331.java b/test/langtools/tools/javac/api/T6357331.java index 0bc4ff98a53..bd8c0d24662 100644 --- a/test/langtools/tools/javac/api/T6357331.java +++ b/test/langtools/tools/javac/api/T6357331.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/T6358786.java b/test/langtools/tools/javac/api/T6358786.java index f8ffb829b2a..063f04baf2a 100644 --- a/test/langtools/tools/javac/api/T6358786.java +++ b/test/langtools/tools/javac/api/T6358786.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/api/T6397104.java b/test/langtools/tools/javac/api/T6397104.java index 7d63c322371..028776e8609 100644 --- a/test/langtools/tools/javac/api/T6397104.java +++ b/test/langtools/tools/javac/api/T6397104.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/T6400205.java b/test/langtools/tools/javac/api/T6400205.java index a942e7c6624..ed5511c3c1e 100644 --- a/test/langtools/tools/javac/api/T6400205.java +++ b/test/langtools/tools/javac/api/T6400205.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/T6400207.java b/test/langtools/tools/javac/api/T6400207.java index 47bf297ce72..6adee3d4999 100644 --- a/test/langtools/tools/javac/api/T6400207.java +++ b/test/langtools/tools/javac/api/T6400207.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/T6407011.java b/test/langtools/tools/javac/api/T6407011.java index 9991efd1a5d..a1ee74ca19b 100644 --- a/test/langtools/tools/javac/api/T6407011.java +++ b/test/langtools/tools/javac/api/T6407011.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/TestEvalExpression.java b/test/langtools/tools/javac/api/TestEvalExpression.java index 41e61548d55..d5dc383c65d 100644 --- a/test/langtools/tools/javac/api/TestEvalExpression.java +++ b/test/langtools/tools/javac/api/TestEvalExpression.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/api/TestGetTree.java b/test/langtools/tools/javac/api/TestGetTree.java index 545645a3541..2d7659188fa 100644 --- a/test/langtools/tools/javac/api/TestGetTree.java +++ b/test/langtools/tools/javac/api/TestGetTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/api/TestJavacTask.java b/test/langtools/tools/javac/api/TestJavacTask.java index 2d86a732a41..ab0119fbe23 100644 --- a/test/langtools/tools/javac/api/TestJavacTask.java +++ b/test/langtools/tools/javac/api/TestJavacTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/api/TestJavacTaskScanner.java b/test/langtools/tools/javac/api/TestJavacTaskScanner.java index 4f920d96fb0..b391b45e459 100644 --- a/test/langtools/tools/javac/api/TestJavacTaskScanner.java +++ b/test/langtools/tools/javac/api/TestJavacTaskScanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/api/TestOperators.java b/test/langtools/tools/javac/api/TestOperators.java index 99448e3e389..62d4b51341a 100644 --- a/test/langtools/tools/javac/api/TestOperators.java +++ b/test/langtools/tools/javac/api/TestOperators.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/api/TestResolveIdent.java b/test/langtools/tools/javac/api/TestResolveIdent.java index d5f5a6bb93e..aa2d2b5dff1 100644 --- a/test/langtools/tools/javac/api/TestResolveIdent.java +++ b/test/langtools/tools/javac/api/TestResolveIdent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/TestTreePath.java b/test/langtools/tools/javac/api/TestTreePath.java index 7a016f42545..089bee71b21 100644 --- a/test/langtools/tools/javac/api/TestTreePath.java +++ b/test/langtools/tools/javac/api/TestTreePath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/guide/Test.java b/test/langtools/tools/javac/api/guide/Test.java index 5bf881a590c..7ec840aaf81 100644 --- a/test/langtools/tools/javac/api/guide/Test.java +++ b/test/langtools/tools/javac/api/guide/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/api/taskListeners/EventsBalancedTest.java b/test/langtools/tools/javac/api/taskListeners/EventsBalancedTest.java index 759ec8d66ac..8c6dc156c15 100644 --- a/test/langtools/tools/javac/api/taskListeners/EventsBalancedTest.java +++ b/test/langtools/tools/javac/api/taskListeners/EventsBalancedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 diff --git a/test/langtools/tools/javac/boxing/T6348760.java b/test/langtools/tools/javac/boxing/T6348760.java index 010bcbfd324..c573f858a83 100644 --- a/test/langtools/tools/javac/boxing/T6348760.java +++ b/test/langtools/tools/javac/boxing/T6348760.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/cast/5043020/T5043020.java b/test/langtools/tools/javac/cast/5043020/T5043020.java index 13152c57a64..0653a15f9db 100644 --- a/test/langtools/tools/javac/cast/5043020/T5043020.java +++ b/test/langtools/tools/javac/cast/5043020/T5043020.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/cast/6302214/T6302214a.java b/test/langtools/tools/javac/cast/6302214/T6302214a.java index eeb8735e4a4..578c20f584a 100644 --- a/test/langtools/tools/javac/cast/6302214/T6302214a.java +++ b/test/langtools/tools/javac/cast/6302214/T6302214a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/diags/ArgTypeCompilerFactory.java b/test/langtools/tools/javac/diags/ArgTypeCompilerFactory.java index 823a0f01a7f..92a84963d65 100644 --- a/test/langtools/tools/javac/diags/ArgTypeCompilerFactory.java +++ b/test/langtools/tools/javac/diags/ArgTypeCompilerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, 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 diff --git a/test/langtools/tools/javac/diags/CheckResourceKeys.java b/test/langtools/tools/javac/diags/CheckResourceKeys.java index 1675d99275e..b29fffd4148 100644 --- a/test/langtools/tools/javac/diags/CheckResourceKeys.java +++ b/test/langtools/tools/javac/diags/CheckResourceKeys.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2024, 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 diff --git a/test/langtools/tools/javac/diags/examples/AttemptToSynchronizeOnInstanceOfVbc.java b/test/langtools/tools/javac/diags/examples/AttemptToSynchronizeOnInstanceOfVbc.java index e677c4b3b8a..53a197ab741 100644 --- a/test/langtools/tools/javac/diags/examples/AttemptToSynchronizeOnInstanceOfVbc.java +++ b/test/langtools/tools/javac/diags/examples/AttemptToSynchronizeOnInstanceOfVbc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/test/langtools/tools/javac/diags/examples/ImportModule.java b/test/langtools/tools/javac/diags/examples/ImportModule.java index f924a59acd4..7a7363e90d3 100644 --- a/test/langtools/tools/javac/diags/examples/ImportModule.java +++ b/test/langtools/tools/javac/diags/examples/ImportModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 diff --git a/test/langtools/tools/javac/diags/examples/ImportModuleDoesNotRead/module-info.java b/test/langtools/tools/javac/diags/examples/ImportModuleDoesNotRead/module-info.java index 8c84bc009da..3450348de58 100644 --- a/test/langtools/tools/javac/diags/examples/ImportModuleDoesNotRead/module-info.java +++ b/test/langtools/tools/javac/diags/examples/ImportModuleDoesNotRead/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 diff --git a/test/langtools/tools/javac/diags/examples/ImportModuleDoesNotReadUnnamed.java b/test/langtools/tools/javac/diags/examples/ImportModuleDoesNotReadUnnamed.java index d25e7593170..c00b8592fd7 100644 --- a/test/langtools/tools/javac/diags/examples/ImportModuleDoesNotReadUnnamed.java +++ b/test/langtools/tools/javac/diags/examples/ImportModuleDoesNotReadUnnamed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 diff --git a/test/langtools/tools/javac/diags/examples/ImportModuleNotFound.java b/test/langtools/tools/javac/diags/examples/ImportModuleNotFound.java index 7e5f98e1a36..fb52bc02188 100644 --- a/test/langtools/tools/javac/diags/examples/ImportModuleNotFound.java +++ b/test/langtools/tools/javac/diags/examples/ImportModuleNotFound.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 diff --git a/test/langtools/tools/javac/diags/examples/ReturnBeforeSuperclassInit.java b/test/langtools/tools/javac/diags/examples/ReturnBeforeSuperclassInit.java index 033a8430625..01fc5e7a5a1 100644 --- a/test/langtools/tools/javac/diags/examples/ReturnBeforeSuperclassInit.java +++ b/test/langtools/tools/javac/diags/examples/ReturnBeforeSuperclassInit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/langtools/tools/javac/diags/examples/TryResourceThrowsInterruptedExc.java b/test/langtools/tools/javac/diags/examples/TryResourceThrowsInterruptedExc.java index 6d24a6c2a83..0fbcf3e2368 100644 --- a/test/langtools/tools/javac/diags/examples/TryResourceThrowsInterruptedExc.java +++ b/test/langtools/tools/javac/diags/examples/TryResourceThrowsInterruptedExc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/test/langtools/tools/javac/enum/6424358/T6424358.java b/test/langtools/tools/javac/enum/6424358/T6424358.java index 6a5d403ada5..535b1ddd7f3 100644 --- a/test/langtools/tools/javac/enum/6424358/T6424358.java +++ b/test/langtools/tools/javac/enum/6424358/T6424358.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/enum/OkFinal.java b/test/langtools/tools/javac/enum/OkFinal.java index a37de61ae5c..385e7998617 100644 --- a/test/langtools/tools/javac/enum/OkFinal.java +++ b/test/langtools/tools/javac/enum/OkFinal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, 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 diff --git a/test/langtools/tools/javac/enum/T5075242.java b/test/langtools/tools/javac/enum/T5075242.java index 29e90bd39fd..6ada9e94ec4 100644 --- a/test/langtools/tools/javac/enum/T5075242.java +++ b/test/langtools/tools/javac/enum/T5075242.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 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 diff --git a/test/langtools/tools/javac/fatalErrors/ImproveFatalErrorHandling.java b/test/langtools/tools/javac/fatalErrors/ImproveFatalErrorHandling.java index 278d8863b4a..9db0199d4b2 100644 --- a/test/langtools/tools/javac/fatalErrors/ImproveFatalErrorHandling.java +++ b/test/langtools/tools/javac/fatalErrors/ImproveFatalErrorHandling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/test/langtools/tools/javac/generics/5086027/T5086027pos.java b/test/langtools/tools/javac/generics/5086027/T5086027pos.java index e1b00372580..c8be3a6156c 100644 --- a/test/langtools/tools/javac/generics/5086027/T5086027pos.java +++ b/test/langtools/tools/javac/generics/5086027/T5086027pos.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/6192945/Method.java b/test/langtools/tools/javac/generics/6192945/Method.java index 0d3698ad75d..96b63e817bb 100644 --- a/test/langtools/tools/javac/generics/6192945/Method.java +++ b/test/langtools/tools/javac/generics/6192945/Method.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/6207386/Test.java b/test/langtools/tools/javac/generics/6207386/Test.java index 7725abb6ceb..80bf99268a4 100644 --- a/test/langtools/tools/javac/generics/6207386/Test.java +++ b/test/langtools/tools/javac/generics/6207386/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/generics/6227936/T6227936.java b/test/langtools/tools/javac/generics/6227936/T6227936.java index 8a9b32261a5..1ecb0762204 100644 --- a/test/langtools/tools/javac/generics/6227936/T6227936.java +++ b/test/langtools/tools/javac/generics/6227936/T6227936.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/generics/6245699/T6245699c.java b/test/langtools/tools/javac/generics/6245699/T6245699c.java index 5105684a7c2..0db1fc5a230 100644 --- a/test/langtools/tools/javac/generics/6245699/T6245699c.java +++ b/test/langtools/tools/javac/generics/6245699/T6245699c.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/generics/6292765/T6292765.java b/test/langtools/tools/javac/generics/6292765/T6292765.java index c58127f15f1..331645b5bad 100644 --- a/test/langtools/tools/javac/generics/6292765/T6292765.java +++ b/test/langtools/tools/javac/generics/6292765/T6292765.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/6332204/T6332204.java b/test/langtools/tools/javac/generics/6332204/T6332204.java index 6c61304cc6d..fd04b9fd5d0 100644 --- a/test/langtools/tools/javac/generics/6332204/T6332204.java +++ b/test/langtools/tools/javac/generics/6332204/T6332204.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/generics/6413682/TestPos.java b/test/langtools/tools/javac/generics/6413682/TestPos.java index 1da09adc591..73143545917 100644 --- a/test/langtools/tools/javac/generics/6413682/TestPos.java +++ b/test/langtools/tools/javac/generics/6413682/TestPos.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/T6391995.java b/test/langtools/tools/javac/generics/T6391995.java index ef01a6405b2..3e992c36762 100644 --- a/test/langtools/tools/javac/generics/T6391995.java +++ b/test/langtools/tools/javac/generics/T6391995.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/inference/5073060/T5073060a.java b/test/langtools/tools/javac/generics/inference/5073060/T5073060a.java index be3364099b9..07004cef0fb 100644 --- a/test/langtools/tools/javac/generics/inference/5073060/T5073060a.java +++ b/test/langtools/tools/javac/generics/inference/5073060/T5073060a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/inference/5081782/Pos.java b/test/langtools/tools/javac/generics/inference/5081782/Pos.java index 5a0b3eb88ee..c9ea9affa35 100644 --- a/test/langtools/tools/javac/generics/inference/5081782/Pos.java +++ b/test/langtools/tools/javac/generics/inference/5081782/Pos.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/inference/6215213/T6215213.java b/test/langtools/tools/javac/generics/inference/6215213/T6215213.java index 98dd5ff1e3f..cedc2368677 100644 --- a/test/langtools/tools/javac/generics/inference/6215213/T6215213.java +++ b/test/langtools/tools/javac/generics/inference/6215213/T6215213.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/generics/inference/6278587/T6278587.java b/test/langtools/tools/javac/generics/inference/6278587/T6278587.java index 76d7bdb4e8b..bdb34d580b7 100644 --- a/test/langtools/tools/javac/generics/inference/6278587/T6278587.java +++ b/test/langtools/tools/javac/generics/inference/6278587/T6278587.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/inference/6302954/T6456971.java b/test/langtools/tools/javac/generics/inference/6302954/T6456971.java index 03ba90132ae..6b206310d98 100644 --- a/test/langtools/tools/javac/generics/inference/6302954/T6456971.java +++ b/test/langtools/tools/javac/generics/inference/6302954/T6456971.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/inference/6359106/T6359106.java b/test/langtools/tools/javac/generics/inference/6359106/T6359106.java index 478cbf465c2..7c87d91ad3f 100644 --- a/test/langtools/tools/javac/generics/inference/6359106/T6359106.java +++ b/test/langtools/tools/javac/generics/inference/6359106/T6359106.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/generics/rawOverride/AttributeSet.java b/test/langtools/tools/javac/generics/rawOverride/AttributeSet.java index c09dbdb29ff..e9f15bc25c5 100644 --- a/test/langtools/tools/javac/generics/rawOverride/AttributeSet.java +++ b/test/langtools/tools/javac/generics/rawOverride/AttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 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 diff --git a/test/langtools/tools/javac/generics/rawOverride/T6178365.java b/test/langtools/tools/javac/generics/rawOverride/T6178365.java index 9a7a97c76aa..a7000ccb99c 100644 --- a/test/langtools/tools/javac/generics/rawOverride/T6178365.java +++ b/test/langtools/tools/javac/generics/rawOverride/T6178365.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, 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 diff --git a/test/langtools/tools/javac/generics/typevars/4856983/T4856983.java b/test/langtools/tools/javac/generics/typevars/4856983/T4856983.java index ceac89e0397..ea1419b298e 100644 --- a/test/langtools/tools/javac/generics/typevars/4856983/T4856983.java +++ b/test/langtools/tools/javac/generics/typevars/4856983/T4856983.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, 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 diff --git a/test/langtools/tools/javac/generics/typevars/5060485/Method.java b/test/langtools/tools/javac/generics/typevars/5060485/Method.java index 2603727b411..a428962615c 100644 --- a/test/langtools/tools/javac/generics/typevars/5060485/Method.java +++ b/test/langtools/tools/javac/generics/typevars/5060485/Method.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/typevars/5060485/Pos.java b/test/langtools/tools/javac/generics/typevars/5060485/Pos.java index 29cc91f0c04..167d54417de 100644 --- a/test/langtools/tools/javac/generics/typevars/5060485/Pos.java +++ b/test/langtools/tools/javac/generics/typevars/5060485/Pos.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/generics/wildcards/6330931/T6330931.java b/test/langtools/tools/javac/generics/wildcards/6330931/T6330931.java index db551e72b1e..6c274619cd8 100644 --- a/test/langtools/tools/javac/generics/wildcards/6330931/T6330931.java +++ b/test/langtools/tools/javac/generics/wildcards/6330931/T6330931.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/generics/wildcards/T5097548.java b/test/langtools/tools/javac/generics/wildcards/T5097548.java index 46459ffa675..1a75210fb42 100644 --- a/test/langtools/tools/javac/generics/wildcards/T5097548.java +++ b/test/langtools/tools/javac/generics/wildcards/T5097548.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, 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 diff --git a/test/langtools/tools/javac/generics/wildcards/T5097548b.java b/test/langtools/tools/javac/generics/wildcards/T5097548b.java index 2ce974fb2ca..5048acf6176 100644 --- a/test/langtools/tools/javac/generics/wildcards/T5097548b.java +++ b/test/langtools/tools/javac/generics/wildcards/T5097548b.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, 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 diff --git a/test/langtools/tools/javac/jvm/6397652/T6397652.java b/test/langtools/tools/javac/jvm/6397652/T6397652.java index 3b6c78f4ed5..a27083902ee 100644 --- a/test/langtools/tools/javac/jvm/6397652/T6397652.java +++ b/test/langtools/tools/javac/jvm/6397652/T6397652.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/lambda/LambdaExpr02.java b/test/langtools/tools/javac/lambda/LambdaExpr02.java index d3526b54373..4f8e912fa4b 100644 --- a/test/langtools/tools/javac/lambda/LambdaExpr02.java +++ b/test/langtools/tools/javac/lambda/LambdaExpr02.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/test/langtools/tools/javac/lib/DPrinter.java b/test/langtools/tools/javac/lib/DPrinter.java index 5092e0698c2..3f89d459166 100644 --- a/test/langtools/tools/javac/lib/DPrinter.java +++ b/test/langtools/tools/javac/lib/DPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/test/langtools/tools/javac/modules/AddModulesTest.java b/test/langtools/tools/javac/modules/AddModulesTest.java index 080a5edda27..6f5d671e5fb 100644 --- a/test/langtools/tools/javac/modules/AddModulesTest.java +++ b/test/langtools/tools/javac/modules/AddModulesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 diff --git a/test/langtools/tools/javac/modules/ConvenientAccessErrorsTest.java b/test/langtools/tools/javac/modules/ConvenientAccessErrorsTest.java index d02f7816814..79972723167 100644 --- a/test/langtools/tools/javac/modules/ConvenientAccessErrorsTest.java +++ b/test/langtools/tools/javac/modules/ConvenientAccessErrorsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/test/langtools/tools/javac/modules/EdgeCases.java b/test/langtools/tools/javac/modules/EdgeCases.java index 39b72dda03a..187ff5ed277 100644 --- a/test/langtools/tools/javac/modules/EdgeCases.java +++ b/test/langtools/tools/javac/modules/EdgeCases.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 diff --git a/test/langtools/tools/javac/modules/QueryBeforeEnter.java b/test/langtools/tools/javac/modules/QueryBeforeEnter.java index 293b6302eec..e37c0348e9d 100644 --- a/test/langtools/tools/javac/modules/QueryBeforeEnter.java +++ b/test/langtools/tools/javac/modules/QueryBeforeEnter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/test/langtools/tools/javac/multicatch/Pos10.java b/test/langtools/tools/javac/multicatch/Pos10.java index d108c8f9671..d6650cfe53e 100644 --- a/test/langtools/tools/javac/multicatch/Pos10.java +++ b/test/langtools/tools/javac/multicatch/Pos10.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 diff --git a/test/langtools/tools/javac/overload/T4494762.java b/test/langtools/tools/javac/overload/T4494762.java index bc4c7c7ab62..f1d30d432fb 100644 --- a/test/langtools/tools/javac/overload/T4494762.java +++ b/test/langtools/tools/javac/overload/T4494762.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/patterns/Domination.java b/test/langtools/tools/javac/patterns/Domination.java index dd9d1153696..416f75494c1 100644 --- a/test/langtools/tools/javac/patterns/Domination.java +++ b/test/langtools/tools/javac/patterns/Domination.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 diff --git a/test/langtools/tools/javac/patterns/PrettyTest.java b/test/langtools/tools/javac/patterns/PrettyTest.java index 5f9c74b760e..420d3a16020 100644 --- a/test/langtools/tools/javac/patterns/PrettyTest.java +++ b/test/langtools/tools/javac/patterns/PrettyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/test/langtools/tools/javac/patterns/SOEDeeplyNestedBlocksTest.java b/test/langtools/tools/javac/patterns/SOEDeeplyNestedBlocksTest.java index 8f64b4cff37..1c96f174f06 100644 --- a/test/langtools/tools/javac/patterns/SOEDeeplyNestedBlocksTest.java +++ b/test/langtools/tools/javac/patterns/SOEDeeplyNestedBlocksTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 diff --git a/test/langtools/tools/javac/patterns/T8332463a.java b/test/langtools/tools/javac/patterns/T8332463a.java index 2501a330af2..47da64366f8 100644 --- a/test/langtools/tools/javac/patterns/T8332463a.java +++ b/test/langtools/tools/javac/patterns/T8332463a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 diff --git a/test/langtools/tools/javac/patterns/T8332463b.java b/test/langtools/tools/javac/patterns/T8332463b.java index 73338b2bd8a..cfc1af8a43a 100644 --- a/test/langtools/tools/javac/patterns/T8332463b.java +++ b/test/langtools/tools/javac/patterns/T8332463b.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 diff --git a/test/langtools/tools/javac/positions/T6402077.java b/test/langtools/tools/javac/positions/T6402077.java index 66caa9c282e..2e067244658 100644 --- a/test/langtools/tools/javac/positions/T6402077.java +++ b/test/langtools/tools/javac/positions/T6402077.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/positions/T6404194.java b/test/langtools/tools/javac/positions/T6404194.java index 18b07ad8af1..939fcb0a7bb 100644 --- a/test/langtools/tools/javac/positions/T6404194.java +++ b/test/langtools/tools/javac/positions/T6404194.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/positions/TreeEndPosTest.java b/test/langtools/tools/javac/positions/TreeEndPosTest.java index dc87409f4b2..19478d268da 100644 --- a/test/langtools/tools/javac/positions/TreeEndPosTest.java +++ b/test/langtools/tools/javac/positions/TreeEndPosTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/test/langtools/tools/javac/processing/6348499/T6348499.java b/test/langtools/tools/javac/processing/6348499/T6348499.java index 266caa1e14f..870aacad8af 100644 --- a/test/langtools/tools/javac/processing/6348499/T6348499.java +++ b/test/langtools/tools/javac/processing/6348499/T6348499.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/processing/6359313/T6359313.java b/test/langtools/tools/javac/processing/6359313/T6359313.java index b3854099075..25a64245190 100644 --- a/test/langtools/tools/javac/processing/6359313/T6359313.java +++ b/test/langtools/tools/javac/processing/6359313/T6359313.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/processing/6413690/T6413690.java b/test/langtools/tools/javac/processing/6413690/T6413690.java index b0945991bd2..65706124b7d 100644 --- a/test/langtools/tools/javac/processing/6413690/T6413690.java +++ b/test/langtools/tools/javac/processing/6413690/T6413690.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/processing/6414633/T6414633.java b/test/langtools/tools/javac/processing/6414633/T6414633.java index 5ee7b5e646d..d2a88249b9d 100644 --- a/test/langtools/tools/javac/processing/6414633/T6414633.java +++ b/test/langtools/tools/javac/processing/6414633/T6414633.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/processing/6430209/T6430209.java b/test/langtools/tools/javac/processing/6430209/T6430209.java index 1371b7c09d6..7064d9bf428 100644 --- a/test/langtools/tools/javac/processing/6430209/T6430209.java +++ b/test/langtools/tools/javac/processing/6430209/T6430209.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/processing/T6439826.java b/test/langtools/tools/javac/processing/T6439826.java index fed293d4e5e..008dfd3942d 100644 --- a/test/langtools/tools/javac/processing/T6439826.java +++ b/test/langtools/tools/javac/processing/T6439826.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/processing/T8142931.java b/test/langtools/tools/javac/processing/T8142931.java index 8ade5e19767..77c07328124 100644 --- a/test/langtools/tools/javac/processing/T8142931.java +++ b/test/langtools/tools/javac/processing/T8142931.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 diff --git a/test/langtools/tools/javac/processing/errors/TestReturnCode.java b/test/langtools/tools/javac/processing/errors/TestReturnCode.java index 5ca6a50e3c6..10d962e1d4b 100644 --- a/test/langtools/tools/javac/processing/errors/TestReturnCode.java +++ b/test/langtools/tools/javac/processing/errors/TestReturnCode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/processing/filer/TestPackageInfo.java b/test/langtools/tools/javac/processing/filer/TestPackageInfo.java index 1b11c75acde..214be4e0cbe 100644 --- a/test/langtools/tools/javac/processing/filer/TestPackageInfo.java +++ b/test/langtools/tools/javac/processing/filer/TestPackageInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/processing/model/6194785/T6194785.java b/test/langtools/tools/javac/processing/model/6194785/T6194785.java index c8f09ba8c95..918741d967c 100644 --- a/test/langtools/tools/javac/processing/model/6194785/T6194785.java +++ b/test/langtools/tools/javac/processing/model/6194785/T6194785.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/processing/model/LocalInAnonymous.java b/test/langtools/tools/javac/processing/model/LocalInAnonymous.java index 616062bb542..4ee869e38b0 100644 --- a/test/langtools/tools/javac/processing/model/LocalInAnonymous.java +++ b/test/langtools/tools/javac/processing/model/LocalInAnonymous.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/test/langtools/tools/javac/processing/model/testgetallmembers/Main.java b/test/langtools/tools/javac/processing/model/testgetallmembers/Main.java index 4d35b9ae747..f861bf7a4a3 100644 --- a/test/langtools/tools/javac/processing/model/testgetallmembers/Main.java +++ b/test/langtools/tools/javac/processing/model/testgetallmembers/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/processing/options/TestNoteOnImplicitProcessing.java b/test/langtools/tools/javac/processing/options/TestNoteOnImplicitProcessing.java index 181c29eeb56..df2d5bfcd52 100644 --- a/test/langtools/tools/javac/processing/options/TestNoteOnImplicitProcessing.java +++ b/test/langtools/tools/javac/processing/options/TestNoteOnImplicitProcessing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 diff --git a/test/langtools/tools/javac/processing/options/Xprint.java b/test/langtools/tools/javac/processing/options/Xprint.java index 51df77afef9..d38baad6a92 100644 --- a/test/langtools/tools/javac/processing/options/Xprint.java +++ b/test/langtools/tools/javac/processing/options/Xprint.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/processing/rounds/CompleteOnClosed.java b/test/langtools/tools/javac/processing/rounds/CompleteOnClosed.java index f724d605e51..838ce124c99 100644 --- a/test/langtools/tools/javac/processing/rounds/CompleteOnClosed.java +++ b/test/langtools/tools/javac/processing/rounds/CompleteOnClosed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 diff --git a/test/langtools/tools/javac/scope/6225935/T6225935.java b/test/langtools/tools/javac/scope/6225935/T6225935.java index 555293ca030..9a43c047ee6 100644 --- a/test/langtools/tools/javac/scope/6225935/T6225935.java +++ b/test/langtools/tools/javac/scope/6225935/T6225935.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/scope/6225935/T6381787.java b/test/langtools/tools/javac/scope/6225935/T6381787.java index 7a658b9e5f8..1d18a1c3443 100644 --- a/test/langtools/tools/javac/scope/6225935/T6381787.java +++ b/test/langtools/tools/javac/scope/6225935/T6381787.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/scope/6225935/Test.java b/test/langtools/tools/javac/scope/6225935/Test.java index 1efc260c1fc..04fc6e3508c 100644 --- a/test/langtools/tools/javac/scope/6225935/Test.java +++ b/test/langtools/tools/javac/scope/6225935/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/scope/6392998/T6392998.java b/test/langtools/tools/javac/scope/6392998/T6392998.java index 353d9d56233..9360f06f5e3 100644 --- a/test/langtools/tools/javac/scope/6392998/T6392998.java +++ b/test/langtools/tools/javac/scope/6392998/T6392998.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/sealed/SealedDiffConfigurationsTest.java b/test/langtools/tools/javac/sealed/SealedDiffConfigurationsTest.java index ddadec7d862..d5ea509fbed 100644 --- a/test/langtools/tools/javac/sealed/SealedDiffConfigurationsTest.java +++ b/test/langtools/tools/javac/sealed/SealedDiffConfigurationsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 diff --git a/test/langtools/tools/javac/sym/ElementStructureTest.java b/test/langtools/tools/javac/sym/ElementStructureTest.java index 14fa194501a..16ab7f4fde4 100644 --- a/test/langtools/tools/javac/sym/ElementStructureTest.java +++ b/test/langtools/tools/javac/sym/ElementStructureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 diff --git a/test/langtools/tools/javac/tree/VarTree.java b/test/langtools/tools/javac/tree/VarTree.java index 2c70d5eb317..6efd080bd4f 100644 --- a/test/langtools/tools/javac/tree/VarTree.java +++ b/test/langtools/tools/javac/tree/VarTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 diff --git a/test/langtools/tools/javac/types/UnknownTypeTest.java b/test/langtools/tools/javac/types/UnknownTypeTest.java index e79c583f142..780c23c4004 100644 --- a/test/langtools/tools/javac/types/UnknownTypeTest.java +++ b/test/langtools/tools/javac/types/UnknownTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 diff --git a/test/langtools/tools/javac/unicode/FirstChar.java b/test/langtools/tools/javac/unicode/FirstChar.java index 261538ab91b..ebe63ebdda9 100644 --- a/test/langtools/tools/javac/unicode/FirstChar.java +++ b/test/langtools/tools/javac/unicode/FirstChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, 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 diff --git a/test/langtools/tools/javac/unit/T6198196.java b/test/langtools/tools/javac/unit/T6198196.java index 3c75cc34477..d1a57b20ba4 100644 --- a/test/langtools/tools/javac/unit/T6198196.java +++ b/test/langtools/tools/javac/unit/T6198196.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/unit/util/convert/EnclosingCandidates.java b/test/langtools/tools/javac/unit/util/convert/EnclosingCandidates.java index 7a96872f663..db318315a25 100644 --- a/test/langtools/tools/javac/unit/util/convert/EnclosingCandidates.java +++ b/test/langtools/tools/javac/unit/util/convert/EnclosingCandidates.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/javac/unit/util/list/AbstractList.java b/test/langtools/tools/javac/unit/util/list/AbstractList.java index 38cdd7c5e78..e392f595efe 100644 --- a/test/langtools/tools/javac/unit/util/list/AbstractList.java +++ b/test/langtools/tools/javac/unit/util/list/AbstractList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/unit/util/list/FromArray.java b/test/langtools/tools/javac/unit/util/list/FromArray.java index eabdb71e148..cac983c63ae 100644 --- a/test/langtools/tools/javac/unit/util/list/FromArray.java +++ b/test/langtools/tools/javac/unit/util/list/FromArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/test/langtools/tools/javac/util/filemanager/TestName.java b/test/langtools/tools/javac/util/filemanager/TestName.java index 23bb2b9c781..2435a1179d0 100644 --- a/test/langtools/tools/javac/util/filemanager/TestName.java +++ b/test/langtools/tools/javac/util/filemanager/TestName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java b/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java index 52db62dd41a..87099d44b48 100644 --- a/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java +++ b/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/test/langtools/tools/jnativescan/TestMissingSystemClass.java b/test/langtools/tools/jnativescan/TestMissingSystemClass.java index 8b6266aa5d7..2d2218b38c8 100644 --- a/test/langtools/tools/jnativescan/TestMissingSystemClass.java +++ b/test/langtools/tools/jnativescan/TestMissingSystemClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 diff --git a/test/langtools/tools/jnativescan/cases/classpath/missingsystem/App.java b/test/langtools/tools/jnativescan/cases/classpath/missingsystem/App.java index 05812be45ce..f863d1e6618 100644 --- a/test/langtools/tools/jnativescan/cases/classpath/missingsystem/App.java +++ b/test/langtools/tools/jnativescan/cases/classpath/missingsystem/App.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 diff --git a/test/langtools/tools/lib/toolbox/JavacTask.java b/test/langtools/tools/lib/toolbox/JavacTask.java index c067764c9d3..9eaa6b62605 100644 --- a/test/langtools/tools/lib/toolbox/JavacTask.java +++ b/test/langtools/tools/lib/toolbox/JavacTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/test/langtools/tools/lib/types/TypeHarness.java b/test/langtools/tools/lib/types/TypeHarness.java index 296ea8d3f9b..8bb0981f9bf 100644 --- a/test/langtools/tools/lib/types/TypeHarness.java +++ b/test/langtools/tools/lib/types/TypeHarness.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, 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 diff --git a/test/lib/jdk/test/lib/NetworkConfiguration.java b/test/lib/jdk/test/lib/NetworkConfiguration.java index a9e6821b2e6..bd6a1360d41 100644 --- a/test/lib/jdk/test/lib/NetworkConfiguration.java +++ b/test/lib/jdk/test/lib/NetworkConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 diff --git a/test/lib/jdk/test/lib/SA/SATestUtils.java b/test/lib/jdk/test/lib/SA/SATestUtils.java index cdb0caf84d4..01233b5bf55 100644 --- a/test/lib/jdk/test/lib/SA/SATestUtils.java +++ b/test/lib/jdk/test/lib/SA/SATestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 diff --git a/test/lib/jdk/test/lib/containers/docker/DockerRunOptions.java b/test/lib/jdk/test/lib/containers/docker/DockerRunOptions.java index b9ea60c9fb7..c8c396013b0 100644 --- a/test/lib/jdk/test/lib/containers/docker/DockerRunOptions.java +++ b/test/lib/jdk/test/lib/containers/docker/DockerRunOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 diff --git a/test/lib/jdk/test/lib/helpers/ClassFileInstaller.java b/test/lib/jdk/test/lib/helpers/ClassFileInstaller.java index 72038191d79..ba585581e78 100644 --- a/test/lib/jdk/test/lib/helpers/ClassFileInstaller.java +++ b/test/lib/jdk/test/lib/helpers/ClassFileInstaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/test/lib/jdk/test/whitebox/code/CodeBlob.java b/test/lib/jdk/test/whitebox/code/CodeBlob.java index fd95b5a7e7d..a3ab74ac14f 100644 --- a/test/lib/jdk/test/whitebox/code/CodeBlob.java +++ b/test/lib/jdk/test/whitebox/code/CodeBlob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 diff --git a/test/make/autoconf/test.m4 b/test/make/autoconf/test.m4 index 0aa002ef9bf..c4b8b0ebbac 100644 --- a/test/make/autoconf/test.m4 +++ b/test/make/autoconf/test.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2020, 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 diff --git a/test/micro/org/openjdk/bench/java/lang/FPComparison.java b/test/micro/org/openjdk/bench/java/lang/FPComparison.java index 18b2b79c7bd..e6b2ab2d39a 100644 --- a/test/micro/org/openjdk/bench/java/lang/FPComparison.java +++ b/test/micro/org/openjdk/bench/java/lang/FPComparison.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayCriticalXorOpImpl.java b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayCriticalXorOpImpl.java index fb43bf90455..28f3e5dc716 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayCriticalXorOpImpl.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayCriticalXorOpImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayElementsXorOpImpl.java b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayElementsXorOpImpl.java index deb121e3fa9..4b2815fb3b9 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayElementsXorOpImpl.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayElementsXorOpImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpCriticalImpl.java b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpCriticalImpl.java index 123e6d20b7c..9bb6fc9788a 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpCriticalImpl.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpCriticalImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpImpl.java b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpImpl.java index 481449c5f42..d1a8385dbb3 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpImpl.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpInitImpl.java b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpInitImpl.java index 6722f21b380..61298b7bc71 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpInitImpl.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayForeignXorOpInitImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayRegionXorOpImpl.java b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayRegionXorOpImpl.java index 937f9bfee92..bc165a05ff6 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayRegionXorOpImpl.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayRegionXorOpImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/xor/XorOp.java b/test/micro/org/openjdk/bench/java/lang/foreign/xor/XorOp.java index 18b5f4de339..9cb1793fb50 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/xor/XorOp.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/xor/XorOp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/xor/libjnitest.c b/test/micro/org/openjdk/bench/java/lang/foreign/xor/libjnitest.c index b311ff0617b..c58df58aedc 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/xor/libjnitest.c +++ b/test/micro/org/openjdk/bench/java/lang/foreign/xor/libjnitest.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/micro/org/openjdk/bench/vm/compiler/ArrayFill.java b/test/micro/org/openjdk/bench/vm/compiler/ArrayFill.java index 90508ec79a9..29910ad0b30 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/ArrayFill.java +++ b/test/micro/org/openjdk/bench/vm/compiler/ArrayFill.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, Arm Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java b/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java index fcdbb9356e0..9ef580d09c7 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java +++ b/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2025 IBM Corporation. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorAliasing.java b/test/micro/org/openjdk/bench/vm/compiler/VectorAliasing.java index 9c8270e4660..590b8560cb6 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorAliasing.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorAliasing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java b/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java index 63fbf030083..9241aca1dad 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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