Search in sources :

Example 6 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry 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.Test)

Example 7 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class ConfigElementImplementationRegistryMother method withNoPlugins.

public static ConfigElementImplementationRegistry withNoPlugins() {
    ConfigElementImplementationRegistry registry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
    new ConfigElementImplementationRegistrar(registry).initialize();
    return registry;
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ConfigElementImplementationRegistrar(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistrar) NoPluginsInstalled(com.thoughtworks.go.config.registry.NoPluginsInstalled)

Example 8 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class GoConfigFileHelper method createTestingDao.

/**
 * Creates config dao that accesses single file
 */
public static GoConfigDao createTestingDao() {
    SystemEnvironment systemEnvironment = new SystemEnvironment();
    try {
        ServerHealthService serverHealthService = new ServerHealthService();
        ConfigRepository configRepository = new ConfigRepository(systemEnvironment);
        configRepository.initialize();
        ConfigCache configCache = new ConfigCache();
        ConfigElementImplementationRegistry configElementImplementationRegistry = ConfigElementImplementationRegistryMother.withNoPlugins();
        CachedGoPartials cachedGoPartials = new CachedGoPartials(serverHealthService);
        FullConfigSaveNormalFlow normalFlow = new FullConfigSaveNormalFlow(configCache, configElementImplementationRegistry, systemEnvironment, new ServerVersion(), new TimeProvider(), configRepository, cachedGoPartials);
        GoFileConfigDataSource dataSource = new GoFileConfigDataSource(new DoNotUpgrade(), configRepository, systemEnvironment, new TimeProvider(), configCache, new ServerVersion(), configElementImplementationRegistry, serverHealthService, cachedGoPartials, null, normalFlow);
        dataSource.upgradeIfNecessary();
        CachedGoConfig cachedConfigService = new CachedGoConfig(serverHealthService, dataSource, cachedGoPartials, null, null);
        cachedConfigService.loadConfigIfNull();
        return new GoConfigDao(cachedConfigService);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) IOException(java.io.IOException) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService)

Example 9 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class ConfigUtilTest method shouldGetAllTasks.

@Test
public void shouldGetAllTasks() {
    ConfigElementImplementationRegistry registry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
    registry.registerImplementer(Task.class, AntTask.class, ExecTask.class, NantTask.class, RakeTask.class, FetchTask.class);
    List<String> tasks = ConfigUtil.allTasks(registry);
    assertThat(tasks, hasItem("ant"));
    assertThat(tasks, hasItem("exec"));
    assertThat(tasks, hasItem("nant"));
    assertThat(tasks, hasItem("rake"));
    assertThat(tasks, hasItem("fetchartifact"));
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) NoPluginsInstalled(com.thoughtworks.go.config.registry.NoPluginsInstalled) Test(org.junit.Test)

Example 10 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class UniqueOnCancelValidatorTest method shouldFailWithExceptionWhenThereIsMoreThanOneOnCancelTasksForAPluginInTask.

@Test
public void shouldFailWithExceptionWhenThereIsMoreThanOneOnCancelTasksForAPluginInTask() 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=\"blah1\" />\n" + "                </oncancel>\n" + "                <oncancel>\n" + "                  <ant buildfile=\"blah\" target=\"blah2\" />\n" + "                </oncancel>\n" + "              </task>" + "          </tasks>" + "        </job>" + "      </jobs>" + "    </stage>" + "  </pipeline>" + "</cruise>";
    try {
        UniqueOnCancelValidator validator = new UniqueOnCancelValidator();
        validator.validate(elementFor(content), registry);
    } catch (Exception e) {
        assertThat(e.getMessage(), is("Task [task] should not contain more than 1 oncancel task"));
    }
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ExecTask(com.thoughtworks.go.config.ExecTask) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) IOException(java.io.IOException) JDOMException(org.jdom2.JDOMException) Test(org.junit.Test)

Aggregations

ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)24 Test (org.junit.Test)13 ExecTask (com.thoughtworks.go.config.ExecTask)8 ConfigRepository (com.thoughtworks.go.service.ConfigRepository)7 Before (org.junit.Before)7 NoPluginsInstalled (com.thoughtworks.go.config.registry.NoPluginsInstalled)4 ServerVersion (com.thoughtworks.go.server.util.ServerVersion)4 TimeProvider (com.thoughtworks.go.util.TimeProvider)4 IOException (java.io.IOException)4 AntTask (com.thoughtworks.go.config.AntTask)3 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)3 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)3 ConfigCache (com.thoughtworks.go.config.ConfigCache)2 FetchTask (com.thoughtworks.go.config.FetchTask)2 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)2 ConfigElementImplementationRegistrar (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistrar)2 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)2 UserDao (com.thoughtworks.go.server.dao.UserDao)2 PipelineRepository (com.thoughtworks.go.server.persistence.PipelineRepository)2 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)2