File file = getDataDirectory().findFile(urlPath.substring("http://localhost:8080/geoserver/".length()));
assertNotNull(file);
assertEquals("test.gpkg", file.getName());
assertTrue(file.exists());
GeoPackage gpkg = new GeoPackage(file);
List<FeatureEntry> features = gpkg.features();
assertEquals(2, features.size());
FeatureEntry fe = features.get(0);
assertEquals("Fifteen", fe.getTableName());
assertEquals("fifteen description", fe.getDescription());
assertEquals("f15", fe.getIdentifier());
assertEquals(32615, fe.getSrid().intValue());
assertEquals(500000, fe.getBounds().getMinX(), 0.0001);
assertEquals(500000, fe.getBounds().getMinY(), 0.0001);
assertEquals(500100, fe.getBounds().getMaxX(), 0.0001);
assertEquals(500100, fe.getBounds().getMaxY(), 0.0001);
SimpleFeatureReader fr = gpkg.reader(fe, null, null);
assertEquals(1, fr.getFeatureType().getAttributeCount());
assertEquals("pointProperty", fr.getFeatureType().getAttributeDescriptors().get(0).getLocalName());
assertTrue(fr.hasNext());
fr.next();
fr.close();
fe = features.get(1);
assertEquals("Lakes", fe.getTableName());
assertEquals("lakes description", fe.getDescription());
assertEquals("lakes1", fe.getIdentifier());
fr = gpkg.reader(fe, null, null);
assertTrue(fr.hasNext());
fr.next();
fr.close();
List<TileEntry> tiles = gpkg.tiles();
assertEquals(2, tiles.size());
TileEntry te = tiles.get(0);
assertEquals("world_lakes", te.getTableName());
assertEquals("world and lakes overlay", te.getDescription());
assertEquals("wl1", te.getIdentifier());
assertEquals(4326, te.getSrid().intValue());
assertEquals(-0.17578125, te.getBounds().getMinX(), 0.0001);
assertEquals(-0.087890625, te.getBounds().getMinY(), 0.0001);
assertEquals(0.17578125, te.getBounds().getMaxX(), 0.0001);
assertEquals(0.087890625, te.getBounds().getMaxY(), 0.0001);
List<TileMatrix> matrices = te.getTileMatricies();
assertEquals(1, matrices.size());
TileMatrix matrix = matrices.get(0);
assertEquals(10, matrix.getZoomLevel().intValue());
assertEquals(256, matrix.getTileWidth().intValue());
assertEquals(256, matrix.getTileHeight().intValue());
assertEquals(2048, matrix.getMatrixWidth().intValue());
assertEquals(1024, matrix.getMatrixHeight().intValue());
TileReader tr = gpkg.reader(te, null, null, null, null, null, null);
assertTrue(tr.hasNext());
assertEquals(10, tr.next().getZoom().intValue());
tr.close();
te = tiles.get(1);
assertEquals("world_lakes2", te.getTableName());
assertEquals("world and lakes overlay 2", te.getDescription());
assertEquals("wl2", te.getIdentifier());
assertEquals(4326, te.getSrid().intValue());
assertEquals(-0.17578125, te.getBounds().getMinX(), 0.0001);
assertEquals(-0.087890625, te.getBounds().getMinY(), 0.0001);
assertEquals(0.17578125, te.getBounds().getMaxX(), 0.0001);
assertEquals(0.087890625, te.getBounds().getMaxY(), 0.0001);
gpkg.close();
}