@Autowired public PipelineConfigsService(ConfigCache configCache, ConfigElementImplementationRegistry registry, GoConfigService goConfigService, SecurityService securityService) { this.goConfigService = goConfigService; this.configCache = configCache; this.registry = registry; this.securityService = securityService; this.magicalGoConfigXmlLoader = new MagicalGoConfigXmlLoader(configCache, registry); }
@Autowired public GoConfigMigrator(GoConfigMigration goConfigMigration, SystemEnvironment systemEnvironment, ConfigCache configCache, ConfigElementImplementationRegistry registry, FullConfigSaveNormalFlow fullConfigSaveNormalFlow, ConfigRepository configRepository, ServerHealthService serverHealthService) { this(goConfigMigration, systemEnvironment, fullConfigSaveNormalFlow, new MagicalGoConfigXmlLoader(configCache, registry), new GoConfigFileReader(systemEnvironment), configRepository, serverHealthService); }
@Autowired public FullConfigSaveMergeFlow(ConfigCache configCache, ConfigElementImplementationRegistry configElementImplementationRegistry, SystemEnvironment systemEnvironment, TimeProvider timeProvider, ConfigRepository configRepository, CachedGoPartials cachedGoPartials) { this(new MagicalGoConfigXmlLoader(configCache, configElementImplementationRegistry), new MagicalGoConfigXmlWriter(configCache, configElementImplementationRegistry), configElementImplementationRegistry, timeProvider, configRepository, cachedGoPartials, new GoConfigFileWriter(systemEnvironment)); }
@Autowired public FullConfigSaveNormalFlow(ConfigCache configCache, ConfigElementImplementationRegistry configElementImplementationRegistry, SystemEnvironment systemEnvironment, TimeProvider timeProvider, ConfigRepository configRepository, CachedGoPartials cachedGoPartials) { this(new MagicalGoConfigXmlLoader(configCache, configElementImplementationRegistry), new MagicalGoConfigXmlWriter(configCache, configElementImplementationRegistry), configElementImplementationRegistry, timeProvider, configRepository, cachedGoPartials, new GoConfigFileWriter(systemEnvironment)); }
protected ConfigSaveState saveConfig(final String xmlString, final String md5) throws Exception { LOGGER.debug("[Config Save] Started saving XML"); final MagicalGoConfigXmlLoader configXmlLoader = new MagicalGoConfigXmlLoader(configCache, registry); LOGGER.debug("[Config Save] Updating config"); final CruiseConfig deserializedConfig = configXmlLoader.deserializeConfig(xmlString); ConfigSaveState configSaveState = systemEnvironment.optimizeFullConfigSave() ? saveConfigNewFlow(deserializedConfig, md5) : saveConfigOldFlow(deserializedConfig, md5); LOGGER.debug("[Config Save] Finished saving XML"); return configSaveState; }
@Autowired public GoFileConfigDataSource(GoConfigMigration upgrader, ConfigRepository configRepository, SystemEnvironment systemEnvironment, TimeProvider timeProvider, ConfigCache configCache, ConfigElementImplementationRegistry configElementImplementationRegistry, ServerHealthService serverHealthService, CachedGoPartials cachedGoPartials, FullConfigSaveMergeFlow fullConfigSaveMergeFlow, FullConfigSaveNormalFlow fullConfigSaveNormalFlow) { this(upgrader, configRepository, systemEnvironment, timeProvider, new MagicalGoConfigXmlLoader(configCache, configElementImplementationRegistry), new MagicalGoConfigXmlWriter(configCache, configElementImplementationRegistry), serverHealthService, cachedGoPartials, fullConfigSaveMergeFlow, fullConfigSaveNormalFlow, new GoConfigFileReader(systemEnvironment), new GoConfigFileWriter(systemEnvironment)); this.configElementImplementationRegistry = configElementImplementationRegistry; }
public static GoConfigHolder loadWithMigration(InputStream input, final ConfigElementImplementationRegistry registry) throws Exception { File tempFile = TestFileUtil.createTempFile("cruise-config.xml"); try { MagicalGoConfigXmlLoader xmlLoader = new MagicalGoConfigXmlLoader(new ConfigCache(), registry); FileUtils.copyInputStreamToFile(input, tempFile); migrate(tempFile); return xmlLoader.loadConfigHolder(FileUtils.readFileToString(tempFile, UTF_8)); } finally { FileUtils.deleteQuietly(tempFile); } }
@Test public void shouldGetConfigRepoPreprocessor() { MagicalGoConfigXmlLoader loader = new MagicalGoConfigXmlLoader(null, null); assertThat(loader.getPreprocessorOfType(ConfigRepoPartialPreprocessor.class) instanceof ConfigRepoPartialPreprocessor, is(true)); assertThat(loader.getPreprocessorOfType(ConfigParamPreprocessor.class) instanceof ConfigParamPreprocessor, is(true)); }
@Before public void setup() { output = new ByteArrayOutputStream(); ConfigCache configCache = new ConfigCache(); xmlWriter = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins()); xmlLoader = new MagicalGoConfigXmlLoader(configCache, ConfigElementImplementationRegistryMother.withNoPlugins()); } }
public static CruiseConfig load(String content) { try { ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins(); return new MagicalGoConfigXmlLoader(new ConfigCache(), registry).loadConfigHolder(migrate(content)).config; } catch (Exception e) { throw new RuntimeException(e); } } }
@Before public void setUp() throws Exception { loader = new MagicalGoConfigXmlLoader(configCache, ConfigElementImplementationRegistryMother.withNoPlugins()); writer = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins()); }
@Test public void shouldNotKillAllChildrenWhenEmptyOnCancel() throws Exception { RakeTask rakeTask = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).fromXmlPartial( "<rake>" + " <oncancel />" + "</rake>", RakeTask.class ); assertThat(rakeTask.cancelTask(), is(instanceOf(NullTask.class))); } }
@Before public void setUp() throws Exception { loader = new MagicalGoConfigXmlLoader(configCache, ConfigElementImplementationRegistryMother.withNoPlugins()); writer = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins()); }
@Before public void setup() throws Exception { RepositoryMetadataStoreHelper.clear(); ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins(); xmlLoader = new MagicalGoConfigXmlLoader(configCache, registry); xmlWriter = new MagicalGoConfigXmlWriter(configCache, registry); }
@Before public void setUp() throws Exception { config = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder( ConfigFileFixture.CONFIG).configForEdit; }
@Test public void shouldBeAbleToParseNewAuthorization() throws Exception { AuthConfig config = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).fromXmlPartial(NEW_AUTHORIZATION, AuthConfig.class); assertThat(config.size(), is(3)); }
@Test public void shouldSupportEmptyPipelineGroup() throws Exception { PipelineConfigs group = new BasicPipelineConfigs("defaultGroup", new Authorization()); CruiseConfig config = new BasicCruiseConfig(group); ByteArrayOutputStream stream = new ByteArrayOutputStream(); new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins()).write(config, stream, true); GoConfigHolder configHolder = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()) .loadConfigHolder(stream.toString()); assertThat(configHolder.config.findGroup("defaultGroup"), is(group)); }
@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"))); } }
@Before public void setUp() throws Exception { writer = new MagicalGoConfigXmlWriter(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()); loader = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()); config = GoConfigMother.configWithPipelines("pipeline1", "pipeline2", "pipeline3", "go"); pipelineConfig = config.getAllPipelineConfigs().get(0); }
@Test public void shouldAllowUnorderedRoleAndUserInXsd() throws Exception { CruiseConfig config = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(ConfigMigrator.migrate( ConfigFileFixture.DEFAULT_XML_WITH_2_AGENTS)).configForEdit; config.setServerConfig(new ServerConfig("dir", security(null, admins(role("role2"), user("jez"), role("role1"))))); new MagicalGoConfigXmlWriter(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).write(config, new ByteArrayOutputStream(), false); } }