public abstract class JdbiRule
extends org.junit.rules.ExternalResource
@Rule to manage a Jdbi instance pointed to a managed database.| Constructor and Description |
|---|
JdbiRule() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
after() |
<T> T |
attach(Class<T> extension)
Attach an extension (such as a SqlObject) to the managed handle.
|
protected void |
before() |
protected abstract DataSource |
createDataSource() |
static JdbiRule |
embeddedPostgres()
Create a JdbiRule with an embedded Postgres instance.
|
Handle |
getHandle()
Get the single Handle instance opened for the duration of this test case.
|
Jdbi |
getJdbi()
Get Jdbi, in case you want to open additional handles to the same data source.
|
static JdbiRule |
h2()
Create a JdbiRule with an in-memory H2 database instance.
|
JdbiRule |
migrateWithFlyway()
Run database migration scripts from
db/migration on the classpath, using Flyway. |
JdbiRule |
migrateWithFlyway(String... locations)
Run database migration scripts from the given locations on the classpath, using Flyway.
|
JdbiRule |
withPlugin(JdbiPlugin plugin)
Install a plugin into JdbiRule.
|
JdbiRule |
withPlugins()
Discover and install plugins from the classpath.
|
protected abstract DataSource createDataSource()
public static JdbiRule embeddedPostgres()
otj-pg-embedded artifact.public static JdbiRule h2()
h2 database artifact.public JdbiRule migrateWithFlyway()
db/migration on the classpath, using Flyway.public JdbiRule migrateWithFlyway(String... locations)
public JdbiRule withPlugins()
public JdbiRule withPlugin(JdbiPlugin plugin)
protected void before()
throws Throwable
before in class org.junit.rules.ExternalResourceThrowableprotected void after()
after in class org.junit.rules.ExternalResourcepublic Jdbi getJdbi()
public Handle getHandle()
public <T> T attach(Class<T> extension)
Copyright © 2018. All rights reserved.