Changeset 14274 in josm for trunk


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

fix bug when writing a locked OSM layer

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmWriter.java

    r14215 r14274  
    121121        }
    122122        if (locked) {
    123             out.print("' locked=true");
     123            out.print("' locked='true");
    124124        }
    125125        out.println("' generator='JOSM'>");
  • 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.