Search in sources :

Example 1 with ConfigFileProvider

use of org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method should_ignore_removed_config_files.

/**
 * Verifies whether a previously generated config file will be ignored if it
 * is not referenced anymore.
 */
@Test
@WithPlugins("config-file-provider")
public void should_ignore_removed_config_files() {
    FreeStyleJob seedJob = executeRemovedConfigFilesAction(JobDslRemovedConfigFilesAction.IGNORE);
    Build build = seedJob.scheduleBuild().shouldSucceed();
    Pattern expected = Pattern.compile("Unreferenced config files:(\\s*)GeneratedConfigFile[{]name='Old_Config_File', id='123456789'}");
    assertThat(build.getConsole(), containsRegexp(expected));
    ConfigFileProvider configFileProvider = new ConfigFileProvider(jenkins);
    configFileProvider.open();
    assertThat(driver, hasElement(by.xpath("//a[@href='editConfig?id=123456789']")));
}
Also used : Pattern(java.util.regex.Pattern) Build(org.jenkinsci.test.acceptance.po.Build) ConfigFileProvider(org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 2 with ConfigFileProvider

use of org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method should_delete_removed_config_files.

/**
 * Verifies whether a previously generated config file will be deleted if it
 * is not referenced anymore.
 */
@Test
@WithPlugins("config-file-provider")
public void should_delete_removed_config_files() {
    FreeStyleJob seedJob = executeRemovedConfigFilesAction(JobDslRemovedConfigFilesAction.DELETE);
    Build build = seedJob.scheduleBuild().shouldSucceed();
    Pattern expected = Pattern.compile("Unreferenced config files:(\\s*)GeneratedConfigFile[{]name='Old_Config_File', id='123456789'}");
    assertThat(build.getConsole(), containsRegexp(expected));
    ConfigFileProvider configFileProvider = new ConfigFileProvider(jenkins);
    configFileProvider.open();
    assertThat(driver, not(hasElement(by.xpath("//a[@href='editConfig?id=123456789']"))));
}
Also used : Pattern(java.util.regex.Pattern) Build(org.jenkinsci.test.acceptance.po.Build) ConfigFileProvider(org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 3 with ConfigFileProvider

use of org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider in project acceptance-test-harness by jenkinsci.

the class ConfigFileProviderTest method createCustomConfig.

private CustomConfig createCustomConfig() {
    final CustomConfig customConfig = new ConfigFileProvider(jenkins).addFile(CustomConfig.class);
    customConfig.content(CUSTOM_CONF_CONTENT);
    customConfig.save();
    return customConfig;
}
Also used : CustomConfig(org.jenkinsci.test.acceptance.plugins.config_file_provider.CustomConfig) ConfigFileProvider(org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider)

Example 4 with ConfigFileProvider

use of org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider in project acceptance-test-harness by jenkinsci.

the class ConfigFileProviderTest method createMavenSettingsConfig.

private MavenSettingsConfig createMavenSettingsConfig(final String serverId, final String credId) {
    final MavenSettingsConfig mvnConfig = new ConfigFileProvider(jenkins).addFile(MavenSettingsConfig.class);
    mvnConfig.content(String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<settings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\" \n" + "          xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n" + "          xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd\">\n" + "  \n" + "  <servers>\n" + "    <server>\n" + "      <id>%s</id>\n" + "    </server>\n" + "  </servers>\n" + "\n" + "</settings>", serverId));
    final ServerCredentialMapping serverCred = mvnConfig.addServerCredentialMapping();
    serverCred.serverId(serverId);
    serverCred.credentialsId(credId);
    mvnConfig.save();
    return mvnConfig;
}
Also used : MavenSettingsConfig(org.jenkinsci.test.acceptance.plugins.config_file_provider.MavenSettingsConfig) ServerCredentialMapping(org.jenkinsci.test.acceptance.plugins.config_file_provider.ServerCredentialMapping) ConfigFileProvider(org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider)

Example 5 with ConfigFileProvider

use of org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider in project acceptance-test-harness by jenkinsci.

the class OpenstackCloudPluginTest method configureCloudInit.

private void configureCloudInit(String cloudInitName) {
    ConfigFileProvider fileProvider = new ConfigFileProvider(jenkins);
    UserDataConfig cloudInit = fileProvider.addFile(UserDataConfig.class);
    cloudInit.name(CLOUD_INIT_NAME);
    cloudInit.content(resource("/openstack_plugin/" + cloudInitName).asText());
    cloudInit.save();
}
Also used : UserDataConfig(org.jenkinsci.test.acceptance.plugins.openstack.UserDataConfig) ConfigFileProvider(org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider)

Aggregations

ConfigFileProvider (org.jenkinsci.test.acceptance.plugins.config_file_provider.ConfigFileProvider)5 Pattern (java.util.regex.Pattern)2 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)2 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)2 Build (org.jenkinsci.test.acceptance.po.Build)2 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)2 Test (org.junit.Test)2 CustomConfig (org.jenkinsci.test.acceptance.plugins.config_file_provider.CustomConfig)1 MavenSettingsConfig (org.jenkinsci.test.acceptance.plugins.config_file_provider.MavenSettingsConfig)1 ServerCredentialMapping (org.jenkinsci.test.acceptance.plugins.config_file_provider.ServerCredentialMapping)1 UserDataConfig (org.jenkinsci.test.acceptance.plugins.openstack.UserDataConfig)1