private void applyConfigViaWebUI(JenkinsRule r, String jenkinsConfig) throws Exception {
        // The UI requires the path to the config file
        File f = File.createTempFile("junit", null, tempFolder.toFile());
        writeToFile(jenkinsConfig, f.getAbsolutePath());

        // Call the replace url
        JenkinsRule.WebClient client = r.createWebClient();
        WebRequest request = new WebRequest(client.createCrumbedUrl("configuration-as-code/replace"), POST);
        NameValuePair param = new NameValuePair("_.newSource", f.toURI().toURL().toExternalForm());
        request.setRequestParameters(Collections.singletonList(param));
        request.setRequestParameters(Collections.singletonList(param));
        WebResponse response = client.loadWebResponse(request);
        assertEquals(
                200,
                response.getStatusCode(),
                "Failed to POST to " + request.getUrl().toString());
        String res = response.getContentAsString();
        /* The result page has:
        Configuration loaded from :
                        <ul>
                            <li>path</li>
                        </ul>
        path is the file used to store the configuration.
         */
        assertThat(res, containsString(f.toURI().toURL().toExternalForm()));
    }
1. Configure the instance with the {@link #configResource()} 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 the {@link #stringInLogExpected()} is set during the restart.

@throws IOException If an exception is thrown managing resources or files.
test-harness/src/main/java/io/jenkins/plugins/casc/misc/junit/jupiter/AbstractRoundTripTest.java