source: josm/trunk/test/unit/org/openstreetmap/josm/io/OsmReaderTest.java@ 12137

Last change on this file since 12137 was 12137, checked in by Don-vip, 7 years ago

see #14788 - add non-regression test

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNull;
6import static org.junit.Assert.assertTrue;
7import static org.junit.Assert.fail;
8
9import java.io.InputStream;
10
11import org.junit.Test;
12import org.openstreetmap.josm.TestUtils;
13import org.openstreetmap.josm.data.osm.Way;
14import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
15
16/**
17 * Unit tests of {@link OsmReader} class.
18 */
19public class OsmReaderTest {
20
21 /**
22 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/14199">Bug #14199</a>.
23 * @throws Exception if any error occurs
24 */
25 @Test
26 public void testTicket14199() throws Exception {
27 try (InputStream in = TestUtils.getRegressionDataStream(14199, "emptytag.osm")) {
28 Way w = OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE).getWays().iterator().next();
29 assertEquals(1, w.getKeys().size());
30 assertNull(w.get(" "));
31 assertTrue(w.isModified());
32 }
33 }
34
35 /**
36 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/14754">Bug #14754</a>.
37 * @throws Exception if any error occurs
38 */
39 @Test
40 public void testTicket14754() throws Exception {
41 try (InputStream in = TestUtils.getRegressionDataStream(14754, "malformed_for_14754.osm")) {
42 OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
43 fail("should throw exception");
44 } catch (IllegalDataException e) {
45 assertEquals("Illegal value for attributes 'lat', 'lon' on node with ID 1425146006." +
46 " Got '550.3311950157', '10.49428298298'." +
47 " (at line 5, column 179). 578 bytes have been read", e.getMessage());
48 }
49 }
50
51 /**
52 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/14788">Bug #14788</a>.
53 * @throws Exception if any error occurs
54 */
55 @Test
56 public void testTicket14788() throws Exception {
57 try (InputStream in = TestUtils.getRegressionDataStream(14788, "remove_sign_test_4.osm")) {
58 OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
59 fail("should throw exception");
60 } catch (IllegalDataException e) {
61 assertEquals("Illegal value for attributes 'lat', 'lon' on node with ID 978." +
62 " Got 'nan', 'nan'." +
63 " (at line 4, column 151). 336 bytes have been read", e.getMessage());
64 }
65 }
66}
Note: See TracBrowser for help on using the repository browser.