Changeset 14274 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2018-09-26T20:21:06+02:00 (6 years ago)
Author:
Don-vip
Message:

fix bug when writing a locked OSM layer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/io/OsmWriterTest.java

    r14201 r14274  
    1616
    1717import org.junit.Test;
     18import org.openstreetmap.josm.data.osm.DataSet;
    1819import org.openstreetmap.josm.data.osm.DownloadPolicy;
    1920import org.openstreetmap.josm.data.osm.NodeData;
     
    6970                baos.toString("UTF-8").replaceAll("\r", "").replaceAll("\n", ""));
    7071    }
     72
     73    /**
     74     * Unit test of {@link OsmWriter#write} with dataset locked.
     75     * @throws IOException if an I/O error occurs
     76     */
     77    @Test
     78    public void testWriteLock() throws IOException {
     79        ByteArrayOutputStream baos = new ByteArrayOutputStream();
     80        try (PrintWriter out = new PrintWriter(new OutputStreamWriter(baos, StandardCharsets.UTF_8));
     81             OsmWriter writer = OsmWriterFactory.createOsmWriter(out, true, OsmWriter.DEFAULT_API_VERSION)) {
     82            DataSet ds = new DataSet();
     83            ds.lock();
     84            writer.write(ds);
     85        }
     86        assertEquals("<?xml version='1.0' encoding='UTF-8'?><osm version='0.6' locked='true' generator='JOSM'></osm>",
     87                baos.toString("UTF-8").replaceAll("\r", "").replaceAll("\n", ""));
     88    }
    7189}
Note: See TracChangeset for help on using the changeset viewer.