Package org.jdbi.v3.testing.junit5
Class JdbiGenericExtension
java.lang.Object
org.jdbi.v3.testing.junit5.JdbiExtension
org.jdbi.v3.testing.junit5.JdbiGenericExtension
- All Implemented Interfaces:
AfterAllCallback,AfterEachCallback,BeforeAllCallback,BeforeEachCallback,Extension,ParameterResolver,TestInstantiationAwareExtension
Very simple implementation of a JUnit 5
JdbiExtension which can handle any JDBC connection.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
TestInstantiationAwareExtension.ExtensionContextScope -
Constructor Summary
ConstructorsConstructorDescriptionJdbiGenericExtension(String jdbcUri) Creates a new instance for a given JDBC URI. -
Method Summary
Modifier and TypeMethodDescriptiongetUrl()Returns a JDBC url representing the data source used by this extension.withCredentials(String user, String password) Sets the username and password.Sets the username.Methods inherited from class org.jdbi.v3.testing.junit5.JdbiExtension
afterAll, afterEach, attach, beforeAll, beforeEach, enableLeakChecker, externalPostgres, getJdbi, getSharedHandle, h2, installPlugins, openHandle, otjEmbeddedPostgres, postgres, resolveParameter, sqlite, supportsParameter, withConfig, withInitializer, withPlugin, withPluginsMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
getTestInstantiationExtensionContextScope
-
Constructor Details
-
JdbiGenericExtension
Creates a new instance for a given JDBC URI. The driver for the database must be on the classpath!- Parameters:
jdbcUri- A JDBC URI.
-
-
Method Details
-
getUrl
Description copied from class:JdbiExtensionReturns 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. theJdbiSqliteExtensionreturns a constant uri for all database instances).- Specified by:
getUrlin classJdbiExtension- Returns:
- A string representing the JDBC URL.
-
withUser
Sets the username.- Parameters:
user- The username. Can be null.- Returns:
- This object.
-
withCredentials
Sets the username and password.- Parameters:
user- The username. Can be null.password- The password. Can be null.- Returns:
- This object.
-