Index: applications/viewer/jmapviewer/test/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSourceTest.java
===================================================================
--- applications/viewer/jmapviewer/test/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSourceTest.java	(revision 34716)
+++ applications/viewer/jmapviewer/test/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSourceTest.java	(revision 35320)
@@ -1,3 +1,3 @@
-// License: GPL. For details, see LICENSE file.
+// License: GPL. For details, see Readme.txt file.
 package org.openstreetmap.gui.jmapviewer.tilesources;
 
@@ -13,12 +13,10 @@
 import org.junit.Test;
 
-
 /**
- *
  * Tests for TemplaedTMSTileSource
  */
 public class TemplatedTMSTileSourceTest {
 
-    private final static Collection<String> TMS_IMAGERIES = Arrays.asList(new String[]{
+    private static final Collection<String> TMS_IMAGERIES = Arrays.asList(new String[]{
             "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z={zoom}&x={x}&y={-y}",
             /*
@@ -36,13 +34,13 @@
      *  * expected tile url for zoom=3, x=2, y=1
      */
-    @SuppressWarnings("unchecked")
     private Collection<String[]> TEST_DATA = Arrays.asList(new String[][] {
         /*
          * generate with main method below once TMS_IMAGERIES is filled in
          */
-            new String[]{"http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z={zoom}&x={x}&y={-y}", 
-                    "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z=1&x=2&y=-2", 
-                    "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z=3&x=2&y=6"
-                    }
+        new String[] {
+                "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z={zoom}&x={x}&y={-y}", 
+                "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z=1&x=2&y=-2", 
+                "http://imagico.de/map/osmim_tiles.php?layer=S2A_R136_N41_20150831T093006&z=3&x=2&y=6"
+                }
     });
 
@@ -59,5 +57,4 @@
     }
 
-
     /**
      * Check template with positive zoom index
@@ -106,4 +103,15 @@
                 "http://localhost/2/1/2"
                 );
+    }
+
+    /**
+     * Test template with switch
+     */
+    @Test
+    public void testGetTileUrl_apiKey() {
+        System.setProperty("id1.api-key", "wololo");
+        TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", "http://localhost/{zoom}/{x}/{y}?token={apiKey}&foo=bar", "id1");
+        TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS);
+        assertEquals("http://localhost/1/2/3?token=wololo&foo=bar", ts.getTileUrl(1, 2, 3));
     }
 
@@ -176,4 +184,5 @@
         assertEquals(expected312, ts.getTileUrl(3, 1, 2));
     }
+
     /**
      * Tests all entries in TEST_DATA. This test will fail if {switch:...} template is used
@@ -181,5 +190,5 @@
     @Test
     public void testAllUrls() {
-        for(String[] test: TEST_DATA) {
+        for (String[] test: TEST_DATA) {
             TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", test[0], "id1");
             TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS);
@@ -190,10 +199,10 @@
 
     public static void main(String[] args) {
-        for(String url: TMS_IMAGERIES) {
+        for (String url: TMS_IMAGERIES) {
             TileSourceInfo testImageryTMS = new TileSourceInfo("test imagery", url, "id1");
             TemplatedTMSTileSource ts = new TemplatedTMSTileSource(testImageryTMS);
-            System.out.println(MessageFormat.format("new String[]{\"{0}\", \"{1}\", \"{2}\"},", url, ts.getTileUrl(1, 2, 3), ts.getTileUrl(3, 2, 1)));
+            System.out.println(MessageFormat.format("new String[]{\"{0}\", \"{1}\", \"{2}\"},",
+                    url, ts.getTileUrl(1, 2, 3), ts.getTileUrl(3, 2, 1)));
         }
     }
-
 }
