Search in sources :

Example 1 with MagicalGoConfigXmlLoader

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")));
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) MailHost(com.thoughtworks.go.config.MailHost) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 2 with MagicalGoConfigXmlLoader

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());
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MagicalGoConfigXmlWriter(com.thoughtworks.go.config.MagicalGoConfigXmlWriter) Before(org.junit.Before)

Example 3 with MagicalGoConfigXmlLoader

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"))));
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) Argument(com.thoughtworks.go.config.Argument) ExecTask(com.thoughtworks.go.config.ExecTask) Arguments(com.thoughtworks.go.domain.config.Arguments) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 4 with MagicalGoConfigXmlLoader

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));
    }
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 5 with MagicalGoConfigXmlLoader

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\"."));
    }
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) ByteArrayInputStream(java.io.ByteArrayInputStream) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) Test(org.junit.Test)

Aggregations

MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)12 ConfigCache (com.thoughtworks.go.config.ConfigCache)11 Test (org.junit.Test)7 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)5 JobConfig (com.thoughtworks.go.config.JobConfig)3 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)3 Builder (com.thoughtworks.go.domain.builder.Builder)3 RakeTask (com.thoughtworks.go.config.RakeTask)2 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 Before (org.junit.Before)2 Argument (com.thoughtworks.go.config.Argument)1 ExecTask (com.thoughtworks.go.config.ExecTask)1 MagicalGoConfigXmlWriter (com.thoughtworks.go.config.MagicalGoConfigXmlWriter)1 MailHost (com.thoughtworks.go.config.MailHost)1 Arguments (com.thoughtworks.go.domain.config.Arguments)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1