ThreadScopeContextHolder.clear();
}
@Test
public void testGetTile() throws Exception {
InternalTile tile;
TileMetadata tmd = new GetVectorTileRequest();
tmd.setCrs("EPSG:4326");
tmd.setCode(new TileCode(1,0,0));
tmd.setLayerId(LAYER_BEANS);
tmd.setRenderer(TileMetadata.PARAM_SVG_RENDERER);
tmd.setScale(1.0);
tmd.setPanOrigin(new Coordinate(0, 0));
// first run, this should put things in the cache
recorder.clear();
tmd.setCode(new TileCode(1,0,0));
tile = vectorLayerService.getTile(tmd);
Assert.assertNotNull(tile);
Assert.assertEquals("<g id=\"beans.features.1-0-0\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-0-0.0\"><path fill-rule=\"evenodd\" d=\"M0 0l1 0 0 -1 -1 0 0 1 Z\" id=\"1\"/></g></g>", tile.getFeatureContent());
Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));
// first run, this should put things in the cache
recorder.clear();
tmd.setCode(new TileCode(1,1,0));
tile = vectorLayerService.getTile(tmd);
Assert.assertNotNull(tile);
Assert.assertEquals("<g id=\"beans.features.1-1-0\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-1-0.0\"><path fill-rule=\"evenodd\" d=\"M4 0l2 0 0 -3 -2 0 0 3 Z\" id=\"2\"/></g></g>", tile.getFeatureContent());
Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));
// first run, this should put things in the cache
recorder.clear();
tmd.setCode(new TileCode(1,1,1));
tile = vectorLayerService.getTile(tmd);
Assert.assertNotNull(tile);
Assert.assertEquals("<g id=\"beans.features.1-1-1\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-1-1.0\"><path fill-rule=\"evenodd\" d=\"M2 -1l4 0 1 -1 -5 0 0 1 Z\" id=\"3\"/></g></g>", tile.getFeatureContent());
Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));
// first run, this should put things in the cache
recorder.clear();
tmd.setCode(new TileCode(1,0,1));
tile = vectorLayerService.getTile(tmd);
Assert.assertNotNull(tile);
Assert.assertEquals("<g id=\"beans.features.1-0-1\"/>", tile.getFeatureContent());
Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));
// first run, this should put things in the cache
recorder.clear();
tmd.setCode(new TileCode(1,1,1));
tmd.setScale(2.0);
tile = vectorLayerService.getTile(tmd);
Assert.assertNotNull(tile);
Assert.assertEquals("<g id=\"beans.features.1-1-1\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-1-1.0\"><path fill-rule=\"evenodd\" d=\"M4 -2l8 0 2 -2 -10 0 0 2 Z\" id=\"3\"/></g></g>", tile.getFeatureContent());
Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));
// get tile again, the result should be different because we changed the cached value
recorder.clear();
tmd.setCode(new TileCode(1,1,0));
tmd.setScale(1.0);
tile = vectorLayerService.getTile(tmd);
Assert.assertNotNull(tile);
Assert.assertEquals("<g id=\"beans.features.1-1-0\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-1-0.0\"><path fill-rule=\"evenodd\" d=\"M4 0l2 0 0 -3 -2 0 0 3 Z\" id=\"2\"/></g></g>", tile.getFeatureContent());
Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Got item from cache"));
Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE));
}