Skip to content

Commit 54de3fa

Browse files
committed
Convert @test to @CartesianTest
1 parent 7bca07c commit 54de3fa

2 files changed

Lines changed: 27 additions & 23 deletions

File tree

src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
import org.junitpioneer.jupiter.DefaultTimeZone;
5353
import org.junitpioneer.jupiter.ReadsDefaultLocale;
5454
import org.junitpioneer.jupiter.ReadsDefaultTimeZone;
55+
import org.junitpioneer.jupiter.cartesian.ArgumentSets;
56+
import org.junitpioneer.jupiter.cartesian.CartesianTest;
5557

5658
/**
5759
* Tests {@link org.apache.commons.lang3.time.FastDateParser}.
@@ -528,28 +530,27 @@ void testParseOffset() {
528530
assertEquals(cal.getTime(), date);
529531
}
530532

531-
@Test
533+
static ArgumentSets testParsesFactory() {
534+
// @formatter:off
535+
return ArgumentSets
536+
.argumentsForFirstParameter(LONG_FORMAT, SHORT_FORMAT)
537+
.argumentsForNextParameter(LocaleUtils.availableLocaleList())
538+
.argumentsForNextParameter(NEW_YORK, REYKJAVIK, TimeZones.GMT)
539+
.argumentsForNextParameter(2003, 1940, 1868, 1867, 1, -1, -1940);
540+
// @formatter:on
541+
}
542+
543+
@CartesianTest
544+
@CartesianTest.MethodFactory("testParsesFactory")
532545
// Check that all Locales can parse the formats we use
533-
void testParses() throws Exception {
534-
for (final String format : new String[] {LONG_FORMAT, SHORT_FORMAT}) {
535-
for (final Locale locale : Locale.getAvailableLocales()) {
536-
for (final TimeZone timeZone : new TimeZone[] {NEW_YORK, REYKJAVIK, TimeZones.GMT}) {
537-
for (final int year : new int[] {2003, 1940, 1868, 1867, 1, -1, -1940}) {
538-
final Calendar cal = getEraStart(year, timeZone, locale);
539-
final Date centuryStart = cal.getTime();
540-
541-
cal.set(Calendar.MONTH, 1);
542-
cal.set(Calendar.DAY_OF_MONTH, 10);
543-
final Date in = cal.getTime();
544-
545-
final FastDateParser fastDateParser = new FastDateParser(format, timeZone, locale,
546-
centuryStart);
547-
validateSdfFormatFdpParseEquality(format, locale, timeZone, fastDateParser, in, year,
548-
centuryStart);
549-
}
550-
}
551-
}
552-
}
546+
void testParses(final String format, final Locale locale, final TimeZone timeZone, final int year) throws Exception {
547+
final Calendar cal = getEraStart(year, timeZone, locale);
548+
final Date centuryStart = cal.getTime();
549+
cal.set(Calendar.MONTH, 1);
550+
cal.set(Calendar.DAY_OF_MONTH, 10);
551+
final Date in = cal.getTime();
552+
final FastDateParser fastDateParser = new FastDateParser(format, timeZone, locale, centuryStart);
553+
validateSdfFormatFdpParseEquality(format, locale, timeZone, fastDateParser, in, year, centuryStart);
553554
}
554555

555556
/**

src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public static void afterAll() {
6969
}
7070
}
7171

72+
private String[][] getZoneStringsSorted(final Locale locale) {
73+
return ArraySorter.sort(DateFormatSymbols.getInstance(locale).getZoneStrings(), Comparator.comparing(array -> array[0]));
74+
}
75+
7276
@Test
7377
void testLang1219() throws ParseException {
7478
final FastDateParser parser = new FastDateParser("dd.MM.yyyy HH:mm:ss z", TimeZone.getDefault(), Locale.GERMAN);
@@ -104,8 +108,7 @@ private void testTimeZoneStrategyPattern_DateFormatSymbols_getZoneStrings(final
104108
assumeFalse(LocaleUtils.isLanguageUndetermined(locale), () -> toFailureMessage(locale, null, null));
105109
assumeTrue(LocaleUtils.isAvailableLocale(locale), () -> toFailureMessage(locale, null, null));
106110

107-
final String[][] zones = ArraySorter.sort(DateFormatSymbols.getInstance(locale).getZoneStrings(),
108-
Comparator.comparing(array -> array[0]));
111+
final String[][] zones = getZoneStringsSorted(locale);
109112
for (final String[] zone : zones) {
110113
for (int zIndex = 1; zIndex < zone.length; ++zIndex) {
111114
final String tzDisplay = zone[zIndex];

0 commit comments

Comments
 (0)