Package org.jdbi.v3.testing.junit5
Class JdbiOtjPostgresExtension
java.lang.Object
org.jdbi.v3.testing.junit5.JdbiExtension
org.jdbi.v3.testing.junit5.JdbiOtjPostgresExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback
,org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
,org.junit.jupiter.api.extension.ParameterResolver
Jdbi PostgreSQL JUnit 5 rule using the otj-pg-embedded component.
Override methods for special case construction:
@RegisterExtension
public JdbiExtension extension = new JdbiOtjPostgresExtension() {
@Override
protected DataSource createDataSource() {
...
}
};
Use with ExtendWith
:
@ExtendWith(JdbiOtjPostgresExtension.class)
public class DatabaseTest {
@Test
public void testWithJdbi(Jdbi jdbi) {
...
}
@Test
public void testWithHandle(Handle handle) {
...
}
}
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterEach
(org.junit.jupiter.api.extension.ExtensionContext context) void
beforeEach
(org.junit.jupiter.api.extension.ExtensionContext context) getUrl()
Returns a JDBC url representing the data source used by this extension.Methods inherited from class org.jdbi.v3.testing.junit5.JdbiExtension
attach, enableLeakChecker, externalPostgres, getJdbi, getSharedHandle, h2, installPlugins, openHandle, otjEmbeddedPostgres, postgres, resolveParameter, sqlite, supportsParameter, withConfig, withInitializer, withPlugin, withPlugins
-
Constructor Details
-
JdbiOtjPostgresExtension
public JdbiOtjPostgresExtension()
-
-
Method Details
-
getUrl
Description copied from class:JdbiExtension
Returns a JDBC url representing the data source used by this extension. This url is database-specific and may or may not be used to connect to the data source outside testing code that uses this extension (e.g. theJdbiSqliteExtension
returns a constant uri for all database instances).- Specified by:
getUrl
in classJdbiExtension
- Returns:
- A string representing the JDBC URL.
-
customize
public JdbiOtjPostgresExtension customize(Consumer<com.opentable.db.postgres.embedded.EmbeddedPostgres.Builder> customizer) -
afterEach
- Specified by:
afterEach
in interfaceorg.junit.jupiter.api.extension.AfterEachCallback
- Overrides:
afterEach
in classJdbiExtension
- Throws:
Exception
-
beforeEach
- Specified by:
beforeEach
in interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
- Overrides:
beforeEach
in classJdbiExtension
- Throws:
Exception
-