Changeset 17149 in josm for trunk


Ignore:
Timestamp:
2020-10-10T22:32:44+02:00 (4 years ago)
Author:
simon04
Message:

see #19370 - Fix GpxWriterTest, InspectPrimitiveDialogTest on Windows

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/TestUtils.java

    r16643 r17149  
    3434import java.util.stream.Stream;
    3535
     36import org.junit.Assert;
    3637import org.junit.Assume;
    3738import org.openstreetmap.josm.command.Command;
     
    540541
    541542    /**
     543     * Replaces {@linkplain System#lineSeparator() system dependent line separators} with {@code \n}
     544     * and calls {@link Assert#assertEquals(java.lang.Object, java.lang.Object)}.
     545     * @param expected expected value
     546     * @param actual the value to check against <code>expected</code>
     547     */
     548    public static void assertEqualsNewline(String expected, String actual) {
     549        assertEquals(expected, actual.replace(System.lineSeparator(), "\n"));
     550    }
     551
     552    /**
    542553     * Waits until any asynchronous operations launched by the test on the EDT or worker threads have
    543554     * (almost certainly) completed.
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialogTest.java

    r16679 r17149  
    22package org.openstreetmap.josm.gui.dialogs;
    33
    4 import static org.junit.Assert.assertEquals;
    54import static org.junit.Assert.assertNotNull;
     5import static org.openstreetmap.josm.TestUtils.assertEqualsNewline;
    66
    77import java.util.ArrayList;
     
    6868    public void testBuildDataText() {
    6969        DataSet ds = new DataSet();
    70         assertEquals("", InspectPrimitiveDialog.buildDataText(ds, new ArrayList<>(ds.allPrimitives())));
     70        assertEqualsNewline("", InspectPrimitiveDialog.buildDataText(ds, new ArrayList<>(ds.allPrimitives())));
    7171        final Way way = new Way();
    7272        way.addNode(new Node(new LatLon(47.2687921, 11.390525)));
     
    8383        ds.addPrimitive(way);
    8484        way.addNode(way.firstNode()); // close way
    85         assertEquals(
     85        assertEqualsNewline(
    8686            "Way: 1\n" +
    8787                "  Data Set: "+Integer.toHexString(ds.hashCode())+"\n" +
     
    110110    public void testBuildListOfEditorsText() {
    111111        DataSet ds = new DataSet();
    112         assertEquals("0 users last edited the selection:\n\n", InspectPrimitiveDialog.buildListOfEditorsText(ds.allPrimitives()));
     112        assertEqualsNewline("0 users last edited the selection:\n\n", InspectPrimitiveDialog.buildListOfEditorsText(ds.allPrimitives()));
    113113        ds.addPrimitive(new Node(LatLon.ZERO));
    114         assertEquals("0 users last edited the selection:\n\n", InspectPrimitiveDialog.buildListOfEditorsText(ds.allPrimitives()));
     114        assertEqualsNewline("0 users last edited the selection:\n\n", InspectPrimitiveDialog.buildListOfEditorsText(ds.allPrimitives()));
    115115        Node n = new Node(LatLon.ZERO);
    116116        n.setUser(User.getAnonymous());
     
    119119        n.setUser(User.getAnonymous());
    120120        ds.addPrimitive(n);
    121         assertEquals(
     121        assertEqualsNewline(
    122122                "1 user last edited the selection:\n" +
    123123                "\n" +
     
    153153        try {
    154154            MainApplication.getLayerManager().addLayer(layer);
    155             assertEquals("", InspectPrimitiveDialog.buildMapPaintText());
     155            assertEqualsNewline("", InspectPrimitiveDialog.buildMapPaintText());
    156156            Node n = new Node(LatLon.ZERO);
    157157            n.setUser(User.getAnonymous());
     
    159159            ds.addSelected(n);
    160160            String text = InspectPrimitiveDialog.buildMapPaintText().replaceAll("@(\\p{XDigit})+", "");
    161             assertEquals(baseText, text);
     161            assertEqualsNewline(baseText, text);
    162162            n = new Node(LatLon.ZERO);
    163163            n.setUser(User.getAnonymous());
    164164            ds.addPrimitive(n);
    165165            ds.addSelected(n);
    166             assertEquals(baseText + baseText + "The 2 selected objects have identical style caches.\n",
     166            assertEqualsNewline(baseText + baseText + "The 2 selected objects have identical style caches.\n",
    167167                    InspectPrimitiveDialog.buildMapPaintText().replaceAll("@(\\p{XDigit})+", ""));
    168168        } finally {
  • trunk/test/unit/org/openstreetmap/josm/io/GpxWriterTest.java

    r15560 r17149  
    22package org.openstreetmap.josm.io;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.openstreetmap.josm.TestUtils.assertEqualsNewline;
    55
    66import java.awt.Color;
    77import java.io.ByteArrayOutputStream;
    88import java.io.IOException;
    9 import java.nio.charset.StandardCharsets;
    109import java.time.LocalDate;
    1110import java.time.Month;
     
    5150            writer.write(gpx);
    5251        }
    53         assertEquals(String.format("<?xml version='1.0' encoding='UTF-8'?>%n" +
    54                 "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"%n" +
    55                 "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"%n" +
    56                 "    xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">%n" +
    57                 "  <metadata>%n" +
    58                 "    <bounds minlat=\"0.0\" minlon=\"0.0\" maxlat=\"0.0\" maxlon=\"0.0\"/>%n" +
    59                 "  </metadata>%n" +
    60                 "  <wpt lat=\"0.0\" lon=\"0.0\">%n" +
     52        assertEqualsNewline("<?xml version='1.0' encoding='UTF-8'?>\n" +
     53                "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" +
     54                "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
     55                "    xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n" +
     56                "  <metadata>\n" +
     57                "    <bounds minlat=\"0.0\" minlon=\"0.0\" maxlat=\"0.0\" maxlon=\"0.0\"/>\n" +
     58                "  </metadata>\n" +
     59                "  <wpt lat=\"0.0\" lon=\"0.0\">\n" +
    6160                atts +
    62                 "  </wpt>%n" +
    63                 "</gpx>"), baos.toString(StandardCharsets.UTF_8.name()));
     61                "  </wpt>\n" +
     62                "</gpx>", baos.toString());
    6463    }
    6564
     
    7372        testSingleWaypoint(
    7473                w -> w.put(GpxConstants.PT_TIME, Date.from(LocalDate.of(2018, Month.AUGUST, 2).atStartOfDay(ZoneOffset.UTC).toInstant())),
    75                 "    <time>2018-08-02T00:00:00Z</time>%n");
     74                "    <time>2018-08-02T00:00:00Z</time>\n");
    7675    }
    7776
     
    9089                    w.put(GpxConstants.PT_PDOP, 1.2);
    9190                },
    92                 "    <sat>16</sat>%n" +
    93                 "    <hdop>0.7</hdop>%n" +
    94                 "    <vdop>0.9</vdop>%n" +
    95                 "    <pdop>1.2</pdop>%n");
     91                "    <sat>16</sat>\n" +
     92                "    <hdop>0.7</hdop>\n" +
     93                "    <vdop>0.9</vdop>\n" +
     94                "    <pdop>1.2</pdop>\n");
    9695    }
    9796
     
    134133
    135134        writer.write(data);
    136         assertEquals("<?xml version='1.0' encoding='UTF-8'?>\n" +
     135        assertEqualsNewline("<?xml version='1.0' encoding='UTF-8'?>\n" +
    137136                "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" +
    138137                "    xmlns:knownprefix=\"http://example.com/URI\"\n" +
     
    171170        baos.reset();
    172171        writer.write(data, GpxConstants.ColorFormat.GPXX, true);
    173         assertEquals("<?xml version='1.0' encoding='UTF-8'?>\n" +
     172        assertEqualsNewline("<?xml version='1.0' encoding='UTF-8'?>\n" +
    174173                "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" +
    175174                "    xmlns:knownprefix=\"http://example.com/URI\"\n" +
     
    210209        baos.reset();
    211210        writer.write(data, null, false);
    212         assertEquals("<?xml version='1.0' encoding='UTF-8'?>\n" +
     211        assertEqualsNewline("<?xml version='1.0' encoding='UTF-8'?>\n" +
    213212                "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" +
    214213                "    xmlns:knownprefix=\"http://example.com/URI\"\n" +
     
    243242        // being hidden, even if they don't actually have to be converted
    244243        // (GPXD -> convertColor() -> GPXX -> hide() -> null -> show() -> GPXX)
    245         assertEquals("<?xml version='1.0' encoding='UTF-8'?>\n" +
     244        assertEqualsNewline("<?xml version='1.0' encoding='UTF-8'?>\n" +
    246245                "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" +
    247246                "    xmlns:knownprefix=\"http://example.com/URI\"\n" +
Note: See TracChangeset for help on using the changeset viewer.