use of com.thoughtworks.go.config.ConfigCache in project gocd by gocd.
the class UniqueRunIfStatusValidatorTest method shouldThrowExceptionWhenThereIsMoreThanOneOnCancelInEachTask.
@Test
public void shouldThrowExceptionWhenThereIsMoreThanOneOnCancelInEachTask() throws Exception {
try {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(ConfigFileFixture.CONTAINS_MULTI_SAME_STATUS_RUN_IF.getBytes());
new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(IOUtils.toString(inputStream, UTF_8));
fail();
} catch (Exception e) {
assertThat(e.getMessage(), anyOf(is("Duplicate unique value [passed] declared for identity constraint of element \"exec\"."), is("Duplicate unique value [passed] declared for identity constraint \"uniqueRunIfTypeForExec\" of element \"exec\".")));
}
}
use of com.thoughtworks.go.config.ConfigCache in project gocd by gocd.
the class ExecTaskTest method shouldNotSupportArgsAttributeWithArgSubElement.
@Test
public void shouldNotSupportArgsAttributeWithArgSubElement() throws Exception {
String jobXml = "<job name='dev'>\n" + " <tasks>\n" + " <exec command='ls' args='arg1 arg2'>\n" + " <arg>arg1</arg>\n" + " <arg>arg2</arg>\n" + " </exec>\n" + " </tasks>" + "</job>";
String configXml = ConfigFileFixture.withJob(jobXml);
try {
ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
new MagicalGoConfigXmlLoader(new ConfigCache(), registry).loadConfigHolder(configXml);
fail("should throw exception if both 'args' attribute and 'arg' sub element are configured");
} catch (Exception e) {
assertThat(e.getMessage(), containsString(ExecTask.EXEC_CONFIG_ERROR));
}
}
use of com.thoughtworks.go.config.ConfigCache in project gocd by gocd.
the class ExecTaskTest method shouldSupportMultipleArgs.
@Test
public void shouldSupportMultipleArgs() throws Exception {
String xml = "<exec command='ls'>\n" + " <arg>arg1</arg>\n" + " <arg>arg2</arg>\n" + "</exec>";
ExecTask execTask = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).fromXmlPartial(xml, ExecTask.class);
assertThat(execTask.getArgList(), is(new Arguments(new Argument("arg1"), new Argument("arg2"))));
}
use of com.thoughtworks.go.config.ConfigCache in project gocd by gocd.
the class ServerConfigTest method shouldParseServerConfigWithMailhost.
@Test
public void shouldParseServerConfigWithMailhost() throws Exception {
String xml = "<mailhost hostname=\"smtp.company.com\" port=\"25\" " + "username=\"smtpuser\" password=\"password\" tls=\"true\" " + "from=\"cruise@me.com\" admin=\"jez@me.com\"/>";
ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
CruiseConfig config = new MagicalGoConfigXmlLoader(new ConfigCache(), registry).loadConfigHolder(withServerConfig(xml)).config;
MailHost mailHost = config.server().mailHost();
assertThat(mailHost, is(new MailHost("smtp.company.com", 25, "smtpuser", "password", true, true, "cruise@me.com", "jez@me.com")));
}
use of com.thoughtworks.go.config.ConfigCache in project gocd by gocd.
the class UniqueRunIfStatusValidatorTest method shouldPassWhenEachJobContainsOnCancel.
@Test
public void shouldPassWhenEachJobContainsOnCancel() throws Exception {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(ConfigMigrator.migrate(ConfigFileFixture.CONTAINS_MULTI_DIFFERENT_STATUS_RUN_IF).getBytes());
CruiseConfig cruiseConfig = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(IOUtils.toString(inputStream, UTF_8)).config;
assertThat(cruiseConfig, is(not(nullValue())));
}
Aggregations