public abstract class DatabaseTestSystem extends TestSystem
TestSystem
s 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, toString
protected 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
SQLException
protected abstract DatabaseWrapper createContainerWrapper() throws Exception
Exception
public 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 TestSystem
Exception
- 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 TestSystem
Exception
public String getDriverJar()
protected Connection getConnection(String url, String username, String password) throws SQLException
SQLException
protected Driver getDriver(String url) throws SQLException
getDriverJar()
as needed and will download the library and manage the classloader as needed.SQLException
protected Connection openSetupConnection() throws SQLException
setup()
logic.SQLException
public Connection getConnection() throws SQLException
getConnection(String, String)
using getUsername()
and getPassword()
SQLException
public Connection getConnection(String username, String password) throws SQLException
SQLException
public 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
SQLException
public boolean executeSql(String sql) throws SQLException
SQLException
public void execute(SqlStatement sqlStatement) throws SQLException, DatabaseException
SQLException
DatabaseException
public Database getDatabaseFromFactory() throws SQLException, DatabaseException
SQLException
DatabaseException
public void execute(Change change) throws SQLException, DatabaseException
SQLException
DatabaseException
public void executeInverses(Change change) throws SQLException, DatabaseException, RollbackImpossibleException
Copyright © 2023 Liquibase.org. All rights reserved.