diff --git a/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/MBTilesBenchmark.java b/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/MBTilesBenchmark.java index dc333999e..3754ae6f7 100644 --- a/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/MBTilesBenchmark.java +++ b/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/MBTilesBenchmark.java @@ -22,8 +22,8 @@ import java.util.concurrent.TimeUnit; import org.apache.baremaps.tilestore.TileCoord; import org.apache.baremaps.tilestore.TileStoreException; -import org.apache.baremaps.tilestore.mbtiles.MBTiles; -import org.apache.baremaps.workflow.tasks.ExportVectorTiles; +import org.apache.baremaps.tilestore.mbtiles.MBTilesStore; +import org.apache.baremaps.utils.SqliteUtils; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; @@ -42,13 +42,13 @@ public class MBTilesBenchmark { private Path file; - private MBTiles mbTiles; + private MBTilesStore mbTilesStore; @Setup public void setup() throws IOException, TileStoreException { file = Files.createTempFile(Paths.get("."), "baremaps", ".mbtiles"); - mbTiles = new MBTiles(ExportVectorTiles.createDataSource(file)); - mbTiles.initializeDatabase(); + mbTilesStore = new MBTilesStore(SqliteUtils.createDataSource(file, false)); + mbTilesStore.initializeDatabase(); } @TearDown @@ -62,7 +62,7 @@ public void writeMBTiles(MBTilesBenchmark benchmark) throws TileStoreException { for (int i = 0; i < benchmark.iterations; i++) { var bytes = new byte[1 << 16]; random.nextBytes(bytes); - mbTiles.put(new TileCoord(0, 0, i), ByteBuffer.wrap(bytes)); + mbTilesStore.put(new TileCoord(0, 0, i), ByteBuffer.wrap(bytes)); } } @@ -78,12 +78,12 @@ public void writeMBTilesBatch(MBTilesBenchmark benchmark) throws TileStoreExcept buffers.add(ByteBuffer.wrap(bytes)); if (coords.size() == 100) { random.nextBytes(bytes); - mbTiles.put(coords, buffers); + mbTilesStore.put(coords, buffers); coords.clear(); buffers.clear(); } } - mbTiles.put(coords, buffers); + mbTilesStore.put(coords, buffers); coords.clear(); buffers.clear(); } diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java index b0daab3c1..c77b1444b 100644 --- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java +++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java @@ -23,12 +23,13 @@ import java.util.function.Supplier; import org.apache.baremaps.cli.Options; import org.apache.baremaps.config.ConfigReader; -import org.apache.baremaps.postgres.PostgresUtils; import org.apache.baremaps.server.*; import org.apache.baremaps.tilestore.TileStore; import org.apache.baremaps.tilestore.postgres.PostgresTileStore; import org.apache.baremaps.vectortile.style.Style; import org.apache.baremaps.vectortile.tilejson.TileJSON; +import org.apache.baremaps.server.CorsFilter; +import org.apache.baremaps.utils.PostgresUtils; import org.apache.baremaps.vectortile.tileset.Tileset; import org.glassfish.hk2.api.TypeLiteral; import org.glassfish.hk2.utilities.binding.AbstractBinder; @@ -69,7 +70,7 @@ public Integer call() throws Exception { var configReader = new ConfigReader(); var objectMapper = objectMapper(); var tileset = objectMapper.readValue(configReader.read(this.tilesetPath), Tileset.class); - var datasource = PostgresUtils.dataSource(tileset.getDatabase()); + var datasource = PostgresUtils.createDataSource(tileset.getDatabase()); var tileStoreType = new TypeLiteral>() {}; var tileStoreSupplier = (Supplier) () -> { diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/MBTiles.java b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/MBTiles.java index 0f8c7f50b..67924764c 100644 --- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/MBTiles.java +++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/MBTiles.java @@ -26,7 +26,8 @@ import org.apache.baremaps.server.ServerResources; import org.apache.baremaps.tilestore.TileCache; import org.apache.baremaps.tilestore.TileStore; -import org.apache.baremaps.workflow.tasks.ExportVectorTiles; +import org.apache.baremaps.tilestore.mbtiles.MBTilesStore; +import org.apache.baremaps.utils.SqliteUtils; import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.server.ResourceConfig; import org.slf4j.Logger; @@ -48,15 +49,15 @@ public class MBTiles implements Callable { @Option(names = {"--mbtiles"}, paramLabel = "MBTILES", description = "The mbtiles file.", required = true) - private Path mbtiles; + private Path mbtilesPath; @Option(names = {"--tilejson"}, paramLabel = "TILEJSON", description = "The tileJSON file.", required = true) - private Path tileset; + private Path tileJSONPath; @Option(names = {"--style"}, paramLabel = "STYLE", description = "The style file.", required = true) - private Path style; + private Path stylePath; @Option(names = {"--port"}, paramLabel = "PORT", description = "The port of the server.") private int port = 9000; @@ -65,9 +66,9 @@ public class MBTiles implements Callable { public Integer call() throws Exception { var objectMapper = objectMapper(); var caffeineSpec = CaffeineSpec.parse(cache); - var datasource = ExportVectorTiles.createDataSource(mbtiles); + var datasource = SqliteUtils.createDataSource(mbtilesPath, true); - var tileStore = new org.apache.baremaps.tilestore.mbtiles.MBTiles(datasource); + var tileStore = new MBTilesStore(datasource); var tileCache = new TileCache(tileStore, caffeineSpec); // Configure the application @@ -76,8 +77,8 @@ public Integer call() throws Exception { .register(newContextResolver(objectMapper)).register(new AbstractBinder() { @Override protected void configure() { - bind(tileset).to(Path.class).named("tileset"); - bind(style).to(Path.class).named("style"); + bind(tileJSONPath).to(Path.class).named("tileset"); + bind(stylePath).to(Path.class).named("style"); bind(tileCache).to(TileStore.class); bind(objectMapper).to(ObjectMapper.class); } diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Serve.java b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Serve.java index e0002b032..5c1fa5add 100644 --- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Serve.java +++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Serve.java @@ -23,13 +23,15 @@ import java.util.function.Supplier; import org.apache.baremaps.cli.Options; import org.apache.baremaps.config.ConfigReader; -import org.apache.baremaps.postgres.PostgresUtils; + import org.apache.baremaps.server.*; import org.apache.baremaps.tilestore.TileCache; import org.apache.baremaps.tilestore.TileStore; import org.apache.baremaps.tilestore.postgres.PostgresTileStore; import org.apache.baremaps.vectortile.style.Style; import org.apache.baremaps.vectortile.tilejson.TileJSON; +import org.apache.baremaps.server.CorsFilter; +import org.apache.baremaps.utils.PostgresUtils; import org.apache.baremaps.vectortile.tileset.Tileset; import org.glassfish.hk2.api.TypeLiteral; import org.glassfish.hk2.utilities.binding.AbstractBinder; @@ -71,7 +73,7 @@ public Integer call() throws Exception { var configReader = new ConfigReader(); var tileset = objectMapper.readValue(configReader.read(this.tilesetPath), Tileset.class); var caffeineSpec = CaffeineSpec.parse(cache); - var datasource = PostgresUtils.dataSource(tileset.getDatabase()); + var datasource = PostgresUtils.createDataSource(tileset.getDatabase()); var tileStoreSupplierType = new TypeLiteral>() {}; var tileStore = new PostgresTileStore(datasource, tileset); diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/ogcapi/OgcApi.java b/baremaps-cli/src/main/java/org/apache/baremaps/cli/ogcapi/OgcApi.java index ea1a7e244..e596edc4f 100644 --- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/ogcapi/OgcApi.java +++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/ogcapi/OgcApi.java @@ -27,11 +27,11 @@ import org.apache.baremaps.cli.Options; import org.apache.baremaps.config.ConfigReader; import org.apache.baremaps.ogcapi.*; -import org.apache.baremaps.postgres.PostgresUtils; import org.apache.baremaps.server.CorsFilter; import org.apache.baremaps.tilestore.TileCache; import org.apache.baremaps.tilestore.TileStore; import org.apache.baremaps.tilestore.postgres.PostgresTileStore; +import org.apache.baremaps.utils.PostgresUtils; import org.apache.baremaps.vectortile.tileset.Tileset; import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.media.multipart.MultiPartFeature; @@ -78,7 +78,7 @@ public Integer call() throws Exception { var configReader = new ConfigReader(); var config = objectMapper.readValue(configReader.read(this.tileset), Tileset.class); var caffeineSpec = CaffeineSpec.parse(cache); - var dataSource = PostgresUtils.dataSource(database); + var dataSource = PostgresUtils.createDataSource(database); var tileStore = new PostgresTileStore(dataSource, config); var tileCache = new TileCache(tileStore, caffeineSpec); diff --git a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTiles.java b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTilesStore.java similarity index 98% rename from baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTiles.java rename to baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTilesStore.java index 0344aed55..9539d9a53 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTiles.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTilesStore.java @@ -34,7 +34,7 @@ * MBTiles file format for storing * tiles. */ -public class MBTiles implements TileStore { +public class MBTilesStore implements TileStore { private static final String CREATE_TABLE_METADATA = "CREATE TABLE IF NOT EXISTS metadata (name TEXT, value TEXT, PRIMARY KEY (name))"; @@ -67,7 +67,7 @@ public class MBTiles implements TileStore { * * @param dataSource the SQLite datasource */ - public MBTiles(DataSource dataSource) { + public MBTilesStore(DataSource dataSource) { this.dataSource = dataSource; } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/postgres/PostgresUtils.java b/baremaps-core/src/main/java/org/apache/baremaps/utils/PostgresUtils.java similarity index 81% rename from baremaps-core/src/main/java/org/apache/baremaps/postgres/PostgresUtils.java rename to baremaps-core/src/main/java/org/apache/baremaps/utils/PostgresUtils.java index 70f0667ae..ab5cf6e31 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/postgres/PostgresUtils.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/utils/PostgresUtils.java @@ -10,7 +10,7 @@ * the License. */ -package org.apache.baremaps.postgres; +package org.apache.baremaps.utils; @@ -29,10 +29,11 @@ public final class PostgresUtils { private PostgresUtils() {} - public static HikariDataSource dataSource(String host, Integer port, String database, + public static HikariDataSource createDataSource(String host, Integer port, String database, String username, String password) { - return dataSource(String.format("jdbc:postgresql://%s:%s/%s?&user=%s&password=%s", host, port, - database, username, password)); + return createDataSource( + String.format("jdbc:postgresql://%s:%s/%s?&user=%s&password=%s", host, port, + database, username, password)); } /** @@ -42,8 +43,8 @@ public static HikariDataSource dataSource(String host, Integer port, String data * @param url the JDBC url * @return the data source */ - public static HikariDataSource dataSource(String url) { - return dataSource(url, Runtime.getRuntime().availableProcessors()); + public static HikariDataSource createDataSource(String url) { + return createDataSource(url, Runtime.getRuntime().availableProcessors()); } /** @@ -53,7 +54,7 @@ public static HikariDataSource dataSource(String url) { * @param poolSize the pool size * @return the data source */ - public static HikariDataSource dataSource(String url, int poolSize) { + public static HikariDataSource createDataSource(String url, int poolSize) { if (poolSize < 1) { throw new IllegalArgumentException("PoolSize cannot be inferior to 1"); } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/utils/SqliteUtils.java b/baremaps-core/src/main/java/org/apache/baremaps/utils/SqliteUtils.java index 4b9379549..1ca6baaac 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/utils/SqliteUtils.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/utils/SqliteUtils.java @@ -15,17 +15,56 @@ import com.google.common.io.Resources; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; import java.io.IOException; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Path; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; +import org.sqlite.SQLiteConfig; +import org.sqlite.SQLiteConfig.JournalMode; +import org.sqlite.SQLiteConfig.LockingMode; +import org.sqlite.SQLiteConfig.SynchronousMode; +import org.sqlite.SQLiteConfig.TempStore; +import org.sqlite.SQLiteDataSource; /** A helper class for creating executing sql scripts onto a SQLite database */ public final class SqliteUtils { + private SqliteUtils() {} + + /** + * Create a SQLite data source. + * + * @param path the path to the SQLite database + * @param readOnly + * @return the SQLite data source + */ + public static HikariDataSource createDataSource(Path path, boolean readOnly) { + var sqliteConfig = new SQLiteConfig(); + sqliteConfig.setCacheSize(1000000); + sqliteConfig.setPageSize(65536); + sqliteConfig.setJournalMode(JournalMode.OFF); + sqliteConfig.setLockingMode(LockingMode.EXCLUSIVE); + sqliteConfig.setSynchronous(SynchronousMode.OFF); + sqliteConfig.setTempStore(TempStore.MEMORY); + sqliteConfig.setReadOnly(readOnly); + + var sqliteDataSource = new SQLiteDataSource(); + sqliteDataSource.setConfig(sqliteConfig); + sqliteDataSource.setUrl("jdbc:sqlite:" + path); + + var hikariConfig = new HikariConfig(); + hikariConfig.setDataSource(sqliteDataSource); + hikariConfig.setMaximumPoolSize(1); + + return new HikariDataSource(hikariConfig); + } + /** * Executes the queries contained in a resource file. * diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java index 1cc7fab68..eff85f265 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java @@ -17,7 +17,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.sql.DataSource; -import org.apache.baremaps.postgres.PostgresUtils; +import org.apache.baremaps.utils.PostgresUtils; /** * A context that is passed to the tasks of a workflow and used to share data between tasks. @@ -33,7 +33,7 @@ public class WorkflowContext { * @return the data source */ public DataSource getDataSource(String database) { - return dataSources.computeIfAbsent(database, d -> PostgresUtils.dataSource(d)); + return dataSources.computeIfAbsent(database, d -> PostgresUtils.createDataSource(d)); } } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java index 43040de82..b33377e5f 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java @@ -16,8 +16,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -30,8 +28,9 @@ import org.apache.baremaps.stream.StreamUtils; import org.apache.baremaps.tilestore.*; import org.apache.baremaps.tilestore.file.FileTileStore; -import org.apache.baremaps.tilestore.mbtiles.MBTiles; +import org.apache.baremaps.tilestore.mbtiles.MBTilesStore; import org.apache.baremaps.tilestore.postgres.PostgresTileStore; +import org.apache.baremaps.utils.SqliteUtils; import org.apache.baremaps.vectortile.tileset.Tileset; import org.apache.baremaps.vectortile.tileset.TilesetQuery; import org.apache.baremaps.workflow.Task; @@ -39,12 +38,6 @@ import org.locationtech.jts.geom.Envelope; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sqlite.SQLiteConfig; -import org.sqlite.SQLiteConfig.JournalMode; -import org.sqlite.SQLiteConfig.LockingMode; -import org.sqlite.SQLiteConfig.SynchronousMode; -import org.sqlite.SQLiteConfig.TempStore; -import org.sqlite.SQLiteDataSource; public record ExportVectorTiles( Path tileset, @@ -86,8 +79,8 @@ private TileStore sourceTileStore(Tileset tileset, DataSource datasource) { private TileStore targetTileStore(Tileset source) throws TileStoreException, IOException { if (mbtiles) { Files.deleteIfExists(repository); - var dataSource = createDataSource(repository); - var tilesStore = new MBTiles(dataSource); + var dataSource = SqliteUtils.createDataSource(repository, false); + var tilesStore = new MBTilesStore(dataSource); tilesStore.initializeDatabase(); tilesStore.writeMetadata(metadata(source)); return tilesStore; @@ -138,29 +131,4 @@ private Map metadata(Tileset tileset) throws JsonProcessingExcep return metadata; } - /** - * Create a SQLite data source. - * - * @param path the path to the SQLite database - * @return the SQLite data source - */ - public static DataSource createDataSource(Path path) { - var sqliteConfig = new SQLiteConfig(); - sqliteConfig.setCacheSize(1000000); - sqliteConfig.setPageSize(65536); - sqliteConfig.setJournalMode(JournalMode.OFF); - sqliteConfig.setLockingMode(LockingMode.EXCLUSIVE); - sqliteConfig.setSynchronous(SynchronousMode.OFF); - sqliteConfig.setTempStore(TempStore.MEMORY); - - var sqliteDataSource = new SQLiteDataSource(); - sqliteDataSource.setConfig(sqliteConfig); - sqliteDataSource.setUrl("jdbc:sqlite:" + path); - - var hikariConfig = new HikariConfig(); - hikariConfig.setDataSource(sqliteDataSource); - hikariConfig.setMaximumPoolSize(1); - - return new HikariDataSource(hikariConfig); - } } diff --git a/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/postgres/PostgresRepositoryTest.java b/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/postgres/PostgresRepositoryTest.java index 00a1f888a..9da06fdff 100644 --- a/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/postgres/PostgresRepositoryTest.java +++ b/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/postgres/PostgresRepositoryTest.java @@ -18,8 +18,8 @@ import java.sql.Connection; import java.sql.SQLException; import javax.sql.DataSource; -import org.apache.baremaps.postgres.PostgresUtils; import org.apache.baremaps.testing.PostgresContainerTest; +import org.apache.baremaps.utils.PostgresUtils; import org.junit.jupiter.api.BeforeEach; public abstract class PostgresRepositoryTest extends PostgresContainerTest { diff --git a/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/repository/BlockImporterTest.java b/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/repository/BlockImporterTest.java index 3d3d14408..3b645c43d 100644 --- a/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/repository/BlockImporterTest.java +++ b/baremaps-core/src/test/java/org/apache/baremaps/openstreetmap/repository/BlockImporterTest.java @@ -27,9 +27,9 @@ import org.apache.baremaps.openstreetmap.postgres.PostgresNodeRepository; import org.apache.baremaps.openstreetmap.postgres.PostgresRelationRepository; import org.apache.baremaps.openstreetmap.postgres.PostgresWayRepository; -import org.apache.baremaps.postgres.PostgresUtils; import org.apache.baremaps.testing.PostgresContainerTest; import org.apache.baremaps.testing.TestFiles; +import org.apache.baremaps.utils.PostgresUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -44,7 +44,7 @@ class BlockImporterTest extends PostgresContainerTest { @BeforeEach void init() throws SQLException, IOException { - dataSource = PostgresUtils.dataSource(jdbcUrl(), 1); + dataSource = PostgresUtils.createDataSource(jdbcUrl(), 1); headerRepository = new PostgresHeaderRepository(dataSource); nodeRepository = new PostgresNodeRepository(dataSource); tableRepository = new PostgresWayRepository(dataSource); diff --git a/baremaps-core/src/test/java/org/apache/baremaps/postgres/metadata/PostgresMetadataTest.java b/baremaps-core/src/test/java/org/apache/baremaps/postgres/metadata/PostgresMetadataTest.java index cf3e93670..411318cef 100644 --- a/baremaps-core/src/test/java/org/apache/baremaps/postgres/metadata/PostgresMetadataTest.java +++ b/baremaps-core/src/test/java/org/apache/baremaps/postgres/metadata/PostgresMetadataTest.java @@ -20,8 +20,8 @@ import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; -import org.apache.baremaps.postgres.PostgresUtils; import org.apache.baremaps.testing.PostgresContainerTest; +import org.apache.baremaps.utils.PostgresUtils; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; diff --git a/baremaps-core/src/test/java/org/apache/baremaps/tilestore/mbtiles/MBTilesTest.java b/baremaps-core/src/test/java/org/apache/baremaps/tilestore/mbtiles/MBTilesStoreTest.java similarity index 90% rename from baremaps-core/src/test/java/org/apache/baremaps/tilestore/mbtiles/MBTilesTest.java rename to baremaps-core/src/test/java/org/apache/baremaps/tilestore/mbtiles/MBTilesStoreTest.java index b677e5d5a..f28154b4e 100644 --- a/baremaps-core/src/test/java/org/apache/baremaps/tilestore/mbtiles/MBTilesTest.java +++ b/baremaps-core/src/test/java/org/apache/baremaps/tilestore/mbtiles/MBTilesStoreTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test; import org.sqlite.SQLiteDataSource; -class MBTilesTest extends TileStoreTest { +class MBTilesStoreTest extends TileStoreTest { Path file; @@ -43,18 +43,18 @@ void after() throws IOException { } @Override - public MBTiles createTileStore() throws Exception { + public MBTilesStore createTileStore() throws Exception { SQLiteDataSource dataSource = new SQLiteDataSource(); String url = "jdbc:sqlite:" + file.toAbsolutePath(); dataSource.setUrl(url); - MBTiles tilesStore = new MBTiles(dataSource); + MBTilesStore tilesStore = new MBTilesStore(dataSource); tilesStore.initializeDatabase(); return tilesStore; } @Test void readWriteMetadata() throws Exception { - MBTiles tileStore = createTileStore(); + MBTilesStore tileStore = createTileStore(); Map metadata = tileStore.readMetadata(); assertTrue(metadata.size() == 0); diff --git a/baremaps-ogcapi/src/test/java/org/apache/baremaps/ogcapi/OgcApiTest.java b/baremaps-ogcapi/src/test/java/org/apache/baremaps/ogcapi/OgcApiTest.java index 6cff8fa58..0b8b0dbda 100644 --- a/baremaps-ogcapi/src/test/java/org/apache/baremaps/ogcapi/OgcApiTest.java +++ b/baremaps-ogcapi/src/test/java/org/apache/baremaps/ogcapi/OgcApiTest.java @@ -20,9 +20,9 @@ import java.nio.file.Path; import java.nio.file.Paths; import javax.sql.DataSource; -import org.apache.baremaps.postgres.PostgresUtils; import org.apache.baremaps.tilestore.TileStore; import org.apache.baremaps.tilestore.postgres.PostgresTileStore; +import org.apache.baremaps.utils.PostgresUtils; import org.apache.baremaps.vectortile.tileset.Tileset; import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.client.ClientConfig; @@ -40,7 +40,7 @@ public abstract class OgcApiTest extends JerseyTest { @Override protected ResourceConfig configure() { // Create a datasource to a throwaway postgis database - dataSource = PostgresUtils.dataSource("jdbc:tc:postgis:13-3.1:///baremaps"); + dataSource = PostgresUtils.createDataSource("jdbc:tc:postgis:13-3.1:///baremaps"); // Initialize the database try (var connection = dataSource.getConnection()) {