Search in sources :

Example 26 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class MessageTest method encodeAndDecodeAssignWorkWithDifferentBuilders.

@Test
public void encodeAndDecodeAssignWorkWithDifferentBuilders() throws Exception {
    File workingDir = new File(CruiseConfig.WORKING_BASE_DIR + "pipelineName");
    Materials materials = MaterialsMother.defaultMaterials();
    MaterialRevisions revisions = ModificationsMother.modifyOneFile(materials, ModificationsMother.nextRevision());
    BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
    List<Builder> builder = new ArrayList<>();
    builder.add(new CommandBuilder("command", "args", workingDir, new RunIfConfigs(), new NullBuilder(), "desc"));
    builder.add(new BuilderForKillAllChildTask());
    builder.add(new CommandBuilderWithArgList("command", new String[] { "arg1", "arg2" }, workingDir, new RunIfConfigs(), new NullBuilder(), "desc"));
    builder.add(new FetchArtifactBuilder(new RunIfConfigs(), new NullBuilder(), "desc", jobPlan().getIdentifier(), "srcdir", "dest", new FileHandler(workingDir, "src"), new ChecksumFileHandler(workingDir)));
    BuildAssignment assignment = BuildAssignment.create(jobPlan(), buildCause, builder, workingDir, new EnvironmentVariableContext(), new ArtifactStores());
    BuildWork work = new BuildWork(assignment, "utf-8");
    byte[] msg = MessageEncoding.encodeMessage(new Message(Action.assignWork, MessageEncoding.encodeWork(work)));
    Message decodedMsg = MessageEncoding.decodeMessage(new ByteArrayInputStream(msg));
    BuildWork decodedWork = (BuildWork) MessageEncoding.decodeWork(decodedMsg.getData());
    assertThat(decodedWork.getAssignment().getJobIdentifier().getPipelineName(), is("pipelineName"));
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) Materials(com.thoughtworks.go.config.materials.Materials) ArrayList(java.util.ArrayList) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) BuildWork(com.thoughtworks.go.remote.work.BuildWork) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) ByteArrayInputStream(java.io.ByteArrayInputStream) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) File(java.io.File) Test(org.junit.Test)

Example 27 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class MergeEnvironmentConfigTest method shouldAddDeduplicatedEnvironmentVariablesToEnvironmentVariableContextFrom2Parts.

@Test
public void shouldAddDeduplicatedEnvironmentVariablesToEnvironmentVariableContextFrom2Parts() throws Exception {
    pairEnvironmentConfig.get(0).addEnvironmentVariable("variable-name1", "variable-value1");
    pairEnvironmentConfig.get(1).addEnvironmentVariable("variable-name1", "variable-value1");
    assertThat(pairEnvironmentConfig.getVariables().size(), is(1));
    EnvironmentVariableContext context = pairEnvironmentConfig.createEnvironmentContext();
    assertThat(context.getProperty("variable-name1"), is("variable-value1"));
}
Also used : EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 28 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class EnvironmentConfigTestBase method shouldAddEnvironmentNameToEnvironmentVariableContext.

@Test
public void shouldAddEnvironmentNameToEnvironmentVariableContext() throws Exception {
    EnvironmentConfig another = new BasicEnvironmentConfig(new CaseInsensitiveString("other"));
    EnvironmentVariableContext context = another.createEnvironmentContext();
    assertThat(context.getProperty(EnvironmentVariableContext.GO_ENVIRONMENT_NAME), is("other"));
}
Also used : EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 29 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class EnvironmentConfigTestBase method shouldAddEnvironmentVariablesToEnvironmentVariableContext.

@Test
public void shouldAddEnvironmentVariablesToEnvironmentVariableContext() throws Exception {
    EnvironmentConfig another = new BasicEnvironmentConfig(new CaseInsensitiveString("other"));
    another.addEnvironmentVariable("variable-name", "variable-value");
    EnvironmentVariableContext context = another.createEnvironmentContext();
    assertThat(context.getProperty("variable-name"), is("variable-value"));
}
Also used : EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 30 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class AgentStatusReportingTest method before.

@Before
public void before() {
    agentIdentifier = new AgentIdentifier("localhost", "127.0.0.1", "uuid");
    environmentVariableContext = new EnvironmentVariableContext();
    artifactManipulator = new GoArtifactsManipulatorStub();
    buildRepository = new com.thoughtworks.go.remote.work.BuildRepositoryRemoteStub();
    this.agentRuntimeInfo = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Before(org.junit.Before)

Aggregations

EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)94 Test (org.junit.Test)74 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)19 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)16 File (java.io.File)14 Date (java.util.Date)13 Modification (com.thoughtworks.go.domain.materials.Modification)12 Modifications (com.thoughtworks.go.domain.materials.Modifications)10 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)9 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)9 Before (org.junit.Before)8 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)7 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)6 Materials (com.thoughtworks.go.config.materials.Materials)6 Builder (com.thoughtworks.go.domain.builder.Builder)6 HashMap (java.util.HashMap)6 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)5 RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)5 PackageMaterialRevision (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision)5 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)5