@Test public void fileSystemTileCacheTest() { Assert.assertFalse(this.cacheDirectory.exists()); for (int tileSize : TILE_SIZES) { TileCache tileCache = new FileSystemTileCache(1, this.cacheDirectory, GRAPHIC_FACTORY); Assert.assertEquals(1, tileCache.getCapacity()); Assert.assertTrue(this.cacheDirectory.exists()); Assert.assertEquals(0, this.cacheDirectory.list().length); Tile tile = new Tile(0, 0, (byte) 1); TileSource tileSource = OpenStreetMapMapnik.INSTANCE; File mapFile = new File("map.file"); XmlRenderTheme xmlRenderTheme = InternalRenderTheme.OSMARENDER; Job job1 = new DownloadJob(tile, tileSize, tileSource); Job job2 = new RendererJob(tile, mapFile, xmlRenderTheme, new DisplayModel(), 1, false); Assert.assertFalse(tileCache.containsKey(job1)); Assert.assertFalse(tileCache.containsKey(job2)); Assert.assertNull(tileCache.get(job1)); Assert.assertNull(tileCache.get(job2)); TileBitmap bitmap1 = GRAPHIC_FACTORY.createTileBitmap(tileSize, false); tileCache.put(job1, bitmap1); Assert.assertTrue(tileCache.containsKey(job1)); Assert.assertFalse(tileCache.containsKey(job2)); verifyEquals(bitmap1, tileCache.get(job1)); Assert.assertNull(tileCache.get(job2)); TileBitmap bitmap2 = GRAPHIC_FACTORY.createTileBitmap(tileSize, false); tileCache.put(job2, bitmap2); Assert.assertFalse(tileCache.containsKey(job1)); Assert.assertTrue(tileCache.containsKey(job2)); Assert.assertNull(tileCache.get(job1)); verifyEquals(bitmap2, tileCache.get(job2)); tileCache.destroy(); Assert.assertFalse(tileCache.containsKey(job1)); Assert.assertFalse(tileCache.containsKey(job2)); Assert.assertNull(tileCache.get(job1)); Assert.assertNull(tileCache.get(job2)); Assert.assertTrue(this.cacheDirectory.exists()); Assert.assertEquals(0, this.cacheDirectory.list().length); } }
public FileSystemTileCache(int capacity, File cacheDirectory, GraphicFactory graphicFactory) { this.lruCache = new FileLRUCache<>(capacity); this.cacheDirectory = checkDirectory(cacheDirectory); this.graphicFactory = graphicFactory; }
FileSystemTileCache implements TileCache { public FileSystemTileCache(int capacity, File cacheDirectory, GraphicFactory graphicFactory) { this.lruCache = new FileLRUCache<>(capacity); this.cacheDirectory = checkDirectory(cacheDirectory); this.graphicFactory = graphicFactory; } }
FileSystemTileCache implements TileCache { public FileSystemTileCache(int capacity, File cacheDirectory, GraphicFactory graphicFactory) { this.lruCache = new FileLRUCache<>(capacity); this.cacheDirectory = checkDirectory(cacheDirectory); this.graphicFactory = graphicFactory; } FileSystemTileCache(int capacity, File cacheDirectory, GraphicFactory graphicFactory); }
FileSystemTileCache implements TileCache { public FileSystemTileCache(int capacity, File cacheDirectory, GraphicFactory graphicFactory) { this.lruCache = new FileLRUCache<>(capacity); this.cacheDirectory = checkDirectory(cacheDirectory); this.graphicFactory = graphicFactory; } FileSystemTileCache(int capacity, File cacheDirectory, GraphicFactory graphicFactory); @Override synchronized boolean containsKey(Job key); @Override synchronized void destroy(); @Override synchronized TileBitmap get(Job key); @Override synchronized int getCapacity(); @Override synchronized void put(Job key, TileBitmap bitmap); }
FileSystemTileCache implements TileCache { public FileSystemTileCache(int capacity, File cacheDirectory, GraphicFactory graphicFactory) { this.lruCache = new FileLRUCache<>(capacity); this.cacheDirectory = checkDirectory(cacheDirectory); this.graphicFactory = graphicFactory; } FileSystemTileCache(int capacity, File cacheDirectory, GraphicFactory graphicFactory); @Override synchronized boolean containsKey(Job key); @Override synchronized void destroy(); @Override synchronized TileBitmap get(Job key); @Override synchronized int getCapacity(); @Override synchronized void put(Job key, TileBitmap bitmap);  }