}
public void testTilRangeDelete() throws Exception {
FileBlobStore fbs = setup();
Resource bytes = new ByteArrayResource("1 2 3 4 5 6 test".getBytes());
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("a", "x");
parameters.put("b", "ø");
MimeType mime = ImageMime.png;
SRS srs = SRS.getEPSG4326();
String layerName = "test:123123 112";
int zoomLevel = 7;
int x = 25;
int y = 6;
// long[] origXYZ = {x,y,zoomLevel};
TileObject[] tos = new TileObject[6];
for (int i = 0; i < tos.length; i++) {
long[] xyz = { x + i - 1, y, zoomLevel };
tos[i] = TileObject.createCompleteTileObject(layerName, xyz, srs.toString(),
mime.getFormat(), parameters, bytes);
fbs.put(tos[i]);
}
long[][] rangeBounds = new long[zoomLevel + 2][5];
int zoomStart = zoomLevel - 1;
int zoomStop = zoomLevel + 1;
long[] range = { x, y, x + tos.length - 3, y, zoomLevel};
rangeBounds[zoomLevel] = range;
TileRange trObj = new TileRange(layerName, srs.toString(), zoomStart, zoomStop,
rangeBounds, mime, parameters);
fbs.delete(trObj);
// starting x and x + tos.length should have data, the remaining should not
TileObject firstTO = TileObject.createQueryTileObject(layerName, tos[0].xyz,
srs.toString(), mime.getFormat(), parameters);
fbs.get(firstTO);
InputStream is = firstTO.getBlob().getInputStream();
InputStream is2 = bytes.getInputStream();
try {
assertTrue(IOUtils.contentEquals(is, is2));
} finally {
is.close();
is2.close();
}
TileObject lastTO = TileObject.createQueryTileObject(layerName, tos[tos.length - 1].xyz,
srs.toString(), mime.getFormat(), parameters);
fbs.get(lastTO);
is = lastTO.getBlob().getInputStream();
is2 = bytes.getInputStream();
try {
assertTrue(IOUtils.contentEquals(is, is2));
} finally {
is.close();
is2.close();