Class JdbiPostgresExtension

java.lang.Object
org.jdbi.v3.testing.junit5.JdbiExtension
org.jdbi.v3.testing.junit5.JdbiPostgresExtension
All Implemented Interfaces:
AfterAllCallback, AfterEachCallback, BeforeAllCallback, BeforeEachCallback, Extension, ParameterResolver

public class JdbiPostgresExtension extends JdbiExtension
Jdbi PostgreSQL JUnit 5 rule using the pg-embedded component.

Using this class with the @ExtendWith annotation is equivalent to using the SingleDatabaseBuilder to create a EmbeddedPgExtension that creates a new postgres instance per test. This is slower than using the MultiDatabaseBuilder and using JdbiExtension.postgres(EmbeddedPgExtension).

Override methods for special case construction:


     @RegisterExtension
     public JdbiExtension extension = new JdbiPostgresExtension(pg) {
         @Override
         protected DataSource createDataSource() {
            ...
         }
     };
 

Use with ExtendWith:


 @ExtendWith(JdbiPostgresExtension.class)
 public class DatabaseTest {
     @Test
     public void testWithJdbi(Jdbi jdbi) {
         ...
     }

     @Test
     public void testWithHandle(Handle handle) {
         ...
     }
 }