Changeset 18466 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2022-06-06T19:07:05+02:00 (2 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/SessionSaveAsActionTest.java
r17275 r18466 4 4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 5 6 import org.junit.jupiter.api.Test; 6 7 import org.junit.jupiter.api.extension.RegisterExtension; 7 import org.junit.jupiter.api.Test;8 8 import org.openstreetmap.josm.testutils.JOSMTestRules; 9 9 … … 20 20 @RegisterExtension 21 21 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 22 public JOSMTestRules test = new JOSMTestRules() ;22 public JOSMTestRules test = new JOSMTestRules().main(); 23 23 24 24 /** -
trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
r18287 r18466 51 51 * Unit tests for Session writing. 52 52 */ 53 class SessionWriterTest {53 public class SessionWriterTest { 54 54 55 55 protected static final class OsmHeadlessJosExporter extends OsmDataSessionExporter { … … 123 123 for (final Layer l : layers) { 124 124 SessionLayerExporter s = SessionWriter.getSessionLayerExporter(l); 125 s.getExportPanel(); 125 126 exporters.put(l, s); 126 127 if (s instanceof GpxTracksSessionExporter) { … … 154 155 } 155 156 156 private OsmDataLayer createOsmLayer() { 157 /** 158 * Creates an OSM layer 159 * @return OSM layer 160 * @since 18466 161 */ 162 public static OsmDataLayer createOsmLayer() { 157 163 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "OSM layer name", null); 158 164 layer.setAssociatedFile(new File("data.osm")); … … 160 166 } 161 167 162 private GpxLayer createGpxLayer() { 168 /** 169 * Creates a GPX layer 170 * @return GPX layer 171 * @since 18466 172 */ 173 public static GpxLayer createGpxLayer() { 163 174 GpxData data = new GpxData(); 164 175 WayPoint wp = new WayPoint(new LatLon(42.72665, -0.00747)); … … 171 182 } 172 183 173 private MarkerLayer createMarkerLayer(GpxLayer gpx) { 184 /** 185 * Creates a MarkerLayer 186 * @param gpx linked GPX layer 187 * @return MarkerLayer 188 * @since 18466 189 */ 190 public static MarkerLayer createMarkerLayer(GpxLayer gpx) { 174 191 MarkerLayer layer = new MarkerLayer(gpx.data, "Marker layer name", gpx.getAssociatedFile(), gpx); 175 192 layer.setOpacity(0.5); 176 193 layer.setColor(new Color(0x12345678, true)); 194 gpx.setLinkedMarkerLayer(layer); 177 195 return layer; 178 196 } 179 197 180 private ImageryLayer createImageryLayer() { 198 /** 199 * Creates an ImageryLayer 200 * @return ImageryLayer 201 * @since 18466 202 */ 203 public static ImageryLayer createImageryLayer() { 181 204 TMSLayer layer = new TMSLayer(new ImageryInfo("the name", "http://www.url.com/")); 182 205 layer.getDisplaySettings().setOffsetBookmark( … … 185 208 } 186 209 187 private NoteLayer createNoteLayer() { 210 /** 211 * Creates a NoteLayer 212 * @return NoteLayer 213 * @since 18466 214 */ 215 public static NoteLayer createNoteLayer() { 188 216 return new NoteLayer(Arrays.asList(new Note(LatLon.ZERO)), "layer name"); 189 217 } … … 250 278 void testWriteGpxAndMarkerJoz() throws IOException { 251 279 GpxLayer gpx = createGpxLayer(); 252 Map<String, byte[]> bytes = testWrite(Arrays.asList(gpx, createMarkerLayer(gpx)), true); 253 254 Path path = Paths.get(TestUtils.getTestDataRoot() + "/sessions/gpx_markers.jos"); 280 MarkerLayer markers = createMarkerLayer(gpx); 281 Map<String, byte[]> bytes = testWrite(Arrays.asList(gpx, markers), true); 282 283 Path path = Paths.get(TestUtils.getTestDataRoot() + "/sessions/gpx_markers_combined.jos"); 255 284 String expected = new String(Files.readAllBytes(path), StandardCharsets.UTF_8).replace("\r", ""); 256 285 String actual = new String(bytes.get("session.jos"), StandardCharsets.UTF_8).replace("\r", ""); … … 262 291 assertEquals(expected, actual); 263 292 293 //Test writing when the marker layer has no corresponding GPX layer: 294 gpx.setLinkedMarkerLayer(null); 295 markers.fromLayer = null; 296 markers.data.transferLayerPrefs(gpx.data.getLayerPrefs()); 297 bytes = testWrite(Arrays.asList(gpx, markers), true); 298 299 path = Paths.get(TestUtils.getTestDataRoot() + "/sessions/gpx_markers.jos"); 300 expected = new String(Files.readAllBytes(path), StandardCharsets.UTF_8).replace("\r", ""); 301 actual = new String(bytes.get("session.jos"), StandardCharsets.UTF_8).replace("\r", ""); 302 assertEquals(expected, actual); 303 304 path = Paths.get(TestUtils.getTestDataRoot() + "/sessions/data_export.gpx"); 305 expected = new String(Files.readAllBytes(path), StandardCharsets.UTF_8).replace("\r", ""); 306 actual = new String(bytes.get("layers/01/data.gpx"), StandardCharsets.UTF_8).replace("\r", ""); 307 assertEquals(expected, actual); 308 264 309 path = Paths.get(TestUtils.getTestDataRoot() + "/sessions/markers.gpx"); 265 310 expected = new String(Files.readAllBytes(path), StandardCharsets.UTF_8).replace("\r", ""); 266 311 actual = new String(bytes.get("layers/02/data.gpx"), StandardCharsets.UTF_8).replace("\r", ""); 267 312 assertEquals(expected, actual); 313 268 314 } 269 315
Note:
See TracChangeset
for help on using the changeset viewer.