}
@Test
public void testGetTile() throws Exception {
InternalTile tile;
TileMetadata tmd = new GetVectorTileRequest();
tmd.setCrs("EPSG:4326");
tmd.setCode(new TileCode(1,0,1));
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();
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"));
// verify that data is in the cache
DummyCacheService cache = (DummyCacheService) cacheManager.getCacheForTesting(LAYER_BEANS, CacheCategory.TILE);
Assert.assertEquals(1, cache.size());
TileCacheContainer tcc = (TileCacheContainer) cache.getObject();
tcc.getTile().setFeatureContent("<dummy />");
// get tile again, the result should be different because we changed the cached value
recorder.clear();
tile = vectorLayerService.getTile(tmd);
Assert.assertNotNull(tile);
Assert.assertEquals("<dummy />", tile.getFeatureContent());
Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Got item from cache"));
Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE));
// ask for different layer, should not be found in cache as context is different
recorder.clear();
tmd.setLayerId(LAYER_COUNTRIES);
tile = vectorLayerService.getTile(tmd);
Assert.assertNotNull(tile);
//Assert.assertEquals(4, features.size());
Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));