Merge branch 'parameterized-FastDateParser_TimeZoneStrategyTest'

This commit is contained in:
Benedikt Ritter 2018-09-06 09:55:45 +02:00
commit 3178494ca1
No known key found for this signature in database
GPG Key ID: 9DAADC1C9FCC82D0
2 changed files with 33 additions and 27 deletions

View File

@ -527,6 +527,11 @@
<artifactId>junit-jupiter-api</artifactId> <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>

View File

@ -16,8 +16,9 @@
*/ */
package org.apache.commons.lang3.time; package org.apache.commons.lang3.time;
import static org.junit.Assert.assertNotEquals; import org.junit.jupiter.api.Test;
import static org.junit.Assert.fail; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import java.text.DateFormatSymbols; import java.text.DateFormatSymbols;
import java.text.ParseException; import java.text.ParseException;
@ -25,13 +26,14 @@
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone; 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 @ParameterizedTest
public void testTimeZoneStrategyPattern() { @MethodSource("java.util.Locale#getAvailableLocales")
for(final Locale locale : Locale.getAvailableLocales()) { void testTimeZoneStrategyPattern(final Locale locale) {
final FastDateParser parser = new FastDateParser("z", TimeZone.getDefault(), locale); final FastDateParser parser = new FastDateParser("z", TimeZone.getDefault(), locale);
final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings(); final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings();
for (final String[] zone : zones) { for (final String[] zone : zones) {
@ -54,10 +56,9 @@ public void testTimeZoneStrategyPattern() {
} }
} }
} }
}
@Test @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 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"); final Date summer = parser.parse("26.10.2014 02:00:00 MESZ");