Changeset 18287 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2021-10-19T01:26:15+02:00 (3 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java
r18207 r18287 504 504 EqualsVerifier.forClass(GpxData.class).usingGetClass() 505 505 .suppress(Warning.NONFINAL_FIELDS) 506 .withIgnoredFields("creator", "fromServer", " storageFile", "initializing", "updating",506 .withIgnoredFields("creator", "fromServer", "fromSession", "storageFile", "initializing", "updating", 507 507 "suppressedInvalidate", "listeners", "tracks", "routes", "waypoints", "proxy", "segSpans", "modified") 508 508 .withPrefabValues(WayPoint.class, new WayPoint(LatLon.NORTH_POLE), new WayPoint(LatLon.SOUTH_POLE)) -
trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxTrackTest.java
r17275 r18287 9 9 import java.util.HashMap; 10 10 11 import org.junit.jupiter.api.Test; 11 12 import org.junit.jupiter.api.extension.RegisterExtension; 12 import org.junit.jupiter.api.Test;13 13 import org.openstreetmap.josm.TestUtils; 14 14 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 32 32 33 33 /** 34 * Tests w eather the track can read and write colors.34 * Tests whether the track can read and write colors. 35 35 */ 36 36 @Test -
trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
r17659 r18287 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.io.session; 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.fail; 3 6 4 7 import java.awt.Color; 5 8 import java.io.File; 6 9 import java.io.IOException; 7 import java.io.InputStream;8 10 import java.nio.charset.StandardCharsets; 9 11 import java.nio.file.Files; 10 12 import java.nio.file.Path; 11 13 import java.nio.file.Paths; 14 import java.time.Instant; 12 15 import java.util.Arrays; 13 16 import java.util.Collections; … … 15 18 import java.util.List; 16 19 import java.util.Map; 20 import java.util.stream.Collectors; 21 import java.util.zip.ZipEntry; 17 22 import java.util.zip.ZipFile; 18 23 … … 43 48 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 44 49 45 import static org.junit.jupiter.api.Assertions.assertEquals;46 47 50 /** 48 51 * Unit tests for Session writing. … … 109 112 } 110 113 111 private byte[]testWrite(List<Layer> layers, final boolean zip) throws IOException {114 private Map<String, byte[]> testWrite(List<Layer> layers, final boolean zip) throws IOException { 112 115 Map<Layer, SessionLayerExporter> exporters = new HashMap<>(); 113 116 if (zip) { … … 119 122 } 120 123 for (final Layer l : layers) { 121 exporters.put(l, SessionWriter.getSessionLayerExporter(l)); 124 SessionLayerExporter s = SessionWriter.getSessionLayerExporter(l); 125 exporters.put(l, s); 126 if (s instanceof GpxTracksSessionExporter) { 127 ((GpxTracksSessionExporter) s).setMetaTime(Instant.parse("2021-10-16T18:27:12.351Z")); 128 } else if (s instanceof MarkerSessionExporter) { 129 ((MarkerSessionExporter) s).setMetaTime(Instant.parse("2021-10-16T18:27:12.351Z")); 130 } 122 131 } 123 132 SessionWriter sw = new SessionWriter(layers, -1, exporters, new MultiMap<Layer, Layer>(), zip); … … 128 137 return null; 129 138 } 130 try (ZipFile zipFile = new ZipFile(file); 131 InputStream input = zipFile.getInputStream(zipFile.getEntry("session.jos"))) { 132 return Utils.readBytesFromStream(input); 139 try (ZipFile zipFile = new ZipFile(file)) { 140 return Collections.list(zipFile.entries()).stream().collect(Collectors.toMap(ZipEntry::getName, e -> { 141 try { 142 return Utils.readBytesFromStream(zipFile.getInputStream(e)); 143 } catch (IOException ex) { 144 fail(ex); 145 } 146 return null; 147 })); 133 148 } 134 149 } finally { … … 147 162 private GpxLayer createGpxLayer() { 148 163 GpxData data = new GpxData(); 149 data.waypoints.add(new WayPoint(new LatLon(42.72665, -0.00747))); 164 WayPoint wp = new WayPoint(new LatLon(42.72665, -0.00747)); 165 wp.setInstant(Instant.parse("2021-01-01T10:15:30.00Z")); 166 data.waypoints.add(wp); 150 167 data.waypoints.add(new WayPoint(new LatLon(42.72659, -0.00749))); 151 168 GpxLayer layer = new GpxLayer(data, "GPX layer name"); … … 233 250 void testWriteGpxAndMarkerJoz() throws IOException { 234 251 GpxLayer gpx = createGpxLayer(); 235 byte[] bytes = testWrite(Arrays.asList(gpx, createMarkerLayer(gpx)), true); 252 Map<String, byte[]> bytes = testWrite(Arrays.asList(gpx, createMarkerLayer(gpx)), true); 253 236 254 Path path = Paths.get(TestUtils.getTestDataRoot() + "/sessions/gpx_markers.jos"); 237 255 String expected = new String(Files.readAllBytes(path), StandardCharsets.UTF_8).replace("\r", ""); 238 String actual = new String(bytes, StandardCharsets.UTF_8).replace("\r", ""); 256 String actual = new String(bytes.get("session.jos"), StandardCharsets.UTF_8).replace("\r", ""); 257 assertEquals(expected, actual); 258 259 path = Paths.get(TestUtils.getTestDataRoot() + "/sessions/data_export.gpx"); 260 expected = new String(Files.readAllBytes(path), StandardCharsets.UTF_8).replace("\r", ""); 261 actual = new String(bytes.get("layers/01/data.gpx"), StandardCharsets.UTF_8).replace("\r", ""); 262 assertEquals(expected, actual); 263 264 path = Paths.get(TestUtils.getTestDataRoot() + "/sessions/markers.gpx"); 265 expected = new String(Files.readAllBytes(path), StandardCharsets.UTF_8).replace("\r", ""); 266 actual = new String(bytes.get("layers/02/data.gpx"), StandardCharsets.UTF_8).replace("\r", ""); 239 267 assertEquals(expected, actual); 240 268 }
Note:
See TracChangeset
for help on using the changeset viewer.