Search in sources :

Example 1 with ExecCreated

use of org.eclipse.che.plugin.docker.client.json.ExecCreated in project che by eclipse.

the class DockerConnectorTest method shouldBeAbleToCreateExec.

@Test
public void shouldBeAbleToCreateExec() throws IOException, JsonParseException {
    CreateExecParams createExecParams = CreateExecParams.create(CONTAINER, CMD_WITH_ARGS);
    Exec exec = new Exec(CMD_WITH_ARGS, EXEC_ID);
    ExecCreated execCreated = mock(ExecCreated.class);
    doReturn(execCreated).when(dockerConnector).parseResponseStreamAndClose(inputStream, ExecCreated.class);
    when(execCreated.getId()).thenReturn(EXEC_ID);
    Exec returnedExec = dockerConnector.createExec(createExecParams);
    verify(dockerConnectionFactory).openConnection(any(URI.class));
    verify(dockerConnection).method(REQUEST_METHOD_POST);
    verify(dockerConnection).path("/containers/" + createExecParams.getContainer() + "/exec");
    verify(dockerConnection).header("Content-Type", MediaType.APPLICATION_JSON);
    verify(dockerConnection).header(eq("Content-Length"), anyInt());
    verify(dockerConnection).entity(any(byte[].class));
    verify(dockerConnection).request();
    verify(dockerResponse).getStatus();
    verify(dockerResponse).getInputStream();
    assertEquals(returnedExec, exec);
}
Also used : CreateExecParams(org.eclipse.che.plugin.docker.client.params.CreateExecParams) ExecCreated(org.eclipse.che.plugin.docker.client.json.ExecCreated) URI(java.net.URI) Test(org.testng.annotations.Test)

Aggregations

URI (java.net.URI)1 ExecCreated (org.eclipse.che.plugin.docker.client.json.ExecCreated)1 CreateExecParams (org.eclipse.che.plugin.docker.client.params.CreateExecParams)1 Test (org.testng.annotations.Test)1