Class AbstractRoundTripTest
java.lang.Object
io.jenkins.plugins.casc.misc.junit.jupiter.AbstractRoundTripTest
Base test to check a complete test of each plugin configuration.
What it does:
- Configure the instance with the
configResource()implemented. - Check it was configured correctly.
- Check the configuration is valid via Web UI.
- Apply the configuration via Web UI.
- Write the configuration to $JENKINS_HOME/jenkins.yaml.
- Restart Jenkins.
- Check the
stringInLogExpected()is set during the restart. - Check it is still configured correctly after the restart
All the plugin author needs to do is override the methods providing:
- The resource with the yaml configuration of the plugin in case they use their own name for the file.
- A way to validate the configuration is established.
- A string that should be present in the logs (casc logger) that guarantees the config is loaded. Usually a weird text configured.
This is the JUnit5 equivalent of RoundTripAbstractTest
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidassertConfiguredAsExpected(org.jvnet.hudson.test.JenkinsRule j, String configContent) A method to assert if the configuration was correctly loaded.protected StringReturn the resource path (yaml file) to be loaded.voidroundTripTest(org.jvnet.hudson.test.JenkinsRule r) 1.protected abstract StringReturn the string that should be in the logs of the JCasC logger to verify it's configured after a restart.
-
Field Details
-
tempFolder
-
-
Constructor Details
-
AbstractRoundTripTest
public AbstractRoundTripTest()
-
-
Method Details
-
assertConfiguredAsExpected
protected abstract void assertConfiguredAsExpected(org.jvnet.hudson.test.JenkinsRule j, String configContent) A method to assert if the configuration was correctly loaded. The Jenkins rule and the content of the config supposedly loaded are passed.- Parameters:
j- a JenkinsRule instance.configContent- expected configuration.
-
configResource
Return the resource path (yaml file) to be loaded. i.e: If the resource is in the same package of the implementor class, then: my-config.yaml- Returns:
- the resource name and path.
-
stringInLogExpected
Return the string that should be in the logs of the JCasC logger to verify it's configured after a restart. This string should be unique to avoid interpreting that it was configured successfully, but it wasn't.- Returns:
- the unique string to be in the logs to certify the configuration was done successfully.
-
roundTripTest
1. Configure the instance with theconfigResource()implemented. 2. Check it was configured correctly. 3. Check the configuration is valid via Web UI. 4. Apply the configuration via Web UI. 5. Write the configuration to $JENKINS_HOME/jenkins.yaml. 6. Restart Jenkins. 7. Check thestringInLogExpected()is set during the restart.- Throws:
IOException- If an exception is thrown managing resources or files.Throwable
-