public class TemporaryDatabasePostgreSQL extends Object implements TemporaryDatabase
Modifier and Type | Field and Description |
---|---|
static String |
LIQUIBASE_RELATIVE_PATH |
protected static int |
MAX_DATABASE_DROP_ATTEMPTS |
static String |
TEMPLATE_DATABASE_NAME_PREFIX |
ADMIN_PASSWORD_PROPERTY, ADMIN_USER_PROPERTY, DEFAULT_ADMIN_PASSWORD, DEFAULT_ADMIN_USER, DEFAULT_DRIVER, DEFAULT_URL, DRIVER_PROPERTY, URL_PROPERTY
Constructor and Description |
---|
TemporaryDatabasePostgreSQL() |
TemporaryDatabasePostgreSQL(String testDatabase) |
TemporaryDatabasePostgreSQL(String testDatabase,
boolean useExisting) |
TemporaryDatabasePostgreSQL(String testDatabase,
String driver,
String url,
String adminUser,
String adminPassword) |
TemporaryDatabasePostgreSQL(String testDatabase,
String driver,
String urlBase,
String adminUser,
String adminPassword,
boolean useExisting) |
Modifier and Type | Method and Description |
---|---|
int |
countRows(String sql,
Object... values) |
void |
create() |
protected void |
createIntegrationTestTemplateDatabase(String dbName) |
void |
drop() |
static void |
dumpThreads() |
protected static void |
failIfUnitTest() |
String |
generateLiquibaseHash() |
DataSource |
getAdminDataSource() |
XADataSource |
getAdminXADataSource() |
Connection |
getConnection() |
Connection |
getConnection(String username,
String password) |
protected static String |
getDatabaseName(Object hashMe) |
DataSource |
getDataSource() |
String |
getIntegrationTestTemplateDatabaseName() |
org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate() |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Logger |
getParentLogger() |
String |
getTestDatabase() |
XAConnection |
getXAConnection() |
XAConnection |
getXAConnection(String user,
String password) |
XADataSource |
getXADataSource() |
boolean |
isWrapperFor(Class<?> iface)
Returns true if this either implements the interface argument or is directly or indirectly a wrapper
for an object that does.
|
void |
setClassName(String className) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(PrintWriter out) |
void |
setMethodName(String methodName) |
void |
setPlpgsqlIplike(boolean iplike) |
void |
setPopulateSchema(boolean populateSchema) |
void |
setTestDetails(String testDetails) |
protected static void |
setupBlame(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
String blame) |
void |
setupDatabase() |
<T> T |
unwrap(Class<T> iface)
Returns an object that implements the given interface to allow access to
non-standard methods, or standard methods not exposed by the proxy.
|
void |
update(String stmt,
Object... values) |
protected static final int MAX_DATABASE_DROP_ATTEMPTS
public static final String TEMPLATE_DATABASE_NAME_PREFIX
public static final String LIQUIBASE_RELATIVE_PATH
public TemporaryDatabasePostgreSQL(String testDatabase) throws Exception
Exception
public TemporaryDatabasePostgreSQL(String testDatabase, boolean useExisting) throws Exception
Exception
public TemporaryDatabasePostgreSQL(String testDatabase, String driver, String url, String adminUser, String adminPassword) throws Exception
Exception
public TemporaryDatabasePostgreSQL(String testDatabase, String driver, String urlBase, String adminUser, String adminPassword, boolean useExisting) throws TemporaryDatabaseException
TemporaryDatabaseException
public void setPlpgsqlIplike(boolean iplike)
setPlpgsqlIplike
in interface TemporaryDatabase
public void setPopulateSchema(boolean populateSchema)
setPopulateSchema
in interface TemporaryDatabase
public void setClassName(String className)
setClassName
in interface TemporaryDatabase
public void setMethodName(String methodName)
setMethodName
in interface TemporaryDatabase
public void setTestDetails(String testDetails)
setTestDetails
in interface TemporaryDatabase
public void create() throws TemporaryDatabaseException
create
in interface TemporaryDatabase
TemporaryDatabaseException
public void drop() throws TemporaryDatabaseException
drop
in interface TemporaryDatabase
TemporaryDatabaseException
public org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
getJdbcTemplate
in interface TemporaryDatabase
public int countRows(String sql, Object... values)
countRows
in interface TemporaryDatabase
public String getTestDatabase()
getTestDatabase
in interface TemporaryDatabase
public String getIntegrationTestTemplateDatabaseName() throws Throwable
Throwable
protected static void failIfUnitTest() throws TemporaryDatabaseException
TemporaryDatabaseException
public void setupDatabase() throws TemporaryDatabaseException
TemporaryDatabaseException
protected static void setupBlame(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, String blame)
public static void dumpThreads()
public Connection getConnection() throws SQLException
getConnection
in interface DataSource
SQLException
public Connection getConnection(String username, String password) throws SQLException
getConnection
in interface DataSource
SQLException
public PrintWriter getLogWriter() throws SQLException
getLogWriter
in interface CommonDataSource
SQLException
public void setLogWriter(PrintWriter out) throws SQLException
setLogWriter
in interface CommonDataSource
SQLException
public void setLoginTimeout(int seconds) throws SQLException
setLoginTimeout
in interface CommonDataSource
SQLException
public int getLoginTimeout() throws SQLException
getLoginTimeout
in interface CommonDataSource
SQLException
public Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger
in interface CommonDataSource
SQLFeatureNotSupportedException
public DataSource getAdminDataSource()
public XADataSource getAdminXADataSource()
public DataSource getDataSource()
public XADataSource getXADataSource()
public <T> T unwrap(Class<T> iface) throws SQLException
unwrap
recursively on the wrapped object
or a proxy for that result. If the receiver is not a
wrapper and does not implement the interface, then an SQLException
is thrown.unwrap
in interface Wrapper
iface
- A Class defining an interface that the result must implement.SQLException
- If no object found that implements the interfacepublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor
on the wrapped
object. If this does not implement the interface and is not a wrapper, return false.
This method should be implemented as a low-cost operation compared to unwrap
so that
callers can use this method to avoid expensive unwrap
calls that may fail. If this method
returns true then calling unwrap
with the same argument should succeed.isWrapperFor
in interface Wrapper
iface
- a Class defining an interface.SQLException
- if an error occurs while determining whether this is a wrapper
for an object with the given interface.public XAConnection getXAConnection() throws SQLException
getXAConnection
in interface XADataSource
SQLException
public XAConnection getXAConnection(String user, String password) throws SQLException
getXAConnection
in interface XADataSource
SQLException
public String generateLiquibaseHash() throws NoSuchAlgorithmException, IOException, Exception, liquibase.exception.ChangeLogParseException, liquibase.exception.LiquibaseException
NoSuchAlgorithmException
IOException
Exception
liquibase.exception.ChangeLogParseException
liquibase.exception.LiquibaseException
protected void createIntegrationTestTemplateDatabase(String dbName) throws ClassNotFoundException, MigrationException, Throwable, SQLException
Copyright © 2021. All rights reserved.