SimpleTmsUrlBuilder implements TileUrlBuilder { @Override public String buildUrl(TileCode tileCode, String baseTmsUrl) { StringBuilder builder = new StringBuilder(baseTmsUrl); if (!baseTmsUrl.endsWith("/")) { builder.append("/"); } builder.append(tileCode.getTileLevel()); builder.append("/"); builder.append(tileCode.getX()); builder.append("/"); builder.append(tileCode.getY()); builder.append(extension); return builder.toString(); } SimpleTmsUrlBuilder(String extension); @Override String buildUrl(TileCode tileCode, String baseTmsUrl);  }
@Test public void testBuildUrl1() { TileUrlBuilder builder = new SimpleTmsUrlBuilder(EXTENSION); String url = builder.buildUrl(new TileCode(1, 2, 3), BASE_TMS_URL); Assert.assertEquals(EXPECTED, url); }
@Test public void testBuildUrl2() { TileUrlBuilder builder = new SimpleTmsUrlBuilder(EXTENSION); String url = builder.buildUrl(new TileCode(1, 2, 3), BASE_TMS_URL + "/"); Assert.assertEquals(EXPECTED, url); }
@Test public void testBuildUrl3() { TileUrlBuilder builder = new SimpleTmsUrlBuilder("." + EXTENSION); String url = builder.buildUrl(new TileCode(1, 2, 3), BASE_TMS_URL + "/"); Assert.assertEquals(EXPECTED, url); }
@Test public void testBuildUrlCornerCases() { try { new SimpleTmsUrlBuilder(null); Assert.fail(); } catch (IllegalStateException e) { } try { TileUrlBuilder builder = new SimpleTmsUrlBuilder("." + EXTENSION); builder.buildUrl(null, ""); Assert.fail(); } catch (NullPointerException e) { } try { TileUrlBuilder builder = new SimpleTmsUrlBuilder("." + EXTENSION); builder.buildUrl(new TileCode(), null); Assert.fail(); } catch (NullPointerException e) { } }