public abstract class DatabaseTestSystem extends TestSystem
TestSystems for databases.TestSystem.Definition| Modifier and Type | Field and Description |
|---|---|
protected DatabaseWrapper |
wrapper |
PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED| Constructor and Description |
|---|
DatabaseTestSystem(String shortName) |
DatabaseTestSystem(TestSystem.Definition definition) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract DatabaseWrapper |
createContainerWrapper() |
protected @NotNull JdbcDatabaseWrapper |
createJdbcWrapper(String url) |
protected @NotNull DatabaseWrapper |
createWrapper() |
void |
execute(Change change) |
void |
execute(SqlStatement sqlStatement) |
void |
executeInverses(Change change) |
boolean |
executeSql(String sql) |
String |
getAltCatalog()
Standard alt catalog to use for testing.
|
String |
getAltSchema()
Standard alt schema to use for testing.
|
String |
getAltTablespace()
Standard alt tablespace to use for testing.
|
String |
getCatalog()
Standard "catalog" to use for testing.
|
Connection |
getConnection()
Returns the connection to this database.
|
Connection |
getConnection(String username,
String password)
Returns the connection to this database.
|
protected Connection |
getConnection(String url,
String username,
String password)
Opens a connection to the given url, username, and password.
|
String |
getConnectionUrl()
Return the url used to connect to this database.
|
Database |
getDatabaseFromFactory() |
protected Driver |
getDriver(String url) |
String |
getDriverJar()
Returns the driver library to use.
|
protected String |
getImageName()
Docker image of the database to test against.
|
String |
getPassword()
Standard password to use when connecting.
|
protected String |
getSetupPassword()
"Privileged" password to use for
setup(). |
protected abstract String[] |
getSetupSql()
Define SQL to run by
setup() |
protected String |
getSetupUsername()
"Privileged" username to use for
setup(). |
String |
getUsername()
Standard username to use when connecting.
|
protected String |
getVersion()
Version of the database to test against."Privileged" username to use for
setup(). |
protected Connection |
openSetupConnection()
Opens a connection with valid permissions for the
setup() logic. |
protected void |
setup()
Sets up any needed catalogs/schemas/usernames/etc.
|
void |
start()
Default implementation uses
createWrapper() to manage the external system. |
void |
stop()
Default implementation uses
createWrapper() to manage the external system, and calls DatabaseWrapper.stop() |
apply, getConfigurationKeys, getConfiguredValue, getConfiguredValue, getConfiguredValue, getDefinition, getEnabledTestSystems, getKeepRunning, getPriority, shouldTest, toStringprotected DatabaseWrapper wrapper
public DatabaseTestSystem(String shortName)
public DatabaseTestSystem(TestSystem.Definition definition)
@NotNull protected @NotNull DatabaseWrapper createWrapper() throws Exception
Exception@NotNull protected @NotNull JdbcDatabaseWrapper createJdbcWrapper(String url) throws SQLException
SQLExceptionprotected abstract DatabaseWrapper createContainerWrapper() throws Exception
Exceptionpublic void start()
throws Exception
createWrapper() to manage the external system.
Multiple calls to start() will be no-ops.
Calls setup() after starting the wrapper.start in class TestSystemException - if the system cannot be started or reached.public void stop()
throws Exception
createWrapper() to manage the external system, and calls DatabaseWrapper.stop()stop in class TestSystemExceptionpublic String getDriverJar()
protected Connection getConnection(String url, String username, String password) throws SQLException
SQLExceptionprotected Driver getDriver(String url) throws SQLException
getDriverJar() as needed and will download the library and manage the classloader as needed.SQLExceptionprotected Connection openSetupConnection() throws SQLException
setup() logic.SQLExceptionpublic Connection getConnection() throws SQLException
getConnection(String, String) using getUsername() and getPassword()SQLExceptionpublic Connection getConnection(String username, String password) throws SQLException
SQLExceptionpublic String getConnectionUrl()
public String getUsername()
public String getPassword()
public String getCatalog()
public String getAltCatalog()
public String getAltSchema()
public String getAltTablespace()
protected String getSetupUsername()
setup(). Returns "setup.username" or "username" test system configuration.protected String getSetupPassword()
setup(). Returns "setup.password" or "password" test system configuration.protected String getVersion()
setup(). Returns "version" test system configuration.protected String getImageName()
protected void setup()
throws SQLException
SQLExceptionpublic boolean executeSql(String sql) throws SQLException
SQLExceptionpublic void execute(SqlStatement sqlStatement) throws SQLException, DatabaseException
SQLExceptionDatabaseExceptionpublic Database getDatabaseFromFactory() throws SQLException, DatabaseException
SQLExceptionDatabaseExceptionpublic void execute(Change change) throws SQLException, DatabaseException
SQLExceptionDatabaseExceptionpublic void executeInverses(Change change) throws SQLException, DatabaseException, RollbackImpossibleException
Copyright © 2022 Liquibase.org. All rights reserved.