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
TestSystems for databases.-
Nested Class Summary
Nested classes/interfaces inherited from class liquibase.extension.testing.testsystem.TestSystem
TestSystem.Definition -
Field Summary
FieldsFields inherited from interface liquibase.plugin.Plugin
PRIORITY_DATABASE, PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED -
Constructor Summary
ConstructorsConstructorDescriptionDatabaseTestSystem(String shortName) DatabaseTestSystem(TestSystem.Definition definition) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract DatabaseWrapperprotected @NotNull JdbcDatabaseWrappercreateJdbcWrapper(String url) protected @NotNull DatabaseWrappervoidvoidexecute(SqlStatement sqlStatement) voidexecuteInverses(Change change) booleanexecuteSql(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 ConnectiongetConnection(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 DriverReturns the driver library to use.protected StringDocker 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 StringVersion of the database to test against."protected ConnectionOpens a connection with valid permissions for thesetup()logic.protected voidsetup()Sets up any needed catalogs/schemas/usernames/etc.voidstart()Default implementation usescreateWrapper()to manage the external system.voidstop()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:
startin 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:
stopin 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:
SQLExceptionDatabaseException
-
getDatabaseFromFactory
- Throws:
SQLExceptionDatabaseException
-
execute
- Throws:
SQLExceptionDatabaseException
-
executeInverses
public void executeInverses(Change change) throws SQLException, DatabaseException, RollbackImpossibleException
-