You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2015/03/13 22:00:37 UTC
svn commit: r1666577 - in
/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time:
FastDatePrinterTest.java FastDatePrinterTimeZonesTest.java
Author: britter
Date: Fri Mar 13 21:00:37 2015
New Revision: 1666577
URL: http://svn.apache.org/r1666577
Log:
Extract formatting tests of time zones into parameterized test
Added:
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java (with props)
Modified:
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java?rev=1666577&r1=1666576&r2=1666577&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java Fri Mar 13 21:00:37 2015
@@ -259,27 +259,7 @@ public class FastDatePrinterTest {
final DatePrinter printer= getInstance(YYYY_MM_DD, NEW_YORK);
assertEquals(NEW_YORK, printer.getTimeZone());
}
-
- @Test
- public void testCalendarTimezoneRespected() {
- final String[] availableZones = TimeZone.getAvailableIDs();
-
- for (final String zone : availableZones) {
- TimeZone anotherZone = TimeZone.getTimeZone(zone);
- assertNotNull("Cannot find another timezone", anotherZone);
-
- final String pattern = "h:mma z";
- final Calendar cal = Calendar.getInstance(anotherZone);
-
- final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
- sdf.setTimeZone(anotherZone);
- final String expectedValue = sdf.format(cal.getTime());
- final String actualValue = FastDateFormat.getInstance(pattern).format(cal);
- assertEquals(expectedValue, actualValue);
- }
- }
-
@Test
public void testTimeZoneAsZ() throws Exception {
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Added: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java?rev=1666577&view=auto
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java (added)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java Fri Mar 13 21:00:37 2015
@@ -0,0 +1,49 @@
+package org.apache.commons.lang3.time;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.List;
+import java.util.TimeZone;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class FastDatePrinterTimeZonesTest {
+
+ private static final String PATTERN = "h:mma z";
+
+ @Parameterized.Parameters
+ public static Collection<TimeZone> data() {
+ final String[] zoneIds = TimeZone.getAvailableIDs();
+ List<TimeZone> timeZones = new ArrayList<TimeZone>();
+ for (String zoneId : zoneIds) {
+ timeZones.add(TimeZone.getTimeZone(zoneId));
+ }
+ return timeZones;
+ }
+
+ private TimeZone timeZone;
+
+ public FastDatePrinterTimeZonesTest(TimeZone timeZone) {
+ this.timeZone = timeZone;
+ }
+
+ @Test
+ public void testCalendarTimezoneRespected() {
+ final Calendar cal = Calendar.getInstance(timeZone);
+
+ final SimpleDateFormat sdf = new SimpleDateFormat(PATTERN);
+ sdf.setTimeZone(timeZone);
+ final String expectedValue = sdf.format(cal.getTime());
+ final String actualValue = FastDateFormat.getInstance(PATTERN).format(cal);
+ assertEquals(expectedValue, actualValue);
+ }
+
+}
Propchange: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java
------------------------------------------------------------------------------
svn:eol-style = native