Search in sources :

Example 1 with GetContainerLogsParams

use of org.eclipse.che.plugin.docker.client.params.GetContainerLogsParams in project che by eclipse.

the class DockerConnectorTest method shouldBeAbleToGetContainerLogs.

@Test
public void shouldBeAbleToGetContainerLogs() throws IOException {
    GetContainerLogsParams getContainerLogsParams = GetContainerLogsParams.create(CONTAINER);
    when(dockerResponse.getInputStream()).thenReturn(new ByteArrayInputStream(DOCKER_RESPONSE_BYTES));
    dockerConnector.getContainerLogs(getContainerLogsParams, logMessageProcessor);
    verify(dockerConnectionFactory).openConnection(any(URI.class));
    verify(dockerConnection).method(REQUEST_METHOD_GET);
    verify(dockerConnection).path("/containers/" + getContainerLogsParams.getContainer() + "/logs");
    verify(dockerConnection).query("stdout", 1);
    verify(dockerConnection).query("stderr", 1);
    verify(dockerConnection).request();
    verify(dockerResponse).getStatus();
    verify(dockerResponse).getInputStream();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) GetContainerLogsParams(org.eclipse.che.plugin.docker.client.params.GetContainerLogsParams) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 2 with GetContainerLogsParams

use of org.eclipse.che.plugin.docker.client.params.GetContainerLogsParams in project che by eclipse.

the class DockerConnectorTest method shouldThrowContainerNotFoundExceptionWhileGettingContainerLogsIfResponseCodeIs404.

@Test(expectedExceptions = ContainerNotFoundException.class)
public void shouldThrowContainerNotFoundExceptionWhileGettingContainerLogsIfResponseCodeIs404() throws IOException {
    GetContainerLogsParams getContainerLogsParams = GetContainerLogsParams.create(CONTAINER);
    when(dockerResponse.getInputStream()).thenReturn(new ByteArrayInputStream("container not found".getBytes()));
    when(dockerResponse.getStatus()).thenReturn(RESPONSE_NOT_FOUND_CODE);
    dockerConnector.getContainerLogs(getContainerLogsParams, logMessageProcessor);
    verify(dockerResponse).getStatus();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) GetContainerLogsParams(org.eclipse.che.plugin.docker.client.params.GetContainerLogsParams) Test(org.testng.annotations.Test)

Example 3 with GetContainerLogsParams

use of org.eclipse.che.plugin.docker.client.params.GetContainerLogsParams in project che by eclipse.

the class DockerConnectorTest method shouldThrowDockerExceptionWhileGettingContainerLogsIfResponseCodeIs5xx.

@Test(expectedExceptions = DockerException.class, expectedExceptionsMessageRegExp = EXCEPTION_ERROR_MESSAGE)
public void shouldThrowDockerExceptionWhileGettingContainerLogsIfResponseCodeIs5xx() throws IOException {
    GetContainerLogsParams getContainerLogsParams = GetContainerLogsParams.create(CONTAINER);
    when(dockerResponse.getStatus()).thenReturn(RESPONSE_ERROR_CODE);
    dockerConnector.getContainerLogs(getContainerLogsParams, logMessageProcessor);
    verify(dockerResponse).getStatus();
}
Also used : GetContainerLogsParams(org.eclipse.che.plugin.docker.client.params.GetContainerLogsParams) Test(org.testng.annotations.Test)

Aggregations

GetContainerLogsParams (org.eclipse.che.plugin.docker.client.params.GetContainerLogsParams)3 Test (org.testng.annotations.Test)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URI (java.net.URI)1