public abstract class TestSystem extends Object implements org.junit.rules.TestRule, Plugin
TestRule
so it can control start/stop of the TestSystem in JUnit, but that may be removed as tests get converted to spock.
TestSystemFactory
Modifier and Type | Class and Description |
---|---|
static class |
TestSystem.Definition |
PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED
Modifier | Constructor and Description |
---|---|
protected |
TestSystem(String name)
Empty constructor for ServiceLocator to use
|
protected |
TestSystem(TestSystem.Definition definition)
Constructor for
TestSystemFactory to use |
Modifier and Type | Method and Description |
---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
Allows test system to be auto-controlled by JUnit tests.
|
SortedSet<String> |
getConfigurationKeys()
Return configuration keys supported by this testSystem
|
<T> T |
getConfiguredValue(String propertyName,
Class<T> type)
Convenience method for
getConfiguredValue(String, ConfigurationValueConverter, boolean) |
<T> T |
getConfiguredValue(String propertyName,
Class<T> type,
boolean required)
Convenience method for
getConfiguredValue(String, ConfigurationValueConverter, boolean) |
<T> T |
getConfiguredValue(String propertyName,
ConfigurationValueConverter<T> converter,
boolean required)
Returns the configured value for the given propertyName.
|
TestSystem.Definition |
getDefinition()
Return the definition of this test system.
|
static List<String> |
getEnabledTestSystems(String configuredTestSystems,
String skippedTestSystems)
Determine which test systems are considered enabled and should have tests run against them.
|
boolean |
getKeepRunning()
Return whether this testSystem should/will keep running after the JVM interacting with it exits.
|
int |
getPriority(TestSystem.Definition definition)
Default implementation returns PRIORITY_DEFAULT if the name matches the given definition, without taking any profiles etc.
|
boolean |
shouldTest() |
abstract void |
start()
Starts the system if possible.
|
abstract void |
stop()
Stops the system if possible.
|
String |
toString() |
protected TestSystem(String name)
protected TestSystem(TestSystem.Definition definition)
TestSystemFactory
to usepublic static List<String> getEnabledTestSystems(String configuredTestSystems, String skippedTestSystems)
configuredTestSystems
- the value of the "liquibase.sdk.testSystem.test" propertyskippedTestSystems
- the value of the "liquibase.sdk.testSystem.skip" propertypublic SortedSet<String> getConfigurationKeys()
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
If the liquibase.sdk.testSystem.test configuration does NOT include the name of this test system, it skips the test.
If the liquibase.sdk.testSystem.test configuration DOES include the name of the test system, it will connect to a matching system if available or will start it as possible.
If it starts the system, it will not stop it until JVM shutdown.
Example:
\@Rule TestSystem testSystem = Scope.getCurrentScope().getSingleton(TestSystemFactory.class).getTestSystem("mysql")
apply
in interface org.junit.rules.TestRule
public int getPriority(TestSystem.Definition definition)
public boolean shouldTest()
public TestSystem.Definition getDefinition()
public boolean getKeepRunning()
public <T> T getConfiguredValue(String propertyName, Class<T> type)
getConfiguredValue(String, ConfigurationValueConverter, boolean)
public <T> T getConfiguredValue(String propertyName, Class<T> type, boolean required)
getConfiguredValue(String, ConfigurationValueConverter, boolean)
public <T> T getConfiguredValue(String propertyName, ConfigurationValueConverter<T> converter, boolean required)
UnexpectedLiquibaseException
if 'required' is true.public abstract void start() throws Exception
getKeepRunning()
configuration.
If the keepRunning flag has an invalid value for this test system, throw an IllegalArgumentException
.Exception
- if the system cannot be started or reached.public abstract void stop() throws Exception
Exception
Copyright © 2023 Liquibase.org. All rights reserved.