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);
}
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);
}
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;
}
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();
}
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);
}
Aggregations