Class DatabaseTestSystem
java.lang.Object
liquibase.extension.testing.testsystem.TestSystem
liquibase.extension.testing.testsystem.DatabaseTestSystem
- All Implemented Interfaces:
Plugin
,org.junit.rules.TestRule
- Direct Known Subclasses:
CockroachTestSystem
,DB2TestSystem
,DB2zTestSystem
,DerbyTestSystem
,FirebirdTestSystem
,H2TestSystem
,HsqlTestSystem
,InformixTestSystem
,MariaDBTestSystem
,MSSQLTestSystem
,MySQLTestSystem
,OracleTestSystem
,PostgresTestSystem
,SnowflakeTestSystem
,SQLiteTestSystem
,SybaseASATestSystem
Base class for
TestSystem
s for databases.-
Nested Class Summary
Nested classes/interfaces inherited from class liquibase.extension.testing.testsystem.TestSystem
TestSystem.Definition
-
Field Summary
Fields inherited from interface liquibase.plugin.Plugin
PRIORITY_DATABASE, PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED
-
Constructor Summary
ConstructorDescriptionDatabaseTestSystem
(String shortName) DatabaseTestSystem
(TestSystem.Definition definition) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract DatabaseWrapper
protected @NotNull JdbcDatabaseWrapper
createJdbcWrapper
(String url) protected @NotNull DatabaseWrapper
void
void
execute
(SqlStatement sqlStatement) void
executeInverses
(Change change) boolean
executeSql
(String sql) Standard alt catalog to use for testing.Standard alt schema to use for testing.Standard alt tablespace to use for testing.Standard "catalog" to use for testing.Returns the connection to this database.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.Return the url used to connect to this database.protected Driver
Returns the driver library to use.protected String
Docker image of the database to test against.Standard password to use when connecting.protected String
"Privileged" password to use forsetup()
.protected abstract String[]
Define SQL to run bysetup()
protected String
"Privileged" username to use forsetup()
.Standard username to use when connecting.protected String
Version of the database to test against."protected Connection
Opens a connection with valid permissions for thesetup()
logic.protected void
setup()
Sets up any needed catalogs/schemas/usernames/etc.void
start()
Default implementation usescreateWrapper()
to manage the external system.void
stop()
Default implementation usescreateWrapper()
to manage the external system, and callsDatabaseWrapper.stop()
Methods inherited from class liquibase.extension.testing.testsystem.TestSystem
apply, getConfigurationKeys, getConfiguredValue, getConfiguredValue, getConfiguredValue, getDefinition, getEnabledTestSystems, getKeepRunning, getPriority, shouldTest, toString
-
Field Details
-
wrapper
-
-
Constructor Details
-
DatabaseTestSystem
-
DatabaseTestSystem
-
-
Method Details
-
createWrapper
- Throws:
Exception
-
createJdbcWrapper
- Throws:
SQLException
-
createContainerWrapper
- Throws:
Exception
-
start
Default implementation usescreateWrapper()
to manage the external system. Multiple calls to start() will be no-ops. Callssetup()
after starting the wrapper.- Specified by:
start
in classTestSystem
- Throws:
Exception
- if the system cannot be started or reached.
-
stop
Default implementation usescreateWrapper()
to manage the external system, and callsDatabaseWrapper.stop()
- Specified by:
stop
in classTestSystem
- Throws:
Exception
-
getDriverJar
Returns the driver library to use. Supports maven-style coordinate, like "com.h2database:h2:1.4.200". Default implementation uses the "driverJar" testSystem configuration value. -
getConnection
protected Connection getConnection(String url, String username, String password) throws SQLException Opens a connection to the given url, username, and password. This is not an end-user facing function because the url to use should be managed by the DatabaseWrapper, not the user.- Throws:
SQLException
-
getDriver
- Returns:
- the Driver instance to use for the given url.
Default implementation uses the value in
getDriverJar()
as needed and will download the library and manage the classloader as needed. - Throws:
SQLException
-
openSetupConnection
Opens a connection with valid permissions for thesetup()
logic.- Throws:
SQLException
-
getConnection
Returns the connection to this database. Will reuse a single connection rather than continually open new ones. Convenience method forgetConnection(String, String)
usinggetUsername()
andgetPassword()
- Throws:
SQLException
-
getConnection
Returns the connection to this database. Will reuse a single connection for each username/password combo rather than continually open new ones.- Throws:
SQLException
-
getConnectionUrl
Return the url used to connect to this database. NOTE: this may be different than the 'url' configured value because the TestSystem implementations are free to tweak and control this URL based on other settings. -
getUsername
Standard username to use when connecting. Returns "username" test system configuration. -
getPassword
Standard password to use when connecting. Returns "password" test system configuration. -
getCatalog
Standard "catalog" to use for testing. Returns "catalog" test system configuration. -
getAltCatalog
Standard alt catalog to use for testing. Returns "altCatalog" test system configuration. -
getAltSchema
Standard alt schema to use for testing. Returns "altSchema" test system configuration. -
getAltTablespace
Standard alt tablespace to use for testing. Returns "username" test system configuration. -
getSetupUsername
"Privileged" username to use forsetup()
. Returns "setup.username" or "username" test system configuration. -
getSetupPassword
"Privileged" password to use forsetup()
. Returns "setup.password" or "password" test system configuration. -
getVersion
Version of the database to test against."Privileged" username to use forsetup()
. Returns "version" test system configuration. -
getImageName
Docker image of the database to test against. Returns "imageName" test system configuration. -
setup
Sets up any needed catalogs/schemas/usernames/etc.- Throws:
SQLException
-
getSetupSql
Define SQL to run bysetup()
-
executeSql
- Throws:
SQLException
-
execute
- Throws:
SQLException
DatabaseException
-
getDatabaseFromFactory
- Throws:
SQLException
DatabaseException
-
execute
- Throws:
SQLException
DatabaseException
-
executeInverses
public void executeInverses(Change change) throws SQLException, DatabaseException, RollbackImpossibleException
-