Repository: commons-lang Updated Branches: refs/heads/master bce28f99f -> 3178494ca
Use @ParameterizedTest to iterate over available locales Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/7e440785 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/7e440785 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/7e440785 Branch: refs/heads/master Commit: 7e440785d9ccdafc84ae7a50022097dc3dd422e8 Parents: bce28f9 Author: Benedikt Ritter <brit...@apache.org> Authored: Wed Sep 5 15:58:27 2018 +0200 Committer: Benedikt Ritter <brit...@apache.org> Committed: Wed Sep 5 15:58:27 2018 +0200 ---------------------------------------------------------------------- pom.xml | 5 ++ .../FastDateParser_TimeZoneStrategyTest.java | 55 ++++++++++---------- 2 files changed, 33 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/7e440785/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index bea54d7..d9a29b3 100644 --- a/pom.xml +++ b/pom.xml @@ -529,6 +529,11 @@ </dependency> <dependency> <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <scope>test</scope> </dependency> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/7e440785/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java index 8192867..9a14998 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java @@ -16,8 +16,9 @@ */ package org.apache.commons.lang3.time; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import java.text.DateFormatSymbols; import java.text.ParseException; @@ -25,39 +26,39 @@ import java.util.Date; import java.util.Locale; import java.util.TimeZone; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.fail; -public class FastDateParser_TimeZoneStrategyTest { +class FastDateParser_TimeZoneStrategyTest { - @Test - public void testTimeZoneStrategyPattern() { - for(final Locale locale : Locale.getAvailableLocales()) { - final FastDateParser parser = new FastDateParser("z", TimeZone.getDefault(), locale); - final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings(); - for(final String[] zone : zones) { - for(int t = 1; t<zone.length; ++t) { - final String tzDisplay = zone[t]; - if (tzDisplay == null) { - break; - } - try { - parser.parse(tzDisplay); - } catch(final Exception ex) { - fail("'" + tzDisplay + "'" - + " Locale: '" + locale.getDisplayName() + "'" - + " TimeZone: " + zone[0] - + " offset: " + t - + " defaultLocale: " + Locale.getDefault() - + " defaultTimeZone: " + TimeZone.getDefault().getDisplayName() - ); - } + @ParameterizedTest + @MethodSource("java.util.Locale#getAvailableLocales") + void testTimeZoneStrategyPattern(final Locale locale) { + final FastDateParser parser = new FastDateParser("z", TimeZone.getDefault(), locale); + final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings(); + for (final String[] zone : zones) { + for (int t = 1; t < zone.length; ++t) { + final String tzDisplay = zone[t]; + if (tzDisplay == null) { + break; + } + try { + parser.parse(tzDisplay); + } catch (final Exception ex) { + fail("'" + tzDisplay + "'" + + " Locale: '" + locale.getDisplayName() + "'" + + " TimeZone: " + zone[0] + + " offset: " + t + + " defaultLocale: " + Locale.getDefault() + + " defaultTimeZone: " + TimeZone.getDefault().getDisplayName() + ); } } } } @Test - public void testLang1219() throws ParseException { + void testLang1219() throws ParseException { final FastDateParser parser = new FastDateParser("dd.MM.yyyy HH:mm:ss z", TimeZone.getDefault(), Locale.GERMAN); final Date summer = parser.parse("26.10.2014 02:00:00 MESZ");