Search in sources :

Example 6 with ConfigCache

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

Example 7 with ConfigCache

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

Example 8 with ConfigCache

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"))));
}
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) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 9 with ConfigCache

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")));
}
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.jupiter.api.Test)

Example 10 with ConfigCache

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

Aggregations

ConfigCache (com.thoughtworks.go.config.ConfigCache)13 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)10 Test (org.junit.jupiter.api.Test)9 MagicalGoConfigXmlWriter (com.thoughtworks.go.config.MagicalGoConfigXmlWriter)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)3 RakeTask (com.thoughtworks.go.config.RakeTask)2 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Before (org.junit.Before)2 Argument (com.thoughtworks.go.config.Argument)1 ExecTask (com.thoughtworks.go.config.ExecTask)1 JobConfig (com.thoughtworks.go.config.JobConfig)1 MailHost (com.thoughtworks.go.config.MailHost)1 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)1 Builder (com.thoughtworks.go.domain.builder.Builder)1 Arguments (com.thoughtworks.go.domain.config.Arguments)1 GoCache (com.thoughtworks.go.server.cache.GoCache)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1