use of org.jdbi.v3.jackson2.Jackson2Plugin in project baremaps by baremaps.
the class TilesetsResourceIntegrationTest method configure.
@Override
protected ResourceConfig configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
// Create a data source with a throwaway postgres database
DataSource dataSource = PostgresUtils.datasource("jdbc:tc:postgresql:13:///test");
jdbi = Jdbi.create(dataSource).installPlugin(new Jackson2Plugin());
jdbi.useHandle(handle -> handle.execute("create table tilesets (id uuid primary key, tileset jsonb)"));
// Configure the service
return new ResourceConfig().registerClasses(JacksonFeature.class, TilesetsResource.class).register(new AbstractBinder() {
@Override
protected void configure() {
bind(dataSource).to(DataSource.class);
bind(jdbi).to(Jdbi.class);
}
});
}
use of org.jdbi.v3.jackson2.Jackson2Plugin in project baremaps by baremaps.
the class Studio method call.
@Override
public Integer call() throws Exception {
// Configure serialization
ObjectMapper mapper = defaultObjectMapper();
// Configure jdbi and set the ObjectMapper
DataSource datasource = PostgresUtils.datasource(this.database);
Jdbi jdbi = Jdbi.create(datasource).installPlugin(new PostgresPlugin()).installPlugin(new Jackson2Plugin()).configure(Jackson2Config.class, config -> config.setMapper(mapper));
// Initialize the application
ResourceConfig application = new ResourceConfig().registerClasses(SwaggerResource.class, RootResource.class, CorsFilter.class, ConformanceResource.class, CollectionsResource.class, StylesResource.class, TilesetsResource.class, StudioResource.class, ImportResource.class, MultiPartFeature.class).register(new ApiResource("studio-openapi.yaml")).register(contextResolverFor(mapper)).register(new AbstractBinder() {
@Override
protected void configure() {
bind(datasource).to(DataSource.class);
bind(jdbi).to(Jdbi.class);
}
});
BlockingStreamingHttpService httpService = new HttpJerseyRouterBuilder().buildBlockingStreaming(application);
ServerContext serverContext = HttpServers.forPort(port).listenBlockingStreamingAndAwait(httpService);
logger.info("Listening on {}", serverContext.listenAddress());
serverContext.awaitShutdown();
return 0;
}
use of org.jdbi.v3.jackson2.Jackson2Plugin in project baremaps by baremaps.
the class CollectionsResourceIntegrationTest method configure.
@Override
protected ResourceConfig configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
// Create a connection to a throwaway postgres database
Connection connection;
try {
connection = DriverManager.getConnection("jdbc:tc:postgresql:13:///test");
} catch (SQLException throwables) {
throw new RuntimeException("Unable to connect to the database");
}
// Initialize the database
jdbi = Jdbi.create(connection).installPlugin(new Jackson2Plugin());
jdbi.useHandle(handle -> handle.execute("create table collections (id uuid primary key, collection jsonb)"));
// Configure the service
return new ResourceConfig().register(CollectionsResource.class).register(new AbstractBinder() {
@Override
protected void configure() {
bind(jdbi).to(Jdbi.class);
}
});
}
use of org.jdbi.v3.jackson2.Jackson2Plugin in project baremaps by baremaps.
the class StylesResourceIntegrationTest method configure.
@Override
protected ResourceConfig configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
// Create a connection to a throwaway postgres database
Connection connection;
try {
connection = DriverManager.getConnection("jdbc:tc:postgresql:13:///test");
} catch (SQLException throwables) {
throw new RuntimeException("Unable to connect to the database");
}
// Initialize the database
jdbi = Jdbi.create(connection).installPlugin(new Jackson2Plugin());
jdbi.useHandle(handle -> handle.execute("create table styles (id uuid primary key, style jsonb)"));
// Configure the service
return new ResourceConfig().register(StylesResource.class).register(new AbstractBinder() {
@Override
protected void configure() {
bind(jdbi).to(Jdbi.class);
}
});
}
use of org.jdbi.v3.jackson2.Jackson2Plugin in project baremaps by baremaps.
the class ImportResourceIntegrationTest method configure.
@Override
protected ResourceConfig configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
// Create a datasource to a throwaway postgis database
DataSource dataSource = PostgresUtils.datasource(DATABASE_URL);
// Initialize the database
jdbi = Jdbi.create(dataSource).installPlugin(new Jackson2Plugin()).installPlugin(new PostgisPlugin());
jdbi.useHandle(handle -> handle.execute("create extension if not exists hstore;" + "create table collections (id uuid primary key, collection jsonb)"));
// Configure the service
return new ResourceConfig().registerClasses(MultiPartFeature.class, ImportResource.class).register(new AbstractBinder() {
@Override
protected void configure() {
bind(jdbi).to(Jdbi.class);
}
});
}
Aggregations