Package org.jdbi.v3.testing.junit5
Class JdbiH2Extension
java.lang.Object
org.jdbi.v3.testing.junit5.JdbiExtension
org.jdbi.v3.testing.junit5.JdbiH2Extension
- All Implemented Interfaces:
- AfterAllCallback,- AfterEachCallback,- BeforeAllCallback,- BeforeEachCallback,- Extension,- ParameterResolver
Jdbi H2 JUnit 5 rule.
 Override methods for special case construction:
 
     @RegisterExtension
     public JdbiExtension extension = new JdbiH2Extension() {
         @Override
         protected DataSource createDataSource() {
            ...
         }
     };
 ExtendWith:
 
 @ExtendWith(JdbiH2Extension.class)
 public class DatabaseTest {
     @Test
     public void testWithJdbi(Jdbi jdbi) {
         ...
     }
     @Test
     public void testWithHandle(Handle handle) {
         ...
     }
 }
 - 
Constructor SummaryConstructorsConstructorDescriptionJdbiH2Extension(String options) Allows setting the options string for the H2 database.
- 
Method SummaryModifier and TypeMethodDescriptiongetUrl()Returns a JDBC url representing the data source used by this extension.withCredentials(String user, String password) Sets the H2 username and password.Sets the H2 username.Methods inherited from class org.jdbi.v3.testing.junit5.JdbiExtensionafterAll, afterEach, attach, beforeAll, beforeEach, enableLeakChecker, externalPostgres, getJdbi, getSharedHandle, h2, installPlugins, openHandle, otjEmbeddedPostgres, postgres, resolveParameter, sqlite, supportsParameter, withConfig, withInitializer, withPlugin, withPlugins
- 
Constructor Details- 
JdbiH2Extensionpublic JdbiH2Extension()
- 
JdbiH2ExtensionAllows setting the options string for the H2 database. The value here is appended to the database URL.- Parameters:
- options- The options string. Must not be null. May start with a semicolon.
 
 
- 
- 
Method Details- 
withUserSets the H2 username.- Parameters:
- user- The username. Can be null.
- Returns:
- This object.
 
- 
withCredentialsSets the H2 username and password.- Parameters:
- user- The username. Can be null.
- password- The password. Can be null.
- Returns:
- This object.
 
- 
getUrlDescription 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 class- JdbiExtension
- Returns:
- A string representing the JDBC URL.
 
 
-