Search in sources :

Example 1 with ConfigCache

use of com.thoughtworks.go.config.ConfigCache in project gocd by gocd.

the class BuildWorkTest method createBuildWorkWithJobPlan.

private void createBuildWorkWithJobPlan(JobPlan jobPlan) throws Exception {
    CruiseConfig cruiseConfig = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(FileUtil.readToEnd(IOUtils.toInputStream(ConfigFileFixture.withJob(CMD_NOT_EXIST)))).config;
    JobConfig jobConfig = cruiseConfig.jobConfigByName(PIPELINE_NAME, STAGE_NAME, JOB_PLAN_NAME, true);
    final Stage stage = StageMother.custom(STAGE_NAME, new JobInstance(JOB_PLAN_NAME));
    BuildCause buildCause = BuildCause.createWithEmptyModifications();
    final Pipeline pipeline = new Pipeline(PIPELINE_NAME, buildCause, stage);
    List<Builder> builder = builderFactory.buildersForTasks(pipeline, jobConfig.getTasks(), resolver);
    BuildAssignment buildAssignment = BuildAssignment.create(jobPlan, BuildCause.createWithEmptyModifications(), builder, pipeline.defaultWorkingFolder());
    buildWork = new BuildWork(buildAssignment);
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) Builder(com.thoughtworks.go.domain.builder.Builder) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) JobConfig(com.thoughtworks.go.config.JobConfig) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 2 with ConfigCache

use of com.thoughtworks.go.config.ConfigCache 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 ConfigCache

use of com.thoughtworks.go.config.ConfigCache in project gocd by gocd.

the class EntityHashingServiceTest method setUp.

@Before
public void setUp() {
    this.goConfigService = mock(GoConfigService.class);
    this.goCache = mock(GoCache.class);
    this.configCache = new ConfigCache();
    this.registry = ConfigElementImplementationRegistryMother.withNoPlugins();
    this.entityHashingService = new EntityHashingService(this.goConfigService, this.goCache, configCache, registry);
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) GoCache(com.thoughtworks.go.server.cache.GoCache) Before(org.junit.Before)

Example 4 with ConfigCache

use of com.thoughtworks.go.config.ConfigCache in project gocd by gocd.

the class GoConfigAdministrationControllerIntegrationTest method shouldConflictWhenGivenMd5IsDifferent.

@Test
public void shouldConflictWhenGivenMd5IsDifferent() throws Exception {
    configHelper.addPipeline("pipeline", "stage", "build1", "build2");
    controller.getCurrentConfigXml("crapy_md5", response);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    new MagicalGoConfigXmlWriter(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).write(goConfigDao.loadForEditing(), os, true);
    assertValidContentAndStatus(SC_CONFLICT, "text/plain; charset=utf-8", CONFIG_CHANGED_PLEASE_REFRESH);
    assertThat(response.getHeader(XmlAction.X_CRUISE_CONFIG_MD5), is(goConfigDao.md5OfConfigFile()));
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MagicalGoConfigXmlWriter(com.thoughtworks.go.config.MagicalGoConfigXmlWriter) Test(org.junit.jupiter.api.Test)

Example 5 with ConfigCache

use of com.thoughtworks.go.config.ConfigCache in project gocd by gocd.

the class GoConfigAdministrationControllerIntegrationTest method shouldGetConfigAsXml.

@Test
public void shouldGetConfigAsXml() throws Exception {
    configHelper.addPipeline("pipeline", "stage", "build1", "build2");
    controller.getCurrentConfigXml(null, response);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    new MagicalGoConfigXmlWriter(new ConfigCache(), registry).write(goConfigDao.loadForEditing(), os, true);
    assertValidContentAndStatus(SC_OK, "text/xml", os.toString());
    assertThat(response.getHeader(XmlAction.X_CRUISE_CONFIG_MD5), is(goConfigDao.md5OfConfigFile()));
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MagicalGoConfigXmlWriter(com.thoughtworks.go.config.MagicalGoConfigXmlWriter) 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