Changeset 17149 in josm
- Timestamp:
- 2020-10-10T22:32:44+02:00 (4 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r16643 r17149 34 34 import java.util.stream.Stream; 35 35 36 import org.junit.Assert; 36 37 import org.junit.Assume; 37 38 import org.openstreetmap.josm.command.Command; … … 540 541 541 542 /** 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 /** 542 553 * Waits until any asynchronous operations launched by the test on the EDT or worker threads have 543 554 * (almost certainly) completed. -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialogTest.java
r16679 r17149 2 2 package org.openstreetmap.josm.gui.dialogs; 3 3 4 import static org.junit.Assert.assertEquals;5 4 import static org.junit.Assert.assertNotNull; 5 import static org.openstreetmap.josm.TestUtils.assertEqualsNewline; 6 6 7 7 import java.util.ArrayList; … … 68 68 public void testBuildDataText() { 69 69 DataSet ds = new DataSet(); 70 assertEquals ("", InspectPrimitiveDialog.buildDataText(ds, new ArrayList<>(ds.allPrimitives())));70 assertEqualsNewline("", InspectPrimitiveDialog.buildDataText(ds, new ArrayList<>(ds.allPrimitives()))); 71 71 final Way way = new Way(); 72 72 way.addNode(new Node(new LatLon(47.2687921, 11.390525))); … … 83 83 ds.addPrimitive(way); 84 84 way.addNode(way.firstNode()); // close way 85 assertEquals (85 assertEqualsNewline( 86 86 "Way: 1\n" + 87 87 " Data Set: "+Integer.toHexString(ds.hashCode())+"\n" + … … 110 110 public void testBuildListOfEditorsText() { 111 111 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())); 113 113 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())); 115 115 Node n = new Node(LatLon.ZERO); 116 116 n.setUser(User.getAnonymous()); … … 119 119 n.setUser(User.getAnonymous()); 120 120 ds.addPrimitive(n); 121 assertEquals (121 assertEqualsNewline( 122 122 "1 user last edited the selection:\n" + 123 123 "\n" + … … 153 153 try { 154 154 MainApplication.getLayerManager().addLayer(layer); 155 assertEquals ("", InspectPrimitiveDialog.buildMapPaintText());155 assertEqualsNewline("", InspectPrimitiveDialog.buildMapPaintText()); 156 156 Node n = new Node(LatLon.ZERO); 157 157 n.setUser(User.getAnonymous()); … … 159 159 ds.addSelected(n); 160 160 String text = InspectPrimitiveDialog.buildMapPaintText().replaceAll("@(\\p{XDigit})+", ""); 161 assertEquals (baseText, text);161 assertEqualsNewline(baseText, text); 162 162 n = new Node(LatLon.ZERO); 163 163 n.setUser(User.getAnonymous()); 164 164 ds.addPrimitive(n); 165 165 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", 167 167 InspectPrimitiveDialog.buildMapPaintText().replaceAll("@(\\p{XDigit})+", "")); 168 168 } finally { -
trunk/test/unit/org/openstreetmap/josm/io/GpxWriterTest.java
r15560 r17149 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org. junit.Assert.assertEquals;4 import static org.openstreetmap.josm.TestUtils.assertEqualsNewline; 5 5 6 6 import java.awt.Color; 7 7 import java.io.ByteArrayOutputStream; 8 8 import java.io.IOException; 9 import java.nio.charset.StandardCharsets;10 9 import java.time.LocalDate; 11 10 import java.time.Month; … … 51 50 writer.write(gpx); 52 51 } 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" + 61 60 atts + 62 " </wpt> %n" +63 "</gpx>" ), baos.toString(StandardCharsets.UTF_8.name()));61 " </wpt>\n" + 62 "</gpx>", baos.toString()); 64 63 } 65 64 … … 73 72 testSingleWaypoint( 74 73 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"); 76 75 } 77 76 … … 90 89 w.put(GpxConstants.PT_PDOP, 1.2); 91 90 }, 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"); 96 95 } 97 96 … … 134 133 135 134 writer.write(data); 136 assertEquals ("<?xml version='1.0' encoding='UTF-8'?>\n" +135 assertEqualsNewline("<?xml version='1.0' encoding='UTF-8'?>\n" + 137 136 "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" + 138 137 " xmlns:knownprefix=\"http://example.com/URI\"\n" + … … 171 170 baos.reset(); 172 171 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" + 174 173 "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" + 175 174 " xmlns:knownprefix=\"http://example.com/URI\"\n" + … … 210 209 baos.reset(); 211 210 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" + 213 212 "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" + 214 213 " xmlns:knownprefix=\"http://example.com/URI\"\n" + … … 243 242 // being hidden, even if they don't actually have to be converted 244 243 // (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" + 246 245 "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" + 247 246 " xmlns:knownprefix=\"http://example.com/URI\"\n" +
Note:
See TracChangeset
for help on using the changeset viewer.