Changeset 14038 in josm for trunk


Ignore:
Timestamp:
2018-07-20T20:27:34+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #16499 - Support GDPR-compliant OSM extracts

Location:
trunk
Files:
2 edited

Legend:

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

    r13901 r14038  
    571571                            v, current.getUniqueId()));
    572572                    current.setChangesetId(0);
    573                 } else {
    574                     // for an existing primitive this is a problem
     573                } else if (current.getChangesetId() < 0) {
     574                    // for an existing primitive this is a problem only for negative ids (GPDR extracts are set to 0)
    575575                    throwException(tr("Illegal value for attribute ''changeset''. Got {0}.", v));
    576576                }
  • trunk/test/unit/org/openstreetmap/josm/io/OsmReaderTest.java

    r12138 r14038  
    1313import java.nio.charset.StandardCharsets;
    1414
     15import org.junit.Rule;
    1516import org.junit.Test;
    1617import org.openstreetmap.josm.TestUtils;
     
    1920import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2021import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     22import org.openstreetmap.josm.testutils.JOSMTestRules;
     23
     24import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2125
    2226/**
     
    2529public class OsmReaderTest {
    2630
     31    /**
     32     * Setup rule
     33     */
     34    @Rule
     35    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     36    public JOSMTestRules test = new JOSMTestRules();
     37
    2738    private static final class PostProcessorStub implements OsmServerReadPostprocessor {
    2839        boolean called;
     
    99110        testUnknown("<osm version='0.6'><foo>bar</foo></osm>");
    100111        testUnknown("<osm version='0.6'><foo><bar/></foo></osm>");
     112    }
     113
     114    /**
     115     * Test valid data.
     116     * @param osm OSM data without XML prefix
     117     * @throws Exception if any error occurs
     118     */
     119    private static void testValidData(String osm) throws Exception {
     120        try (InputStream in = new ByteArrayInputStream(
     121                ("<?xml version='1.0' encoding='UTF-8'?>" + osm).getBytes(StandardCharsets.UTF_8))) {
     122            OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
     123        }
    101124    }
    102125
     
    240263        testInvalidData("<osm version='0.6'><node id='1' version='1' changeset='nan'/></osm>",
    241264                "Illegal value for attribute 'changeset'. Got nan. (at line 1, column 100). 100 bytes have been read");
    242         testInvalidData("<osm version='0.6'><node id='1' version='1' changeset='0'/></osm>",
    243                 "Illegal value for attribute 'changeset'. Got 0. (at line 1, column 98). 98 bytes have been read");
     265        testInvalidData("<osm version='0.6'><node id='1' version='1' changeset='-1'/></osm>",
     266                "Illegal value for attribute 'changeset'. Got -1. (at line 1, column 99). 99 bytes have been read");
     267    }
     268
     269    /**
     270     * Test GPDR-compliant changeset.
     271     * @throws Exception if any error occurs
     272     */
     273    @Test
     274    public void testGdprChangeset() throws Exception {
     275        testValidData("<osm version='0.6'><node id='1' version='1' changeset='0'/></osm>");
    244276    }
    245277
Note: See TracChangeset for help on using the changeset viewer.