Package fr.ght1pc9kc.testy.jooq
Class WithDatabaseLoaded
java.lang.Object
fr.ght1pc9kc.testy.jooq.WithDatabaseLoaded
- All Implemented Interfaces:
org.junit.jupiter.api.extension.BeforeAllCallback
,org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
public final class WithDatabaseLoaded
extends Object
implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback
This extension depends on a DatasourceExtension
and runs a Flyway
migration on the related DB catalog.
By default, the SQL scripts have to be located into db.migration.<catalog>
in the classpath, where <catalog>
is the name of DataSource catalog. The names of the SQL files shall match
Flyway naming convention.
The SQL scripts are run **before all the test methods**. They are expected to be used to create the database schema.
private static final WithInMemoryDatasource wDataSource = WithInMemoryDatasource.builder()
.setCatalog("my_catalog")
.build();
// SQL files shall be located in classpath:db.migration.my_catalog
private static final WithDatabaseLoaded wDatabaseLoaded = WithDatabaseLoaded.builder()
.setDatasourceExtension(wDataSource)
.build();
@RegisterExtension
static final ChainedExtension chain = ChainedExtension
.outer(wDataSource)
.append(wDatabaseLoaded)
.register();
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
beforeAll
(org.junit.jupiter.api.extension.ExtensionContext context) void
beforeEach
(org.junit.jupiter.api.extension.ExtensionContext context) builder()
-
Constructor Details
-
WithDatabaseLoaded
public WithDatabaseLoaded()
-
-
Method Details
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
beforeAll
in interfaceorg.junit.jupiter.api.extension.BeforeAllCallback
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
beforeEach
in interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
-
builder
-