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

public class JdbiGenericExtension extends JdbiExtension
Very simple implementation of a JUnit 5 JdbiExtension which can handle any JDBC connection.
  • Constructor Details

    • JdbiGenericExtension

      public JdbiGenericExtension(String jdbcUri)
      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

      public String 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. the JdbiSqliteExtension returns a constant uri for all database instances).
      Specified by:
      getUrl in class JdbiExtension
      Returns:
      A string representing the JDBC URL.
    • withUser

      public JdbiGenericExtension withUser(String user)
      Sets the username.
      Parameters:
      user - The username. Can be null.
      Returns:
      This object.
    • withCredentials

      public JdbiGenericExtension withCredentials(String user, String password)
      Sets the username and password.
      Parameters:
      user - The username. Can be null.
      password - The password. Can be null.
      Returns:
      This object.