Search in sources :

Example 6 with Jackson2Plugin

use of org.jdbi.v3.jackson2.Jackson2Plugin in project baremaps by baremaps.

the class StudioResourceIntegrationTest 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 schema studio"));
    jdbi.useHandle(handle -> handle.execute("create table studio.entities (id uuid primary key, entity jsonb, kind text)"));
    // Configure the service
    return new ResourceConfig().register(StudioResource.class).register(new AbstractBinder() {

        @Override
        protected void configure() {
            bind(jdbi).to(Jdbi.class);
        }
    });
}
Also used : Jdbi(org.jdbi.v3.core.Jdbi) SQLException(java.sql.SQLException) AbstractBinder(org.glassfish.hk2.utilities.binding.AbstractBinder) Connection(java.sql.Connection) Jackson2Plugin(org.jdbi.v3.jackson2.Jackson2Plugin) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Aggregations

AbstractBinder (org.glassfish.hk2.utilities.binding.AbstractBinder)6 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)6 Jdbi (org.jdbi.v3.core.Jdbi)6 Jackson2Plugin (org.jdbi.v3.jackson2.Jackson2Plugin)6 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3 DataSource (javax.sql.DataSource)3 MultiPartFeature (org.glassfish.jersey.media.multipart.MultiPartFeature)2 PostgisPlugin (com.baremaps.postgres.jdbi.PostgisPlugin)1 CorsFilter (com.baremaps.server.common.CorsFilter)1 DefaultObjectMapper.defaultObjectMapper (com.baremaps.server.common.DefaultObjectMapper.defaultObjectMapper)1 ApiResource (com.baremaps.server.ogcapi.ApiResource)1 CollectionsResource (com.baremaps.server.ogcapi.CollectionsResource)1 ConformanceResource (com.baremaps.server.ogcapi.ConformanceResource)1 RootResource (com.baremaps.server.ogcapi.RootResource)1 StylesResource (com.baremaps.server.ogcapi.StylesResource)1 SwaggerResource (com.baremaps.server.ogcapi.SwaggerResource)1 TilesetsResource (com.baremaps.server.ogcapi.TilesetsResource)1 ImportResource (com.baremaps.server.studio.ImportResource)1 StudioResource (com.baremaps.server.studio.StudioResource)1