use of org.eclipse.che.plugin.docker.client.params.GetResourceParams in project che by eclipse.
the class DockerConnectorTest method shouldProduceErrorWhenGetsResourcesFromContainerIfResponseCodeIsNotSuccess.
@Test(expectedExceptions = IOException.class, expectedExceptionsMessageRegExp = EXCEPTION_ERROR_MESSAGE)
public void shouldProduceErrorWhenGetsResourcesFromContainerIfResponseCodeIsNotSuccess() throws IOException {
GetResourceParams getResourceParams = GetResourceParams.create(CONTAINER, PATH_TO_FILE);
when(dockerResponse.getStatus()).thenReturn(RESPONSE_ERROR_CODE);
when(dockerResponse.getInputStream()).thenReturn(new CloseConnectionInputStream(new ByteArrayInputStream(ERROR_MESSAGE.getBytes()), dockerConnection));
dockerConnector.getResource(getResourceParams);
verify(dockerResponse).getStatus();
}
use of org.eclipse.che.plugin.docker.client.params.GetResourceParams in project che by eclipse.
the class DockerConnectorTest method shouldBeAbleToGetResourcesFromContainer.
@Test
public void shouldBeAbleToGetResourcesFromContainer() throws IOException {
GetResourceParams getResourceParams = GetResourceParams.create(CONTAINER, PATH_TO_FILE);
when(dockerResponse.getInputStream()).thenReturn(new CloseConnectionInputStream(new ByteArrayInputStream(STREAM_DATA_BYTES), dockerConnection));
String response = CharStreams.toString(new InputStreamReader(dockerConnector.getResource(getResourceParams)));
verify(dockerConnectionFactory).openConnection(any(URI.class));
verify(dockerConnection).method(REQUEST_METHOD_GET);
verify(dockerConnection).path("/containers/" + getResourceParams.getContainer() + "/archive");
verify(dockerConnection).query(eq("path"), eq(PATH_TO_FILE));
verify(dockerConnection).request();
verify(dockerResponse).getStatus();
verify(dockerResponse).getInputStream();
assertEquals(response, STREAM_DATA);
}
Aggregations