use of com.thoughtworks.go.config.MagicalGoConfigXmlLoader 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(FileUtil.readToEnd(IOUtils.toInputStream(ConfigFileFixture.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.MagicalGoConfigXmlLoader in project gocd by gocd.
the class BaseConfigXmlWriterTest method setup.
@Before
public void setup() {
output = new ByteArrayOutputStream();
ConfigCache configCache = new ConfigCache();
xmlWriter = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins());
xmlLoader = new MagicalGoConfigXmlLoader(configCache, ConfigElementImplementationRegistryMother.withNoPlugins());
}
use of com.thoughtworks.go.config.MagicalGoConfigXmlLoader 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.MagicalGoConfigXmlLoader 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(FileUtil.readToEnd(IOUtils.toInputStream(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.MagicalGoConfigXmlLoader 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(FileUtil.readToEnd(inputStream));
fail();
} catch (Exception e) {
assertThat(e.getMessage(), is("Duplicate unique value [passed] declared for identity constraint \"uniqueRunIfTypeForExec\" of element \"exec\"."));
}
}
Aggregations