Ignore:
Timestamp:
2019-05-11T20:24:40+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #17701, fix #17702 - add robustness when loading imagery layers from session

File:
1 edited

Legend:

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

    r14138 r15070  
    66import static org.junit.Assert.assertTrue;
    77
     8import java.io.ByteArrayInputStream;
    89import java.io.File;
    910import java.io.IOException;
     11import java.io.InputStream;
     12import java.nio.charset.StandardCharsets;
    1013import java.util.List;
    1114
     
    154157        assertEquals(174, layer.getNoteData().getNotes().size());
    155158    }
     159
     160    /**
     161     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/17701">Bug #17701</a>.
     162     * @throws Exception if an error occurs
     163     */
     164    @Test
     165    public void testTicket17701() throws Exception {
     166        try (InputStream in = new ByteArrayInputStream(("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
     167                "<josm-session version=\"0.1\">\n" +
     168                "    <layers active=\"1\">\n" +
     169                "        <layer index=\"1\" name=\"GPS-треки OpenStreetMap\" type=\"imagery\" version=\"0.1\" visible=\"true\">\n" +
     170                "            <id>osm-gps</id>\n" +
     171                "            <type>tms</type>\n" +
     172                "            <url>https://{switch:a,b,c}.gps-tile.openstreetmap.org/lines/{zoom}/{x}/{y}.png</url>\n" +
     173                "            <attribution-text>© OpenStreetMap contributors</attribution-text>\n" +
     174                "            <attribution-url>https://www.openstreetmap.org/copyright</attribution-url>\n" +
     175                "            <max-zoom>20</max-zoom>\n" +
     176                "            <cookies/>\n" +
     177                "            <description>Общедоступные GPS-треки, загруженные на OpenStreetMap.</description>\n" +
     178                "            <valid-georeference>true</valid-georeference>\n" +
     179                "            <overlay>true</overlay>\n" +
     180                "            <show-errors>true</show-errors>\n" +
     181                "            <automatic-downloading>true</automatic-downloading>\n" +
     182                "            <automatically-change-resolution>true</automatically-change-resolution>\n" +
     183                "        </layer>\r\n" +
     184                "    </layers>\n" +
     185                "</josm-session>").getBytes(StandardCharsets.UTF_8))) {
     186            SessionReader reader = new SessionReader();
     187            reader.loadSession(in, null, false, null);
     188            assertTrue(reader.getLayers().isEmpty());
     189        }
     190    }
    156191}
Note: See TracChangeset for help on using the changeset viewer.