source: josm/trunk/test/unit/org/openstreetmap/josm/io/OsmApiTest.java

Last change on this file was 18853, checked in by taylor.smock, 7 months ago

See #16567: Update to JUnit 5

This removes new JOSMTestRules() with no additional setup and most
JOSMFixture calls.

Removing the bare JOSMTestRules speeds up the test suite since there are two
fewer System.gc() calls per test.

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5
6import java.io.ByteArrayInputStream;
7import java.nio.charset.StandardCharsets;
8
9import org.junit.jupiter.api.Test;
10import org.openstreetmap.josm.data.osm.Changeset;
11import org.openstreetmap.josm.data.osm.User;
12import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
13
14/**
15 * Unit tests of {@link OsmApi} class.
16 */
17class OsmApiTest {
18 /**
19 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/12675">Bug #12675</a>.
20 * @throws IllegalDataException if an error occurs
21 */
22 @Test
23 void testTicket12675() throws IllegalDataException {
24 OsmApi api = OsmApi.getOsmApi();
25 Changeset cs = new Changeset();
26 cs.setUser(User.getAnonymous());
27 cs.setId(38038262);
28 String xml = api.toXml(cs);
29 assertEquals("<?xml version='1.0' encoding='UTF-8'?>\n"+
30 "<osm version='0.6' generator='JOSM'>\n"+
31 " <changeset id='38038262' user='&lt;anonymous&gt;' uid='-1' open='false'>\n"+
32 " </changeset>\n"+
33 "</osm>\n", xml.replace("\r", ""));
34 Changeset cs2 = OsmChangesetParser.parse(
35 new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)),
36 NullProgressMonitor.INSTANCE).iterator().next();
37 assertEquals(User.getAnonymous(), cs2.getUser());
38 }
39}
Note: See TracBrowser for help on using the repository browser.