Changeset 35320 in osm for applications/viewer/jmapviewer/test
- Timestamp:
- 2020-02-15T12:30:27+01:00 (5 years ago)
- 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 LICENSEfile.1 // License: GPL. For details, see Readme.txt file. 2 2 package org.openstreetmap.gui.jmapviewer.tilesources; 3 3 … … 13 13 import org.junit.Test; 14 14 15 16 15 /** 17 *18 16 * Tests for TemplaedTMSTileSource 19 17 */ 20 18 public class TemplatedTMSTileSourceTest { 21 19 22 private final staticCollection<String> TMS_IMAGERIES = Arrays.asList(new String[]{20 private static final Collection<String> TMS_IMAGERIES = Arrays.asList(new String[]{ 23 21 "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z={zoom}&x={x}&y={-y}", 24 22 /* … … 36 34 * * expected tile url for zoom=3, x=2, y=1 37 35 */ 38 @SuppressWarnings("unchecked")39 36 private Collection<String[]> TEST_DATA = Arrays.asList(new String[][] { 40 37 /* 41 38 * generate with main method below once TMS_IMAGERIES is filled in 42 39 */ 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 } 47 45 }); 48 46 … … 59 57 } 60 58 61 62 59 /** 63 60 * Check template with positive zoom index … … 106 103 "http://localhost/2/1/2" 107 104 ); 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)); 108 116 } 109 117 … … 176 184 assertEquals(expected312, ts.getTileUrl(3, 1, 2)); 177 185 } 186 178 187 /** 179 188 * Tests all entries in TEST_DATA. This test will fail if {switch:...} template is used … … 181 190 @Test 182 191 public void testAllUrls() { 183 for(String[] test: TEST_DATA) { 192 for (String[] test: TEST_DATA) { 184 193 TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", test[0], "id1"); 185 194 TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS); … … 190 199 191 200 public static void main(String[] args) { 192 for(String url: TMS_IMAGERIES) { 201 for (String url: TMS_IMAGERIES) { 193 202 TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", url, "id1"); 194 203 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))); 196 206 } 197 207 } 198 199 208 }
Note:
See TracChangeset
for help on using the changeset viewer.