Ignore:
Timestamp:
2016-06-24T22:27:38+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13047 - Make time zone test work in any time zone (patch by michael2402) - gsoc-core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

    r10222 r10483  
    1010import java.util.TimeZone;
    1111
    12 import org.junit.BeforeClass;
     12import org.junit.Rule;
    1313import org.junit.Test;
    14 import org.openstreetmap.josm.JOSMFixture;
     14import org.openstreetmap.josm.testutils.JOSMTestRules;
    1515import org.openstreetmap.josm.tools.UncheckedParseException;
    1616
     
    2323
    2424    /**
    25      * Setup test.
    26      */
    27     @BeforeClass
    28     public static void setUp() {
    29         JOSMFixture.createUnitTestFixture().init();
    30     }
     25     * Set the timezone and timeout.
     26     */
     27    @Rule
     28    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     29    public JOSMTestRules test = new JOSMTestRules().i18n().preferences();
    3130
    3231    /**
     
    117116    @Test
    118117    public void testFormatTime() {
    119         assertEquals("1:00 AM", DateUtils.formatTime(new Date(123), DateFormat.SHORT));
    120         assertEquals("1:00:00 AM CET", DateUtils.formatTime(new Date(123), DateFormat.LONG));
     118        assertEquals("12:00 AM", DateUtils.formatTime(new Date(0), DateFormat.SHORT));
     119        assertEquals("1:00 AM", DateUtils.formatTime(new Date(60 * 60 * 1000), DateFormat.SHORT));
     120        assertEquals("12:00 AM", DateUtils.formatTime(new Date(999), DateFormat.SHORT));
     121        // ignore seconds
     122        assertEquals("12:00 AM", DateUtils.formatTime(new Date(5999), DateFormat.SHORT));
     123
     124        TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin"));
     125        assertEquals("1:00:00 AM CET", DateUtils.formatTime(new Date(0), DateFormat.LONG));
    121126    }
    122127
Note: See TracChangeset for help on using the changeset viewer.