Class DbUnitEmbeddedDatabaseRule
- java.lang.Object
-
- com.github.mjeanroy.dbunit.integration.spring.junit4.DbUnitEmbeddedDatabaseRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class DbUnitEmbeddedDatabaseRule extends Object implements 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
Constructors Constructor Description DbUnitEmbeddedDatabaseRule()Create rule, embedded database will be initialized withEmbeddedDatabaseConfigurationif 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description)ConnectiongetConnection()Return new database connection, may returnnullif the database has not been initialized yet.org.springframework.jdbc.datasource.embedded.EmbeddedDatabasegetDb()Get embedded database, may returnnullif the database has not been initialized yet.
-
-
-
Constructor Detail
-
DbUnitEmbeddedDatabaseRule
public DbUnitEmbeddedDatabaseRule()
Create rule, embedded database will be initialized withEmbeddedDatabaseConfigurationif 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 Detail
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)- Specified by:
applyin interfaceorg.junit.rules.TestRule
-
getDb
public org.springframework.jdbc.datasource.embedded.EmbeddedDatabase getDb()
Get embedded database, may returnnullif the database has not been initialized yet.- Returns:
- Embedded database.
-
getConnection
public Connection getConnection()
Return new database connection, may returnnullif the database has not been initialized yet.- Returns:
- New database connection.
-
-