Search in sources :

Example 11 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class UniqueOnCancelValidatorTest method shouldNotFailWithExceptionWhenThereAreNoOnCancelTasksForABuiltInTask.

@Test
public void shouldNotFailWithExceptionWhenThereAreNoOnCancelTasksForABuiltInTask() throws Exception {
    ConfigElementImplementationRegistry registry = mock(ConfigElementImplementationRegistry.class);
    when(registry.implementersOf(Task.class)).thenReturn(tasks(ExecTask.class));
    String content = "<cruise>" + "  <pipeline>" + "    <stage>" + "      <jobs>" + "        <job>" + "          <tasks>" + "            <exec command=\"install_addons.sh\">" + "              <runif status=\"passed\" />\n" + "            </exec>" + "          </tasks>" + "        </job>" + "      </jobs>" + "    </stage>" + "  </pipeline>" + "</cruise>";
    UniqueOnCancelValidator validator = new UniqueOnCancelValidator();
    validator.validate(elementFor(content), registry);
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ExecTask(com.thoughtworks.go.config.ExecTask) Test(org.junit.Test)

Example 12 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class UniqueOnCancelValidatorTest method shouldNotFailWithExceptionWhenThereIsOneOnCancelTaskForABuiltInTask.

@Test
public void shouldNotFailWithExceptionWhenThereIsOneOnCancelTaskForABuiltInTask() throws Exception {
    ConfigElementImplementationRegistry registry = mock(ConfigElementImplementationRegistry.class);
    when(registry.implementersOf(Task.class)).thenReturn(tasks(ExecTask.class));
    String content = "<cruise>" + "  <pipeline>" + "    <stage>" + "      <jobs>" + "        <job>" + "          <tasks>" + "            <exec command=\"install_addons.sh\">" + "              <runif status=\"passed\" />" + "               <oncancel>\n" + "                 <ant buildfile=\"build.xml\" />\n" + "               </oncancel>" + "            </exec>" + "          </tasks>" + "        </job>" + "      </jobs>" + "    </stage>" + "  </pipeline>" + "</cruise>";
    UniqueOnCancelValidator validator = new UniqueOnCancelValidator();
    validator.validate(elementFor(content), registry);
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ExecTask(com.thoughtworks.go.config.ExecTask) Test(org.junit.Test)

Example 13 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class ConfigMigrator method migrate.

public static GoConfigMigration migrate(final File configFile) {
    ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
    GoConfigMigration upgrader = new GoConfigMigration(new GoConfigMigration.UpgradeFailedHandler() {

        public void handle(Exception e) {
            String content = "";
            try {
                content = FileUtils.readFileToString(configFile, UTF_8);
            } catch (IOException e1) {
            }
            throw bomb(e.getMessage() + ": content=\n" + content + "\n" + (e.getCause() == null ? "" : e.getCause().getMessage()), e);
        }
    }, mock(ConfigRepository.class), new TimeProvider(), new ConfigCache(), registry);
    // TODO: LYH & GL GoConfigMigration should be able to handle stream instead of binding to file
    upgrader.upgradeIfNecessary(configFile, "N/A");
    return upgrader;
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ConfigRepository(com.thoughtworks.go.service.ConfigRepository)

Example 14 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class MagicalGoConfigXmlLoaderFixture method toMaterials.

public static MaterialConfigs toMaterials(String materials) throws Exception {
    ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
    MagicalGoConfigXmlLoader xmlLoader = new MagicalGoConfigXmlLoader(new ConfigCache(), registry);
    String pipelineXmlPartial = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<cruise " + "        xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "        xsi:noNamespaceSchemaLocation=\"cruise-config.xsd\" " + "        schemaVersion=\"" + GoConstants.CONFIG_SCHEMA_VERSION + "\">\n" + "  <server artifactsdir=\"logs\">\n" + "  </server>\n" + "  <pipelines>" + "<pipeline name=\"pipeline\">\n" + materials + "  <stage name=\"mingle\">\n" + "    <jobs>\n" + "      <job name=\"functional\">\n" + "        <artifacts>\n" + "          <artifact src=\"artifact1.xml\" dest=\"cruise-output\" />\n" + "        </artifacts>\n" + "      </job>\n" + "    </jobs>\n" + "  </stage>\n" + "</pipeline>\n" + "</pipelines>" + "</cruise>\n";
    CruiseConfig cruiseConfig = xmlLoader.loadConfigHolder(pipelineXmlPartial).config;
    return cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("pipeline")).materialConfigs();
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) Matchers.containsString(org.hamcrest.Matchers.containsString)

Example 15 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class UniqueOnCancelValidatorTest method shouldNotFailWithExceptionWhenThereIsOneOnCancelTasksForAPluginInTask.

@Test
public void shouldNotFailWithExceptionWhenThereIsOneOnCancelTasksForAPluginInTask() throws Exception {
    ConfigElementImplementationRegistry registry = mock(ConfigElementImplementationRegistry.class);
    when(registry.implementersOf(Task.class)).thenReturn(tasks(ExecTask.class, PluggableTask.class));
    String content = "<cruise>" + "  <pipeline>" + "    <stage>" + "      <jobs>" + "        <job>" + "          <tasks>" + "              <task name=\"\">\n" + "                <pluginConfiguration id=\"curl.task.plugin\" version=\"1\" />\n" + "                <configuration>\n" + "                  <property>\n" + "                    <key>Url</key>\n" + "                    <value>With_On_Cancel</value>\n" + "                  </property>\n" + "                </configuration>\n" + "                <runif status=\"passed\" />\n" + "                <oncancel>\n" + "                  <ant buildfile=\"blah\" target=\"blah\" />\n" + "                </oncancel>\n" + "              </task>" + "          </tasks>" + "        </job>" + "      </jobs>" + "    </stage>" + "  </pipeline>" + "</cruise>";
    UniqueOnCancelValidator validator = new UniqueOnCancelValidator();
    validator.validate(elementFor(content), registry);
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ExecTask(com.thoughtworks.go.config.ExecTask) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Test(org.junit.Test)

Aggregations

ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)24 Test (org.junit.Test)13 ExecTask (com.thoughtworks.go.config.ExecTask)8 ConfigRepository (com.thoughtworks.go.service.ConfigRepository)7 Before (org.junit.Before)7 NoPluginsInstalled (com.thoughtworks.go.config.registry.NoPluginsInstalled)4 ServerVersion (com.thoughtworks.go.server.util.ServerVersion)4 TimeProvider (com.thoughtworks.go.util.TimeProvider)4 IOException (java.io.IOException)4 AntTask (com.thoughtworks.go.config.AntTask)3 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)3 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)3 ConfigCache (com.thoughtworks.go.config.ConfigCache)2 FetchTask (com.thoughtworks.go.config.FetchTask)2 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)2 ConfigElementImplementationRegistrar (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistrar)2 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)2 UserDao (com.thoughtworks.go.server.dao.UserDao)2 PipelineRepository (com.thoughtworks.go.server.persistence.PipelineRepository)2 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)2