Class DbUnitEmbeddedDatabaseRule
java.lang.Object
com.github.mjeanroy.dbunit.integration.spring.junit4.DbUnitEmbeddedDatabaseRule
- All Implemented Interfaces:
org.junit.rules.TestRule
This rule provide a fine integration between spring embedded database
and dbunit:
- Ensure that embedded database is started and available before dbUnit load dataSet.
- Shutdown database after test.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate rule, embedded database will be initialized withEmbeddedDatabaseConfiguration
if defined on the test class, or using a default embedded database.DbUnitEmbeddedDatabaseRule
(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase db) Create rule with givenEmbeddedDatabase
. -
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runner.Description description) Return new database connection, may returnnull
if the database has not been initialized yet.org.springframework.jdbc.datasource.embedded.EmbeddedDatabase
getDb()
Get embedded database, may returnnull
if the database has not been initialized yet.
-
Constructor Details
-
DbUnitEmbeddedDatabaseRule
public DbUnitEmbeddedDatabaseRule()Create rule, embedded database will be initialized withEmbeddedDatabaseConfiguration
if defined on the test class, or using a default embedded database. -
DbUnitEmbeddedDatabaseRule
public DbUnitEmbeddedDatabaseRule(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase db) Create rule with givenEmbeddedDatabase
.- Parameters:
db
- Embedded database.
-
-
Method Details
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
getDb
public org.springframework.jdbc.datasource.embedded.EmbeddedDatabase getDb()Get embedded database, may returnnull
if the database has not been initialized yet.- Returns:
- Embedded database.
-
getConnection
Return new database connection, may returnnull
if the database has not been initialized yet.- Returns:
- New database connection.
-