Changeset 19055 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2024-04-23T18:41:05+02:00 (7 months ago)
Author:
taylor.smock
Message:

Fix tests in Java 21

  • Regenerate Java 21 image files (probably from r19043: Drop COMPAT locale provider).
  • Remove Java 8 image files, since we no longer support Java 8.
  • Fix an issue where Java 21 uses a non-breaking space between time and AM/PM.
File:
1 edited

Legend:

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

    r19054 r19055  
    2424import org.openstreetmap.josm.testutils.annotations.I18n;
    2525import org.openstreetmap.josm.tools.UncheckedParseException;
     26import org.openstreetmap.josm.tools.Utils;
    2627
    2728import net.trajano.commons.testing.UtilityClassTestUtil;
     
    153154    @Test
    154155    void testFormatTime() {
    155         assertEquals("12:00 AM", DateUtils.formatTime(new Date(0), DateFormat.SHORT));
    156         assertEquals("1:00 AM", DateUtils.formatTime(new Date(60 * 60 * 1000), DateFormat.SHORT));
    157         assertEquals("12:00 AM", DateUtils.formatTime(new Date(999), DateFormat.SHORT));
     156        // Somewhere between Java 17 and Java 21, a non-breaking space replaced the original space between the time and AM/PM.
     157        final var separator = Utils.getJavaVersion() >= 21 ? '\u202f' : ' ';
     158        final var twelveAM = "12:00" + separator + "AM";
     159        assertEquals(twelveAM, DateUtils.formatTime(new Date(0), DateFormat.SHORT));
     160        assertEquals("1:00" + separator + "AM", DateUtils.formatTime(new Date(60 * 60 * 1000), DateFormat.SHORT));
     161        assertEquals(twelveAM, DateUtils.formatTime(new Date(999), DateFormat.SHORT));
    158162        // ignore seconds
    159         assertEquals("12:00 AM", DateUtils.formatTime(new Date(5999), DateFormat.SHORT));
     163        assertEquals(twelveAM, DateUtils.formatTime(new Date(5999), DateFormat.SHORT));
    160164
    161165        setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
    162         assertEquals("1:00:00 AM GMT+01:00", DateUtils.formatTime(new Date(0), DateFormat.LONG), "This is mostly dependent upon java.locale.providers. CET is also OK.");
     166        assertEquals("1:00:00" + separator + "AM GMT+01:00", DateUtils.formatTime(new Date(0), DateFormat.LONG), "This is mostly dependent upon java.locale.providers. CET is also OK.");
    163167    }
    164168
Note: See TracChangeset for help on using the changeset viewer.