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")));
}
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;
}
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);
}
}
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"));
}
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"));
}
}
Aggregations