Release 0.6, now with Liquibase support
The brand new 0.6 release of the Embedded DB JUnit Rule has been released with some notable new features:
- A new initialization plugin API
- Liquibase support by implementing the new initialization plugin
A new initialization plugin API
You can now implement custom initialization code by implementing the new InitializationPlugin interface:
public interface InitializationPlugin {
void connectionMade(final String name, final Connection connection);
}
Liquibase support
To initiate the embedded in-memory H2 database created by the @Rule, add the plugin to the @Rule initialization using the fluent Builder API:
@Rule
public EmbeddedDatabaseRule embeddedDatabaseRule = EmbeddedDatabaseRule
.builder()
.withMode(EmbeddedDatabaseRule.CompatibilityMode.MSSQLServer)
.initializedByPlugin(LiquibaseInitializer.builder()
.withChangelogResource("example-changelog.sql")
.build())
.build();
You can then get a DataSource or Connection from the JUnit rule to be used in your test
@Test
public void testCanConnect() throws Exception {
try(final Connection connection = embeddedDatabaseRule.getConnection()) {
// test code
}
}
Links
- How-to add the Liquibase plugin to your project
- Feel free to submit issues, pull requests or comments via the GitHub project site