use of org.eclipse.che.plugin.docker.client.params.PutResourceParams in project che by eclipse.
the class DockerConnectorTest method shouldProduceErrorWhenPutsResourcesIntoContainerIfResponseCodeIsNotSuccess.
@Test(expectedExceptions = IOException.class, expectedExceptionsMessageRegExp = EXCEPTION_ERROR_MESSAGE)
public void shouldProduceErrorWhenPutsResourcesIntoContainerIfResponseCodeIsNotSuccess() throws IOException {
InputStream source = new CloseConnectionInputStream(new ByteArrayInputStream(ERROR_MESSAGE.getBytes()), dockerConnection);
PutResourceParams putResourceParams = PutResourceParams.create(CONTAINER, PATH_TO_FILE, source);
when(dockerResponse.getStatus()).thenReturn(RESPONSE_ERROR_CODE);
when(dockerResponse.getInputStream()).thenReturn(new ByteArrayInputStream(ERROR_MESSAGE.getBytes()));
dockerConnector.putResource(putResourceParams);
verify(dockerResponse).getStatus();
}
use of org.eclipse.che.plugin.docker.client.params.PutResourceParams in project che by eclipse.
the class DockerConnectorTest method shouldBeAbleToPutResourcesIntoContainer.
@Test
public void shouldBeAbleToPutResourcesIntoContainer() throws IOException {
InputStream source = new CloseConnectionInputStream(new ByteArrayInputStream(STREAM_DATA_BYTES), dockerConnection);
PutResourceParams putResourceParams = PutResourceParams.create(CONTAINER, PATH_TO_FILE, source);
dockerConnector.putResource(putResourceParams);
verify(dockerConnectionFactory).openConnection(any(URI.class));
verify(dockerConnection).method(REQUEST_METHOD_PUT);
verify(dockerConnection).path("/containers/" + putResourceParams.getContainer() + "/archive");
verify(dockerConnection).query(eq("path"), eq(PATH_TO_FILE));
verify(dockerConnection).header("Content-Type", ExtMediaType.APPLICATION_X_TAR);
verify(dockerConnection).header(eq("Content-Length"), anyInt());
verify(dockerConnection).entity(any(InputStream.class));
verify(dockerConnection).request();
verify(dockerResponse).getStatus();
}
Aggregations