msdalp / dropwizard-jdbi

Simple dropwizard 1.0.0 service using JDBI to talk to a DB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dropwizard JDBI

BuildStatus

Test project for Dropwizard 10 using JDBI to interact with a DB.

Also using Flyway and H2 to create an in memory DB with test data for integration testing. Flyway solution can be expanded to create a fully featured Database Migration process using any JBDC compatible Database you can connect to. Using it here was overkill as I could have just used a simple script, I wanted to try it out as a comparison to Liquibase.

Code for JDBI integration was trivial, most of the effort was getting my head around the fact that I didn't have to do anything to startup the H2 instance (it starts itself as embedded instance when you try to connect to the local DB file by black magic). For reference the most useful stuff is probably in the build.gradle, libraries and plugins used.

Didn't do integration tests as I figured for a real project it would make more sense to do full stack integration testing against the service and the production DB.

Setup H2 DB

Creates an H2 DB populated with the migration scripts in src/main/resources/db/migration

gradle flywayMigrate -i

Run Dropwizard service

To compile:

gradle build

To run:

gradle run

Running the service will start an embedded H2 instance using the person.mv.db file generated by flyway.

To test:

gradle test

About

Simple dropwizard 1.0.0 service using JDBI to talk to a DB


Languages

Language:Java 100.0%