public class TemporaryDatabaseITCase extends Object
For each unit test method, creates a temporary database before the unit test is run and destroys the database after each test (optionally leaving around the test database, either always or on a test failure).
If you get errors about not being able to delete a database because it is in use, make sure that your tests always close their database connections (even in case of failures).
Modifier and Type | Class and Description |
---|---|
static class |
TemporaryDatabaseITCase.TestFailureAndTearDownErrorException
Represents a failure both in a unit test method (e.g.: testFoo) and
in the tearDown method.
|
Modifier and Type | Field and Description |
---|---|
protected org.springframework.jdbc.core.JdbcTemplate |
jdbcTemplate |
Constructor and Description |
---|
TemporaryDatabaseITCase() |
TemporaryDatabaseITCase(String driver,
String url,
String adminUser,
String adminPassword) |
Modifier and Type | Method and Description |
---|---|
void |
executeSQL(String command) |
void |
executeSQL(String[] commands) |
void |
fail(String message,
Throwable t) |
protected DataSource |
getAdminDataSource() |
String |
getAdminPassword() |
String |
getAdminUser() |
Connection |
getConnection() |
DataSource |
getDataSource() |
String |
getDriver() |
org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate() |
String |
getTestDatabase() |
protected String |
getTestDatabaseName() |
Throwable |
getTestFailureThrowable() |
String |
getUrl() |
boolean |
hasTestFailed() |
void |
setDataSource(DataSource dataSource) |
void |
setTestFailureThrowable(Throwable t) |
void |
setUp() |
void |
tearDown() |
void |
testNothing() |
public void testNothing()
protected String getTestDatabaseName()
public String getTestDatabase()
public void setDataSource(DataSource dataSource)
public DataSource getDataSource()
protected DataSource getAdminDataSource()
public Connection getConnection() throws SQLException
SQLException
public String getDriver()
public String getUrl()
public String getAdminUser()
public String getAdminPassword()
public void setTestFailureThrowable(Throwable t)
public Throwable getTestFailureThrowable()
public boolean hasTestFailed()
public void executeSQL(String command)
public void executeSQL(String[] commands)
public void fail(String message, Throwable t) throws junit.framework.AssertionFailedError
junit.framework.AssertionFailedError
public org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
Copyright © 2016. All rights reserved.