Ignore:
Timestamp:
2020-02-15T12:30:27+01:00 (5 years ago)
Author:
donvip
Message:

see #josm18440 - add new API key provider system

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/test/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSourceTest.java

    r34716 r35320  
    1 // License: GPL. For details, see LICENSE file.
     1// License: GPL. For details, see Readme.txt file.
    22package org.openstreetmap.gui.jmapviewer.tilesources;
    33
     
    1313import org.junit.Test;
    1414
    15 
    1615/**
    17  *
    1816 * Tests for TemplaedTMSTileSource
    1917 */
    2018public class TemplatedTMSTileSourceTest {
    2119
    22     private final static Collection<String> TMS_IMAGERIES = Arrays.asList(new String[]{
     20    private static final Collection<String> TMS_IMAGERIES = Arrays.asList(new String[]{
    2321            "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z={zoom}&x={x}&y={-y}",
    2422            /*
     
    3634     *  * expected tile url for zoom=3, x=2, y=1
    3735     */
    38     @SuppressWarnings("unchecked")
    3936    private Collection<String[]> TEST_DATA = Arrays.asList(new String[][] {
    4037        /*
    4138         * generate with main method below once TMS_IMAGERIES is filled in
    4239         */
    43             new String[]{"http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z={zoom}&x={x}&y={-y}",
    44                     "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z=1&x=2&y=-2",
    45                     "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z=3&x=2&y=6"
    46                     }
     40        new String[] {
     41                "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z={zoom}&x={x}&y={-y}",
     42                "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z=1&x=2&y=-2",
     43                "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z=3&x=2&y=6"
     44                }
    4745    });
    4846
     
    5957    }
    6058
    61 
    6259    /**
    6360     * Check template with positive zoom index
     
    106103                "http://localhost/2/1/2"
    107104                );
     105    }
     106
     107    /**
     108     * Test template with switch
     109     */
     110    @Test
     111    public void testGetTileUrl_apiKey() {
     112        System.setProperty("id1.api-key", "wololo");
     113        TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", "http://localhost/{zoom}/{x}/{y}?token={apiKey}&foo=bar", "id1");
     114        TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS);
     115        assertEquals("http://localhost/1/2/3?token=wololo&foo=bar", ts.getTileUrl(1, 2, 3));
    108116    }
    109117
     
    176184        assertEquals(expected312, ts.getTileUrl(3, 1, 2));
    177185    }
     186
    178187    /**
    179188     * Tests all entries in TEST_DATA. This test will fail if {switch:...} template is used
     
    181190    @Test
    182191    public void testAllUrls() {
    183         for(String[] test: TEST_DATA) {
     192        for (String[] test: TEST_DATA) {
    184193            TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", test[0], "id1");
    185194            TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS);
     
    190199
    191200    public static void main(String[] args) {
    192         for(String url: TMS_IMAGERIES) {
     201        for (String url: TMS_IMAGERIES) {
    193202            TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", url, "id1");
    194203            TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS);
    195             System.out.println(MessageFormat.format("new String[]{\"{0}\", \"{1}\", \"{2}\"},", url, ts.getTileUrl(1, 2, 3), ts.getTileUrl(3, 2, 1)));
     204            System.out.println(MessageFormat.format("new String[]{\"{0}\", \"{1}\", \"{2}\"},",
     205                    url, ts.getTileUrl(1, 2, 3), ts.getTileUrl(3, 2, 1)));
    196206        }
    197207    }
    198 
    199208}
Note: See TracChangeset for help on using the changeset viewer.